diff options
-rw-r--r-- | TelepathyQt4/account.cpp | 6 | ||||
-rw-r--r-- | TelepathyQt4/connection.cpp | 59 | ||||
-rw-r--r-- | TelepathyQt4/connection.h | 1 |
3 files changed, 55 insertions, 11 deletions
diff --git a/TelepathyQt4/account.cpp b/TelepathyQt4/account.cpp index 7c4c7635..d8451753 100644 --- a/TelepathyQt4/account.cpp +++ b/TelepathyQt4/account.cpp @@ -190,7 +190,8 @@ Account::Private::~Private() * * If the account is deleted from the AccountManager, this object * will not be deleted automatically; however, it will emit invalidated() - * and will cease to be useful. + * with error code %TELEPATHY_QT4_ERROR_OBJECT_REMOVED and will cease to + * be useful. */ const Feature Account::FeatureCore = Feature(Account::staticMetaObject.className(), 0, true); @@ -1581,8 +1582,7 @@ void Account::onRemoved() { mPriv->valid = false; mPriv->enabled = false; - // This is the closest error we have at the moment - invalidate(QLatin1String(TELEPATHY_ERROR_CANCELLED), + invalidate(QLatin1String(TELEPATHY_QT4_ERROR_OBJECT_REMOVED), QLatin1String("Account removed from AccountManager")); } diff --git a/TelepathyQt4/connection.cpp b/TelepathyQt4/connection.cpp index 56ce11d1..84cb3c2c 100644 --- a/TelepathyQt4/connection.cpp +++ b/TelepathyQt4/connection.cpp @@ -278,6 +278,9 @@ void Connection::Private::init() parent->connect(baseInterface, SIGNAL(StatusChanged(uint, uint)), SLOT(onStatusChanged(uint, uint))); + parent->connect(baseInterface, + SIGNAL(ConnectionError(const QString &, const QVariantMap &)), + SLOT(onConnectionError(const QString &, const QVariantMap &))); debug() << "Calling GetStatus()"; QDBusPendingCallWatcher *watcher = @@ -817,6 +820,7 @@ void Connection::onStatusChanged(uint status, uint reason) return; } + uint oldStatus = mPriv->pendingStatus; mPriv->pendingStatus = status; mPriv->pendingStatusReason = reason; @@ -833,38 +837,70 @@ void Connection::onStatusChanged(uint status, uint reason) case ConnectionStatusDisconnected: const char *errorName; - // This is the best we can do right now: in an imminent - // spec version we should define a different D-Bus error name - // for each ConnectionStatusReason - switch (reason) { case ConnectionStatusReasonNoneSpecified: - case ConnectionStatusReasonRequested: errorName = TELEPATHY_ERROR_DISCONNECTED; break; + case ConnectionStatusReasonRequested: + errorName = TELEPATHY_ERROR_CANCELLED; + break; + case ConnectionStatusReasonNetworkError: + errorName = TELEPATHY_ERROR_NETWORK_ERROR; + break; + case ConnectionStatusReasonAuthenticationFailed: + errorName = TELEPATHY_ERROR_AUTHENTICATION_FAILED; + break; + case ConnectionStatusReasonEncryptionError: - errorName = TELEPATHY_ERROR_NETWORK_ERROR; + errorName = TELEPATHY_ERROR_ENCRYPTION_ERROR; break; case ConnectionStatusReasonNameInUse: - errorName = TELEPATHY_ERROR_NOT_YOURS; + if (oldStatus == ConnectionStatusConnecting) { + errorName = TELEPATHY_ERROR_ALREADY_CONNECTED; + } else { + errorName = TELEPATHY_ERROR_CONNECTION_REPLACED; + } break; case ConnectionStatusReasonCertNotProvided: + errorName = TELEPATHY_ERROR_CERT_NOT_PROVIDED; + break; + case ConnectionStatusReasonCertUntrusted: + errorName = TELEPATHY_ERROR_CERT_UNTRUSTED; + break; + case ConnectionStatusReasonCertExpired: + errorName = TELEPATHY_ERROR_CERT_EXPIRED; + break; + case ConnectionStatusReasonCertNotActivated: + errorName = TELEPATHY_ERROR_CERT_NOT_ACTIVATED; + break; + case ConnectionStatusReasonCertHostnameMismatch: + errorName = TELEPATHY_ERROR_CERT_HOSTNAME_MISMATCH; + break; + case ConnectionStatusReasonCertFingerprintMismatch: + errorName = TELEPATHY_ERROR_CERT_FINGERPRINT_MISMATCH; + break; + case ConnectionStatusReasonCertSelfSigned: + errorName = TELEPATHY_ERROR_CERT_SELF_SIGNED; + break; + case ConnectionStatusReasonCertOtherError: - errorName = TELEPATHY_ERROR_NETWORK_ERROR; + errorName = TELEPATHY_ERROR_CERT_INVALID; + break; default: errorName = TELEPATHY_ERROR_DISCONNECTED; + break; } // TODO should we signal statusChanged to Disconnected here or just @@ -883,6 +919,13 @@ void Connection::onStatusChanged(uint status, uint reason) } } +void Connection::onConnectionError(const QString &error, + const QVariantMap &details) +{ + invalidate(error, + details.value(QLatin1String("debug-message")).toString()); +} + void Connection::gotStatus(QDBusPendingCallWatcher *watcher) { QDBusPendingReply<uint> reply = *watcher; diff --git a/TelepathyQt4/connection.h b/TelepathyQt4/connection.h index 4ec4ce83..c188d287 100644 --- a/TelepathyQt4/connection.h +++ b/TelepathyQt4/connection.h @@ -176,6 +176,7 @@ protected: private Q_SLOTS: void onStatusReady(uint); void onStatusChanged(uint, uint); + void onConnectionError(const QString &, const QVariantMap &); void gotStatus(QDBusPendingCallWatcher *watcher); void gotInterfaces(QDBusPendingCallWatcher *watcher); void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher); |