annotate plugins/perl/perl-handlers.c @ 12813:547c199072c8

[gaim-migrate @ 15161] - fixes to sametime administrative notification message dialog to make them a little less obscure as to what the heck they are - added an extra step to the sametime connection login between authenticating and starting services - fix to outgoing encoding of html formatted messages in sametime to use NCR encoding - addition of gaim_utf8_ncr_encode to util.h - fix of minor possible (unlikely) memleak in gaim_utf8_ncr_decode committer: Tailor Script <tailor@pidgin.im>
author Christopher O'Brien <siege@pidgin.im>
date Wed, 11 Jan 2006 03:07:01 +0000
parents 86d67bd4ef24
children 2422097a7a5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 #include "perl-common.h"
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 #include "perl-handlers.h"
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 #include "debug.h"
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
5 #include "signals.h"
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 static GList *timeout_handlers = NULL;
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
8 static GList *signal_handlers = NULL;
11123
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
9 static char *perl_plugin_pref_cb;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
10 static char *perl_gtk_plugin_pref_cb;
11123
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
11 extern PerlInterpreter *my_perl;
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12
12165
f8e22fef03fc [gaim-migrate @ 14466]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11170
diff changeset
13 /* perl < 5.8.0 doesn't define PERL_MAGIC_ext */
f8e22fef03fc [gaim-migrate @ 14466]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11170
diff changeset
14 #ifndef PERL_MAGIC_ext
f8e22fef03fc [gaim-migrate @ 14466]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11170
diff changeset
15 #define PERL_MAGIC_ext '~'
f8e22fef03fc [gaim-migrate @ 14466]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11170
diff changeset
16 #endif
f8e22fef03fc [gaim-migrate @ 14466]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11170
diff changeset
17
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
18 /* For now a plugin can only have one action */
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
19 void
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
20 gaim_perl_plugin_action_cb(GaimPluginAction * gpa)
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
21 {
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
22 dSP;
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
23 ENTER;
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
24 SAVETMPS;
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
25 PUSHMARK(sp);
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
26
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
27 /* We put the plugin handle on the stack so it can pass it along */
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
28 /* to anything called from the callback. It is supposed to pass */
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
29 /* the Action, but there is no way to access the plugin handle from */
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
30 /* the GaimPluginAction in perl...yet. */
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
31
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
32 XPUSHs(gaim_perl_bless_object(gpa->plugin, "Gaim::Plugin"));
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
33 PUTBACK;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
34
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
35 /* gaim_perl_plugin_action_callback_sub defined in the header is set
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
36 * in perl.c during plugin probe by a PLUGIN_INFO hash value limiting
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
37 * us to only one action for right now even though the action member
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
38 * of GaimPluginInfo can take (does take) a GList. */
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
39 call_pv(gaim_perl_plugin_action_callback_sub, G_EVAL | G_SCALAR);
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
40 SPAGAIN;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
41
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
42 PUTBACK;
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
43 FREETMPS;
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
44 LEAVE;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
45 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
46
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
47 GList *
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
48 gaim_perl_plugin_action(GaimPlugin *plugin, gpointer context)
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
49 {
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
50 GaimPluginAction *act = NULL;
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
51 GList *gl = NULL;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
52
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
53 /* TODO: Fix the way we create action handlers so we can have more
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
54 * than one action in perl. Maybe there is a clever work around, but
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
55 * so far I have not figured it out. There is no way to tie the perl
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
56 * sub's name to the callback function without these global variables
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
57 * and there is no way to create a callback on the fly so each would
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
58 * have to be hardcoded--more than one would just be arbitrary. */
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
59 act = gaim_plugin_action_new(gaim_perl_plugin_action_label,
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
60 gaim_perl_plugin_action_cb);
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
61 gl = g_list_append(gl, act);
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
62
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
63 return gl;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
64 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
65
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
66
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
67 GaimGtkPluginUiInfo *
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
68 gaim_perl_gtk_plugin_pref(const char * frame_cb)
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
69 {
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
70 GaimGtkPluginUiInfo *ui_info;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
71
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
72 ui_info = g_new0(GaimGtkPluginUiInfo, 1);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
73 perl_gtk_plugin_pref_cb = g_strdup(frame_cb);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
74 ui_info->get_config_frame = gaim_perl_gtk_get_plugin_frame;
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
75
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
76 return ui_info;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
77 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
78
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
79 GtkWidget *
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
80 gaim_perl_gtk_get_plugin_frame(GaimPlugin *plugin)
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
81 {
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
82 SV * sv;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
83 GtkWidget *ret;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
84 MAGIC *mg;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
85 dSP;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
86 int count;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
87
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
88 ENTER;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
89 SAVETMPS;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
90
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
91 count = call_pv(perl_gtk_plugin_pref_cb, G_SCALAR | G_NOARGS);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
92 if (count != 1)
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
93 croak("call_pv: Did not return the correct number of values.\n");
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
94
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
95 /* the frame was created in a perl sub and is returned */
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
96 SPAGAIN;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
97
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
98 /* We have a Gtk2::Frame on top of the stack */
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
99 sv = POPs;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
100
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
101 /* The magic field hides the pointer to the actuale GtkWidget */
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
102 mg = mg_find(SvRV(sv), PERL_MAGIC_ext);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
103 ret = (GtkWidget *)mg->mg_ptr;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
104
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
105 PUTBACK;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
106 FREETMPS;
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
107 LEAVE;
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
108
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
109 return ret;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
110 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
111
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
112 /* Called to create a pointer to GaimPluginUiInfo for the GaimPluginInfo */
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
113 /* It will then in turn create ui_info with the C function pointer */
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
114 /* that will eventually do a call_pv to call a perl functions so users */
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
115 /* can create their own frames in the prefs */
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
116 GaimPluginUiInfo *
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
117 gaim_perl_plugin_pref(const char * frame_cb)
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
118 {
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
119 GaimPluginUiInfo *ui_info;
11123
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
120
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
121 ui_info = g_new0(GaimPluginUiInfo, 1);
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
122 perl_plugin_pref_cb = g_strdup(frame_cb);
11123
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
123 ui_info->get_plugin_pref_frame = gaim_perl_get_plugin_frame;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
124
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
125 return ui_info;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
126 }
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
127
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
128 GaimPluginPrefFrame *
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
129 gaim_perl_get_plugin_frame(GaimPlugin *plugin)
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
130 {
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
131 /* Sets up the Perl Stack for our call back into the script to run the
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
132 * plugin_pref... sub */
11123
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
133 GaimPluginPrefFrame *ret_frame;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
134 dSP;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
135 int count;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
136
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
137 ENTER;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
138 SAVETMPS;
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
139 /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
140 * return the frame */
11123
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
141 PUSHMARK(SP);
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
142 PUTBACK;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
143
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
144 count = call_pv(perl_plugin_pref_cb, G_SCALAR | G_NOARGS);
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
145
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
146 SPAGAIN;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
147
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
148 if (count != 1)
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
149 croak("call_pv: Did not return the correct number of values.\n");
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
150 /* the frame was created in a perl sub and is returned */
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
151 ret_frame = (GaimPluginPrefFrame *)gaim_perl_ref_object(POPs);
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
152
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
153 /* Tidy up the Perl stack */
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
154 PUTBACK;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
155 FREETMPS;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
156 LEAVE;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 11123
diff changeset
157
11123
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
158 return ret_frame;
4315bb5f427b [gaim-migrate @ 13179]
John H. Kelm <johnkelm@gmail.com>
parents: 7386
diff changeset
159 }
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 static void
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 destroy_timeout_handler(GaimPerlTimeoutHandler *handler)
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 timeout_handlers = g_list_remove(timeout_handlers, handler);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165
6568
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
166 if (handler->callback != NULL)
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
167 SvREFCNT_dec(handler->callback);
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
168
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
169 if (handler->data != NULL)
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
170 SvREFCNT_dec(handler->data);
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
171
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 g_free(handler);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
175 static void
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
176 destroy_signal_handler(GaimPerlSignalHandler *handler)
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
177 {
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
178 signal_handlers = g_list_remove(signal_handlers, handler);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
179
6567
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
180 if (handler->callback != NULL)
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
181 SvREFCNT_dec(handler->callback);
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
182
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
183 if (handler->data != NULL)
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
184 SvREFCNT_dec(handler->data);
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
185
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
186 g_free(handler->signal);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
187 g_free(handler);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
188 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
189
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 static int
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 perl_timeout_cb(gpointer data)
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 GaimPerlTimeoutHandler *handler = (GaimPerlTimeoutHandler *)data;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 dSP;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 ENTER;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 SAVETMPS;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 PUSHMARK(sp);
6568
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
199 XPUSHs((SV *)handler->data);
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 PUTBACK;
6568
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
201 call_sv(handler->callback, G_EVAL | G_SCALAR);
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 SPAGAIN;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 PUTBACK;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 FREETMPS;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 LEAVE;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 destroy_timeout_handler(handler);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 return 0;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
213 typedef void *DATATYPE;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
214
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
215 static void *
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
216 perl_signal_cb(va_list args, void *data)
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
217 {
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
218 GaimPerlSignalHandler *handler = (GaimPerlSignalHandler *)data;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
219 void *ret_val = NULL;
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
220 int i;
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
221 int count;
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
222 int value_count;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
223 GaimValue *ret_value, **values;
6919
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
224 SV **sv_args;
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
225 DATATYPE **copy_args;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
226 STRLEN na;
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
227
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
228 dSP;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
229 ENTER;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
230 SAVETMPS;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
231 PUSHMARK(sp);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
232
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
233 gaim_signal_get_values(handler->instance, handler->signal,
12804
86d67bd4ef24 [gaim-migrate @ 15151]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12803
diff changeset
234 &ret_value, &value_count, &values);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
235
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
236 sv_args = g_new(SV *, value_count);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
237 copy_args = g_new(void **, value_count);
6919
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
238
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
239 for (i = 0; i < value_count; i++) {
12804
86d67bd4ef24 [gaim-migrate @ 15151]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12803
diff changeset
240 sv_args[i] = gaim_perl_sv_from_vargs(values[i],
86d67bd4ef24 [gaim-migrate @ 15151]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12803
diff changeset
241 (va_list*)&args,
86d67bd4ef24 [gaim-migrate @ 15151]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12803
diff changeset
242 &copy_args[i]);
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
243
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6919
diff changeset
244 XPUSHs(sv_args[i]);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
245 }
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6554
diff changeset
246
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
247 XPUSHs((SV *)handler->data);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
248
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
249 PUTBACK;
6567
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
250
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
251 if (ret_value != NULL) {
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
252 count = call_sv(handler->callback, G_EVAL | G_SCALAR);
6567
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
253
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
254 SPAGAIN;
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
255
6567
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
256 if (count != 1)
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
257 croak("Uh oh! call_sv returned %i != 1", i);
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
258 else
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6919
diff changeset
259 ret_val = gaim_perl_data_from_sv(ret_value, POPs);
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
260 } else {
6567
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
261 call_sv(handler->callback, G_SCALAR);
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
262
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
263 SPAGAIN;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
264 }
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
265
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
266 if (SvTRUE(ERRSV)) {
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
267 gaim_debug_error("perl",
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
268 "Perl function exited abnormally: %s\n",
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
269 SvPV(ERRSV, na));
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
270 }
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
271
6919
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
272 /* See if any parameters changed. */
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
273 for (i = 0; i < value_count; i++) {
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
274 if (gaim_value_is_outgoing(values[i])) {
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
275 switch (gaim_value_get_type(values[i])) {
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
276 case GAIM_TYPE_BOOLEAN:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
277 *((gboolean *)copy_args[i]) = SvIV(sv_args[i]);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
278 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
279
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
280 case GAIM_TYPE_INT:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
281 *((int *)copy_args[i]) = SvIV(sv_args[i]);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
282 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
283
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
284 case GAIM_TYPE_UINT:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
285 *((unsigned int *)copy_args[i]) = SvUV(sv_args[i]);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
286 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
287
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
288 case GAIM_TYPE_LONG:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
289 *((long *)copy_args[i]) = SvIV(sv_args[i]);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
290 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
291
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
292 case GAIM_TYPE_ULONG:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
293 *((unsigned long *)copy_args[i]) = SvUV(sv_args[i]);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
294 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
295
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
296 case GAIM_TYPE_INT64:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
297 *((gint64 *)copy_args[i]) = SvIV(sv_args[i]);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
298 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
299
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
300 case GAIM_TYPE_UINT64:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
301 *((guint64 *)copy_args[i]) = SvUV(sv_args[i]);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
302 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
303
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
304 case GAIM_TYPE_STRING:
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
305 if (strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) {
6925
3ec6aac0ff67 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
306 g_free(*((char **)copy_args[i]));
3ec6aac0ff67 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
307 *((char **)copy_args[i]) =
3ec6aac0ff67 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
308 g_strdup(SvPV(sv_args[i], na));
3ec6aac0ff67 [gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents: 6924
diff changeset
309 }
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
310 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
311
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
312 case GAIM_TYPE_POINTER:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
313 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
314 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
315
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
316 case GAIM_TYPE_BOXED:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
317 *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]);
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
318 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
319
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
320 default:
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
321 break;
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
322 }
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
323
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
324 #if 0
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6919
diff changeset
325 *((void **)copy_args[i]) = gaim_perl_data_from_sv(values[i],
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6919
diff changeset
326 sv_args[i]);
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
327 #endif
6919
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
328 }
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
329 }
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
330
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
331 PUTBACK;
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
332 FREETMPS;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
333 LEAVE;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
334
6919
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
335 g_free(sv_args);
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6919
diff changeset
336 g_free(copy_args);
6919
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
337
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
338 gaim_debug_misc("perl", "ret_val = %p\n", ret_val);
1aa771990188 [gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents: 6568
diff changeset
339
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
340 return ret_val;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
341 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
342
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
343 static GaimPerlSignalHandler *
6567
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
344 find_signal_handler(GaimPlugin *plugin, void *instance, const char *signal)
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
345 {
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
346 GaimPerlSignalHandler *handler;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
347 GList *l;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
348
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
349 for (l = signal_handlers; l != NULL; l = l->next) {
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
350 handler = (GaimPerlSignalHandler *)l->data;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
351
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
352 if (handler->plugin == plugin &&
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
353 handler->instance == instance &&
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
354 !strcmp(handler->signal, signal)) {
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
355 return handler;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
356 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
357 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
358
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
359 return NULL;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
360 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
361
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 void
6568
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
363 gaim_perl_timeout_add(GaimPlugin *plugin, int seconds, SV *callback, SV *data)
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 GaimPerlTimeoutHandler *handler;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
367 if (plugin == NULL) {
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
368 croak("Invalid handle in adding perl timeout handler.\n");
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 return;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 handler = g_new0(GaimPerlTimeoutHandler, 1);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373
6568
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
374 handler->plugin = plugin;
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
375 handler->callback = (callback != NULL && callback != &PL_sv_undef
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
376 ? newSVsv(callback) : NULL);
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
377 handler->data = (data != NULL && data != &PL_sv_undef
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
378 ? newSVsv(data) : NULL);
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380 timeout_handlers = g_list_append(timeout_handlers, handler);
6568
33486b749aa9 [gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents: 6567
diff changeset
381
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 handler->iotag = g_timeout_add(seconds * 1000, perl_timeout_cb, handler);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 void
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 gaim_perl_timeout_clear_for_plugin(GaimPlugin *plugin)
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387 {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 GaimPerlTimeoutHandler *handler;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 GList *l, *l_next;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
391 for (l = timeout_handlers; l != NULL; l = l_next) {
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392 l_next = l->next;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 handler = (GaimPerlTimeoutHandler *)l->data;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 if (handler->plugin == plugin)
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 destroy_timeout_handler(handler);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 void
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 gaim_perl_timeout_clear(void)
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 {
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
404 while (timeout_handlers != NULL)
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 destroy_timeout_handler(timeout_handlers->data);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
408 void
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
409 gaim_perl_signal_connect(GaimPlugin *plugin, void *instance,
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
410 const char *signal, SV *callback, SV *data)
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
411 {
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
412 GaimPerlSignalHandler *handler;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
413
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
414 handler = g_new0(GaimPerlSignalHandler, 1);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
415 handler->plugin = plugin;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
416 handler->instance = instance;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
417 handler->signal = g_strdup(signal);
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
418 handler->callback = (callback != NULL &&
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
419 callback != &PL_sv_undef ? newSVsv(callback)
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
420 : NULL);
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
421 handler->data = (data != NULL &&
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
422 data != &PL_sv_undef ? newSVsv(data) : NULL);
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
423
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
424 signal_handlers = g_list_append(signal_handlers, handler);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
425
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
426 gaim_signal_connect_vargs(instance, signal, plugin,
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
427 GAIM_CALLBACK(perl_signal_cb), handler);
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
428 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
429
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
430 void
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
431 gaim_perl_signal_disconnect(GaimPlugin *plugin, void *instance,
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
432 const char *signal)
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
433 {
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
434 GaimPerlSignalHandler *handler;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
435
6567
6e25e1e08ffb [gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents: 6566
diff changeset
436 handler = find_signal_handler(plugin, instance, signal);
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
437
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
438 if (handler == NULL) {
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
439 croak("Invalid signal handler information in "
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
440 "disconnecting a perl signal handler.\n");
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
441 return;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
442 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
443
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
444 destroy_signal_handler(handler);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
445 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
446
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
447 void
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
448 gaim_perl_signal_clear_for_plugin(GaimPlugin *plugin)
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
449 {
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
450 GaimPerlSignalHandler *handler;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
451 GList *l, *l_next;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
452
12803
050b29b7232a [gaim-migrate @ 15150]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12165
diff changeset
453 for (l = signal_handlers; l != NULL; l = l_next) {
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
454 l_next = l->next;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
455
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
456 handler = (GaimPerlSignalHandler *)l->data;
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
457
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
458 if (handler->plugin == plugin)
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
459 destroy_signal_handler(handler);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
460 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
461 }
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
462
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
463 void
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
464 gaim_perl_signal_clear(void)
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
465 {
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
466 while (signal_handlers != NULL)
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
467 destroy_signal_handler(signal_handlers->data);
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
468 }