comparison src/conversation.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 b30b0a02ada0
children f3afcc4dd133
comparison
equal deleted inserted replaced
4490:70b892694e0b 4491:3196d9044a45
840 840
841 /************************************************************************** 841 /**************************************************************************
842 * Conversation API 842 * Conversation API
843 **************************************************************************/ 843 **************************************************************************/
844 struct gaim_conversation * 844 struct gaim_conversation *
845 gaim_conversation_new(GaimConversationType type, struct aim_user *user, 845 gaim_conversation_new(GaimConversationType type, struct gaim_account *account,
846 const char *name) 846 const char *name)
847 { 847 {
848 struct gaim_conversation *conv; 848 struct gaim_conversation *conv;
849 849
850 if (type == GAIM_CONV_UNKNOWN) 850 if (type == GAIM_CONV_UNKNOWN)
851 return NULL; 851 return NULL;
852 852
853 /* Check if this conversation already exists. */ 853 /* Check if this conversation already exists. */
854 if ((conv = gaim_find_conversation_with_user(name, user)) != NULL) 854 if ((conv = gaim_find_conversation_with_account(name, account)) != NULL)
855 return conv; 855 return conv;
856 856
857 conv = g_malloc0(sizeof(struct gaim_conversation)); 857 conv = g_malloc0(sizeof(struct gaim_conversation));
858 858
859 conv->type = type; 859 conv->type = type;
860 conv->user = user; 860 conv->account = account;
861 conv->name = g_strdup(name); 861 conv->name = g_strdup(name);
862 conv->title = g_strdup(name); 862 conv->title = g_strdup(name);
863 conv->send_history = g_list_append(NULL, NULL); 863 conv->send_history = g_list_append(NULL, NULL);
864 conv->history = g_string_new(""); 864 conv->history = g_string_new("");
865 865
1049 1049
1050 return conv->ui_ops; 1050 return conv->ui_ops;
1051 } 1051 }
1052 1052
1053 void 1053 void
1054 gaim_conversation_set_user(struct gaim_conversation *conv, 1054 gaim_conversation_set_account(struct gaim_conversation *conv,
1055 struct aim_user *user) 1055 struct gaim_account *account)
1056 { 1056 {
1057 if (conv == NULL || user == gaim_conversation_get_user(conv)) 1057 if (conv == NULL || account == gaim_conversation_get_account(conv))
1058 return; 1058 return;
1059 1059
1060 conv->user = user; 1060 conv->account = account;
1061 1061
1062 gaim_conversation_update(conv, GAIM_CONV_UPDATE_USER); 1062 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT);
1063 } 1063 }
1064 1064
1065 struct aim_user * 1065 struct gaim_account *
1066 gaim_conversation_get_user(const struct gaim_conversation *conv) 1066 gaim_conversation_get_account(const struct gaim_conversation *conv)
1067 { 1067 {
1068 if (conv == NULL) 1068 if (conv == NULL)
1069 return NULL; 1069 return NULL;
1070 1070
1071 return conv->user; 1071 return conv->account;
1072 } 1072 }
1073 1073
1074 struct gaim_connection * 1074 struct gaim_connection *
1075 gaim_conversation_get_gc(const struct gaim_conversation *conv) 1075 gaim_conversation_get_gc(const struct gaim_conversation *conv)
1076 { 1076 {
1077 struct aim_user *user; 1077 struct gaim_account *account;
1078 1078
1079 if (conv == NULL) 1079 if (conv == NULL)
1080 return NULL; 1080 return NULL;
1081 1081
1082 user = gaim_conversation_get_user(conv); 1082 account = gaim_conversation_get_account(conv);
1083 1083
1084 if (user == NULL) 1084 if (account == NULL)
1085 return NULL; 1085 return NULL;
1086 1086
1087 return user->gc; 1087 return account->gc;
1088 } 1088 }
1089 1089
1090 void 1090 void
1091 gaim_conversation_set_title(struct gaim_conversation *conv, const char *title) 1091 gaim_conversation_set_title(struct gaim_conversation *conv, const char *title)
1092 { 1092 {
1116 } 1116 }
1117 1117
1118 void 1118 void
1119 gaim_conversation_autoset_title(struct gaim_conversation *conv) 1119 gaim_conversation_autoset_title(struct gaim_conversation *conv)
1120 { 1120 {
1121 struct aim_user *user; 1121 struct gaim_account *account;
1122 struct buddy *b; 1122 struct buddy *b;
1123 const char *text, *name; 1123 const char *text, *name;
1124 1124
1125 if (conv == NULL) 1125 if (conv == NULL)
1126 return; 1126 return;
1127 1127
1128 user = gaim_conversation_get_user(conv); 1128 account = gaim_conversation_get_account(conv);
1129 name = gaim_conversation_get_name(conv); 1129 name = gaim_conversation_get_name(conv);
1130 1130
1131 if (((im_options & OPT_IM_ALIAS_TAB) == OPT_IM_ALIAS_TAB) && 1131 if (((im_options & OPT_IM_ALIAS_TAB) == OPT_IM_ALIAS_TAB) &&
1132 user != NULL && ((b = find_buddy(user, name)) != NULL)) { 1132 account != NULL && ((b = find_buddy(account, name)) != NULL)) {
1133 1133
1134 text = get_buddy_alias(b); 1134 text = get_buddy_alias(b);
1135 } 1135 }
1136 else 1136 else
1137 text = name; 1137 text = name;
1318 1318
1319 return c; 1319 return c;
1320 } 1320 }
1321 1321
1322 struct gaim_conversation * 1322 struct gaim_conversation *
1323 gaim_find_conversation_with_user(const char *name, const struct aim_user *user) 1323 gaim_find_conversation_with_account(const char *name, const struct gaim_account *account)
1324 { 1324 {
1325 struct gaim_conversation *c = NULL; 1325 struct gaim_conversation *c = NULL;
1326 char *cuser; 1326 char *cuser;
1327 GList *cnv; 1327 GList *cnv;
1328 1328
1333 1333
1334 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { 1334 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
1335 c = (struct gaim_conversation *)cnv->data; 1335 c = (struct gaim_conversation *)cnv->data;
1336 1336
1337 if (!g_strcasecmp(cuser, normalize(gaim_conversation_get_name(c))) && 1337 if (!g_strcasecmp(cuser, normalize(gaim_conversation_get_name(c))) &&
1338 user == gaim_conversation_get_user(c)) { 1338 account == gaim_conversation_get_account(c)) {
1339 1339
1340 break; 1340 break;
1341 } 1341 }
1342 1342
1343 c = NULL; 1343 c = NULL;
1381 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM || 1381 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM ||
1382 !(gc->prpl->options & OPT_PROTO_UNIQUE_CHATNAME)) { 1382 !(gc->prpl->options & OPT_PROTO_UNIQUE_CHATNAME)) {
1383 1383
1384 if (who == NULL) { 1384 if (who == NULL) {
1385 if ((flags & WFLAG_SEND) == WFLAG_SEND) { 1385 if ((flags & WFLAG_SEND) == WFLAG_SEND) {
1386 b = find_buddy(gc->user, gc->username); 1386 b = find_buddy(gc->account, gc->username);
1387 1387
1388 if (b != NULL && strcmp(b->name, get_buddy_alias(b))) 1388 if (b != NULL && strcmp(b->name, get_buddy_alias(b)))
1389 who = get_buddy_alias(b); 1389 who = get_buddy_alias(b);
1390 else if (*gc->user->alias) 1390 else if (*gc->account->alias)
1391 who = gc->user->alias; 1391 who = gc->account->alias;
1392 else if (*gc->displayname) 1392 else if (*gc->displayname)
1393 who = gc->displayname; 1393 who = gc->displayname;
1394 else 1394 else
1395 who = gc->username; 1395 who = gc->username;
1396 } 1396 }
1397 else { 1397 else {
1398 b = find_buddy(gc->user, gaim_conversation_get_name(conv)); 1398 b = find_buddy(gc->account, gaim_conversation_get_name(conv));
1399 1399
1400 if (b != NULL) 1400 if (b != NULL)
1401 who = get_buddy_alias(b); 1401 who = get_buddy_alias(b);
1402 else 1402 else
1403 who = gaim_conversation_get_name(conv); 1403 who = gaim_conversation_get_name(conv);
1404 } 1404 }
1405 } 1405 }
1406 else { 1406 else {
1407 b = find_buddy(gc->user, who); 1407 b = find_buddy(gc->account, who);
1408 1408
1409 if (b != NULL) 1409 if (b != NULL)
1410 who = get_buddy_alias(b); 1410 who = get_buddy_alias(b);
1411 } 1411 }
1412 } 1412 }
2070 else { 2070 else {
2071 struct buddy *b; 2071 struct buddy *b;
2072 struct group *grp = NULL; 2072 struct group *grp = NULL;
2073 GList *wins, *convs; 2073 GList *wins, *convs;
2074 2074
2075 b = find_buddy(gaim_conversation_get_user(conv), 2075 b = find_buddy(gaim_conversation_get_account(conv),
2076 gaim_conversation_get_name(conv)); 2076 gaim_conversation_get_name(conv));
2077 2077
2078 if (b != NULL) 2078 if (b != NULL)
2079 grp = find_group_by_buddy(b); 2079 grp = find_group_by_buddy(b);
2080 2080
2091 convs != NULL; 2091 convs != NULL;
2092 convs = convs->next) { 2092 convs = convs->next) {
2093 2093
2094 conv2 = (struct gaim_conversation *)convs->data; 2094 conv2 = (struct gaim_conversation *)convs->data;
2095 2095
2096 b2 = find_buddy(gaim_conversation_get_user(conv2), 2096 b2 = find_buddy(gaim_conversation_get_account(conv2),
2097 gaim_conversation_get_name(conv2)); 2097 gaim_conversation_get_name(conv2));
2098 2098
2099 if (b2 != NULL) 2099 if (b2 != NULL)
2100 g2 = find_group_by_buddy(b2); 2100 g2 = find_group_by_buddy(b2);
2101 2101