void PurpleLine::join_chat(GHashTable *components) { char *id_ptr = (char *)g_hash_table_lookup(components, "id"); if (!id_ptr) { purple_debug_warning("line", "Tried to join a chat with no id.\n"); return; } std::string id(id_ptr); ChatType type = get_chat_type((char *)g_hash_table_lookup(components, "type")); if (type == ChatType::ANY) { purple_debug_warning("line", "Tried to join a chat with weird type.\n"); return; } if (type == ChatType::GROUP_INVITE) { c_out->send_acceptGroupInvitation(0, id); c_out->send([this, id]{ try { c_out->recv_acceptGroupInvitation(); } catch (line::TalkException &err) { purple_notify_warning( (void *)conn, "Failed to join LINE group", "Your invitation was probably cancelled.", err.reason.c_str()); return; } c_out->send_getGroup(id); c_out->send([this]{ line::Group group; c_out->recv_getGroup(group); if (!group.__isset.id) { purple_debug_warning("line", "Couldn't get group: %s\n", group.id.c_str()); return; } join_chat_success(ChatType::GROUP, group.id); }); }); return; } join_chat_success(type, id); }
void PurpleLine::signal_blist_node_removed(PurpleBlistNode *node) { if (!(PURPLE_BLIST_NODE_IS_CHAT(node) && purple_chat_get_account(PURPLE_CHAT(node)) == acct)) { return; } GHashTable *components = purple_chat_get_components(PURPLE_CHAT(node)); char *id_ptr = (char *)g_hash_table_lookup(components, "id"); if (!id_ptr) { purple_debug_warning("line", "Tried to remove a chat with no id."); return; } std::string id(id_ptr); ChatType type = get_chat_type((char *)g_hash_table_lookup(components, "type")); if (type == ChatType::ROOM) { c_out->send_leaveRoom(0, id); c_out->send([this]{ try { c_out->recv_leaveRoom(); } catch (line::TalkException &err) { notify_error(std::string("Couldn't leave from chat: ") + err.reason); } }); } else if (type == ChatType::GROUP) { c_out->send_leaveGroup(0, id); c_out->send([this]{ try { c_out->recv_leaveGroup(); } catch (line::TalkException &err) { notify_error(std::string("Couldn't leave from group: ") + err.reason); } }); } else { purple_debug_warning("line", "Tried to remove a chat with no type."); return; } }