| 195 chat_name = g_strdup_printf("%s@%s", room, server); |
195 chat_name = g_strdup_printf("%s@%s", room, server); |
| 196 } |
196 } |
| 197 return chat_name; |
197 return chat_name; |
| 198 } |
198 } |
| 199 |
199 |
| |
200 static void insert_in_hash_table(gpointer key, gpointer value, gpointer user_data) |
| |
201 { |
| |
202 GHashTable *hash_table = (GHashTable *)user_data; |
| |
203 g_hash_table_insert(hash_table, g_strdup(key), g_strdup(value)); |
| |
204 } |
| |
205 |
| 200 void jabber_chat_join(PurpleConnection *gc, GHashTable *data) |
206 void jabber_chat_join(PurpleConnection *gc, GHashTable *data) |
| 201 { |
207 { |
| 202 JabberChat *chat; |
208 JabberChat *chat; |
| 203 char *room, *server, *handle, *passwd; |
209 char *room, *server, *handle, *passwd; |
| 204 xmlnode *presence, *x; |
210 xmlnode *presence, *x; |
| 223 |
229 |
| 224 if(!jabber_nodeprep_validate(room)) { |
230 if(!jabber_nodeprep_validate(room)) { |
| 225 char *buf = g_strdup_printf(_("%s is not a valid room name"), room); |
231 char *buf = g_strdup_printf(_("%s is not a valid room name"), room); |
| 226 purple_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"), |
232 purple_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"), |
| 227 buf); |
233 buf); |
| |
234 purple_serv_got_join_chat_failed(gc, data); |
| 228 g_free(buf); |
235 g_free(buf); |
| 229 return; |
236 return; |
| 230 } else if(!jabber_nameprep_validate(server)) { |
237 } else if(!jabber_nameprep_validate(server)) { |
| 231 char *buf = g_strdup_printf(_("%s is not a valid server name"), server); |
238 char *buf = g_strdup_printf(_("%s is not a valid server name"), server); |
| 232 purple_notify_error(gc, _("Invalid Server Name"), |
239 purple_notify_error(gc, _("Invalid Server Name"), |
| 233 _("Invalid Server Name"), buf); |
240 _("Invalid Server Name"), buf); |
| |
241 purple_serv_got_join_chat_failed(gc, data); |
| 234 g_free(buf); |
242 g_free(buf); |
| 235 return; |
243 return; |
| 236 } else if(!jabber_resourceprep_validate(handle)) { |
244 } else if(!jabber_resourceprep_validate(handle)) { |
| 237 char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle); |
245 char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle); |
| 238 purple_notify_error(gc, _("Invalid Room Handle"), |
246 purple_notify_error(gc, _("Invalid Room Handle"), |
| 239 _("Invalid Room Handle"), buf); |
247 _("Invalid Room Handle"), buf); |
| |
248 purple_serv_got_join_chat_failed(gc, data); |
| 240 g_free(buf); |
249 g_free(buf); |
| 241 return; |
250 return; |
| 242 } |
251 } |
| 243 |
252 |
| 244 if(jabber_chat_find(js, room, server)) |
253 if(jabber_chat_find(js, room, server)) |
| 252 chat->js = gc->proto_data; |
261 chat->js = gc->proto_data; |
| 253 |
262 |
| 254 chat->room = g_strdup(room); |
263 chat->room = g_strdup(room); |
| 255 chat->server = g_strdup(server); |
264 chat->server = g_strdup(server); |
| 256 chat->handle = g_strdup(handle); |
265 chat->handle = g_strdup(handle); |
| |
266 |
| |
267 /* Copy the data hash table to chat->components */ |
| |
268 chat->components = g_hash_table_new_full(g_str_hash, g_str_equal, |
| |
269 g_free, g_free); |
| |
270 g_hash_table_foreach(data, insert_in_hash_table, chat->components); |
| 257 |
271 |
| 258 chat->members = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, |
272 chat->members = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, |
| 259 (GDestroyNotify)jabber_chat_member_free); |
273 (GDestroyNotify)jabber_chat_member_free); |
| 260 |
274 |
| 261 g_hash_table_insert(js->chats, room_jid, chat); |
275 g_hash_table_insert(js->chats, room_jid, chat); |
| 313 |
327 |
| 314 g_free(chat->room); |
328 g_free(chat->room); |
| 315 g_free(chat->server); |
329 g_free(chat->server); |
| 316 g_free(chat->handle); |
330 g_free(chat->handle); |
| 317 g_hash_table_destroy(chat->members); |
331 g_hash_table_destroy(chat->members); |
| |
332 g_hash_table_destroy(chat->components); |
| 318 g_free(chat); |
333 g_free(chat); |
| 319 } |
334 } |
| 320 |
335 |
| 321 gboolean jabber_chat_find_buddy(PurpleConversation *conv, const char *name) |
336 gboolean jabber_chat_find_buddy(PurpleConversation *conv, const char *name) |
| 322 { |
337 { |