Exemplo n.º 1
0
QList<uint> tst_Events::queryEvents()
{
    QMap<QString,QVariant> parameters;
    parameters.insert("APPLICATION", QVariant(QString(APPNAME)));

    Maemo::Timed::Interface timedIface;
    QDBusReply<QList<QVariant> > queryReply = timedIface.query_sync(parameters);
    QList<uint> cookieList;
    if(!queryReply.isValid()) {
        qWarning() << "query call failed" << timedIface.lastError();
        return cookieList;
    }
    const QList<QVariant> &result = queryReply.value();
    bool ok;
    foreach (const QVariant &variant, result) {
        cookieList.append(variant.toUInt(&ok));
        if (!ok) {
            qWarning() << "Failed to cast QVariant to uint";
            return QList<uint>();
        }
    }
Exemplo n.º 2
0
int query(int ac, char **av)
{
  QMap<QString,QVariant> p ;
  for(int i=0; i<ac; i+=2)
    p[av[i]] = (QString)(av[i+1]) ;

  Maemo::Timed::Interface ifc ;
  QDBusReply<QList<QVariant> > reply = ifc.query_sync(p) ;
  if(!reply.isValid())
  {
    qDebug() << "query call failed" << ifc.lastError() ;
    return 1 ;
  }
  const QList<QVariant> &result = reply.value() ;
  int s = result.size() ;
  cout << "got " << s << " cookie(s)" << ( s ? ": " : "" ) ;
  if(s>0)
    for(int i=0; i<s; ++i)
      cout << (i?", ":"") << result[i].toUInt() ;
  cout << endl ;
  return 0 ;
}