Mercurial > pidgin
annotate src/plugins.c @ 615:9f168ba28ac2
[gaim-migrate @ 625]
the default fontface now works in buddy chats as well
committer: Tailor Script <tailor@pidgin.im>
author | Todd Kulesza <fflewddur> |
---|---|
date | Sat, 05 Aug 2000 04:38:19 +0000 |
parents | f03f041c1aa9 |
children | faa7603ae02e |
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" | |
48 | |
90 | 49 #include <dlfcn.h> |
50 | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
51 /* ------------------ Global Variables ----------------------- */ |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
52 |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
53 GList *plugins = NULL; |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
54 GList *callbacks = NULL; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
55 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
56 /* ------------------ Local Variables ------------------------ */ |
1 | 57 |
90 | 58 static GtkWidget *plugin_dialog = NULL; |
59 | |
60 static GtkWidget *pluglist; | |
61 static GtkWidget *plugtext; | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
62 static GtkWidget *plugwindow; |
1 | 63 |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
64 static GtkWidget *config = NULL; |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
65 static guint confighandle = 0; |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
66 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
67 /* --------------- Function Declarations --------------------- */ |
1 | 68 |
90 | 69 void show_plugins (GtkWidget *, gpointer); |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
70 void load_plugin (char *); |
90 | 71 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
72 void gaim_signal_connect (void *, enum gaim_event, void *, void *); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
73 void gaim_signal_disconnect(void *, enum gaim_event, void *); |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
74 void gaim_plugin_unload (void *); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
75 |
90 | 76 static void destroy_plugins (GtkWidget *, gpointer); |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
77 static void load_file (GtkWidget *, gpointer); |
90 | 78 static void load_which_plugin(GtkWidget *, gpointer); |
79 static void unload (GtkWidget *, gpointer); | |
80 static void list_clicked (GtkWidget *, struct gaim_plugin *); | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
81 static void update_show_plugins(); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
82 static void hide_plugins (GtkWidget *, gpointer); |
90 | 83 |
1 | 84 /* ------------------ Code Below ---------------------------- */ |
85 | |
90 | 86 static void destroy_plugins(GtkWidget *w, gpointer data) { |
87 if (plugin_dialog) | |
88 gtk_widget_destroy(plugin_dialog); | |
89 plugin_dialog = NULL; | |
90 } | |
91 | |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
92 static void load_file(GtkWidget *w, gpointer data) |
1 | 93 { |
90 | 94 char *buf = g_malloc(BUF_LEN); |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
95 FILE *fd; |
1 | 96 |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
97 if (plugin_dialog) { |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
98 g_free(buf); |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
99 gtk_widget_show(plugin_dialog); |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
100 gdk_window_raise(plugin_dialog->window); |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
101 return; |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
102 } |
90 | 103 |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
104 plugin_dialog = gtk_file_selection_new(_("Gaim - Plugin List")); |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
105 |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
106 gtk_file_selection_hide_fileop_buttons( |
90 | 107 GTK_FILE_SELECTION(plugin_dialog)); |
108 | |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
109 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
|
110 fd = fopen(buf, "r"); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
111 if (!fd) |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
112 mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
113 else |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
114 fclose(fd); |
1 | 115 |
90 | 116 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
|
117 gtk_file_selection_complete(GTK_FILE_SELECTION(plugin_dialog), "*.so"); |
90 | 118 gtk_signal_connect(GTK_OBJECT(plugin_dialog), "destroy", |
119 GTK_SIGNAL_FUNC(destroy_plugins), plugin_dialog); | |
120 | |
121 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->ok_button), | |
122 "clicked", GTK_SIGNAL_FUNC(load_which_plugin), NULL); | |
123 | |
124 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->cancel_button), | |
125 "clicked", GTK_SIGNAL_FUNC(destroy_plugins), NULL); | |
126 | |
127 g_free(buf); | |
128 gtk_widget_show(plugin_dialog); | |
129 gdk_window_raise(plugin_dialog->window); | |
130 } | |
1 | 131 |
139
c009c4f4ad02
[gaim-migrate @ 149]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
138
diff
changeset
|
132 static void load_which_plugin(GtkWidget *w, gpointer data) { |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
133 load_plugin(gtk_file_selection_get_filename( |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
134 GTK_FILE_SELECTION(plugin_dialog))); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
135 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
136 if (plugin_dialog) |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
137 gtk_widget_destroy(plugin_dialog); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
138 plugin_dialog = NULL; |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
139 } |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
140 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
141 void load_plugin(char *filename) { |
90 | 142 struct gaim_plugin *plug; |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
143 GList *c = plugins; |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
144 int (*gaim_plugin_init)(); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
145 char *(*gaim_plugin_error)(int); |
90 | 146 char *(*cfunc)(); |
147 char *error; | |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
148 int retval; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
149 char *plugin_error; |
90 | 150 |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
151 if (filename == NULL) return; |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
152 /* 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
|
153 while (c) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
154 plug = (struct gaim_plugin *)c->data; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
155 if (!strcmp(filename, plug->filename)) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
156 sprintf(debug_buff, _("Already loaded %s, " |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
157 "not reloading.\n"), filename); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
158 debug_print(debug_buff); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
159 return; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
160 } |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
161 c = c->next; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
162 } |
90 | 163 plug = g_malloc(sizeof *plug); |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
164 if (filename[0] != '/') { |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
165 char *buf = g_malloc(BUF_LEN); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
166 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
|
167 plug->filename = g_malloc(strlen(buf) + strlen(filename) + 1); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
168 sprintf(plug->filename, "%s%s", buf, filename); |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
169 } else |
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
170 plug->filename = g_strdup(filename); |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
171 sprintf(debug_buff, "Loading %s\n", filename); |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
172 debug_print(debug_buff); |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
173 /* do NOT `OR' with RTLD_GLOBAL, otherwise plugins may conflict |
90 | 174 * (it's really just a way to work around other people's bad |
175 * programming, by not using RTLD_GLOBAL :P ) */ | |
176 plug->handle = dlopen(plug->filename, RTLD_LAZY); | |
177 if (!plug->handle) { | |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
178 error = (char *)dlerror(); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
179 do_error_dialog(error, _("Plugin Error")); |
90 | 180 g_free(plug); |
181 return; | |
182 } | |
183 | |
184 gaim_plugin_init = dlsym(plug->handle, "gaim_plugin_init"); | |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
185 if ((error = (char *)dlerror()) != NULL) { |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
186 do_error_dialog(error, _("Plugin Error")); |
90 | 187 dlclose(plug->handle); |
188 g_free(plug); | |
189 return; | |
190 } | |
191 | |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
192 retval = (*gaim_plugin_init)(plug->handle); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
193 sprintf(debug_buff, "loaded plugin returned %d\n", retval); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
194 debug_print(debug_buff); |
397
0b5ecac8aa54
[gaim-migrate @ 407]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
392
diff
changeset
|
195 if (retval < 0) { |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
196 GList *c = callbacks; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
197 struct gaim_callback *g; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
198 while (c) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
199 g = (struct gaim_callback *)c->data; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
200 if (g->handle == plug->handle) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
201 callbacks = g_list_remove(callbacks, c->data); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
202 sprintf(debug_buff, "Removing callback, %d remain\n", |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
203 g_list_length(callbacks)); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
204 debug_print(debug_buff); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
205 c = callbacks; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
206 if (c == NULL) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
207 break; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
208 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
209 } else { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
210 c = c->next; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
211 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
212 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
213 gaim_plugin_error = dlsym(plug->handle, "gaim_plugin_error"); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
214 if ((error = (char *)dlerror()) == NULL) { |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
215 plugin_error = (*gaim_plugin_error)(retval); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
216 if (plugin_error) |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
217 do_error_dialog(plugin_error, _("Plugin Error")); |
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 dlclose(plug->handle); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
220 g_free(plug); |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
221 return; |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
222 } |
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
223 |
90 | 224 plugins = g_list_append(plugins, plug); |
1 | 225 |
90 | 226 cfunc = dlsym(plug->handle, "name"); |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
227 if ((error = (char *)dlerror()) == NULL) |
90 | 228 plug->name = (*cfunc)(); |
229 else | |
230 plug->name = NULL; | |
1 | 231 |
90 | 232 cfunc = dlsym(plug->handle, "description"); |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
233 if ((error = (char *)dlerror()) == NULL) |
90 | 234 plug->description = (*cfunc)(); |
235 else | |
236 plug->description = NULL; | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
237 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
238 update_show_plugins(); |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
239 save_prefs(); |
90 | 240 } |
1 | 241 |
90 | 242 void show_plugins(GtkWidget *w, gpointer data) { |
243 /* most of this code was shamelessly stolen from prefs.c */ | |
244 GtkWidget *page; | |
245 GtkWidget *topbox; | |
246 GtkWidget *botbox; | |
247 GtkWidget *sw; | |
248 GtkWidget *label; | |
249 GtkWidget *list_item; | |
250 GtkWidget *sw2; | |
251 GtkWidget *add; | |
252 GtkWidget *remove; | |
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
253 GtkWidget *close; |
90 | 254 GList *plugs = plugins; |
255 struct gaim_plugin *p; | |
256 gchar buffer[1024]; | |
257 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
258 if (plugwindow) return; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
259 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
260 plugwindow = gtk_window_new(GTK_WINDOW_DIALOG); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
261 gtk_widget_realize(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
262 aol_icon(plugwindow->window); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
263 gtk_container_border_width(GTK_CONTAINER(plugwindow), 10); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
264 gtk_window_set_title(GTK_WINDOW(plugwindow), _("Gaim - Plugins")); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
265 gtk_widget_set_usize(plugwindow, 400, 250); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
266 gtk_signal_connect(GTK_OBJECT(plugwindow), "destroy", |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
267 GTK_SIGNAL_FUNC(hide_plugins), NULL); |
90 | 268 |
269 page = gtk_vbox_new(FALSE, 0); | |
270 topbox = gtk_hbox_new(FALSE, 0); | |
271 botbox = gtk_hbox_new(FALSE, 0); | |
272 | |
273 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
274 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
275 GTK_POLICY_AUTOMATIC, | |
276 GTK_POLICY_AUTOMATIC); | |
277 | |
278 pluglist = gtk_list_new(); | |
279 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), pluglist); | |
280 gtk_box_pack_start(GTK_BOX(topbox), sw2, TRUE, TRUE, 0); | |
281 | |
282 sw = gtk_scrolled_window_new(NULL, NULL); | |
283 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
284 GTK_POLICY_AUTOMATIC, | |
285 GTK_POLICY_AUTOMATIC); | |
286 | |
287 plugtext = gtk_text_new(NULL, NULL); | |
288 gtk_container_add(GTK_CONTAINER(sw), plugtext); | |
289 gtk_box_pack_start(GTK_BOX(topbox), sw, TRUE, TRUE, 0); | |
290 gtk_text_set_word_wrap(GTK_TEXT(plugtext), TRUE); | |
291 gtk_text_set_editable(GTK_TEXT(plugtext), FALSE); | |
292 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
293 add = gtk_button_new_with_label(_("Load Plugin")); |
90 | 294 gtk_signal_connect(GTK_OBJECT(add), "clicked", |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
295 GTK_SIGNAL_FUNC(load_file), NULL); |
90 | 296 gtk_box_pack_start(GTK_BOX(botbox), add, TRUE, FALSE, 5); |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
297 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
298 gtk_button_set_relief(GTK_BUTTON(add), GTK_RELIEF_NONE); |
90 | 299 |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
300 config = gtk_button_new_with_label(_("Configure Plugin")); |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
301 gtk_widget_set_sensitive(config, 0); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
302 gtk_box_pack_start(GTK_BOX(botbox), config, TRUE, FALSE, 5); |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
303 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
304 gtk_button_set_relief(GTK_BUTTON(config), GTK_RELIEF_NONE); |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
305 |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
306 remove = gtk_button_new_with_label(_("Unload Plugin")); |
90 | 307 gtk_signal_connect(GTK_OBJECT(remove), "clicked", |
308 GTK_SIGNAL_FUNC(unload), pluglist); | |
309 gtk_box_pack_start(GTK_BOX(botbox), remove, TRUE, FALSE, 5); | |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
310 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
311 gtk_button_set_relief(GTK_BUTTON(remove), GTK_RELIEF_NONE); |
90 | 312 |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
313 close = gtk_button_new_with_label(_("Close")); |
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); |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
317 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
522
diff
changeset
|
318 gtk_button_set_relief(GTK_BUTTON(close), GTK_RELIEF_NONE); |
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
319 |
90 | 320 gtk_box_pack_start(GTK_BOX(page), topbox, TRUE, TRUE, 0); |
321 gtk_box_pack_start(GTK_BOX(page), botbox, FALSE, FALSE, 0); | |
322 | |
323 if (plugs != NULL) { | |
324 p = (struct gaim_plugin *)plugs->data; | |
325 g_snprintf(buffer, sizeof(buffer), "%s", p->filename); | |
326 gtk_text_insert(GTK_TEXT(plugtext), NULL, NULL, NULL, buffer, -1); | |
327 } | |
328 | |
329 while (plugs) { | |
330 p = (struct gaim_plugin *)plugs->data; | |
331 label = gtk_label_new(p->filename); | |
332 list_item = gtk_list_item_new(); | |
333 gtk_container_add(GTK_CONTAINER(list_item), label); | |
334 gtk_signal_connect(GTK_OBJECT(list_item), "select", | |
335 GTK_SIGNAL_FUNC(list_clicked), p); | |
336 gtk_object_set_user_data(GTK_OBJECT(list_item), p); | |
337 | |
338 gtk_widget_show(label); | |
339 gtk_container_add(GTK_CONTAINER(pluglist), list_item); | |
340 gtk_widget_show(list_item); | |
341 | |
342 plugs = plugs->next; | |
343 } | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
344 if (plugins != NULL) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
345 gtk_list_select_item(GTK_LIST(pluglist), 0); |
90 | 346 |
347 gtk_widget_show(page); | |
348 gtk_widget_show(topbox); | |
349 gtk_widget_show(botbox); | |
350 gtk_widget_show(sw); | |
351 gtk_widget_show(sw2); | |
352 gtk_widget_show(pluglist); | |
353 gtk_widget_show(plugtext); | |
354 gtk_widget_show(add); | |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
355 gtk_widget_show(config); |
90 | 356 gtk_widget_show(remove); |
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
357 gtk_widget_show(close); |
90 | 358 |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
359 gtk_container_add(GTK_CONTAINER(plugwindow), page); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
360 gtk_widget_show(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
361 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
362 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
363 void update_show_plugins() { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
364 GList *plugs = plugins; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
365 struct gaim_plugin *p; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
366 GtkWidget *label; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
367 GtkWidget *list_item; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
368 |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
369 if (plugwindow == NULL) return; |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
370 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
371 gtk_list_clear_items(GTK_LIST(pluglist), 0, -1); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
372 while (plugs) { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
373 p = (struct gaim_plugin *)plugs->data; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
374 label = gtk_label_new(p->filename); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
375 list_item = gtk_list_item_new(); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
376 gtk_container_add(GTK_CONTAINER(list_item), label); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
377 gtk_signal_connect(GTK_OBJECT(list_item), "select", |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
378 GTK_SIGNAL_FUNC(list_clicked), p); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
379 gtk_object_set_user_data(GTK_OBJECT(list_item), p); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
380 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
381 gtk_widget_show(label); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
382 gtk_container_add(GTK_CONTAINER(pluglist), list_item); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
383 gtk_widget_show(list_item); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
384 plugs = plugs->next; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
385 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
386 if (plugins != NULL) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
387 gtk_list_select_item(GTK_LIST(pluglist), 0); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
388 else { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
389 gtk_text_set_point(GTK_TEXT(plugtext), 0); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
390 gtk_text_forward_delete(GTK_TEXT(plugtext), |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
391 gtk_text_get_length(GTK_TEXT(plugtext))); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
392 } |
1 | 393 } |
394 | |
90 | 395 void unload(GtkWidget *w, gpointer data) { |
396 GList *i; | |
397 struct gaim_plugin *p; | |
398 void (*gaim_plugin_remove)(); | |
399 char *error; | |
400 | |
401 i = GTK_LIST(pluglist)->selection; | |
402 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
403 if (i == NULL) return; |
90 | 404 |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
405 p = gtk_object_get_user_data(GTK_OBJECT(i->data)); |
1 | 406 |
90 | 407 gaim_plugin_remove = dlsym(p->handle, "gaim_plugin_remove"); |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
408 if ((error = (char *)dlerror()) == NULL) |
90 | 409 (*gaim_plugin_remove)(); |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
410 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
411 gaim_plugin_unload(p->handle); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
412 } |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
413 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
414 static void remove_callback(struct gaim_plugin *p) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
415 gtk_timeout_remove(p->remove); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
416 dlclose(p->handle); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
417 g_free(p); |
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 /* 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
|
421 * 2. to make my life easier */ |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
422 void gaim_plugin_unload(void *handle) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
423 GList *i; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
424 struct gaim_plugin *p = NULL; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
425 GList *c = callbacks; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
426 struct gaim_callback *g; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
427 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
428 i = plugins; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
429 while (i) { |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
430 p = (struct gaim_plugin *)i->data; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
431 if (handle == p->handle) |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
432 break; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
433 p = NULL; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
434 i = i->next; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
435 } |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
436 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
437 if (!p) |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
438 return; |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
439 |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
440 sprintf(debug_buff, "Unloading %s\n", p->filename); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
441 debug_print(debug_buff); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
442 |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
443 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
|
444 debug_print(debug_buff); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
445 while (c) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
446 g = (struct gaim_callback *)c->data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
447 if (g->handle == p->handle) { |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
448 callbacks = g_list_remove(callbacks, c->data); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
449 g_free(g); |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
450 sprintf(debug_buff, "Removing callback, %d remain\n", |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
451 g_list_length(callbacks)); |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
452 debug_print(debug_buff); |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
453 c = callbacks; |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
454 if (c == NULL) { |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
455 break; |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
456 } |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
457 } else { |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
458 c = c->next; |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
459 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
460 } |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
461 p->remove = gtk_timeout_add(5000, (GtkFunction)remove_callback, p); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
462 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
463 plugins = g_list_remove(plugins, p); |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
464 g_free(p->filename); |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
465 if (config) gtk_widget_set_sensitive(config, 0); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
466 update_show_plugins(); |
154
1c4e47c0c5dd
[gaim-migrate @ 164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
153
diff
changeset
|
467 save_prefs(); |
90 | 468 } |
469 | |
470 void list_clicked(GtkWidget *w, struct gaim_plugin *p) { | |
471 gchar buffer[2048]; | |
472 guint text_len; | |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
473 void (*gaim_plugin_config)(); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
474 char *error; |
90 | 475 |
522
11cbf8b403b6
[gaim-migrate @ 532]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
476 if (confighandle != 0) |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
477 gtk_signal_disconnect(GTK_OBJECT(config), confighandle); |
90 | 478 text_len = gtk_text_get_length(GTK_TEXT(plugtext)); |
479 gtk_text_set_point(GTK_TEXT(plugtext), 0); | |
480 gtk_text_forward_delete(GTK_TEXT(plugtext), text_len); | |
481 | |
482 g_snprintf(buffer, sizeof buffer, "%s\n%s", p->name, p->description); | |
483 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
|
484 |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
485 gaim_plugin_config = dlsym(p->handle, "gaim_plugin_config"); |
129
4290a5a20d3c
[gaim-migrate @ 139]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
110
diff
changeset
|
486 if ((error = (char *)dlerror()) == NULL) { |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
487 confighandle = gtk_signal_connect(GTK_OBJECT(config), "clicked", |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
488 GTK_SIGNAL_FUNC(gaim_plugin_config), NULL); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
489 gtk_widget_set_sensitive(config, 1); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
490 } else { |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
491 confighandle = 0; |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
492 gtk_widget_set_sensitive(config, 0); |
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
493 } |
90 | 494 } |
495 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
496 void hide_plugins(GtkWidget *w, gpointer data) { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
497 if (plugwindow) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
498 gtk_widget_destroy(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
499 plugwindow = NULL; |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
500 config = NULL; |
522
11cbf8b403b6
[gaim-migrate @ 532]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
501 confighandle = 0; |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
502 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
503 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
504 void gaim_signal_connect(void *handle, enum gaim_event which, |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
505 void *func, void *data) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
506 struct gaim_callback *call = g_malloc(sizeof *call); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
507 call->handle = handle; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
508 call->event = which; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
509 call->function = func; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
510 call->data = data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
511 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
512 callbacks = g_list_append(callbacks, call); |
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
513 sprintf(debug_buff, "Adding callback %d\n", g_list_length(callbacks)); |
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
154
diff
changeset
|
514 debug_print(debug_buff); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
515 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
516 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
517 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
|
518 GList *c = callbacks; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
519 struct gaim_callback *g = NULL; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
520 while (c) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
521 g = (struct gaim_callback *)c->data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
522 if (handle == g->handle && func == g->function) { |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
523 callbacks = g_list_remove(callbacks, c->data); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
524 g_free(g); |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
525 c = callbacks; |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
526 if (c == NULL) break; |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
527 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
528 c = c->next; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
529 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
530 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
531 |
90 | 532 #endif /* GAIM_PLUGINS */ |