Mercurial > pidgin
changeset 11996:ecd33ffb0b0a
[gaim-migrate @ 14289]
more mono cleanups from Eoin Coffey
committer: Tailor Script <tailor@pidgin.im>
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Sun, 06 Nov 2005 23:09:07 +0000 |
parents | 969fd533bd5d |
children | 9d451c9cc3d9 |
files | plugins/mono/loader/blist-glue.c plugins/mono/loader/mono-helper.c plugins/mono/loader/mono-helper.h plugins/mono/loader/mono.c plugins/mono/loader/status-glue.c |
diffstat | 5 files changed, 31 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mono/loader/blist-glue.c Sun Nov 06 23:02:39 2005 +0000 +++ b/plugins/mono/loader/blist-glue.c Sun Nov 06 23:09:07 2005 +0000 @@ -12,22 +12,12 @@ MonoObject* gaim_blist_build_buddy_object(void* data) { MonoObject *obj = NULL; - MonoClass *klass = NULL; GaimBuddy *buddy = (GaimBuddy*)data; - klass = mono_class_from_name(ml_get_api_image(), "Gaim", "Buddy"); - if (!klass) { - gaim_debug(GAIM_DEBUG_FATAL, "mono", "couldn't build the class!\n"); - } - - obj = mono_object_new(ml_get_domain(), klass); - if (!obj) { - gaim_debug(GAIM_DEBUG_FATAL, "mono", "couldn't create the object!\n"); - } - - mono_runtime_object_init(obj); - + obj = ml_create_api_object("Buddy"); + g_return_val_if_fail(obj != NULL, NULL); + ml_set_prop_string(obj, "Name", (char*)gaim_buddy_get_name(buddy)); ml_set_prop_string(obj, "Alias", (char*)gaim_buddy_get_alias(buddy));
--- a/plugins/mono/loader/mono-helper.c Sun Nov 06 23:02:39 2005 +0000 +++ b/plugins/mono/loader/mono-helper.c Sun Nov 06 23:09:07 2005 +0000 @@ -167,6 +167,28 @@ return obj; } +MonoObject* ml_create_api_object(char *class_name) +{ + MonoObject *obj = NULL; + MonoClass *klass = NULL; + + klass = mono_class_from_name(ml_get_api_image(), "Gaim", class_name); + if (!klass) { + gaim_debug(GAIM_DEBUG_FATAL, "mono", "couldn't find the '%s' class\n", class_name); + return NULL; + } + + obj = mono_object_new(ml_get_domain(), klass); + if (!obj) { + gaim_debug(GAIM_DEBUG_FATAL, "mono", "couldn't create the object from class '%s'\n", class_name); + return NULL; + } + + mono_runtime_object_init(obj); + + return obj; +} + static MonoDomain *_domain = NULL; MonoDomain* ml_get_domain(void) @@ -198,11 +220,6 @@ mono_add_internal_call("Gaim.BuddyList::_get_handle", gaim_blist_get_handle_glue); } -void ml_destroy_signal_data(gpointer data, gpointer user_data) -{ - g_free(data); -} - static GHashTable *plugins_hash = NULL; void ml_add_plugin(GaimMonoPlugin *plugin)
--- a/plugins/mono/loader/mono-helper.h Sun Nov 06 23:02:39 2005 +0000 +++ b/plugins/mono/loader/mono-helper.h Sun Nov 06 23:09:07 2005 +0000 @@ -52,12 +52,12 @@ MonoObject* ml_object_from_gaim_subtype(GaimSubType type, gpointer data); +MonoObject* ml_create_api_object(char *class_name); + void ml_set_api_image(MonoImage *image); MonoImage* ml_get_api_image(); -void ml_destroy_signal_data(gpointer data, gpointer user_data); - /* hash table stuff; probably don't need it anymore */ void ml_add_plugin(GaimMonoPlugin *plugin);
--- a/plugins/mono/loader/mono.c Sun Nov 06 23:02:39 2005 +0000 +++ b/plugins/mono/loader/mono.c Sun Nov 06 23:09:07 2005 +0000 @@ -144,6 +144,7 @@ mplug = (GaimMonoPlugin*)plugin->info->extra_info; gaim_signals_disconnect_by_handle((gpointer)mplug->klass); + g_list_foreach(mplug->signal_data, (GFunc)g_free, NULL); g_list_free(mplug->signal_data); mplug->signal_data = NULL;
--- a/plugins/mono/loader/status-glue.c Sun Nov 06 23:02:39 2005 +0000 +++ b/plugins/mono/loader/status-glue.c Sun Nov 06 23:09:07 2005 +0000 @@ -4,22 +4,11 @@ MonoObject* gaim_status_build_status_object(void* data) { MonoObject *obj = NULL; - MonoClass *klass = NULL; - GaimStatus *status = (GaimStatus*)data; - klass = mono_class_from_name(ml_get_api_image(), "Gaim", "Status"); - if (!klass) { - gaim_debug(GAIM_DEBUG_FATAL, "mono", "couldn't build the class!\n"); - } - - obj = mono_object_new(ml_get_domain(), klass); - if (!obj) { - gaim_debug(GAIM_DEBUG_FATAL, "mono", "couldn't create the object!\n"); - } - - mono_runtime_object_init(obj); - + obj = ml_create_api_object("Status"); + g_return_val_if_fail(obj != NULL, NULL); + ml_set_prop_string(obj, "Id", (char*)gaim_status_get_id(status)); return obj;