Mercurial > pidgin.yaz
diff src/util.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 | cfbdfe334975 |
children | 84df15473af6 |
line wrap: on
line diff
--- a/src/util.c Fri Aug 30 03:39:00 2002 +0000 +++ b/src/util.c Fri Aug 30 16:09:22 2002 +0000 @@ -32,7 +32,9 @@ #include <string.h> #include <sys/wait.h> #include <ctype.h> +#ifdef HAVE_ICONV #include <iconv.h> +#endif #include <math.h> #include "gaim.h" #include "prpl.h" @@ -1264,3 +1266,127 @@ return fp; } + +/* AIM URI's ARE FUN :-D */ +const char *handle_uri(char *uri) { + GString *str; + GSList *conn = connections; + struct gaim_connection *gc; + + debug_printf("Handling URI: %s\n", uri); + + /* Well, we'd better check to make sure we have at least one + AIM account connected. */ + while (gc = conn->data) { + if (gc->protocol == PROTO_TOC) { + break; + } + conn = conn->next; + } + + if (gc == NULL) + return "Not connected to AIM"; + + /* aim://goim?screenname=screenname&message=message */ + if (!g_strncasecmp(uri, "aim://goim?", strlen("aim://goim?"))) { + char *who, *what; + struct conversation *c; + uri = uri + strlen("aim://goim?"); + + if (!(who = strstr(uri, "screenname="))) { + return "No screenname given."; + } + /* spaces are encoded as +'s */ + who = who + strlen("screenname="); + str = g_string_new(NULL); + while (*who && (*who != '&')) { + g_string_append_c(str, *who == '+' ? ' ' : *who); + who++; + } + who = g_strdup(str->str); + g_string_free(str, TRUE); + + what = strstr(uri, "message="); + if (what) { + what = what + strlen("message="); + str = g_string_new(NULL); + while (*what && (*what != '&' || !g_strncasecmp(what, "&", 5))) { + g_string_append_c(str, *what == '+' ? ' ' : *what); + what++; + } + what = g_strdup(str->str); + g_string_free(str, TRUE); + } + + c = new_conversation(who); + g_free(who); + if (what) { + int finish; + gtk_editable_insert_text(GTK_EDITABLE(c->entry), + what, strlen(what), &finish); + g_free(what); + } + } else if (!g_strncasecmp(uri, "aim://addbuddy?", strlen("aim://addbuddy?"))) { + char *who, *group; + uri = uri + strlen("aim://addbuddy?"); + /* spaces are encoded as +'s */ + + if (!(who = strstr(uri, "screenname="))) { + return "No screenname given."; + } + who = who + strlen("screenname="); + str = g_string_new(NULL); + while (*who && (*who != '&')) { + g_string_append_c(str, *who == '+' ? ' ' : *who); + who++; + } + who = g_strdup(str->str); + g_string_free(str, TRUE); + + group = strstr(uri, "group="); + if (group) { + group = group + strlen("group="); + str = g_string_new(NULL); + while (*group && (*group != '&' || !g_strncasecmp(group, "&", 5))) { + g_string_append_c(str, *group == '+' ? ' ' : *group); + group++; + } + group = g_strdup(str->str); + g_string_free(str, TRUE); + } + debug_printf("who: %s\n", who); + show_add_buddy(gc, who, group, NULL); + g_free(who); + if (group) + g_free(group); + } else if (!g_strncasecmp(uri, "aim://gochat?", strlen("aim://gochat?"))) { + char *room; + GList *chat=NULL; + int exch = 5; + + uri = uri + strlen("aim://gochat?"); + /* spaces are encoded as +'s */ + + if (!(room = strstr(uri, "roomname="))) { + return "No roomname given."; + } + room = room + strlen("roomname="); + str = g_string_new(NULL); + while (*room && (*room != '&')) { + g_string_append_c(str, *room == '+' ? ' ' : *room); + room++; + } + room = g_strdup(str->str); + g_string_free(str, TRUE); + chat = g_list_append(NULL, room); + chat = g_list_append(chat, &exch); + serv_join_chat(gc, chat); + g_free(room); + g_list_free(chat); + } else { + return "Invalid AIM URI"; + } + + + return NULL; +}