Thu, 22 Aug 2024 20:51:22 -0500
IRCv3: Implement leaving conversations
Testing Done:
Connected to a local ergo and left a channel.
Bugs closed: PIDGIN-17895
Reviewed at https://reviews.imfreedom.org/r/3430/
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
7 | * source distribution. |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
8 | * |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
12 | * (at your option) any later version. |
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
17 | * GNU General Public License for more details. |
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42511
diff
changeset
|
20 | * along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
25 | #include <ibis.h> |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
26 | |
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include "purpleircv3protocolconversation.h" |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | #include "purpleircv3connection.h" |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
30 | #include "purpleircv3core.h" |
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | /****************************************************************************** |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | * PurpleProtocolConversation Implementation |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | *****************************************************************************/ |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | static void |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | purple_ircv3_protocol_conversation_send_message_async(PurpleProtocolConversation *protocol, |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | PurpleConversation *conversation, |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | PurpleMessage *message, |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | GCancellable *cancellable, |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | GAsyncReadyCallback callback, |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | gpointer data) |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | { |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | PurpleIRCv3Connection *v3_connection = NULL; |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | PurpleAccount *account = NULL; |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | PurpleConnection *connection = NULL; |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
46 | IbisClient *client = NULL; |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
47 | IbisMessage *ibis_message = NULL; |
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | GTask *task = NULL; |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | const char *id = NULL; |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | account = purple_conversation_get_account(conversation); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | connection = purple_account_get_connection(account); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | v3_connection = PURPLE_IRCV3_CONNECTION(connection); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | id = purple_conversation_get_id(conversation); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | /* TODO: the new message dialog sets the name but not the id and we want to |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | * use the id only, so for now if id is NULL we grab the name. |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | */ |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | if(purple_strempty(id)) { |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | id = purple_conversation_get_name(conversation); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | } |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
63 | client = purple_ircv3_connection_get_client(v3_connection); |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
64 | |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
65 | ibis_message = ibis_message_new(IBIS_MSG_PRIVMSG); |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
66 | ibis_message_set_params(ibis_message, id, |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
67 | purple_message_get_contents(message), NULL); |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
68 | ibis_client_write(client, ibis_message); |
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | task = g_task_new(protocol, cancellable, callback, data); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | g_task_return_boolean(task, TRUE); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | g_clear_object(&task); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | /* This will be made conditional when we add echo-message support. |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | * https://ircv3.net/specs/extensions/echo-message |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | */ |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | purple_conversation_write_message(conversation, message); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | } |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | static gboolean |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | purple_ircv3_protocol_conversation_send_message_finish(G_GNUC_UNUSED PurpleProtocolConversation *protocol, |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | GAsyncResult *result, |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | GError **error) |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | { |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | return g_task_propagate_boolean(G_TASK(result), error); |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | } |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
88 | static PurpleChannelJoinDetails * |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
89 | purple_ircv3_protocol_conversation_get_channel_join_details(G_GNUC_UNUSED PurpleProtocolConversation *protocol, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
90 | G_GNUC_UNUSED PurpleAccount *account) |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
91 | { |
|
42799
8b06291db25c
Add properties for the maximum length of properties to ChannelJoinDetails
Gary Kramlich <grim@reaperworld.com>
parents:
42769
diff
changeset
|
92 | return purple_channel_join_details_new(0, FALSE, 0, TRUE, 0); |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
93 | } |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
94 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
95 | static void |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
96 | purple_ircv3_protocol_conversation_join_channel_async(PurpleProtocolConversation *protocol, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
97 | PurpleAccount *account, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
98 | PurpleChannelJoinDetails* details, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
99 | GCancellable* cancellable, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
100 | GAsyncReadyCallback callback, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
101 | gpointer data) |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
102 | { |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
103 | PurpleIRCv3Connection *v3_connection = NULL; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
104 | PurpleConnection *connection = NULL; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
105 | PurpleConversation *conversation = NULL; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
106 | PurpleConversationManager *manager = NULL; |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
107 | IbisClient *client = NULL; |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
108 | IbisMessage *message = NULL; |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
109 | GTask *task = NULL; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
110 | const char *name = NULL; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
111 | const char *password = NULL; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
112 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
113 | connection = purple_account_get_connection(account); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
114 | v3_connection = PURPLE_IRCV3_CONNECTION(connection); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
115 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
116 | task = g_task_new(protocol, cancellable, callback, data); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
117 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
118 | /* Validate that the name isn't empty. */ |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
119 | /* TODO: check that name match the ISUPPORT channel prefixes. */ |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
120 | name = purple_channel_join_details_get_name(details); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
121 | if(purple_strempty(name)) { |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
122 | g_task_return_new_error(task, PURPLE_IRCV3_DOMAIN, 0, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
123 | "channel name is empty"); |
|
42450
bd1327c022d4
fix some memory leaks
Markus Fischer <ivanhoe@fiscari.de>
parents:
42378
diff
changeset
|
124 | g_clear_object(&task); |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
125 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
126 | return; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
127 | } |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
128 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
129 | manager = purple_conversation_manager_get_default(); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
130 | conversation = purple_conversation_manager_find_with_id(manager, account, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
131 | name); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
132 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
133 | /* If the conversation already exists, just return TRUE. */ |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
134 | if(PURPLE_IS_CONVERSATION(conversation)) { |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
135 | g_task_return_boolean(task, TRUE); |
|
42450
bd1327c022d4
fix some memory leaks
Markus Fischer <ivanhoe@fiscari.de>
parents:
42378
diff
changeset
|
136 | g_clear_object(&task); |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
137 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
138 | return; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
139 | } |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
140 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
141 | message = ibis_message_new(IBIS_MSG_JOIN); |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
142 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
143 | password = purple_channel_join_details_get_password(details); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
144 | if(!purple_strempty(password)) { |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
145 | ibis_message_set_params(message, name, password, NULL); |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
146 | } else { |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
147 | ibis_message_set_params(message, name, NULL); |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
148 | } |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
149 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
150 | conversation = g_object_new( |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
151 | PURPLE_TYPE_CONVERSATION, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
152 | "account", account, |
|
42653
584895b844d2
PurpleConversationType's values were pascal case when they should be upper snake case
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
153 | "type", PURPLE_CONVERSATION_TYPE_CHANNEL, |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
154 | "id", name, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
155 | "name", name, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
156 | NULL); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
157 | purple_conversation_manager_register(manager, conversation); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
158 | g_clear_object(&conversation); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
159 | |
|
42769
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
160 | client = purple_ircv3_connection_get_client(v3_connection); |
|
c488d7af2923
Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents:
42653
diff
changeset
|
161 | ibis_client_write(client, message); |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
162 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
163 | g_task_return_boolean(task, TRUE); |
|
42450
bd1327c022d4
fix some memory leaks
Markus Fischer <ivanhoe@fiscari.de>
parents:
42378
diff
changeset
|
164 | g_clear_object(&task); |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
165 | } |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
166 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
167 | static gboolean |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
168 | purple_ircv3_protocol_conversation_join_channel_finish(G_GNUC_UNUSED PurpleProtocolConversation *protocol, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
169 | GAsyncResult *result, |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
170 | GError **error) |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
171 | { |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
172 | return g_task_propagate_boolean(G_TASK(result), error); |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
173 | } |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
174 | |
|
42889
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
175 | static void |
|
42900
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
176 | purple_ircv3_protocol_conversation_leave_conversation_async(PurpleProtocolConversation *protocol, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
177 | PurpleConversation *conversation, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
178 | GCancellable *cancellable, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
179 | GAsyncReadyCallback callback, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
180 | gpointer data) |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
181 | { |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
182 | GTask *task = NULL; |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
183 | |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
184 | if(purple_conversation_is_channel(conversation)) { |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
185 | PurpleIRCv3Connection *v3_connection = NULL; |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
186 | PurpleAccount *account = NULL; |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
187 | PurpleConnection *connection = NULL; |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
188 | IbisClient *client = NULL; |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
189 | IbisMessage *message = NULL; |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
190 | |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
191 | account = purple_conversation_get_account(conversation); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
192 | connection = purple_account_get_connection(account); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
193 | v3_connection = PURPLE_IRCV3_CONNECTION(connection); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
194 | client = purple_ircv3_connection_get_client(v3_connection); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
195 | |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
196 | message = ibis_message_new(IBIS_MSG_PART); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
197 | ibis_message_set_params(message, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
198 | purple_conversation_get_id(conversation), |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
199 | NULL); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
200 | ibis_client_write(client, message); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
201 | } |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
202 | |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
203 | task = g_task_new(protocol, cancellable, callback, data); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
204 | g_task_set_source_tag(task, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
205 | purple_ircv3_protocol_conversation_leave_conversation_async); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
206 | g_task_return_boolean(task, TRUE); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
207 | g_clear_object(&task); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
208 | } |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
209 | |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
210 | static gboolean |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
211 | purple_ircv3_protocol_conversation_leave_conversation_finish(G_GNUC_UNUSED PurpleProtocolConversation *protocol, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
212 | GAsyncResult *result, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
213 | GError **error) |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
214 | { |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
215 | g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
216 | |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
217 | if(!g_async_result_is_tagged(result, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
218 | purple_ircv3_protocol_conversation_leave_conversation_async)) |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
219 | { |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
220 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
221 | "result has unexpected tag"); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
222 | return FALSE; |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
223 | } |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
224 | |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
225 | return g_task_propagate_boolean(G_TASK(result), error); |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
226 | } |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
227 | |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
228 | static void |
|
42889
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
229 | purple_ircv3_protocol_conversation_send_typing(G_GNUC_UNUSED PurpleProtocolConversation *protocol, |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
230 | PurpleConversation *conversation, |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
231 | PurpleTypingState state) |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
232 | { |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
233 | PurpleIRCv3Connection *connection; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
234 | PurpleAccount *account = NULL; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
235 | PurpleConnection *purple_connection = NULL; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
236 | IbisClient *client = NULL; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
237 | IbisMessage *message = NULL; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
238 | IbisTags *tags = NULL; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
239 | const char *value = NULL; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
240 | |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
241 | if(state == PURPLE_TYPING_STATE_TYPING) { |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
242 | value = IBIS_TYPING_ACTIVE; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
243 | } else if(state == PURPLE_TYPING_STATE_PAUSED) { |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
244 | value = IBIS_TYPING_PAUSED; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
245 | } else if(state == PURPLE_TYPING_STATE_NONE) { |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
246 | value = IBIS_TYPING_DONE; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
247 | } |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
248 | |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
249 | if(value == NULL) { |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
250 | return; |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
251 | } |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
252 | |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
253 | account = purple_conversation_get_account(conversation); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
254 | purple_connection = purple_account_get_connection(account); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
255 | connection = PURPLE_IRCV3_CONNECTION(purple_connection); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
256 | |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
257 | message = ibis_message_new(IBIS_MSG_TAGMSG); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
258 | ibis_message_set_params(message, purple_conversation_get_id(conversation), |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
259 | NULL); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
260 | |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
261 | tags = ibis_tags_new(); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
262 | ibis_message_set_tags(message, tags); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
263 | ibis_tags_add(tags, IBIS_TAG_TYPING, value); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
264 | g_clear_object(&tags); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
265 | |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
266 | client = purple_ircv3_connection_get_client(connection); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
267 | ibis_client_write(client, message); |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
268 | } |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
269 | |
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | void |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | purple_ircv3_protocol_conversation_init(PurpleProtocolConversationInterface *iface) { |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | iface->send_message_async = |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | purple_ircv3_protocol_conversation_send_message_async; |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | iface->send_message_finish = |
|
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | purple_ircv3_protocol_conversation_send_message_finish; |
|
42378
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
276 | |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
277 | iface->get_channel_join_details = |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
278 | purple_ircv3_protocol_conversation_get_channel_join_details; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
279 | iface->join_channel_async = |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
280 | purple_ircv3_protocol_conversation_join_channel_async; |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
281 | iface->join_channel_finish = |
|
b64cb320215a
IRCv3: Implement the channel joining functions in PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
42320
diff
changeset
|
282 | purple_ircv3_protocol_conversation_join_channel_finish; |
|
42889
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
283 | |
|
42900
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
284 | iface->leave_conversation_async = |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
285 | purple_ircv3_protocol_conversation_leave_conversation_async; |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
286 | iface->leave_conversation_finish = |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
287 | purple_ircv3_protocol_conversation_leave_conversation_finish; |
|
f7601128636b
IRCv3: Implement leaving conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42889
diff
changeset
|
288 | |
|
42889
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
289 | iface->send_typing = |
|
9e329eab0f9d
IRCv3: Implement sending typing notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42799
diff
changeset
|
290 | purple_ircv3_protocol_conversation_send_typing; |
|
42320
21cab78fb7d2
IRCv3: Move from ProtocolIM to ProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | } |