Qt 4.8
Public Functions | Public Variables | List of all members
Maemo::IcdPrivate Class Reference

Public Functions

uint addrinfo (QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdAddressInfoResult &addr_result)
 
uint addrinfo (QList< IcdAddressInfoResult > &addr_results)
 
void callReply (const QString &method, const QList< QVariant > &args, const QString &error)
 
void clearState ()
 
bool doState ()
 
 IcdPrivate (Icd *myfriend)
 
 IcdPrivate (unsigned int timeout, Icd *myfriend)
 
 IcdPrivate (unsigned int timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
 
void init (unsigned int dbus_timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
 
QStringList scan (icd_scan_request_flags flags, QStringList &network_types, QList< IcdScanResult > &scan_results, QString &error)
 
void signalReceived (const QString &interface, const QString &signal, const QList< QVariant > &args)
 
uint state (QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdStateResult &state_result)
 
uint state (QList< IcdStateResult > &state_results)
 
uint statistics (QList< IcdStatisticsResult > &stats_results)
 
 ~IcdPrivate ()
 

Public Variables

Icdicd
 
IcdDbusInterfaceVer icd_dbus_version
 
QList< QVariantmArgs
 
DBusDispatchermDBus
 
QString mError
 
QString mInterface
 
QString mMethod
 
QString mSignal
 
QList< QVariantreceivedSignals
 
unsigned int timeout
 

Detailed Description

Definition at line 79 of file maemo_icd.cpp.

Constructors and Destructors

◆ IcdPrivate() [1/3]

Maemo::IcdPrivate::IcdPrivate ( Icd myfriend)
inline

Definition at line 82 of file maemo_icd.cpp.

83  {
84  init(10000, IcdNewDbusInterface, myfriend);
85  }
void init(unsigned int dbus_timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
Definition: maemo_icd.cpp:165

◆ IcdPrivate() [2/3]

Maemo::IcdPrivate::IcdPrivate ( unsigned int  timeout,
Icd myfriend 
)
inline

Definition at line 87 of file maemo_icd.cpp.

88  {
89  init(timeout, IcdNewDbusInterface, myfriend);
90  }
void init(unsigned int dbus_timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
Definition: maemo_icd.cpp:165
unsigned int timeout
Definition: maemo_icd.cpp:161

◆ IcdPrivate() [3/3]

Maemo::IcdPrivate::IcdPrivate ( unsigned int  timeout,
IcdDbusInterfaceVer  ver,
Icd myfriend 
)
inline

Definition at line 92 of file maemo_icd.cpp.

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  }
void init(unsigned int dbus_timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
Definition: maemo_icd.cpp:165
unsigned int timeout
Definition: maemo_icd.cpp:161
#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()

Maemo::IcdPrivate::~IcdPrivate ( )
inline

Definition at line 102 of file maemo_icd.cpp.

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  }
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
DBusDispatcher * mDBus
Definition: maemo_icd.cpp:154
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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
void callReply(const QString &method, const QList< QVariant > &args, const QString &error)
Definition: maemo_icd.cpp:239
void signalReceived(const QString &interface, const QString &signal, const QList< QVariant > &args)
Definition: maemo_icd.cpp:225

Functions

◆ addrinfo() [1/2]

uint Maemo::IcdPrivate::addrinfo ( QString service_type,
uint  service_attrs,
QString service_id,
QString network_type,
uint  network_attrs,
QByteArray network_id,
IcdAddressInfoResult addr_result 
)

Definition at line 716 of file maemo_icd.cpp.

Referenced by Maemo::Icd::addrinfo(), and ~IcdPrivate().

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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
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
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
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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())
Q_CORE_EXPORT void qWarning(const char *,...)
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
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
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
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
unsigned int timeout
Definition: maemo_icd.cpp:161
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

◆ addrinfo() [2/2]

uint Maemo::IcdPrivate::addrinfo ( QList< IcdAddressInfoResult > &  addr_results)

Definition at line 658 of file maemo_icd.cpp.

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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
void synchronousDispatch(int timeout_ms)
DBusDispatcher * mDBus
Definition: maemo_icd.cpp:154
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
unsigned long time_t
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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())
Q_CORE_EXPORT void qWarning(const char *,...)
unsigned int uint
Definition: qglobal.h:996
static void sendPostedEvents()
void clear()
Removes all items from the list.
Definition: qlist.h:764
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
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
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
unsigned int timeout
Definition: maemo_icd.cpp:161
static void get_addrinfo_all_result(QList< QVariant > &args, IcdAddressInfoResult &ret)
Definition: maemo_icd.cpp:620
#define PDEBUG(fmt...)
Definition: maemo_icd.cpp:75

◆ callReply()

void Maemo::IcdPrivate::callReply ( const QString method,
const QList< QVariant > &  args,
const QString error 
)

Definition at line 239 of file maemo_icd.cpp.

Referenced by Maemo::Icd::icdCallReply(), init(), and ~IcdPrivate().

242 {
243  mMethod = method;
244  mError = error;
245 }
#define error(msg)

◆ clearState()

void Maemo::IcdPrivate::clearState ( )
inline

Definition at line 211 of file maemo_icd.cpp.

Referenced by addrinfo(), scan(), state(), and statistics().

212  {
213  mMethod.clear();
214  mInterface.clear();
215  mSignal.clear();
216  mError.clear();
217  mArgs.clear();
219  }
QList< QVariant > receivedSignals
Definition: maemo_icd.cpp:160
void clear()
Removes all items from the list.
Definition: qlist.h:764
QList< QVariant > mArgs
Definition: maemo_icd.cpp:159
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723

◆ doState()

bool Maemo::IcdPrivate::doState ( )

Referenced by clearState().

◆ init()

void Maemo::IcdPrivate::init ( unsigned int  dbus_timeout,
IcdDbusInterfaceVer  ver,
Icd myfriend 
)
inline

Definition at line 165 of file maemo_icd.cpp.

Referenced by IcdPrivate().

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  */
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 
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  }
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
DBusDispatcher * mDBus
Definition: maemo_icd.cpp:154
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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
IcdDbusInterfaceVer icd_dbus_version
Definition: maemo_icd.cpp:162
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
void signalReceived(const QString &interface, const QString &signal, const QList< QVariant > &args)
Definition: maemo_icd.cpp:225
#define PDEBUG(fmt...)
Definition: maemo_icd.cpp:75

