]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-dispatcher.c
empathy-dispatcher: deal properly with NULL channel_wrapper
[empathy.git] / libempathy / empathy-dispatcher.c
index 769b42120a83efe12886a12b0d75b08f82022b69..ab00503c813d804f4f7962ba9abccc050ab65773 100644 (file)
@@ -121,7 +121,8 @@ new_dispatch_data (TpChannel *channel,
 {
   DispatchData *d = g_slice_new0 (DispatchData);
   d->channel = g_object_ref (channel);
-  d->channel_wrapper = g_object_ref (channel_wrapper);
+  if (channel_wrapper != NULL)
+    d->channel_wrapper = g_object_ref (channel_wrapper);
 
   return d;
 }
@@ -130,7 +131,8 @@ static void
 free_dispatch_data (DispatchData *data)
 {
   g_object_unref (data->channel);
-  g_object_unref (data->channel_wrapper);
+  if (data->channel_wrapper != NULL)
+    g_object_unref (data->channel_wrapper);
 
   g_slice_free (DispatchData, data);
 }
@@ -698,8 +700,11 @@ dispatcher_connection_new_channels_cb (TpConnection *connection,
 }
 
 static void
-dispatcher_connection_got_all (TpProxy *proxy, GHashTable *properties,
-  const GError *error, gpointer user_data, GObject *object)
+dispatcher_connection_got_all (TpProxy *proxy,
+                               GHashTable *properties,
+                               const GError *error,
+                               gpointer user_data,
+                               GObject *object)
 {
   EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (object);
   EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
@@ -896,7 +901,7 @@ dispatcher_constructor (GType type,
           (type, n_construct_params, construct_params);
 
       dispatcher = EMPATHY_DISPATCHER (retval);
-      g_object_add_weak_pointer (retval, (gpointer *) &dispatcher);
+      g_object_add_weak_pointer (retval, (gpointer) &dispatcher);
     }
   else
     {
@@ -1162,6 +1167,8 @@ empathy_dispatcher_call_with_contact (EmpathyContact *contact,
   ConnectionData *cd;
   DispatcherRequestData *request_data;
 
+  g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
   account = empathy_contact_get_account (contact);
   connection = g_hash_table_lookup (priv->accounts, account);
 
@@ -1204,6 +1211,8 @@ empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
   ConnectionData *connection_data;
   DispatcherRequestData *request_data;
 
+  g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
   dispatcher = empathy_dispatcher_dup_singleton();
   priv = GET_PRIV (dispatcher);
 
@@ -1236,6 +1245,9 @@ empathy_dispatcher_chat_with_contact_id (McAccount *account,
   EmpathyContactFactory *factory;
   EmpathyContact        *contact;
 
+  g_return_if_fail (MC_IS_ACCOUNT (account));
+  g_return_if_fail (!EMP_STR_EMPTY (contact_id));
+
   factory = empathy_contact_factory_dup_singleton ();
   contact = empathy_contact_factory_get_from_id (factory, account, contact_id);
 
@@ -1292,6 +1304,9 @@ empathy_dispatcher_join_muc (McAccount *account,
   ConnectionData *connection_data;
   const gchar *names[] = { roomname, NULL };
 
+  g_return_if_fail (MC_IS_ACCOUNT (account));
+  g_return_if_fail (!EMP_STR_EMPTY (roomname));
+
   dispatcher = empathy_dispatcher_dup_singleton();
   priv = GET_PRIV (dispatcher);
 
@@ -1332,8 +1347,10 @@ dispatcher_create_channel_cb (TpConnection *connect,
 
 void
 empathy_dispatcher_create_channel (EmpathyDispatcher *dispatcher,
-  McAccount *account, GHashTable *request,
-  EmpathyDispatcherRequestCb *callback, gpointer user_data)
+                                   McAccount *account,
+                                   GHashTable *request,
+                                   EmpathyDispatcherRequestCb *callback,
+                                   gpointer user_data)
 {
   EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
   ConnectionData *connection_data;
@@ -1344,6 +1361,10 @@ empathy_dispatcher_create_channel (EmpathyDispatcher *dispatcher,
   gboolean valid;
   TpConnection *connection;
 
+  g_return_if_fail (EMPATHY_IS_DISPATCHER (dispatcher));
+  g_return_if_fail (MC_IS_ACCOUNT (account));
+  g_return_if_fail (request != NULL);
+
   connection = g_hash_table_lookup (priv->accounts, account);
   g_assert (connection != NULL);
 
@@ -1442,6 +1463,10 @@ empathy_dispatcher_send_file_to_contact (EmpathyContact *contact,
   GHashTable *request = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
       (GDestroyNotify) tp_g_value_slice_free);
 
+  g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+  g_return_if_fail (!EMP_STR_EMPTY (filename));
+  g_return_if_fail (!EMP_STR_EMPTY (content_type));
+
   /* org.freedesktop.Telepathy.Channel.ChannelType */
   value = tp_g_value_slice_new (G_TYPE_STRING);
   g_value_set_string (value, EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER);
@@ -1492,7 +1517,9 @@ empathy_dispatcher_send_file_to_contact (EmpathyContact *contact,
 
 GStrv
 empathy_dispatcher_find_channel_class (EmpathyDispatcher *dispatcher,
-  McAccount *account, const gchar *channel_type, guint handle_type)
+                                       McAccount *account,
+                                       const gchar *channel_type,
+                                       guint handle_type)
 {
   EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
   ConnectionData *cd;