Mercurial > pidgin.yaz
changeset 2355:571971659533
[gaim-migrate @ 2368]
gaim.pl works like it should now
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 24 Sep 2001 19:32:57 +0000 |
parents | e485dcbefb9a |
children | ddf404cd9757 |
files | plugins/PERL-HOWTO plugins/gaim.pl src/perl.c src/plugins.c src/prpl.c |
diffstat | 5 files changed, 54 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/PERL-HOWTO Mon Sep 24 16:49:32 2001 +0000 +++ b/plugins/PERL-HOWTO Mon Sep 24 19:32:57 2001 +0000 @@ -45,6 +45,7 @@ 4 - given a connection index, the index in the users list 5 - the list of names of users 6 - the list of protocols of the users + 7 - given a connection index, the name of the protocol (as a string) GAIM::print(title, message) This displays a nice little dialog window.
--- a/plugins/gaim.pl Mon Sep 24 16:49:32 2001 +0000 +++ b/plugins/gaim.pl Mon Sep 24 19:32:57 2001 +0000 @@ -1,24 +1,30 @@ GAIM::register("gaim test", "0.0.1", "goodbye", ""); $ver = GAIM::get_info(0); -$nam = GAIM::get_info(1); -$pro = GAIM::get_info(2, $nam); - -GAIM::print("Perl Says", "Gaim $ver, $nam using $pro"); +@ids = GAIM::get_info(1); -GAIM::command("idle", 60000); +$msg = "Gaim $ver:"; +foreach $id (@ids) { + $pro = GAIM::get_info(7, $id); + $nam = GAIM::get_info(3, $id); + $msg .= "\n$nam using $pro"; +} -GAIM::add_event_handler("event_buddy_signon", "say_hello"); -GAIM::add_timeout_handler(600, "notify"); +GAIM::print("Perl Says", $msg); + +GAIM::command("idle", 6000); + +GAIM::add_event_handler("event_buddy_signon", "echo_reply"); +GAIM::add_timeout_handler(60, "notify"); sub echo_reply { - $args = @_; - $args =~ s/\"//g; - GAIM::print_to_conv($args, "Hello"); + $args = $_[0]; + $args =~ s/(.+) \"(.+)\"//; + GAIM::print_to_conv($1, $2, "Hello", 0); } sub notify { - GAIM::print("10 minutes", "gaim test has been loaded for 10 minutes"); + GAIM::print("1 minute", "gaim test has been loaded for 1 minute"); } sub goodbye {
--- a/src/perl.c Mon Sep 24 16:49:32 2001 +0000 +++ b/src/perl.c Mon Sep 24 19:32:57 2001 +0000 @@ -60,6 +60,7 @@ #undef DEBUG #endif #include "gaim.h" +#include "prpl.h" struct perlscript { char *name; @@ -302,7 +303,6 @@ XS (XS_GAIM_get_info) { int i = 0; - unsigned int junk; dXSARGS; items = 0; @@ -325,7 +325,8 @@ break; case 2: { - struct gaim_connection *gc = (struct gaim_connection *)SvPV(ST(1), junk); + struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); + debug_printf("%lu %lu\n", connections->data, gc); if (g_slist_find(connections, gc)) XST_mIV(i++, gc->protocol); else @@ -334,15 +335,18 @@ break; case 3: { - struct gaim_connection *gc = (struct gaim_connection *)SvPV(ST(1), junk); + struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); + debug_printf("%lu %lu\n", connections->data, gc); if (g_slist_find(connections, gc)) XST_mPV(i++, gc->username); else XST_mPV(i++, ""); } + break; case 4: { - struct gaim_connection *gc = (struct gaim_connection *)SvPV(ST(1), junk); + struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); + debug_printf("%lu %lu\n", connections->data, gc); if (g_slist_find(connections, gc)) XST_mIV(i++, g_list_index(aim_users, gc->user)); else @@ -369,6 +373,16 @@ } } break; + case 7: + { + struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); + debug_printf("%lu %lu\n", connections->data, gc); + if (g_slist_find(connections, gc)) + XST_mPV(i++, (*gc->prpl->name)()); + else + XST_mPV(i++, "Unknown"); + } + break; default: XST_mPV(0, "Error2"); i = 1; @@ -482,7 +496,6 @@ while (c) { gc = (struct gaim_connection *)c->data; serv_set_idle(gc, SvIV(ST(1))); - gc->is_idle = 1; c = c->next; } } else if (!strncasecmp(command, "warn", 4)) { @@ -687,7 +700,8 @@ items = 0; handler = g_new0(struct _perl_timeout_handlers, 1); - timeout = 1000 * atol(SvPV(ST(0), junk)); + timeout = 1000 * SvIV(ST(0)); + debug_printf("Adding timeout for %d seconds.\n", timeout/1000); handler->handler_name = g_strdup(SvPV(ST(1), junk)); perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler); handler->iotag = gtk_timeout_add(timeout, (GtkFunction)perl_timeout, handler);
--- a/src/plugins.c Mon Sep 24 16:49:32 2001 +0000 +++ b/src/plugins.c Mon Sep 24 19:32:57 2001 +0000 @@ -831,15 +831,15 @@ case event_signoff: case event_away: case event_back: - g_snprintf(buf, sizeof buf, "%p", arg1); + g_snprintf(buf, sizeof buf, "%lu", (unsigned long)arg1); break; case event_im_recv: - g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, + g_snprintf(buf, sizeof buf, "%lu \"%s\" %s", (unsigned long)arg1, *(char **)arg2 ? *(char **)arg2 : "(null)", *(char **)arg3 ? *(char **)arg3 : "(null)"); break; case event_im_send: - g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, + g_snprintf(buf, sizeof buf, "%lu \"%s\" %s", (unsigned long)arg1, (char *)arg2, *(char **)arg3 ? *(char **)arg3 : "(null)"); break; case event_buddy_signon: @@ -849,31 +849,33 @@ case event_buddy_back: case event_buddy_idle: case event_buddy_unidle: - g_snprintf(buf, sizeof buf, "%p \"%s\"", arg1, (char *)arg2); + g_snprintf(buf, sizeof buf, "%lu \"%s\"", (unsigned long)arg1, (char *)arg2); break; case event_chat_invited: - g_snprintf(buf, sizeof buf, "%p \"%s\" \"%s\" %s", arg1, + g_snprintf(buf, sizeof buf, "%lu \"%s\" \"%s\" %s", (unsigned long)arg1, (char *)arg2, (char *)arg3, arg4 ? (char *)arg4 : ""); break; case event_chat_join: case event_chat_buddy_join: case event_chat_buddy_leave: - g_snprintf(buf, sizeof buf, "%p %d \"%s\"", arg1, (int)arg2, (char *)arg3); + g_snprintf(buf, sizeof buf, "%lu %d \"%s\"", (unsigned long)arg1, + (int)arg2, (char *)arg3); break; case event_chat_leave: - g_snprintf(buf, sizeof buf, "%p %d", arg1, (int)arg2); + g_snprintf(buf, sizeof buf, "%lu %d", (unsigned long)arg1, (int)arg2); break; case event_chat_recv: case event_chat_send_invite: - g_snprintf(buf, sizeof buf, "%p %d \"%s\" %s", arg1, + g_snprintf(buf, sizeof buf, "%lu %d \"%s\" %s", (unsigned long)arg1, (int)arg2, (char *)arg3, (char *)arg4); break; case event_chat_send: - g_snprintf(buf, sizeof buf, "%p %d %s", arg1, (int)arg2, + g_snprintf(buf, sizeof buf, "%lu %d %s", (unsigned long)arg1, (int)arg2, *(char **)arg3 ? *(char **)arg3 : "(null)"); break; case event_warned: - g_snprintf(buf, sizeof buf, "%p \"%s\" %d", arg1, arg2 ? (char *)arg2 : "", (int)arg3); + g_snprintf(buf, sizeof buf, "%lu \"%s\" %d", (unsigned long)arg1, + arg2 ? (char *)arg2 : "", (int)arg3); break; case event_quit: buf[0] = 0; @@ -882,11 +884,11 @@ g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); break; case event_im_displayed_sent: - g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, + g_snprintf(buf, sizeof buf, "%lu \"%s\" %s", (unsigned long)arg1, (char *)arg2, *(char **)arg3 ? *(char **)arg3 : "(null)"); break; case event_im_displayed_rcvd: - g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, + g_snprintf(buf, sizeof buf, "%lu \"%s\" %s", (unsigned long)arg1, (char *)arg2, (char *)arg3 ? (char *)arg3 : "(null)"); break; default:
--- a/src/prpl.c Mon Sep 24 16:49:32 2001 +0000 +++ b/src/prpl.c Mon Sep 24 19:32:57 2001 +0000 @@ -376,6 +376,7 @@ gtk_widget_show(gc->email_label); close = picture_button(gc->email_win, _("Close"), cancel_xpm); + gtk_window_set_focus(GTK_WINDOW(gc->email_win), close); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(gc->email_win)->action_area), close, 0, 0, 5); gtk_signal_connect(GTK_OBJECT(close), "clicked", @@ -405,6 +406,7 @@ gtk_widget_show(gc->email_label); close = picture_button(gc->email_win, _("Close"), cancel_xpm); + gtk_window_set_focus(GTK_WINDOW(gc->email_win), close); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(gc->email_win)->action_area), close, 0, 0, 5); gtk_signal_connect(GTK_OBJECT(close), "clicked",