◆ scan()

QStringList Maemo::IcdPrivate::scan ( icd_scan_request_flags  flags,
QStringList network_types,
QList< IcdScanResult > &  scan_results,
QString error 
)

Definition at line 274 of file maemo_icd.cpp.

Referenced by Maemo::Icd::scan(), and ~IcdPrivate().

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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
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
The QString class provides a Unicode character string.
Definition: qstring.h:83
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 *,...)
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
QList< QVariant > receivedSignals
Definition: maemo_icd.cpp:160
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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())
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT void qWarning(const char *,...)
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
void clear()
Removes all items from the list.
Definition: qlist.h:764
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
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
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
unsigned int timeout
Definition: maemo_icd.cpp:161
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
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
#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

◆ signalReceived()

void Maemo::IcdPrivate::signalReceived ( const QString interface,
const QString signal,
const QList< QVariant > &  args 
)

Definition at line 225 of file maemo_icd.cpp.

Referenced by Maemo::Icd::icdSignalReceived(), init(), and ~IcdPrivate().

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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QList< QVariant > receivedSignals
Definition: maemo_icd.cpp:160
QList< QVariant > mArgs
Definition: maemo_icd.cpp:159

◆ state() [1/2]

uint Maemo::IcdPrivate::state ( QString service_type,
uint  service_attrs,
QString service_id,
QString network_type,
uint  network_attrs,
QByteArray network_id,
IcdStateResult state_result 
)

