Mercurial > pidgin
comparison src/plugins.c @ 94:9f6ce50ffb78
[gaim-migrate @ 104]
Woohoo, the landing of the plugins. Nearly everything necessary is here. The
only thing missing is that you can't load a plugin without signing on first
(at least, not without some trickery).
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 09 Apr 2000 11:18:25 +0000 |
parents | f3c6cf79f651 |
children | 247f540ea6e1 |
comparison
equal
deleted
inserted
replaced
93:5ca21b68eb29 | 94:9f6ce50ffb78 |
---|---|
42 #include <gtk/gtk.h> | 42 #include <gtk/gtk.h> |
43 #include "gaim.h" | 43 #include "gaim.h" |
44 | 44 |
45 #include <dlfcn.h> | 45 #include <dlfcn.h> |
46 | 46 |
47 /* ------------------ Local Variables -------------------------*/ | 47 /* ------------------ Global Variables ----------------------- */ |
48 | |
49 GList *callbacks = NULL; | |
50 | |
51 /* ------------------ Local Variables ------------------------ */ | |
48 | 52 |
49 static GtkWidget *plugin_dialog = NULL; | 53 static GtkWidget *plugin_dialog = NULL; |
50 static GList *plugins = NULL; | 54 static GList *plugins = NULL; |
51 | 55 |
52 static GtkWidget *pluglist; | 56 static GtkWidget *pluglist; |
53 static GtkWidget *plugtext; | 57 static GtkWidget *plugtext; |
54 static GtkWidget *plugwindow; | 58 static GtkWidget *plugwindow; |
55 | 59 |
56 /* --------------- Function Declarations -------------------- */ | 60 /* --------------- Function Declarations --------------------- */ |
57 | 61 |
58 void load_plugin (GtkWidget *, gpointer); | 62 void load_plugin (GtkWidget *, gpointer); |
59 void unload_plugin(GtkWidget *, gpointer); | 63 void unload_plugin(GtkWidget *, gpointer); |
60 void show_plugins (GtkWidget *, gpointer); | 64 void show_plugins (GtkWidget *, gpointer); |
65 | |
66 void gaim_signal_connect (void *, enum gaim_event, void *, void *); | |
67 void gaim_signal_disconnect(void *, enum gaim_event, void *); | |
61 | 68 |
62 static void destroy_plugins (GtkWidget *, gpointer); | 69 static void destroy_plugins (GtkWidget *, gpointer); |
63 static void load_which_plugin(GtkWidget *, gpointer); | 70 static void load_which_plugin(GtkWidget *, gpointer); |
64 static void unload (GtkWidget *, gpointer); | 71 static void unload (GtkWidget *, gpointer); |
65 static void list_clicked (GtkWidget *, struct gaim_plugin *); | 72 static void list_clicked (GtkWidget *, struct gaim_plugin *); |
138 g_free(plug); | 145 g_free(plug); |
139 return; | 146 return; |
140 } | 147 } |
141 | 148 |
142 plugins = g_list_append(plugins, plug); | 149 plugins = g_list_append(plugins, plug); |
143 (*gaim_plugin_init)(); | 150 (*gaim_plugin_init)(plug->handle); |
144 | 151 |
145 cfunc = dlsym(plug->handle, "name"); | 152 cfunc = dlsym(plug->handle, "name"); |
146 if ((error = dlerror()) == NULL) | 153 if ((error = dlerror()) == NULL) |
147 plug->name = (*cfunc)(); | 154 plug->name = (*cfunc)(); |
148 else | 155 else |
297 void unload(GtkWidget *w, gpointer data) { | 304 void unload(GtkWidget *w, gpointer data) { |
298 GList *i; | 305 GList *i; |
299 struct gaim_plugin *p; | 306 struct gaim_plugin *p; |
300 void (*gaim_plugin_remove)(); | 307 void (*gaim_plugin_remove)(); |
301 char *error; | 308 char *error; |
309 GList *c = callbacks; | |
310 struct gaim_callback *g; | |
302 | 311 |
303 i = GTK_LIST(pluglist)->selection; | 312 i = GTK_LIST(pluglist)->selection; |
304 | 313 |
305 if (i == NULL) return; | 314 if (i == NULL) return; |
306 | 315 |
307 p = gtk_object_get_user_data(GTK_OBJECT(i->data)); | 316 p = gtk_object_get_user_data(GTK_OBJECT(i->data)); |
308 | 317 |
309 gaim_plugin_remove = dlsym(p->handle, "gaim_plugin_remove"); | 318 gaim_plugin_remove = dlsym(p->handle, "gaim_plugin_remove"); |
310 if ((error = dlerror()) == NULL) | 319 if ((error = dlerror()) == NULL) |
311 (*gaim_plugin_remove)(); | 320 (*gaim_plugin_remove)(); |
321 while (c) { | |
322 g = (struct gaim_callback *)c->data; | |
323 if (g->handle == p->handle) { | |
324 callbacks = g_list_remove(callbacks, c); | |
325 g_free(g); | |
326 } | |
327 c = c->next; | |
328 } | |
312 dlclose(p->handle); | 329 dlclose(p->handle); |
313 | 330 |
314 plugins = g_list_remove(plugins, p); | 331 plugins = g_list_remove(plugins, p); |
315 g_free(p); | 332 g_free(p); |
316 update_show_plugins(); | 333 update_show_plugins(); |
332 if (plugwindow) | 349 if (plugwindow) |
333 gtk_widget_destroy(plugwindow); | 350 gtk_widget_destroy(plugwindow); |
334 plugwindow = NULL; | 351 plugwindow = NULL; |
335 } | 352 } |
336 | 353 |
354 void gaim_signal_connect(void *handle, enum gaim_event which, | |
355 void *func, void *data) { | |
356 struct gaim_callback *call = g_malloc(sizeof *call); | |
357 call->handle = handle; | |
358 call->event = which; | |
359 call->function = func; | |
360 call->data = data; | |
361 | |
362 callbacks = g_list_append(callbacks, call); | |
363 } | |
364 | |
365 void gaim_signal_disconnect(void *handle, enum gaim_event which, void *func) { | |
366 GList *c = callbacks; | |
367 struct gaim_callback *g = NULL; | |
368 while (c) { | |
369 g = (struct gaim_callback *)c->data; | |
370 if (handle == g->handle && func == g->function) { | |
371 callbacks = g_list_remove(callbacks, g); | |
372 g_free(g); | |
373 } | |
374 c = c->next; | |
375 } | |
376 } | |
377 | |
337 #endif /* GAIM_PLUGINS */ | 378 #endif /* GAIM_PLUGINS */ |