]> git.0d.be Git - empathy.git/commitdiff
refactor friendly status reason messages
authorFelix Kaser <f.kaser@gmx.net>
Tue, 8 Dec 2009 18:41:57 +0000 (19:41 +0100)
committerFelix Kaser <f.kaser@gmx.net>
Tue, 15 Dec 2009 12:52:45 +0000 (13:52 +0100)
the friendly status reason can be asked from empathy-utils

libempathy/empathy-utils.c
libempathy/empathy-utils.h
src/empathy-accounts-dialog.c
src/empathy-main-window.c

index 3acd4707d253e0ea6e0e39a154f095c8d5522f3e..6fdd6d257923cd70e15448c0f8657f5d576f8460 100644 (file)
@@ -278,6 +278,43 @@ empathy_presence_from_str (const gchar *str)
        return TP_CONNECTION_PRESENCE_TYPE_UNSET;
 }
 
        return TP_CONNECTION_PRESENCE_TYPE_UNSET;
 }
 
+const gchar *
+empathy_status_reason_get_default_message (TpConnectionStatusReason reason)
+{
+       switch (reason) {
+       case TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED:
+               return _("No reason specified");
+       case TP_CONNECTION_STATUS_REASON_REQUESTED:
+               return _("User requested disconnect");
+       case TP_CONNECTION_STATUS_REASON_NETWORK_ERROR:
+               return _("Network error");
+       case TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
+               return _("Authentication failed");
+       case TP_CONNECTION_STATUS_REASON_ENCRYPTION_ERROR:
+               return _("Encryption error");
+       case TP_CONNECTION_STATUS_REASON_NAME_IN_USE:
+               return _("Name in use");
+       case TP_CONNECTION_STATUS_REASON_CERT_NOT_PROVIDED:
+               return _("Certificate not provided");
+       case TP_CONNECTION_STATUS_REASON_CERT_UNTRUSTED:
+               return _("Certificate untrusted");
+       case TP_CONNECTION_STATUS_REASON_CERT_EXPIRED:
+               return _("Certificate expired");
+       case TP_CONNECTION_STATUS_REASON_CERT_NOT_ACTIVATED:
+               return _("Certificate not activated");
+       case TP_CONNECTION_STATUS_REASON_CERT_HOSTNAME_MISMATCH:
+               return _("Certificate hostname mismatch");
+       case TP_CONNECTION_STATUS_REASON_CERT_FINGERPRINT_MISMATCH:
+               return _("Certificate fingerprint mismatch");
+       case TP_CONNECTION_STATUS_REASON_CERT_SELF_SIGNED:
+               return _("Certificate self-signed");
+       case TP_CONNECTION_STATUS_REASON_CERT_OTHER_ERROR:
+               return _("Certificate error");
+       default:
+               return _("Unknown reason");
+       }
+}
+
 gchar *
 empathy_file_lookup (const gchar *filename, const gchar *subdir)
 {
 gchar *
 empathy_file_lookup (const gchar *filename, const gchar *subdir)
 {
index 97e5e85b7fa9fec1e0687680b0121b7dc199f69f..0fc6fc2a9773282116784640400b9e414304aeca 100644 (file)
@@ -73,6 +73,7 @@ guint        empathy_proxy_hash                     (gconstpointer    key);
 gboolean     empathy_check_available_state          (void);
 gint        empathy_uint_compare                    (gconstpointer a,
                                                     gconstpointer b);
 gboolean     empathy_check_available_state          (void);
 gint        empathy_uint_compare                    (gconstpointer a,
                                                     gconstpointer b);
+const gchar * empathy_status_reason_get_default_message (TpConnectionStatusReason reason);
 
 gchar *empathy_protocol_icon_name (const gchar *protocol);
 const gchar *empathy_protocol_name_to_display_name (const gchar *proto_name);
 
 gchar *empathy_protocol_icon_name (const gchar *protocol);
 const gchar *empathy_protocol_name_to_display_name (const gchar *proto_name);
index 016e8b6c376e17cc805e92dbf92e7129f22b95e9..49c65f071f6cbb1d053067300a9c1f06675d54f7 100644 (file)
@@ -212,57 +212,19 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
             gtk_widget_hide (priv->throbber);
             break;
           case TP_CONNECTION_STATUS_DISCONNECTED:
             gtk_widget_hide (priv->throbber);
             break;
           case TP_CONNECTION_STATUS_DISCONNECTED:
-            switch (reason)
+            message = g_strdup_printf (_("Offline - %s"),
+                empathy_status_reason_get_default_message (reason));
+
+            if (reason == TP_CONNECTION_STATUS_REASON_REQUESTED)
               {
               {
-                case TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED:
-                  message = _("Disconnected - No error specified");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_REQUESTED:
-                  message = _("Disconnected - Requested");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_NETWORK_ERROR:
-                  message = _("Disconnected - Network error");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
-                  message = _("Disconnected - Authentication failed");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_ENCRYPTION_ERROR:
-                  message = _("Disconnected - Encryption error");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_NAME_IN_USE:
-                  message = _("Disconnected - Name in use");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_CERT_NOT_PROVIDED:
-                  message = _("Disconnected - Certificate not provided");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_CERT_UNTRUSTED:
-                  message = _("Disconnected - Certificate untrusted");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_CERT_EXPIRED:
-                  message = _("Disconnected - Certificate expired");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_CERT_NOT_ACTIVATED:
-                  message = _("Disconnected - Certificate not activated");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_CERT_HOSTNAME_MISMATCH:
-                  message = _("Disconnected - Certificate hostname mismatch");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_CERT_FINGERPRINT_MISMATCH:
-                  message = _("Disconnected - Certificate fingerprint mismatch");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_CERT_SELF_SIGNED:
-                  message = _("Disconnected - Certificate self-signed");
-                  break;
-                case TP_CONNECTION_STATUS_REASON_CERT_OTHER_ERROR:
-                  message = _("Disconnected - Certificate error");
-                  break;
-                default:
-                  message = _("Disconnected - Unknown reason");
-                  break;
+                gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
+                    GTK_MESSAGE_WARNING);
+              }
+            else
+              {
+                gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
+                    GTK_MESSAGE_ERROR);
               }
               }
