Mercurial > pidgin.yaz
annotate plugins/perl/perl.c @ 12890:e0629444c455
[gaim-migrate @ 15243]
I was working on making plugin prefs more useful from perl and realized this
file was all out of order, so I fixed it. I managed to get plugin prefs
working but gaim was crashing if you quit while a plugin was loaded that used
them so they aren't getting committed, but this is since it's barely real.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Mon, 16 Jan 2006 09:30:11 +0000 |
parents | e1603fd610fa |
children | d1e6890ed062 |
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> | |
8138
3e8592b95f68
[gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents:
8095
diff
changeset
|
22 # ifdef HAVE_LIMITS_H |
3e8592b95f68
[gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents:
8095
diff
changeset
|
23 # include <limits.h> |
3e8592b95f68
[gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents:
8095
diff
changeset
|
24 # ifndef NAME_MAX |
3e8592b95f68
[gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents:
8095
diff
changeset
|
25 # define NAME_MAX _POSIX_NAME_MAX |
3e8592b95f68
[gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents:
8095
diff
changeset
|
26 # endif |
3e8592b95f68
[gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents:
8095
diff
changeset
|
27 # endif |
6235 | 28 #endif |
29 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
30 #ifdef DEBUG |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
31 # undef DEBUG |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
32 #endif |
5205 | 33 |
34 #undef PACKAGE | |
35 | |
36 #define group perl_group | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
37 |
5205 | 38 #ifdef _WIN32 |
39 /* This took me an age to figure out.. without this __declspec(dllimport) | |
40 * will be ignored. | |
41 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
42 # define HASATTRIBUTE |
5205 | 43 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
44 |
5205 | 45 #include <EXTERN.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
46 |
5205 | 47 #ifndef _SEM_SEMUN_UNDEFINED |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
48 # define HAS_UNION_SEMUN |
5205 | 49 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
50 |
5205 | 51 #include <perl.h> |
52 #include <XSUB.h> | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
53 |
5205 | 54 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
55 # include <sys/mman.h> |
5205 | 56 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
57 |
5205 | 58 #undef PACKAGE |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
59 |
5205 | 60 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
61 # include <dirent.h> |
5205 | 62 #else |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
63 /* We're using perl's win32 port of this */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
64 # define dirent direct |
5205 | 65 #endif |
66 | |
67 #undef group | |
68 | |
69 /* perl module support */ | |
70 #ifdef OLD_PERL | |
71 extern void boot_DynaLoader _((CV * cv)); | |
72 #else | |
73 extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */ | |
74 #endif | |
75 | |
76 #undef _ | |
77 #ifdef DEBUG | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
78 # undef DEBUG |
5205 | 79 #endif |
80 #ifdef _WIN32 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
81 # undef pipe |
5205 | 82 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
83 |
6575
87a0fb97d3b9
[gaim-migrate @ 7097]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6549
diff
changeset
|
84 #ifdef _WIN32 |
87a0fb97d3b9
[gaim-migrate @ 7097]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6549
diff
changeset
|
85 #define _WIN32DEP_H_ |
87a0fb97d3b9
[gaim-migrate @ 7097]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6549
diff
changeset
|
86 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
87 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
88 #include "debug.h" |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
89 #include "plugin.h" |
6531
7c42b8ca3222
[gaim-migrate @ 7048]
Christian Hammond <chipx86@chipx86.com>
parents:
6527
diff
changeset
|
90 #include "signals.h" |
9943 | 91 #include "version.h" |
5205 | 92 |
6526
e162c765fe21
[gaim-migrate @ 7043]
Christian Hammond <chipx86@chipx86.com>
parents:
6525
diff
changeset
|
93 #include "perl-common.h" |
6522
0c5233faceb8
[gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
94 #include "perl-handlers.h" |
0c5233faceb8
[gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
95 |
5205 | 96 #define PERL_PLUGIN_ID "core-perl" |
97 | |
12872
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
98 PerlInterpreter *my_perl = NULL; |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
99 |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
100 static GaimPluginUiInfo ui_info = |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
101 { |
12872
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
102 gaim_perl_get_plugin_frame, |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
103 0, /* page_num (Reserved) */ |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
104 NULL /* frame (Reserved) */ |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
105 }; |
5205 | 106 |
12872
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
107 static GaimGtkPluginUiInfo gtk_ui_info = |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
108 { |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
109 gaim_perl_gtk_get_plugin_frame, |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
110 0 /* page_num (Reserved) */ |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
111 }; |
5205 | 112 |
113 static void | |
114 #ifdef OLD_PERL | |
115 xs_init() | |
116 #else | |
117 xs_init(pTHX) | |
118 #endif | |
119 { | |
120 char *file = __FILE__; | |
121 | |
12873
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
122 /* This one allows dynamic loading of perl modules in perl scripts by |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
123 * the 'use perlmod;' construction */ |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
124 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); |
5205 | 125 } |
126 | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
127 static void |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
128 perl_init(void) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
129 { |
12873
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
130 /* changed the name of the variable from load_file to perl_definitions |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
131 * since now it does much more than defining the load_file sub. |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
132 * Moreover, deplaced the initialisation to the xs_init function. |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
133 * (TheHobbit) */ |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
134 char *perl_args[] = { "", "-e", "0", "-w" }; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
135 char perl_definitions[] = |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
136 { |
12873
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
137 /* We use to function one to load a file the other to execute |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
138 * the string obtained from the first and holding the file |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
139 * contents. This allows to have a really local $/ without |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
140 * introducing temp variables to hold the old value. Just a |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
141 * question of style:) */ |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
142 "package Gaim::PerlLoader;" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
143 "use Symbol;" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
144 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
145 "sub load_file {" |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
146 "my $f_name=shift;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
147 "local $/=undef;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
148 "open FH,$f_name or return \"__FAILED__\";" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
149 "$_=<FH>;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
150 "close FH;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
151 "return $_;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
152 "}" |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
153 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
154 "sub destroy_package {" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
155 "eval { $_[0]->UNLOAD() if $_[0]->can('UNLOAD'); };" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
156 "Symbol::delete_package($_[0]);" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
157 "}" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
158 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
159 "sub load_n_eval {" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
160 "my ($f_name, $package) = @_;" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
161 "destroy_package($package);" |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
162 "my $strin=load_file($f_name);" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
163 "return 2 if($strin eq \"__FAILED__\");" |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
164 "my $eval = qq{package $package; $strin;};" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
165 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
166 "{" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
167 " eval $eval;" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
168 "}" |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
169 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
170 "if($@) {" |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
171 /*" #something went wrong\n"*/ |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
172 "die(\"Errors loading file $f_name: $@\");" |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
173 "}" |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
174 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
175 "return 0;" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
176 "}" |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
177 }; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
178 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
179 my_perl = perl_alloc(); |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
180 PERL_SET_CONTEXT(my_perl); |
11290 | 181 PL_perl_destruct_level = 1; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
182 perl_construct(my_perl); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
183 #ifdef DEBUG |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
184 perl_parse(my_perl, xs_init, 4, perl_args, NULL); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
185 #else |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
186 perl_parse(my_perl, xs_init, 3, perl_args, NULL); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
187 #endif |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
188 #ifdef HAVE_PERL_EVAL_PV |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
189 eval_pv(perl_definitions, TRUE); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
190 #else |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
191 perl_eval_pv(perl_definitions, TRUE); /* deprecated */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
192 #endif |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
193 perl_run(my_perl); |
5205 | 194 } |
195 | |
196 static void | |
197 perl_end(void) | |
198 { | |
6520
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
199 if (my_perl == NULL) |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
200 return; |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
201 |
11290 | 202 PL_perl_destruct_level = 1; |
12873
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
203 PERL_SET_CONTEXT(my_perl); |
6520
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
204 perl_eval_pv( |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
205 "foreach my $lib (@DynaLoader::dl_modules) {" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
206 "if ($lib =~ /^Gaim\\b/) {" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
207 "$lib .= '::deinit();';" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
208 "eval $lib;" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
209 "}" |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
210 "}", |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
211 TRUE); |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
212 |
11290 | 213 PL_perl_destruct_level = 1; |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
214 PERL_SET_CONTEXT(my_perl); |
6520
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
215 perl_destruct(my_perl); |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
216 perl_free(my_perl); |
2e2593d95121
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
217 my_perl = NULL; |
5205 | 218 } |
219 | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
220 void |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
221 gaim_perl_callXS(void (*subaddr)(pTHX_ CV *cv), CV *cv, SV **mark) |
5205 | 222 { |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
223 dSP; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
224 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
225 PUSHMARK(mark); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
226 (*subaddr)(aTHX_ cv); |
5205 | 227 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
228 PUTBACK; |
5205 | 229 } |
230 | |
231 static gboolean | |
232 probe_perl_plugin(GaimPlugin *plugin) | |
233 { | |
234 /* XXX This would be much faster if I didn't create a new | |
235 * PerlInterpreter every time I probed a plugin */ | |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
236 |
5205 | 237 PerlInterpreter *prober = perl_alloc(); |
238 char *argv[] = {"", plugin->path }; | |
239 gboolean status = TRUE; | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
240 HV *plugin_info; |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
241 PERL_SET_CONTEXT(prober); |
11290 | 242 PL_perl_destruct_level = 1; |
5205 | 243 perl_construct(prober); |
11290 | 244 |
5922 | 245 perl_parse(prober, xs_init, 2, argv, NULL); |
11290 | 246 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
247 perl_run(prober); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
248 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
249 plugin_info = perl_get_hv("PLUGIN_INFO", FALSE); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
250 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
251 if (plugin_info == NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
252 status = FALSE; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
253 else if (!hv_exists(plugin_info, "perl_api_version", |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
254 strlen("perl_api_version")) || |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
255 !hv_exists(plugin_info, "name", strlen("name")) || |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
256 !hv_exists(plugin_info, "load", strlen("load"))) { |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
257 /* Not a valid plugin. */ |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
258 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
259 status = FALSE; |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
260 } else { |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
261 SV **key; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
262 int perl_api_ver; |
5205 | 263 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
264 key = hv_fetch(plugin_info, "perl_api_version", |
12873
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
265 strlen("perl_api_version"), 0); |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
266 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
267 perl_api_ver = SvIV(*key); |
5205 | 268 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
269 if (perl_api_ver != 2) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
270 status = FALSE; |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
271 else { |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
272 GaimPluginInfo *info; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
273 GaimPerlScript *gps; |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
274 char *basename; |
6678
eb95f31fa4eb
[gaim-migrate @ 7203]
Christian Hammond <chipx86@chipx86.com>
parents:
6636
diff
changeset
|
275 STRLEN len; |
5205 | 276 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
277 gaim_debug(GAIM_DEBUG_INFO, "perl", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
278 "Found plugin info\n"); |
6508
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 info = g_new0(GaimPluginInfo, 1); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
281 gps = g_new0(GaimPerlScript, 1); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
282 |
9943 | 283 info->magic = GAIM_PLUGIN_MAGIC; |
284 info->major_version = GAIM_MAJOR_VERSION; | |
285 info->minor_version = GAIM_MINOR_VERSION; | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
286 info->type = GAIM_PLUGIN_STANDARD; |
5205 | 287 |
288 info->dependencies = g_list_append(info->dependencies, | |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
289 PERL_PLUGIN_ID); |
5205 | 290 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
291 gps->plugin = plugin; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
292 |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
293 basename = g_path_get_basename(plugin->path); |
11170 | 294 gaim_perl_normalize_script_name(basename); |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
295 gps->package = g_strdup_printf("Gaim::Script::%s", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
296 basename); |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
297 g_free(basename); |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
298 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
299 /* We know this one exists. */ |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
300 key = hv_fetch(plugin_info, "name", strlen("name"), 0); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
301 info->name = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
302 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
303 if ((key = hv_fetch(plugin_info, "GTK_UI", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
304 strlen("GTK_UI"), 0))) |
11170 | 305 info->ui_requirement = GAIM_GTK_PLUGIN_TYPE; |
306 | |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
307 if ((key = hv_fetch(plugin_info, "url", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
308 strlen("url"), 0))) |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
309 info->homepage = g_strdup(SvPV(*key, len)); |
12873
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
310 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
311 if ((key = hv_fetch(plugin_info, "author", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
312 strlen("author"), 0))) |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
313 info->author = g_strdup(SvPV(*key, len)); |
5205 | 314 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
315 if ((key = hv_fetch(plugin_info, "summary", |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
316 strlen("summary"), 0))) |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
317 info->summary = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
318 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
319 if ((key = hv_fetch(plugin_info, "description", |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
320 strlen("description"), 0))) |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
321 info->description = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
322 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
323 if ((key = hv_fetch(plugin_info, "version", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
324 strlen("version"), 0))) |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
325 info->version = g_strdup(SvPV(*key, len)); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
326 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
327 if ((key = hv_fetch(plugin_info, "load", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
328 strlen("load"), 0))) |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
329 gps->load_sub = g_strdup_printf("%s::%s", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
330 gps->package, |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
331 SvPV(*key, len)); |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
332 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
333 if ((key = hv_fetch(plugin_info, "unload", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
334 strlen("unload"), 0))) |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
335 gps->unload_sub = g_strdup_printf("%s::%s", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
336 gps->package, |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
337 SvPV(*key, len)); |
5205 | 338 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
339 /********************************************************/ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
340 /* Only one of the next two options should be present */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
341 /* */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
342 /* prefs_info - Uses non-GUI (read GTK) gaim API calls */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
343 /* and creates a GaimPluginPrefInfo type. */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
344 /* */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
345 /* gtk_prefs_info - Requires gtk2-perl be installed by */ |
12873
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
346 /* the user and he must create a */ |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
347 /* GtkWidget the user and he must */ |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
348 /* create a GtkWidget representing the */ |
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
349 /* plugin preferences page. */ |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
350 /********************************************************/ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
351 if ((key = hv_fetch(plugin_info, "prefs_info", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
352 strlen("prefs_info"), 0))) { |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
353 /* key now is the name of the Perl sub that |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
354 * will create a frame for us */ |
12872
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
355 gps->prefs_sub = g_strdup_printf("%s::%s", |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
356 gps->package, |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
357 SvPV(*key, len)); |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
358 info->prefs_info = &ui_info; |
11123 | 359 } |
12890
e0629444c455
[gaim-migrate @ 15243]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12882
diff
changeset
|
360 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
361 if ((key = hv_fetch(plugin_info, "gtk_prefs_info", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
362 strlen("gtk_prefs_info"), 0))) { |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
363 /* key now is the name of the Perl sub that |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
364 * will create a frame for us */ |
12872
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
365 gps->gtk_prefs_sub = g_strdup_printf("%s::%s", |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
366 gps->package, |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
367 SvPV(*key, len)); |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
368 info->ui_info = >k_ui_info; |
11170 | 369 } |
370 | |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
371 /********************************************************/ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
372 /* */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
373 /* plugin_action - This is given to the plugin info */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
374 /* as the action GList. There are two */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
375 /* parts so the user can set the title */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
376 /* as it will appear in the plugin */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
377 /* action menu. The name is extracted */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
378 /* and then the callback perl sub's */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
379 /* name both of which then are handled */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
380 /* by an internal gaim_perl function */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
381 /* that sets up the single cb function */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
382 /* which is then inserted into 'info'. */ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
383 /********************************************************/ |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
384 if ((key = hv_fetch(plugin_info, "plugin_action_label", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
385 strlen("plugin_action_label"), 0))) { |
11170 | 386 gaim_perl_plugin_action_label = g_strdup(SvPV(*key, len)); |
387 } | |
388 | |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
389 if ((key = hv_fetch(plugin_info, "plugin_action", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
390 strlen("plugin_action"), 0))) { |
11170 | 391 gaim_perl_plugin_action_callback_sub = g_strdup_printf("%s::%s", gps->package, SvPV(*key, len)); |
392 info->actions = gaim_perl_plugin_action; | |
393 } | |
11123 | 394 |
5205 | 395 plugin->info = info; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
396 info->extra_info = gps; |
5205 | 397 |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
398 status = gaim_plugin_register(plugin); |
5205 | 399 } |
400 } | |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
401 |
11290 | 402 PL_perl_destruct_level = 1; |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
403 PERL_SET_CONTEXT(prober); |
5205 | 404 perl_destruct(prober); |
405 perl_free(prober); | |
406 return status; | |
407 } | |
408 | |
409 static gboolean | |
410 load_perl_plugin(GaimPlugin *plugin) | |
411 { | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
412 GaimPerlScript *gps = (GaimPerlScript *)plugin->info->extra_info; |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
413 char *atmp[3] = { plugin->path, NULL, NULL }; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
414 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
415 if (gps == NULL || gps->load_sub == NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
416 return FALSE; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
417 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
418 gaim_debug(GAIM_DEBUG_INFO, "perl", "Loading perl script\n"); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
419 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
420 if (my_perl == NULL) |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
421 perl_init(); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
422 |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
423 plugin->handle = gps; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
424 |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
425 atmp[1] = gps->package; |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
426 |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
427 PERL_SET_CONTEXT(my_perl); |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
428 execute_perl("Gaim::PerlLoader::load_n_eval", 2, atmp); |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
429 |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
430 { |
11318 | 431 dSP; |
11290 | 432 PERL_SET_CONTEXT(my_perl); |
11318 | 433 SPAGAIN; |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
434 ENTER; |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
435 SAVETMPS; |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
436 PUSHMARK(sp); |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
437 XPUSHs(sv_2mortal(gaim_perl_bless_object(plugin, |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
438 "Gaim::Plugin"))); |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
439 PUTBACK; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
440 |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
441 perl_call_pv(gps->load_sub, G_EVAL | G_SCALAR); |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
442 SPAGAIN; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
443 |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
444 if (SvTRUE(ERRSV)) { |
6678
eb95f31fa4eb
[gaim-migrate @ 7203]
Christian Hammond <chipx86@chipx86.com>
parents:
6636
diff
changeset
|
445 STRLEN len; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
446 |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
447 gaim_debug(GAIM_DEBUG_ERROR, "perl", |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
448 "Perl function %s exited abnormally: %s\n", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
449 gps->load_sub, SvPV(ERRSV, len)); |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
450 } |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
451 |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
452 PUTBACK; |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
453 FREETMPS; |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
454 LEAVE; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
455 } |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
456 |
5205 | 457 return TRUE; |
458 } | |
459 | |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
460 static void |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
461 destroy_package(const char *package) |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
462 { |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
463 dSP; |
11318 | 464 PERL_SET_CONTEXT(my_perl); |
465 SPAGAIN; | |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
466 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
467 ENTER; |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
468 SAVETMPS; |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
469 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
470 PUSHMARK(SP); |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
471 XPUSHs(sv_2mortal(newSVpv(package, strlen(package)))); |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
472 PUTBACK; |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
473 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
474 perl_call_pv("Gaim::PerlLoader::destroy_package", |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
475 G_VOID | G_EVAL | G_DISCARD); |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
476 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
477 SPAGAIN; |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
478 |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
479 PUTBACK; |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
480 FREETMPS; |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
481 LEAVE; |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
482 } |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
483 |
5205 | 484 static gboolean |
485 unload_perl_plugin(GaimPlugin *plugin) | |
486 { | |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
487 GaimPerlScript *gps = (GaimPerlScript *)plugin->info->extra_info; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
488 |
9578
7cd7da72c872
[gaim-migrate @ 10421]
Christian Hammond <chipx86@chipx86.com>
parents:
8993
diff
changeset
|
489 if (gps == NULL) |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
490 return FALSE; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
491 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
492 gaim_debug(GAIM_DEBUG_INFO, "perl", "Unloading perl script\n"); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
493 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
494 if (gps->unload_sub != NULL) { |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
495 dSP; |
11318 | 496 PERL_SET_CONTEXT(my_perl); |
497 SPAGAIN; | |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
498 ENTER; |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
499 SAVETMPS; |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
500 PUSHMARK(sp); |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
501 XPUSHs(sv_2mortal(gaim_perl_bless_object(plugin, |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
502 "Gaim::Plugin"))); |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
503 PUTBACK; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
504 |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
505 perl_call_pv(gps->unload_sub, G_EVAL | G_SCALAR); |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
506 SPAGAIN; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
507 |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
508 if (SvTRUE(ERRSV)) { |
6678
eb95f31fa4eb
[gaim-migrate @ 7203]
Christian Hammond <chipx86@chipx86.com>
parents:
6636
diff
changeset
|
509 STRLEN len; |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
510 |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
511 gaim_debug(GAIM_DEBUG_ERROR, "perl", |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
512 "Perl function %s exited abnormally: %s\n", |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
513 gps->load_sub, SvPV(ERRSV, len)); |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
514 } |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
515 |
6536
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
516 PUTBACK; |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
517 FREETMPS; |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
518 LEAVE; |
9767117bc47e
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
519 } |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
520 |
12882
e1603fd610fa
[gaim-migrate @ 15234]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12873
diff
changeset
|
521 gaim_perl_cmd_clear_for_plugin(plugin); |
6549
ed796f756237
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6536
diff
changeset
|
522 gaim_perl_signal_clear_for_plugin(plugin); |
6522
0c5233faceb8
[gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
523 gaim_perl_timeout_clear_for_plugin(plugin); |
5205 | 524 |
6636
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
525 destroy_package(gps->package); |
452c62a92963
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
526 |
5205 | 527 return TRUE; |
528 } | |
529 | |
530 static void | |
531 destroy_perl_plugin(GaimPlugin *plugin) | |
532 { | |
12873
96d611ab3fcb
[gaim-migrate @ 15225]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12872
diff
changeset
|
533 if (plugin->info != NULL) { |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
534 GaimPerlScript *gps; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
535 |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
536 g_free(plugin->info->name); |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
537 g_free(plugin->info->version); |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
538 g_free(plugin->info->summary); |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
539 g_free(plugin->info->description); |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
540 g_free(plugin->info->author); |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
541 g_free(plugin->info->homepage); |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
542 |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
543 gps = (GaimPerlScript *)plugin->info->extra_info; |
12871
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
544 if (gps != NULL) { |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
545 g_free(gps->load_sub); |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
546 g_free(gps->unload_sub); |
2422097a7a5e
[gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11842
diff
changeset
|
547 g_free(gps->package); |
12872
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
548 g_free(gps->prefs_sub); |
59ff3e1c874e
[gaim-migrate @ 15224]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12871
diff
changeset
|
549 g_free(gps->gtk_prefs_sub); |
6508
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
550 g_free(gps); |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
551 plugin->info->extra_info = NULL; |
cbd24b37350d
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
552 } |
5205 | 553 } |
554 } | |
555 | |
556 static gboolean | |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
9943
diff
changeset
|
557 plugin_load(GaimPlugin *plugin) |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
9943
diff
changeset
|
558 { |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
9943
diff
changeset
|
559 return TRUE; |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
9943
diff
changeset
|
560 } |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
9943
diff
changeset
|
561 |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
9943
diff
changeset
|
562 static gboolean |
5205 | 563 plugin_unload(GaimPlugin *plugin) |
564 { | |
565 perl_end(); | |
566 | |
567 return TRUE; | |
568 } | |
569 | |
570 static GaimPluginLoaderInfo loader_info = | |
571 { | |
572 NULL, /**< exts */ | |
573 probe_perl_plugin, /**< probe */ | |
574 load_perl_plugin, /**< load */ | |
575 unload_perl_plugin, /**< unload */ | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
576 destroy_perl_plugin /**< destroy */ |
5205 | 577 }; |
578 | |
579 static GaimPluginInfo info = | |
580 { | |
9943 | 581 GAIM_PLUGIN_MAGIC, |
582 GAIM_MAJOR_VERSION, | |
583 GAIM_MINOR_VERSION, | |
5205 | 584 GAIM_PLUGIN_LOADER, /**< type */ |
585 NULL, /**< ui_requirement */ | |
586 0, /**< flags */ | |
587 NULL, /**< dependencies */ | |
588 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
589 | |
590 PERL_PLUGIN_ID, /**< id */ | |
591 N_("Perl Plugin Loader"), /**< name */ | |
592 VERSION, /**< version */ | |
593 N_("Provides support for loading perl plugins."), /**< summary */ | |
594 N_("Provides support for loading perl plugins."), /**< description */ | |
595 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6235
diff
changeset
|
596 GAIM_WEBSITE, /**< homepage */ |
5205 | 597 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
9943
diff
changeset
|
598 plugin_load, /**< load */ |
5205 | 599 plugin_unload, /**< unload */ |
600 NULL, /**< destroy */ | |
601 | |
602 NULL, /**< ui_info */ | |
8993 | 603 &loader_info, /**< extra_info */ |
604 NULL, | |
605 NULL | |
5205 | 606 }; |
607 | |
608 static void | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
609 init_plugin(GaimPlugin *plugin) |
5205 | 610 { |
611 loader_info.exts = g_list_append(loader_info.exts, "pl"); | |
612 } | |
613 | |
6063 | 614 GAIM_INIT_PLUGIN(perl, init_plugin, info) |