diff options
author | Andre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk> | 2009-11-10 09:32:28 -0300 |
---|---|---|
committer | Andre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk> | 2009-11-10 09:38:50 -0300 |
commit | 2ae16416edd817e886074d9ba6683eb24dd8f0a2 (patch) | |
tree | a499ee9329da0ca69a93f3c70357a9f2645b3b9b | |
parent | c0ef389ead8a5fa5f02b4f8b1cc71727b3779468 (diff) |
Connection: Better map status change reason to D-Bus errors.
-rw-r--r-- | TelepathyQt4/connection.cpp | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/TelepathyQt4/connection.cpp b/TelepathyQt4/connection.cpp index 1c6d26c9..45885965 100644 --- a/TelepathyQt4/connection.cpp +++ b/TelepathyQt4/connection.cpp @@ -816,6 +816,7 @@ void Connection::onStatusChanged(uint status, uint reason) return; } + uint oldStatus = mPriv->pendingStatus; mPriv->pendingStatus = status; mPriv->pendingStatusReason = reason; @@ -832,38 +833,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 |