diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2008-11-22 00:17:15 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-11-22 00:17:15 +0800 |
commit | ccf82d6956ca277cdc70aa19472d1af3f5763451 (patch) | |
tree | c09d1af6c451c3e7d6b1d6ee9ea16b2422a19159 | |
parent | 231f86f6deb8da116be891567fcdceed81fc6c69 (diff) | |
download | gsoc2013-empathy-ccf82d6956ca277cdc70aa19472d1af3f5763451.tar gsoc2013-empathy-ccf82d6956ca277cdc70aa19472d1af3f5763451.tar.gz gsoc2013-empathy-ccf82d6956ca277cdc70aa19472d1af3f5763451.tar.bz2 gsoc2013-empathy-ccf82d6956ca277cdc70aa19472d1af3f5763451.tar.lz gsoc2013-empathy-ccf82d6956ca277cdc70aa19472d1af3f5763451.tar.xz gsoc2013-empathy-ccf82d6956ca277cdc70aa19472d1af3f5763451.tar.zst gsoc2013-empathy-ccf82d6956ca277cdc70aa19472d1af3f5763451.zip |
Changed _run_ method calls to _call_ calls. (Jonny Lamb)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=1791
-rw-r--r-- | libempathy-gtk/empathy-ft-manager.c | 2 | ||||
-rw-r--r-- | libempathy/empathy-tp-file.c | 165 | ||||
-rw-r--r-- | libempathy/empathy-utils.c | 18 | ||||
-rw-r--r-- | src/empathy-event-manager.c | 87 |
4 files changed, 143 insertions, 129 deletions
diff --git a/libempathy-gtk/empathy-ft-manager.c b/libempathy-gtk/empathy-ft-manager.c index 9ca971099..536e2e7f4 100644 --- a/libempathy-gtk/empathy-ft-manager.c +++ b/libempathy-gtk/empathy-ft-manager.c @@ -1158,7 +1158,7 @@ ft_manager_receive_file_response_cb (GtkWidget *dialog, else { channel = empathy_tp_file_get_channel (response_data->tp_file); - tp_cli_channel_run_close (channel, -1, NULL, NULL); + tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL); free_receive_response_data (response_data); } diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c index 9ce2e3be7..fec91af5a 100644 --- a/libempathy/empathy-tp-file.c +++ b/libempathy/empathy-tp-file.c @@ -268,7 +268,7 @@ tp_file_finalize (GObject *object) DEBUG ("Closing channel.."); g_signal_handlers_disconnect_by_func (priv->channel, tp_file_destroy_cb, object); - tp_cli_channel_run_close (priv->channel, -1, NULL, NULL); + tp_cli_channel_call_close (priv->channel, -1, NULL, NULL, NULL, NULL); if (G_IS_OBJECT (priv->channel)) g_object_unref (priv->channel); } @@ -308,6 +308,49 @@ tp_file_finalize (GObject *object) G_OBJECT_CLASS (empathy_tp_file_parent_class)->finalize (object); } +static void +tp_file_get_all_cb (TpProxy *proxy, + GHashTable *properties, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + EmpathyTpFilePriv *priv = (EmpathyTpFilePriv *) user_data; + + if (error) + { + DEBUG ("Failed to get properties: %s", error->message); + return; + } + + priv->size = g_value_get_uint64 ( + g_hash_table_lookup (properties, "Size")); + + priv->state = g_value_get_uint ( + g_hash_table_lookup (properties, "State")); + + /* Invalid reason, so empathy_file_get_state_change_reason() can give + * a warning if called for a not closed file transfer. */ + priv->state_change_reason = -1; + + priv->transferred_bytes = g_value_get_uint64 ( + g_hash_table_lookup (properties, "TransferredBytes")); + + priv->filename = g_value_dup_string ( + g_hash_table_lookup (properties, "Filename")); + + priv->content_hash = g_value_dup_string ( + g_hash_table_lookup (properties, "ContentHash")); + + priv->description = g_value_dup_string ( + g_hash_table_lookup (properties, "Description")); + + if (priv->state == EMP_FILE_TRANSFER_STATE_LOCAL_PENDING) + priv->incoming = TRUE; + + g_hash_table_destroy (properties); +} + static GObject * tp_file_constructor (GType type, guint n_props, @@ -315,8 +358,6 @@ tp_file_constructor (GType type, { GObject *tp_file; EmpathyTpFilePriv *priv; - GError *error = NULL; - GHashTable *properties; TpHandle handle; tp_file = G_OBJECT_CLASS (empathy_tp_file_parent_class)->constructor (type, @@ -352,39 +393,8 @@ tp_file_constructor (GType type, priv->account, (guint) handle); - if (!tp_cli_dbus_properties_run_get_all (priv->channel, - -1, EMP_IFACE_CHANNEL_TYPE_FILE, &properties, &error, NULL)) - { - DEBUG ("Failed to get properties: %s", - error ? error->message : "No error given"); - g_clear_error (&error); - return NULL; - } - - priv->size = g_value_get_uint64 (g_hash_table_lookup (properties, "Size")); - - priv->state = g_value_get_uint (g_hash_table_lookup (properties, "State")); - - /* Invalid reason, so empathy_file_get_state_change_reason() can give - * a warning if called for a not closed file transfer. */ - priv->state_change_reason = -1; - - priv->transferred_bytes = g_value_get_uint64 (g_hash_table_lookup ( - properties, "TransferredBytes")); - - priv->filename = g_value_dup_string (g_hash_table_lookup (properties, - "Filename")); - - priv->content_hash = g_value_dup_string (g_hash_table_lookup (properties, - "ContentHash")); - - priv->description = g_value_dup_string (g_hash_table_lookup (properties, - "Description")); - - if (priv->state == EMP_FILE_TRANSFER_STATE_LOCAL_PENDING) - priv->incoming = TRUE; - - g_hash_table_destroy (properties); + tp_cli_dbus_properties_call_get_all (priv->channel, + -1, EMP_IFACE_CHANNEL_TYPE_FILE, tp_file_get_all_cb, priv, NULL, NULL); return tp_file; } @@ -421,13 +431,9 @@ tp_file_channel_set_dbus_property (gpointer proxy, const GValue *value) { DEBUG ("Setting %s property", property); - tp_cli_dbus_properties_run_set (TP_PROXY (proxy), - -1, - EMP_IFACE_CHANNEL_TYPE_FILE, - property, - value, - NULL, NULL); - DEBUG ("done"); + tp_cli_dbus_properties_call_set (TP_PROXY (proxy), -1, + EMP_IFACE_CHANNEL_TYPE_FILE, property, value, + NULL, NULL, NULL, NULL); } @@ -615,6 +621,30 @@ _get_local_socket (EmpathyTpFile *tp_file) return fd; } +static void +tp_file_method_cb (TpProxy *proxy, + const GValue *address, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + EmpathyTpFilePriv *priv = (EmpathyTpFilePriv *) user_data; + + if (error) + { + DEBUG ("Error: %s", error->message); + return; + } + + if (priv->unix_socket_path) + g_free (priv->unix_socket_path); + + priv->unix_socket_path = g_value_dup_string (address); + + DEBUG ("Got unix socket path: %s", priv->unix_socket_path); +} + + /** * empathy_tp_file_accept: * @tp_file: an #EmpathyTpFile @@ -627,9 +657,7 @@ empathy_tp_file_accept (EmpathyTpFile *tp_file, guint64 offset) { EmpathyTpFilePriv *priv; - GValue *address; GValue nothing = { 0 }; - GError *error = NULL; g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file)); @@ -642,31 +670,22 @@ empathy_tp_file_accept (EmpathyTpFile *tp_file, g_value_init (¬hing, G_TYPE_STRING); g_value_set_string (¬hing, ""); - if (!emp_cli_channel_type_file_run_accept_file (TP_PROXY (priv->channel), + emp_cli_channel_type_file_call_accept_file (TP_PROXY (priv->channel), -1, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST, - ¬hing, offset, &address, &error, NULL)) - { - DEBUG ("Accept error: %s", - error ? error->message : "No message given"); - g_clear_error (&error); - return; - } - - if (priv->unix_socket_path) - g_free (priv->unix_socket_path); - - priv->unix_socket_path = g_value_dup_string (address); - g_value_unset (address); - - DEBUG ("Got unix socket path: %s", priv->unix_socket_path); + ¬hing, offset, tp_file_method_cb, priv, NULL, NULL); } +/** + * empathy_tp_file_offer: + * @tp_file: an #EmpathyTpFile + * + * Offers a file transfer that's in the "not offered" state (i.e. + * EMP_FILE_TRANSFER_STATE_NOT_OFFERED). + */ void empathy_tp_file_offer (EmpathyTpFile *tp_file) { EmpathyTpFilePriv *priv; - GValue *address; - GError *error = NULL; GValue nothing = { 0 }; g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file)); @@ -676,23 +695,9 @@ empathy_tp_file_offer (EmpathyTpFile *tp_file) g_value_init (¬hing, G_TYPE_STRING); g_value_set_string (¬hing, ""); - if (!emp_cli_channel_type_file_run_offer_file (TP_PROXY (priv->channel), + emp_cli_channel_type_file_call_offer_file (TP_PROXY (priv->channel), -1, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST, - ¬hing, &address, &error, NULL)) - { - DEBUG ("OfferFile error: %s", - error ? error->message : "No message given"); - g_clear_error (&error); - return; - } - - if (priv->unix_socket_path) - g_free (priv->unix_socket_path); - - priv->unix_socket_path = g_value_dup_string (address); - g_value_unset (address); - - DEBUG ("Got unix socket path: %s", priv->unix_socket_path); + ¬hing, tp_file_method_cb, priv, NULL, NULL); } static void @@ -925,7 +930,7 @@ empathy_tp_file_cancel (EmpathyTpFile *tp_file) priv = GET_PRIV (tp_file); - tp_cli_channel_run_close (priv->channel, -1, NULL, NULL); + tp_cli_channel_call_close (priv->channel, -1, NULL, NULL, NULL, NULL); g_cancellable_cancel (priv->cancellable); } diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 7397a0784..a789fdc31 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -843,23 +843,23 @@ empathy_send_file (EmpathyContact *contact, g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, g_filename_display_basename (filename)); - tp_cli_dbus_properties_run_set (TP_PROXY (channel), - -1, EMP_IFACE_CHANNEL_TYPE_FILE, "Filename", - &value, NULL, NULL); + tp_cli_dbus_properties_call_set (TP_PROXY (channel), -1, + EMP_IFACE_CHANNEL_TYPE_FILE, "Filename", + &value, NULL, NULL, NULL, NULL); g_value_reset (&value); g_value_set_string (&value, g_file_info_get_content_type (info)); - tp_cli_dbus_properties_run_set (TP_PROXY (channel), - -1, EMP_IFACE_CHANNEL_TYPE_FILE, "ContentType", - &value, NULL, NULL); + tp_cli_dbus_properties_call_set (TP_PROXY (channel), -1, + EMP_IFACE_CHANNEL_TYPE_FILE, "Filename", + &value, NULL, NULL, NULL, NULL); g_value_unset (&value); g_value_init (&value, G_TYPE_UINT64); g_value_set_uint64 (&value, size); - tp_cli_dbus_properties_run_set (TP_PROXY (channel), - -1, EMP_IFACE_CHANNEL_TYPE_FILE, "Size", - &value, NULL, NULL); + tp_cli_dbus_properties_call_set (TP_PROXY (channel), -1, + EMP_IFACE_CHANNEL_TYPE_FILE, "Size", + &value, NULL, NULL, NULL, NULL); g_value_unset (&value); tp_file = empathy_tp_file_new (account, channel); diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index 913e69c9f..fdc3fc332 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -189,6 +189,48 @@ event_channel_file_process_func (EventPriv *event) } static void +file_channel_state_cb (TpProxy *proxy, + const GValue *state, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + TpChannel *channel = (TpChannel *) weak_object; + EmpathyEventManager *manager = (EmpathyEventManager *) user_data; + + if (error) { + DEBUG ("Error: %s", error->message); + return; + } + + /* Only deal with incoming channels */ + if (g_value_get_uint (state) == + EMP_FILE_TRANSFER_STATE_LOCAL_PENDING) { + EmpathyContact *contact; + gchar *msg; + McAccount *account; + EmpathyTpFile *tp_file; + + account = empathy_channel_get_account (channel); + tp_file = empathy_tp_file_new (account, channel); + + contact = empathy_tp_file_get_contact (tp_file); + + msg = g_strdup_printf (_("Incoming file transfer from %s"), + empathy_contact_get_name (contact)); + + event_manager_add (manager, contact, + EMPATHY_IMAGE_DOCUMENT_SEND, + msg, + channel, + event_channel_file_process_func, + tp_file); + + g_free (msg); + } +} + +static void event_manager_filter_channel_cb (EmpathyDispatcher *dispatcher, TpChannel *channel, EmpathyEventManager *manager) @@ -227,45 +269,12 @@ event_manager_filter_channel_cb (EmpathyDispatcher *dispatcher, g_object_unref (tp_group); } else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_FILE)) { - GValue *state; - - tp_cli_dbus_properties_run_get (channel, - -1, - EMP_IFACE_CHANNEL_TYPE_FILE, - "State", - &state, - NULL, - NULL); - - DEBUG ("file channel with state %u", g_value_get_uint (state)); - - /* Only deal with incoming channels */ - if (g_value_get_uint (state) == - EMP_FILE_TRANSFER_STATE_LOCAL_PENDING) { - EmpathyContact *contact; - gchar *msg; - McAccount *account; - EmpathyTpFile *tp_file; - - account = empathy_channel_get_account (channel); - tp_file = empathy_tp_file_new (account, channel); - - contact = empathy_tp_file_get_contact (tp_file); - - msg = g_strdup_printf (_("Incoming file transfer from %s"), - empathy_contact_get_name (contact)); - - event_manager_add (manager, contact, - EMPATHY_IMAGE_DOCUMENT_SEND, - msg, - channel, - event_channel_file_process_func, - tp_file); - - g_free (msg); - } - - g_value_unset (state); + tp_cli_dbus_properties_call_get (channel, -1, + EMP_IFACE_CHANNEL_TYPE_FILE, + "State", + file_channel_state_cb, + manager, NULL, + G_OBJECT (channel)); } g_free (channel_type); |