Mercurial > pidgin.yaz
diff plugins/gaim-remote/remote.c @ 10003:33431f91e4a8
[gaim-migrate @ 10920]
(21:42:10) JBSilvest: see away msg :)
(21:42:29) Luke: awesome
(21:42:47) JBSilvest: it could probably use a glance at by a second pair of
eyes, but it works
(21:43:02) JBSilvest: oh, i should do the obligatory thing, shouldn't i?
(21:43:15) JBSilvest: [^H]
(21:43:31) JBSilvest: Hello World
(21:43:53) JBSilvest: [john@tux-laptop gaim]$ gaim-remote send -t lschiere
-f JBSilvest -p prpl-oscar -m "Hello World"
(21:44:27) JBSilvest: i shain't think there are any memleak risks or other
baddies, but i won't profess to being a highly skilled C programmer
(21:45:06) Luke: so is it ready?
(21:45:16) JBSilvest: more or less
(21:45:26) JBSilvest: could use more strings/docs, but it definitely works
(21:47:51) JBSilvest: someone will no doubt bitch & moan about 9999-char
limit, but until someone can recommend a better way || i redo the whole
sys., that'll be it
(21:49:13) JBSilvest: *and* thinking about things, there is blessedly no
risk of remote buffer overflow or any such crap :-D
(21:49:21) JBSilvest: it has to be run by the user :)
(21:49:25) Luke: okay, so this patch does what now? it lets you send and
not just put text in the input widget and what else?
(21:49:40) Luke: or the web browser
(21:49:42) JBSilvest: it lets you send...period :)
(21:49:52) JBSilvest: from the command line/scripts
(21:49:56) Luke: for instance if you made gaim-remote your handler for aim:
uris
(21:50:02) JBSilvest: no
(21:50:06) JBSilvest: that's not what this does
(21:50:12) JBSilvest: it doesn't parse aim:uris
(21:50:16) Luke: ah
(21:50:17) JBSilvest: it's for sending messages themselves
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 10 Sep 2004 01:51:02 +0000 |
parents | bdec08a8fc5b |
children | c892b6dbc341 |
line wrap: on
line diff
--- a/plugins/gaim-remote/remote.c Fri Sep 10 01:43:41 2004 +0000 +++ b/plugins/gaim-remote/remote.c Fri Sep 10 01:51:02 2004 +0000 @@ -70,7 +70,7 @@ GaimConnection *gc = NULL; GaimAccount *account; - gaim_debug(GAIM_DEBUG_INFO, "gaim_remote_handle_uri", "Handling URI: %s\n", uri); + gaim_debug_info("gaim_remote_handle_uri", "Handling URI: %s\n", uri); /* Well, we'd better check to make sure we have at least one AIM account connected. */ @@ -158,7 +158,7 @@ g_string_free(str, TRUE); } - gaim_debug(GAIM_DEBUG_MISC, "gaim_remote_handle_uri", "who: %s\n", who); + gaim_debug_misc("gaim_remote_handle_uri", "who: %s\n", who); gaim_blist_request_add_buddy(gc->account, who, group, NULL); g_free(who); if (group) @@ -330,8 +330,7 @@ gaim_remote_packet_free(p); break; default: - gaim_debug(GAIM_DEBUG_WARNING, "cui", - "Unhandled meta subtype %d\n", subtype); + gaim_debug_warning("cui", "Unhandled meta subtype %d\n", subtype); break; } @@ -362,8 +361,7 @@ } break; default: - gaim_debug(GAIM_DEBUG_WARNING, "cui", - "Unhandled plugin subtype %d\n", subtype); + gaim_debug_warning("cui", "Unhandled plugin subtype %d\n", subtype); break; } #endif @@ -414,8 +412,7 @@ break; #endif /* STATUS */ default: - gaim_debug(GAIM_DEBUG_WARNING, "cui", - "Unhandled user subtype %d\n", subtype); + gaim_debug_warning("cui", "Unhandled user subtype %d\n", subtype); break; } } @@ -463,8 +460,7 @@ case CUI_MESSAGE_RECV: break; default: - gaim_debug(GAIM_DEBUG_WARNING, "cui", - "Unhandled message subtype %d\n", subtype); + gaim_debug_warning("cui", "Unhandled message subtype %d\n", subtype); break; } } @@ -496,9 +492,89 @@ { const char *resp; char *send; + + GList *c = gaim_connections_get_all(); + GaimConnection *gc; + GaimAccount *account; + switch (subtype) { case CUI_REMOTE_CONNECTIONS: break; + case CUI_REMOTE_SEND: + if (!data) + return; + { + guint id; + GaimConnection *gc; + GaimConversation *conv; + guint tlen,len,len2,quiet; + char *who, *msg; + char *tmp, *from, *proto; + gint flags; + int pos = 0; + GList *c = gaim_connections_get_all(); + + gaim_debug_info("cui", "Got `gaim-remote send` packet\n",data); + gaim_debug_info("cui", "g-r>%s;\n",data); + + tmp = g_strndup(data + pos, 4); + tlen=atoi(tmp); + pos+=4; + + who=g_strndup(data+pos, tlen); + pos+=tlen; + + tmp = g_strndup(data + pos, 4); + tlen=atoi(tmp); len=tlen; /*length for 'from' compare*/ + pos+=4; + + from=g_strndup(data+pos, tlen); + pos+=tlen; + + tmp = g_strndup(data + pos, 4); + tlen=atoi(tmp); len2=tlen; /*length for 'proto' compare*/ + pos+=4; + + proto=g_strndup(data+pos, tlen); + pos+=tlen; + + tmp = g_strndup(data + pos, 4); + tlen=atoi(tmp); + pos+=4; + + msg=g_strndup(data+pos, tlen); + pos+=tlen; + + tmp = g_strndup(data + pos, 1); + quiet=atoi(tmp); /*quiet flag - not in use yet*/ + + /*find acct*/ + while (c) { + gc = c->data; + account=gaim_connection_get_account(gc); + if ((!gaim_utf8_strcasecmp(from, gaim_account_get_username(account))) && (!g_ascii_strncasecmp(proto, gaim_account_get_protocol_id(account), len2)) ) + break; + c = c->next; + } + if (!gc) + return; + /*end acct find*/ + + /*gaim_debug_info("cui", "g-r>To: %s; From: %s; Protocol: %s; Message: %s; Quiet: %d\n",who,from,proto,msg,quiet);*/ + conv = gaim_conversation_new(GAIM_CONV_IM, gaim_connection_get_account(gc), who); + gaim_conv_im_send(GAIM_CONV_IM(conv), msg); + + /*likely to be used for quiet: + serv_send_im(gc, who, msg, -1, 0); + */ + + g_free(who); + g_free(msg); + g_free(from); + g_free(tmp); + } + break; + case CUI_REMOTE_URI: send = g_malloc(len + 1); memcpy(send, data, len); @@ -508,8 +584,7 @@ /* report error */ break; default: - gaim_debug(GAIM_DEBUG_WARNING, "cui", - "Unhandled remote subtype %d\n", subtype); + gaim_debug_warning("cui", "Unhandled remote subtype %d\n", subtype); break; } } @@ -529,7 +604,7 @@ /* no byte order worries! this'll change if we go to TCP */ if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) { - gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n"); + gaim_debug_error("cui", "UI has abandoned us!\n"); uis = g_slist_remove(uis, ui); g_io_channel_shutdown(ui->channel, TRUE, &error); if(error) { @@ -542,7 +617,7 @@ } if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) { - gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n"); + gaim_debug_error("cui", "UI has abandoned us!\n"); uis = g_slist_remove(uis, ui); g_io_channel_shutdown(ui->channel, TRUE, &error); if(error) { @@ -555,7 +630,7 @@ } if (gaim_recv(source, (gchar *)&len, sizeof(len)) != sizeof(len)) { - gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n"); + gaim_debug_error("cui", "UI has abandoned us!\n"); uis = g_slist_remove(uis, ui); g_io_channel_shutdown(ui->channel, TRUE, &error); if(error) { @@ -570,7 +645,7 @@ if (len) { in = g_new0(gchar, len); if (gaim_recv(source, in, len) != len) { - gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n"); + gaim_debug_error("cui", "UI has abandoned us!\n"); uis = g_slist_remove(uis, ui); g_io_channel_shutdown(ui->channel, TRUE, &error); if(error) { @@ -614,8 +689,7 @@ remote_handler(ui, subtype, in, len); break; default: - gaim_debug(GAIM_DEBUG_WARNING, "cui", - "Unhandled type %d\n", type); + gaim_debug_warning("cui", "Unhandled type %d\n", type); break; } @@ -643,7 +717,7 @@ ui->inpa = g_io_add_watch(ui->channel, G_IO_IN | G_IO_HUP | G_IO_ERR, UI_readable, ui); g_io_channel_unref(ui->channel); - gaim_debug(GAIM_DEBUG_MISC, "cui", "Got one\n"); + gaim_debug_misc("cui", "Got one\n"); return TRUE; } @@ -656,7 +730,7 @@ while (gaim_remote_session_exists(gaim_session)) gaim_session++; - gaim_debug(GAIM_DEBUG_MISC, "cui", "Session: %d\n", gaim_session); + gaim_debug_misc("cui", "Session: %d\n", gaim_session); if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) { mode_t m = umask(0177); @@ -720,7 +794,7 @@ unlink(buf); - gaim_debug(GAIM_DEBUG_MISC, "core", "Removed core\n"); + gaim_debug_misc("core", "Removed core\n"); return TRUE; #else