Mercurial > pidgin
comparison src/module.c @ 3563:e120097bbd72
[gaim-migrate @ 3658]
I made my perl script unloading not suck (as much). Now you may port your
perl scripts--use gaim.pl and PERL-HOWTO as references.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Sat, 28 Sep 2002 08:08:14 +0000 |
| parents | cd938f18f3f8 |
| children | 154c4a9d9b6d |
comparison
equal
deleted
inserted
replaced
| 3562:de3bc24fff02 | 3563:e120097bbd72 |
|---|---|
| 134 g_module_close(handle); | 134 g_module_close(handle); |
| 135 } | 135 } |
| 136 #endif | 136 #endif |
| 137 #ifdef USE_PERL | 137 #ifdef USE_PERL |
| 138 if (is_so_file(file, ".pl")) { | 138 if (is_so_file(file, ".pl")) { |
| 139 path = g_build_filename(LIBDIR, file, NULL); | 139 path = g_build_filename(probedirs[l], file, NULL); |
| 140 plug = probe_perl(path); | 140 plug = probe_perl(path); |
| 141 if (plug) | 141 if (plug) |
| 142 probed_plugins = g_list_append(probed_plugins, plug); | 142 probed_plugins = g_list_append(probed_plugins, plug); |
| 143 g_free(path); | 143 g_free(path); |
| 144 } | 144 } |
| 157 struct gaim_plugin_description *(*gaim_plugin_desc)(); | 157 struct gaim_plugin_description *(*gaim_plugin_desc)(); |
| 158 char *(*cfunc)(); | 158 char *(*cfunc)(); |
| 159 GList *c = plugins; | 159 GList *c = plugins; |
| 160 GList *p = probed_plugins; | 160 GList *p = probed_plugins; |
| 161 char *(*gaim_plugin_init)(GModule *); | 161 char *(*gaim_plugin_init)(GModule *); |
| 162 char *error, *retval, *tmp; | 162 char *error, *retval; |
| 163 gboolean newplug = FALSE; | 163 gboolean newplug = FALSE; |
| 164 | 164 |
| 165 if (!g_module_supported()) | 165 if (!g_module_supported()) |
| 166 return NULL; | 166 return NULL; |
| 167 if (!filename || !strlen(filename)) | 167 if (!filename || !strlen(filename)) |
| 168 return NULL; | 168 return NULL; |
| 169 | |
| 170 if (is_so_file(filename, ".pl")) { | |
| 171 return perl_load_file(filename); | |
| 172 } | |
| 169 | 173 |
| 170 while (filename && p) { | 174 while (filename && p) { |
| 171 plug = (struct gaim_plugin *)p->data; | 175 plug = (struct gaim_plugin *)p->data; |
| 172 if (!strcmp(filename, plug->path)) | 176 if (!strcmp(filename, plug->path)) |
| 173 break; | 177 break; |
| 188 debug_printf("Loading %s\n", filename); | 192 debug_printf("Loading %s\n", filename); |
| 189 plug->handle = g_module_open(filename, 0); | 193 plug->handle = g_module_open(filename, 0); |
| 190 if (!plug->handle) { | 194 if (!plug->handle) { |
| 191 error = (char *)g_module_error(); | 195 error = (char *)g_module_error(); |
| 192 plug->handle = NULL; | 196 plug->handle = NULL; |
| 193 tmp = plug->desc.description; | 197 g_snprintf(plug->error, sizeof(plug->error), error); |
| 194 plug->desc.description = g_strdup_printf("<span weight=\"bold\" foreground=\"red\">%s</span>\n\n%s", error, tmp); | |
| 195 g_free(tmp); | |
| 196 return NULL; | 198 return NULL; |
| 197 } | 199 } |
| 198 | 200 |
| 199 if (!g_module_symbol(plug->handle, "gaim_plugin_init", (gpointer *)&gaim_plugin_init)) { | 201 if (!g_module_symbol(plug->handle, "gaim_plugin_init", (gpointer *)&gaim_plugin_init)) { |
| 200 g_module_close(plug->handle); | 202 g_module_close(plug->handle); |
| 201 plug->handle = NULL; | 203 plug->handle = NULL; |
| 202 tmp = plug->desc.description; | 204 g_snprintf(plug->error, sizeof(plug->error), error); |
| 203 plug->desc.description = g_strdup_printf("<span foreground=\"red\">%s</span>\n\n%s", g_module_error(), tmp); | |
| 204 g_free(tmp); | |
| 205 return NULL; | 205 return NULL; |
| 206 } | 206 } |
| 207 | 207 |
| 208 plug->error[0] = '\0'; | |
| 208 retval = gaim_plugin_init(plug->handle); | 209 retval = gaim_plugin_init(plug->handle); |
| 209 debug_printf("loaded plugin returned %s\n", retval ? retval : "NULL"); | 210 debug_printf("loaded plugin returned %s\n", retval ? retval : "NULL"); |
| 210 if (retval) { | 211 if (retval) { |
| 211 plugin_remove_callbacks(plug->handle); | 212 plugin_remove_callbacks(plug->handle); |
| 212 do_error_dialog("Gaim was unable to load your plugin.", retval, GAIM_ERROR); | 213 do_error_dialog("Gaim was unable to load your plugin.", retval, GAIM_ERROR); |
| 630 struct gaim_plugin *p; | 631 struct gaim_plugin *p; |
| 631 void (*gaim_plugin_remove)(); | 632 void (*gaim_plugin_remove)(); |
| 632 | 633 |
| 633 while (c) { | 634 while (c) { |
| 634 p = (struct gaim_plugin *)c->data; | 635 p = (struct gaim_plugin *)c->data; |
| 635 if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove)) | 636 if (p->type == plugin) { |
| 636 gaim_plugin_remove(); | 637 if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove)) |
| 638 gaim_plugin_remove(); | |
| 639 } | |
| 637 g_free(p); | 640 g_free(p); |
| 638 c = c->next; | 641 c = c->next; |
| 639 } | 642 } |
| 640 } | 643 } |
| 641 #endif | 644 #endif |
