| 147 |
147 |
| 148 return TRUE; |
148 return TRUE; |
| 149 } |
149 } |
| 150 |
150 |
| 151 gboolean |
151 gboolean |
| |
152 purple_ircv3_message_handler_namreply(IbisClient *client, |
| |
153 G_GNUC_UNUSED const char *command, |
| |
154 IbisMessage *message, gpointer data) |
| |
155 { |
| |
156 PurpleIRCv3Connection *connection = data; |
| |
157 PurpleConversation *conversation = NULL; |
| |
158 GStrv params = NULL; |
| |
159 GStrv nicks = NULL; |
| |
160 const char *target = NULL; |
| |
161 |
| |
162 params = ibis_message_get_params(message); |
| |
163 if(params == NULL) { |
| |
164 g_warning("namreply received with no parameters"); |
| |
165 |
| |
166 return FALSE; |
| |
167 } |
| |
168 |
| |
169 if(g_strv_length(params) != 4) { |
| |
170 char *body = g_strjoinv(" ", params); |
| |
171 g_warning("unknown namreply format: '%s'", body); |
| |
172 g_free(body); |
| |
173 |
| |
174 return FALSE; |
| |
175 } |
| |
176 |
| |
177 /* params[0] holds nick of the user and params[1] holds the channel type |
| |
178 * (public/private) but we don't care about either of these. |
| |
179 */ |
| |
180 |
| |
181 target = params[2]; |
| |
182 if(!ibis_client_is_channel(client, target)) { |
| |
183 g_warning("received namreply for '%s' which is not a channel.", |
| |
184 target); |
| |
185 |
| |
186 return FALSE; |
| |
187 } |
| |
188 |
| |
189 conversation = purple_ircv3_connection_find_or_create_conversation(connection, |
| |
190 target); |
| |
191 |
| |
192 /* Split the last parameter on space to get a list of all the nicks. */ |
| |
193 nicks = g_strsplit(params[3], " ", -1); |
| |
194 if(nicks != NULL) { |
| |
195 PurpleAccount *account = NULL; |
| |
196 PurpleConnection *purple_connection = NULL; |
| |
197 PurpleContactManager *manager = purple_contact_manager_get_default(); |
| |
198 PurpleConversationMembers *members = NULL; |
| |
199 |
| |
200 purple_connection = PURPLE_CONNECTION(connection); |
| |
201 account = purple_connection_get_account(purple_connection); |
| |
202 |
| |
203 members = purple_conversation_get_members(conversation); |
| |
204 |
| |
205 for(guint i = 0; i < g_strv_length(nicks); i++) { |
| |
206 PurpleContact *contact = NULL; |
| |
207 const char *nick = nicks[i]; |
| |
208 char *stripped = NULL; |
| |
209 |
| |
210 stripped = ibis_client_strip_source_prefix(client, nick); |
| |
211 |
| |
212 contact = purple_contact_manager_find_with_id(manager, account, |
| |
213 stripped); |
| |
214 if(!PURPLE_IS_CONTACT(contact)) { |
| |
215 contact = purple_contact_new(account, stripped); |
| |
216 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact), |
| |
217 stripped); |
| |
218 purple_contact_manager_add(manager, contact); |
| |
219 } |
| |
220 |
| |
221 purple_conversation_members_add_member(members, |
| |
222 PURPLE_CONTACT_INFO(contact), |
| |
223 FALSE, NULL); |
| |
224 g_free(stripped); |
| |
225 } |
| |
226 } |
| |
227 |
| |
228 g_strfreev(nicks); |
| |
229 |
| |
230 return TRUE; |
| |
231 } |
| |
232 |
| |
233 gboolean |
| 152 purple_ircv3_message_handler_tagmsg(IbisClient *client, |
234 purple_ircv3_message_handler_tagmsg(IbisClient *client, |
| 153 G_GNUC_UNUSED const char *command, |
235 G_GNUC_UNUSED const char *command, |
| 154 IbisMessage *ibis_message, gpointer data) |
236 IbisMessage *ibis_message, gpointer data) |
| 155 { |
237 { |
| 156 PurpleIRCv3Connection *connection = data; |
238 PurpleIRCv3Connection *connection = data; |