Add g_at_chat_unregister_all function
authorDenis Kenzior <denkenz@gmail.com>
Wed, 2 Dec 2009 23:27:58 +0000 (17:27 -0600)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 3 Dec 2009 01:16:21 +0000 (02:16 +0100)
gatchat/gatchat.c
gatchat/gatchat.h

index 54e6434..d090766 100644 (file)
@@ -1346,6 +1346,34 @@ gboolean g_at_chat_unregister(GAtChat *chat, guint id)
        return TRUE;
 }
 
+gboolean g_at_chat_unregister_all(GAtChat *chat)
+{
+       GHashTableIter iter;
+       struct at_notify *notify;
+       char *prefix;
+       gpointer key, value;
+       GSList *l;
+
+       if (chat == NULL || chat->notify_list == NULL)
+               return FALSE;
+
+       g_hash_table_iter_init(&iter, chat->notify_list);
+
+       while (g_hash_table_iter_next(&iter, &key, &value)) {
+               prefix = key;
+               notify = value;
+
+               for (l = notify->nodes; l; l = l->next)
+                       at_notify_node_destroy(l->data);
+
+               g_slist_free(notify->nodes);
+               notify->nodes=  NULL;
+               g_hash_table_iter_remove(&iter);
+       }
+
+       return TRUE;
+}
+
 gboolean g_at_chat_set_wakeup_command(GAtChat *chat, const char *cmd,
                                        unsigned int timeout, unsigned int msec)
 {
index 8fffda6..c74ef15 100644 (file)
@@ -125,6 +125,7 @@ guint g_at_chat_register(GAtChat *chat, const char *prefix,
                                gpointer user_data, GDestroyNotify notify);
 
 gboolean g_at_chat_unregister(GAtChat *chat, guint id);
+gboolean g_at_chat_unregister_all(GAtChat *chat);
 
 gboolean g_at_chat_set_wakeup_command(GAtChat *chat, const char *cmd,
                                        guint timeout, guint msec);