]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-utils.c
Updated Polish translation
[empathy.git] / libempathy / empathy-utils.c
index dacc1d88c883b53af7a3c06c65e1b396ac5f4495..7d169ff94d55d1c465e432c17f4ada1a042e3152 100644 (file)
@@ -242,7 +242,7 @@ empathy_presence_get_default_message (TpConnectionPresenceType presence)
        case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
                return _("Away");
        case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
-               return _("Hidden");
+               return _("Invisible");
        case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
                return _("Offline");
        case TP_CONNECTION_PRESENCE_TYPE_UNSET:
@@ -278,6 +278,43 @@ empathy_presence_from_str (const gchar *str)
        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 _("Status is set to offline");
+       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)
 {
@@ -354,6 +391,15 @@ empathy_uint_compare (gconstpointer a,
 gchar *
 empathy_protocol_icon_name (const gchar *protocol)
 {
+  if (!tp_strdiff (protocol, "yahoojp"))
+    /* Yahoo Japan uses the same icon as Yahoo */
+    protocol = "yahoo";
+  else if (!tp_strdiff (protocol, "simple"))
+    /* SIMPLE uses the same icon as SIP */
+    protocol = "sip";
+  else if (!tp_strdiff (protocol, "sms"))
+    return g_strdup ("phone");
+
   return g_strdup_printf ("im-%s", protocol);
 }
 
@@ -503,8 +549,6 @@ empathy_get_account_for_connection (TpConnection *connection)
 
   manager = tp_account_manager_dup ();
 
-  /* FIXME: assumes account manager is prepared */
-
   accounts = tp_account_manager_get_valid_accounts (manager);
 
   for (l = accounts; l != NULL; l = l->next)
@@ -523,3 +567,79 @@ empathy_get_account_for_connection (TpConnection *connection)
 
   return account;
 }
+
+gboolean
+empathy_account_manager_get_accounts_connected (gboolean *connecting)
+{
+  TpAccountManager *manager;
+  GList *accounts, *l;
+  gboolean out_connecting = FALSE;
+  gboolean out_connected = FALSE;
+
+  manager = tp_account_manager_dup ();
+
+  if (G_UNLIKELY (!tp_account_manager_is_prepared (manager,
+          TP_ACCOUNT_MANAGER_FEATURE_CORE)))
+    g_critical (G_STRLOC ": %s called before AccountManager ready", G_STRFUNC);
+
+  accounts = tp_account_manager_get_valid_accounts (manager);
+
+  for (l = accounts; l != NULL; l = l->next)
+    {
+      TpConnectionStatus s = tp_account_get_connection_status (
+          TP_ACCOUNT (l->data), NULL);
+
+      if (s == TP_CONNECTION_STATUS_CONNECTING)
+        out_connecting = TRUE;
+      else if (s == TP_CONNECTION_STATUS_CONNECTED)
+        out_connected = TRUE;
+
+      if (out_connecting && out_connected)
+        break;
+    }
+
+  g_list_free (accounts);
+  g_object_unref (manager);
+
+  if (connecting != NULL)
+    *connecting = out_connecting;
+
+  return out_connected;
+}
+
+/* Change the RequestedPresence of a newly created account to ensure that it
+ * is actually connected. */
+void
+empathy_connect_new_account (TpAccount *account,
+    TpAccountManager *account_manager)
+{
+  TpConnectionPresenceType presence;
+  gchar *status, *message;
+
+  /* only force presence if presence was offline, unknown or unset */
+  presence = tp_account_get_requested_presence (account, NULL, NULL);
+  switch (presence)
+    {
+      case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
+      case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
+      case TP_CONNECTION_PRESENCE_TYPE_UNSET:
+        presence = tp_account_manager_get_most_available_presence (
+            account_manager, &status, &message);
+
+        if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
+          /* Global presence is offline; we force it so user doesn't have to
+           * manually change the presence to connect his new account. */
+          presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
+
+        tp_account_request_presence_async (account, presence,
+            status, NULL, NULL, NULL);
+
+        g_free (status);
+        g_free (message);
+        break;
+
+       default:
+        /* do nothing if the presence is not offline */
+        break;
+    }
+}