Mercurial > pidgin.yaz
diff src/core.c @ 3478:3da42b64304e
[gaim-migrate @ 3532]
This isn't complete--but it's cool. gaim-remote is now built and installed.
Eventually it will do lots of cool stuff--right now it just handles aim://
URI's. Try it out... when connected to OSCAR run:
gaim-remote uri "aim://goim?screenname=seanegn&message=Good+job+Sean"
Also, I made it so that if you're already running a Gaim session, and start
a new one, it won't auto-login and disconnect all your accounts from the
first instance. Useful if you accidentally hit the wrong button or something.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Fri, 30 Aug 2002 16:09:22 +0000 |
| parents | 1e12a24b7f27 |
| children | 6c32036050cf |
line wrap: on
line diff
--- a/src/core.c Fri Aug 30 03:39:00 2002 +0000 +++ b/src/core.c Fri Aug 30 16:09:22 2002 +0000 @@ -38,8 +38,10 @@ #include <string.h> #include "gaim.h" +#include "gaim-socket.h" static gint UI_fd = -1; +int gaim_session = 0; GSList *uis = NULL; static guchar *UI_build(guint32 *len, guchar type, guchar subtype, va_list args) @@ -132,6 +134,7 @@ static void meta_handler(struct UI *ui, guchar subtype, guchar *data) { + struct gaim_cui_packet *p; switch (subtype) { case CUI_META_LIST: break; @@ -151,6 +154,11 @@ g_source_remove(ui->inpa); g_free(ui); break; + case CUI_META_PING: + p = cui_packet_new(CUI_TYPE_META, CUI_META_ACK); + cui_send_packet(g_io_channel_unix_get_fd(ui->channel), p); + cui_packet_free(p); + break; default: debug_printf("unhandled meta subtype %d\n", subtype); break; @@ -289,6 +297,27 @@ return total; } +static void remote_handler(struct UI *ui, guchar subtype, guchar *data, int len) +{ + const char *resp; + char *send; + switch (subtype) { + case CUI_REMOTE_CONNECTIONS: + break; + case CUI_REMOTE_URI: + send = g_malloc(len + 1); + memcpy(send, data, len); + send[len] = 0; + resp = handle_uri(send); + g_free(send); + /* report error */ + break; + default: + debug_printf("Unhandled remote subtype %d\n", subtype); + break; + } +} + static gboolean UI_readable(GIOChannel *source, GIOCondition cond, gpointer data) { struct UI *ui = data; @@ -365,8 +394,11 @@ case CUI_TYPE_CHAT: chat_handler(ui, subtype, in); break; - */ - default: + */ + case CUI_TYPE_REMOTE: + remote_handler(ui, subtype, in, len); + break; + default: debug_printf("unhandled type %d\n", type); break; } @@ -402,18 +434,23 @@ { struct sockaddr_un saddr; gint fd; - + + while (gaim_session_exists(gaim_session)) + gaim_session++; + + debug_printf("session: %d\n", gaim_session); + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) { mode_t m = umask(0177); saddr.sun_family = AF_UNIX; g_snprintf(saddr.sun_path, 108, "%s/gaim_%s.%d", - g_get_tmp_dir(), g_get_user_name(), getpid()); + g_get_tmp_dir(), g_get_user_name(), gaim_session); if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) != -1) listen(fd, 100); else { g_log(NULL, G_LOG_LEVEL_CRITICAL, - "Failed to assign %s to a socket (Error: %s)", - saddr.sun_path, strerror(errno)); + "Failed to assign %s to a socket (Error: %s)", + saddr.sun_path, strerror(errno)); return -1; } umask(m); @@ -450,7 +487,7 @@ { char buf[1024]; close(UI_fd); - sprintf(buf, "%s/gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), getpid()); + sprintf(buf, "%s/gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), gaim_session); unlink(buf); debug_printf("Removed core\n"); }
