aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2009-09-08 23:22:00 +0800
committerJonny Lamb <jonny.lamb@collabora.co.uk>2009-09-08 23:22:00 +0800
commit469e38c1578332e3cff6ceea9bf0940f9965ff04 (patch)
tree40e7c8abbca53f36c1f9fe885c317cb82e0a45b6 /src
parent0cfd64b658e967d9e2257bb21aa43dce4762ee29 (diff)
parent923bb82f3aa66ac7b24168b5b69541268bf9d055 (diff)
downloadgsoc2013-empathy-469e38c1578332e3cff6ceea9bf0940f9965ff04.tar
gsoc2013-empathy-469e38c1578332e3cff6ceea9bf0940f9965ff04.tar.gz
gsoc2013-empathy-469e38c1578332e3cff6ceea9bf0940f9965ff04.tar.bz2
gsoc2013-empathy-469e38c1578332e3cff6ceea9bf0940f9965ff04.tar.lz
gsoc2013-empathy-469e38c1578332e3cff6ceea9bf0940f9965ff04.tar.xz
gsoc2013-empathy-469e38c1578332e3cff6ceea9bf0940f9965ff04.tar.zst
gsoc2013-empathy-469e38c1578332e3cff6ceea9bf0940f9965ff04.zip
Merge branch 'auto-connect'
Diffstat (limited to 'src')
-rw-r--r--src/empathy.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/empathy.c b/src/empathy.c
index ed90cb5e1..8a2f107b7 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -627,6 +627,89 @@ setup_dispatcher (void)
return d;
}
+static void
+account_connection_notify_cb (EmpathyAccount *account,
+ GParamSpec *pspec,
+ EmpathyChatroom *room)
+{
+ TpConnection *conn;
+
+ conn = empathy_account_get_connection (account);
+
+ if (conn == NULL)
+ return;
+
+ empathy_dispatcher_join_muc (conn,
+ empathy_chatroom_get_room (room), NULL, NULL);
+}
+
+static void
+account_manager_chatroom_ready_cb (EmpathyAccountManager *account_manager,
+ GParamSpec *pspec,
+ EmpathyChatroomManager *chatroom_manager)
+{
+ GList *accounts, *l;
+
+ accounts = empathy_account_manager_dup_accounts (account_manager);
+
+ for (l = accounts; l != NULL; l = g_list_next (l))
+ {
+ EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
+ TpConnection *conn;
+ GList *chatrooms, *p;
+
+ conn = empathy_account_get_connection (account);
+
+ chatrooms = empathy_chatroom_manager_get_chatrooms (
+ chatroom_manager, account);
+
+ for (p = chatrooms; p != NULL; p = p->next)
+ {
+ EmpathyChatroom *room = EMPATHY_CHATROOM (p->data);
+
+ if (!empathy_chatroom_get_auto_connect (room))
+ continue;
+
+ if (conn == NULL)
+ {
+ g_signal_connect (G_OBJECT (account), "notify::connection",
+ G_CALLBACK (account_connection_notify_cb), room);
+ }
+ else
+ {
+ empathy_dispatcher_join_muc (conn,
+ empathy_chatroom_get_room (room), NULL, NULL);
+ }
+ }
+
+ g_list_free (chatrooms);
+ }
+
+ g_list_foreach (accounts, (GFunc) g_object_unref, NULL);
+ g_list_free (accounts);
+}
+
+static void
+chatroom_manager_ready_cb (EmpathyChatroomManager *chatroom_manager,
+ GParamSpec *pspec,
+ EmpathyAccountManager *account_manager)
+{
+ gboolean ready;
+
+ g_object_get (G_OBJECT (account_manager), "ready", &ready, NULL);
+
+ if (ready)
+ {
+ account_manager_chatroom_ready_cb (account_manager, NULL,
+ chatroom_manager);
+ }
+ else
+ {
+ g_signal_connect (account_manager, "notify::ready",
+ G_CALLBACK (account_manager_chatroom_ready_cb), chatroom_manager);
+ }
+}
+
int
main (int argc, char *argv[])
{
@@ -650,6 +733,7 @@ main (int argc, char *argv[])
GError *error = NULL;
TpDBusDaemon *dbus_daemon;
UniqueApp *unique_app;
+ gboolean chatroom_manager_ready;
GOptionContext *optcontext;
GOptionEntry options[] = {
@@ -794,6 +878,17 @@ main (int argc, char *argv[])
chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
empathy_chatroom_manager_observe (chatroom_manager, dispatcher);
+ g_object_get (chatroom_manager, "ready", &chatroom_manager_ready, NULL);
+ if (!chatroom_manager_ready)
+ {
+ g_signal_connect (G_OBJECT (chatroom_manager), "notify::ready",
+ G_CALLBACK (chatroom_manager_ready_cb), account_manager);
+ }
+ else
+ {
+ chatroom_manager_ready_cb (chatroom_manager, NULL, account_manager);
+ }
+
notify_init (_(PACKAGE_NAME));
/* Create the call factory */
call_factory = empathy_call_factory_initialise ();