Mercurial > pidgin.yaz
annotate plugins/perl/perl.c @ 6525:66689e2cb966
[gaim-migrate @ 7042]
Pass the GaimPlugin to the load/unload functions in the perl scripts.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 20 Aug 2003 10:45:12 +0000 |
parents | 2d9857a0d8a3 |
children | e162c765fe21 |
rev | line source |
---|---|
5205 | 1 /* |
2 * gaim | |
3 * | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
4 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> |
5205 | 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 */ | |
6235 | 20 #ifdef HAVE_CONFIG_H |
21 #include <config.h> | |
22 #endif | |
23 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
24 #ifdef DEBUG |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
25 # undef DEBUG |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
26 #endif |
5205 | 27 |
28 #undef PACKAGE | |
29 | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
30 |
5205 | 31 #define group perl_group |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
32 |
5205 | 33 #ifdef _WIN32 |
34 /* This took me an age to figure out.. without this __declspec(dllimport) | |
35 * will be ignored. | |
36 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
37 # define HASATTRIBUTE |
5205 | 38 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
39 |
5205 | 40 #include <EXTERN.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
41 |
5205 | 42 #ifndef _SEM_SEMUN_UNDEFINED |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
43 # define HAS_UNION_SEMUN |
5205 | 44 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
45 |
5205 | 46 #include <perl.h> |
47 #include <XSUB.h> | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
48 |
5205 | 49 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
50 # include <sys/mman.h> |
5205 | 51 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
52 |
5205 | 53 #undef PACKAGE |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
54 |
5205 | 55 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
56 # include <dirent.h> |
5205 | 57 #else |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
58 /* We're using perl's win32 port of this */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
59 # define dirent direct |
5205 | 60 #endif |
61 | |
62 #undef group | |
63 | |
64 /* perl module support */ | |
65 #ifdef OLD_PERL | |
66 extern void boot_DynaLoader _((CV * cv)); | |
67 #else | |
68 extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */ | |
69 #endif | |
70 | |
71 #undef _ | |
72 #ifdef DEBUG | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
73 # undef DEBUG |
5205 | 74 #endif |
75 #ifdef _WIN32 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
76 # undef pipe |
5205 | 77 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
78 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
79 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
80 #include "debug.h" |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
81 #include "plugin.h" |
5205 | 82 |
6522
0c5233faceb8
[gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
83 #include "perl-handlers.h" |
0c5233faceb8
[gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
84 |
5205 | 85 #define PERL_PLUGIN_ID "core-perl" |
86 | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
87 typedef struct |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
88 { |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
89 GaimPlugin *plugin; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
90 char *load_sub; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
91 char *unload_sub; |
5205 | 92 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
93 } GaimPerlScript; |
5205 | 94 |
95 | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
96 PerlInterpreter *my_perl = NULL; |
5205 | 97 |
98 static void | |
99 #ifdef OLD_PERL | |
100 xs_init() | |
101 #else | |
102 xs_init(pTHX) | |
103 #endif | |
104 { | |
105 char *file = __FILE__; | |
106 | |
107 /* This one allows dynamic loading of perl modules in perl | |
108 scripts by the 'use perlmod;' construction*/ | |
109 newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); | |
110 } | |
111 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
112 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
113 static void |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
114 perl_init(void) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
115 { |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
116 /* changed the name of the variable from load_file to |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
117 perl_definitions since now it does much more than defining |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
118 the load_file sub. Moreover, deplaced the initialisation to |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
119 the xs_init function. (TheHobbit)*/ |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
120 char *perl_args[] = { "", "-e", "0", "-w" }; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
121 char perl_definitions[] = |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
122 { |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
123 /* We use to function one to load a file the other to |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
124 execute the string obtained from the first and holding |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
125 the file conents. This allows to have a realy local $/ |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
126 without introducing temp variables to hold the old |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
127 value. Just a question of style:) */ |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
128 "sub load_file{" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
129 "my $f_name=shift;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
130 "local $/=undef;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
131 "open FH,$f_name or return \"__FAILED__\";" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
132 "$_=<FH>;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
133 "close FH;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
134 "return $_;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
135 "}" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
136 "sub load_n_eval{" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
137 "my $f_name=shift;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
138 "my $strin=load_file($f_name);" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
139 "return 2 if($strin eq \"__FAILED__\");" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
140 "eval $strin;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
141 "if($@){" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
142 /*" #something went wrong\n"*/ |
6524
2d9857a0d8a3
[gaim-migrate @ 7041]
Christian Hammond <chipx86@chipx86.com>
parents:
6523
diff
changeset
|
143 "Gaim::debug(\"perl\", \"Errors loading file $f_name:\\n$@\");" |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
144 "return 1;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
145 "}" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
146 "return 0;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
147 "}" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
148 }; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
149 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
150 my_perl = perl_alloc(); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
151 perl_construct(my_perl); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
152 #ifdef DEBUG |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
153 perl_parse(my_perl, xs_init, 4, perl_args, NULL); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
154 #else |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
155 perl_parse(my_perl, xs_init, 3, perl_args, NULL); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
156 #endif |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
157 #ifdef HAVE_PERL_EVAL_PV |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
158 eval_pv(perl_definitions, TRUE); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
159 #else |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
160 perl_eval_pv(perl_definitions, TRUE); /* deprecated */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
161 #endif |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
162 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
163 perl_run(my_perl); |
5205 | 164 } |
165 | |
166 static void | |
167 perl_end(void) | |
168 { | |
6520
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
169 if (my_perl == NULL) |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
170 return; |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
171 |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
172 perl_eval_pv( |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
173 "foreach my $lib (@DynaLoader::dl_modules) {" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
174 "if ($lib =~ /^Gaim\\b/) {" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
175 "$lib .= '::deinit();';" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
176 "eval $lib;" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
177 "}" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
178 "}", |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
179 TRUE); |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
180 |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
181 perl_destruct(my_perl); |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
182 perl_free(my_perl); |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
183 my_perl = NULL; |
5205 | 184 } |
185 | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
186 void |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
187 gaim_perl_callXS(void (*subaddr)(pTHX_ CV *cv), CV *cv, SV **mark) |
5205 | 188 { |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
189 dSP; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
190 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
191 PUSHMARK(mark); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
192 (*subaddr)(aTHX_ cv); |
5205 | 193 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
194 PUTBACK; |
5205 | 195 } |
196 | |
197 static gboolean | |
198 probe_perl_plugin(GaimPlugin *plugin) | |
199 { | |
200 /* XXX This would be much faster if I didn't create a new | |
201 * PerlInterpreter every time I probed a plugin */ | |
202 PerlInterpreter *prober = perl_alloc(); | |
203 char *argv[] = {"", plugin->path }; | |
204 int count; | |
205 gboolean status = TRUE; | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
206 HV *plugin_info; |
5205 | 207 |
208 perl_construct(prober); | |
5922 | 209 perl_parse(prober, xs_init, 2, argv, NULL); |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
210 perl_run(prober); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
211 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
212 plugin_info = perl_get_hv("PLUGIN_INFO", FALSE); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
213 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
214 if (plugin_info == NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
215 status = FALSE; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
216 else if (!hv_exists(plugin_info, "perl_api_version", |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
217 strlen("perl_api_version")) || |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
218 !hv_exists(plugin_info, "name", strlen("name")) || |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
219 !hv_exists(plugin_info, "load", strlen("load"))) |
5205 | 220 { |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
221 /* Not a valid plugin. */ |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
222 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
223 status = FALSE; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
224 } |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
225 else |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
226 { |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
227 SV **key; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
228 int perl_api_ver; |
5205 | 229 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
230 key = hv_fetch(plugin_info, "perl_api_version", |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
231 strlen("perl_api_version"), 0); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
232 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
233 perl_api_ver = SvIV(*key); |
5205 | 234 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
235 if (perl_api_ver != 2) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
236 status = FALSE; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
237 else |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
238 { |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
239 GaimPluginInfo *info; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
240 GaimPerlScript *gps; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
241 int len; |
5205 | 242 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
243 gaim_debug(GAIM_DEBUG_INFO, "perl", "Found plugin info\n"); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
244 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
245 info = g_new0(GaimPluginInfo, 1); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
246 gps = g_new0(GaimPerlScript, 1); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
247 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
248 info->api_version = 2; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
249 info->type = GAIM_PLUGIN_STANDARD; |
5205 | 250 |
251 info->dependencies = g_list_append(info->dependencies, | |
252 PERL_PLUGIN_ID); | |
253 | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
254 gps->plugin = plugin; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
255 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
256 /* We know this one exists. */ |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
257 key = hv_fetch(plugin_info, "name", strlen("name"), 0); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
258 info->name = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
259 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
260 if ((key = hv_fetch(plugin_info, "url", strlen("url"), 0))) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
261 info->homepage = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
262 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
263 if ((key = hv_fetch(plugin_info, "author", strlen("author"), 0))) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
264 info->author = g_strdup(SvPV(*key, len)); |
5205 | 265 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
266 if ((key = hv_fetch(plugin_info, "summary", |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
267 strlen("summary"), 0))) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
268 info->summary = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
269 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
270 if ((key = hv_fetch(plugin_info, "description", |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
271 strlen("description"), 0))) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
272 info->description = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
273 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
274 if ((key = hv_fetch(plugin_info, "version", strlen("version"), 0))) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
275 info->version = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
276 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
277 if ((key = hv_fetch(plugin_info, "load", strlen("load"), 0))) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
278 gps->load_sub = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
279 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
280 if ((key = hv_fetch(plugin_info, "unload", strlen("unload"), 0))) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
281 gps->unload_sub = g_strdup(SvPV(*key, len)); |
5205 | 282 |
283 plugin->info = info; | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
284 info->extra_info = gps; |
5205 | 285 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
286 status = gaim_plugin_register(plugin); |
5205 | 287 } |
288 } | |
289 | |
290 perl_destruct(prober); | |
291 perl_free(prober); | |
292 | |
293 return status; | |
294 } | |
295 | |
296 static gboolean | |
297 load_perl_plugin(GaimPlugin *plugin) | |
298 { | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
299 GaimPerlScript *gps = (GaimPerlScript *)plugin->info->extra_info; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
300 char *atmp[2] = { plugin->path, NULL }; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
301 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
302 if (gps == NULL || gps->load_sub == NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
303 return FALSE; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
304 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
305 gaim_debug(GAIM_DEBUG_INFO, "perl", "Loading perl script\n"); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
306 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
307 if (my_perl == NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
308 perl_init(); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
309 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
310 plugin->handle = plugin->path; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
311 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
312 execute_perl("load_n_eval", 1, atmp); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
313 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
314 dSP; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
315 ENTER; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
316 SAVETMPS; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
317 PUSHMARK(SP); |
6525
66689e2cb966
[gaim-migrate @ 7042]
Christian Hammond <chipx86@chipx86.com>
parents:
6524
diff
changeset
|
318 XPUSHs(gaim_perl_ref_object(plugin)); |
66689e2cb966
[gaim-migrate @ 7042]
Christian Hammond <chipx86@chipx86.com>
parents:
6524
diff
changeset
|
319 PUTBACK; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
320 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
321 perl_call_pv(gps->load_sub, G_NOARGS | G_EVAL | G_SCALAR); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
322 SPAGAIN; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
323 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
324 if (SvTRUE(ERRSV)) { |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
325 int len; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
326 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
327 gaim_debug(GAIM_DEBUG_ERROR, "perl", |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
328 "Perl function %s exited abnormally: %s\n", |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
329 gps->load_sub, SvPV(ERRSV, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
330 } |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
331 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
332 PUTBACK; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
333 FREETMPS; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
334 LEAVE; |
5205 | 335 |
336 return TRUE; | |
337 } | |
338 | |
339 static gboolean | |
340 unload_perl_plugin(GaimPlugin *plugin) | |
341 { | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
342 GaimPerlScript *gps = (GaimPerlScript *)plugin->info->extra_info; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
343 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
344 if (gps == NULL || gps->unload_sub == NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
345 return FALSE; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
346 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
347 gaim_debug(GAIM_DEBUG_INFO, "perl", "Unloading perl script\n"); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
348 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
349 dSP; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
350 ENTER; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
351 SAVETMPS; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
352 PUSHMARK(SP); |
6525
66689e2cb966
[gaim-migrate @ 7042]
Christian Hammond <chipx86@chipx86.com>
parents:
6524
diff
changeset
|
353 XPUSHs(gaim_perl_ref_object(plugin)); |
66689e2cb966
[gaim-migrate @ 7042]
Christian Hammond <chipx86@chipx86.com>
parents:
6524
diff
changeset
|
354 PUTBACK; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
355 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
356 perl_call_pv(gps->unload_sub, G_NOARGS | G_EVAL | G_SCALAR); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
357 SPAGAIN; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
358 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
359 if (SvTRUE(ERRSV)) { |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
360 int len; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
361 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
362 gaim_debug(GAIM_DEBUG_ERROR, "perl", |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
363 "Perl function %s exited abnormally: %s\n", |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
364 gps->load_sub, SvPV(ERRSV, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
365 } |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
366 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
367 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
368 PUTBACK; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
369 FREETMPS; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
370 LEAVE; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
371 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
372 gaim_signals_disconnect_by_handle(plugin); |
6522
0c5233faceb8
[gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
373 gaim_perl_timeout_clear_for_plugin(plugin); |
5205 | 374 |
375 return TRUE; | |
376 } | |
377 | |
378 static void | |
379 destroy_perl_plugin(GaimPlugin *plugin) | |
380 { | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
381 if (plugin->info != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
382 { |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
383 GaimPerlScript *gps; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
384 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
385 if (plugin->info->name != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
386 g_free(plugin->info->name); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
387 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
388 if (plugin->info->version != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
389 g_free(plugin->info->version); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
390 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
391 if (plugin->info->summary != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
392 g_free(plugin->info->summary); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
393 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
394 if (plugin->info->description != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
395 g_free(plugin->info->description); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
396 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
397 if (plugin->info->author != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
398 g_free(plugin->info->author); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
399 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
400 if (plugin->info->homepage != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
401 g_free(plugin->info->homepage); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
402 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
403 gps = (GaimPerlScript *)plugin->info->extra_info; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
404 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
405 if (gps != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
406 { |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
407 if (gps->load_sub != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
408 g_free(gps->load_sub); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
409 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
410 if (gps->unload_sub != NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
411 g_free(gps->unload_sub); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
412 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
413 g_free(gps); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
414 plugin->info->extra_info = NULL; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
415 } |
5205 | 416 } |
417 } | |
418 | |
419 static gboolean | |
420 plugin_unload(GaimPlugin *plugin) | |
421 { | |
422 perl_end(); | |
423 | |
424 return TRUE; | |
425 } | |
426 | |
427 static GaimPluginLoaderInfo loader_info = | |
428 { | |
429 NULL, /**< exts */ | |
430 | |
431 probe_perl_plugin, /**< probe */ | |
432 load_perl_plugin, /**< load */ | |
433 unload_perl_plugin, /**< unload */ | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
434 destroy_perl_plugin /**< destroy */ |
5205 | 435 }; |
436 | |
437 static GaimPluginInfo info = | |
438 { | |
439 2, /**< api_version */ | |
440 GAIM_PLUGIN_LOADER, /**< type */ | |
441 NULL, /**< ui_requirement */ | |
442 0, /**< flags */ | |
443 NULL, /**< dependencies */ | |
444 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
445 | |
446 PERL_PLUGIN_ID, /**< id */ | |
447 N_("Perl Plugin Loader"), /**< name */ | |
448 VERSION, /**< version */ | |
449 N_("Provides support for loading perl plugins."), /**< summary */ | |
450 N_("Provides support for loading perl plugins."), /**< description */ | |
451 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6235
diff
changeset
|
452 GAIM_WEBSITE, /**< homepage */ |
5205 | 453 |
454 NULL, /**< load */ | |
455 plugin_unload, /**< unload */ | |
456 NULL, /**< destroy */ | |
457 | |
458 NULL, /**< ui_info */ | |
459 &loader_info /**< extra_info */ | |
460 }; | |
461 | |
462 static void | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
463 init_plugin(GaimPlugin *plugin) |
5205 | 464 { |
465 loader_info.exts = g_list_append(loader_info.exts, "pl"); | |
466 } | |
467 | |
6063 | 468 GAIM_INIT_PLUGIN(perl, init_plugin, info) |