---
 gatchat/gatserver.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 gatchat/gatserver.h |    6 ++++++
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/gatchat/gatserver.c b/gatchat/gatserver.c
index 6e3347c..c17a7b5 100644
--- a/gatchat/gatserver.c
+++ b/gatchat/gatserver.c
@@ -970,3 +970,51 @@ gboolean g_at_server_set_debug(GAtServer *server, 
GAtDebugFunc func,
 
        return TRUE;
 }
+
+gboolean g_at_server_register(GAtServer *server, char *prefix,
+                                       GAtServerNotifyFunc notify,
+                                       gpointer user_data,
+                                       GDestroyNotify destroy_notify)
+{
+       struct at_command *node;
+
+       if (server == NULL || server->command_list == NULL)
+               return FALSE;
+
+       if (notify == NULL)
+               return FALSE;
+
+       if (prefix == NULL || strlen(prefix) == 0)
+               return FALSE;
+
+       node = g_try_new0(struct at_command, 1);
+       if (!node)
+               return FALSE;
+
+       node->notify = notify;
+       node->user_data = user_data;
+       node->destroy_notify = destroy_notify;
+
+       g_hash_table_replace(server->command_list, g_strdup(prefix), node);
+
+       return TRUE;
+}
+
+gboolean g_at_server_unregister(GAtServer *server, const char *prefix)
+{
+       struct at_command *node;
+
+       if (server == NULL || server->command_list == NULL)
+               return FALSE;
+
+       if (prefix == NULL || strlen(prefix) == 0)
+               return FALSE;
+
+       node = g_hash_table_lookup(server->command_list, prefix);
+       if (!node)
+               return FALSE;
+
+       g_hash_table_remove(server->command_list, prefix);
+
+       return TRUE;
+}
diff --git a/gatchat/gatserver.h b/gatchat/gatserver.h
index 1c12a0d..5e9eb62 100644
--- a/gatchat/gatserver.h
+++ b/gatchat/gatserver.h
@@ -81,6 +81,12 @@ gboolean g_at_server_set_debug(GAtServer *server,
                                        GAtDebugFunc func,
                                        gpointer user);
 
+gboolean g_at_server_register(GAtServer *server, char *prefix,
+                                       GAtServerNotifyFunc notify,
+                                       gpointer user_data,
+                                       GDestroyNotify destroy_notify);
+gboolean g_at_server_unregister(GAtServer *server, const char *prefix);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.6.6.1

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to