comparison src/server.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 abb0c3eccc76
children 5fcb44d771d2
comparison
equal deleted inserted replaced
4490:70b892694e0b 4491:3196d9044a45
37 #include "gaim.h" 37 #include "gaim.h"
38 38
39 #include "pixmaps/cancel.xpm" 39 #include "pixmaps/cancel.xpm"
40 #include "pixmaps/tb_search.xpm" 40 #include "pixmaps/tb_search.xpm"
41 41
42 void serv_login(struct aim_user *user) 42 void serv_login(struct gaim_account *account)
43 { 43 {
44 struct prpl *p = find_prpl(user->protocol); 44 struct prpl *p = find_prpl(account->protocol);
45 45
46 if (user->gc != NULL || p == NULL) 46 if (account->gc != NULL || p == NULL)
47 return; 47 return;
48 48
49 if(!ref_protocol(p)) 49 if(!ref_protocol(p))
50 return; 50 return;
51 51
52 if (p->login) { 52 if (p->login) {
53 if (!strlen(user->password) && !(p->options & OPT_PROTO_NO_PASSWORD) && 53 if (!strlen(account->password) && !(p->options & OPT_PROTO_NO_PASSWORD) &&
54 !(p->options & OPT_PROTO_PASSWORD_OPTIONAL)) { 54 !(p->options & OPT_PROTO_PASSWORD_OPTIONAL)) {
55 do_error_dialog(_("Please enter your password"), NULL, GAIM_ERROR); 55 do_error_dialog(_("Please enter your password"), NULL, GAIM_ERROR);
56 return; 56 return;
57 } 57 }
58 58
59 debug_printf(PACKAGE " " VERSION " logging in %s using %s\n", user->username, p->name); 59 debug_printf(PACKAGE " " VERSION " logging in %s using %s\n", account->username, p->name);
60 user->connecting = TRUE; 60 account->connecting = TRUE;
61 connecting_count++; 61 connecting_count++;
62 debug_printf("connecting_count: %d\n", connecting_count); 62 debug_printf("connecting_count: %d\n", connecting_count);
63 plugin_event(event_connecting, user); 63 plugin_event(event_connecting, account);
64 p->login(user); 64 p->login(account);
65 } 65 }
66 } 66 }
67 67
68 static gboolean send_keepalive(gpointer d) 68 static gboolean send_keepalive(gpointer d)
69 { 69 {
126 check_idle(gc); 126 check_idle(gc);
127 } 127 }
128 128
129 void serv_finish_login(struct gaim_connection *gc) 129 void serv_finish_login(struct gaim_connection *gc)
130 { 130 {
131 if (strlen(gc->user->user_info)) { 131 if (strlen(gc->account->user_info)) {
132 /* g_malloc(strlen(gc->user->user_info) * 4); 132 /* g_malloc(strlen(gc->user->user_info) * 4);
133 strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); */ 133 strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); */
134 serv_set_info(gc, gc->user->user_info); 134 serv_set_info(gc, gc->account->user_info);
135 /* g_free(buf); */ 135 /* g_free(buf); */
136 } 136 }
137 137
138 if (gc->idle_timer > 0) 138 if (gc->idle_timer > 0)
139 g_source_remove(gc->idle_timer); 139 g_source_remove(gc->idle_timer);
343 /* 343 /*
344 * Set buddy's alias on server roster/list 344 * Set buddy's alias on server roster/list
345 */ 345 */
346 void serv_alias_buddy(struct buddy *b) 346 void serv_alias_buddy(struct buddy *b)
347 { 347 {
348 if(b && b->user->gc && b->user->gc->prpl && b->user->gc->prpl->alias_buddy) { 348 if(b && b->account->gc && b->account->gc->prpl && b->account->gc->prpl->alias_buddy) {
349 b->user->gc->prpl->alias_buddy(b->user->gc, b->name, b->alias); 349 b->account->gc->prpl->alias_buddy(b->account->gc, b->name, b->alias);
350 } 350 }
351 } 351 }
352 352
353 void serv_got_alias(struct gaim_connection *gc, char *who, char *alias) { 353 void serv_got_alias(struct gaim_connection *gc, char *who, char *alias) {
354 struct buddy *b = find_buddy(gc->user, who); 354 struct buddy *b = find_buddy(gc->account, who);
355 if(!b) 355 if(!b)
356 return; 356 return;
357 357
358 if(alias) 358 if(alias)
359 g_snprintf(b->server_alias, sizeof(b->server_alias), "%s", alias); 359 g_snprintf(b->server_alias, sizeof(b->server_alias), "%s", alias);
369 * Note: For now we'll not deal with changing gc's at the same time, but 369 * Note: For now we'll not deal with changing gc's at the same time, but
370 * it should be possible. Probably needs to be done, someday. 370 * it should be possible. Probably needs to be done, someday.
371 */ 371 */
372 void serv_move_buddy(struct buddy *b, struct group *og, struct group *ng) 372 void serv_move_buddy(struct buddy *b, struct group *og, struct group *ng)
373 { 373 {
374 if(b && b->user->gc && og && ng) { 374 if(b && b->account->gc && og && ng) {
375 if(b->user->gc->prpl && b->user->gc->prpl->group_buddy) { 375 if(b->account->gc->prpl && b->account->gc->prpl->group_buddy) {
376 b->user->gc->prpl->group_buddy(b->user->gc, b->name, og->name, ng->name); 376 b->account->gc->prpl->group_buddy(b->account->gc, b->name, og->name, ng->name);
377 } 377 }
378 } 378 }
379 } 379 }
380 380
381 /* 381 /*
387 GList *tobemoved = NULL; 387 GList *tobemoved = NULL;
388 GSList *original; 388 GSList *original;
389 389
390 for (original=old_group->members; original; original=g_slist_next(original)) { 390 for (original=old_group->members; original; original=g_slist_next(original)) {
391 struct buddy *b = original->data; 391 struct buddy *b = original->data;
392 if(b->user == g->user) 392 if(b->account == g->account)
393 tobemoved = g_list_append(tobemoved, b->name); 393 tobemoved = g_list_append(tobemoved, b->name);
394 } 394 }
395 395
396 if (g->prpl->rename_group) { 396 if (g->prpl->rename_group) {
397 /* prpl's might need to check if the group already 397 /* prpl's might need to check if the group already
580 580
581 /* 581 /*
582 * We should update the conversation window buttons and menu, 582 * We should update the conversation window buttons and menu,
583 * if it exists. 583 * if it exists.
584 */ 584 */
585 cnv = gaim_find_conversation_with_user(name, gc->user); 585 cnv = gaim_find_conversation_with_account(name, gc->account);
586 586
587 /* 587 /*
588 * Plugin stuff. we pass a char ** but we don't want to pass what's 588 * Plugin stuff. we pass a char ** but we don't want to pass what's
589 * been given us by the prpls. So we create temp holders and pass 589 * been given us by the prpls. So we create temp holders and pass
590 * those instead. It's basically just to avoid segfaults. Of course, 590 * those instead. It's basically just to avoid segfaults. Of course,
654 * things we have to do for each. 654 * things we have to do for each.
655 */ 655 */
656 if (gc->away) { 656 if (gc->away) {
657 time_t t; 657 time_t t;
658 char *tmpmsg; 658 char *tmpmsg;
659 struct buddy *b = find_buddy(gc->user, name); 659 struct buddy *b = find_buddy(gc->account, name);
660 char *alias = b ? get_buddy_alias(b) : name; 660 char *alias = b ? get_buddy_alias(b) : name;
661 int row; 661 int row;
662 struct queued_away_response *qar; 662 struct queued_away_response *qar;
663 663
664 time(&t); 664 time(&t);
731 * exists and is updated (partly handled above already), play 731 * exists and is updated (partly handled above already), play
732 * the receive sound (sound.c will take care of not playing 732 * the receive sound (sound.c will take care of not playing
733 * while away), and then write it to the convo window. 733 * while away), and then write it to the convo window.
734 */ 734 */
735 if (cnv == NULL) 735 if (cnv == NULL)
736 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->user, name); 736 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name);
737 737
738 gaim_im_write(GAIM_IM(cnv), NULL, message, len, 738 gaim_im_write(GAIM_IM(cnv), NULL, message, len,
739 away | WFLAG_RECV, mtime); 739 away | WFLAG_RECV, mtime);
740 } 740 }
741 741
823 qm->flags = away | WFLAG_RECV; 823 qm->flags = away | WFLAG_RECV;
824 qm->len = len; 824 qm->len = len;
825 unread_message_queue = g_slist_append(unread_message_queue, qm); 825 unread_message_queue = g_slist_append(unread_message_queue, qm);
826 } else { 826 } else {
827 if (cnv == NULL) 827 if (cnv == NULL)
828 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->user, name); 828 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name);
829 829
830 /* CONV XXX gaim_conversation_set_name(cnv, name); */ 830 /* CONV XXX gaim_conversation_set_name(cnv, name); */
831 831
832 gaim_im_write(GAIM_IM(cnv), NULL, message, len, 832 gaim_im_write(GAIM_IM(cnv), NULL, message, len,
833 away | WFLAG_RECV, mtime); 833 away | WFLAG_RECV, mtime);
843 843
844 844
845 void serv_got_update(struct gaim_connection *gc, char *name, int loggedin, 845 void serv_got_update(struct gaim_connection *gc, char *name, int loggedin,
846 int evil, time_t signon, time_t idle, int type, guint caps) 846 int evil, time_t signon, time_t idle, int type, guint caps)
847 { 847 {
848 struct buddy *b = find_buddy(gc->user, name); 848 struct buddy *b = find_buddy(gc->account, name);
849 849
850 if (signon && (gc->prpl->options & OPT_PROTO_CORRECT_TIME)) { 850 if (signon && (gc->prpl->options & OPT_PROTO_CORRECT_TIME)) {
851 char *tmp = g_strdup(normalize(name)); 851 char *tmp = g_strdup(normalize(name));
852 if (!g_strcasecmp(tmp, normalize(gc->username))) { 852 if (!g_strcasecmp(tmp, normalize(gc->username))) {
853 gc->evil = evil; 853 gc->evil = evil;
951 if (!cnv) 951 if (!cnv)
952 return; 952 return;
953 953
954 im = GAIM_IM(cnv); 954 im = GAIM_IM(cnv);
955 955
956 gaim_conversation_set_user(cnv, gc->user); 956 gaim_conversation_set_account(cnv, gc->account);
957 gaim_im_set_typing_state(im, state); 957 gaim_im_set_typing_state(im, state);
958 gaim_im_update_typing(im); 958 gaim_im_update_typing(im);
959 959
960 plugin_event(event_got_typing, gc, name); 960 plugin_event(event_got_typing, gc, name);
961 do_pounce(gc, name, OPT_POUNCE_TYPING); 961 do_pounce(gc, name, OPT_POUNCE_TYPING);
1034 int id, char *name) 1034 int id, char *name)
1035 { 1035 {
1036 struct gaim_conversation *b; 1036 struct gaim_conversation *b;
1037 struct gaim_chat *chat; 1037 struct gaim_chat *chat;
1038 1038
1039 b = gaim_conversation_new(GAIM_CONV_CHAT, gc->user, name); 1039 b = gaim_conversation_new(GAIM_CONV_CHAT, gc->account, name);
1040 chat = GAIM_CHAT(b); 1040 chat = GAIM_CHAT(b);
1041 1041
1042 gc->buddy_chats = g_slist_append(gc->buddy_chats, b); 1042 gc->buddy_chats = g_slist_append(gc->buddy_chats, b);
1043 1043
1044 gaim_chat_set_id(chat, id); 1044 gaim_chat_set_id(chat, id);