Mercurial > pidgin
annotate src/plugins.c @ 643:df1ceace5cac
[gaim-migrate @ 653]
this should take care of hideous backgrounds in toc's user info
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 08 Aug 2000 22:47:47 +0000 |
parents | d86cc11faab8 |
children | 732ee4f6f541 |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 * ---------------- | |
21 * The Plug-in plug | |
22 * | |
23 * Plugin support is currently being maintained by Mike Saraf | |
24 * msaraf@dwc.edu | |
25 * | |
90 | 26 * Well, I didn't see any work done on it for a while, so I'm going to try |
27 * my hand at it. - Eric warmenhoven@yahoo.com | |
28 * | |
1 | 29 */ |
30 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
176
diff
changeset
|
31 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
176
diff
changeset
|
32 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
176
diff
changeset
|
33 #endif |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
176
diff
changeset
|
34 |
90 | 35 #ifdef GAIM_PLUGINS |
36 | |
1 | 37 #include <string.h> |
38 #include <sys/time.h> | |
39 | |
40 #include <sys/types.h> | |
41 #include <sys/stat.h> | |
42 | |
43 #include <unistd.h> | |
44 #include <stdio.h> | |
45 #include <stdlib.h> | |
46 #include <gtk/gtk.h> | |
47 #include "gaim.h" | |
619 | 48 #include "pixmaps/gnome_add.xpm" |
49 #include "pixmaps/gnome_close.xpm" | |
50 #include "pixmaps/gnome_preferences.xpm" | |
51 #include "pixmaps/gnome_remove.xpm" | |
52 #include "pixmaps/ok.xpm" | |
1 | 53 |
90 | 54 #include <dlfcn.h> |
55 | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
56 /* ------------------ Global Variables ----------------------- */ |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
57 |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
58 GList *plugins = NULL; |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
59 GList *callbacks = NULL; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
60 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
61 /* ------------------ Local Variables ------------------------ */ |
1 | 62 |
90 | 63 static GtkWidget *plugin_dialog = NULL; |
64 | |
65 static GtkWidget *pluglist; | |
66 static GtkWidget *plugtext; | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
67 static GtkWidget *plugwindow; |
1 | 68 |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
69 static GtkWidget *config = NULL; |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
70 static guint confighandle = 0; |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
71 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
72 /* --------------- Function Declarations --------------------- */ |
1 | 73 |
90 | 74 void show_plugins (GtkWidget *, gpointer); |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
75 void load_plugin (char *); |
90 | 76 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
77 void gaim_signal_connect (void *, enum gaim_event, void *, void *); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
78 void gaim_signal_disconnect(void *, enum gaim_event, void *); |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
79 void gaim_plugin_unload (void *); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
80 |
90 | 81 static void destroy_plugins (GtkWidget *, gpointer); |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
82 static void load_file (GtkWidget *, gpointer); |
90 | 83 static void load_which_plugin(GtkWidget *, gpointer); |
84 static void unload (GtkWidget *, gpointer); | |
85 static void list_clicked (GtkWidget *, struct gaim_plugin *); | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
86 static void update_show_plugins(); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
87 static void hide_plugins (GtkWidget *, gpointer); |
90 | 88 |
1 | 89 /* ------------------ Code Below ---------------------------- */ |
90 | |
90 | 91 static void destroy_plugins(GtkWidget *w, gpointer data) { |
92 if (plugin_dialog) | |
93 gtk_widget_destroy(plugin_dialog); | |
94 plugin_dialog = NULL; | |
95 } | |
96 | |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
97 static void load_file(GtkWidget *w, gpointer data) |
1 | 98 { |
90 | 99 char *buf = g_malloc(BUF_LEN); |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
100 FILE *fd; |
1 | 101 |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
102 if (plugin_dialog) { |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
103 g_free(buf); |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
104 gtk_widget_show(plugin_dialog); |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
105 gdk_window_raise(plugin_dialog->window); |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
106 return; |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
107 } |
90 | 108 |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
109 plugin_dialog = gtk_file_selection_new(_("Gaim - Plugin List")); |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
110 |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
111 gtk_file_selection_hide_fileop_buttons( |
90 | 112 GTK_FILE_SELECTION(plugin_dialog)); |
113 | |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
114 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
115 fd = fopen(buf, "r"); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
116 if (!fd) |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
117 mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
118 else |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
119 fclose(fd); |
1 | 120 |
90 | 121 gtk_file_selection_set_filename(GTK_FILE_SELECTION(plugin_dialog), buf); |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
122 gtk_file_selection_complete(GTK_FILE_SELECTION(plugin_dialog), "*.so"); |
90 | 123 gtk_signal_connect(GTK_OBJECT(plugin_dialog), "destroy", |
124 GTK_SIGNAL_FUNC(destroy_plugins), plugin_dialog); | |
125 | |
126 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->ok_button), | |
127 "clicked", GTK_SIGNAL_FUNC(load_which_plugin), NULL); | |
128 | |
129 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->cancel_button), | |
130 "clicked", GTK_SIGNAL_FUNC(destroy_plugins), NULL); | |
131 | |
132 g_free(buf); | |
619 | 133 |
626
d86cc11faab8
[gaim-migrate @ 636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
619
diff
changeset
|
134 gtk_widget_show(plugin_dialog); |
90 | 135 gdk_window_raise(plugin_dialog->window); |
136 } | |
1 | 137 |
139
c009c4f4ad02
[gaim-migrate @ 149]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
138
diff
changeset
|
138 static void load_which_plugin(GtkWidget *w, gpointer data) { |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
139 load_plugin(gtk_file_selection_get_filename( |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
140 GTK_FILE_SELECTION(plugin_dialog))); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
141 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
142 if (plugin_dialog) |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
143 gtk_widget_destroy(plugin_dialog); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
144 plugin_dialog = NULL; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
145 } |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
146 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
147 void load_plugin(char *filename) { |
90 | 148 struct gaim_plugin *plug; |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
149 GList *c = plugins; |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
150 int (*gaim_plugin_init)(); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
151 char *(*gaim_plugin_error)(int); |
90 | 152 char *(*cfunc)(); |
153 char *error; | |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
154 int retval; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
155 char *plugin_error; |
90 | 156 |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
157 if (filename == NULL) return; |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
158 /* i shouldn't be checking based solely on path, but i'm lazy */ |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
159 while (c) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
160 plug = (struct gaim_plugin *)c->data; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
161 if (!strcmp(filename, plug->filename)) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
162 sprintf(debug_buff, _("Already loaded %s, " |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
163 "not reloading.\n"), filename); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
164 debug_print(debug_buff); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
165 return; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
166 } |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
167 c = c->next; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
168 } |
90 | 169 plug = g_malloc(sizeof *plug); |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
170 if (filename[0] != '/') { |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
171 char *buf = g_malloc(BUF_LEN); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
172 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
173 plug->filename = g_malloc(strlen(buf) + strlen(filename) + 1); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
174 sprintf(plug->filename, "%s%s", buf, filename); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
175 } else |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
176 plug->filename = g_strdup(filename); |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
177 sprintf(debug_buff, "Loading %s\n", filename); |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
178 debug_print(debug_buff); |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
179 /* do NOT `OR' with RTLD_GLOBAL, otherwise plugins may conflict |
90 | 180 * (it's really just a way to work around other people's bad |
181 * programming, by not using RTLD_GLOBAL :P ) */ | |
182 plug->handle = dlopen(plug->filename, RTLD_LAZY); | |
183 if (!plug->handle) { | |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
184 error = (char *)dlerror(); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
185 do_error_dialog(error, _("Plugin Error")); |
90 | 186 g_free(plug); |
187 return; | |
188 } | |
189 | |
190 gaim_plugin_init = dlsym(plug->handle, "gaim_plugin_init"); | |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
191 if ((error = (char *)dlerror()) != NULL) { |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
192 do_error_dialog(error, _("Plugin Error")); |
90 | 193 dlclose(plug->handle); |
194 g_free(plug); | |
195 return; | |
196 } | |
197 | |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
198 retval = (*gaim_plugin_init)(plug->handle); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
199 sprintf(debug_buff, "loaded plugin returned %d\n", retval); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
200 debug_print(debug_buff); |
397
0b5ecac8aa54
[gaim-migrate @ 407]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
392
diff
changeset
|
201 if (retval < 0) { |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
202 GList *c = callbacks; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
203 struct gaim_callback *g; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
204 while (c) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
205 g = (struct gaim_callback *)c->data; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
206 if (g->handle == plug->handle) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
207 callbacks = g_list_remove(callbacks, c->data); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
208 sprintf(debug_buff, "Removing callback, %d remain\n", |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
209 g_list_length(callbacks)); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
210 debug_print(debug_buff); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
211 c = callbacks; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
212 if (c == NULL) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
213 break; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
214 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
215 } else { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
216 c = c->next; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
217 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
218 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
219 gaim_plugin_error = dlsym(plug->handle, "gaim_plugin_error"); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
220 if ((error = (char *)dlerror()) == NULL) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
221 plugin_error = (*gaim_plugin_error)(retval); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
222 if (plugin_error) |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
223 do_error_dialog(plugin_error, _("Plugin Error")); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
224 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
225 dlclose(plug->handle); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
226 g_free(plug); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
227 return; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
228 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
229 |
90 | 230 plugins = g_list_append(plugins, plug); |
1 | 231 |
90 | 232 cfunc = dlsym(plug->handle, "name"); |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
233 if ((error = (char *)dlerror()) == NULL) |
90 | 234 plug->name = (*cfunc)(); |
235 else | |
236 plug->name = NULL; | |
1 | 237 |
90 | 238 cfunc = dlsym(plug->handle, "description"); |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
239 if ((error = (char *)dlerror()) == NULL) |
90 | 240 plug->description = (*cfunc)(); |
241 else | |
242 plug->description = NULL; | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
243 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
244 update_show_plugins(); |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
245 save_prefs(); |
90 | 246 } |
1 | 247 |
90 | 248 void show_plugins(GtkWidget *w, gpointer data) { |
249 /* most of this code was shamelessly stolen from prefs.c */ | |
250 GtkWidget *page; | |
251 GtkWidget *topbox; | |
252 GtkWidget *botbox; | |
253 GtkWidget *sw; | |
254 GtkWidget *label; | |
255 GtkWidget *list_item; | |
256 GtkWidget *sw2; | |
257 GtkWidget *add; | |
258 GtkWidget *remove; | |
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
259 GtkWidget *close; |
90 | 260 GList *plugs = plugins; |
261 struct gaim_plugin *p; | |
262 gchar buffer[1024]; | |
263 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
264 if (plugwindow) return; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
265 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
266 plugwindow = gtk_window_new(GTK_WINDOW_DIALOG); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
267 gtk_widget_realize(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
268 aol_icon(plugwindow->window); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
269 gtk_container_border_width(GTK_CONTAINER(plugwindow), 10); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
270 gtk_window_set_title(GTK_WINDOW(plugwindow), _("Gaim - Plugins")); |
619 | 271 gtk_widget_set_usize(plugwindow, -1, 250); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
272 gtk_signal_connect(GTK_OBJECT(plugwindow), "destroy", |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
273 GTK_SIGNAL_FUNC(hide_plugins), NULL); |
90 | 274 |
275 page = gtk_vbox_new(FALSE, 0); | |
276 topbox = gtk_hbox_new(FALSE, 0); | |
277 botbox = gtk_hbox_new(FALSE, 0); | |
278 | |
279 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
280 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
281 GTK_POLICY_AUTOMATIC, | |
282 GTK_POLICY_AUTOMATIC); | |
283 | |
284 pluglist = gtk_list_new(); | |
285 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), pluglist); | |
286 gtk_box_pack_start(GTK_BOX(topbox), sw2, TRUE, TRUE, 0); | |
287 | |
288 sw = gtk_scrolled_window_new(NULL, NULL); | |
289 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
290 GTK_POLICY_AUTOMATIC, | |
291 GTK_POLICY_AUTOMATIC); | |
292 | |
293 plugtext = gtk_text_new(NULL, NULL); | |
294 gtk_container_add(GTK_CONTAINER(sw), plugtext); | |
295 gtk_box_pack_start(GTK_BOX(topbox), sw, TRUE, TRUE, 0); | |
296 gtk_text_set_word_wrap(GTK_TEXT(plugtext), TRUE); | |
297 gtk_text_set_editable(GTK_TEXT(plugtext), FALSE); | |
298 | |
619 | 299 add = picture_button(plugwindow, _("Add Plugin"), gnome_add_xpm); |
90 | 300 gtk_signal_connect(GTK_OBJECT(add), "clicked", |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
301 GTK_SIGNAL_FUNC(load_file), NULL); |
90 | 302 gtk_box_pack_start(GTK_BOX(botbox), add, TRUE, FALSE, 5); |
303 | |
619 | 304 config = picture_button(plugwindow, _("Configure Plugin"), gnome_preferences_xpm); |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
305 gtk_widget_set_sensitive(config, 0); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
306 gtk_box_pack_start(GTK_BOX(botbox), config, TRUE, FALSE, 5); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
307 |
619 | 308 remove = picture_button(plugwindow, _("Remove Plugin"), gnome_remove_xpm); |
90 | 309 gtk_signal_connect(GTK_OBJECT(remove), "clicked", |
310 GTK_SIGNAL_FUNC(unload), pluglist); | |
311 gtk_box_pack_start(GTK_BOX(botbox), remove, TRUE, FALSE, 5); | |
312 | |
619 | 313 close = picture_button(plugwindow, _("Close"), gnome_close_xpm); |
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
314 gtk_signal_connect(GTK_OBJECT(close), "clicked", |
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
315 GTK_SIGNAL_FUNC(hide_plugins), NULL); |
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
316 gtk_box_pack_start(GTK_BOX(botbox), close, TRUE, FALSE, 5); |
619 | 317 |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
318 if (display_options & OPT_DISP_COOL_LOOK) |
619 | 319 { |
320 gtk_button_set_relief(GTK_BUTTON(add), GTK_RELIEF_NONE); | |
321 gtk_button_set_relief(GTK_BUTTON(config), GTK_RELIEF_NONE); | |
322 gtk_button_set_relief(GTK_BUTTON(remove), GTK_RELIEF_NONE); | |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
323 gtk_button_set_relief(GTK_BUTTON(close), GTK_RELIEF_NONE); |
619 | 324 } |
325 | |
90 | 326 gtk_box_pack_start(GTK_BOX(page), topbox, TRUE, TRUE, 0); |
327 gtk_box_pack_start(GTK_BOX(page), botbox, FALSE, FALSE, 0); | |
328 | |
329 if (plugs != NULL) { | |
330 p = (struct gaim_plugin *)plugs->data; | |
331 g_snprintf(buffer, sizeof(buffer), "%s", p->filename); | |
332 gtk_text_insert(GTK_TEXT(plugtext), NULL, NULL, NULL, buffer, -1); | |
333 } | |
334 | |
335 while (plugs) { | |
336 p = (struct gaim_plugin *)plugs->data; | |
337 label = gtk_label_new(p->filename); | |
338 list_item = gtk_list_item_new(); | |
339 gtk_container_add(GTK_CONTAINER(list_item), label); | |
340 gtk_signal_connect(GTK_OBJECT(list_item), "select", | |
341 GTK_SIGNAL_FUNC(list_clicked), p); | |
342 gtk_object_set_user_data(GTK_OBJECT(list_item), p); | |
343 | |
344 gtk_widget_show(label); | |
345 gtk_container_add(GTK_CONTAINER(pluglist), list_item); | |
346 gtk_widget_show(list_item); | |
347 | |
348 plugs = plugs->next; | |
349 } | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
350 if (plugins != NULL) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
351 gtk_list_select_item(GTK_LIST(pluglist), 0); |
90 | 352 |
353 gtk_widget_show(page); | |
354 gtk_widget_show(topbox); | |
355 gtk_widget_show(botbox); | |
356 gtk_widget_show(sw); | |
357 gtk_widget_show(sw2); | |
358 gtk_widget_show(pluglist); | |
359 gtk_widget_show(plugtext); | |
360 gtk_widget_show(add); | |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
361 gtk_widget_show(config); |
90 | 362 gtk_widget_show(remove); |
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
363 gtk_widget_show(close); |
90 | 364 |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
365 gtk_container_add(GTK_CONTAINER(plugwindow), page); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
366 gtk_widget_show(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
367 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
368 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
369 void update_show_plugins() { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
370 GList *plugs = plugins; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
371 struct gaim_plugin *p; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
372 GtkWidget *label; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
373 GtkWidget *list_item; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
374 |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
375 if (plugwindow == NULL) return; |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
376 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
377 gtk_list_clear_items(GTK_LIST(pluglist), 0, -1); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
378 while (plugs) { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
379 p = (struct gaim_plugin *)plugs->data; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
380 label = gtk_label_new(p->filename); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
381 list_item = gtk_list_item_new(); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
382 gtk_container_add(GTK_CONTAINER(list_item), label); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
383 gtk_signal_connect(GTK_OBJECT(list_item), "select", |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
384 GTK_SIGNAL_FUNC(list_clicked), p); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
385 gtk_object_set_user_data(GTK_OBJECT(list_item), p); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
386 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
387 gtk_widget_show(label); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
388 gtk_container_add(GTK_CONTAINER(pluglist), list_item); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
389 gtk_widget_show(list_item); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
390 plugs = plugs->next; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
391 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
392 if (plugins != NULL) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
393 gtk_list_select_item(GTK_LIST(pluglist), 0); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
394 else { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
395 gtk_text_set_point(GTK_TEXT(plugtext), 0); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
396 gtk_text_forward_delete(GTK_TEXT(plugtext), |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
397 gtk_text_get_length(GTK_TEXT(plugtext))); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
398 } |
1 | 399 } |
400 | |
90 | 401 void unload(GtkWidget *w, gpointer data) { |
402 GList *i; | |
403 struct gaim_plugin *p; | |
404 void (*gaim_plugin_remove)(); | |
405 char *error; | |
406 | |
407 i = GTK_LIST(pluglist)->selection; | |
408 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
409 if (i == NULL) return; |
90 | 410 |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
411 p = gtk_object_get_user_data(GTK_OBJECT(i->data)); |
1 | 412 |
90 | 413 gaim_plugin_remove = dlsym(p->handle, "gaim_plugin_remove"); |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
414 if ((error = (char *)dlerror()) == NULL) |
90 | 415 (*gaim_plugin_remove)(); |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
416 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
417 gaim_plugin_unload(p->handle); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
418 } |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
419 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
420 static void remove_callback(struct gaim_plugin *p) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
421 gtk_timeout_remove(p->remove); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
422 dlclose(p->handle); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
423 g_free(p); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
424 } |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
425 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
426 /* gaim_plugin_unload serves 2 purposes: 1. so plugins can unload themselves |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
427 * 2. to make my life easier */ |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
428 void gaim_plugin_unload(void *handle) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
429 GList *i; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
430 struct gaim_plugin *p = NULL; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
431 GList *c = callbacks; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
432 struct gaim_callback *g; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
433 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
434 i = plugins; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
435 while (i) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
436 p = (struct gaim_plugin *)i->data; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
437 if (handle == p->handle) |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
438 break; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
439 p = NULL; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
440 i = i->next; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
441 } |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
442 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
443 if (!p) |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
444 return; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
445 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
446 sprintf(debug_buff, "Unloading %s\n", p->filename); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
447 debug_print(debug_buff); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
448 |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
449 sprintf(debug_buff, "%d callbacks to search\n", g_list_length(callbacks)); |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
450 debug_print(debug_buff); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
451 while (c) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
452 g = (struct gaim_callback *)c->data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
453 if (g->handle == p->handle) { |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
454 callbacks = g_list_remove(callbacks, c->data); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
455 g_free(g); |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
456 sprintf(debug_buff, "Removing callback, %d remain\n", |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
457 g_list_length(callbacks)); |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
458 debug_print(debug_buff); |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
459 c = callbacks; |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
460 if (c == NULL) { |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
461 break; |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
462 } |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
463 } else { |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
464 c = c->next; |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
465 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
466 } |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
467 p->remove = gtk_timeout_add(5000, (GtkFunction)remove_callback, p); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
468 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
469 plugins = g_list_remove(plugins, p); |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
470 g_free(p->filename); |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
471 if (config) gtk_widget_set_sensitive(config, 0); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
472 update_show_plugins(); |
154
1c4e47c0c5dd
[gaim-migrate @ 164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
153
diff
changeset
|
473 save_prefs(); |
90 | 474 } |
475 | |
476 void list_clicked(GtkWidget *w, struct gaim_plugin *p) { | |
477 gchar buffer[2048]; | |
478 guint text_len; | |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
479 void (*gaim_plugin_config)(); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
480 char *error; |
90 | 481 |
522
11cbf8b403b6
[gaim-migrate @ 532]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
482 if (confighandle != 0) |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
483 gtk_signal_disconnect(GTK_OBJECT(config), confighandle); |
90 | 484 text_len = gtk_text_get_length(GTK_TEXT(plugtext)); |
485 gtk_text_set_point(GTK_TEXT(plugtext), 0); | |
486 gtk_text_forward_delete(GTK_TEXT(plugtext), text_len); | |
487 | |
488 g_snprintf(buffer, sizeof buffer, "%s\n%s", p->name, p->description); | |
489 gtk_text_insert(GTK_TEXT(plugtext), NULL, NULL, NULL, buffer, -1); | |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
490 |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
491 gaim_plugin_config = dlsym(p->handle, "gaim_plugin_config"); |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
492 if ((error = (char *)dlerror()) == NULL) { |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
493 confighandle = gtk_signal_connect(GTK_OBJECT(config), "clicked", |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
494 GTK_SIGNAL_FUNC(gaim_plugin_config), NULL); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
495 gtk_widget_set_sensitive(config, 1); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
496 } else { |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
497 confighandle = 0; |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
498 gtk_widget_set_sensitive(config, 0); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
499 } |
90 | 500 } |
501 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
502 void hide_plugins(GtkWidget *w, gpointer data) { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
503 if (plugwindow) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
504 gtk_widget_destroy(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
505 plugwindow = NULL; |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
506 config = NULL; |
522
11cbf8b403b6
[gaim-migrate @ 532]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
507 confighandle = 0; |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
508 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
509 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
510 void gaim_signal_connect(void *handle, enum gaim_event which, |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
511 void *func, void *data) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
512 struct gaim_callback *call = g_malloc(sizeof *call); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
513 call->handle = handle; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
514 call->event = which; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
515 call->function = func; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
516 call->data = data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
517 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
518 callbacks = g_list_append(callbacks, call); |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
519 sprintf(debug_buff, "Adding callback %d\n", g_list_length(callbacks)); |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
520 debug_print(debug_buff); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
521 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
522 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
523 void gaim_signal_disconnect(void *handle, enum gaim_event which, void *func) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
524 GList *c = callbacks; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
525 struct gaim_callback *g = NULL; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
526 while (c) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
527 g = (struct gaim_callback *)c->data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
528 if (handle == g->handle && func == g->function) { |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
529 callbacks = g_list_remove(callbacks, c->data); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
530 g_free(g); |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
531 c = callbacks; |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
532 if (c == NULL) break; |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
533 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
534 c = c->next; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
535 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
536 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
537 |
90 | 538 #endif /* GAIM_PLUGINS */ |