comparison 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
comparison
equal deleted inserted replaced
3477:db5dd21aa345 3478:3da42b64304e
30 #include <sys/types.h> 30 #include <sys/types.h>
31 #include <sys/stat.h> 31 #include <sys/stat.h>
32 #include <string.h> 32 #include <string.h>
33 #include <sys/wait.h> 33 #include <sys/wait.h>
34 #include <ctype.h> 34 #include <ctype.h>
35 #ifdef HAVE_ICONV
35 #include <iconv.h> 36 #include <iconv.h>
37 #endif
36 #include <math.h> 38 #include <math.h>
37 #include "gaim.h" 39 #include "gaim.h"
38 #include "prpl.h" 40 #include "prpl.h"
39 #include "gtkspell.h" 41 #include "gtkspell.h"
40 42
1262 debug_printf("Error: g_get_tmp_dir() failed in gaim_mkstemp()!\n"); 1264 debug_printf("Error: g_get_tmp_dir() failed in gaim_mkstemp()!\n");
1263 } 1265 }
1264 1266
1265 return fp; 1267 return fp;
1266 } 1268 }
1269
1270 /* AIM URI's ARE FUN :-D */
1271 const char *handle_uri(char *uri) {
1272 GString *str;
1273 GSList *conn = connections;
1274 struct gaim_connection *gc;
1275
1276 debug_printf("Handling URI: %s\n", uri);
1277
1278 /* Well, we'd better check to make sure we have at least one
1279 AIM account connected. */
1280 while (gc = conn->data) {
1281 if (gc->protocol == PROTO_TOC) {
1282 break;
1283 }
1284 conn = conn->next;
1285 }
1286
1287 if (gc == NULL)
1288 return "Not connected to AIM";
1289
1290 /* aim://goim?screenname=screenname&message=message */
1291 if (!g_strncasecmp(uri, "aim://goim?", strlen("aim://goim?"))) {
1292 char *who, *what;
1293 struct conversation *c;
1294 uri = uri + strlen("aim://goim?");
1295
1296 if (!(who = strstr(uri, "screenname="))) {
1297 return "No screenname given.";
1298 }
1299 /* spaces are encoded as +'s */
1300 who = who + strlen("screenname=");
1301 str = g_string_new(NULL);
1302 while (*who && (*who != '&')) {
1303 g_string_append_c(str, *who == '+' ? ' ' : *who);
1304 who++;
1305 }
1306 who = g_strdup(str->str);
1307 g_string_free(str, TRUE);
1308
1309 what = strstr(uri, "message=");
1310 if (what) {
1311 what = what + strlen("message=");
1312 str = g_string_new(NULL);
1313 while (*what && (*what != '&' || !g_strncasecmp(what, "&amp;", 5))) {
1314 g_string_append_c(str, *what == '+' ? ' ' : *what);
1315 what++;
1316 }
1317 what = g_strdup(str->str);
1318 g_string_free(str, TRUE);
1319 }
1320
1321 c = new_conversation(who);
1322 g_free(who);
1323 if (what) {
1324 int finish;
1325 gtk_editable_insert_text(GTK_EDITABLE(c->entry),
1326 what, strlen(what), &finish);
1327 g_free(what);
1328 }
1329 } else if (!g_strncasecmp(uri, "aim://addbuddy?", strlen("aim://addbuddy?"))) {
1330 char *who, *group;
1331 uri = uri + strlen("aim://addbuddy?");
1332 /* spaces are encoded as +'s */
1333
1334 if (!(who = strstr(uri, "screenname="))) {
1335 return "No screenname given.";
1336 }
1337 who = who + strlen("screenname=");
1338 str = g_string_new(NULL);
1339 while (*who && (*who != '&')) {
1340 g_string_append_c(str, *who == '+' ? ' ' : *who);
1341 who++;
1342 }
1343 who = g_strdup(str->str);
1344 g_string_free(str, TRUE);
1345
1346 group = strstr(uri, "group=");
1347 if (group) {
1348 group = group + strlen("group=");
1349 str = g_string_new(NULL);
1350 while (*group && (*group != '&' || !g_strncasecmp(group, "&amp;", 5))) {
1351 g_string_append_c(str, *group == '+' ? ' ' : *group);
1352 group++;
1353 }
1354 group = g_strdup(str->str);
1355 g_string_free(str, TRUE);
1356 }
1357 debug_printf("who: %s\n", who);
1358 show_add_buddy(gc, who, group, NULL);
1359 g_free(who);
1360 if (group)
1361 g_free(group);
1362 } else if (!g_strncasecmp(uri, "aim://gochat?", strlen("aim://gochat?"))) {
1363 char *room;
1364 GList *chat=NULL;
1365 int exch = 5;
1366
1367 uri = uri + strlen("aim://gochat?");
1368 /* spaces are encoded as +'s */
1369
1370 if (!(room = strstr(uri, "roomname="))) {
1371 return "No roomname given.";
1372 }
1373 room = room + strlen("roomname=");
1374 str = g_string_new(NULL);
1375 while (*room && (*room != '&')) {
1376 g_string_append_c(str, *room == '+' ? ' ' : *room);
1377 room++;
1378 }
1379 room = g_strdup(str->str);
1380 g_string_free(str, TRUE);
1381 chat = g_list_append(NULL, room);
1382 chat = g_list_append(chat, &exch);
1383 serv_join_chat(gc, chat);
1384 g_free(room);
1385 g_list_free(chat);
1386 } else {
1387 return "Invalid AIM URI";
1388 }
1389
1390
1391 return NULL;
1392 }