Fri, 23 Dec 2005 19:26:04 +0000
[gaim-migrate @ 14983]
SF Patch #1314512 from Sadrul (who has a patch for everything)
"This patch introduces a flag for protocol plugins that
support offline messages (like Y!M and ICQ). This was
encouraged by the following conversation:
<sadrul> should offline buddies be listed/enabled in
the send-to menu?
<rekkanoryo> i would think only for protocols that
support offline messaging, if it's indicated that the
buddy is offline
-- <snip> --
<Bleeter> sadrul: personally, I'd like to see a
'supports offline' flag of some description
<Bleeter> one could then redirect (via plugins) through
email or alternative methods
<Bleeter> just a thought
<Paco-Paco> yeah, that sounds like a reasonble thing to have
This patch uses this flag to disable the buddies in the
send-to menu who are offline and the protocol doesn't
support offline messages."
I made this make the label insensitive instead of the whole menuitem. This
should address SimGuy's concerns about inconsistency (i.e. you could create a
conversation with someone via the buddy list that you couldn't create via the
Send To menu). I also hacked up some voodoo to show the label as sensitive when
moused-over, as that looks better (given the label-insensitive thing is itself a
hack). I think this works quite well.
BUG NOTE:
This makes more obvious an existing bug. The Send To menu isn't updated when
buddies sign on or off or change status (at least under some circumstances).
We need to fix that anyway, so I'm not going to let it hold up this commit.
Switching tabs will clear it up. I'm thinking we just might want to build the
contents of that menu when it is selected. That would save us a mess of
inefficient signal callbacks that update the Send To menus in open windows all
the time.
AIM NOTE:
This assumes that AIM can't offline message. That's not strictly true. You can
message invisible users on AIM. However, by design, we can't tell when a user
is invisible without resorting to dirty hackery. In practice, this isn't a
problem, as you can still select the AIM user from the menu. And really, how
often will you be choosing the Invisible contact, rather than the user going
Invisible in the middle of a conversation or IMing you while they're Invisible?
JABBER NOTE:
This assumes that Jabber can always offline message. This isn't strictly true.
Sadrul said:
I have updated Jabber according to this link which seems to
talk about how to determine the existence offline-message
support in a server:
http://www.jabber.org/jeps/jep-0013.html#discover
However, jabber.org doesn't seem to send the required
info. So I am not sure about it.
He later said:
I talked to Nathan and he said offline message support is
mostly assumed for most jabber servers. GTalk doesn't yet
support it, but they are working on it. So I have made
jabber to always return TRUE.
If there is truly no way to detect offline messaging capability, then this is
an acceptable solution. We could special case Google Talk because of its
popularity, and remove that later. It's probably not worth it though.
MSN NOTE:
This assumes that MSN can never offline message. That's effectively true, but
to be technically correct, MSN can offline message if there's already a
switchboard conversation open with a user. We could write an offline_message
function in the MSN prpl to detect that, but it'd be of limited usefulness,
especially given that under most circumstances (where this might matter), the
switchboard connection will be closed almost immediately.
CVS NOTE:
I'm writing to share a tragic little story.
I have a PC that I use for Gaim development. One day, I was writing a commit
message on it, when all of a suddent it went berserk. The screen started
flashing, and the whole commit message just disappeared. All of it. And it was
a good commit message! I had to cram and rewrite it really quickly. Needless to
say, my rushed commit message wasn't nearly as good, and I blame the PC for that.
Seriously, though, what kind of version control system loses your commit
message on a broken connection to the server? Stupid!
committer: Richard Laager <rlaager@pidgin.im>
| 6520 | 1 | #include "perl-common.h" |
| 2 | #include "perl-handlers.h" | |
| 3 | ||
| 4 | #include "debug.h" | |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
5 | #include "signals.h" |
| 6520 | 6 | |
| 11170 | 7 | |
| 6520 | 8 | static GList *timeout_handlers = NULL; |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
9 | static GList *signal_handlers = NULL; |
| 11123 | 10 | static char *perl_plugin_pref_cb; |
| 11170 | 11 | static char *perl_gtk_plugin_pref_cb; |
| 11123 | 12 | extern PerlInterpreter *my_perl; |
| 6520 | 13 | |
|
12165
9f2d7e6b8707
[gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11170
diff
changeset
|
14 | /* perl < 5.8.0 doesn't define PERL_MAGIC_ext */ |
|
9f2d7e6b8707
[gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11170
diff
changeset
|
15 | #ifndef PERL_MAGIC_ext |
|
9f2d7e6b8707
[gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11170
diff
changeset
|
16 | #define PERL_MAGIC_ext '~' |
|
9f2d7e6b8707
[gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11170
diff
changeset
|
17 | #endif |
|
9f2d7e6b8707
[gaim-migrate @ 14466]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11170
diff
changeset
|
18 | |
| 11170 | 19 | /* For now a plugin can only have one action */ |
| 20 | void gaim_perl_plugin_action_cb(GaimPluginAction * gpa) { | |
| 21 | ||
| 22 | dSP; | |
| 23 | ENTER; | |
| 24 | SAVETMPS; | |
| 25 | PUSHMARK(sp); | |
| 26 | ||
| 27 | /* We put the plugin handle on the stack so it can pass it along */ | |
| 28 | /* to anythng called from the callback. It is supposed to pass */ | |
| 29 | /* the Action, but there is no way to access the plugin handle from */ | |
| 30 | /* the GaimPluginAction in perl...yet. */ | |
| 31 | ||
| 32 | XPUSHs(gaim_perl_bless_object(gpa->plugin, "Gaim::Plugin")); | |
| 33 | PUTBACK; | |
| 34 | ||
| 35 | /* gaim_perl_plugin_action_callback_sub defined in the header is set */ | |
| 36 | /* in perl.c during plugin probe by a PLUGIN_INFO hash value limiting */ | |
| 37 | /* us to only one action for right now even though the action member of */ | |
| 38 | /* GaimPluginInfo can take (does take) a GList. */ | |
| 39 | call_pv(gaim_perl_plugin_action_callback_sub, G_EVAL | G_SCALAR); | |
| 40 | SPAGAIN; | |
| 41 | ||
| 42 | PUTBACK; | |
| 43 | FREETMPS; | |
| 44 | LEAVE; | |
| 45 | } | |
| 46 | ||
| 47 | GList *gaim_perl_plugin_action(GaimPlugin *plugin, gpointer context) { | |
| 48 | GaimPluginAction *act = NULL; | |
| 49 | GList *gl = NULL; | |
| 50 | ||
| 51 | /* TODO: Fix the way we create action handlers so we can have mroe than */ | |
| 52 | /* one action in perl. Maybe there is a clever work around, but so far */ | |
| 53 | /* I have not figured it out. There is no way to tie the perl sub's */ | |
| 54 | /* name to the callback function without these global variables and */ | |
| 55 | /* there is no way to create a callback on the fly so each would have */ | |
| 56 | /* to be hardcoded--more than one would just be arbitrary. */ | |
| 57 | act = gaim_plugin_action_new(gaim_perl_plugin_action_label, gaim_perl_plugin_action_cb); | |
| 58 | gl = g_list_append(gl, act); | |
| 59 | ||
| 60 | return gl; | |
| 61 | } | |
| 62 | ||
| 63 | ||
| 64 | GaimGtkPluginUiInfo *gaim_perl_gtk_plugin_pref(const char * frame_cb) { | |
| 65 | ||
| 66 | GaimGtkPluginUiInfo *ui_info; | |
| 67 | ||
| 68 | ui_info = g_new0(GaimGtkPluginUiInfo, 1); | |
| 69 | perl_gtk_plugin_pref_cb = g_strdup(frame_cb); | |
| 70 | ui_info->get_config_frame = gaim_perl_gtk_get_plugin_frame; | |
| 71 | ||
| 72 | return ui_info; | |
| 73 | } | |
| 74 | ||
| 75 | GtkWidget *gaim_perl_gtk_get_plugin_frame(GaimPlugin *plugin) { | |
| 76 | ||
| 77 | SV * sv; | |
| 78 | GtkWidget *ret; | |
| 79 | MAGIC *mg; | |
| 80 | dSP; | |
| 81 | int count; | |
| 82 | ||
| 83 | ENTER; | |
| 84 | SAVETMPS; | |
| 85 | ||
| 86 | count = call_pv(perl_gtk_plugin_pref_cb, G_SCALAR | G_NOARGS); | |
| 87 | if (count != 1) | |
| 88 | croak("call_pv: Did not return the correct number of values.\n"); | |
| 89 | ||
| 90 | /* the frame was created in a perl sub and is returned */ | |
| 91 | SPAGAIN; | |
| 92 | ||
| 93 | /* We have a Gtk2::Frame on top of the stack */ | |
| 94 | sv = POPs; | |
| 95 | ||
| 96 | /* The magic field hides the pointer to the actuale GtkWidget */ | |
| 97 | mg = mg_find(SvRV(sv), PERL_MAGIC_ext); | |
| 98 | ret = (GtkWidget *)mg->mg_ptr; | |
| 99 | ||
| 100 | PUTBACK; | |
| 101 | FREETMPS; | |
| 102 | LEAVE; | |
| 103 | ||
| 104 | return ret; | |
| 105 | } | |
| 106 | ||
| 107 | ||
| 108 | ||
| 11123 | 109 | |
| 110 | /* Called to create a pointer to GaimPluginUiInfo for the GaimPluginInfo */ | |
| 111 | /* It will then inturn create ui_info with the C function pointer */ | |
| 112 | /* that will eventually do a call_pv to call a perl functions so users */ | |
| 113 | /* can create their own frames in the prefs */ | |
| 11170 | 114 | GaimPluginUiInfo *gaim_perl_plugin_pref(const char * frame_cb) { |
| 11123 | 115 | GaimPluginUiInfo *ui_info; |
| 116 | ||
| 117 | ui_info = g_new0(GaimPluginUiInfo, 1); | |
| 11170 | 118 | perl_plugin_pref_cb = g_strdup(frame_cb); |
| 11123 | 119 | ui_info->get_plugin_pref_frame = gaim_perl_get_plugin_frame; |
| 120 | ||
| 121 | return ui_info; | |
| 122 | } | |
| 123 | ||
| 124 | GaimPluginPrefFrame *gaim_perl_get_plugin_frame(GaimPlugin *plugin) { | |
| 125 | /* Sets up the Perl Stack for our call back into the script to run the */ | |
| 126 | /* plugin_pref... sub */ | |
| 127 | GaimPluginPrefFrame *ret_frame; | |
| 128 | dSP; | |
| 129 | int count; | |
| 130 | ||
| 131 | ENTER; | |
| 132 | SAVETMPS; | |
| 133 | /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and return */ | |
| 134 | /* the frame */ | |
| 135 | PUSHMARK(SP); | |
| 136 | PUTBACK; | |
| 137 | ||
| 138 | count = call_pv(perl_plugin_pref_cb, G_SCALAR | G_NOARGS); | |
| 139 | ||
| 140 | SPAGAIN; | |
| 141 | ||
| 142 | if (count != 1) | |
| 143 | croak("call_pv: Did not return the correct number of values.\n"); | |
| 144 | /* the frame was created in a perl sub and is returned */ | |
| 145 | ret_frame = (GaimPluginPrefFrame *)gaim_perl_ref_object(POPs); | |
| 146 | ||
| 147 | /* Tidy up the Perl stack */ | |
| 148 | PUTBACK; | |
| 149 | FREETMPS; | |
| 150 | LEAVE; | |
| 11170 | 151 | |
| 11123 | 152 | return ret_frame; |
| 153 | } | |
| 6520 | 154 | |
| 155 | static void | |
| 156 | destroy_timeout_handler(GaimPerlTimeoutHandler *handler) | |
| 157 | { | |
| 158 | timeout_handlers = g_list_remove(timeout_handlers, handler); | |
| 159 | ||
|
6568
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
160 | if (handler->callback != NULL) |
|
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
161 | SvREFCNT_dec(handler->callback); |
|
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
162 | |
|
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
163 | if (handler->data != NULL) |
|
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
164 | SvREFCNT_dec(handler->data); |
|
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
165 | |
| 6520 | 166 | g_free(handler); |
| 167 | } | |
| 168 | ||
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
169 | static void |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
170 | destroy_signal_handler(GaimPerlSignalHandler *handler) |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
171 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
172 | signal_handlers = g_list_remove(signal_handlers, handler); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
173 | |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
174 | if (handler->callback != NULL) |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
175 | SvREFCNT_dec(handler->callback); |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
176 | |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
177 | if (handler->data != NULL) |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
178 | SvREFCNT_dec(handler->data); |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
179 | |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
180 | g_free(handler->signal); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
181 | g_free(handler); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
182 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
183 | |
| 6520 | 184 | static int |
| 185 | perl_timeout_cb(gpointer data) | |
| 186 | { | |
| 187 | GaimPerlTimeoutHandler *handler = (GaimPerlTimeoutHandler *)data; | |
| 188 | ||
| 189 | dSP; | |
| 190 | ENTER; | |
| 191 | SAVETMPS; | |
| 192 | PUSHMARK(sp); | |
|
6568
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
193 | XPUSHs((SV *)handler->data); |
| 6520 | 194 | PUTBACK; |
|
6568
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
195 | call_sv(handler->callback, G_EVAL | G_SCALAR); |
| 6520 | 196 | SPAGAIN; |
| 197 | ||
| 198 | PUTBACK; | |
| 199 | FREETMPS; | |
| 200 | LEAVE; | |
| 201 | ||
| 202 | destroy_timeout_handler(handler); | |
| 203 | ||
| 204 | return 0; | |
| 205 | } | |
| 206 | ||
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
207 | typedef void *DATATYPE; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
208 | |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
209 | static void * |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
210 | perl_signal_cb(va_list args, void *data) |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
211 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
212 | GaimPerlSignalHandler *handler = (GaimPerlSignalHandler *)data; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
213 | void *ret_val = NULL; |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
214 | int i; |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
215 | int count; |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
216 | int value_count; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
217 | GaimValue *ret_value, **values; |
|
6919
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
218 | SV **sv_args; |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
219 | DATATYPE **copy_args; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
220 | STRLEN na; |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
221 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
222 | dSP; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
223 | ENTER; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
224 | SAVETMPS; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
225 | PUSHMARK(sp); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
226 | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
227 | gaim_signal_get_values(handler->instance, handler->signal, |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
228 | &ret_value, &value_count, &values); |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
229 | |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
230 | sv_args = g_new(SV *, value_count); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
231 | copy_args = g_new(void **, value_count); |
|
6919
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
232 | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
233 | for (i = 0; i < value_count; i++) |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
234 | { |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
235 | sv_args[i] = sv_2mortal(gaim_perl_sv_from_vargs(values[i], |
| 7386 | 236 | (va_list*)&args, ©_args[i])); |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
237 | |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
238 | XPUSHs(sv_args[i]); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
239 | } |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6554
diff
changeset
|
240 | |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
241 | XPUSHs((SV *)handler->data); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
242 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
243 | PUTBACK; |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
244 | |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
245 | if (ret_value != NULL) |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
246 | { |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
247 | count = call_sv(handler->callback, G_EVAL | G_SCALAR); |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
248 | |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
249 | SPAGAIN; |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
250 | |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
251 | if (count != 1) |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
252 | croak("Uh oh! call_sv returned %i != 1", i); |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
253 | else |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
254 | ret_val = gaim_perl_data_from_sv(ret_value, POPs); |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
255 | } |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
256 | else |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
257 | { |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
258 | call_sv(handler->callback, G_SCALAR); |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
259 | |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
260 | SPAGAIN; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
261 | } |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
262 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
263 | if (SvTRUE(ERRSV)) |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
264 | { |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
265 | gaim_debug_error("perl", "Perl function exited abnormally: %s\n", |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
266 | SvPV(ERRSV, na)); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
267 | } |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
268 | |
|
6919
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
269 | /* See if any parameters changed. */ |
|
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
270 | for (i = 0; i < value_count; i++) |
|
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
271 | { |
|
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
272 | if (gaim_value_is_outgoing(values[i])) |
|
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
273 | { |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
274 | switch (gaim_value_get_type(values[i])) |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
275 | { |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
276 | case GAIM_TYPE_BOOLEAN: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
277 | *((gboolean *)copy_args[i]) = SvIV(sv_args[i]); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
278 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
279 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
280 | case GAIM_TYPE_INT: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
281 | *((int *)copy_args[i]) = SvIV(sv_args[i]); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
282 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
283 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
284 | case GAIM_TYPE_UINT: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
285 | *((unsigned int *)copy_args[i]) = SvUV(sv_args[i]); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
286 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
287 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
288 | case GAIM_TYPE_LONG: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
289 | *((long *)copy_args[i]) = SvIV(sv_args[i]); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
290 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
291 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
292 | case GAIM_TYPE_ULONG: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
293 | *((unsigned long *)copy_args[i]) = SvUV(sv_args[i]); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
294 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
295 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
296 | case GAIM_TYPE_INT64: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
297 | *((gint64 *)copy_args[i]) = SvIV(sv_args[i]); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
298 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
299 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
300 | case GAIM_TYPE_UINT64: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
301 | *((guint64 *)copy_args[i]) = SvUV(sv_args[i]); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
302 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
303 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
304 | case GAIM_TYPE_STRING: |
|
6925
ace22b159921
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
305 | if (strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) |
|
ace22b159921
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
306 | { |
|
ace22b159921
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
307 | g_free(*((char **)copy_args[i])); |
|
ace22b159921
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
308 | *((char **)copy_args[i]) = |
|
ace22b159921
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
309 | g_strdup(SvPV(sv_args[i], na)); |
|
ace22b159921
[gaim-migrate @ 7472]
Christian Hammond <chipx86@chipx86.com>
parents:
6924
diff
changeset
|
310 | } |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
311 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
312 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
313 | case GAIM_TYPE_POINTER: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
314 | *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
315 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
316 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
317 | case GAIM_TYPE_BOXED: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
318 | *((void **)copy_args[i]) = (void *)SvIV(sv_args[i]); |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
319 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
320 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
321 | default: |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
322 | break; |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
323 | } |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
324 | |
|
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
325 | #if 0 |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
326 | *((void **)copy_args[i]) = gaim_perl_data_from_sv(values[i], |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
327 | sv_args[i]); |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
328 | #endif |
|
6919
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
329 | } |
|
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
330 | } |
|
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
331 | |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
332 | PUTBACK; |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
333 | FREETMPS; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
334 | LEAVE; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
335 | |
|
6919
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
336 | g_free(sv_args); |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6919
diff
changeset
|
337 | g_free(copy_args); |
|
6919
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
338 | |
|
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
339 | gaim_debug_misc("perl", "ret_val = %p\n", ret_val); |
|
2fd7ce2393f7
[gaim-migrate @ 7466]
Christian Hammond <chipx86@chipx86.com>
parents:
6568
diff
changeset
|
340 | |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
341 | return ret_val; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
342 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
343 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
344 | static GaimPerlSignalHandler * |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
345 | find_signal_handler(GaimPlugin *plugin, void *instance, const char *signal) |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
346 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
347 | GaimPerlSignalHandler *handler; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
348 | GList *l; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
349 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
350 | for (l = signal_handlers; l != NULL; l = l->next) |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
351 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
352 | handler = (GaimPerlSignalHandler *)l->data; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
353 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
354 | if (handler->plugin == plugin && |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
355 | handler->instance == instance && |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
356 | !strcmp(handler->signal, signal)) |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
357 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
358 | return handler; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
359 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
360 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
361 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
362 | return NULL; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
363 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
364 | |
| 6520 | 365 | void |
|
6568
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
366 | gaim_perl_timeout_add(GaimPlugin *plugin, int seconds, SV *callback, SV *data) |
| 6520 | 367 | { |
| 368 | GaimPerlTimeoutHandler *handler; | |
| 369 | ||
| 370 | if (plugin == NULL) | |
| 371 | { | |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
372 | croak("Invalid handle in adding perl timeout handler.\n"); |
| 6520 | 373 | return; |
| 374 | } | |
| 375 | ||
| 376 | handler = g_new0(GaimPerlTimeoutHandler, 1); | |
| 377 | ||
|
6568
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
378 | handler->plugin = plugin; |
|
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
379 | handler->callback = (callback != NULL && callback != &PL_sv_undef |
|
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
380 | ? newSVsv(callback) : NULL); |
|
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
381 | handler->data = (data != NULL && data != &PL_sv_undef |
|
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
382 | ? newSVsv(data) : NULL); |
| 6520 | 383 | |
| 384 | timeout_handlers = g_list_append(timeout_handlers, handler); | |
|
6568
5c8c70b63dc3
[gaim-migrate @ 7090]
Christian Hammond <chipx86@chipx86.com>
parents:
6567
diff
changeset
|
385 | |
| 6520 | 386 | handler->iotag = g_timeout_add(seconds * 1000, perl_timeout_cb, handler); |
| 387 | } | |
| 388 | ||
| 389 | void | |
| 390 | gaim_perl_timeout_clear_for_plugin(GaimPlugin *plugin) | |
| 391 | { | |
| 392 | GaimPerlTimeoutHandler *handler; | |
| 393 | GList *l, *l_next; | |
| 394 | ||
| 395 | for (l = timeout_handlers; l != NULL; l = l_next) | |
| 396 | { | |
| 397 | l_next = l->next; | |
| 398 | ||
| 399 | handler = (GaimPerlTimeoutHandler *)l->data; | |
| 400 | ||
| 401 | if (handler->plugin == plugin) | |
| 402 | destroy_timeout_handler(handler); | |
| 403 | } | |
| 404 | } | |
| 405 | ||
| 406 | void | |
| 407 | gaim_perl_timeout_clear(void) | |
| 408 | { | |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
409 | while (timeout_handlers != NULL) |
| 6520 | 410 | destroy_timeout_handler(timeout_handlers->data); |
| 411 | } | |
| 412 | ||
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
413 | void |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
414 | gaim_perl_signal_connect(GaimPlugin *plugin, void *instance, |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
415 | const char *signal, SV *callback, SV *data) |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
416 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
417 | GaimPerlSignalHandler *handler; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
418 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
419 | handler = g_new0(GaimPerlSignalHandler, 1); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
420 | handler->plugin = plugin; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
421 | handler->instance = instance; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
422 | handler->signal = g_strdup(signal); |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
423 | handler->callback = (callback != NULL && callback != &PL_sv_undef |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
424 | ? newSVsv(callback) : NULL); |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
425 | handler->data = (data != NULL && data != &PL_sv_undef |
|
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
426 | ? newSVsv(data) : NULL); |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
427 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
428 | signal_handlers = g_list_append(signal_handlers, handler); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
429 | |
|
6554
4e85a132ad50
[gaim-migrate @ 7076]
Christian Hammond <chipx86@chipx86.com>
parents:
6549
diff
changeset
|
430 | gaim_signal_connect_vargs(instance, signal, |
|
4e85a132ad50
[gaim-migrate @ 7076]
Christian Hammond <chipx86@chipx86.com>
parents:
6549
diff
changeset
|
431 | plugin, GAIM_CALLBACK(perl_signal_cb), handler); |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
432 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
433 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
434 | void |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
435 | gaim_perl_signal_disconnect(GaimPlugin *plugin, void *instance, |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
436 | const char *signal) |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
437 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
438 | GaimPerlSignalHandler *handler; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
439 | |
|
6567
761a1feb5561
[gaim-migrate @ 7089]
Christian Hammond <chipx86@chipx86.com>
parents:
6566
diff
changeset
|
440 | handler = find_signal_handler(plugin, instance, signal); |
|
6549
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
441 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
442 | if (handler == NULL) |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
443 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
444 | croak("Invalid signal handler information in " |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
445 | "disconnecting a perl signal handler.\n"); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
446 | return; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
447 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
448 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
449 | destroy_signal_handler(handler); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
450 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
451 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
452 | void |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
453 | gaim_perl_signal_clear_for_plugin(GaimPlugin *plugin) |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
454 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
455 | GaimPerlSignalHandler *handler; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
456 | GList *l, *l_next; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
457 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
458 | for (l = signal_handlers; l != NULL; l = l_next) |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
459 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
460 | l_next = l->next; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
461 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
462 | handler = (GaimPerlSignalHandler *)l->data; |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
463 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
464 | if (handler->plugin == plugin) |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
465 | destroy_signal_handler(handler); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
466 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
467 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
468 | |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
469 | void |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
470 | gaim_perl_signal_clear(void) |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
471 | { |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
472 | while (signal_handlers != NULL) |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
473 | destroy_signal_handler(signal_handlers->data); |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
474 | } |
|
8e6ba2a45698
[gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents:
6520
diff
changeset
|
475 |