Thu, 22 Aug 2013 00:29:09 +0530
Changed signature of purple_protocols_add() take a GType and return the PurpleProtocol
| libpurple/protocols.c | file | annotate | diff | comparison | revisions | |
| libpurple/protocols.h | file | annotate | diff | comparison | revisions |
--- a/libpurple/protocols.c Thu Aug 22 00:25:08 2013 +0530 +++ b/libpurple/protocols.c Thu Aug 22 00:29:09 2013 +0530 @@ -687,6 +687,8 @@ purple_signals_unregister_by_instance(protocol); purple_prefs_disconnect_by_handle(protocol); + + g_object_unref(protocol); } PurpleProtocol * @@ -695,22 +697,26 @@ return g_hash_table_lookup(protocols, id); } -gboolean -purple_protocols_add(PurpleProtocol *protocol) +PurpleProtocol * +purple_protocols_add(GType protocol_type) { - if (purple_find_protocol_info(protocol->id)) - return FALSE; + PurpleProtocol *protocol = g_object_new(protocol_type, NULL); + if (purple_find_protocol_info(purple_protocol_get_id(protocol))) { + g_object_unref(protocol); + return NULL; + } - g_hash_table_insert(protocols, g_strdup(protocol->id), protocol); - return TRUE; + g_hash_table_insert(protocols, g_strdup(purple_protocol_get_id(protocol)), + protocol); + return protocol; } gboolean purple_protocols_remove(PurpleProtocol *protocol) { - if (purple_find_protocol_info(protocol->id) == NULL) + if (purple_find_protocol_info(purple_protocol_get_id(protocol)) == NULL) return FALSE; - g_hash_table_remove(protocols, protocol->id); + g_hash_table_remove(protocols, purple_protocol_get_id(protocol)); purple_protocol_destroy(protocol); return TRUE;
--- a/libpurple/protocols.h Thu Aug 22 00:25:08 2013 +0530 +++ b/libpurple/protocols.h Thu Aug 22 00:29:09 2013 +0530 @@ -410,11 +410,11 @@ /** TODO A sanity check is needed * Adds a protocol to the list of protocols. * - * @param protocol The protocol to add. + * @param protocol_type The type of the protocol to add. * - * @return TRUE if the protocol was added, else FALSE. + * @return The protocol instance if the protocol was added, else @c NULL. */ -gboolean purple_protocols_add(PurpleProtocol *protocol); +PurpleProtocol *purple_protocols_add(GType protocol_type); /** TODO A sanity check is needed * Removes a protocol from the list of protocols. This will disconnect all