-
-            gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
-                GTK_MESSAGE_ERROR);
 
             ephy_spinner_stop (EPHY_SPINNER (priv->throbber));
             gtk_widget_show (priv->image_status);
 
             ephy_spinner_stop (EPHY_SPINNER (priv->throbber));
             gtk_widget_show (priv->image_status);
@@ -280,7 +242,7 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
     }
   else
     {
     }
   else
     {
-      message = _("Disconnected - Account disabled");
+      message = _("Offline - Account disabled");
       gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
           GTK_MESSAGE_WARNING);
       ephy_spinner_stop (EPHY_SPINNER (priv->throbber));
       gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
           GTK_MESSAGE_WARNING);
       ephy_spinner_stop (EPHY_SPINNER (priv->throbber));
index 44eeff3ac78487244909b72a335224fdec84ec6c..447e25b4858cfbe2f9cec6853d41ea769c2f7483 100644 (file)
@@ -519,50 +519,7 @@ main_window_connection_changed_cb (TpAccount  *account,
            reason != TP_CONNECTION_STATUS_REASON_REQUESTED) {
                const gchar *message;
 
            reason != TP_CONNECTION_STATUS_REASON_REQUESTED) {
                const gchar *message;
 
-               switch (reason) {
-               case TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED:
-                       message = _("No error specified");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_NETWORK_ERROR:
-                       message = _("Network error");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
-                       message = _("Authentication failed");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_ENCRYPTION_ERROR:
-                       message = _("Encryption error");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_NAME_IN_USE:
-                       message = _("Name in use");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_CERT_NOT_PROVIDED:
-                       message = _("Certificate not provided");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_CERT_UNTRUSTED:
-                       message = _("Certificate untrusted");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_CERT_EXPIRED:
-                       message = _("Certificate expired");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_CERT_NOT_ACTIVATED:
-                       message = _("Certificate not activated");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_CERT_HOSTNAME_MISMATCH:
-                       message = _("Certificate hostname mismatch");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_CERT_FINGERPRINT_MISMATCH:
-                       message = _("Certificate fingerprint mismatch");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_CERT_SELF_SIGNED:
-                       message = _("Certificate self-signed");
-                       break;
-               case TP_CONNECTION_STATUS_REASON_CERT_OTHER_ERROR:
-                       message = _("Certificate error");
-                       break;
-               default:
-                       message = _("Unknown error");
-                       break;
-               }
+               message = empathy_status_reason_get_default_message (reason);
 
                main_window_error_display (window, account, message);
        }
 
                main_window_error_display (window, account, message);
        }