| 188 newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM"); |
188 newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM"); |
| 189 |
189 |
| 190 newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM"); |
190 newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM"); |
| 191 } |
191 } |
| 192 |
192 |
| |
193 #if 0 |
| |
194 #define COMPARE_EVENT(evt, sig, h) \ |
| |
195 if (!strcmp(event_name, (evt))) \ |
| |
196 { \ |
| |
197 *signal_name = (sig); \ |
| |
198 *handle = (h); \ |
| |
199 return TRUE; \ |
| |
200 } |
| |
201 |
| |
202 static gboolean |
| |
203 convert_event_to_signal(const char *event_name, const char **signal_name, |
| |
204 void **handle) |
| |
205 { |
| |
206 void *conn_handle = gaim_connections_get_handle(); |
| |
207 void *account_handle = gaim_accounts_get_handle(); |
| |
208 void *conv_handle = gaim_conversations_get_handle(); |
| |
209 void *blist_handle = gaim_get_blist(); |
| |
210 |
| |
211 COMPARE_EVENT("event_signon", "signed-on", conn_handle); |
| |
212 COMPARE_EVENT("event_signoff", "signed-off", conn_handle); |
| |
213 |
| |
214 COMPARE_EVENT("event_away", "account-away", account_handle); |
| |
215 COMPARE_EVENT("event_back", "account-back", account_handle); |
| |
216 COMPARE_EVENT("event_warned", "account-warned", account_handle); |
| |
217 COMPARE_EVENT("event_set_info", "account-set-info", account_handle); |
| |
218 COMPARE_EVENT("event_connecting", "account-connecting", account_handle); |
| |
219 |
| |
220 COMPARE_EVENT("event_im_recv", "received-im-msg", conv_handle); |
| |
221 COMPARE_EVENT("event_im_send", "sent-im-msg", conv_handle); |
| |
222 COMPARE_EVENT("event_chat_invited", "chat-invited", conv_handle); |
| |
223 COMPARE_EVENT("event_chat_join", "chat-joined", conv_handle); |
| |
224 COMPARE_EVENT("event_chat_leave", "chat-left", conv_handle); |
| |
225 COMPARE_EVENT("event_chat_buddy_join", "chat-buddy-joined", conv_handle); |
| |
226 COMPARE_EVENT("event_chat_buddy_leave", "chat-buddy-left", conv_handle); |
| |
227 COMPARE_EVENT("event_chat_recv", "received-chat-msg", conv_handle); |
| |
228 COMPARE_EVENT("event_chat_send", "sent-chat-msg", conv_handle); |
| |
229 COMPARE_EVENT("event_new_conversation", "conversation-created", |
| |
230 conv_handle); |
| |
231 COMPARE_EVENT("event_im_displayed_sent", "sending-im-msg", conv_handle); |
| |
232 COMPARE_EVENT("event_im_displayed_rcvd", NULL, NULL); |
| |
233 COMPARE_EVENT("event_chat_send_invite", "chat-inviting-user", conv_handle); |
| |
234 COMPARE_EVENT("event_got_typing", "buddy-typing", conv_handle); |
| |
235 COMPARE_EVENT("event_del_conversation", "deleting-conversation", |
| |
236 conv_handle); |
| |
237 COMPARE_EVENT("event_conversation_switch", "conversation-switched", |
| |
238 conv_handle); |
| |
239 |
| |
240 COMPARE_EVENT("event_buddy_signon", "buddy-signed-on", blist_handle); |
| |
241 COMPARE_EVENT("event_buddy_signoff", "buddy-signed-off", blist_handle); |
| |
242 COMPARE_EVENT("event_buddy_away", "buddy-away", blist_handle); |
| |
243 COMPARE_EVENT("event_buddy_back", "buddy-back", blist_handle); |
| |
244 COMPARE_EVENT("event_buddy_idle", "buddy-idle", blist_handle); |
| |
245 COMPARE_EVENT("event_buddy_unidle", "buddy-unidle", blist_handle); |
| |
246 COMPARE_EVENT("event_blist_update", "update-idle", blist_handle); |
| |
247 |
| |
248 COMPARE_EVENT("event_quit", "quitting", gaim_get_core()); |
| |
249 |
| |
250 *signal_name = NULL; |
| |
251 *handle = NULL; |
| |
252 |
| |
253 return FALSE; |
| |
254 } |
| |
255 #endif |
| |
256 |
| 193 static char * |
257 static char * |
| 194 escape_quotes(const char *buf) |
258 escape_quotes(const char *buf) |
| 195 { |
259 { |
| 196 static char *tmp_buf = NULL; |
260 static char *tmp_buf = NULL; |
| 197 const char *i; |
261 const char *i; |
| 214 return tmp_buf; |
278 return tmp_buf; |
| 215 } |
279 } |
| 216 |
280 |
| 217 /* |
281 /* |
| 218 2003/02/06: execute_perl modified by Mark Doliner <mark@kingant.net> |
282 2003/02/06: execute_perl modified by Mark Doliner <mark@kingant.net> |
| 219 Pass parameters by pushing them onto the stack rather than |
283 Pass parameters by pushing them onto the stack rather than |
| 220 passing an array of strings. This way, perl scripts can |
284 passing an array of strings. This way, perl scripts can |
| 221 modify the parameters and we can get the changed values |
285 modify the parameters and we can get the changed values |
| 222 and then shoot ourselves. I mean, uh, use them. |
286 and then shoot ourselves. I mean, uh, use them. |
| 223 |
287 |
| 224 2001/06/14: execute_perl replaced by Martin Persson <mep@passagen.se> |
288 2001/06/14: execute_perl replaced by Martin Persson <mep@passagen.se> |
| 225 previous use of perl_eval leaked memory, replaced with |
289 previous use of perl_eval leaked memory, replaced with |
| 226 a version that uses perl_call instead |
290 a version that uses perl_call instead |
| 227 |
291 |
| 228 30/11/2002: execute_perl modified by Eric Timme <timothy@voidnet.com> |
292 30/11/2002: execute_perl modified by Eric Timme <timothy@voidnet.com> |
| 229 args changed to char** so that we can have preparsed |
293 args changed to char** so that we can have preparsed |
| 230 arguments again, and many headaches ensued! This essentially |
294 arguments again, and many headaches ensued! This essentially |
| 231 means we replaced one hacked method with a messier hacked |
295 means we replaced one hacked method with a messier hacked |
| 232 method out of perceived necessity. Formerly execute_perl |
296 method out of perceived necessity. Formerly execute_perl |
| 233 required a single char_ptr, and it would insert it into an |
297 required a single char_ptr, and it would insert it into an |
| 234 array of character pointers and NULL terminate the new array. |
298 array of character pointers and NULL terminate the new array. |
| 235 Now we have to pass in pre-terminated character pointer arrays |
299 Now we have to pass in pre-terminated character pointer arrays |
| 236 to accomodate functions that want to pass in multiple arguments. |
300 to accomodate functions that want to pass in multiple arguments. |
| 237 |
301 |
| 238 Previously arguments were preparsed because an argument list |
302 Previously arguments were preparsed because an argument list |
| 239 was constructed in the form 'arg one','arg two' and was |
303 was constructed in the form 'arg one','arg two' and was |
| 240 executed via a call like &funcname(arglist) (see .59.x), so |
304 executed via a call like &funcname(arglist) (see .59.x), so |
| 241 the arglist was magically pre-parsed because of the method. |
305 the arglist was magically pre-parsed because of the method. |
| 242 With Martin Persson's change to perl_call we now need to |
306 With Martin Persson's change to perl_call we now need to |
| 243 use a null terminated list of character pointers for arguments |
307 use a null terminated list of character pointers for arguments |
| 244 if we wish them to be parsed. Lacking a better way to allow |
308 if we wish them to be parsed. Lacking a better way to allow |
| 245 for both single arguments and many I created a NULL terminated |
309 for both single arguments and many I created a NULL terminated |
| 246 array in every function that called execute_perl and passed |
310 array in every function that called execute_perl and passed |
| 253 the array sizes? I am not comfortable enough with this |
317 the array sizes? I am not comfortable enough with this |
| 254 subject to attempt it myself and hope it to stand the test |
318 subject to attempt it myself and hope it to stand the test |
| 255 of time. |
319 of time. |
| 256 */ |
320 */ |
| 257 |
321 |
| 258 static int |
322 static int |
| 259 execute_perl(const char *function, int argc, char **args) |
323 execute_perl(const char *function, int argc, char **args) |
| 260 { |
324 { |
| 261 int count = 0, i, ret_value = 1; |
325 int count = 0, i, ret_value = 1; |
| 262 SV *sv_args[argc]; |
326 SV *sv_args[argc]; |
| 263 STRLEN na; |
327 STRLEN na; |
| 264 |
328 |
| 265 /* |
329 /* |
| 266 * Set up the perl environment, push arguments onto the |
330 * Set up the perl environment, push arguments onto the |
| 267 * perl stack, then call the given function |
331 * perl stack, then call the given function |
| 268 */ |
332 */ |
| 269 dSP; |
333 dSP; |
| 270 ENTER; |
334 ENTER; |
| 271 SAVETMPS; |
335 SAVETMPS; |
| 821 |
885 |
| 822 nick = SvPV(ST(0), junk); |
886 nick = SvPV(ST(0), junk); |
| 823 send = SvIV(ST(1)); |
887 send = SvIV(ST(1)); |
| 824 what = SvPV(ST(2), junk); |
888 what = SvPV(ST(2), junk); |
| 825 who = SvPV(ST(3), junk); |
889 who = SvPV(ST(3), junk); |
| 826 |
890 |
| 827 if (!*who) who=NULL; |
891 if (!*who) who=NULL; |
| 828 |
892 |
| 829 switch (send) { |
893 switch (send) { |
| 830 case 0: wflags=WFLAG_SEND; break; |
894 case 0: wflags=WFLAG_SEND; break; |
| 831 case 1: wflags=WFLAG_RECV; break; |
895 case 1: wflags=WFLAG_RECV; break; |
| 832 case 2: wflags=WFLAG_SYSTEM; break; |
896 case 2: wflags=WFLAG_SYSTEM; break; |
| 833 default: wflags=WFLAG_RECV; |
897 default: wflags=WFLAG_RECV; |
| 834 } |
898 } |
| 835 |
899 |
| 836 c = gaim_find_conversation(nick); |
900 c = gaim_find_conversation(nick); |
| 837 |
901 |
| 838 if (!c) |
902 if (!c) |
| 839 c = gaim_conversation_new(GAIM_CONV_IM, NULL, nick); |
903 c = gaim_conversation_new(GAIM_CONV_IM, NULL, nick); |
| 888 if (!c) |
952 if (!c) |
| 889 c = gaim_conversation_new(GAIM_CONV_IM, gc->account, nick); |
953 c = gaim_conversation_new(GAIM_CONV_IM, gc->account, nick); |
| 890 else |
954 else |
| 891 gaim_conversation_set_account(c, gc->account); |
955 gaim_conversation_set_account(c, gc->account); |
| 892 |
956 |
| 893 gaim_conversation_write(c, NULL, what, -1, |
957 gaim_conversation_write(c, NULL, what, -1, |
| 894 (WFLAG_SEND | (isauto ? WFLAG_AUTO : 0)), time(NULL)); |
958 (WFLAG_SEND | (isauto ? WFLAG_AUTO : 0)), time(NULL)); |
| 895 serv_send_im(gc, nick, what, -1, isauto ? IM_FLAG_AWAY : 0); |
959 serv_send_im(gc, nick, what, -1, isauto ? IM_FLAG_AWAY : 0); |
| 896 XSRETURN(0); |
960 XSRETURN(0); |
| 897 } |
961 } |
| 898 |
962 |
| 899 |
963 |
| 900 |
964 |
| 901 XS (XS_GAIM_print_to_chat) |
965 XS (XS_GAIM_print_to_chat) |
| 902 { |
966 { |
| 903 GaimConnection *gc; |
967 GaimConnection *gc; |
| 904 int id; |
968 int id; |
| 905 char *what; |
969 char *what; |
| 929 if (b) |
993 if (b) |
| 930 serv_chat_send(gc, id, what); |
994 serv_chat_send(gc, id, what); |
| 931 XSRETURN(0); |
995 XSRETURN(0); |
| 932 } |
996 } |
| 933 |
997 |
| |
998 #if 0 |
| 934 static int |
999 static int |
| 935 perl_event(GaimEvent event, void *unused, va_list args) |
1000 perl_event(GaimEvent event, void *unused, va_list args) |
| 936 { |
1001 { |
| 937 char *buf[5] = { NULL, NULL, NULL, NULL, NULL }; /* Maximum of 5 args */ |
1002 char *buf[5] = { NULL, NULL, NULL, NULL, NULL }; /* Maximum of 5 args */ |
| 938 void *arg1 = NULL, *arg2 = NULL, *arg3 = NULL, *arg4 = NULL, *arg5 = NULL; |
1003 void *arg1 = NULL, *arg2 = NULL, *arg3 = NULL, *arg4 = NULL, *arg5 = NULL; |