comparison src/buddy.c @ 4491:3196d9044a45

[gaim-migrate @ 4766] aim_user is dead. long live gaim_account. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 31 Jan 2003 13:03:47 +0000
parents 62c1e5e656d0
children 7521e29658bc
comparison
equal deleted inserted replaced
4490:70b892694e0b 4491:3196d9044a45
181 /* buddy's offline */ 181 /* buddy's offline */
182 return; 182 return;
183 } 183 }
184 184
185 if (g_strcasecmp(b->name, prevname)) { 185 if (g_strcasecmp(b->name, prevname)) {
186 bs->connlist = g_slist_remove(bs->connlist, b->user->gc); 186 bs->connlist = g_slist_remove(bs->connlist, b->account->gc);
187 if (!bs->connlist) { 187 if (!bs->connlist) {
188 gs->members = g_slist_remove(gs->members, bs); 188 gs->members = g_slist_remove(gs->members, bs);
189 if (bs->log_timer > 0) 189 if (bs->log_timer > 0)
190 g_source_remove(bs->log_timer); 190 g_source_remove(bs->log_timer);
191 bs->log_timer = 0; 191 bs->log_timer = 0;
353 return; 353 return;
354 } 354 }
355 if (g) { 355 if (g) {
356 for (c = g->members; c; c = c->next) { 356 for (c = g->members; c; c = c->next) {
357 b = c->data; 357 b = c->data;
358 if(b->user->gc) { 358 if(b->account->gc) {
359 if(b->present) 359 if(b->present)
360 on++; 360 on++;
361 total++; 361 total++;
362 } 362 }
363 } 363 }
441 c = gaim_find_conversation(b->name); 441 c = gaim_find_conversation(b->name);
442 442
443 if (c != NULL) 443 if (c != NULL)
444 gaim_window_show(gaim_conversation_get_window(c)); 444 gaim_window_show(gaim_conversation_get_window(c));
445 else 445 else
446 c = gaim_conversation_new(GAIM_CONV_IM, b->user, b->name); 446 c = gaim_conversation_new(GAIM_CONV_IM, b->account, b->name);
447 } 447 }
448 448
449 void pressed_im(GtkWidget *widget, struct buddy_show *b) 449 void pressed_im(GtkWidget *widget, struct buddy_show *b)
450 { 450 {
451 struct gaim_conversation *c; 451 struct gaim_conversation *c;
453 c = gaim_find_conversation(b->name); 453 c = gaim_find_conversation(b->name);
454 454
455 if (c != NULL) { 455 if (c != NULL) {
456 gaim_window_show(gaim_conversation_get_window(c)); 456 gaim_window_show(gaim_conversation_get_window(c));
457 } else { 457 } else {
458 struct aim_user *user; 458 struct gaim_account *account;
459 459
460 user = ((struct gaim_connection *)b->connlist->data)->user; 460 account = ((struct gaim_connection *)b->connlist->data)->account;
461 c = gaim_conversation_new(GAIM_CONV_IM, user, b->name); 461 c = gaim_conversation_new(GAIM_CONV_IM, account, b->name);
462 } 462 }
463 } 463 }
464 464
465 void pressed_log(GtkWidget *widget, char *name) 465 void pressed_log(GtkWidget *widget, char *name)
466 { 466 {
473 } 473 }
474 474
475 void pressed_alias_bs(GtkWidget *widget, struct buddy_show *bs) 475 void pressed_alias_bs(GtkWidget *widget, struct buddy_show *bs)
476 { 476 {
477 struct gaim_connection *gc = bs->connlist->data; 477 struct gaim_connection *gc = bs->connlist->data;
478 alias_dialog_bud(find_buddy(gc->user, bs->name)); 478 alias_dialog_bud(find_buddy(gc->account, bs->name));
479 } 479 }
480 480
481 void pressed_alias_bud(GtkWidget *widget, struct buddy *b) 481 void pressed_alias_bud(GtkWidget *widget, struct buddy *b)
482 { 482 {
483 alias_dialog_bud(b); 483 alias_dialog_bud(b);
496 if (!b->connlist) 496 if (!b->connlist)
497 return FALSE; 497 return FALSE;
498 498
499 if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { 499 if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
500 struct gaim_conversation *c; 500 struct gaim_conversation *c;
501 struct aim_user *user; 501 struct gaim_account *account;
502 502
503 user = ((struct gaim_connection *)b->connlist->data)->user; 503 account = ((struct gaim_connection *)b->connlist->data)->account;
504 504
505 c = gaim_find_conversation(b->name); 505 c = gaim_find_conversation(b->name);
506 506
507 if (c != NULL) { 507 if (c != NULL) {
508 struct gaim_window *win = gaim_conversation_get_window(c); 508 struct gaim_window *win = gaim_conversation_get_window(c);
509 size_t index = gaim_conversation_get_index(c); 509 size_t index = gaim_conversation_get_index(c);
510 510
511 gaim_window_switch_conversation(win, index); 511 gaim_window_switch_conversation(win, index);
512 gaim_window_show(win); 512 gaim_window_show(win);
513 513
514 gaim_conversation_set_user(c, user); 514 gaim_conversation_set_account(c, account);
515 } 515 }
516 else 516 else
517 c = gaim_conversation_new(GAIM_CONV_IM, user, b->name); 517 c = gaim_conversation_new(GAIM_CONV_IM, account, b->name);
518 518
519 gaim_window_switch_conversation(gaim_conversation_get_window(c), 519 gaim_window_switch_conversation(gaim_conversation_get_window(c),
520 gaim_conversation_get_index(c)); 520 gaim_conversation_get_index(c));
521 521
522 gaim_window_raise(gaim_conversation_get_window(c)); 522 gaim_window_raise(gaim_conversation_get_window(c));
559 gtk_widget_show(button); 559 gtk_widget_show(button);
560 560
561 button = gtk_menu_item_new_with_label(_("Add Buddy Pounce")); 561 button = gtk_menu_item_new_with_label(_("Add Buddy Pounce"));
562 g_signal_connect(GTK_OBJECT(button), "activate", 562 g_signal_connect(GTK_OBJECT(button), "activate",
563 G_CALLBACK(new_bp_callback), 563 G_CALLBACK(new_bp_callback),
564 cn ? find_buddy(((struct gaim_connection *)cn->data)->user, b->name) : NULL); 564 cn ? find_buddy(((struct gaim_connection *)cn->data)->account, b->name) : NULL);
565 gtk_menu_append(GTK_MENU(menu), button); 565 gtk_menu_append(GTK_MENU(menu), button);
566 gtk_widget_show(button); 566 gtk_widget_show(button);
567 567
568 button = gtk_menu_item_new_with_label(_("View Log")); 568 button = gtk_menu_item_new_with_label(_("View Log"));
569 g_signal_connect(GTK_OBJECT(button), "activate", 569 g_signal_connect(GTK_OBJECT(button), "activate",
749 gtk_widget_show(button); 749 gtk_widget_show(button);
750 750
751 /* 751 /*
752 * Add protocol-specific edit buddy menu items if they exist 752 * Add protocol-specific edit buddy menu items if they exist
753 */ 753 */
754 if (b->user->gc && b->user->gc->prpl->edit_buddy_menu) { 754 if (b->account->gc && b->account->gc->prpl->edit_buddy_menu) {
755 GList *mo = mo_top = b->user->gc->prpl->edit_buddy_menu(b->user->gc, b->name); 755 GList *mo = mo_top = b->account->gc->prpl->edit_buddy_menu(b->account->gc, b->name);
756 756
757 while (mo) { 757 while (mo) {
758 struct proto_buddy_menu *pbm = mo->data; 758 struct proto_buddy_menu *pbm = mo->data;
759 GtkWidget *button; 759 GtkWidget *button;
760 760
801 801
802 gs = find_group_show(rem_g->name); 802 gs = find_group_show(rem_g->name);
803 if (gs) { 803 if (gs) {
804 bs = find_buddy_show(gs, rem_b->name); 804 bs = find_buddy_show(gs, rem_b->name);
805 if (bs) { 805 if (bs) {
806 if (g_slist_find(bs->connlist, rem_b->user->gc)) { 806 if (g_slist_find(bs->connlist, rem_b->account->gc)) {
807 bs->connlist = g_slist_remove(bs->connlist, rem_b->user->gc); 807 bs->connlist = g_slist_remove(bs->connlist, rem_b->account->gc);
808 if (!g_slist_length(bs->connlist)) { 808 if (!g_slist_length(bs->connlist)) {
809 gs->members = g_slist_remove(gs->members, bs); 809 gs->members = g_slist_remove(gs->members, bs);
810 if (bs->log_timer > 0) 810 if (bs->log_timer > 0)
811 g_source_remove(bs->log_timer); 811 g_source_remove(bs->log_timer);
812 bs->log_timer = 0; 812 bs->log_timer = 0;
934 if (b->present) { 934 if (b->present) {
935 if (!gs) 935 if (!gs)
936 gs = new_group_show(g->name); 936 gs = new_group_show(g->name);
937 bs = find_buddy_show(gs, b->name); 937 bs = find_buddy_show(gs, b->name);
938 if (!bs) { 938 if (!bs) {
939 if (b->user->gc->prpl->list_icon) 939 if (b->account->gc->prpl->list_icon)
940 bs = new_buddy_show(gs, b, 940 bs = new_buddy_show(gs, b,
941 b->user->gc->prpl->list_icon(b-> 941 b->account->gc->prpl->list_icon(b->
942 uc)); 942 uc));
943 else 943 else
944 bs = new_buddy_show(gs, b, (char **)no_icon_xpm); 944 bs = new_buddy_show(gs, b, (char **)no_icon_xpm);
945 } 945 }
946 bs->connlist = g_slist_append(bs->connlist, b->user->gc); 946 bs->connlist = g_slist_append(bs->connlist, b->account->gc);
947 update_num_group(gs); 947 update_num_group(gs);
948 } 948 }
949 } 949 }
950 } 950 }
951 update_idle_times(); 951 update_idle_times();
959 959
960 for (l = gaim_get_ims(); l != NULL; l = l->next) { 960 for (l = gaim_get_ims(); l != NULL; l = l->next) {
961 c = (struct gaim_conversation *)l->data; 961 c = (struct gaim_conversation *)l->data;
962 962
963 if (!g_slist_find(connections, gaim_conversation_get_gc(c))) { 963 if (!g_slist_find(connections, gaim_conversation_get_gc(c))) {
964 struct aim_user *user; 964 struct gaim_account *account;
965 965
966 if (connections == NULL) 966 if (connections == NULL)
967 user = ((struct gaim_connection *)connections->data)->user; 967 account = ((struct gaim_connection *)connections->data)->account;
968 else 968 else
969 user = NULL; 969 account = NULL;
970 970
971 gaim_conversation_set_user(c, user); 971 gaim_conversation_set_account(c, account);
972 } 972 }
973 } 973 }
974 } 974 }
975 975
976 static void edit_tree_move(GtkCTree *ctree, GtkCTreeNode *child, 976 static void edit_tree_move(GtkCTree *ctree, GtkCTreeNode *child,
1110 mem = g->members; 1110 mem = g->members;
1111 1111
1112 while (mem) { 1112 while (mem) {
1113 char buf[256]; 1113 char buf[256];
1114 b = (struct buddy *)mem->data; 1114 b = (struct buddy *)mem->data;
1115 if(b->user->gc) { 1115 if(b->account->gc) {
1116 if (get_buddy_alias_only(b)) { 1116 if (get_buddy_alias_only(b)) {
1117 g_snprintf(buf, sizeof(buf), "%s (%s)", b->name, get_buddy_alias(b)); 1117 g_snprintf(buf, sizeof(buf), "%s (%s)", b->name, get_buddy_alias(b));
1118 text[0] = buf; 1118 text[0] = buf;
1119 } else 1119 } else
1120 text[0] = b->name; 1120 text[0] = b->name;
1148 update_num_group(gs); 1148 update_num_group(gs);
1149 1149
1150 if (!blist) 1150 if (!blist)
1151 return; 1151 return;
1152 1152
1153 if(!b->user->gc) 1153 if(!b->account->gc)
1154 return; 1154 return;
1155 1155
1156 p = gtk_ctree_find_by_row_data(GTK_CTREE(edittree), NULL, g); 1156 p = gtk_ctree_find_by_row_data(GTK_CTREE(edittree), NULL, g);
1157 if (get_buddy_alias_only(b)) { 1157 if (get_buddy_alias_only(b)) {
1158 g_snprintf(buf, sizeof(buf), "%s (%s)", b->name, get_buddy_alias(b)); 1158 g_snprintf(buf, sizeof(buf), "%s (%s)", b->name, get_buddy_alias(b));
1198 type = (int *)gtk_ctree_node_get_row_data(GTK_CTREE(edittree), node); 1198 type = (int *)gtk_ctree_node_get_row_data(GTK_CTREE(edittree), node);
1199 1199
1200 if (*type == EDIT_BUDDY) { 1200 if (*type == EDIT_BUDDY) {
1201 b = (struct buddy *)type; 1201 b = (struct buddy *)type;
1202 g = find_group_by_buddy(b); 1202 g = find_group_by_buddy(b);
1203 serv_remove_buddy(b->user->gc, b->name, g->name); 1203 serv_remove_buddy(b->account->gc, b->name, g->name);
1204 remove_buddy(b); 1204 remove_buddy(b);
1205 gaim_blist_save(); 1205 gaim_blist_save();
1206 } else if (*type == EDIT_GROUP) { 1206 } else if (*type == EDIT_GROUP) {
1207 remove_group((struct group *)type); 1207 remove_group((struct group *)type);
1208 gaim_blist_save(); 1208 gaim_blist_save();
1234 1234
1235 if (*type == EDIT_BUDDY) { 1235 if (*type == EDIT_BUDDY) {
1236 struct buddy *b = (struct buddy *)type; 1236 struct buddy *b = (struct buddy *)type;
1237 struct group *g = find_group_by_buddy(b); 1237 struct group *g = find_group_by_buddy(b);
1238 grp = g->name; 1238 grp = g->name;
1239 gc = b->user->gc; 1239 gc = b->account->gc;
1240 } else if (*type == EDIT_GROUP) { 1240 } else if (*type == EDIT_GROUP) {
1241 struct group *g = (struct group *)type; 1241 struct group *g = (struct group *)type;
1242 grp = g->name; 1242 grp = g->name;
1243 if(g->members) 1243 if(g->members)
1244 gc = ((struct buddy *)g->members->data)->user->gc; 1244 gc = ((struct buddy *)g->members->data)->account->gc;
1245 else 1245 else
1246 gc = connections->data; 1246 gc = connections->data;
1247 } else { 1247 } else {
1248 gc = (struct gaim_connection *)type; 1248 gc = (struct gaim_connection *)type;
1249 } 1249 }
1262 i = GTK_CLIST(edittree)->selection; 1262 i = GTK_CLIST(edittree)->selection;
1263 if (i) { 1263 if (i) {
1264 node = i->data; 1264 node = i->data;
1265 type = (int *)gtk_ctree_node_get_row_data(GTK_CTREE(edittree), node); 1265 type = (int *)gtk_ctree_node_get_row_data(GTK_CTREE(edittree), node);
1266 if (*type == EDIT_BUDDY) 1266 if (*type == EDIT_BUDDY)
1267 gc = ((struct buddy *)type)->user->gc; 1267 gc = ((struct buddy *)type)->account->gc;
1268 else if (*type == EDIT_GROUP) 1268 else if (*type == EDIT_GROUP)
1269 gc = connections->data; 1269 gc = connections->data;
1270 else 1270 else
1271 gc = (struct gaim_connection *)type; 1271 gc = (struct gaim_connection *)type;
1272 } 1272 }
1276 static void im_callback(GtkWidget *widget, GtkTree *tree) 1276 static void im_callback(GtkWidget *widget, GtkTree *tree)
1277 { 1277 {
1278 GList *i; 1278 GList *i;
1279 struct buddy_show *b = NULL; 1279 struct buddy_show *b = NULL;
1280 struct gaim_conversation *c; 1280 struct gaim_conversation *c;
1281 struct aim_user *user; 1281 struct gaim_account *account;
1282 1282
1283 i = GTK_TREE_SELECTION_OLD(tree); 1283 i = GTK_TREE_SELECTION_OLD(tree);
1284 if (i) { 1284 if (i) {
1285 b = gtk_object_get_user_data(GTK_OBJECT(i->data)); 1285 b = gtk_object_get_user_data(GTK_OBJECT(i->data));
1286 } 1286 }
1289 return; 1289 return;
1290 } 1290 }
1291 if (!b->name) 1291 if (!b->name)
1292 return; 1292 return;
1293 1293
1294 user = ((struct gaim_connection *)b->connlist->data)->user; 1294 account = ((struct gaim_connection *)b->connlist->data)->account;
1295 1295
1296 c = gaim_find_conversation(b->name); 1296 c = gaim_find_conversation(b->name);
1297 1297
1298 if (c == NULL) 1298 if (c == NULL)
1299 c = gaim_conversation_new(GAIM_CONV_IM, user, b->name); 1299 c = gaim_conversation_new(GAIM_CONV_IM, account, b->name);
1300 else { 1300 else {
1301 gaim_conversation_set_user(c, user); 1301 gaim_conversation_set_account(c, account);
1302 gaim_window_raise(gaim_conversation_get_window(c)); 1302 gaim_window_raise(gaim_conversation_get_window(c));
1303 } 1303 }
1304 } 1304 }
1305 1305
1306 static void info_callback(GtkWidget *widget, GtkTree *tree) 1306 static void info_callback(GtkWidget *widget, GtkTree *tree)
1370 { 1370 {
1371 char *who; 1371 char *who;
1372 1372
1373 struct buddy_pounce *b; 1373 struct buddy_pounce *b;
1374 struct gaim_conversation *c; 1374 struct gaim_conversation *c;
1375 struct aim_user *u; 1375 struct gaim_account *account;
1376 1376
1377 GList *bp = buddy_pounces; 1377 GList *bp = buddy_pounces;
1378 1378
1379 who = g_strdup(normalize (name)); 1379 who = g_strdup(normalize (name));
1380 1380
1383 bp = bp->next; /* increment the list here because rem_bp can make our handle bad */ 1383 bp = bp->next; /* increment the list here because rem_bp can make our handle bad */
1384 1384
1385 if (!(b->options & when)) 1385 if (!(b->options & when))
1386 continue; 1386 continue;
1387 1387
1388 u = find_user(b->pouncer, b->protocol); /* find our user */ 1388 account = gaim_account_find(b->pouncer, b->protocol); /* find our user */
1389 if (u == NULL) 1389 if (account == NULL)
1390 continue; 1390 continue;
1391 1391
1392 /* check and see if we're signed on as the pouncer */ 1392 /* check and see if we're signed on as the pouncer */
1393 if (u->gc != gc) 1393 if (account->gc != gc)
1394 continue; 1394 continue;
1395 1395
1396 if (!g_strcasecmp(who, normalize (b->name))) { /* find someone to pounce */ 1396 if (!g_strcasecmp(who, normalize (b->name))) { /* find someone to pounce */
1397 if (b->options & OPT_POUNCE_POPUP) { 1397 if (b->options & OPT_POUNCE_POPUP) {
1398 c = gaim_find_conversation(name); 1398 c = gaim_find_conversation(name);
1399 1399
1400 if (c == NULL) 1400 if (c == NULL)
1401 c = gaim_conversation_new(GAIM_CONV_IM, u, name); 1401 c = gaim_conversation_new(GAIM_CONV_IM, account, name);
1402 else 1402 else
1403 gaim_conversation_set_user(c, u); 1403 gaim_conversation_set_account(c, account);
1404 } 1404 }
1405 if (b->options & OPT_POUNCE_NOTIFY) { 1405 if (b->options & OPT_POUNCE_NOTIFY) {
1406 char tmp[1024]; 1406 char tmp[1024];
1407 1407
1408 /* I know the line below is really ugly. I only did it this way 1408 /* I know the line below is really ugly. I only did it this way
1419 if (b->options & OPT_POUNCE_SEND_IM) { 1419 if (b->options & OPT_POUNCE_SEND_IM) {
1420 if (strlen(b->message) > 0) { 1420 if (strlen(b->message) > 0) {
1421 c = gaim_find_conversation(name); 1421 c = gaim_find_conversation(name);
1422 1422
1423 if (c == NULL) 1423 if (c == NULL)
1424 c = gaim_conversation_new(GAIM_CONV_IM, u, name); 1424 c = gaim_conversation_new(GAIM_CONV_IM, account, name);
1425 else 1425 else
1426 gaim_conversation_set_user(c, u); 1426 gaim_conversation_set_account(c, account);
1427 1427
1428 gaim_conversation_write(c, NULL, b->message, -1, 1428 gaim_conversation_write(c, NULL, b->message, -1,
1429 WFLAG_SEND, time(NULL)); 1429 WFLAG_SEND, time(NULL));
1430 1430
1431 serv_send_im(u->gc, name, b->message, -1, 0); 1431 serv_send_im(account->gc, name, b->message, -1, 0);
1432 } 1432 }
1433 } 1433 }
1434 if (b->options & OPT_POUNCE_COMMAND) { 1434 if (b->options & OPT_POUNCE_COMMAND) {
1435 #ifndef _WIN32 1435 #ifndef _WIN32
1436 int pid = fork(); 1436 int pid = fork();
1473 } 1473 }
1474 1474
1475 static void new_bp_callback(GtkWidget *w, struct buddy *b) 1475 static void new_bp_callback(GtkWidget *w, struct buddy *b)
1476 { 1476 {
1477 if (b) 1477 if (b)
1478 show_new_bp(b->name, b->user->gc, b->idle, b->uc & UC_UNAVAILABLE, NULL); 1478 show_new_bp(b->name, b->account->gc, b->idle, b->uc & UC_UNAVAILABLE, NULL);
1479 else 1479 else
1480 show_new_bp(NULL, NULL, 0, 0, NULL); 1480 show_new_bp(NULL, NULL, 0, 0, NULL);
1481 } 1481 }
1482 1482
1483 static void edit_bp_callback(GtkWidget *w, struct buddy_pounce *b) 1483 static void edit_bp_callback(GtkWidget *w, struct buddy_pounce *b)
1964 /* um.... what do we have to do here? just update the pixmap? */ 1964 /* um.... what do we have to do here? just update the pixmap? */
1965 GdkPixmap *pm; 1965 GdkPixmap *pm;
1966 GdkBitmap *bm; 1966 GdkBitmap *bm;
1967 gchar **xpm = NULL; 1967 gchar **xpm = NULL;
1968 struct gaim_connection *gc = b->connlist->data; 1968 struct gaim_connection *gc = b->connlist->data;
1969 struct buddy *light = find_buddy(gc->user, b->name); 1969 struct buddy *light = find_buddy(gc->account, b->name);
1970 if (gc->prpl->list_icon) 1970 if (gc->prpl->list_icon)
1971 xpm = gc->prpl->list_icon(light->uc); 1971 xpm = gc->prpl->list_icon(light->uc);
1972 if (xpm == NULL) 1972 if (xpm == NULL)
1973 xpm = (char **)no_icon_xpm; 1973 xpm = (char **)no_icon_xpm;
1974 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, xpm); 1974 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, xpm);
2081 2081
2082 time(&t); 2082 time(&t);
2083 if (!bs->connlist) 2083 if (!bs->connlist)
2084 return; 2084 return;
2085 gc = bs->connlist->data; 2085 gc = bs->connlist->data;
2086 b = find_buddy(gc->user, bs->name); 2086 b = find_buddy(gc->account, bs->name);
2087 if (!b) 2087 if (!b)
2088 return; 2088 return;
2089 ihrs = (t - b->idle) / 3600; 2089 ihrs = (t - b->idle) / 3600;
2090 imin = ((t - b->idle) / 60) % 60; 2090 imin = ((t - b->idle) / 60) % 60;
2091 2091