EngineType idType(const QMessageAccountId& id) { if (id.toString().startsWith(mtmPrefix)) { return EngineTypeMTM; } else if (id.toString().startsWith(freestylePrefix)) { return EngineTypeFreestyle; } else { return EngineTypeMTM; } }
bool QMessageStore::removeAccount(const QMessageAccountId &id) { bool result = false; d_ptr->error = QMessageManager::NoError; if (id.isValid() && id.toString().startsWith("QMF_")) { qDebug() << __PRETTY_FUNCTION__ << "Removing QMF accountId " << id.toString(); result = QMFStore::instance()->removeAccount(id, d_ptr->error); } else d_ptr->error = QMessageManager::NotYetImplemented; return result; }
QMessageAccountId addIdPrefix(const QMessageAccountId& id, const EngineType& type) { switch (type) { case EngineTypeFreestyle: Q_ASSERT(!id.toString().startsWith(freestylePrefix)); return QMessageAccountId(QString(freestylePrefix) + id.toString()); case EngineTypeMTM: Q_ASSERT(!id.toString().startsWith(mtmPrefix)); return QMessageAccountId(QString(mtmPrefix) + id.toString()); default: return QMessageAccountId(id); } }
QMessageAccount QMessageStore::account(const QMessageAccountId& id) const { if (id.toString().startsWith("MO_")) { return ModestEngine::instance()->account(id); } else { return TelepathyEngine::instance()->account(id); } }
QMessageFolderFilter QMessageFolderFilter::byParentAccountId(const QMessageAccountId &id, QMessageDataComparator::EqualityComparator cmp) { QMessageFolderFilter result; result.d_ptr->_field = QMessageFolderFilterPrivate::ParentAccountId; result.d_ptr->_value = id.toString(); result.d_ptr->_comparatorType = QMessageFolderFilterPrivate::Equality; result.d_ptr->_comparatorValue = static_cast<int>(cmp); result.d_ptr->_valid = true; return result; }
QMessageAccountId stripIdPrefix(const QMessageAccountId& id) { if (id.toString().startsWith(freestylePrefix)) return QMessageAccountId(id.toString().right(id.toString().length() - QString(freestylePrefix).length())); else if (id.toString().startsWith(mtmPrefix)) return QMessageAccountId(id.toString().right(id.toString().length() - QString(mtmPrefix).length())); else return QMessageAccountId(id); }
QMessageAccount QMessageStore::account(const QMessageAccountId& id) const { if (!id.isValid()) { d_ptr->error = QMessageManager::InvalidId; return QMessageAccount(); } d_ptr->error = QMessageManager::NoError; if (id.toString().startsWith("QMF_")) { return QMFStore::instance()->account(id, d_ptr->error); } else { return TelepathyEngine::instance()->account(id); } return QMessageAccount(); }
QMailAccountId convert(const QMessageAccountId &id) { return QMailAccountId(stripIdentifierPrefix(id.toString()).toULongLong()); }
uint qHash(const QMessageAccountId &id) { return qHash(id.toString()); }