protocols/ircv3/purpleircv3connection.c

Thu, 17 Jul 2025 20:28:54 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 17 Jul 2025 20:28:54 -0500
changeset 43290
01edcfbfebaa
parent 43287
1de854696dfc
permissions
-rw-r--r--

IRCv3: Implement the /me command

This was kind of forgotten about, but it's here now.

Testing Done:
Watched a packet dump to verify it was sent correct and asked people in #pidgin on libera if it came through correctly.

Reviewed at https://reviews.imfreedom.org/r/4070/

41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
5ea6c18ef7a8 Add the ability to connect to IRCv3
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: 42547
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: 42547
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: 42547
diff changeset
7 * source distribution.
31e8c7c92e2f Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents: 42547
diff changeset
8 *
31e8c7c92e2f Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents: 42547
diff changeset
9 * This library is free software; you can redistribute it and/or modify
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42568
31e8c7c92e2f Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents: 42547
diff changeset
14 * This library is distributed in the hope that it will be useful,
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
42568
31e8c7c92e2f Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents: 42547
diff changeset
20 * along with this library; if not, see <https://www.gnu.org/licenses/>.
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
43246
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
25 #include <pango/pango.h>
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
26
42547
7a4558293dca Add birb as a subproject and make IRCv3 use it
Gary Kramlich <grim@reaperworld.com>
parents: 42544
diff changeset
27 #include <birb.h>
7a4558293dca Add birb as a subproject and make IRCv3 use it
Gary Kramlich <grim@reaperworld.com>
parents: 42544
diff changeset
28
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
29 #include <hasl.h>
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
30
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 #include "purpleircv3connection.h"
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 #include "purpleircv3core.h"
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
34 #include "purpleircv3messagehandlers.h"
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
43174
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
36 #define IRCV3_STATUS_CONVERSATION_ID "@ircv3-status@"
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
37
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 enum {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 PROP_0,
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
40 PROP_CLIENT,
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 N_PROPERTIES,
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 };
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
45 struct _PurpleIRCv3Connection {
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
46 PurpleConnection parent;
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
47
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
48 IbisClient *client;
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
50 char *server_name;
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
51
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
52 PurpleConversation *status_conversation;
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
53 };
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
42030
7af8ab97086d Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42023
diff changeset
55 G_DEFINE_DYNAMIC_TYPE_EXTENDED(PurpleIRCv3Connection,
7af8ab97086d Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42023
diff changeset
56 purple_ircv3_connection,
7af8ab97086d Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42023
diff changeset
57 PURPLE_TYPE_CONNECTION,
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
58 G_TYPE_FLAG_FINAL,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
59 {})
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
42771
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
61 static gboolean
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
62 purple_ircv3_connection_unknown_message_cb(IbisClient *client,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
63 const char *command,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
64 IbisMessage *message,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
65 gpointer data);
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
66
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
67 static gboolean
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
68 purple_ircv3_connection_saslsuccess(IbisClient *client, const char *command,
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
69 IbisMessage *message, gpointer data);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
70
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 /******************************************************************************
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 * Helpers
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 *****************************************************************************/
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 static void
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
75 purple_ircv3_connection_rejoin_channels(PurpleIRCv3Connection *connection) {
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
76 PurpleAccount *account = NULL;
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
77 PurpleConversationManager *manager = NULL;
43287
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
78 GListModel *conversations = NULL;
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
79 guint n_items = 0;
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
80
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
81 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
82 manager = purple_conversation_manager_get_default();
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
83
43287
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
84 conversations = purple_conversation_manager_get_all_for_account(manager,
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
85 account);
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
86
43287
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
87 n_items = g_list_model_get_n_items(G_LIST_MODEL(conversations));
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
88 for(guint i = 0; i < n_items; i++) {
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
89 PurpleConversation *conversation = NULL;
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
90
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
91 conversation = g_list_model_get_item(G_LIST_MODEL(conversations), i);
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
92
43287
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
93 /* We set the online status and clear the error on the conversation
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
94 * so that we can get any updated value if the join fails.
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
95 */
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
96 purple_conversation_set_online(conversation, TRUE);
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
97 purple_conversation_set_error(conversation, NULL);
43098
13b0954a268b IRCv3: Fix kick detection and handle online conversation states
Gary Kramlich <grim@reaperworld.com>
parents: 43069
diff changeset
98
43287
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
99 /* If this is not the status conversation we need to rejoin it. */
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
100 if(conversation != connection->status_conversation) {
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
101 IbisMessage *message = NULL;
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
102 const char *id = NULL;
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
103
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
104 id = purple_conversation_get_id(conversation);
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
105
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
106 message = ibis_message_new(IBIS_MSG_JOIN);
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
107 ibis_message_set_params(message, id, NULL);
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
108 ibis_client_write(connection->client, message);
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
109 }
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
110
43287
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
111 g_clear_object(&conversation);
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
112 }
43287
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
113
1de854696dfc Add Purple.ConversationManager.get_all_for_account
Gary Kramlich <grim@reaperworld.com>
parents: 43254
diff changeset
114 g_clear_object(&conversations);
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
115 }
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
116
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
117 static inline void
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
118 purple_ircv3_connection_setup_sasl(PurpleIRCv3Connection *connection,
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
119 PurpleAccount *account)
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
120 {
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
121 HaslContext *hasl_context = NULL;
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
122 const char *value = NULL;
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
123 gboolean clear_text = FALSE;
43117
f347ec7ceb73 IRCv3: Tell the HASL context whether or not we're using TLS
Gary Kramlich <grim@reaperworld.com>
parents: 43116
diff changeset
124 gboolean tls = FALSE;
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
125
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
126 hasl_context = hasl_context_new();
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
127
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
128 value = purple_account_get_string(account, "sasl-login-name", NULL);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
129 if(!purple_strempty(value)) {
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
130 hasl_context_set_username(hasl_context, value);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
131 } else {
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
132 hasl_context_set_username(hasl_context,
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
133 ibis_client_get_nick(connection->client));
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
134
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
135 /* Since the user doesn't have a SASL login name set, we'll listen for
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
136 * IBIS_RPL_SASLSUCCESS and use that to set the login name to the
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
137 * username in HASL which worked if the signal handler gets called.
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
138 */
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
139 g_signal_connect_object(connection->client,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
140 "message::" IBIS_RPL_SASLSUCCESS,
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
141 G_CALLBACK(purple_ircv3_connection_saslsuccess),
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
142 connection, G_CONNECT_DEFAULT);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
143 }
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
144
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
145 value = purple_connection_get_password(PURPLE_CONNECTION(connection));
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
146 hasl_context_set_password(hasl_context, value);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
147
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
148 value = purple_account_get_string(account, "sasl-mechanisms", NULL);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
149 if(!purple_strempty(value)) {
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
150 hasl_context_set_allowed_mechanisms(hasl_context, value);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
151 }
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
152
43117
f347ec7ceb73 IRCv3: Tell the HASL context whether or not we're using TLS
Gary Kramlich <grim@reaperworld.com>
parents: 43116
diff changeset
153 tls = purple_account_get_bool(account, "use-tls", TRUE);
f347ec7ceb73 IRCv3: Tell the HASL context whether or not we're using TLS
Gary Kramlich <grim@reaperworld.com>
parents: 43116
diff changeset
154 hasl_context_set_tls(hasl_context, tls);
f347ec7ceb73 IRCv3: Tell the HASL context whether or not we're using TLS
Gary Kramlich <grim@reaperworld.com>
parents: 43116
diff changeset
155
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
156 clear_text = purple_account_get_bool(account, "plain-sasl-in-clear",
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
157 FALSE);
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
158 hasl_context_set_allow_clear_text(hasl_context, clear_text);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
159
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
160 ibis_client_set_hasl_context(connection->client, hasl_context);
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
161 g_clear_object(&hasl_context);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
162 }
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
163
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
164 /**
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
165 * purple_ircv3_write_server_status_message: (skip)
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
166 * @connection: The instance.
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
167 * @message: The message to write to the status window.
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
168 * @show_command: Whether or not to display the command.
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
169 *
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
170 * Like purple_ircv3_connection_write_status_message() but removes the first
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
171 * parameter which is the user's nick for server messages.
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
172 */
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
173 static void
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
174 purple_ircv3_write_server_status_message(PurpleIRCv3Connection *connection,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
175 IbisMessage *message,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
176 gboolean show_command)
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
177 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
178 GStrv original = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
179 GStrv extra_crispy = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
180
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
181 original = ibis_message_get_params(message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
182 extra_crispy = g_strdupv(original + 1);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
183 ibis_message_set_paramsv(message, extra_crispy);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
184 g_strfreev(extra_crispy);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
185
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
186 purple_ircv3_connection_write_status_message(connection, message,
43195
10a8a087d356 IRCv3: mark ping and pong messages as events
Gary Kramlich <grim@reaperworld.com>
parents: 43178
diff changeset
187 show_command, FALSE);
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
188 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
189
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 /******************************************************************************
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
191 * Message Handlers
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
192 *****************************************************************************/
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
193 static void
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
194 purple_ircv3_wrote_message_echo_cb(G_GNUC_UNUSED IbisClient *client,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
195 IbisMessage *message, gpointer data)
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
196 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
197 PurpleIRCv3Connection *connection = data;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
198 PurpleAccount *account = NULL;
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
199 PurpleContactInfo *info = NULL;
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
200 PurpleConversationMember *author = NULL;
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
201 PurpleMessage *purple_message = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
202 GStrv params = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
203 char *body = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
204 const char *command = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
205
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
206 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
207 info = purple_account_get_contact_info(account);
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
208
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
209 command = ibis_message_get_command(message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
210 params = ibis_message_get_params(message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
211 if(params != NULL) {
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
212 char *paramsv = g_strjoinv(" ", params);
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
213 body = g_strdup_printf("%s %s", command, paramsv);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
214 g_free(paramsv);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
215 } else {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
216 body = g_strdup(command);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
217 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
218
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
219 author = purple_conversation_find_or_add_member(connection->status_conversation,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
220 info, FALSE, NULL);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
221 purple_message = purple_message_new(author, body);
43195
10a8a087d356 IRCv3: mark ping and pong messages as events
Gary Kramlich <grim@reaperworld.com>
parents: 43178
diff changeset
222 purple_message_set_event(purple_message, TRUE);
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
223 g_clear_pointer(&body, g_free);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
224
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
225 purple_conversation_write_message(connection->status_conversation,
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
226 purple_message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
227 g_clear_object(&purple_message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
228 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
229
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
230 static gboolean
42925
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
231 purple_ircv3_message_handler_ignore(G_GNUC_UNUSED IbisClient *client,
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
232 G_GNUC_UNUSED const char *command,
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
233 G_GNUC_UNUSED IbisMessage *message,
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
234 G_GNUC_UNUSED gpointer data)
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
235 {
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
236 return TRUE;
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
237 }
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
238
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
239 static gboolean
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
240 purple_ircv3_connection_saslsuccess(IbisClient *client,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
241 G_GNUC_UNUSED const char *command,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
242 G_GNUC_UNUSED IbisMessage *message,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
243 gpointer data)
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
244 {
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
245 PurpleIRCv3Connection *connection = data;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
246 PurpleAccount *account = NULL;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
247 const char *value = NULL;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
248
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
249 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
250 value = purple_account_get_string(account, "sasl-login-name", NULL);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
251
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
252 /* If the sasl-login-name is empty, we set it to the current username in
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
253 * our hasl context that was used to login.
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
254 */
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
255 if(purple_strempty(value)) {
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
256 HaslContext *hasl_context = NULL;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
257
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
258 hasl_context = ibis_client_get_hasl_context(client);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
259 if(HASL_IS_CONTEXT(hasl_context)) {
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
260 purple_account_set_string(account, "sasl-login-name",
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
261 hasl_context_get_username(hasl_context));
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
262
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
263 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
264 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
265
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
266 /* We don't actually handle SASLSUCCESS, but we just needed to know if it
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
267 * was sent.
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
268 */
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
269 return FALSE;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
270 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
271
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
272 static gboolean
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
273 purple_ircv3_server_message_echo(G_GNUC_UNUSED IbisClient *client,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
274 G_GNUC_UNUSED const char *command,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
275 IbisMessage *message,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
276 gpointer data)
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
277 {
43195
10a8a087d356 IRCv3: mark ping and pong messages as events
Gary Kramlich <grim@reaperworld.com>
parents: 43178
diff changeset
278 purple_ircv3_connection_write_status_message(data, message, TRUE, TRUE);
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
279
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
280 return FALSE;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
281 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
282
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
283 static gboolean
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
284 purple_ircv3_server_message_handler(G_GNUC_UNUSED IbisClient *client,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
285 G_GNUC_UNUSED const char *command,
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
286 IbisMessage *message, gpointer data)
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
287 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
288 GStrv original = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
289 GStrv extra_crispy = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
290
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
291 original = ibis_message_get_params(message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
292 extra_crispy = g_strdupv(original + 1);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
293 ibis_message_set_paramsv(message, extra_crispy);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
294 g_strfreev(extra_crispy);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
295
43195
10a8a087d356 IRCv3: mark ping and pong messages as events
Gary Kramlich <grim@reaperworld.com>
parents: 43178
diff changeset
296 purple_ircv3_connection_write_status_message(data, message, FALSE, FALSE);
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
297
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
298 return TRUE;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
299 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
300
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
301 static gboolean
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
302 purple_ircv3_rpl_welcome_handler(G_GNUC_UNUSED IbisClient *client,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
303 G_GNUC_UNUSED const char *command,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
304 IbisMessage *message, gpointer data)
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
305 {
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
306 PurpleIRCv3Connection *connection = data;
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
307 PurpleAccount *account = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
308 PurpleContactInfo *info = NULL;
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
309 GStrv params = NULL;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
310
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
311 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
312 info = purple_account_get_contact_info(account);
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
313
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
314 params = ibis_message_get_params(message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
315 if(params != NULL) {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
316 /* Per https://modern.ircdocs.horse/#connection-registration the first
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
317 * parameter of RPL_WELCOME is the nick that the server assigned us.
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
318 */
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
319 purple_contact_info_set_id(info, params[0]);
42948
e1957d51b3b4 IRCv3: Stop using Purple.Connection:display-name
Gary Kramlich <grim@reaperworld.com>
parents: 42926
diff changeset
320 purple_contact_info_set_username(info, params[0]);
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
321 }
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
322
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
323 purple_ircv3_write_server_status_message(connection, message, FALSE);
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
324
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
325 return TRUE;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
326 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
327
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
328 static gboolean
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
329 purple_ircv3_server_rpl_isupport(G_GNUC_UNUSED IbisClient *client,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
330 G_GNUC_UNUSED const char *command,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
331 IbisMessage *message, gpointer data)
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
332 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
333 PurpleIRCv3Connection *connection = data;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
334
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
335 purple_ircv3_write_server_status_message(connection, message, FALSE);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
336
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
337 /* We want the default handler to run which will populate the features
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
338 * object on the client, so we return false here.
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
339 */
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
340
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
341 return FALSE;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
342 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
343
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
344 static gboolean
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
345 purple_ircv3_server_no_motd_handler(G_GNUC_UNUSED IbisClient *client,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
346 G_GNUC_UNUSED const char *command,
42898
04084609a1eb IRCv3: Use Purple.Message.new instead of GObject.new
Gary Kramlich <grim@reaperworld.com>
parents: 42896
diff changeset
347 IbisMessage *ibis_message,
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
348 gpointer data)
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
349 {
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
350 PurpleIRCv3Connection *connection = data;
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
351 PurpleContact *contact = NULL;
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
352 PurpleConversationMember *author = NULL;
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
353 PurpleMessage *purple_message = NULL;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
354
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
355 contact = purple_ircv3_connection_find_or_create_contact(connection,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
356 ibis_message);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
357 author = purple_conversation_find_or_add_member(connection->status_conversation,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
358 PURPLE_CONTACT_INFO(contact),
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
359 FALSE, NULL);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
360 purple_message = purple_message_new(author,
42898
04084609a1eb IRCv3: Use Purple.Message.new instead of GObject.new
Gary Kramlich <grim@reaperworld.com>
parents: 42896
diff changeset
361 _("no message of the day found"));
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
362 purple_conversation_write_message(connection->status_conversation,
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
363 purple_message);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
364 g_clear_object(&purple_message);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
365
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
366 return TRUE;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
367 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
368
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
369 static void
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
370 purple_ircv3_connection_add_message_handlers(PurpleIRCv3Connection *connection,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
371 IbisClient *client)
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
372 {
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
373 g_signal_connect_object(client, "wrote-message::" IBIS_MSG_PING,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
374 G_CALLBACK(purple_ircv3_wrote_message_echo_cb),
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
375 connection, 0);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
376 g_signal_connect_object(client, "wrote-message::" IBIS_MSG_PONG,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
377 G_CALLBACK(purple_ircv3_wrote_message_echo_cb),
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
378 connection, 0);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
379
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
380 g_signal_connect_object(client, "message::" IBIS_MSG_PING,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
381 G_CALLBACK(purple_ircv3_server_message_echo),
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
382 connection, G_CONNECT_DEFAULT);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
383 g_signal_connect_object(client, "message::" IBIS_MSG_PONG,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
384 G_CALLBACK(purple_ircv3_server_message_echo),
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
385 connection, G_CONNECT_DEFAULT);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
386
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
387 g_signal_connect_object(client, "message::" IBIS_RPL_WELCOME,
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
388 G_CALLBACK(purple_ircv3_rpl_welcome_handler),
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
389 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
390 g_signal_connect_object(client, "message::" IBIS_RPL_YOURHOST,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
391 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
392 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
393 g_signal_connect_object(client, "message::" IBIS_RPL_CREATED,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
394 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
395 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
396 g_signal_connect_object(client, "message::" IBIS_RPL_MYINFO,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
397 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
398 connection, G_CONNECT_DEFAULT);
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
399 g_signal_connect_object(client, "message::" IBIS_RPL_ISUPPORT,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
400 G_CALLBACK(purple_ircv3_server_rpl_isupport),
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
401 connection, G_CONNECT_DEFAULT);
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
402 g_signal_connect_object(client, "message::" IBIS_RPL_LUSERCLIENT,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
403 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
404 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
405 g_signal_connect_object(client, "message::" IBIS_RPL_LUSEROP,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
406 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
407 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
408 g_signal_connect_object(client, "message::" IBIS_RPL_LUSERUNKNOWN,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
409 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
410 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
411 g_signal_connect_object(client, "message::" IBIS_RPL_LUSERCHANNELS,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
412 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
413 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
414 g_signal_connect_object(client, "message::" IBIS_RPL_LUSERME,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
415 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
416 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
417 g_signal_connect_object(client, "message::" IBIS_RPL_LOCALUSERS,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
418 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
419 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
420 g_signal_connect_object(client, "message::" IBIS_RPL_GLOBALUSERS,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
421 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
422 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
423 g_signal_connect_object(client, "message::" IBIS_RPL_MOTD,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
424 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
425 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
426 g_signal_connect_object(client, "message::" IBIS_RPL_MOTDSTART,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
427 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
428 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
429 g_signal_connect_object(client, "message::" IBIS_RPL_UMODEIS,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
430 G_CALLBACK(purple_ircv3_server_message_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
431 connection, G_CONNECT_DEFAULT);
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
432 g_signal_connect_object(client, "message::" IBIS_ERR_YOUREBANNEDCREEP,
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
433 G_CALLBACK(purple_ircv3_server_message_handler),
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
434 connection, G_CONNECT_DEFAULT);
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
435
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
436 g_signal_connect_object(client, "message::" IBIS_ERR_NOMOTD,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
437 G_CALLBACK(purple_ircv3_server_no_motd_handler),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
438 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
439
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
440 g_signal_connect_object(client, "message::" IBIS_MSG_TOPIC,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
441 G_CALLBACK(purple_ircv3_message_handler_topic),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
442 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
443 g_signal_connect_object(client, "message::" IBIS_RPL_NOTOPIC,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
444 G_CALLBACK(purple_ircv3_message_handler_topic),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
445 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
446 g_signal_connect_object(client, "message::" IBIS_RPL_TOPIC,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
447 G_CALLBACK(purple_ircv3_message_handler_topic),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
448 connection, G_CONNECT_DEFAULT);
43238
58bca4467196 IRCv3: Handle the WHOTOPIC and CHANNEL_URL messages
Gary Kramlich <grim@reaperworld.com>
parents: 43236
diff changeset
449 g_signal_connect_object(client, "message::" IBIS_RPL_TOPICWHOTIME,
58bca4467196 IRCv3: Handle the WHOTOPIC and CHANNEL_URL messages
Gary Kramlich <grim@reaperworld.com>
parents: 43236
diff changeset
450 G_CALLBACK(purple_ircv3_message_handler_whotopic),
58bca4467196 IRCv3: Handle the WHOTOPIC and CHANNEL_URL messages
Gary Kramlich <grim@reaperworld.com>
parents: 43236
diff changeset
451 connection, G_CONNECT_DEFAULT);
58bca4467196 IRCv3: Handle the WHOTOPIC and CHANNEL_URL messages
Gary Kramlich <grim@reaperworld.com>
parents: 43236
diff changeset
452 g_signal_connect_object(client, "message::" IBIS_RPL_CHANNEL_URL,
58bca4467196 IRCv3: Handle the WHOTOPIC and CHANNEL_URL messages
Gary Kramlich <grim@reaperworld.com>
parents: 43236
diff changeset
453 G_CALLBACK(purple_ircv3_message_handler_channel_url),
58bca4467196 IRCv3: Handle the WHOTOPIC and CHANNEL_URL messages
Gary Kramlich <grim@reaperworld.com>
parents: 43236
diff changeset
454 connection, G_CONNECT_DEFAULT);
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
455
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
456 g_signal_connect_object(client, "message::" IBIS_MSG_PRIVMSG,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
457 G_CALLBACK(purple_ircv3_message_handler_privmsg),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
458 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
459 g_signal_connect_object(client, "message::" IBIS_MSG_NOTICE,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
460 G_CALLBACK(purple_ircv3_message_handler_privmsg),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
461 connection, G_CONNECT_DEFAULT);
42883
51a0fe1e2500 IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents: 42879
diff changeset
462 g_signal_connect_object(client, "message::" IBIS_MSG_TAGMSG,
51a0fe1e2500 IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents: 42879
diff changeset
463 G_CALLBACK(purple_ircv3_message_handler_tagmsg),
51a0fe1e2500 IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents: 42879
diff changeset
464 connection, G_CONNECT_DEFAULT);
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
465
43228
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
466 g_signal_connect_object(client, "message::" IBIS_MSG_AWAY,
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
467 G_CALLBACK(purple_ircv3_message_handler_away),
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
468 connection, G_CONNECT_DEFAULT);
43254
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
469 g_signal_connect_object(client, "message::" IBIS_RPL_NOWAWAY,
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
470 G_CALLBACK(purple_ircv3_message_handler_nowaway),
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
471 connection, G_CONNECT_DEFAULT);
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
472 g_signal_connect_object(client, "message::" IBIS_RPL_UNAWAY,
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
473 G_CALLBACK(purple_ircv3_message_handler_unaway),
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
474 connection, G_CONNECT_DEFAULT);
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
475 g_signal_connect_object(client, "message::" IBIS_MSG_JOIN,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
476 G_CALLBACK(purple_ircv3_message_handler_join),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
477 connection, G_CONNECT_DEFAULT);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
478 g_signal_connect_object(client, "message::" IBIS_MSG_PART,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
479 G_CALLBACK(purple_ircv3_message_handler_part),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
480 connection, G_CONNECT_DEFAULT);
43015
a743311c9c2c IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents: 43007
diff changeset
481 g_signal_connect_object(client, "message::" IBIS_MSG_NICK,
a743311c9c2c IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents: 43007
diff changeset
482 G_CALLBACK(purple_ircv3_message_handler_nick),
a743311c9c2c IRCv3: Finally handle NICK messages
Gary Kramlich <grim@reaperworld.com>
parents: 43007
diff changeset
483 connection, G_CONNECT_DEFAULT);
43007
e61836350fce IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents: 43006
diff changeset
484 g_signal_connect_object(client, "message::" IBIS_MSG_QUIT,
e61836350fce IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents: 43006
diff changeset
485 G_CALLBACK(purple_ircv3_message_handler_quit),
e61836350fce IRCv3: handle the QUIT message
Gary Kramlich <grim@reaperworld.com>
parents: 43006
diff changeset
486 connection, G_CONNECT_DEFAULT);
43024
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
487 g_signal_connect_object(client, "message::" IBIS_MSG_ERROR,
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
488 G_CALLBACK(purple_ircv3_message_handler_error),
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
489 connection, G_CONNECT_DEFAULT);
42925
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
490 g_signal_connect_object(client, "message::" IBIS_RPL_NAMREPLY,
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
491 G_CALLBACK(purple_ircv3_message_handler_namreply),
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
492 connection, G_CONNECT_DEFAULT);
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
493 g_signal_connect_object(client, "message::" IBIS_RPL_ENDOFNAMES,
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
494 G_CALLBACK(purple_ircv3_message_handler_ignore),
3c9b77d62b0d IRCv3: Handle RPL_NAMREPLY
Gary Kramlich <grim@reaperworld.com>
parents: 42898
diff changeset
495 connection, G_CONNECT_DEFAULT);
43028
dda093fe275e IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents: 43026
diff changeset
496 g_signal_connect_object(client, "message::" IBIS_MSG_WALLOPS,
dda093fe275e IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents: 43026
diff changeset
497 G_CALLBACK(purple_ircv3_message_handler_wallops),
dda093fe275e IRCv3: Create notifications for incoming WALLOPS messages
Gary Kramlich <grim@reaperworld.com>
parents: 43026
diff changeset
498 connection, G_CONNECT_DEFAULT);
43067
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
499 g_signal_connect_object(client, "message::" IBIS_MSG_KICK,
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
500 G_CALLBACK(purple_ircv3_message_handler_kick),
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
501 connection, G_CONNECT_DEFAULT);
43199
99b283ab8116 IRCv3: handle mode messages for channel modes
Gary Kramlich <grim@reaperworld.com>
parents: 43195
diff changeset
502 g_signal_connect_object(client, "message::" IBIS_MSG_MODE,
99b283ab8116 IRCv3: handle mode messages for channel modes
Gary Kramlich <grim@reaperworld.com>
parents: 43195
diff changeset
503 G_CALLBACK(purple_ircv3_message_handler_mode),
99b283ab8116 IRCv3: handle mode messages for channel modes
Gary Kramlich <grim@reaperworld.com>
parents: 43195
diff changeset
504 connection, G_CONNECT_DEFAULT);
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
505
43236
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
506 g_signal_connect_object(client, "message::" IBIS_RPL_WHOREPLY,
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
507 G_CALLBACK(purple_ircv3_message_handler_whoreply),
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
508 connection, G_CONNECT_DEFAULT);
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
509 g_signal_connect_object(client, "message::" IBIS_RPL_ENDOFWHO,
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
510 G_CALLBACK(purple_ircv3_message_handler_ignore),
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
511 connection, G_CONNECT_DEFAULT);
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
512
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
513 g_signal_connect_object(client, "message",
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
514 G_CALLBACK(purple_ircv3_connection_unknown_message_cb),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
515 connection, G_CONNECT_AFTER);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
516 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
517
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
518 /******************************************************************************
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
519 * Callbacks
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
520 *****************************************************************************/
42771
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
521 static gboolean
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
522 purple_ircv3_connection_unknown_message_cb(G_GNUC_UNUSED IbisClient *client,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
523 G_GNUC_UNUSED const char *command,
42898
04084609a1eb IRCv3: Use Purple.Message.new instead of GObject.new
Gary Kramlich <grim@reaperworld.com>
parents: 42896
diff changeset
524 IbisMessage *ibis_message,
42771
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
525 gpointer data)
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
526 {
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
527 PurpleIRCv3Connection *connection = data;
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
528 PurpleContact *contact = NULL;
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
529 PurpleConversationMember *author = NULL;
42771
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
530 PurpleMessage *purple_message = NULL;
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
531 char *contents = NULL;
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
532
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
533 contact = purple_ircv3_connection_find_or_create_contact(connection,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
534 ibis_message);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
535 author = purple_conversation_find_or_add_member(connection->status_conversation,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
536 PURPLE_CONTACT_INFO(contact),
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
537 FALSE, NULL);
42771
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
538 contents = g_strdup_printf(_("unhandled message: '%s'"),
42898
04084609a1eb IRCv3: Use Purple.Message.new instead of GObject.new
Gary Kramlich <grim@reaperworld.com>
parents: 42896
diff changeset
539 ibis_message_get_raw_message(ibis_message));
42771
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
540
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
541 purple_message = purple_message_new(author, contents);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
542 purple_conversation_write_message(connection->status_conversation,
42771
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
543 purple_message);
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
544 g_clear_object(&purple_message);
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
545
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
546 g_free(contents);
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
547
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
548 return TRUE;
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
549 }
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
550
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
551 static void
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
552 purple_ircv3_connection_connect_cb(GObject *source,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
553 G_GNUC_UNUSED GParamSpec *pspec,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
554 gpointer data)
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
555 {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
556 PurpleConnection *connection = data;
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
557 IbisClient *client = IBIS_CLIENT(source);
42030
7af8ab97086d Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42023
diff changeset
558
43042
8135b5752cec Update the protocols to the new connection state api
Gary Kramlich <grim@reaperworld.com>
parents: 43030
diff changeset
559 if(!ibis_client_get_connected(client)) {
8135b5752cec Update the protocols to the new connection state api
Gary Kramlich <grim@reaperworld.com>
parents: 43030
diff changeset
560 PurpleAccount *account = purple_connection_get_account(connection);
8135b5752cec Update the protocols to the new connection state api
Gary Kramlich <grim@reaperworld.com>
parents: 43030
diff changeset
561
8135b5752cec Update the protocols to the new connection state api
Gary Kramlich <grim@reaperworld.com>
parents: 43030
diff changeset
562 purple_account_disconnect(account);
43024
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
563 }
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
564 }
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
565
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
566 static void
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
567 purple_ircv3_connection_registered_cb(GObject *source,
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
568 G_GNUC_UNUSED GParamSpec *pspec,
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
569 gpointer data)
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
570 {
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
571 PurpleConnection *connection = data;
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
572 IbisClient *client = IBIS_CLIENT(source);
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
573
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
574 if(ibis_client_get_registered(client)) {
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
575 PurpleAccount *account = NULL;
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
576
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
577 account = purple_connection_get_account(connection);
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
578 if(!purple_account_is_connected(account)) {
43042
8135b5752cec Update the protocols to the new connection state api
Gary Kramlich <grim@reaperworld.com>
parents: 43030
diff changeset
579 purple_account_connected(account);
43024
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
580 }
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
581
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
582 /* Once reconnected, we need to rejoin any channels that the
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
583 * conversation manager has for us.
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
584 */
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
585 purple_ircv3_connection_rejoin_channels(PURPLE_IRCV3_CONNECTION(connection));
41793
2e6f09066f94 Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41783
diff changeset
586 }
2e6f09066f94 Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41783
diff changeset
587 }
2e6f09066f94 Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41783
diff changeset
588
2e6f09066f94 Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41783
diff changeset
589 static void
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
590 purple_ircv3_connection_error_cb(GObject *source,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
591 G_GNUC_UNUSED GParamSpec *pspec,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
592 gpointer data)
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
593 {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
594 IbisClient *client = IBIS_CLIENT(source);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
595 PurpleConnection *connection = data;
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
596 GError *error = NULL;
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
597
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
598 error = ibis_client_get_error(client);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
599 if(error != NULL) {
42998
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42975
diff changeset
600 PurpleAccount *account = purple_connection_get_account(connection);
9fae31173eb3 Remove Purple.Connection.error and its friends
Gary Kramlich <grim@reaperworld.com>
parents: 42975
diff changeset
601
43167
bae3d8a68760 ircv3: Remove another redundant account disconnection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 43148
diff changeset
602 purple_account_set_error(account, g_error_copy(error));
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
603 }
41954
558106ebf999 Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents: 41951
diff changeset
604 }
558106ebf999 Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents: 41951
diff changeset
605
42790
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
606 static void
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
607 purple_ircv3_connection_capabilities_ready_cb(IbisCapabilities *capabilities,
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
608 G_GNUC_UNUSED gpointer data)
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
609 {
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
610 /* account-tag just adds an account tag to everything if it's available.
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
611 * The account-tag is the user's username for authentication for all users
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
612 * not just the one using libpurple.
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
613 */
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
614 ibis_capabilities_lookup_and_request(capabilities,
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
615 IBIS_CAPABILITY_ACCOUNT_TAG);
43228
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
616
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
617 /* away-notify tells us when users in a channel go away or come back. */
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
618 ibis_capabilities_lookup_and_request(capabilities,
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
619 IBIS_CAPABILITY_AWAY_NOTIFY);
43236
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
620
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
621 /* no-implicit-names tells the server to not send us the namreply message
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
622 * when joining a channel. These messages are not useful to use since we
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
623 * immediately send a WHO command on the channel when we join which has a
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
624 * super set of the information in namreply.
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
625 */
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
626 ibis_capabilities_lookup_and_request(capabilities,
ce4987105a4e IRCv3: Do a who after joining a channel
Gary Kramlich <grim@reaperworld.com>
parents: 43228
diff changeset
627 IBIS_CAPABILITY_NO_IMPLICIT_NAMES);
42790
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
628 }
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
629
43174
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
630 static void
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
631 purple_ircv3_connection_update_status_title_cb(G_GNUC_UNUSED GObject *obj,
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
632 G_GNUC_UNUSED GParamSpec *pspec,
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
633 gpointer data)
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
634 {
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
635 PurpleIRCv3Connection *connection = data;
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
636 char *title = NULL;
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
637 const char *nick = NULL;
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
638 const char *network = NULL;
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
639
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
640 nick = ibis_client_get_active_nick(connection->client);
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
641
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
642 network = ibis_client_get_network(connection->client);
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
643 if(purple_strempty(network)) {
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
644 network = connection->server_name;
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
645 }
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
646
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
647 title = g_strdup_printf(_("status %s on %s"), nick, network);
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
648 purple_conversation_set_title(connection->status_conversation, title);
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
649 g_free(title);
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
650 }
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
651
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
652 /******************************************************************************
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
653 * PurpleConnection Implementation
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
654 *****************************************************************************/
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
655 static gboolean
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
656 purple_ircv3_connection_connect(PurpleConnection *purple_connection,
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
657 GError **error)
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
658 {
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
659 PurpleIRCv3Connection *connection = NULL;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
660 PurpleAccount *account = NULL;
42786
8bbe6478d623 Update to ibis 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
661 GCancellable *cancellable = NULL;
42790
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
662 IbisCapabilities *capabilities = NULL;
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
663 GError *local_error = NULL;
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
664 GProxyResolver *resolver = NULL;
42955
a7ce6e2d6408 IRCv3: Send the correct nick when connecting
Gary Kramlich <grim@reaperworld.com>
parents: 42948
diff changeset
665 GStrv userparts = NULL;
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
666 const char *password = NULL;
42955
a7ce6e2d6408 IRCv3: Send the correct nick when connecting
Gary Kramlich <grim@reaperworld.com>
parents: 42948
diff changeset
667 const char *username = NULL;
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
668 const char *value = NULL;
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
669 int default_port = PURPLE_IRCV3_DEFAULT_TLS_PORT;
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
670 int port = 0;
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
671 gboolean tls = TRUE;
42787
a96dfca87750 IRCv3: Only set up SASL if the account requires a password
Markus Fischer <ivanhoe@fiscari.de>
parents: 42786
diff changeset
672 gboolean require_password = FALSE;
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
673
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
674 g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(purple_connection), FALSE);
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
675
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
676 connection = PURPLE_IRCV3_CONNECTION(purple_connection);
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
677 account = purple_connection_get_account(purple_connection);
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
678
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
679 connection->client = ibis_client_new();
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
680 g_signal_connect_object(connection->client, "notify::connected",
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
681 G_CALLBACK(purple_ircv3_connection_connect_cb),
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
682 connection, G_CONNECT_DEFAULT);
43024
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
683 g_signal_connect_object(connection->client, "notify::registered",
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
684 G_CALLBACK(purple_ircv3_connection_registered_cb),
8a7be63f83e4 IRCv3: Handle ERROR messages
Gary Kramlich <grim@reaperworld.com>
parents: 43015
diff changeset
685 connection, G_CONNECT_DEFAULT);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
686 g_signal_connect_object(connection->client, "notify::error",
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
687 G_CALLBACK(purple_ircv3_connection_error_cb),
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
688 connection, G_CONNECT_DEFAULT);
43174
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
689 g_signal_connect_object(connection->client, "notify::active-nick",
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
690 G_CALLBACK(purple_ircv3_connection_update_status_title_cb),
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
691 connection, G_CONNECT_DEFAULT);
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
692 g_signal_connect_object(connection->client, "notify::network",
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
693 G_CALLBACK(purple_ircv3_connection_update_status_title_cb),
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
694 connection, G_CONNECT_DEFAULT);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
695 purple_ircv3_connection_add_message_handlers(connection,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
696 connection->client);
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
697
42955
a7ce6e2d6408 IRCv3: Send the correct nick when connecting
Gary Kramlich <grim@reaperworld.com>
parents: 42948
diff changeset
698 /* We need to split the username to get the nick. */
a7ce6e2d6408 IRCv3: Send the correct nick when connecting
Gary Kramlich <grim@reaperworld.com>
parents: 42948
diff changeset
699 username = purple_account_get_username(account);
a7ce6e2d6408 IRCv3: Send the correct nick when connecting
Gary Kramlich <grim@reaperworld.com>
parents: 42948
diff changeset
700 userparts = g_strsplit(username, "@", 2);
a7ce6e2d6408 IRCv3: Send the correct nick when connecting
Gary Kramlich <grim@reaperworld.com>
parents: 42948
diff changeset
701 ibis_client_set_nick(connection->client, userparts[0]);
a7ce6e2d6408 IRCv3: Send the correct nick when connecting
Gary Kramlich <grim@reaperworld.com>
parents: 42948
diff changeset
702 g_strfreev(userparts);
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
703
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
704 value = purple_account_get_string(account, "ident", NULL);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
705 ibis_client_set_username(connection->client, value);
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
706
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
707 value = purple_account_get_string(account, "real-name", NULL);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
708 ibis_client_set_realname(connection->client, value);
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
709
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
710 password = purple_account_get_string(account, "server-password", NULL);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
711
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
712 /* Turn on TLS if requested. */
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
713 tls = purple_account_get_bool(account, "use-tls", TRUE);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
714
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
715 /* If TLS is not being used, set the default port to the plain port. */
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
716 if(!tls) {
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
717 default_port = PURPLE_IRCV3_DEFAULT_PLAIN_PORT;
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
718 }
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
719 port = purple_account_get_int(account, "port", default_port);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
720
42787
a96dfca87750 IRCv3: Only set up SASL if the account requires a password
Markus Fischer <ivanhoe@fiscari.de>
parents: 42786
diff changeset
721 require_password = purple_account_get_require_password(account);
a96dfca87750 IRCv3: Only set up SASL if the account requires a password
Markus Fischer <ivanhoe@fiscari.de>
parents: 42786
diff changeset
722 if(require_password) {
a96dfca87750 IRCv3: Only set up SASL if the account requires a password
Markus Fischer <ivanhoe@fiscari.de>
parents: 42786
diff changeset
723 purple_ircv3_connection_setup_sasl(connection, account);
a96dfca87750 IRCv3: Only set up SASL if the account requires a password
Markus Fischer <ivanhoe@fiscari.de>
parents: 42786
diff changeset
724 }
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
725
42786
8bbe6478d623 Update to ibis 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
726 cancellable = purple_connection_get_cancellable(purple_connection);
8bbe6478d623 Update to ibis 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
727
42790
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
728 /* Connect to the ready signal of capabilities. */
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
729 capabilities = ibis_client_get_capabilities(connection->client);
42790
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
730 g_signal_connect_object(capabilities, "ready",
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
731 G_CALLBACK(purple_ircv3_connection_capabilities_ready_cb),
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
732 connection, G_CONNECT_DEFAULT);
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
733
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
734 resolver = purple_proxy_get_proxy_resolver(account, &local_error);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
735 if(local_error != NULL) {
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
736 g_propagate_error(error, local_error);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
737
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
738 g_clear_object(&resolver);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
739 g_clear_object(&connection->client);
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
740
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
741 return FALSE;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
742 }
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
743
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
744 ibis_client_connect(connection->client, connection->server_name, port,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
745 password, tls, cancellable, resolver);
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
746
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
747 return TRUE;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
748 }
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
749
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
750 static gboolean
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
751 purple_ircv3_connection_disconnect(PurpleConnection *purple_connection,
42794
80cbeec14238 Fix SIGSEGV when disconnecting an account
Markus Fischer <ivanhoe@fiscari.de>
parents: 42792
diff changeset
752 G_GNUC_UNUSED GError **error)
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
753 {
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
754 PurpleIRCv3Connection *connection = NULL;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
755
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
756 g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(purple_connection), FALSE);
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
757
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
758 connection = PURPLE_IRCV3_CONNECTION(purple_connection);
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
759
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
760 /* TODO: send QUIT command. */
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
761
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
762 g_clear_object(&connection->client);
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
763
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
764 return TRUE;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
765 }
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
766
42543
6dcf672547fe IRCv3: Update the signals so that handlers can inhibit the message from being displayed
Gary Kramlich <grim@reaperworld.com>
parents: 42542
diff changeset
767 /******************************************************************************
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
768 * GObject Implementation
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
769 *****************************************************************************/
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
770 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
771 purple_ircv3_connection_get_property(GObject *obj, guint param_id,
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
772 GValue *value, GParamSpec *pspec)
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
773 {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
774 PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
775
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
776 switch(param_id) {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
777 case PROP_CLIENT:
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
778 g_value_set_object(value,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
779 purple_ircv3_connection_get_client(connection));
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
780 break;
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
781 default:
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
782 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
783 break;
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
784 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
785 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
786
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
787 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
788 purple_ircv3_connection_dispose(GObject *obj) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
789 PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
790
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
791 g_clear_object(&connection->client);
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
792 g_clear_object(&connection->status_conversation);
41796
ebe4ff278b02 Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents: 41793
diff changeset
793
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
794 G_OBJECT_CLASS(purple_ircv3_connection_parent_class)->dispose(obj);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
795 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
796
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
797 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
798 purple_ircv3_connection_finalize(GObject *obj) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
799 PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
800
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
801 g_clear_pointer(&connection->server_name, g_free);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
802
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
803 G_OBJECT_CLASS(purple_ircv3_connection_parent_class)->finalize(obj);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
804 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
805
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
806 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
807 purple_ircv3_connection_constructed(GObject *obj) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
808 PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj);
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
809 PurpleAccount *account = NULL;
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
810 PurpleConversationManager *conversation_manager = NULL;
42133
e9a794bfe183 IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents: 42030
diff changeset
811 char **userparts = NULL;
e9a794bfe183 IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents: 42030
diff changeset
812 const char *username = NULL;
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
813
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
814 G_OBJECT_CLASS(purple_ircv3_connection_parent_class)->constructed(obj);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
815
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
816 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
817
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
818 /* Split the username into nick and server and store the values. */
42803
984f8dfabb47 Update the protocols to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42794
diff changeset
819 username = purple_account_get_username(account);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
820 userparts = g_strsplit(username, "@", 2);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
821 connection->server_name = g_strdup(userparts[1]);
42133
e9a794bfe183 IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents: 42030
diff changeset
822
e9a794bfe183 IRCv3: Set the SASL login name to the current nick if not set during connection
Gary Kramlich <grim@reaperworld.com>
parents: 42030
diff changeset
823 /* Free the userparts vector. */
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
824 g_strfreev(userparts);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
825
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
826 /* Check if we have an existing status conversation. */
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
827 conversation_manager = purple_conversation_manager_get_default();
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
828 connection->status_conversation = purple_conversation_manager_find_with_id(conversation_manager,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
829 account,
43174
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
830 IRCV3_STATUS_CONVERSATION_ID);
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
831
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
832 if(!PURPLE_IS_CONVERSATION(connection->status_conversation)) {
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
833 /* Create our status conversation. */
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
834 connection->status_conversation = g_object_new(
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
835 PURPLE_TYPE_CONVERSATION,
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
836 "account", account,
43174
94bf15b8dad0 IRCv3: Update the status window title when the user's nick changes
Gary Kramlich <grim@reaperworld.com>
parents: 43170
diff changeset
837 "id", IRCV3_STATUS_CONVERSATION_ID,
43098
13b0954a268b IRCv3: Fix kick detection and handle online conversation states
Gary Kramlich <grim@reaperworld.com>
parents: 43069
diff changeset
838 "online", TRUE,
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
839 NULL);
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
840
43030
97ed7473351f Update the protocols for the ConversationManager deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 43028
diff changeset
841 purple_conversation_manager_add(conversation_manager,
97ed7473351f Update the protocols for the ConversationManager deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 43028
diff changeset
842 connection->status_conversation);
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
843 } else {
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
844 /* The conversation existed, so add a reference to it. */
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
845 g_object_ref(connection->status_conversation);
43098
13b0954a268b IRCv3: Fix kick detection and handle online conversation states
Gary Kramlich <grim@reaperworld.com>
parents: 43069
diff changeset
846
13b0954a268b IRCv3: Fix kick detection and handle online conversation states
Gary Kramlich <grim@reaperworld.com>
parents: 43069
diff changeset
847 purple_conversation_set_online(connection->status_conversation, TRUE);
13b0954a268b IRCv3: Fix kick detection and handle online conversation states
Gary Kramlich <grim@reaperworld.com>
parents: 43069
diff changeset
848 purple_conversation_set_error(connection->status_conversation, NULL);
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
849 }
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
850 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
851
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
852 static void
41941
355bd17297f0 Set the C standard to C99 and set warning_level to 2 for the IRCv3 Protocol Plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41870
diff changeset
853 purple_ircv3_connection_init(G_GNUC_UNUSED PurpleIRCv3Connection *connection) {
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
854 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
855
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
856 static void
41941
355bd17297f0 Set the C standard to C99 and set warning_level to 2 for the IRCv3 Protocol Plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41870
diff changeset
857 purple_ircv3_connection_class_finalize(G_GNUC_UNUSED PurpleIRCv3ConnectionClass *klass) {
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
858 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
859
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
860 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
861 purple_ircv3_connection_class_init(PurpleIRCv3ConnectionClass *klass) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
862 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
863 PurpleConnectionClass *connection_class = PURPLE_CONNECTION_CLASS(klass);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
864
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
865 obj_class->get_property = purple_ircv3_connection_get_property;
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
866 obj_class->constructed = purple_ircv3_connection_constructed;
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
867 obj_class->dispose = purple_ircv3_connection_dispose;
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
868 obj_class->finalize = purple_ircv3_connection_finalize;
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
869
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
870 connection_class->connect = purple_ircv3_connection_connect;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
871 connection_class->disconnect = purple_ircv3_connection_disconnect;
41814
f8940ebd4eee Back out the PurpleProtocol->login change that returned a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41812
diff changeset
872
f8940ebd4eee Back out the PurpleProtocol->login change that returned a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41812
diff changeset
873 /**
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
874 * PurpleIRCv3Connection:client:
42013
5634642aca06 Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42000
diff changeset
875 *
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
876 * The [class@Ibis.Client] that this connection is using.
41954
558106ebf999 Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents: 41951
diff changeset
877 *
42619
3dd7cd0eabf1 Remove the micro version from Since tags in IRCv3 prpl
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42568
diff changeset
878 * Since: 3.0
41954
558106ebf999 Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents: 41951
diff changeset
879 */
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
880 properties[PROP_CLIENT] = g_param_spec_object(
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
881 "client", NULL, NULL,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
882 IBIS_TYPE_CLIENT,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
883 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
42530
55b30ce86f17 IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents: 42513
diff changeset
884
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
885 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
886 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
887
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
888 /******************************************************************************
42000
0b26ebc842db Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
889 * Internal API
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
890 *****************************************************************************/
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
891 void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
892 purple_ircv3_connection_register(GPluginNativePlugin *plugin) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
893 purple_ircv3_connection_register_type(G_TYPE_MODULE(plugin));
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
894 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
895
42000
0b26ebc842db Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
896 /******************************************************************************
0b26ebc842db Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
897 * Public API
0b26ebc842db Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
898 *****************************************************************************/
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
899 IbisClient *
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
900 purple_ircv3_connection_get_client(PurpleIRCv3Connection *connection) {
41807
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41805
diff changeset
901 g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection), NULL);
66d473190e94 Start adding capability support to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents: 41805
diff changeset
902
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
903 return connection->client;
42013
5634642aca06 Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42000
diff changeset
904 }
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
905
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
906 void
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
907 purple_ircv3_connection_add_status_message(PurpleIRCv3Connection *connection,
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
908 IbisMessage *ibis_message)
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
909 {
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
910 PurpleContact *contact = NULL;
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
911 PurpleConversationMember *author = NULL;
42898
04084609a1eb IRCv3: Use Purple.Message.new instead of GObject.new
Gary Kramlich <grim@reaperworld.com>
parents: 42896
diff changeset
912 PurpleMessage *purple_message = NULL;
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
913 GString *str = NULL;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42288
diff changeset
914 GStrv params = NULL;
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
915 char *stripped = NULL;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42288
diff changeset
916 const char *command = NULL;
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
917
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
918 g_return_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection));
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
919 g_return_if_fail(IBIS_IS_MESSAGE(ibis_message));
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
920
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
921 command = ibis_message_get_command(ibis_message);
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42288
diff changeset
922
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
923 str = g_string_new(command);
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
924
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
925 params = ibis_message_get_params(ibis_message);
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42288
diff changeset
926 if(params != NULL && params[0] != NULL) {
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
927 char *joined = g_strjoinv(" ", params);
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
928
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
929 g_string_append_printf(str, " %s", joined);
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
930
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
931 g_free(joined);
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
932 }
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
933
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
934 stripped = ibis_formatting_strip(str->str);
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
935 g_string_free(str, TRUE);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
936
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
937 contact = purple_ircv3_connection_find_or_create_contact(connection,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
938 ibis_message);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
939 author = purple_conversation_find_or_add_member(connection->status_conversation,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
940 PURPLE_CONTACT_INFO(contact),
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
941 FALSE, NULL);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
942 purple_message = purple_message_new(author, stripped);
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
943 g_free(stripped);
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
944
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
945 purple_conversation_write_message(connection->status_conversation,
42898
04084609a1eb IRCv3: Use Purple.Message.new instead of GObject.new
Gary Kramlich <grim@reaperworld.com>
parents: 42896
diff changeset
946 purple_message);
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
947
42898
04084609a1eb IRCv3: Use Purple.Message.new instead of GObject.new
Gary Kramlich <grim@reaperworld.com>
parents: 42896
diff changeset
948 g_clear_object(&purple_message);
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
949 }
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
950
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
951 PurpleConversation *
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
952 purple_ircv3_connection_find_or_create_conversation(PurpleIRCv3Connection *connection,
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
953 const char *id)
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
954 {
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
955 PurpleAccount *account = NULL;
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
956 PurpleConversation *conversation = NULL;
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
957 PurpleConversationManager *manager = NULL;
43200
163d7b5a8364 IRCv3: Normalize channel names when joining and looking for existing ones
Gary Kramlich <grim@reaperworld.com>
parents: 43199
diff changeset
958 char *normalized_id = NULL;
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
959
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
960 g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection), NULL);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
961 g_return_val_if_fail(id != NULL, NULL);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
962
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
963 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
964 manager = purple_conversation_manager_get_default();
43200
163d7b5a8364 IRCv3: Normalize channel names when joining and looking for existing ones
Gary Kramlich <grim@reaperworld.com>
parents: 43199
diff changeset
965
163d7b5a8364 IRCv3: Normalize channel names when joining and looking for existing ones
Gary Kramlich <grim@reaperworld.com>
parents: 43199
diff changeset
966 normalized_id = ibis_client_normalize(connection->client, id);
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
967 conversation = purple_conversation_manager_find_with_id(manager, account,
43200
163d7b5a8364 IRCv3: Normalize channel names when joining and looking for existing ones
Gary Kramlich <grim@reaperworld.com>
parents: 43199
diff changeset
968 normalized_id);
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
969
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
970 if(!PURPLE_IS_CONVERSATION(conversation)) {
42653
584895b844d2 PurpleConversationType's values were pascal case when they should be upper snake case
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
971 PurpleConversationType type = PURPLE_CONVERSATION_TYPE_DM;
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
972
42896
5c8f4a455d3c IRCv3: Use Ibis.Client.is_channel instead of our old version
Gary Kramlich <grim@reaperworld.com>
parents: 42883
diff changeset
973 if(ibis_client_is_channel(connection->client, id)) {
42653
584895b844d2 PurpleConversationType's values were pascal case when they should be upper snake case
Gary Kramlich <grim@reaperworld.com>
parents: 42652
diff changeset
974 type = PURPLE_CONVERSATION_TYPE_CHANNEL;
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
975 }
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
976
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
977 conversation = g_object_new(
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
978 PURPLE_TYPE_CONVERSATION,
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
979 "account", account,
43200
163d7b5a8364 IRCv3: Normalize channel names when joining and looking for existing ones
Gary Kramlich <grim@reaperworld.com>
parents: 43199
diff changeset
980 "id", normalized_id,
42770
3e1f34d33c9a IRCv3: Make sure to set the title property when creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
981 "title", id,
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
982 "type", type,
43178
c1ee3a2f783e Update the IRCv3 and Demo protocol plugins to default conversations to online
Gary Kramlich <grim@reaperworld.com>
parents: 43174
diff changeset
983 "online", TRUE,
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
984 NULL);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
985
43030
97ed7473351f Update the protocols for the ConversationManager deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 43028
diff changeset
986 purple_conversation_manager_add(manager, conversation);
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
987
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
988 /* The manager creates its own reference on our new conversation, so we
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
989 * borrow it like we do above if it already exists.
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
990 */
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
991 g_object_unref(conversation);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
992 }
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
993
43200
163d7b5a8364 IRCv3: Normalize channel names when joining and looking for existing ones
Gary Kramlich <grim@reaperworld.com>
parents: 43199
diff changeset
994 g_free(normalized_id);
163d7b5a8364 IRCv3: Normalize channel names when joining and looking for existing ones
Gary Kramlich <grim@reaperworld.com>
parents: 43199
diff changeset
995
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
996 return conversation;
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
997 }
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
998
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
999 PurpleContact *
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1000 purple_ircv3_connection_find_or_create_contact(PurpleIRCv3Connection *connection,
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1001 IbisMessage *message)
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1002 {
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1003 PurpleAccount *account = NULL;
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1004 PurpleContact *contact = NULL;
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1005 PurpleContactManager *manager = NULL;
43228
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
1006 PurplePresence *presence = NULL;
43254
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1007 PurplePresencePrimitive cur_primitive = PURPLE_PRESENCE_PRIMITIVE_OFFLINE;
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1008 IbisTags *tags = NULL;
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1009 const char *source = NULL;
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1010 char *nick = NULL;
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1011
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1012 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1013 manager = purple_contact_manager_get_default();
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1014
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1015 tags = ibis_message_get_tags(message);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1016 if(IBIS_IS_TAGS(tags)) {
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1017 const char *account_tag = NULL;
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1018
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1019 account_tag = ibis_tags_lookup(tags, IBIS_TAG_ACCOUNT);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1020 if(!purple_strempty(account_tag)) {
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1021 contact = purple_contact_manager_find_with_id(manager, account,
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1022 account_tag);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1023 }
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1024 }
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1025
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1026 source = ibis_message_get_source(message);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1027 ibis_source_parse(source, &nick, NULL, NULL);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1028
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1029 /* If we don't have a contact yet, use the source (Luke) to search next. */
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1030 if(!PURPLE_IS_CONTACT(contact)) {
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1031 contact = purple_contact_manager_find_with_id(manager, account, nick);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1032 }
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1033
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1034 /* If we _still_ don't have a contact, create it. */
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1035 if(!PURPLE_IS_CONTACT(contact)) {
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1036 contact = purple_contact_new(account, nick);
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1037 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact), nick);
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1038
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1039 purple_contact_manager_add(manager, contact);
43067
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1040
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1041 /* We don't return a reference and the manager add its own. */
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1042 g_object_unref(G_OBJECT(contact));
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1043 }
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1044
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1045 purple_contact_info_set_sid(PURPLE_CONTACT_INFO(contact), source);
42975
c77cf8366ec6 IRCv3: Use the nick as the display name
Gary Kramlich <grim@reaperworld.com>
parents: 42955
diff changeset
1046 purple_contact_info_set_display_name(PURPLE_CONTACT_INFO(contact), nick);
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1047
43254
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1048 /*
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1049 * Grab the presence and set it as online if we were offline. It's possible
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1050 * that we're already AWAY due to an RPL_NOWAWAY message.
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1051 */
43228
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
1052 presence = purple_contact_info_get_presence(PURPLE_CONTACT_INFO(contact));
43254
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1053
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1054 cur_primitive = purple_presence_get_primitive(presence);
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1055 if (cur_primitive == PURPLE_PRESENCE_PRIMITIVE_OFFLINE) {
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1056 purple_presence_set_primitive(presence,
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1057 PURPLE_PRESENCE_PRIMITIVE_AVAILABLE);
27610c58b03b IRCv3: handle RPL_NOWAWAY and RPL_UNAWAY messages
Markus Fischer <ivanhoe@fiscari.de>
parents: 43246
diff changeset
1058 }
43228
6f895d255386 IRCv3: add support for away-notify
Gary Kramlich <grim@reaperworld.com>
parents: 43200
diff changeset
1059
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1060 g_free(nick);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
1061
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1062 return contact;
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
1063 }
42926
c63faf01193e Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42925
diff changeset
1064
43067
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1065 PurpleContact *
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1066 purple_ircv3_connection_find_or_create_contact_from_nick(PurpleIRCv3Connection *connection,
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1067 const char *nick)
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1068 {
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1069 PurpleAccount *account = NULL;
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1070 PurpleContact *contact = NULL;
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1071 PurpleContactManager *manager = NULL;
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1072
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1073 g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection), NULL);
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1074 g_return_val_if_fail(!purple_strempty(nick), NULL);
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1075
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1076 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1077 manager = purple_contact_manager_get_default();
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1078
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1079 contact = purple_contact_manager_find_with_id(manager, account, nick);
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1080 if(!PURPLE_IS_CONTACT(contact)) {
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1081 contact = purple_contact_manager_find_with_username(manager, account,
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1082 nick);
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1083 }
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1084
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1085 if(!PURPLE_IS_CONTACT(contact)) {
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1086 PurpleAccount *account = NULL;
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1087
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1088 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1089
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1090 contact = purple_contact_new(account, nick);
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1091 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact), nick);
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1092 purple_contact_info_set_display_name(PURPLE_CONTACT_INFO(contact),
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1093 nick);
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1094
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1095 purple_contact_manager_add(manager, contact);
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1096 g_object_unref(G_OBJECT(contact));
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1097 }
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1098
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1099 return contact;
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1100 }
7e8b86e7dc43 IRCv3: Implement the KICK command
Gary Kramlich <grim@reaperworld.com>
parents: 43042
diff changeset
1101
42926
c63faf01193e Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42925
diff changeset
1102 PurpleConversation *
c63faf01193e Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42925
diff changeset
1103 purple_ircv3_connection_get_status_conversation(PurpleIRCv3Connection *connection)
c63faf01193e Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42925
diff changeset
1104 {
c63faf01193e Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42925
diff changeset
1105 g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection), NULL);
c63faf01193e Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42925
diff changeset
1106
c63faf01193e Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42925
diff changeset
1107 return connection->status_conversation;
c63faf01193e Display CTCP requests in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42925
diff changeset
1108 }
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1109
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1110 void
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1111 purple_ircv3_connection_write_status_message(PurpleIRCv3Connection *connection,
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1112 IbisMessage *ibis_message,
43195
10a8a087d356 IRCv3: mark ping and pong messages as events
Gary Kramlich <grim@reaperworld.com>
parents: 43178
diff changeset
1113 gboolean show_command,
10a8a087d356 IRCv3: mark ping and pong messages as events
Gary Kramlich <grim@reaperworld.com>
parents: 43178
diff changeset
1114 gboolean event)
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1115 {
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1116 PurpleContact *contact = NULL;
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
1117 PurpleConversationMember *author = NULL;
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1118 PurpleMessage *purple_message = NULL;
43246
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1119 PangoAttrList *attrs = NULL;
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1120 GString *str = NULL;
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1121 GStrv params = NULL;
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1122 char *body = NULL;
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1123 char *stripped = NULL;
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1124
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1125 str = g_string_new("");
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1126
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1127 if(show_command) {
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1128 const char *command = NULL;
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1129
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1130 command = ibis_message_get_command(ibis_message);
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1131
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1132 if(!purple_strempty(command)) {
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1133 g_string_append_printf(str, "%s ", command);
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1134 }
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1135 }
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1136
43246
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1137
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1138 params = ibis_message_get_params(ibis_message);
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1139 body = g_strjoinv(" ", params);
43246
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1140
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1141 /* Grab the attributes and offset them for however many bytes are already
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1142 * in the string.
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1143 */
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1144 stripped = ibis_formatting_parse(body, &attrs);
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1145 pango_attr_list_update(attrs, 0, 0, str->len);
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1146
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1147 g_free(body);
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1148 g_string_append(str, stripped);
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1149 g_free(stripped);
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1150
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1151 contact = purple_ircv3_connection_find_or_create_contact(connection,
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1152 ibis_message);
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
1153 author = purple_conversation_find_or_add_member(connection->status_conversation,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
1154 PURPLE_CONTACT_INFO(contact),
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
1155 FALSE, NULL);
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1156
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43098
diff changeset
1157 purple_message = purple_message_new(author, str->str);
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1158 g_string_free(str, TRUE);
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1159
43246
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1160 purple_message_set_attributes(purple_message, attrs);
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1161 pango_attr_list_unref(attrs);
0e9bbe9b4da8 Handle formatting in server messages
Gary Kramlich <grim@reaperworld.com>
parents: 43238
diff changeset
1162
43195
10a8a087d356 IRCv3: mark ping and pong messages as events
Gary Kramlich <grim@reaperworld.com>
parents: 43178
diff changeset
1163 purple_message_set_event(purple_message, event);
10a8a087d356 IRCv3: mark ping and pong messages as events
Gary Kramlich <grim@reaperworld.com>
parents: 43178
diff changeset
1164
43069
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1165 purple_conversation_write_message(connection->status_conversation,
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1166 purple_message);
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1167 g_clear_object(&purple_message);
cc8ba79c350e IRCv3: Display the contents of ERROR messages in the status window
Gary Kramlich <grim@reaperworld.com>
parents: 43067
diff changeset
1168 }

mercurial