Skip to content

Commit

Permalink
[mkcal] Use QMailStore::queryAccounts to check that an id is an email…
Browse files Browse the repository at this point in the history
… account.
  • Loading branch information
dcaliste committed Jul 15, 2020
1 parent ab9497b commit 780fcb4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions plugins/defaultinvitationplugin/defaultinvitationplugin.cpp
Expand Up @@ -74,12 +74,15 @@ class DefaultInvitationPlugin::Private
if (accountId.isEmpty()) {
return QString();
}
QMailAccount account(QMailAccountId(accountId.toULongLong()));
QString email;
if (account.id().isValid() && (account.status() & QMailAccount::CanTransmit)) {
email = account.fromAddress().address();
} else {
qDebug() << "Default plugin: account" << accountId << "is not an email account";
const QMailAccountId accId(accountId.toULongLong());
if (!QMailStore::instance()->queryAccounts(QMailAccountKey::id(accId)).isEmpty()) {
QMailAccount account(accId);
if (account.id().isValid() && (account.status() & QMailAccount::CanTransmit)) {
email = account.fromAddress().address();
} else {
qWarning() << "Default plugin: account" << accountId << "is invalid or cannot transmit";
}
}
if (email.isEmpty()) {
qDebug() << "Default plugin: account" << accountId << "do not have a valid email address";
Expand Down

0 comments on commit 780fcb4

Please sign in to comment.