| 1347 FALSE) && sd->data) |
1347 FALSE) && sd->data) |
| 1348 { |
1348 { |
| 1349 GaimGroup *group = NULL; |
1349 GaimGroup *group = NULL; |
| 1350 GtkTreePath *path = NULL; |
1350 GtkTreePath *path = NULL; |
| 1351 GtkTreeViewDropPosition position; |
1351 GtkTreeViewDropPosition position; |
| |
1352 GaimAccount *account; |
| 1352 char *protocol = NULL; |
1353 char *protocol = NULL; |
| 1353 char *username = NULL; |
1354 char *username = NULL; |
| 1354 char *alias = NULL; |
1355 char *alias = NULL; |
| 1355 char *contact_str; |
|
| 1356 char *c, *s; |
|
| 1357 |
1356 |
| 1358 if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), |
1357 if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), |
| 1359 x, y, &path, &position)) |
1358 x, y, &path, &position)) |
| 1360 { |
1359 { |
| 1361 GtkTreeIter iter; |
1360 GtkTreeIter iter; |
| 1381 { |
1380 { |
| 1382 group = (GaimGroup *)node; |
1381 group = (GaimGroup *)node; |
| 1383 } |
1382 } |
| 1384 } |
1383 } |
| 1385 |
1384 |
| 1386 contact_str = g_strndup(sd->data, sd->length); |
1385 if (gaim_gtk_parse_x_im_contact(sd->data, FALSE, &account, |
| 1387 |
1386 &protocol, &username, &alias)) |
| 1388 s = contact_str; |
|
| 1389 |
|
| 1390 while (*s != '\r' && *s != '\n' && *s != '\0') |
|
| 1391 { |
1387 { |
| 1392 char *key, *value; |
|
| 1393 |
|
| 1394 key = s; |
|
| 1395 |
|
| 1396 /* Grab the key */ |
|
| 1397 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ') |
|
| 1398 s++; |
|
| 1399 |
|
| 1400 if (*s == '\r') s++; |
|
| 1401 |
|
| 1402 if (*s == '\n') |
|
| 1403 { |
|
| 1404 s++; |
|
| 1405 continue; |
|
| 1406 } |
|
| 1407 |
|
| 1408 if (*s != '\0') *s++ = '\0'; |
|
| 1409 |
|
| 1410 /* Clear past any whitespace */ |
|
| 1411 while (*s != '\0' && *s == ' ') |
|
| 1412 s++; |
|
| 1413 |
|
| 1414 /* Now let's grab until the end of the line. */ |
|
| 1415 value = s; |
|
| 1416 |
|
| 1417 while (*s != '\r' && *s != '\n' && *s != '\0') |
|
| 1418 s++; |
|
| 1419 |
|
| 1420 if (*s == '\r') *s++ = '\0'; |
|
| 1421 if (*s == '\n') *s++ = '\0'; |
|
| 1422 |
|
| 1423 if ((c = strchr(key, ':')) != NULL) |
|
| 1424 { |
|
| 1425 if (!g_ascii_strcasecmp(key, "X-IM-Username:")) |
|
| 1426 username = g_strdup(value); |
|
| 1427 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:")) |
|
| 1428 protocol = g_strdup(value); |
|
| 1429 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:")) |
|
| 1430 alias = g_strdup(value); |
|
| 1431 } |
|
| 1432 } |
|
| 1433 |
|
| 1434 if (username != NULL && protocol != NULL) |
|
| 1435 { |
|
| 1436 GaimAccount *account = NULL; |
|
| 1437 GList *l; |
|
| 1438 const char *protoname; |
|
| 1439 |
|
| 1440 for (l = gaim_connections_get_all(); l != NULL; l = l->next) |
|
| 1441 { |
|
| 1442 GaimConnection *gc = (GaimConnection *)l->data; |
|
| 1443 account = gaim_connection_get_account(gc); |
|
| 1444 |
|
| 1445 protoname = |
|
| 1446 GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->list_icon(account, |
|
| 1447 NULL); |
|
| 1448 |
|
| 1449 if (!strcmp(protoname, protocol)) |
|
| 1450 break; |
|
| 1451 |
|
| 1452 account = NULL; |
|
| 1453 } |
|
| 1454 |
|
| 1455 /* Special case for AIM and ICQ */ |
|
| 1456 if (account == NULL && (!strcmp(protocol, "aim") || |
|
| 1457 !strcmp(protocol, "icq"))) |
|
| 1458 { |
|
| 1459 |
|
| 1460 for (l = gaim_connections_get_all(); l != NULL; l = l->next) |
|
| 1461 { |
|
| 1462 GaimConnection *gc = (GaimConnection *)l->data; |
|
| 1463 account = gaim_connection_get_account(gc); |
|
| 1464 |
|
| 1465 protoname = |
|
| 1466 GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->list_icon(account, |
|
| 1467 NULL); |
|
| 1468 |
|
| 1469 if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq")) |
|
| 1470 break; |
|
| 1471 |
|
| 1472 account = NULL; |
|
| 1473 } |
|
| 1474 } |
|
| 1475 |
|
| 1476 if (account == NULL) |
1388 if (account == NULL) |
| 1477 { |
1389 { |
| 1478 gaim_notify_error(NULL, NULL, |
1390 gaim_notify_error(NULL, NULL, |
| 1479 _("You are not currently signed on with an account that " |
1391 _("You are not currently signed on with an account that " |
| 1480 "can add that buddy."), NULL); |
1392 "can add that buddy."), NULL); |
| 1488 } |
1400 } |
| 1489 |
1401 |
| 1490 if (username != NULL) g_free(username); |
1402 if (username != NULL) g_free(username); |
| 1491 if (protocol != NULL) g_free(protocol); |
1403 if (protocol != NULL) g_free(protocol); |
| 1492 if (alias != NULL) g_free(alias); |
1404 if (alias != NULL) g_free(alias); |
| 1493 |
|
| 1494 g_free(contact_str); |
|
| 1495 |
1405 |
| 1496 if (path != NULL) |
1406 if (path != NULL) |
| 1497 gtk_tree_path_free(path); |
1407 gtk_tree_path_free(path); |
| 1498 |
1408 |
| 1499 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
1409 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |