Agent::Agent() : QObject(NULL, "agent") { kdebugf(); connect(gadu, SIGNAL(userStatusChangeIgnored(UinType)), this, SLOT(userFound(UinType))); // Main menu entry agentActionDescription = new ActionDescription( ActionDescription::TypeMainMenu, "agentAction", this, SLOT(resultsRequest()), "Agent", tr("Who has me on list") ); kadu->insertMenuActionDescription(0, agentActionDescription); if(config_file.readBoolEntry("Agent", "FirstTime", true)) { QFile listFile; listFile.setName(QString(ggPath("spy-unknownslist").ascii())); if(listFile.open(IO_ReadOnly)) { if(MessageBox::ask(tr("Agent has founded spy's unknown-users list. Do you want to append this list to agent module?"))) { QTextStream stream(&listFile); QString uin_str, date_str, line; bool ok; while (!stream.atEnd()) { UnknownUser user; bool isAlready = false; line = stream.readLine(); uin_str = line.section(',', 0, 0); date_str = line.section(',', 1, 1); unsigned int uin_int = uin_str.toUInt(&ok, 10); if(!ok) kdebugm(KDEBUG_PANIC, "Couldn't cast QString to int"); foreach(UnknownUser user, UnknownsList) { if (user.uin == uin_int) { isAlready = true; break; } } if (!isAlready) { user.uin = uin_int; user.date = QDate::fromString(date_str, Qt::ISODate); user.seq = 0; UnknownsList.append(user); } } } listFile.close(); }
/*! Finds a user by user \a userName Async unblocking API \param userName The user name to look up. */ void AccountsManager::findUserByNameAsync(const QString &userName) { Q_D(AccountsManager); QDBusPendingCall call = d->interface->FindUserByName(userName); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) { QDBusPendingReply<QDBusObjectPath> reply = *w; w->deleteLater(); if (reply.isError()) { QDBusError error = reply.error(); qWarning("Couldn't find user by name %s: %s", userName.toUtf8().constData(), error.errorString(error.type()).toUtf8().constData()); } else { QDBusObjectPath path = reply.argumentAt<0>(); if (!path.path().isEmpty()) Q_EMIT userFound(new UserAccount(path.path(), d->interface->connection())); } }); }