void RoutingBin::GetEntries(ContactList &outList, bool bEmptyFirst) { if(bEmptyFirst) outList.clear(); if(nodeList.size() > 0) { outList.insert(outList.end(),nodeList.begin(),nodeList.end()); } }
ContactList *RosterDBManager::getAllContacts() { ContactList *list = new ContactList(); QSqlQuery query(db); qint64 startTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); Utilities::logData("Reading roster DB..."); query.prepare("select * from roster"); query.exec(); while (query.next()) { Contact *c; int type = query.value(1).toInt(); c = ((type == Contact::TypeContact) ? new Contact() : new Group()); c->type = (Contact::ContactType) type; c->jid = query.value(0).toString(); c->alias = query.value(2).toString(); c->fromAddressBook = query.value(3).toBool(); c->name = query.value(4).toString(); c->phone = query.value(5).toString(); c->status = query.value(6).toString(); c->statusTimestamp = query.value(7).toLongLong(); c->lastSeen = query.value(8).toLongLong(); QByteArray bytes = query.value(9).toByteArray(); c->photo = QImage::fromData(bytes); if (c->type == Contact::TypeGroup) { Group *g = (Group *)c; g->creationTimestamp = query.value(10).toLongLong(); g->author = query.value(11).toString(); g->subjectTimestamp = query.value(12).toLongLong(); g->subjectOwner = query.value(13).toString(); g->subjectOwnerName = query.value(14).toString(); QSqlQuery subQuery(db); subQuery.prepare("select jid from participants where gjid = :gjid"); subQuery.bindValue(":jid",g->jid); subQuery.exec(); while (subQuery.next()) { g->addParticipant(subQuery.value(0).toString()); } } c->photoId = query.value(15).toString(); c->blocked = query.value(16).toBool(); list->insert(c->jid,c); } qint64 endTime = QDateTime::currentDateTime().toMSecsSinceEpoch() - startTime; Utilities::logData("Roster retrieved in " + QString::number(endTime) + " milliseconds."); return list; }