File indexing completed on 2023-10-01 08:41:44

0001 /*
0002     Telepathy error dictionary - usable strings for dbus messages
0003     Copyright (C) 2011  Martin Klapetek <martin.klapetek@gmail.com>
0004     Copyright (C) 2011  Dario Freddi <dario.freddi@collabora.com>
0005 
0006     This library is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU Lesser General Public
0008     License as published by the Free Software Foundation; either
0009     version 2.1 of the License, or (at your option) any later version.
0010 
0011     This library is distributed in the hope that it will be useful,
0012     but WITHOUT ANY WARRANTY; without even the implied warranty of
0013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014     Lesser General Public License for more details.
0015 
0016     You should have received a copy of the GNU Lesser General Public
0017     License along with this library; if not, write to the Free Software
0018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019 */
0020 
0021 
0022 #include "error-dictionary.h"
0023 
0024 #include <TelepathyQt/Constants>
0025 
0026 #include <KLocalizedString>
0027 #include "ktp-debug.h"
0028 
0029 namespace KTp
0030 {
0031 
0032 QString ErrorDictionary::displayVerboseErrorMessage(const QString& dbusErrorName)
0033 {
0034     if (dbusErrorName == QLatin1String(TP_QT_ERROR_ALREADY_CONNECTED)) {
0035         return i18nc("Verbose user visible error string", "Looks like you are already connected from other location and the server does not allow multiple connections");
0036     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_AUTHENTICATION_FAILED)) {
0037         return i18nc("Verbose user visible error string", "Authentication of your account failed (is your password correct?)");
0038     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_BUSY)) {
0039         return i18nc("Verbose user visible error string", "The channel is too busy now to process your request. Try again in a few minutes");
0040     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CANCELLED)) {
0041         return i18nc("Verbose user visible error string", "The connection was canceled on your request");
0042     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_EXPIRED)) {
0043         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server is expired");
0044     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_FINGERPRINT_MISMATCH)) {
0045         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server has different fingerprint than expected");
0046     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_HOSTNAME_MISMATCH)) {
0047         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server has different hostname than expected");
0048     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_INSECURE)) {
0049         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server uses too weak encryption");
0050     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_INVALID)) {
0051         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server is invalid");
0052     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_LIMIT_EXCEEDED)) {
0053         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server has exceeded length limit");
0054     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_NOT_ACTIVATED)) {
0055         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server has not been activated yet");
0056     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_NOT_PROVIDED)) {
0057         return i18nc("Verbose user visible error string", "The server did not provide any SSL/TLS certificate");
0058     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_REVOKED)) {
0059         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server has been revoked");
0060     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_SELF_SIGNED)) {
0061         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server was self-signed by the server and is untrusted");
0062     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_UNTRUSTED)) {
0063         return i18nc("Verbose user visible error string", "The SSL/TLS certificate received from server was not signed by a trusted certificate authority");
0064     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CHANNEL_BANNED)) {
0065         return i18nc("Verbose user visible error string", "You have been banned from the channel");
0066     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CHANNEL_FULL)) {
0067         return i18nc("Verbose user visible error string", "The channel is full");
0068     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CHANNEL_INVITE_ONLY)) {
0069         return i18nc("Verbose user visible error string", "The channel is invite-only");
0070     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CHANNEL_KICKED)) {
0071         return i18nc("Verbose user visible error string", "You have been kicked from the channel");
0072     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONFUSED)) {
0073         return i18nc("Verbose user visible error string", "An unexpected error has occurred");
0074     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONNECTION_FAILED)) {
0075         return i18nc("Verbose user visible error string", "Could not establish connection");
0076     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONNECTION_LOST)) {
0077         return i18nc("Verbose user visible error string", "Connection to server was lost");
0078     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONNECTION_REFUSED)) {
0079         return i18nc("Verbose user visible error string", "Server refused your connection");
0080     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONNECTION_REPLACED)) {
0081         return i18nc("Verbose user visible error string", "Somewhere there is another client connecting with your account and your current connection is lost");
0082     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_DISCONNECTED)) {
0083         return i18nc("Verbose user visible error string", "You have been disconnected");
0084     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_DOES_NOT_EXIST)) {
0085         return i18nc("Verbose user visible error string", "Selected user does not exist");
0086     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_EMERGENCY_CALLS_NOT_SUPPORTED)) {
0087         return i18nc("Verbose user visible error string", "Emergency calls are not supported");
0088     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_ENCRYPTION_ERROR)) {
0089         return i18nc("Verbose user visible error string", "An encryption error has occurred");
0090     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_ENCRYPTION_NOT_AVAILABLE)) {
0091         return i18nc("Verbose user visible error string", "Requested encryption is not available");
0092     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_INVALID_ARGUMENT)) {
0093         return i18nc("Verbose user visible error string", "An invalid argument was provided");
0094     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_INVALID_HANDLE)) {
0095         return i18nc("Verbose user visible error string", "The specified handle is unknown on this channel");
0096     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NETWORK_ERROR)) {
0097         return i18nc("Verbose user visible error string", "There appears to be a problem with your network, check your connection");
0098     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NO_ANSWER)) {
0099         return i18nc("Verbose user visible error string", "You were removed from the channel because you did not respond"); //FIXME: this sound bad
0100     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_AVAILABLE)) {
0101         return i18nc("Verbose user visible error string", "The service is not available");
0102     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_CAPABLE)) {
0103         return i18nc("Verbose user visible error string", "The contact does not have the requested capabilities");
0104     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_IMPLEMENTED)) {
0105         return i18nc("Verbose user visible error string", "This operation is not implemented");
0106     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_YET)) {
0107         return i18nc("Verbose user visible error string", "This operation is not yet implemented");
0108     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_YOURS)) {
0109         return i18nc("Verbose user visible error string", "The requested channel is already being handled by some other process");
0110     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_OFFLINE)) {
0111         return i18nc("Verbose user visible error string", "This operation is unavailable for offline contacts");
0112     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_PERMISSION_DENIED)) {
0113         return i18nc("Verbose user visible error string", "You are not permitted to perform this operation");
0114     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_PICKED_UP_ELSEWHERE)) {
0115         return i18nc("Verbose user visible error string", "Current call was picked up by another resource");
0116     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_REGISTRATION_EXISTS)) {
0117         return i18nc("Verbose user visible error string", "Account with this username already exists");
0118     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_REJECTED)) {
0119         return i18nc("Verbose user visible error string", "The receiver rejected your call");
0120     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_RESOURCE_UNAVAILABLE)) {
0121         return i18nc("Verbose user visible error string", "There are insufficient resources (like free memory) to finish the operation at the moment");
0122     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_SERVICE_BUSY)) {
0123         return i18nc("Verbose user visible error string", "Your request hit a busy resource somewhere along the way and the operation was unable to finish");
0124     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_SERVICE_CONFUSED)) {
0125         return i18nc("Verbose user visible error string", "An internal error has occurred (known as the 'Confused service error')");
0126     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_SOFTWARE_UPGRADE_REQUIRED)) {
0127         return i18nc("Verbose user visible error string", "The installed libraries are too old. Please try updating all Telepathy packages to a newer version");
0128     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_TERMINATED)) {
0129         return i18nc("Verbose user visible error string", "The channel was terminated for no apparent reason");
0130     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_WOULD_BREAK_ANONYMITY)) {
0131         return i18nc("Verbose user visible error string", "This operation can not be finished as it would break your requested anonymity");
0132     } else if (dbusErrorName == QLatin1String("org.freedesktop.DBus.Error.NoReply")) {
0133         return i18nc("Verbose user visible error string", "Some of the IM components are not working correctly");
0134     } else {
0135         return i18nc("User visible error string", "An unknown error was encountered (%1), please report this", dbusErrorName);
0136     }
0137 }
0138 
0139 QString ErrorDictionary::displayShortErrorMessage(const QString& dbusErrorName)
0140 {
0141     if (dbusErrorName == QLatin1String(TP_QT_ERROR_ALREADY_CONNECTED)) {
0142         return i18nc("Short user visible error string", "Connected elsewhere");
0143     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_AUTHENTICATION_FAILED)) {
0144         return i18nc("Short user visible error string", "Authentication failed");
0145     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_BUSY)) {
0146         return i18nc("Short user visible error string", "Channel too busy");
0147     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CANCELLED)) {
0148         return i18nc("Short user visible error string", "Cancelled by user");
0149     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_EXPIRED)) {
0150         return i18nc("Short user visible error string", "Certificate is expired");
0151     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_FINGERPRINT_MISMATCH)) {
0152         return i18nc("Short user visible error string", "Wrong certificate fingerprint");
0153     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_HOSTNAME_MISMATCH)) {
0154         return i18nc("Short user visible error string", "Wrong certificate hostname");
0155     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_INSECURE)) {
0156         return i18nc("Short user visible error string", "Too weak certificate encryption");
0157     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_INVALID)) {
0158         return i18nc("Short user visible error string", "Invalid certificate");
0159     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_LIMIT_EXCEEDED)) {
0160         return i18nc("Short user visible error string", "Certificate length limit exceeded");
0161     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_NOT_ACTIVATED)) {
0162         return i18nc("Short user visible error string", "Certificate not yet active");
0163     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_NOT_PROVIDED)) {
0164         return i18nc("Short user visible error string", "No certificate from server");
0165     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_REVOKED)) {
0166         return i18nc("Short user visible error string", "Certificate revoked");
0167     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_SELF_SIGNED)) {
0168         return i18nc("Short user visible error string", "Untrusted self-signed certificate");
0169     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CERT_UNTRUSTED)) {
0170         return i18nc("Short user visible error string", "Untrusted certificate");
0171     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CHANNEL_BANNED)) {
0172         return i18nc("Short user visible error string", "Banned from channel");
0173     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CHANNEL_FULL)) {
0174         return i18nc("Short user visible error string", "The channel is full");
0175     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CHANNEL_INVITE_ONLY)) {
0176         return i18nc("Short user visible error string", "The channel is invite-only");
0177     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CHANNEL_KICKED)) {
0178         return i18nc("Short user visible error string", "Kicked from channel");
0179     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONFUSED)) {
0180         return i18nc("Short user visible error string", "Something's seriously wrong");
0181     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONNECTION_FAILED)) {
0182         return i18nc("Short user visible error string", "Connection failed");
0183     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONNECTION_LOST)) {
0184         return i18nc("Short user visible error string", "Connection lost");
0185     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONNECTION_REFUSED)) {
0186         return i18nc("Short user visible error string", "Connection refused");
0187     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_CONNECTION_REPLACED)) {
0188         return i18nc("Short user visible error string", "Connection stolen by other account");
0189     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_DISCONNECTED)) {
0190         return i18nc("Short user visible error string", "Disconnected");
0191     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_DOES_NOT_EXIST)) {
0192         return i18nc("Short user visible error string", "User does not exist");
0193     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_EMERGENCY_CALLS_NOT_SUPPORTED)) {
0194         return i18nc("Short user visible error string", "Emergency calls unsupported");
0195     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_ENCRYPTION_ERROR)) {
0196         return i18nc("Short user visible error string", "Encryption error");
0197     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_ENCRYPTION_NOT_AVAILABLE)) {
0198         return i18nc("Short user visible error string", "Encryption not available");
0199     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_INVALID_ARGUMENT)) {
0200         return i18nc("Short user visible error string", "Invalid argument");
0201     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_INVALID_HANDLE)) {
0202         return i18nc("Short user visible error string", "Invalid handle");
0203     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NETWORK_ERROR)) {
0204         return i18nc("Short user visible error string", "Network error");
0205     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NO_ANSWER)) {
0206         return i18nc("Short user visible error string", "Removed from channel");
0207     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_AVAILABLE)) {
0208         return i18nc("Short user visible error string", "Service not available");
0209     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_CAPABLE)) {
0210         return i18nc("Short user visible error string", "Contact has no support");
0211     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_IMPLEMENTED)) {
0212         return i18nc("Short user visible error string", "Operation not implemented");
0213     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_YET)) {
0214         return i18nc("Short user visible error string", "Operation not yet implemented");
0215     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_NOT_YOURS)) {
0216         return i18nc("Short user visible error string", "Channel already being handled");
0217     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_OFFLINE)) {
0218         return i18nc("Short user visible error string", "Contact is offline");
0219     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_PERMISSION_DENIED)) {
0220         return i18nc("Short user visible error string", "Operation not permitted");
0221     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_PICKED_UP_ELSEWHERE)) {
0222         return i18nc("Short user visible error string", "Call picked by other resource");
0223     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_REGISTRATION_EXISTS)) {
0224         return i18nc("Short user visible error string", "Username already taken");
0225     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_REJECTED)) {
0226         return i18nc("Short user visible error string", "Call rejected");
0227     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_RESOURCE_UNAVAILABLE)) {
0228         return i18nc("Short user visible error string", "Insufficient resources");
0229     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_SERVICE_BUSY)) {
0230         return i18nc("Short user visible error string", "Service is busy");
0231     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_SERVICE_CONFUSED)) {
0232         return i18nc("Short user visible error string", "Internal error");
0233     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_SOFTWARE_UPGRADE_REQUIRED)) {
0234         return i18nc("Short user visible error string", "Software upgrade required");
0235     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_TERMINATED)) {
0236         return i18nc("Short user visible error string", "Channel terminated");
0237     } else if (dbusErrorName == QLatin1String(TP_QT_ERROR_WOULD_BREAK_ANONYMITY)) {
0238         return i18nc("Short user visible error string", "Anonymity break possible");
0239     } else if (dbusErrorName == QLatin1String("org.freedesktop.DBus.Error.NoReply")) {
0240         return i18nc("Short user visible error string", "Internal component error");
0241     } else {
0242         //print the error so users can send it in
0243         qCWarning(KTP_COMMONINTERNALS) << "Unknown error encountered:" << dbusErrorName;
0244         return i18nc("User visible error string", "Unknown error");
0245     }
0246 }
0247 
0248 }