Exemple #1
0
void machine_t::get_cookies_by_attributes(const QMap<QString,QString> &words, QList<uint> &res)
{
  vector<string> keys, values ;
  for(QMap<QString,QString>::const_iterator it=words.begin(); it!=words.end(); ++it)
  {
    keys.push_back(string_q_to_std(it.key())) ;
    values.push_back(string_q_to_std(it.value())) ;
  }
  unsigned N = keys.size() ;
  for(map<cookie_t, event_t*>::const_iterator it=events.begin(); it!=events.end(); ++it)
  {
    bool text_matches = true ;
    const map<string,string> &attr = it->second->attr.txt ;
    for(unsigned i=0; text_matches and i<N; ++i)
    {
      map<string,string>::const_iterator F = attr.find(keys[i]) ;
      if (F==attr.end())
        text_matches = values[i].empty() ;
      else
        text_matches = values[i]==F->second ;
    }
    if(text_matches)
      res.push_back(it->second->cookie.value()) ;
  }
}
Exemple #2
0
void Timed::send_next_bootup_event(int value)
{
#if HAVE_DSME
  QDBusConnection dsme = QDBusConnection::systemBus() ;
  QString path = Maemo::Timed::objpath() ;
  QString iface = Maemo::Timed::interface() ;
  QString signal = "next_bootup_event" ;
  QDBusMessage m = QDBusMessage::createSignal(path, iface, signal) ;
  m << value ;
  if(dsme.send(m))
    log_info("signal %s(%d) sent", string_q_to_std(signal).c_str(), value) ;
  else
    log_error("Failed to send the signal %s(%d) on system bus: %s", string_q_to_std(signal).c_str(), value, dsme.lastError().message().toStdString().c_str()) ;
#endif
}
Exemple #3
0
static void spam()
{
#if NO_SPAM
  time_t now = time(NULL) ;
  for(int i=0; i<12; ++i)
  {
    time_t then = now + i*30*24*60*60 ;
    struct tm t ;
    localtime_r(&then, &t) ;
    log_debug("i=%d, time:%ld, t.tm_gmtoff=%ld", i, then, t.tm_gmtoff) ;
  }
#endif
#if NO_SPAM
  qlonglong A=1111, B=2222 ;
  QString str = "bebe " ;
  str += QString(" timestamp: %1/%2").arg(A).arg(B) ;
  log_debug("%s", str.toStdString().c_str()) ;
#endif
#if NO_SPAM
  log_info("AA") ;
  for(nanotime_t x(-2,0); x.sec()<3; x+=nanotime_t(0,100000000))
  {
    QString res ;
    QTextStream os(&res) ;
    os << x ;
    log_info("%s=%ld", string_q_to_std(res).c_str(), x.to_time_t()) ;
  }
  log_info("BB") ;
#endif
}
Exemple #4
0
void machine_t::query(const QMap<QString,QVariant> &words, QList<QVariant> &res)
{
  vector<string> qk, qv ;
  for(QMap<QString,QVariant>::const_iterator it=words.begin(); it!=words.end(); ++it)
  {
    qk.push_back(string_q_to_std(it.key())) ;
    qv.push_back(string_q_to_std(it.value().toString())) ;
  }
  unsigned N = qk.size() ;
  for(map<cookie_t, event_t*>::const_iterator it=events.begin(); it!=events.end(); ++it)
  {
    bool text_matches = true ;
    for(unsigned i=0; text_matches && i<N; ++i)
    {
      map<string,string>::const_iterator F = it->second->attr.txt.find(qk[i]) ;
      if(F==it->second->attr.txt.end())
        text_matches = qv[i]=="" ;
      else
        text_matches = qv[i]==F->second ;
    }
    if(text_matches)
      res.push_back(it->second->cookie.value()) ;
  }
}