Sun, 15 Apr 2007 03:56:08 +0000
propagate from branch 'im.pidgin.rlaager.merging.msnp13-and-sf-1621854-4-rlaager-whitespace' (head df9df972434fafda3e8030977ab3c18d480d8fa8)
to branch 'im.pidgin.rlaager.merging.msnp13-and-pidgin' (head 46933dc6288036763e484bfb1906f1149ada01cf)
| 11660 | 1 | /* |
| 2 | * Mono Plugin Loader | |
| 3 | * | |
| 4 | * -- Thanks to the perl plugin loader for all the great tips ;-) | |
| 5 | * | |
| 6 | * Eoin Coffey | |
| 7 | */ | |
| 8 | ||
| 9 | #ifdef HAVE_CONFIG_H | |
| 10 | #include <config.h> | |
| 11 | #endif | |
| 12 | ||
| 13 | #include <glib.h> | |
| 14 | #include <string.h> | |
| 15 | #include "mono-helper.h" | |
| 16 | #include "mono-glue.h" | |
| 17 | #include "value.h" | |
|
11952
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
18 | #include "debug.h" |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
19 | |
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
20 | static gboolean _runtime_active = FALSE; |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
21 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
22 | gboolean ml_init() |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
23 | { |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
24 | MonoDomain *d; |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
25 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
26 | g_return_val_if_fail(_runtime_active == FALSE, TRUE); |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
27 | |
| 15884 | 28 | d = mono_jit_init("purple"); |
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
29 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
30 | if (!d) { |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
31 | ml_set_domain(NULL); |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
32 | return FALSE; |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
33 | } |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
34 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
35 | ml_set_domain(d); |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
36 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
37 | ml_init_internal_calls(); |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
38 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
39 | _runtime_active = TRUE; |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
40 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
41 | return TRUE; |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
42 | } |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
43 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
44 | void ml_uninit() |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
45 | { |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
46 | g_return_if_fail(_runtime_active == TRUE); |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
47 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
48 | mono_jit_cleanup(ml_get_domain()); |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
49 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
50 | ml_set_domain(NULL); |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
51 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
52 | _runtime_active = FALSE; |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
53 | } |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
54 | |
|
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
55 | MonoObject* ml_delegate_invoke(MonoObject *method, void **params) |
|
11952
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
56 | { |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
57 | MonoObject *ret, *exception; |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
58 | |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
59 | ret = mono_runtime_delegate_invoke(method, params, &exception); |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
60 | if (exception) { |
| 15884 | 61 | purple_debug(PURPLE_DEBUG_ERROR, "mono", "caught exception: %s\n", mono_class_get_name(mono_object_get_class(exception))); |
|
11952
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
62 | } |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
63 | |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
64 | return ret; |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
65 | } |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
66 | |
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
67 | MonoObject* ml_invoke(MonoMethod *method, void *obj, void **params) |
|
11952
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
68 | { |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
69 | MonoObject *ret, *exception; |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
70 | |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
71 | ret = mono_runtime_invoke(method, obj, params, &exception); |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
72 | if (exception) { |
| 15884 | 73 | purple_debug(PURPLE_DEBUG_ERROR, "mono", "caught exception: %s\n", mono_class_get_name(mono_object_get_class(exception))); |
|
11952
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
74 | } |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
75 | |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
76 | return ret; |
|
9cefc8360bff
[gaim-migrate @ 14243]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11786
diff
changeset
|
77 | } |
| 11660 | 78 | |
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
79 | MonoClass* ml_find_plugin_class(MonoImage *image) |
| 11660 | 80 | { |
| 81 | MonoClass *klass, *pklass = NULL; | |
| 82 | int i, total; | |
| 83 | ||
| 84 | total = mono_image_get_table_rows (image, MONO_TABLE_TYPEDEF); | |
| 85 | for (i = 1; i <= total; ++i) { | |
| 86 | klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | i); | |
|
15938
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
87 | |
| 11660 | 88 | pklass = mono_class_get_parent(klass); |
|
15938
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
89 | if (pklass) { |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
90 | |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
91 | if (strcmp("Plugin", mono_class_get_name(pklass)) == 0) |
| 11660 | 92 | return klass; |
|
15938
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
93 | } |
| 11660 | 94 | } |
| 95 | ||
| 96 | return NULL; | |
| 97 | } | |
| 98 | ||
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
99 | void ml_set_prop_string(MonoObject *obj, char *field, char *data) |
| 11660 | 100 | { |
| 101 | MonoClass *klass; | |
| 102 | MonoProperty *prop; | |
| 103 | MonoString *str; | |
| 104 | gpointer args[1]; | |
| 105 | ||
| 106 | klass = mono_object_get_class(obj); | |
| 107 | ||
| 108 | prop = mono_class_get_property_from_name(klass, field); | |
| 109 | ||
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
110 | str = mono_string_new(ml_get_domain(), data); |
| 11660 | 111 | |
| 112 | args[0] = str; | |
| 113 | ||
| 114 | mono_property_set_value(prop, obj, args, NULL); | |
| 115 | } | |
| 116 | ||
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
117 | gchar* ml_get_prop_string(MonoObject *obj, char *field) |
| 11660 | 118 | { |
| 119 | MonoClass *klass; | |
| 120 | MonoProperty *prop; | |
| 121 | MonoString *str; | |
| 122 | ||
| 123 | klass = mono_object_get_class(obj); | |
| 124 | ||
| 125 | prop = mono_class_get_property_from_name(klass, field); | |
| 126 | ||
| 127 | str = (MonoString*)mono_property_get_value(prop, obj, NULL, NULL); | |
| 128 | ||
| 129 | return mono_string_to_utf8(str); | |
| 130 | } | |
| 131 | ||
|
15938
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
132 | MonoObject* ml_get_info_prop(MonoObject *obj) |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
133 | { |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
134 | MonoClass *klass; |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
135 | MonoProperty *prop; |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
136 | |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
137 | klass = mono_class_get_parent(mono_object_get_class(obj)); |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
138 | |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
139 | prop = mono_class_get_property_from_name(klass, "Info"); |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
140 | |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
141 | return mono_property_get_value(prop, obj, NULL, NULL); |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
142 | } |
|
1b037158411e
SF Patch #1686400 from Eoin Coffey ("ecoffey")
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
143 | |
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
144 | gboolean ml_is_api_dll(MonoImage *image) |
| 11660 | 145 | { |
| 146 | MonoClass *klass; | |
| 147 | int i, total; | |
| 148 | ||
| 149 | total = mono_image_get_table_rows (image, MONO_TABLE_TYPEDEF); | |
| 150 | for (i = 1; i <= total; ++i) { | |
| 151 | klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | i); | |
| 152 | if (strcmp(mono_class_get_name(klass), "Debug") == 0) | |
| 15884 | 153 | if (strcmp(mono_class_get_namespace(klass), "Purple") == 0) { |
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
154 | ml_set_api_image(image); |
| 11660 | 155 | return TRUE; |
| 156 | } | |
| 157 | } | |
| 158 | ||
| 159 | return FALSE; | |
| 160 | } | |
| 161 | ||
| 15884 | 162 | MonoObject* ml_object_from_purple_type(PurpleType type, gpointer data) |
| 11660 | 163 | { |
| 164 | return NULL; | |
| 165 | } | |
| 166 | ||
| 15884 | 167 | MonoObject* ml_object_from_purple_subtype(PurpleSubType type, gpointer data) |
| 11660 | 168 | { |
|
11776
58fd4b78788a
[gaim-migrate @ 14067]
Gary Kramlich <grim@reaperworld.com>
parents:
11660
diff
changeset
|
169 | MonoObject *obj = NULL; |
| 11660 | 170 | |
| 171 | switch (type) { | |
| 15884 | 172 | case PURPLE_SUBTYPE_BLIST_BUDDY: |
| 173 | obj = purple_blist_build_buddy_object(data); | |
| 11660 | 174 | break; |
| 15884 | 175 | case PURPLE_SUBTYPE_STATUS: |
| 176 | obj = purple_status_build_status_object(data); | |
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
177 | break; |
| 11660 | 178 | default: |
| 179 | break; | |
| 180 | } | |
| 181 | ||
| 182 | return obj; | |
| 183 | } | |
| 184 | ||
|
11996
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
185 | MonoObject* ml_create_api_object(char *class_name) |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
186 | { |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
187 | MonoObject *obj = NULL; |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
188 | MonoClass *klass = NULL; |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
189 | |
| 15884 | 190 | klass = mono_class_from_name(ml_get_api_image(), "Purple", class_name); |
|
11996
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
191 | if (!klass) { |
| 15884 | 192 | purple_debug(PURPLE_DEBUG_FATAL, "mono", "couldn't find the '%s' class\n", class_name); |
|
11996
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
193 | return NULL; |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
194 | } |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
195 | |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
196 | obj = mono_object_new(ml_get_domain(), klass); |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
197 | if (!obj) { |
| 15884 | 198 | purple_debug(PURPLE_DEBUG_FATAL, "mono", "couldn't create the object from class '%s'\n", class_name); |
|
11996
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
199 | return NULL; |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
200 | } |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
201 | |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
202 | mono_runtime_object_init(obj); |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
203 | |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
204 | return obj; |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
205 | } |
|
858bd928831c
[gaim-migrate @ 14289]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11980
diff
changeset
|
206 | |
|
11786
d0067c6e542a
[gaim-migrate @ 14077]
Gary Kramlich <grim@reaperworld.com>
parents:
11776
diff
changeset
|
207 | static MonoDomain *_domain = NULL; |
| 11660 | 208 | |
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
209 | MonoDomain* ml_get_domain(void) |
| 11660 | 210 | { |
| 211 | return _domain; | |
| 212 | } | |
| 213 | ||
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
214 | void ml_set_domain(MonoDomain *d) |
| 11660 | 215 | { |
| 216 | _domain = d; | |
| 217 | } | |
| 218 | ||
| 219 | static MonoImage *_api_image = NULL; | |
| 220 | ||
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
221 | void ml_set_api_image(MonoImage *image) |
| 11660 | 222 | { |
| 223 | _api_image = image; | |
| 224 | } | |
| 225 | ||
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
226 | MonoImage* ml_get_api_image() |
| 11660 | 227 | { |
| 228 | return _api_image; | |
| 229 | } | |
| 230 | ||
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
231 | void ml_init_internal_calls(void) |
| 11660 | 232 | { |
| 15884 | 233 | mono_add_internal_call("Purple.Debug::_debug", purple_debug_glue); |
| 234 | mono_add_internal_call("Purple.Signal::_connect", purple_signal_connect_glue); | |
| 235 | mono_add_internal_call("Purple.BuddyList::_get_handle", purple_blist_get_handle_glue); | |
| 11660 | 236 | } |
| 237 | ||
| 238 | static GHashTable *plugins_hash = NULL; | |
| 239 | ||
| 15884 | 240 | void ml_add_plugin(PurpleMonoPlugin *plugin) |
| 11660 | 241 | { |
| 242 | if (!plugins_hash) | |
| 243 | plugins_hash = g_hash_table_new(NULL, NULL); | |
| 244 | ||
| 245 | g_hash_table_insert(plugins_hash, plugin->klass, plugin); | |
| 246 | } | |
| 247 | ||
| 15884 | 248 | gboolean ml_remove_plugin(PurpleMonoPlugin *plugin) |
| 11660 | 249 | { |
| 250 | return g_hash_table_remove(plugins_hash, plugin->klass); | |
| 251 | } | |
| 252 | ||
| 15884 | 253 | gpointer ml_find_plugin(PurpleMonoPlugin *plugin) |
| 11660 | 254 | { |
| 255 | return g_hash_table_lookup(plugins_hash, plugin->klass); | |
| 256 | } | |
| 257 | ||
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
258 | gpointer ml_find_plugin_by_class(MonoClass *klass) |
| 11660 | 259 | { |
| 260 | return g_hash_table_lookup(plugins_hash, klass); | |
| 261 | } | |
| 262 | ||
|
11980
fe5c2c58508c
[gaim-migrate @ 14273]
Eoin Coffey <ecoffey@soc.pidgin.im>
parents:
11952
diff
changeset
|
263 | GHashTable* ml_get_plugin_hash() |
| 11660 | 264 | { |
| 265 | return plugins_hash; | |
| 266 | } |