Qt 4.8
maemo_icd.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 
43 #include "maemo_icd.h"
44 #include "dbusdispatcher.h"
45 
46 #include <QObject>
47 #include <QTimer>
48 #include <QCoreApplication>
49 #include <QEventLoop>
50 #include <QDebug>
51 #include <dbus/dbus.h>
52 #include <dbus/dbus-glib-lowlevel.h>
53 
54 #include <stdio.h>
55 #include <sys/time.h>
56 #include <sys/types.h>
57 #include <unistd.h>
58 
59 namespace Maemo {
60 
61 #undef PRINT_DEBUGINFO
62 #ifdef PRINT_DEBUGINFO
63  static FILE *fdebug = NULL;
64 #define PDEBUG(fmt, args...) \
65  do { \
66  struct timeval tv; \
67  gettimeofday(&tv, 0); \
68  fprintf(fdebug, "DEBUG[%d]:%ld.%ld:%s:%s():%d: " fmt, \
69  getpid(), \
70  tv.tv_sec, tv.tv_usec, \
71  __FILE__, __FUNCTION__, __LINE__, args); \
72  fflush(fdebug); \
73  } while(0)
74 #else
75 #define PDEBUG(fmt...)
76 #endif
77 
78 
80 {
81 public:
82  IcdPrivate(Icd *myfriend)
83  {
84  init(10000, IcdNewDbusInterface, myfriend);
85  }
86 
87  IcdPrivate(unsigned int timeout, Icd *myfriend)
88  {
89  init(timeout, IcdNewDbusInterface, myfriend);
90  }
91 
92  IcdPrivate(unsigned int timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
93  {
94  Q_UNUSED(ver);
95 
96  /* Note that the old Icd interface is currently disabled and
97  * the new one is always used.
98  */
99  init(timeout, IcdNewDbusInterface, myfriend);
100  }
101 
103  {
105  SIGNAL(signalReceived(const QString&,
106  const QString&,
107  const QList<QVariant>&)),
108  icd,
109  SLOT(icdSignalReceived(const QString&,
110  const QString&,
111  const QList<QVariant>&)));
112 
114  SIGNAL(callReply(const QString&,
115  const QList<QVariant>&,
116  const QString&)),
117  icd,
118  SLOT(icdCallReply(const QString&,
119  const QList<QVariant>&,
120  const QString&)));
121 
122  delete mDBus;
123  mDBus = 0;
124  }
125 
126  /* Icd2 dbus API functions */
127  QStringList scan(icd_scan_request_flags flags,
128  QStringList &network_types,
129  QList<IcdScanResult>& scan_results,
130  QString& error);
131 
132  uint state(QString& service_type, uint service_attrs,
133  QString& service_id, QString& network_type,
134  uint network_attrs, QByteArray& network_id,
135  IcdStateResult &state_result);
136 
137  uint addrinfo(QString& service_type, uint service_attrs,
138  QString& service_id, QString& network_type,
139  uint network_attrs, QByteArray& network_id,
140  IcdAddressInfoResult& addr_result);
141 
142  uint state(QList<IcdStateResult>& state_results);
145 
146  void signalReceived(const QString& interface,
147  const QString& signal,
148  const QList<QVariant>& args);
149  void callReply(const QString& method,
150  const QList<QVariant>& args,
151  const QString& error);
152 
153 public:
161  unsigned int timeout;
164 
165  void init(unsigned int dbus_timeout, IcdDbusInterfaceVer ver,
166  Icd *myfriend)
167  {
168  if (ver == IcdNewDbusInterface) {
169  mDBus = new DBusDispatcher(ICD_DBUS_API_INTERFACE,
170  ICD_DBUS_API_PATH,
171  ICD_DBUS_API_INTERFACE);
172  } else {
173  mDBus = new DBusDispatcher(ICD_DBUS_SERVICE,
174  ICD_DBUS_PATH,
175  ICD_DBUS_INTERFACE);
176  }
177  icd_dbus_version = ver;
178 
179  /* This connect has a side effect as it means that only one
180  * Icd object can exists in one time. This should be fixed!
181  */
182  QObject::connect(mDBus,
183  SIGNAL(signalReceived(const QString&,
184  const QString&,
185  const QList<QVariant>&)),
186  myfriend,
187  SLOT(icdSignalReceived(const QString&,
188  const QString&,
189  const QList<QVariant>&)));
190 
191  QObject::connect(mDBus,
192  SIGNAL(callReply(const QString&,
193  const QList<QVariant>&,
194  const QString&)),
195  myfriend,
196  SLOT(icdCallReply(const QString&,
197  const QList<QVariant>&,
198  const QString&)));
199 
200  icd = myfriend;
201  timeout = dbus_timeout;
202 
203 #ifdef PRINT_DEBUGINFO
204  if (!fdebug) {
205  fdebug = fopen("/tmp/maemoicd.log", "a+");
206  }
207  PDEBUG("created %s\n", "IcdPrivate");
208 #endif
209  }
210 
211  void clearState()
212  {
213  mMethod.clear();
214  mInterface.clear();
215  mSignal.clear();
216  mError.clear();
217  mArgs.clear();
218  receivedSignals.clear();
219  }
220 
221  bool doState();
222 };
223 
224 
225 void IcdPrivate::signalReceived(const QString& interface,
226  const QString& signal,
227  const QList<QVariant>& args)
228 {
229  // Signal handler, which simply records what has been signalled
230  mInterface = interface;
231  mSignal = signal;
232  mArgs = args;
233 
234  //qDebug() << "signal" << signal << "received:" << args;
235  receivedSignals << QVariant(interface) << QVariant(signal) << QVariant(args);
236 }
237 
238 
239 void IcdPrivate::callReply(const QString& method,
240  const QList<QVariant>& /*args*/,
241  const QString& error)
242 {
243  mMethod = method;
244  mError = error;
245 }
246 
247 
249  IcdScanResult& ret)
250 {
251  int i=0;
252 
253  if (args.isEmpty())
254  return;
255 
256  ret.status = args[i++].toUInt();
257  ret.timestamp = args[i++].toUInt();
258  ret.scan.service_type = args[i++].toString();
259  ret.service_name = args[i++].toString();
260  ret.scan.service_attrs = args[i++].toUInt();
261  ret.scan.service_id = args[i++].toString();
262  ret.service_priority = args[i++].toInt();
263  ret.scan.network_type = args[i++].toString();
264  ret.network_name = args[i++].toString();
265  ret.scan.network_attrs = args[i++].toUInt();
266  ret.scan.network_id = args[i++].toByteArray();
267  ret.network_priority = args[i++].toInt();
268  ret.signal_strength = args[i++].toInt();
269  ret.station_id = args[i++].toString();
270  ret.signal_dB = args[i++].toInt();
271 }
272 
273 
274 QStringList IcdPrivate::scan(icd_scan_request_flags flags,
275  QStringList &network_types,
276  QList<IcdScanResult>& scan_results,
277  QString& error)
278 {
279  Q_UNUSED(network_types);
280 
281  QStringList scanned_types;
282  QTimer timer;
283  QVariant reply;
284  QVariantList vl;
285  bool last_result = false;
286  IcdScanResult result;
287  int all_waited;
288 
289  clearState();
290  reply = mDBus->call(ICD_DBUS_API_SCAN_REQ, (uint)flags);
291  if (reply.type() != QVariant::List)
292  return scanned_types;
293  vl = reply.toList();
294  if (vl.isEmpty()) {
295  error = "Scan did not return anything.";
296  return scanned_types;
297  }
298  reply = vl.first();
299  scanned_types = reply.toStringList();
300  //qDebug() << "Scanning:" << scanned_types;
301  all_waited = scanned_types.size();
302 
303  timer.setSingleShot(true);
304  timer.start(timeout);
305 
306  scan_results.clear();
307  while (!last_result) {
308  while (timer.isActive() && mInterface.isEmpty() && mError.isEmpty()) {
310  }
311 
312  if (!timer.isActive()) {
313  //qDebug() << "Timeout happened";
314  break;
315  }
316 
317  if (mSignal != ICD_DBUS_API_SCAN_SIG) {
318  //qDebug() << "Received" << mSignal << "while waiting" << ICD_DBUS_API_SCAN_SIG << ", ignoring";
319  mInterface.clear();
320  continue;
321  }
322 
323  if (mError.isEmpty()) {
324  QString msgInterface = receivedSignals.takeFirst().toString();
325  QString msgSignal = receivedSignals.takeFirst().toString();
327  //qDebug() << "Signal" << msgSignal << "received.";
328  //qDebug() << "Params:" << msgArgs;
329 
330  while (!msgSignal.isEmpty()) {
331  get_scan_result(msgArgs, result);
332 
333 #if 0
334  qDebug() << "Received: " <<
335  "status =" << result.status <<
336  ", timestamp =" << result.timestamp <<
337  ", service_type =" << result.scan.service_type <<
338  ", service_name =" << result.service_name <<
339  ", service_attrs =" << result.scan.service_attrs <<
340  ", service_id =" << result.scan.service_id <<
341  ", service_priority =" << result.service_priority <<
342  ", network_type =" << result.scan.network_type <<
343  ", network_name =" << result.network_name <<
344  ", network_attrs =" << result.scan.network_attrs <<
345  ", network_id =" << "-" <<
346  ", network_priority =" << result.network_priority <<
347  ", signal_strength =" << result.signal_strength <<
348  ", station_id =" << result.station_id <<
349  ", signal_dB =" << result.signal_dB;
350 #endif
351 
352  if (result.status == ICD_SCAN_COMPLETE) {
353  //qDebug() << "waited =" << all_waited;
354  if (--all_waited == 0) {
355  last_result = true;
356  break;
357  }
358  } else
359  scan_results << result;
360 
361  if (receivedSignals.isEmpty())
362  break;
363 
364  msgInterface = receivedSignals.takeFirst().toString();
365  msgSignal = receivedSignals.takeFirst().toString();
366  msgArgs = receivedSignals.takeFirst().toList();
367  }
368  mInterface.clear();
369 
370  } else {
371  qWarning() << "Error while scanning:" << mError;
372  break;
373  }
374  }
375  timer.stop();
376 
377  error = mError;
378  return scanned_types;
379 }
380 
381 
383  IcdStateResult& ret)
384 {
385  int i=0;
386 
387  ret.params.service_type = args[i++].toString();
388  ret.params.service_attrs = args[i++].toUInt();
389  ret.params.service_id = args[i++].toString();
390  ret.params.network_type = args[i++].toString();
391  ret.params.network_attrs = args[i++].toUInt();
392  ret.params.network_id = args[i++].toByteArray();
393  ret.error = args[i++].toString();
394  ret.state = args[i++].toInt();
395 }
396 
397 
399  IcdStateResult& ret)
400 {
401  int i=0;
402 
403  ret.params.network_type = args[i++].toString();
404  ret.state = args[i++].toInt();
405 
406  // Initialize the other values so that the caller can
407  // notice we only returned partial status
408  ret.params.service_type = QString();
409  ret.params.service_attrs = 0;
410  ret.params.service_id = QString();
411  ret.params.network_attrs = 0;
412  ret.params.network_id = QByteArray();
413  ret.error = QString();
414 }
415 
416 
417 uint IcdPrivate::state(QString& service_type, uint service_attrs,
418  QString& service_id, QString& network_type,
419  uint network_attrs, QByteArray& network_id,
420  IcdStateResult& state_result)
421 {
422  QTimer timer;
423  QVariant reply;
424  uint total_signals;
425  QVariantList vl;
426 
427  clearState();
428 
429  reply = mDBus->call(ICD_DBUS_API_STATE_REQ,
430  service_type, service_attrs, service_id,
431  network_type, network_attrs, network_id);
432  if (reply.type() != QVariant::List)
433  return 0;
434  vl = reply.toList();
435  if (vl.isEmpty())
436  return 0;
437  reply = vl.first();
438  total_signals = reply.toUInt();
439  if (!total_signals)
440  return 0;
441 
442  timer.setSingleShot(true);
443  timer.start(timeout);
444 
445  mInterface.clear();
446  while (timer.isActive() && mInterface.isEmpty()) {
448 
449  if (mSignal != ICD_DBUS_API_STATE_SIG) {
450  mInterface.clear();
451  continue;
452  }
453  }
454 
455  timer.stop();
456 
457  if (mError.isEmpty()) {
458  if (!mArgs.isEmpty()) {
459  if (mArgs.size()>2)
460  get_state_all_result(mArgs, state_result);
461  else {
462  // We are not connected as we did not get the status we asked
463  return 0;
464  }
465  }
466  } else {
467  qWarning() << "Error:" << mError;
468  }
469 
470  // The returned value should be one because we asked for one state
471  return total_signals;
472 }
473 
474 
475 /* Special version of the state() call which does not call event loop.
476  * Needed in order to fix NB#175098 where Qt4.7 webkit crashes because event
477  * loop is run when webkit does not expect it. This function is called from
478  * bearer management API syncStateWithInterface() in QNetworkSession
479  * constructor.
480  */
482 {
483  QVariant reply;
484  QVariantList vl;
485  uint signals_left, total_signals;
486  IcdStateResult result;
487  time_t started;
488  int timeout_secs = timeout / 1000;
489 
490  PDEBUG("%s\n", "state_results");
491 
492  clearState();
493  reply = mDBus->call(ICD_DBUS_API_STATE_REQ);
494  if (reply.type() != QVariant::List)
495  return 0;
496  vl = reply.toList();
497  if (vl.isEmpty())
498  return 0;
499  reply = vl.first();
500  signals_left = total_signals = reply.toUInt();
501  if (!signals_left)
502  return 0;
503 
504  started = time(0);
505  state_results.clear();
506  mError.clear();
507  while (signals_left) {
508  mInterface.clear();
509  while ((time(0)<=(started+timeout_secs)) && mInterface.isEmpty()) {
510  mDBus->synchronousDispatch(1000);
512  }
513 
514  if (time(0)>(started+timeout_secs)) {
515  total_signals = 0;
516  break;
517  }
518 
519  if (mSignal != ICD_DBUS_API_STATE_SIG) {
520  continue;
521  }
522 
523  if (mError.isEmpty()) {
524  if (!mArgs.isEmpty()) {
525  if (mArgs.size()==2)
526  get_state_all_result2(mArgs, result);
527  else
528  get_state_all_result(mArgs, result);
529  state_results << result;
530  }
531  signals_left--;
532  } else {
533  qWarning() << "Error:" << mError;
534  break;
535  }
536  }
537 
538  PDEBUG("total_signals=%d\n", total_signals);
539  return total_signals;
540 }
541 
542 
544  IcdStatisticsResult& ret)
545 {
546  int i=0;
547 
548  if (args.isEmpty())
549  return;
550 
551  ret.params.service_type = args[i++].toString();
552  ret.params.service_attrs = args[i++].toUInt();
553  ret.params.service_id = args[i++].toString();
554  ret.params.network_type = args[i++].toString();
555  ret.params.network_attrs = args[i++].toUInt();
556  ret.params.network_id = args[i++].toByteArray();
557  ret.time_active = args[i++].toUInt();
558  ret.signal_strength = (enum icd_nw_levels)args[i++].toUInt();
559  ret.bytes_sent = args[i++].toUInt();
560  ret.bytes_received = args[i++].toUInt();
561 }
562 
563 
565 {
566  QTimer timer;
567  QVariant reply;
568  QVariantList vl;
569  uint signals_left, total_signals;
570  IcdStatisticsResult result;
571 
572  clearState();
573  reply = mDBus->call(ICD_DBUS_API_STATISTICS_REQ);
574  if (reply.type() != QVariant::List)
575  return 0;
576  vl = reply.toList();
577  if (vl.isEmpty())
578  return 0;
579  reply = vl.first();
580  if (reply.type() != QVariant::UInt)
581  return 0;
582  signals_left = total_signals = reply.toUInt();
583 
584  if (!signals_left)
585  return 0;
586 
587  timer.setSingleShot(true);
588  timer.start(timeout);
589  stats_results.clear();
590  while (signals_left) {
591  mInterface.clear();
592  while (timer.isActive() && mInterface.isEmpty()) {
594  }
595 
596  if (!timer.isActive()) {
597  total_signals = 0;
598  break;
599  }
600 
601  if (mSignal != ICD_DBUS_API_STATISTICS_SIG) {
602  continue;
603  }
604 
605  if (mError.isEmpty()) {
607  stats_results << result;
608  signals_left--;
609  } else {
610  qWarning() << "Error:" << mError;
611  break;
612  }
613  }
614  timer.stop();
615 
616  return total_signals;
617 }
618 
619 
622 {
623  int i=0;
624 
625  if (args.isEmpty())
626  return;
627 
628  ret.params.service_type = args[i++].toString();
629  ret.params.service_attrs = args[i++].toUInt();
630  ret.params.service_id = args[i++].toString();
631  ret.params.network_type = args[i++].toString();
632  ret.params.network_attrs = args[i++].toUInt();
633  ret.params.network_id = args[i++].toByteArray();
634 
635  QVariantList vl = args[i].toList();
636  QVariant reply = vl.first();
637  QList<QVariant> lst = reply.toList();
638  for (int k=0; k<lst.size()/6; k=k+6) {
639  IcdIPInformation ip_info;
640  ip_info.address = lst[k].toString();
641  ip_info.netmask = lst[k++].toString();
642  ip_info.default_gateway = lst[k++].toString();
643  ip_info.dns1 = lst[k++].toString();
644  ip_info.dns2 = lst[k++].toString();
645  ip_info.dns3 = lst[k++].toString();
646 
647  ret.ip_info << ip_info;
648  }
649 }
650 
651 
652 /* Special version of the addrinfo() call which does not call event loop.
653  * Needed in order to fix NB#175098 where Qt4.7 webkit crashes because event
654  * loop is run when webkit does not expect it. This function is called from
655  * bearer management API syncStateWithInterface() in QNetworkSession
656  * constructor.
657  */
659 {
660  QVariant reply;
661  QVariantList vl;
662  uint signals_left, total_signals;
663  IcdAddressInfoResult result;
664  time_t started;
665  int timeout_secs = timeout / 1000;
666 
667  PDEBUG("%s\n", "addr_results");
668 
669  clearState();
670  reply = mDBus->call(ICD_DBUS_API_ADDRINFO_REQ);
671  if (reply.type() != QVariant::List)
672  return 0;
673  vl = reply.toList();
674  if (vl.isEmpty())
675  return 0;
676  reply = vl.first();
677  if (reply.type() != QVariant::UInt)
678  return 0;
679  signals_left = total_signals = reply.toUInt();
680  if (!signals_left)
681  return 0;
682 
683  started = time(0);
684  addr_results.clear();
685  while (signals_left) {
686  mInterface.clear();
687  while ((time(0)<=(started+timeout_secs)) && mInterface.isEmpty()) {
688  mDBus->synchronousDispatch(1000);
690  }
691 
692  if (time(0)>(started+timeout_secs)) {
693  total_signals = 0;
694  break;
695  }
696 
697  if (mSignal != ICD_DBUS_API_ADDRINFO_SIG) {
698  continue;
699  }
700 
701  if (mError.isEmpty()) {
703  addr_results << result;
704  signals_left--;
705  } else {
706  qWarning() << "Error:" << mError;
707  break;
708  }
709  }
710 
711  PDEBUG("total_signals=%d\n", total_signals);
712  return total_signals;
713 }
714 
715 
716 uint IcdPrivate::addrinfo(QString& service_type, uint service_attrs,
717  QString& service_id, QString& network_type,
718  uint network_attrs, QByteArray& network_id,
719  IcdAddressInfoResult& addr_result)
720 {
721  QTimer timer;
722  QVariant reply;
723  uint total_signals;
724  QVariantList vl;
725 
726  clearState();
727 
728  reply = mDBus->call(ICD_DBUS_API_ADDRINFO_REQ,
729  service_type, service_attrs, service_id,
730  network_type, network_attrs, network_id);
731  if (reply.type() != QVariant::List)
732  return 0;
733  vl = reply.toList();
734  if (vl.isEmpty())
735  return 0;
736  reply = vl.first();
737  total_signals = reply.toUInt();
738 
739  if (!total_signals)
740  return 0;
741 
742  timer.setSingleShot(true);
743  timer.start(timeout);
744 
745  mInterface.clear();
746  while (timer.isActive() && mInterface.isEmpty()) {
748 
749  if (mSignal != ICD_DBUS_API_ADDRINFO_SIG) {
750  mInterface.clear();
751  continue;
752  }
753  }
754 
755  timer.stop();
756 
757  if (mError.isEmpty()) {
758  get_addrinfo_all_result(mArgs, addr_result);
759  } else {
760  qWarning() << "Error:" << mError;
761  }
762 
763  // The returned value should be one because we asked for one addrinfo
764  return total_signals;
765 }
766 
767 
769  : QObject(parent), d(new IcdPrivate(this))
770 {
771 }
772 
773 Icd::Icd(unsigned int timeout, QObject *parent)
774  : QObject(parent), d(new IcdPrivate(timeout, this))
775 {
776 }
777 
778 Icd::Icd(unsigned int timeout, IcdDbusInterfaceVer ver, QObject *parent)
779  : QObject(parent), d(new IcdPrivate(timeout, ver, this))
780 {
781 }
782 
784 {
785  delete d;
786 }
787 
788 
789 QStringList Icd::scan(icd_scan_request_flags flags,
790  QStringList &network_types,
791  QList<IcdScanResult>& scan_results,
792  QString& error)
793 {
794  return d->scan(flags, network_types, scan_results, error);
795 }
796 
797 
798 uint Icd::state(QString& service_type, uint service_attrs,
799  QString& service_id, QString& network_type,
800  uint network_attrs, QByteArray& network_id,
801  IcdStateResult &state_result)
802 {
803  return d->state(service_type, service_attrs, service_id,
804  network_type, network_attrs, network_id,
805  state_result);
806 }
807 
808 
809 uint Icd::addrinfo(QString& service_type, uint service_attrs,
810  QString& service_id, QString& network_type,
811  uint network_attrs, QByteArray& network_id,
812  IcdAddressInfoResult& addr_result)
813 {
814  return d->addrinfo(service_type, service_attrs, service_id,
815  network_type, network_attrs, network_id,
816  addr_result);
817 }
818 
819 
821 {
822  return d->state(state_results);
823 }
824 
825 
827 {
828  return d->statistics(stats_results);
829 }
830 
831 
833 {
834  return d->addrinfo(addr_results);
835 }
836 
837 
838 void Icd::icdSignalReceived(const QString& interface,
839  const QString& signal,
840  const QList<QVariant>& args)
841 {
842  d->signalReceived(interface, signal, args);
843 }
844 
845 
846 void Icd::icdCallReply(const QString& method,
847  const QList<QVariant>& args,
848  const QString& error)
849 {
850  d->callReply(method, args, error);
851 }
852 
853 } // Maemo namespace
854 
855 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static void get_statistics_all_result(QList< QVariant > &args, IcdStatisticsResult &ret)
Definition: maemo_icd.cpp:543
double d
Definition: qnumeric_p.h:62
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
DBusDispatcher is a class that can send DBUS method call messages and receive unicast signals from DB...
uint state(QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdStateResult &state_result)
Definition: maemo_icd.cpp:417
QString network_name
Definition: maemo_icd.h:80
#define error(msg)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static void get_state_all_result2(QList< QVariant > &args, IcdStateResult &ret)
Definition: maemo_icd.cpp:398
QString service_id
Definition: maemo_icd.h:69
#define SLOT(a)
Definition: qobjectdefs.h:226
struct CommonParams scan
Definition: maemo_icd.h:82
QByteArray network_id
Definition: maemo_icd.h:72
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
void icdCallReply(const QString &method, const QList< QVariant > &args, const QString &error)
Definition: maemo_icd.cpp:846
IcdPrivate * d
Definition: maemo_icd.h:168
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
EventLoopTimerRef timer
void synchronousDispatch(int timeout_ms)
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void init(unsigned int dbus_timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
Definition: maemo_icd.cpp:165
DBusDispatcher * mDBus
Definition: maemo_icd.cpp:154
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes all pending events for the calling thread according to the specified flags until there are ...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
Q_CORE_EXPORT void qDebug(const char *,...)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
IcdPrivate(unsigned int timeout, Icd *myfriend)
Definition: maemo_icd.cpp:87
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
unsigned long time_t
QList< QVariant > receivedSignals
Definition: maemo_icd.cpp:160
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
IcdDbusInterfaceVer
Definition: maemo_icd.h:122
QList< QVariant > call(const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
uint addrinfo(QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdAddressInfoResult &addr_result)
Definition: maemo_icd.cpp:716
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT void qWarning(const char *,...)
QStringList scan(icd_scan_request_flags flags, QStringList &network_types, QList< IcdScanResult > &scan_results, QString &error)
Definition: maemo_icd.cpp:274
struct CommonParams params
Definition: maemo_icd.h:101
unsigned int uint
Definition: qglobal.h:996
bool isActive() const
Returns true if the timer is running (pending); otherwise returns false.
Definition: qtimer.h:69
static void sendPostedEvents()
void clear()
Removes all items from the list.
Definition: qlist.h:764
struct CommonParams params
Definition: maemo_icd.h:95
QString service_name
Definition: maemo_icd.h:78
static void get_state_all_result(QList< QVariant > &args, IcdStateResult &ret)
Definition: maemo_icd.cpp:382
QList< IcdIPInformation > ip_info
Definition: maemo_icd.h:119
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
static void get_scan_result(QList< QVariant > &args, IcdScanResult &ret)
Definition: maemo_icd.cpp:248
uint state(QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdStateResult &state_result)
Definition: maemo_icd.cpp:798
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
uint addrinfo(QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdAddressInfoResult &addr_result)
Definition: maemo_icd.cpp:809
IcdDbusInterfaceVer icd_dbus_version
Definition: maemo_icd.cpp:162
QList< QVariant > mArgs
Definition: maemo_icd.cpp:159
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
IcdPrivate(unsigned int timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
Definition: maemo_icd.cpp:92
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
Definition: qvariant.cpp:2644
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void callReply(const QString &method, const QList< QVariant > &args, const QString &error)
Definition: maemo_icd.cpp:239
unsigned int timeout
Definition: maemo_icd.cpp:161
uint statistics(QList< IcdStatisticsResult > &stats_results)
Definition: maemo_icd.cpp:826
enum icd_nw_levels signal_strength
Definition: maemo_icd.h:103
uint statistics(QList< IcdStatisticsResult > &stats_results)
Definition: maemo_icd.cpp:564
void icdSignalReceived(const QString &interface, const QString &signal, const QList< QVariant > &args)
Definition: maemo_icd.cpp:838
QString service_type
Definition: maemo_icd.h:67
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
static void get_addrinfo_all_result(QList< QVariant > &args, IcdAddressInfoResult &ret)
Definition: maemo_icd.cpp:620
void stop()
Stops the timer.
Definition: qtimer.cpp:284
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249
Icd(QObject *parent=0)
Definition: maemo_icd.cpp:768
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
IcdPrivate(Icd *myfriend)
Definition: maemo_icd.cpp:82
void signalReceived(const QString &interface, const QString &signal, const QList< QVariant > &args)
Definition: maemo_icd.cpp:225
QStringList scan(icd_scan_request_flags flags, QStringList &network_types, QList< IcdScanResult > &scan_results, QString &error)
Definition: maemo_icd.cpp:789
struct CommonParams params
Definition: maemo_icd.h:118
#define PDEBUG(fmt...)
Definition: maemo_icd.cpp:75
QString network_type
Definition: maemo_icd.h:70