Definition at line 417 of file maemo_icd.cpp.

Referenced by Maemo::Icd::state(), and ~IcdPrivate().

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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
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
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
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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())
Q_CORE_EXPORT void qWarning(const char *,...)
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 get_state_all_result(QList< QVariant > &args, IcdStateResult &ret)
Definition: maemo_icd.cpp:382
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
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
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
unsigned int timeout
Definition: maemo_icd.cpp:161
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
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

◆ state() [2/2]

uint Maemo::IcdPrivate::state ( QList< IcdStateResult > &  state_results)

Definition at line 481 of file maemo_icd.cpp.

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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static void get_state_all_result2(QList< QVariant > &args, IcdStateResult &ret)
Definition: maemo_icd.cpp:398
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
void synchronousDispatch(int timeout_ms)
DBusDispatcher * mDBus
Definition: maemo_icd.cpp:154
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
unsigned long time_t
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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())
Q_CORE_EXPORT void qWarning(const char *,...)
unsigned int uint
Definition: qglobal.h:996
static void sendPostedEvents()
void clear()
Removes all items from the list.
Definition: qlist.h:764
static void get_state_all_result(QList< QVariant > &args, IcdStateResult &ret)
Definition: maemo_icd.cpp:382
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
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
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
unsigned int timeout
Definition: maemo_icd.cpp:161
#define PDEBUG(fmt...)
Definition: maemo_icd.cpp:75

◆ statistics()

uint Maemo::IcdPrivate::statistics ( QList< IcdStatisticsResult > &  stats_results)

Definition at line 564 of file maemo_icd.cpp.

Referenced by Maemo::Icd::statistics(), and ~IcdPrivate().

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 }
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
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
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
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
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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())
Q_CORE_EXPORT void qWarning(const char *,...)
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
void clear()
Removes all items from the list.
Definition: qlist.h:764
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
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
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
unsigned int timeout
Definition: maemo_icd.cpp:161
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
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

Properties

◆ icd

Icd* Maemo::IcdPrivate::icd

Definition at line 163 of file maemo_icd.cpp.

Referenced by addrinfo(), state(), and ~IcdPrivate().

◆ icd_dbus_version

IcdDbusInterfaceVer Maemo::IcdPrivate::icd_dbus_version

Definition at line 162 of file maemo_icd.cpp.

◆ mArgs

QList<QVariant> Maemo::IcdPrivate::mArgs

Definition at line 159 of file maemo_icd.cpp.

Referenced by addrinfo(), signalReceived(), state(), and statistics().

◆ mDBus

DBusDispatcher* Maemo::IcdPrivate::mDBus

Definition at line 154 of file maemo_icd.cpp.

Referenced by addrinfo(), scan(), state(), statistics(), and ~IcdPrivate().

◆ mError

QString Maemo::IcdPrivate::mError

Definition at line 158 of file maemo_icd.cpp.

Referenced by addrinfo(), callReply(), scan(), state(), and statistics().

◆ mInterface

QString Maemo::IcdPrivate::mInterface

Definition at line 156 of file maemo_icd.cpp.

Referenced by addrinfo(), scan(), signalReceived(), state(), and statistics().

◆ mMethod

QString Maemo::IcdPrivate::mMethod

Definition at line 155 of file maemo_icd.cpp.

Referenced by callReply().

◆ mSignal

QString Maemo::IcdPrivate::mSignal

Definition at line 157 of file maemo_icd.cpp.

Referenced by addrinfo(), scan(), signalReceived(), state(), and statistics().

◆ receivedSignals

QList<QVariant> Maemo::IcdPrivate::receivedSignals

Definition at line 160 of file maemo_icd.cpp.

Referenced by scan(), and signalReceived().

◆ timeout

unsigned int Maemo::IcdPrivate::timeout

Definition at line 161 of file maemo_icd.cpp.

Referenced by addrinfo(), scan(), state(), and statistics().


The documentation for this class was generated from the following file: