bool QMessageAccountId::operator==(const QMessageAccountId& other) const { if (isValid()) { if (other.isValid()) { return (d_ptr->_id == other.d_ptr->_id); } return false; } else { return !other.isValid(); } }
bool QMessageService::synchronize(const QMessageAccountId &id) { if (d_ptr->_active) { return false; } if (!id.isValid()) { d_ptr->_error = QMessageManager::InvalidId; return false; } d_ptr->_active = true; d_ptr->_error = QMessageManager::NoError; bool retVal = true; d_ptr->_state = QMessageService::ActiveState; emit stateChanged(d_ptr->_state); retVal = d_ptr->synchronize(id); if (retVal == false) { d_ptr->setFinished(retVal); } return retVal; }
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; }
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(); }
bool QMessageService::send(QMessage &message) { if (d_ptr->_active) { return false; } d_ptr->_active = true; d_ptr->_error = QMessageManager::NoError; bool retVal = true; d_ptr->_state = QMessageService::ActiveState; emit stateChanged(d_ptr->_state); QMessageAccountId accountId = message.parentAccountId(); QMessage::Type msgType = QMessage::NoType; // Check message type if (message.type() == QMessage::AnyType || message.type() == QMessage::NoType) { QMessage::TypeFlags types = QMessage::NoType; if (accountId.isValid()) { // ParentAccountId was defined => Message type can be read // from parent account QMessageAccount account = QMessageAccount(accountId); QMessage::TypeFlags types = account.messageTypes(); if (types & QMessage::Sms) { msgType = QMessage::Sms; } else if (types & QMessage::Mms) { msgType = QMessage::Mms; } else if (types & QMessage::Email) { msgType = QMessage::Email; } } if (msgType == QMessage::NoType) { d_ptr->_error = QMessageManager::ConstraintFailure; retVal = false; } } if (retVal) { // Check account if (!accountId.isValid()) { accountId = QMessageAccount::defaultAccount(message.type()); if (!accountId.isValid()) { d_ptr->_error = QMessageManager::InvalidId; retVal = false; } } } QMessageAccount account(accountId); if (retVal) { // Check account/message type compatibility if (!(account.messageTypes() & message.type()) && (msgType == QMessage::NoType)) { d_ptr->_error = QMessageManager::ConstraintFailure; retVal = false; } } if (retVal) { // Check recipients QMessageAddressList recipients = message.to() + message.bcc() + message.cc(); if (recipients.isEmpty()) { d_ptr->_error = QMessageManager::ConstraintFailure; return false; } } if (retVal) { QMessage outgoing(message); // Set default account if unset if (!outgoing.parentAccountId().isValid()) { outgoing.setParentAccountId(accountId); } if (outgoing.type() == QMessage::AnyType || outgoing.type() == QMessage::NoType) { outgoing.setType(msgType); } if (account.messageTypes() & QMessage::Sms) { retVal = d_ptr->sendSMS(outgoing); } else if (account.messageTypes() & QMessage::Mms) { retVal = d_ptr->sendMMS(outgoing); } else if (account.messageTypes() & QMessage::Email) { retVal = d_ptr->sendEmail(outgoing); } QMessagePrivate* privateMessage = QMessagePrivate::implementation(message); privateMessage->_id = outgoing.id(); } if (retVal == false) { d_ptr->setFinished(retVal); } return retVal; }
bool QMessageStore::addMessage(QMessage *m) { bool retVal = true; QMessageAccountId accountId = m->parentAccountId(); QMessage::Type msgType = QMessage::NoType; // Check message type if (m->type() == QMessage::AnyType || m->type() == QMessage::NoType) { if (accountId.isValid()) { // ParentAccountId was defined => Message type can be read // from parent account QMessageAccount account = QMessageAccount(accountId); QMessage::TypeFlags types = account.messageTypes(); if (types & QMessage::Sms) { msgType = QMessage::Sms; } else if (account.messageTypes() & QMessage::InstantMessage) { msgType = QMessage::InstantMessage; } else if (types & QMessage::Mms) { msgType = QMessage::Mms; } else if (types & QMessage::Email) { msgType = QMessage::Email; } } if (msgType == QMessage::NoType) { retVal = false; d_ptr->error = QMessageManager::ConstraintFailure; } } if (retVal) { // Check account if (!accountId.isValid()) { accountId = QMessageAccount::defaultAccount(m->type()); if (!accountId.isValid()) { d_ptr->error = QMessageManager::ConstraintFailure; retVal = false; } } } QMessageAccount account(accountId); if (retVal) { // Check account/message type compatibility if (!(account.messageTypes() & m->type()) && (msgType == QMessage::NoType)) { retVal = false; d_ptr->error = QMessageManager::ConstraintFailure; } } if (retVal) { // Set default account if unset if (!m->parentAccountId().isValid()) { m->setParentAccountId(accountId); } if (account.messageTypes() & QMessage::Sms) { retVal = StorageEngine::instance()->addMessage(*m); } else if (account.messageTypes() & QMessage::InstantMessage) { retVal = false; //TODO: d_ptr->error = QMessageManager::NotYetImplemented; qWarning() << "QMessageManager::add not yet implemented for Instant Message"; } else if (account.messageTypes() & QMessage::Mms) { retVal = false; //TODO: d_ptr->error = QMessageManager::NotYetImplemented; qWarning() << "QMessageManager::add not yet implemented for MMS"; } else if (account.messageTypes() & QMessage::Email) { retVal = QMFStore::instance()->addMessage(*m, d_ptr->error); } } return retVal; }