]> git.0d.be Git - empathy.git/commitdiff
Support Conn.I.Balance.ManageCreditURI
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 15 Apr 2011 05:24:23 +0000 (15:24 +1000)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Thu, 5 May 2011 07:12:20 +0000 (17:12 +1000)
src/empathy-main-window.c

index 03386a01a1f023f0f9066164be6f6ad3065bd65f..ed306509e91d726dbf48166afd29b08051b24265 100644 (file)
@@ -801,7 +801,16 @@ static void
 main_window_balance_activate_cb (GtkAction         *action,
                                 EmpathyMainWindow *window)
 {
-       DEBUG ("ACTIVATE!");
+       const char *uri;
+
+       uri = g_object_get_data (G_OBJECT (action), "manage-credit-uri");
+
+       if (!tp_str_empty (uri)) {
+               DEBUG ("Top-up credit URI: %s", uri);
+               empathy_url_show (GTK_WIDGET (window), uri);
+       } else {
+               DEBUG ("unknown protocol for top-up");
+       }
 }
 
 static void
@@ -840,23 +849,30 @@ main_window_balance_update_balance (GtkAction   *action,
 }
 
 static void
-main_window_setup_balance_got_balance (TpProxy      *conn,
-                                      const GValue *value,
-                                      const GError *in_error,
-                                      gpointer      user_data,
-                                      GObject      *action)
+main_window_setup_balance_got_balance_props (TpProxy      *conn,
+                                            GHashTable   *props,
+                                            const GError *in_error,
+                                            gpointer      user_data,
+                                            GObject      *action)
 {
        GValueArray *balance = NULL;
+       const char *uri;
 
        if (in_error != NULL) {
-               DEBUG ("Failed to get account balance: %s",
+               DEBUG ("Failed to get account balance properties: %s",
                        in_error->message);
-       } else if (!G_VALUE_HOLDS (value, TP_STRUCT_TYPE_CURRENCY_AMOUNT)) {
-               DEBUG ("Type mismatch");
-       } else {
-               balance = g_value_get_boxed (value);
+               goto finally;
        }
 
+       balance = tp_asv_get_boxed (props, "AccountBalance",
+               TP_STRUCT_TYPE_CURRENCY_AMOUNT);
+       uri = tp_asv_get_string (props, "ManageCreditURI");
+
+       g_object_set_data_full (action, "manage-credit-uri",
+               g_strdup (uri), g_free);
+       gtk_action_set_sensitive (GTK_ACTION (action), !tp_str_empty (uri));
+
+finally:
        main_window_balance_update_balance (GTK_ACTION (action), balance);
 }
 
@@ -950,10 +966,9 @@ main_window_setup_balance_conn_ready (GObject      *conn,
        }
 
        /* request the current balance and monitor for any changes */
-       tp_cli_dbus_properties_call_get (conn, -1,
+       tp_cli_dbus_properties_call_get_all (conn, -1,
                TP_IFACE_CONNECTION_INTERFACE_BALANCE,
-               "AccountBalance",
-               main_window_setup_balance_got_balance,
+               main_window_setup_balance_got_balance_props,
                window, NULL, G_OBJECT (action));
 
        tp_cli_connection_interface_balance_connect_to_balance_changed (