Wed, 30 Jul 2008 03:51:26 +0000
Add support to the Perl plugin loader for listing for pref changes.
The Prefs Functions Test plugin (plugin_pref.pl) includes an example.
Fixes #6383
| 5205 | 1 | /* |
| 15884 | 2 | * purple |
| 5205 | 3 | * |
|
6508
57d1df1ca3a0
[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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16786
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 5205 | 19 | */ |
|
6235
8293e7d4c050
[gaim-migrate @ 6728]
Mark Doliner <markdoliner@pidgin.im>
parents:
6100
diff
changeset
|
20 | #ifdef HAVE_CONFIG_H |
|
8293e7d4c050
[gaim-migrate @ 6728]
Mark Doliner <markdoliner@pidgin.im>
parents:
6100
diff
changeset
|
21 | #include <config.h> |
| 8138 | 22 | # ifdef HAVE_LIMITS_H |
| 23 | # include <limits.h> | |
| 24 | # ifndef NAME_MAX | |
| 25 | # define NAME_MAX _POSIX_NAME_MAX | |
| 26 | # endif | |
| 27 | # endif | |
|
6235
8293e7d4c050
[gaim-migrate @ 6728]
Mark Doliner <markdoliner@pidgin.im>
parents:
6100
diff
changeset
|
28 | #endif |
|
8293e7d4c050
[gaim-migrate @ 6728]
Mark Doliner <markdoliner@pidgin.im>
parents:
6100
diff
changeset
|
29 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
30 | #ifdef DEBUG |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
31 | # undef DEBUG |
|
754c63f29b77
[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
754c63f29b77
[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
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
42 | # define HASATTRIBUTE |
| 5205 | 43 | #endif |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
44 | |
| 5205 | 45 | #include <EXTERN.h> |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
46 | |
| 5205 | 47 | #ifndef _SEM_SEMUN_UNDEFINED |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
48 | # define HAS_UNION_SEMUN |
| 5205 | 49 | #endif |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
50 | |
| 5205 | 51 | #include <perl.h> |
| 52 | #include <XSUB.h> | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
53 | |
| 5205 | 54 | #ifndef _WIN32 |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
55 | # include <sys/mman.h> |
| 5205 | 56 | #endif |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
57 | |
| 5205 | 58 | #undef PACKAGE |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
59 | |
| 5205 | 60 | #ifndef _WIN32 |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
61 | # include <dirent.h> |
| 5205 | 62 | #else |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
63 | /* We're using perl's win32 port of this */ |
|
754c63f29b77
[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 */ | |
|
23915
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
70 | #ifdef _WIN32 |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
71 | EXTERN_C void boot_Win32CORE (pTHX_ CV* cv); |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
72 | #endif |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
73 | |
| 5205 | 74 | #ifdef OLD_PERL |
| 75 | extern void boot_DynaLoader _((CV * cv)); | |
| 76 | #else | |
| 77 | extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */ | |
| 78 | #endif | |
| 79 | ||
| 80 | #undef _ | |
| 81 | #ifdef DEBUG | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
82 | # undef DEBUG |
| 5205 | 83 | #endif |
| 84 | #ifdef _WIN32 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
85 | # undef pipe |
| 5205 | 86 | #endif |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
87 | |
|
6575
fdb1928afdf9
[gaim-migrate @ 7097]
Herman Bloggs <herman@bluedigits.com>
parents:
6549
diff
changeset
|
88 | #ifdef _WIN32 |
|
fdb1928afdf9
[gaim-migrate @ 7097]
Herman Bloggs <herman@bluedigits.com>
parents:
6549
diff
changeset
|
89 | #define _WIN32DEP_H_ |
|
fdb1928afdf9
[gaim-migrate @ 7097]
Herman Bloggs <herman@bluedigits.com>
parents:
6549
diff
changeset
|
90 | #endif |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
91 | #include "internal.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
92 | #include "debug.h" |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
93 | #include "plugin.h" |
|
6531
3fca41d7b411
[gaim-migrate @ 7048]
Christian Hammond <chipx86@chipx86.com>
parents:
6527
diff
changeset
|
94 | #include "signals.h" |
| 9943 | 95 | #include "version.h" |
| 5205 | 96 | |
|
6526
c6c3f10519ab
[gaim-migrate @ 7043]
Christian Hammond <chipx86@chipx86.com>
parents:
6525
diff
changeset
|
97 | #include "perl-common.h" |
|
6522
e7d94240fc71
[gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
98 | #include "perl-handlers.h" |
|
e7d94240fc71
[gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
99 | |
|
16529
1d0da9270ff9
This is mostly moving Purple::GtkUI:: -> Pidgin:: which has the side effect of
Etan Reisner <deryni@pidgin.im>
parents:
16528
diff
changeset
|
100 | #include <gmodule.h> |
|
1d0da9270ff9
This is mostly moving Purple::GtkUI:: -> Pidgin:: which has the side effect of
Etan Reisner <deryni@pidgin.im>
parents:
16528
diff
changeset
|
101 | |
| 5205 | 102 | #define PERL_PLUGIN_ID "core-perl" |
| 103 | ||
| 12872 | 104 | PerlInterpreter *my_perl = NULL; |
| 105 | ||
| 15884 | 106 | static PurplePluginUiInfo ui_info = |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
107 | { |
| 15884 | 108 | purple_perl_get_plugin_frame, |
| 12872 | 109 | 0, /* page_num (Reserved) */ |
|
16786
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16750
diff
changeset
|
110 | NULL, /* frame (Reserved) */ |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16750
diff
changeset
|
111 | /* Padding */ |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16750
diff
changeset
|
112 | NULL, |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16750
diff
changeset
|
113 | NULL, |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16750
diff
changeset
|
114 | NULL, |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16750
diff
changeset
|
115 | NULL |
| 12872 | 116 | }; |
| 5205 | 117 | |
| 15884 | 118 | #ifdef PURPLE_GTKPERL |
| 119 | static PurpleGtkPluginUiInfo gtk_ui_info = | |
| 12872 | 120 | { |
| 15884 | 121 | purple_perl_gtk_get_plugin_frame, |
| 12872 | 122 | 0 /* page_num (Reserved) */ |
| 123 | }; | |
|
14426
8d4f164c4979
[gaim-migrate @ 17070]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
124 | #endif |
| 5205 | 125 | |
| 126 | static void | |
| 127 | #ifdef OLD_PERL | |
| 128 | xs_init() | |
| 129 | #else | |
| 130 | xs_init(pTHX) | |
| 131 | #endif | |
| 132 | { | |
| 133 | char *file = __FILE__; | |
|
23915
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
134 | dXSUB_SYS; |
| 5205 | 135 | |
| 12873 | 136 | /* This one allows dynamic loading of perl modules in perl scripts by |
| 137 | * the 'use perlmod;' construction */ | |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
138 | newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); |
|
23915
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
139 | #ifdef _WIN32 |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
140 | newXS("Win32CORE::bootstrap", boot_Win32CORE, file); |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
141 | #endif |
| 5205 | 142 | } |
| 143 | ||
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
144 | static void |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
145 | perl_init(void) |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
146 | { |
| 12873 | 147 | /* changed the name of the variable from load_file to perl_definitions |
| 148 | * since now it does much more than defining the load_file sub. | |
| 149 | * Moreover, deplaced the initialisation to the xs_init function. | |
| 150 | * (TheHobbit) */ | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
151 | char *perl_args[] = { "", "-e", "0", "-w" }; |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
152 | char perl_definitions[] = |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
153 | { |
| 12873 | 154 | /* We use to function one to load a file the other to execute |
| 155 | * the string obtained from the first and holding the file | |
| 156 | * contents. This allows to have a really local $/ without | |
| 157 | * introducing temp variables to hold the old value. Just a | |
| 158 | * question of style:) */ | |
| 15884 | 159 | "package Purple::PerlLoader;" |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
160 | "use Symbol;" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
161 | |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
162 | "sub load_file {" |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
163 | "my $f_name=shift;" |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
164 | "local $/=undef;" |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
165 | "open FH,$f_name or return \"__FAILED__\";" |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
166 | "$_=<FH>;" |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
167 | "close FH;" |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
168 | "return $_;" |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
169 | "}" |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
170 | |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
171 | "sub destroy_package {" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
172 | "eval { $_[0]->UNLOAD() if $_[0]->can('UNLOAD'); };" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
173 | "Symbol::delete_package($_[0]);" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
174 | "}" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
175 | |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
176 | "sub load_n_eval {" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
177 | "my ($f_name, $package) = @_;" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
178 | "destroy_package($package);" |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
179 | "my $strin=load_file($f_name);" |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
180 | "return 2 if($strin eq \"__FAILED__\");" |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
181 | "my $eval = qq{package $package; $strin;};" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
182 | |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
183 | "{" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
184 | " eval $eval;" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
185 | "}" |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
186 | |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
187 | "if($@) {" |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
188 | /*" #something went wrong\n"*/ |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
189 | "die(\"Errors loading file $f_name: $@\");" |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
190 | "}" |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
191 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
192 | "return 0;" |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
193 | "}" |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
194 | }; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
195 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
196 | my_perl = perl_alloc(); |
| 12871 | 197 | PERL_SET_CONTEXT(my_perl); |
| 11290 | 198 | PL_perl_destruct_level = 1; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
199 | perl_construct(my_perl); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
200 | #ifdef DEBUG |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
201 | perl_parse(my_perl, xs_init, 4, perl_args, NULL); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
202 | #else |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
203 | perl_parse(my_perl, xs_init, 3, perl_args, NULL); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
204 | #endif |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
205 | #ifdef HAVE_PERL_EVAL_PV |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
206 | eval_pv(perl_definitions, TRUE); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
207 | #else |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
208 | perl_eval_pv(perl_definitions, TRUE); /* deprecated */ |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
209 | #endif |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
210 | perl_run(my_perl); |
| 5205 | 211 | } |
| 212 | ||
| 213 | static void | |
| 214 | perl_end(void) | |
| 215 | { | |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
216 | if (my_perl == NULL) |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
217 | return; |
| 12871 | 218 | |
| 11290 | 219 | PL_perl_destruct_level = 1; |
| 12873 | 220 | PERL_SET_CONTEXT(my_perl); |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
221 | perl_eval_pv( |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
222 | "foreach my $lib (@DynaLoader::dl_modules) {" |
| 15884 | 223 | "if ($lib =~ /^Purple\\b/) {" |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
224 | "$lib .= '::deinit();';" |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
225 | "eval $lib;" |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
226 | "}" |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
227 | "}", |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
228 | TRUE); |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
229 | |
| 11290 | 230 | PL_perl_destruct_level = 1; |
| 12871 | 231 | PERL_SET_CONTEXT(my_perl); |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
232 | perl_destruct(my_perl); |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
233 | perl_free(my_perl); |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
234 | my_perl = NULL; |
| 5205 | 235 | } |
| 236 | ||
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
237 | void |
| 15884 | 238 | purple_perl_callXS(void (*subaddr)(pTHX_ CV *cv), CV *cv, SV **mark) |
| 5205 | 239 | { |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
240 | dSP; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
241 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
242 | PUSHMARK(mark); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
243 | (*subaddr)(aTHX_ cv); |
| 5205 | 244 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
245 | PUTBACK; |
| 5205 | 246 | } |
| 247 | ||
| 248 | static gboolean | |
| 15884 | 249 | probe_perl_plugin(PurplePlugin *plugin) |
| 5205 | 250 | { |
| 12871 | 251 | |
|
23915
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
252 | char *args[] = {"", plugin->path }; |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
253 | char **argv = args; |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
254 | int argc = 2; |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
255 | PerlInterpreter *prober; |
| 5205 | 256 | gboolean status = TRUE; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
257 | HV *plugin_info; |
|
23915
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
258 | |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
259 | PERL_SYS_INIT(&argc, &argv); |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
260 | |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
261 | /* XXX This would be much faster if we didn't create a new |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
262 | * PerlInterpreter every time we probe a plugin */ |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
263 | prober = perl_alloc(); |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
264 | |
| 12871 | 265 | PERL_SET_CONTEXT(prober); |
|
23915
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
266 | |
| 11290 | 267 | PL_perl_destruct_level = 1; |
| 5205 | 268 | perl_construct(prober); |
| 11290 | 269 | |
|
23917
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
270 | /* Fix IO redirection to match where pidgin's is going. |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
271 | * Without this, we lose stdout/stderr unless we redirect to a file */ |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
272 | #ifdef _WIN32 |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
273 | { |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
274 | PerlIO* newprlIO = PerlIO_open("CONOUT$", "w"); |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
275 | if (newprlIO) { |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
276 | int stdout_fd = PerlIO_fileno(PerlIO_stdout()); |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
277 | int stderr_fd = PerlIO_fileno(PerlIO_stderr()); |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
278 | PerlIO_close(PerlIO_stdout()); |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
279 | PerlIO_close(PerlIO_stderr()); |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
280 | PerlLIO_dup2(PerlIO_fileno(newprlIO), stdout_fd); |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
281 | PerlLIO_dup2(PerlIO_fileno(newprlIO), stderr_fd); |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
282 | |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
283 | PerlIO_close(newprlIO); |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
284 | } |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
285 | } |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
286 | #endif |
|
8555374207d8
Fix output redirection for perl plugins on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
287 | |
|
23915
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
288 | perl_parse(prober, xs_init, argc, argv, NULL); |
| 11290 | 289 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
290 | perl_run(prober); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
291 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
292 | plugin_info = perl_get_hv("PLUGIN_INFO", FALSE); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
293 | |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
294 | if (plugin_info == NULL) |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
295 | status = FALSE; |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
296 | else if (!hv_exists(plugin_info, "perl_api_version", |
| 12871 | 297 | strlen("perl_api_version")) || |
| 298 | !hv_exists(plugin_info, "name", strlen("name")) || | |
| 299 | !hv_exists(plugin_info, "load", strlen("load"))) { | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
300 | /* Not a valid plugin. */ |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
301 | |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
302 | status = FALSE; |
| 12871 | 303 | } else { |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
304 | SV **key; |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
305 | int perl_api_ver; |
| 5205 | 306 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
307 | key = hv_fetch(plugin_info, "perl_api_version", |
| 12873 | 308 | strlen("perl_api_version"), 0); |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
309 | |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
310 | perl_api_ver = SvIV(*key); |
| 5205 | 311 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
312 | if (perl_api_ver != 2) |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
313 | status = FALSE; |
| 12871 | 314 | else { |
| 15884 | 315 | PurplePluginInfo *info; |
| 316 | PurplePerlScript *gps; | |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
317 | char *basename; |
|
6678
c633179afd00
[gaim-migrate @ 7203]
Christian Hammond <chipx86@chipx86.com>
parents:
6636
diff
changeset
|
318 | STRLEN len; |
| 5205 | 319 | |
| 15884 | 320 | info = g_new0(PurplePluginInfo, 1); |
| 321 | gps = g_new0(PurplePerlScript, 1); | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
322 | |
| 15884 | 323 | info->magic = PURPLE_PLUGIN_MAGIC; |
| 324 | info->major_version = PURPLE_MAJOR_VERSION; | |
| 325 | info->minor_version = PURPLE_MINOR_VERSION; | |
| 326 | info->type = PURPLE_PLUGIN_STANDARD; | |
| 5205 | 327 | |
| 328 | info->dependencies = g_list_append(info->dependencies, | |
| 12871 | 329 | PERL_PLUGIN_ID); |
| 5205 | 330 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
331 | gps->plugin = plugin; |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
332 | |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
333 | basename = g_path_get_basename(plugin->path); |
| 15884 | 334 | purple_perl_normalize_script_name(basename); |
| 335 | gps->package = g_strdup_printf("Purple::Script::%s", | |
| 12871 | 336 | basename); |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
337 | g_free(basename); |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
338 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
339 | /* We know this one exists. */ |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
340 | key = hv_fetch(plugin_info, "name", strlen("name"), 0); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
341 | info->name = g_strdup(SvPV(*key, len)); |
| 12984 | 342 | /* Set id here in case we don't find one later. */ |
| 343 | info->id = g_strdup(SvPV(*key, len)); | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
344 | |
| 15884 | 345 | #ifdef PURPLE_GTKPERL |
| 12871 | 346 | if ((key = hv_fetch(plugin_info, "GTK_UI", |
| 347 | strlen("GTK_UI"), 0))) | |
| 15884 | 348 | info->ui_requirement = PURPLE_GTK_PLUGIN_TYPE; |
| 14434 | 349 | #endif |
| 11170 | 350 | |
| 12871 | 351 | if ((key = hv_fetch(plugin_info, "url", |
| 352 | strlen("url"), 0))) | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
353 | info->homepage = g_strdup(SvPV(*key, len)); |
| 12873 | 354 | |
| 12871 | 355 | if ((key = hv_fetch(plugin_info, "author", |
| 356 | strlen("author"), 0))) | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
357 | info->author = g_strdup(SvPV(*key, len)); |
| 5205 | 358 | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
359 | if ((key = hv_fetch(plugin_info, "summary", |
| 12871 | 360 | strlen("summary"), 0))) |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
361 | info->summary = g_strdup(SvPV(*key, len)); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
362 | |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
363 | if ((key = hv_fetch(plugin_info, "description", |
| 12871 | 364 | strlen("description"), 0))) |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
365 | info->description = g_strdup(SvPV(*key, len)); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
366 | |
| 12871 | 367 | if ((key = hv_fetch(plugin_info, "version", |
| 368 | strlen("version"), 0))) | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
369 | info->version = g_strdup(SvPV(*key, len)); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
370 | |
| 12984 | 371 | /* We know this one exists. */ |
| 372 | key = hv_fetch(plugin_info, "load", strlen("load"), 0); | |
| 373 | gps->load_sub = g_strdup_printf("%s::%s", gps->package, | |
| 374 | SvPV(*key, len)); | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
375 | |
| 12871 | 376 | if ((key = hv_fetch(plugin_info, "unload", |
| 377 | strlen("unload"), 0))) | |
| 378 | gps->unload_sub = g_strdup_printf("%s::%s", | |
| 379 | gps->package, | |
| 380 | SvPV(*key, len)); | |
| 5205 | 381 | |
| 12984 | 382 | if ((key = hv_fetch(plugin_info, "id", |
| 383 | strlen("id"), 0))) { | |
| 384 | g_free(info->id); | |
| 385 | info->id = g_strdup_printf("perl-%s", | |
| 386 | SvPV(*key, len)); | |
| 387 | } | |
| 388 | ||
| 12871 | 389 | /********************************************************/ |
| 390 | /* Only one of the next two options should be present */ | |
| 391 | /* */ | |
| 15884 | 392 | /* prefs_info - Uses non-GUI (read GTK) purple API calls */ |
| 393 | /* and creates a PurplePluginPrefInfo type. */ | |
| 12871 | 394 | /* */ |
| 395 | /* gtk_prefs_info - Requires gtk2-perl be installed by */ | |
| 12873 | 396 | /* the user and he must create a */ |
| 397 | /* GtkWidget the user and he must */ | |
| 398 | /* create a GtkWidget representing the */ | |
| 399 | /* plugin preferences page. */ | |
| 12871 | 400 | /********************************************************/ |
| 401 | if ((key = hv_fetch(plugin_info, "prefs_info", | |
| 402 | strlen("prefs_info"), 0))) { | |
| 403 | /* key now is the name of the Perl sub that | |
| 404 | * will create a frame for us */ | |
| 12872 | 405 | gps->prefs_sub = g_strdup_printf("%s::%s", |
| 406 | gps->package, | |
| 407 | SvPV(*key, len)); | |
| 408 | info->prefs_info = &ui_info; | |
| 11123 | 409 | } |
| 12890 | 410 | |
| 15884 | 411 | #ifdef PURPLE_GTKPERL |
| 12871 | 412 | if ((key = hv_fetch(plugin_info, "gtk_prefs_info", |
| 413 | strlen("gtk_prefs_info"), 0))) { | |
| 414 | /* key now is the name of the Perl sub that | |
| 415 | * will create a frame for us */ | |
| 12872 | 416 | gps->gtk_prefs_sub = g_strdup_printf("%s::%s", |
| 417 | gps->package, | |
| 418 | SvPV(*key, len)); | |
| 419 | info->ui_info = >k_ui_info; | |
| 11170 | 420 | } |
|
14426
8d4f164c4979
[gaim-migrate @ 17070]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
421 | #endif |
| 11170 | 422 | |
| 12988 | 423 | if ((key = hv_fetch(plugin_info, "plugin_action_sub", |
| 424 | strlen("plugin_action_sub"), 0))) { | |
| 425 | gps->plugin_action_sub = g_strdup_printf("%s::%s", | |
| 426 | gps->package, | |
| 427 | SvPV(*key, len)); | |
| 15884 | 428 | info->actions = purple_perl_plugin_actions; |
| 11170 | 429 | } |
| 11123 | 430 | |
| 5205 | 431 | plugin->info = info; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
432 | info->extra_info = gps; |
| 5205 | 433 | |
| 15884 | 434 | status = purple_plugin_register(plugin); |
| 5205 | 435 | } |
| 436 | } | |
| 12871 | 437 | |
| 11290 | 438 | PL_perl_destruct_level = 1; |
| 12871 | 439 | PERL_SET_CONTEXT(prober); |
| 5205 | 440 | perl_destruct(prober); |
| 441 | perl_free(prober); | |
| 442 | return status; | |
| 443 | } | |
| 444 | ||
| 445 | static gboolean | |
| 15884 | 446 | load_perl_plugin(PurplePlugin *plugin) |
| 5205 | 447 | { |
| 15884 | 448 | PurplePerlScript *gps = (PurplePerlScript *)plugin->info->extra_info; |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
449 | char *atmp[3] = { plugin->path, NULL, NULL }; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
450 | |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
451 | if (gps == NULL || gps->load_sub == NULL) |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
452 | return FALSE; |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
453 | |
| 15884 | 454 | purple_debug(PURPLE_DEBUG_INFO, "perl", "Loading perl script\n"); |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
455 | |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
456 | if (my_perl == NULL) |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
457 | perl_init(); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
458 | |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
459 | plugin->handle = gps; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
460 | |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
461 | atmp[1] = gps->package; |
| 12871 | 462 | |
| 463 | PERL_SET_CONTEXT(my_perl); | |
| 15884 | 464 | execute_perl("Purple::PerlLoader::load_n_eval", 2, atmp); |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
465 | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
466 | { |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11290
diff
changeset
|
467 | dSP; |
| 11290 | 468 | PERL_SET_CONTEXT(my_perl); |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11290
diff
changeset
|
469 | SPAGAIN; |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
470 | ENTER; |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
471 | SAVETMPS; |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
472 | PUSHMARK(sp); |
| 15884 | 473 | XPUSHs(sv_2mortal(purple_perl_bless_object(plugin, |
| 474 | "Purple::Plugin"))); | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
475 | PUTBACK; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
476 | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
477 | perl_call_pv(gps->load_sub, G_EVAL | G_SCALAR); |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
478 | SPAGAIN; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
479 | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
480 | if (SvTRUE(ERRSV)) { |
|
6678
c633179afd00
[gaim-migrate @ 7203]
Christian Hammond <chipx86@chipx86.com>
parents:
6636
diff
changeset
|
481 | STRLEN len; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
482 | |
| 15884 | 483 | purple_debug(PURPLE_DEBUG_ERROR, "perl", |
| 12871 | 484 | "Perl function %s exited abnormally: %s\n", |
| 485 | gps->load_sub, SvPV(ERRSV, len)); | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
486 | } |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
487 | |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
488 | PUTBACK; |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
489 | FREETMPS; |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
490 | LEAVE; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
491 | } |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
492 | |
| 5205 | 493 | return TRUE; |
| 494 | } | |
| 495 | ||
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
496 | static void |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
497 | destroy_package(const char *package) |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
498 | { |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
499 | dSP; |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11290
diff
changeset
|
500 | PERL_SET_CONTEXT(my_perl); |
|
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11290
diff
changeset
|
501 | SPAGAIN; |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
502 | |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
503 | ENTER; |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
504 | SAVETMPS; |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
505 | |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
506 | PUSHMARK(SP); |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
507 | XPUSHs(sv_2mortal(newSVpv(package, strlen(package)))); |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
508 | PUTBACK; |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
509 | |
| 15884 | 510 | perl_call_pv("Purple::PerlLoader::destroy_package", |
| 12871 | 511 | G_VOID | G_EVAL | G_DISCARD); |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
512 | |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
513 | SPAGAIN; |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
514 | |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
515 | PUTBACK; |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
516 | FREETMPS; |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
517 | LEAVE; |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
518 | } |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
519 | |
| 5205 | 520 | static gboolean |
| 15884 | 521 | unload_perl_plugin(PurplePlugin *plugin) |
| 5205 | 522 | { |
| 15884 | 523 | PurplePerlScript *gps = (PurplePerlScript *)plugin->info->extra_info; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
524 | |
|
9578
d02c3d247fb7
[gaim-migrate @ 10421]
Christian Hammond <chipx86@chipx86.com>
parents:
8993
diff
changeset
|
525 | if (gps == NULL) |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
526 | return FALSE; |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
527 | |
| 15884 | 528 | purple_debug(PURPLE_DEBUG_INFO, "perl", "Unloading perl script\n"); |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
529 | |
| 12871 | 530 | if (gps->unload_sub != NULL) { |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
531 | dSP; |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11290
diff
changeset
|
532 | PERL_SET_CONTEXT(my_perl); |
|
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11290
diff
changeset
|
533 | SPAGAIN; |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
534 | ENTER; |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
535 | SAVETMPS; |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
536 | PUSHMARK(sp); |
| 15884 | 537 | XPUSHs(sv_2mortal(purple_perl_bless_object(plugin, |
| 538 | "Purple::Plugin"))); | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
539 | PUTBACK; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
540 | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
541 | perl_call_pv(gps->unload_sub, G_EVAL | G_SCALAR); |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
542 | SPAGAIN; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
543 | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
544 | if (SvTRUE(ERRSV)) { |
|
6678
c633179afd00
[gaim-migrate @ 7203]
Christian Hammond <chipx86@chipx86.com>
parents:
6636
diff
changeset
|
545 | STRLEN len; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
546 | |
| 15884 | 547 | purple_debug(PURPLE_DEBUG_ERROR, "perl", |
| 12871 | 548 | "Perl function %s exited abnormally: %s\n", |
| 549 | gps->load_sub, SvPV(ERRSV, len)); | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
550 | } |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
551 | |
|
6536
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
552 | PUTBACK; |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
553 | FREETMPS; |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
554 | LEAVE; |
|
b91ae5d45371
[gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
555 | } |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
556 | |
| 15884 | 557 | purple_perl_cmd_clear_for_plugin(plugin); |
| 558 | purple_perl_signal_clear_for_plugin(plugin); | |
| 559 | purple_perl_timeout_clear_for_plugin(plugin); | |
|
23930
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
23917
diff
changeset
|
560 | purple_perl_pref_cb_clear_for_plugin(plugin); |
| 5205 | 561 | |
|
6636
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
562 | destroy_package(gps->package); |
|
e906c663da5c
[gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents:
6575
diff
changeset
|
563 | |
| 5205 | 564 | return TRUE; |
| 565 | } | |
| 566 | ||
| 567 | static void | |
| 15884 | 568 | destroy_perl_plugin(PurplePlugin *plugin) |
| 5205 | 569 | { |
| 12873 | 570 | if (plugin->info != NULL) { |
| 15884 | 571 | PurplePerlScript *gps; |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
572 | |
| 12871 | 573 | g_free(plugin->info->name); |
| 574 | g_free(plugin->info->version); | |
| 575 | g_free(plugin->info->summary); | |
| 576 | g_free(plugin->info->description); | |
| 577 | g_free(plugin->info->author); | |
| 578 | g_free(plugin->info->homepage); | |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
579 | |
| 15884 | 580 | gps = (PurplePerlScript *)plugin->info->extra_info; |
| 12871 | 581 | if (gps != NULL) { |
| 582 | g_free(gps->load_sub); | |
| 583 | g_free(gps->unload_sub); | |
| 584 | g_free(gps->package); | |
| 12872 | 585 | g_free(gps->prefs_sub); |
| 15884 | 586 | #ifdef PURPLE_GTKPERL |
| 12872 | 587 | g_free(gps->gtk_prefs_sub); |
|
14426
8d4f164c4979
[gaim-migrate @ 17070]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
588 | #endif |
|
6508
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
589 | g_free(gps); |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
590 | plugin->info->extra_info = NULL; |
|
57d1df1ca3a0
[gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
591 | } |
| 5205 | 592 | } |
| 593 | } | |
| 594 | ||
| 595 | static gboolean | |
| 15884 | 596 | plugin_load(PurplePlugin *plugin) |
| 11033 | 597 | { |
| 598 | return TRUE; | |
| 599 | } | |
| 600 | ||
| 601 | static gboolean | |
| 15884 | 602 | plugin_unload(PurplePlugin *plugin) |
| 5205 | 603 | { |
| 604 | perl_end(); | |
| 605 | ||
| 606 | return TRUE; | |
| 607 | } | |
| 608 | ||
| 15884 | 609 | static PurplePluginLoaderInfo loader_info = |
| 5205 | 610 | { |
| 611 | NULL, /**< exts */ | |
| 612 | probe_perl_plugin, /**< probe */ | |
| 613 | load_perl_plugin, /**< load */ | |
| 614 | unload_perl_plugin, /**< unload */ | |
|
16750
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
615 | destroy_perl_plugin, /**< destroy */ |
|
23915
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
616 | |
|
16750
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
617 | /* padding */ |
|
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
618 | NULL, |
|
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
619 | NULL, |
|
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
620 | NULL, |
|
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
621 | NULL |
| 5205 | 622 | }; |
| 623 | ||
| 15884 | 624 | static PurplePluginInfo info = |
| 5205 | 625 | { |
| 15884 | 626 | PURPLE_PLUGIN_MAGIC, |
| 627 | PURPLE_MAJOR_VERSION, | |
| 628 | PURPLE_MINOR_VERSION, | |
|
16529
1d0da9270ff9
This is mostly moving Purple::GtkUI:: -> Pidgin:: which has the side effect of
Etan Reisner <deryni@pidgin.im>
parents:
16528
diff
changeset
|
629 | PURPLE_PLUGIN_LOADER, /**< type */ |
| 5205 | 630 | NULL, /**< ui_requirement */ |
| 631 | 0, /**< flags */ | |
| 632 | NULL, /**< dependencies */ | |
|
16529
1d0da9270ff9
This is mostly moving Purple::GtkUI:: -> Pidgin:: which has the side effect of
Etan Reisner <deryni@pidgin.im>
parents:
16528
diff
changeset
|
633 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 5205 | 634 | |
| 635 | PERL_PLUGIN_ID, /**< id */ | |
| 636 | N_("Perl Plugin Loader"), /**< name */ | |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
637 | DISPLAY_VERSION, /**< version */ |
| 5205 | 638 | N_("Provides support for loading perl plugins."), /**< summary */ |
| 639 | N_("Provides support for loading perl plugins."), /**< description */ | |
| 640 | "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
|
16529
1d0da9270ff9
This is mostly moving Purple::GtkUI:: -> Pidgin:: which has the side effect of
Etan Reisner <deryni@pidgin.im>
parents:
16528
diff
changeset
|
641 | PURPLE_WEBSITE, /**< homepage */ |
| 5205 | 642 | |
| 11033 | 643 | plugin_load, /**< load */ |
| 5205 | 644 | plugin_unload, /**< unload */ |
| 645 | NULL, /**< destroy */ | |
| 646 | ||
| 647 | NULL, /**< ui_info */ | |
| 8993 | 648 | &loader_info, /**< extra_info */ |
| 649 | NULL, | |
|
16750
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
650 | NULL, |
|
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
651 | |
|
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
652 | /* padding */ |
|
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
653 | NULL, |
|
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
654 | NULL, |
|
a568944eee52
Updating the loaders since I missed them since I'm not building any of them right now
Gary Kramlich <grim@reaperworld.com>
parents:
16529
diff
changeset
|
655 | NULL, |
| 8993 | 656 | NULL |
| 5205 | 657 | }; |
| 658 | ||
| 659 | static void | |
| 15884 | 660 | init_plugin(PurplePlugin *plugin) |
| 5205 | 661 | { |
| 662 | loader_info.exts = g_list_append(loader_info.exts, "pl"); | |
| 663 | } | |
| 664 | ||
|
16528
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
665 | #ifdef __SUNPRO_C |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
666 | #pragma init (my_init) |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
667 | #else |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
668 | void __attribute__ ((constructor)) my_init(void); |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
669 | #endif |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
670 | |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
671 | void |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
672 | my_init(void) |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
673 | { |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
674 | /* Mostly evil hack... puts perl.so's symbols in the global table but |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
675 | * does not create a circular dependency because g_module_open will |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
676 | * only open the library once. */ |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
677 | /* Do we need to keep track of the returned GModule here so that we |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
678 | * can g_module_close it when this plugin gets unloaded? |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
679 | * At the moment I don't think this plugin can ever get unloaded but |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
680 | * in case that becomes possible this wants to get noted. */ |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
681 | g_module_open("perl.so", 0); |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
682 | } |
|
6cd4a90e0970
Kill the libpurpleperl hack library and move the init stuff to perl.so itself.
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
683 | |
| 15884 | 684 | PURPLE_INIT_PLUGIN(perl, init_plugin, info) |