| 121 PurpleConversation *conversation = NULL; |
121 PurpleConversation *conversation = NULL; |
| 122 PurpleConversationManager *manager = NULL; |
122 PurpleConversationManager *manager = NULL; |
| 123 IbisClient *client = NULL; |
123 IbisClient *client = NULL; |
| 124 IbisMessage *message = NULL; |
124 IbisMessage *message = NULL; |
| 125 GTask *task = NULL; |
125 GTask *task = NULL; |
| |
126 char *normalized_name = NULL; |
| 126 const char *name = NULL; |
127 const char *name = NULL; |
| 127 const char *password = NULL; |
128 const char *password = NULL; |
| 128 |
129 |
| 129 connection = purple_account_get_connection(account); |
130 connection = purple_account_get_connection(account); |
| 130 v3_connection = PURPLE_IRCV3_CONNECTION(connection); |
131 v3_connection = PURPLE_IRCV3_CONNECTION(connection); |
| 148 g_clear_object(&task); |
149 g_clear_object(&task); |
| 149 |
150 |
| 150 return; |
151 return; |
| 151 } |
152 } |
| 152 |
153 |
| |
154 client = purple_ircv3_connection_get_client(v3_connection); |
| |
155 normalized_name = ibis_client_normalize(client, name); |
| |
156 |
| 153 manager = purple_conversation_manager_get_default(); |
157 manager = purple_conversation_manager_get_default(); |
| 154 conversation = purple_conversation_manager_find_with_id(manager, account, |
158 conversation = purple_conversation_manager_find_with_id(manager, account, |
| 155 name); |
159 normalized_name); |
| 156 |
160 |
| 157 /* If the conversation already exists, just return TRUE. */ |
161 /* If the conversation already exists, just return TRUE. */ |
| 158 if(PURPLE_IS_CONVERSATION(conversation)) { |
162 if(PURPLE_IS_CONVERSATION(conversation)) { |
| |
163 g_free(normalized_name); |
| |
164 |
| 159 g_task_return_boolean(task, TRUE); |
165 g_task_return_boolean(task, TRUE); |
| 160 g_clear_object(&task); |
166 g_clear_object(&task); |
| 161 |
167 |
| 162 return; |
168 return; |
| 163 } |
169 } |
| 164 |
170 |
| 165 message = ibis_message_new(IBIS_MSG_JOIN); |
171 message = ibis_message_new(IBIS_MSG_JOIN); |
| 166 |
172 |
| 167 password = purple_channel_join_details_get_password(details); |
173 password = purple_channel_join_details_get_password(details); |
| 168 if(!purple_strempty(password)) { |
174 if(!purple_strempty(password)) { |
| 169 ibis_message_set_params(message, name, password, NULL); |
175 ibis_message_set_params(message, normalized_name, password, NULL); |
| 170 } else { |
176 } else { |
| 171 ibis_message_set_params(message, name, NULL); |
177 ibis_message_set_params(message, normalized_name, NULL); |
| 172 } |
178 } |
| 173 |
179 |
| 174 conversation = g_object_new( |
180 conversation = g_object_new( |
| 175 PURPLE_TYPE_CONVERSATION, |
181 PURPLE_TYPE_CONVERSATION, |
| 176 "account", account, |
182 "account", account, |
| 177 "type", PURPLE_CONVERSATION_TYPE_CHANNEL, |
183 "type", PURPLE_CONVERSATION_TYPE_CHANNEL, |
| 178 "id", name, |
184 "id", normalized_name, |
| |
185 "title", name, |
| 179 "online", TRUE, |
186 "online", TRUE, |
| 180 NULL); |
187 NULL); |
| 181 purple_conversation_manager_add(manager, conversation); |
188 purple_conversation_manager_add(manager, conversation); |
| 182 g_clear_object(&conversation); |
189 g_clear_object(&conversation); |
| 183 |
190 |
| 184 client = purple_ircv3_connection_get_client(v3_connection); |
|
| 185 ibis_client_write(client, message); |
191 ibis_client_write(client, message); |
| |
192 |
| |
193 g_free(normalized_name); |
| 186 |
194 |
| 187 g_task_return_boolean(task, TRUE); |
195 g_task_return_boolean(task, TRUE); |
| 188 g_clear_object(&task); |
196 g_clear_object(&task); |
| 189 } |
197 } |
| 190 |
198 |