void tgprpl_chat_join (PurpleConnection *gc, GHashTable *data) { debug ("tgprpl_chat_join()"); g_return_if_fail(data); // auto joins will cause chat joins at a time when the dialogue list is not ready, remember // those chats and join them once the dialogue list is fetched if (! gc_get_data (gc)->dialogues_ready) { g_return_if_fail (data); const char *id = g_hash_table_lookup (data, "id"); if (id) { debug ("attempting to join chat %s while not ready, queue up for later", id); gc_get_data (gc)->pending_joins = g_list_append (gc_get_data (gc)->pending_joins, g_strdup (id)); } return; } // join existing chat by id when the user clicks on a chat in the buddy list void *value = g_hash_table_lookup (data, "id"); if (value && atoi (value)) { tgl_peer_id_t cid = TGL_MK_CHAT(atoi (value)); tgl_peer_t *P = tgl_peer_get (gc_get_tls (gc), cid); if (P) { debug ("joining chat by id %d ...", tgl_get_peer_id (cid)); tgl_do_get_chat_info (gc_get_tls (gc), cid, FALSE, tgp_chat_on_loaded_chat_full_joining, NULL); } else { warning ("Cannot join chat %d, peer not found...", tgl_get_peer_id (cid)); purple_serv_got_join_chat_failed (gc, data); } return; } // join chat by invite link provided in the chat join window const char *link = g_hash_table_lookup (data, "link"); if (str_not_empty (link)) { tgl_do_import_chat_link (gc_get_tls (gc), link, (int)strlen (link), tgp_notify_on_error_gw, NULL); return; } // if a chat with this name doesn't exist yet, prompt to create one const char *subject = g_hash_table_lookup (data, "subject"); if (str_not_empty (subject)) { tgl_peer_t *P = tgl_peer_get_by_name (gc_get_tls (gc), subject); // handle joining chats by print_names as used by the Adium plugin if (P && tgl_get_peer_type (P->id) == TGL_PEER_CHAT) { debug ("joining chat by subject %s ...", subject); tgl_do_get_chat_info (gc_get_tls (gc), P->id, FALSE, tgp_chat_on_loaded_chat_full_joining, NULL); return; } // user creates a new chat by providing its subject the chat join window request_create_chat (gc_get_tls (gc), subject); } }
void tgprpl_chat_join (PurpleConnection * gc, GHashTable *data) { debug ("tgprpl_chat_join()"); connection_data *conn = purple_connection_get_protocol_data (gc); // join existing chat by id when the user clicks on a chat in the buddy list void *value = g_hash_table_lookup (data, "id"); if (value && atoi (value)) { tgl_peer_id_t cid = TGL_MK_CHAT(atoi (value)); tgl_peer_t *P = tgl_peer_get (conn->TLS, cid); if (P) { debug ("joining chat by id %d ...", tgl_get_peer_id (cid)); tgl_do_get_chat_info (conn->TLS, cid, FALSE, tgp_chat_on_loaded_chat_full_joining, NULL); } else { warning ("Cannot join chat %d, peer not found...", tgl_get_peer_id (cid)); purple_serv_got_join_chat_failed (gc, data); } return; } // join chat by invite link provided in the chat join window const char *link = g_hash_table_lookup (data, "link"); if (str_not_empty (link)) { tgl_do_import_chat_link (conn->TLS, link, (int)strlen (link), tgp_notify_on_error_gw, NULL); return; } // if a chat with this name doesn't exist yet, prompt to create one const char *subject = g_hash_table_lookup (data, "subject"); if (str_not_empty (subject)) { tgl_peer_t *P = tgl_peer_get_by_name (conn->TLS, subject); // handle joining chats by print_names as used by the Adium plugin if (P && tgl_get_peer_type (P->id) == TGL_PEER_CHAT) { debug ("joining chat by subject %s ...", subject); tgl_do_get_chat_info (conn->TLS, P->id, FALSE, tgp_chat_on_loaded_chat_full_joining, NULL); return; } // user creates a new chat by providing its subject the chat join window request_create_chat (conn->TLS, subject); } }