Mercurial > pidgin
comparison libpurple/protocols/qq/group_conv.c @ 24145:ec3f7d3e0445
2008.10.04 - lonicerae <lonicerae(at)gmail.com>
* fixed a bug in qq_base.c
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:49:38 +0000 |
parents | a95c7e71064c |
children | ce94189f15ad |
comparison
equal
deleted
inserted
replaced
24144:a95c7e71064c | 24145:ec3f7d3e0445 |
---|---|
72 GList *names, *list, *flags; | 72 GList *names, *list, *flags; |
73 qq_buddy *member; | 73 qq_buddy *member; |
74 gchar *member_name, *member_uid; | 74 gchar *member_name, *member_uid; |
75 PurpleConversation *conv; | 75 PurpleConversation *conv; |
76 gint flag; | 76 gint flag; |
77 gboolean is_find; | |
78 g_return_if_fail(group != NULL); | 77 g_return_if_fail(group != NULL); |
79 | |
80 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, | |
81 group->title_utf8, purple_connection_get_account(gc)); | |
82 | |
83 g_return_if_fail (conv != NULL && group->members != NULL); | |
84 | 78 |
85 names = NULL; | 79 names = NULL; |
86 flags = NULL; | 80 flags = NULL; |
81 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, | |
82 group->title_utf8, purple_connection_get_account(gc)); | |
83 if (conv != NULL && group->members != NULL) { | |
84 list = group->members; | |
85 while (list != NULL) { | |
86 member = (qq_buddy *) list->data; | |
87 | 87 |
88 list = group->members; | 88 /* we need unique identifiers for everyone in the chat or else we'll |
89 while (list != NULL) { | 89 * run into problems with functions like get_cb_real_name from qq.c */ |
90 member = (qq_buddy *) list->data; | 90 member_name = (member->nickname != NULL && *(member->nickname) != '\0') ? |
91 g_strdup_printf("%s (%u)", member->nickname, member->uid) : | |
92 g_strdup_printf("(%u)", member->uid); | |
93 member_uid = g_strdup_printf("(%u)", member->uid); | |
91 | 94 |
92 /* we need unique identifiers for everyone in the chat or else we'll | 95 flag = 0; |
93 * run into problems with functions like get_cb_real_name from qq.c */ | 96 /* TYPING to put online above OP and FOUNDER */ |
94 member_name = (member->nickname != NULL && *(member->nickname) != '\0') ? | 97 if (is_online(member->status)) |
95 g_strdup_printf("%s (%u)", member->nickname, member->uid) : | 98 flag |= (PURPLE_CBFLAGS_TYPING | PURPLE_CBFLAGS_VOICE); |
96 g_strdup_printf("(%u)", member->uid); | 99 if(1 == (member->role & 1)) flag |= PURPLE_CBFLAGS_OP; |
97 member_uid = g_strdup_printf("(%u)", member->uid); | 100 if(member->uid == group->creator_uid) flag |= PURPLE_CBFLAGS_FOUNDER; |
98 | 101 |
99 flag = 0; | 102 if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), member_name)) |
100 /* TYPING to put online above OP and FOUNDER */ | 103 { |
101 if (is_online(member->status)) flag |= (PURPLE_CBFLAGS_TYPING | PURPLE_CBFLAGS_VOICE); | 104 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(conv), |
102 if(1 == (member->role & 1)) flag |= PURPLE_CBFLAGS_OP; | 105 member_name, |
103 if(member->uid == group->creator_uid) flag |= PURPLE_CBFLAGS_FOUNDER; | 106 flag); |
107 } else if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), member_uid)) | |
108 { | |
109 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(conv), | |
110 member_uid, | |
111 flag); | |
112 purple_conv_chat_rename_user(PURPLE_CONV_CHAT(conv), member_uid, member_name); | |
113 } else { | |
114 /* always put it even offline */ | |
115 names = g_list_append(names, member_name); | |
116 flags = g_list_append(flags, GINT_TO_POINTER(flag)); | |
117 } | |
118 g_free(member_uid); | |
119 list = list->next; | |
120 } | |
104 | 121 |
105 is_find = TRUE; | 122 if (names != NULL && flags != NULL) { |
106 if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), member_name)) | 123 purple_conv_chat_add_users(PURPLE_CONV_CHAT(conv), names, NULL, flags, FALSE); |
107 { | |
108 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(conv), | |
109 member_name, | |
110 flag); | |
111 } else if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), member_uid)) | |
112 { | |
113 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(conv), | |
114 member_uid, | |
115 flag); | |
116 purple_conv_chat_rename_user(PURPLE_CONV_CHAT(conv), member_uid, member_name); | |
117 } else { | |
118 is_find = FALSE; | |
119 } | 124 } |
120 if (!is_find) { | |
121 /* always put it even offline */ | |
122 names = g_list_append(names, member_name); | |
123 flags = g_list_append(flags, GINT_TO_POINTER(flag)); | |
124 } else { | |
125 g_free(member_name); | |
126 } | |
127 g_free(member_uid); | |
128 list = list->next; | |
129 } | 125 } |
130 | |
131 if (names != NULL && flags != NULL) { | |
132 purple_conv_chat_add_users(PURPLE_CONV_CHAT(conv), names, NULL, flags, FALSE); | |
133 } | |
134 | |
135 /* clean up names */ | 126 /* clean up names */ |
136 while (names != NULL) { | 127 while (names != NULL) { |
137 member_name = (gchar *) names->data; | 128 member_name = (gchar *) names->data; |
138 names = g_list_remove(names, member_name); | 129 names = g_list_remove(names, member_name); |
139 g_free(member_name); | 130 g_free(member_name); |