]> www.infradead.org Git - pidgin-chime.git/commitdiff
Close Joinable Meetings dialog when there are none left
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 25 Apr 2018 14:36:34 +0000 (15:36 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 25 Apr 2018 14:36:36 +0000 (15:36 +0100)
In fact, we should probably do this when we *join* the only meeting too.

prpl/meeting.c

index a04d03ac4ed8f0381c93251a1536820554c5de6e..ad19a93c080078e8ce7594698331ecb738e4350c 100644 (file)
@@ -372,13 +372,30 @@ static gboolean update_joinable(gpointer _conn)
        return FALSE;
 }
 
+static void count_mtg(ChimeConnection *cxn, ChimeMeeting *mtg, gpointer _count)
+{
+       int *count = _count;
+
+       (*count)++;
+}
 
 static void on_joinable_changed(ChimeMeeting *mtg, GParamSpec *ignored, PurpleConnection *conn)
 {
        struct purple_chime *pc = purple_connection_get_protocol_data(conn);
 
-       if (pc->joinable_handle && !pc->joinable_refresh_id)
-               pc->joinable_refresh_id = g_idle_add(update_joinable, conn);
+       if (pc->joinable_handle) {
+               int count = 0;
+
+               chime_connection_foreach_meeting(PURPLE_CHIME_CXN(conn), count_mtg, &count);
+               if (!count) {
+                       if (pc->joinable_refresh_id)
+                               g_source_remove(pc->joinable_refresh_id);
+                       pc->joinable_refresh_id = 0;
+                       purple_notify_close(PURPLE_NOTIFY_SEARCHRESULTS, pc->joinable_handle);
+                       pc->joinable_handle = NULL;
+               } else if (!pc->joinable_refresh_id)
+                       pc->joinable_refresh_id = g_idle_add(update_joinable, conn);
+       }
 }
 
 static void unsub_mtg(ChimeConnection *cxn, ChimeMeeting *mtg, gpointer _conn)