protocols/ircv3/purpleircv3connection.c

Fri, 16 Aug 2024 03:15:34 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 16 Aug 2024 03:15:34 -0500
changeset 42883
51a0fe1e2500
parent 42879
dc1e61fb9f00
child 42896
5c8f4a455d3c
permissions
-rw-r--r--

IRCv3: Handle incoming typing notifications

This also bumped Ibis to version 0.5.0 or newer.

Testing Done:
Used senpai to send typing notifications that I verified with temporary `g_warnings` in `Purple.ConversationMemember.set_typing_state`.

Called in the turtles for everything else.

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

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
42547
7a4558293dca Add birb as a subproject and make IRCv3 use it
Gary Kramlich <grim@reaperworld.com>
parents: 42544
diff changeset
25 #include <birb.h>
7a4558293dca Add birb as a subproject and make IRCv3 use it
Gary Kramlich <grim@reaperworld.com>
parents: 42544
diff changeset
26
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
27 #include <hasl.h>
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
28
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 #include "purpleircv3connection.h"
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 #include "purpleircv3core.h"
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
32 #include "purpleircv3messagehandlers.h"
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 enum {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 PROP_0,
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
36 PROP_CLIENT,
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 N_PROPERTIES,
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 };
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
41 struct _PurpleIRCv3Connection {
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
42 PurpleConnection parent;
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
43
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
44 IbisClient *client;
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
46 char *server_name;
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
47
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
48 PurpleConversation *status_conversation;
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
49 };
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
42030
7af8ab97086d Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42023
diff changeset
51 G_DEFINE_DYNAMIC_TYPE_EXTENDED(PurpleIRCv3Connection,
7af8ab97086d Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42023
diff changeset
52 purple_ircv3_connection,
7af8ab97086d Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42023
diff changeset
53 PURPLE_TYPE_CONNECTION,
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
54 G_TYPE_FLAG_FINAL,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
55 {})
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
42771
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
57 static gboolean
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
58 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
59 const char *command,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
60 IbisMessage *message,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
61 gpointer data);
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
62
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
63 static gboolean
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
64 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
65 IbisMessage *message, gpointer data);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
66
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 /******************************************************************************
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 * Helpers
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 *****************************************************************************/
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 static void
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
71 purple_ircv3_connection_rejoin_channels(PurpleIRCv3Connection *connection) {
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
72 PurpleAccount *account = NULL;
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
73 PurpleConversationManager *manager = NULL;
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
74 GList *conversations = NULL;
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
75
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
76 account = purple_connection_get_account(PURPLE_CONNECTION(connection));
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
77 manager = purple_conversation_manager_get_default();
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
78
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
79 conversations = purple_conversation_manager_get_all(manager);
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
80 while(conversations != NULL) {
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
81 PurpleConversation *conversation = conversations->data;
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
82 PurpleAccount *conv_account = NULL;
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
83
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
84 conv_account = purple_conversation_get_account(conversation);
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
85 if(conv_account == account) {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
86 IbisMessage *message = NULL;
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
87 const char *id = purple_conversation_get_id(conversation);
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
88
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
89 message = ibis_message_new(IBIS_MSG_JOIN);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
90 ibis_message_set_params(message, id, NULL);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
91 ibis_client_write(connection->client, message);
42511
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
92 }
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
93
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
94 conversations = g_list_delete_link(conversations, conversations);
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
95 }
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
96 }
77d01d3cf007 IRCv3: rejoin channels after reconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42506
diff changeset
97
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
98 static inline void
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
99 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
100 PurpleAccount *account)
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
101 {
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
102 HaslContext *hasl_context = NULL;
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
103 const char *value = NULL;
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
104 gboolean clear_text = FALSE;
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
105
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
106 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
107
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
108 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
109 if(!purple_strempty(value)) {
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
110 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
111 } else {
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
112 hasl_context_set_username(hasl_context,
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
113 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
114
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
115 /* 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
116 * 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
117 * 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
118 */
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
119 g_signal_connect_object(connection->client,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
120 "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
121 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
122 connection, G_CONNECT_DEFAULT);
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
123 }
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
124
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
125 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
126 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
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-mechanisms", 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_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
131 }
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
132
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
133 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
134 FALSE);
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
135 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
136
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
137 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
138 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
139 }
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
140
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
141 /**
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
142 * purple_ircv3_write_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
143 * @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
144 * @ibis_message: The message to write.
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
145 * @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
146 *
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
147 * Writes @ibis_message to the status window of @connection.
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
148 */
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
149 static void
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
150 purple_ircv3_write_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
151 IbisMessage *ibis_message,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
152 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
153 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
154 PurpleContact *contact = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
155 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
156 GString *str = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
157 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
158 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
159
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
160 str = g_string_new("");
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
161
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
162 if(show_command) {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
163 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
164
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
165 command = ibis_message_get_command(ibis_message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
166
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
167 if(!purple_strempty(command)) {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
168 g_string_append_printf(str, "%s ", command);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
169 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
170 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
171
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
172 params = ibis_message_get_params(ibis_message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
173 body = g_strjoinv(" ", params);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
174 g_string_append(str, body);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
175 g_free(body);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
176
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
177 contact = purple_ircv3_connection_find_or_create_contact(connection,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
178 ibis_message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
179
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
180 purple_message = purple_message_new(PURPLE_CONTACT_INFO(contact),
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
181 str->str);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
182 g_string_free(str, TRUE);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
183
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
184 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
185 purple_message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
186 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
187 }
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 /**
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
190 * 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
191 * @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
192 * @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
193 * @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
194 *
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
195 * Like purple_ircv3_write_status_message() but removes the first parameter
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
196 * which is the user's nick for server messages.
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
197 */
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
198 static void
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
199 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
200 IbisMessage *message,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
201 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
202 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
203 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
204 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
205
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
206 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
207 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
208 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
209 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
210
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
211 purple_ircv3_write_status_message(connection, message, show_command);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
212 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
213
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 /******************************************************************************
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
215 * Message Handlers
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
216 *****************************************************************************/
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
217 static void
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
218 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
219 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
220 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
221 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
222 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
223 PurpleContactInfo *contact = NULL;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
224 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
225 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
226 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
227 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
228
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
229 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
230 contact = purple_account_get_contact_info(account);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
231
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
232 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
233 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
234 if(params != NULL) {
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
235 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
236 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
237 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
238 } else {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
239 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
240 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
241
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
242 purple_message = purple_message_new(PURPLE_CONTACT_INFO(contact), body);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
243 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
244
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
245 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
246 purple_message);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
247 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
248 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
249
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
250 static gboolean
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
251 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
252 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
253 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
254 gpointer data)
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
255 {
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
256 PurpleIRCv3Connection *connection = data;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
257 PurpleAccount *account = NULL;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
258 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
259
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
260 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
261 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
262
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
263 /* 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
264 * 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
265 */
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
266 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
267 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
268
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
269 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
270 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
271 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
272 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
273
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
274 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
275 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
276
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
277 /* 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
278 * was sent.
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
279 */
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
280 return FALSE;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
281 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
282
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
283 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
284 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
285 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
286 IbisMessage *message,
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
287 gpointer data)
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
288 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
289 purple_ircv3_write_status_message(data, message, TRUE);
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 return FALSE;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
292 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
293
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
294 static gboolean
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
295 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
296 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
297 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
298 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
299 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
300 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
301
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
302 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
303 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
304 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
305 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
306
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
307 purple_ircv3_write_status_message(data, message, FALSE);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
308
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
309 return TRUE;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
310 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
311
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
312 static gboolean
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
313 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
314 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
315 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
316 {
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
317 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
318 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
319 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
320 GStrv params = NULL;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
321
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
322 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
323 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
324
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
325 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
326 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
327 /* 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
328 * 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
329 */
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
330 purple_contact_info_set_id(info, params[0]);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
331 }
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
332
42867
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
333 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
334
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
335 return TRUE;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
336 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
337
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
338 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
339 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
340 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
341 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
342 {
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
343 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
344
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
345 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
346
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
347 /* 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
348 * 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
349 */
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
350
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
351 return FALSE;
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
352 }
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
353
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
354 static gboolean
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
355 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
356 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
357 IbisMessage *message,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
358 gpointer data)
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
359 {
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
360 PurpleIRCv3Connection *connection = data;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
361 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
362 const char *source = NULL;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
363
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
364 source = ibis_message_get_source(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 purple_message = g_object_new(
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
367 PURPLE_TYPE_MESSAGE,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
368 "author", source,
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
369 "contents", _("no message of the day found"),
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
370 NULL);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
371
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
372 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
373 purple_message);
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
374 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
375
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
376 return TRUE;
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
377 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
378
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
379 static void
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
380 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
381 IbisClient *client)
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
382 {
42867
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, "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
384 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
385 connection, 0);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
386 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
387 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
388 connection, 0);
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
389
e16b8726d9b5 Echo out pings and pongs as well as the RPL_ISUPPORT message
Gary Kramlich <grim@reaperworld.com>
parents: 42815
diff changeset
390 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
391 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
392 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
393 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
394 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
395 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
396
42792
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
397 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
398 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
399 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
400 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
401 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
402 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
403 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
404 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
405 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
406 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
407 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
408 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
409 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
410 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
411 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
412 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
413 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
414 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
415 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
416 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
417 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
418 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
419 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
420 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
421 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
422 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
423 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
424 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
425 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
426 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
427 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
428 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
429 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
430 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
431 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
432 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
433 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
434 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
435 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
436 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
437 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
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 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
440 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
441 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
442
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_ERR_NOMOTD,
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_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
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
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
447 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
448 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
449 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
450 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
451 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
452 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
453 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
454 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
455 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
456
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
457 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
458 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
459 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
460 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
461 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
462 connection, G_CONNECT_DEFAULT);
42883
51a0fe1e2500 IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents: 42879
diff changeset
463 g_signal_connect_object(client, "message::" IBIS_MSG_TAGMSG,
51a0fe1e2500 IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents: 42879
diff changeset
464 G_CALLBACK(purple_ircv3_message_handler_tagmsg),
51a0fe1e2500 IRCv3: Handle incoming typing notifications
Gary Kramlich <grim@reaperworld.com>
parents: 42879
diff changeset
465 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
466
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
467 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
468 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
469 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
470 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
471 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
472 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
473
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
474 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
475 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
476 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
477 }
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
478
2d6b17c4d351 IRCv3: Handle server messages and add them to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42790
diff changeset
479 /******************************************************************************
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
480 * Callbacks
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
481 *****************************************************************************/
42771
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
482 static gboolean
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
483 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
484 G_GNUC_UNUSED const char *command,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
485 IbisMessage *message,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
486 gpointer data)
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
487 {
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
488 PurpleIRCv3Connection *connection = data;
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
489 PurpleMessage *purple_message = NULL;
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
490 char *contents = NULL;
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
491
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
492 contents = g_strdup_printf(_("unhandled message: '%s'"),
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
493 ibis_message_get_raw_message(message));
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
494
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
495 purple_message = g_object_new(
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
496 PURPLE_TYPE_MESSAGE,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
497 "author", ibis_message_get_source(message),
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
498 "contents", contents,
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
499 NULL);
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
500
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
501 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
502 purple_message);
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
503 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
504
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
505 g_free(contents);
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
506
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
507 return TRUE;
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
508 }
3dc6600c6c0e IRCv3: write the unhandled raw messages to the status window
Gary Kramlich <grim@reaperworld.com>
parents: 42770
diff changeset
509
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
510 static void
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
511 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
512 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
513 gpointer data)
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
514 {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
515 PurpleConnection *connection = data;
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
516 IbisClient *client = IBIS_CLIENT(source);
42030
7af8ab97086d Make PurpleIRCv3Connection Derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42023
diff changeset
517
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
518 if(ibis_client_get_connected(client)) {
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
519 purple_connection_set_state(connection,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
520 PURPLE_CONNECTION_STATE_CONNECTED);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
521
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
522 /* 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
523 * 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
524 */
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
525 purple_ircv3_connection_rejoin_channels(PURPLE_IRCV3_CONNECTION(connection));
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
526 } else {
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
527 purple_connection_set_state(connection,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
528 PURPLE_CONNECTION_STATE_DISCONNECTED);
41793
2e6f09066f94 Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41783
diff changeset
529 }
2e6f09066f94 Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41783
diff changeset
530 }
2e6f09066f94 Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41783
diff changeset
531
2e6f09066f94 Add connection registration to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 41783
diff changeset
532 static void
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
533 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
534 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
535 gpointer data)
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
536 {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
537 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
538 PurpleConnection *connection = data;
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
539 GError *error = NULL;
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
540
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
541 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
542 if(error != NULL) {
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
543 purple_connection_g_error(connection, error);
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
544 }
41954
558106ebf999 Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents: 41951
diff changeset
545 }
558106ebf999 Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents: 41951
diff changeset
546
42790
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
547 static void
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
548 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
549 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
550 {
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
551 /* 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
552 * 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
553 * 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
554 */
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
555 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
556 IBIS_CAPABILITY_ACCOUNT_TAG);
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
557 }
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
558
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
559 /******************************************************************************
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
560 * PurpleConnection Implementation
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
561 *****************************************************************************/
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
562 static gboolean
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
563 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
564 GError **error)
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
565 {
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
566 PurpleIRCv3Connection *connection = NULL;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
567 PurpleAccount *account = NULL;
42786
8bbe6478d623 Update to ibis 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
568 GCancellable *cancellable = NULL;
42790
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
569 IbisCapabilities *capabilities = NULL;
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
570 GError *local_error = NULL;
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
571 GProxyResolver *resolver = NULL;
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
572 const char *password = NULL;
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
573 const char *value = NULL;
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
574 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
575 int port = 0;
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
576 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
577 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
578
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
579 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
580
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
581 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
582 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
583
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
584 connection->client = ibis_client_new();
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
585 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
586 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
587 connection, G_CONNECT_DEFAULT);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
588 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
589 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
590 connection, G_CONNECT_DEFAULT);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
591 purple_ircv3_connection_add_message_handlers(connection,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
592 connection->client);
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
593
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
594 ibis_client_set_nick(connection->client,
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
595 purple_connection_get_display_name(purple_connection));
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
596
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
597 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
598 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
599
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
600 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
601 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
602
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
603 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
604
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
605 /* 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
606 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
607
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
608 /* 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
609 if(!tls) {
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
610 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
611 }
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
612 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
613
42787
a96dfca87750 IRCv3: Only set up SASL if the account requires a password
Markus Fischer <ivanhoe@fiscari.de>
parents: 42786
diff changeset
614 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
615 if(require_password) {
a96dfca87750 IRCv3: Only set up SASL if the account requires a password
Markus Fischer <ivanhoe@fiscari.de>
parents: 42786
diff changeset
616 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
617 }
42772
4103b1b41a29 IRCv3: Require Ibis 0.1.0 and wire up SASL
Gary Kramlich <grim@reaperworld.com>
parents: 42771
diff changeset
618
42786
8bbe6478d623 Update to ibis 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
619 cancellable = purple_connection_get_cancellable(purple_connection);
8bbe6478d623 Update to ibis 0.2.0
Gary Kramlich <grim@reaperworld.com>
parents: 42780
diff changeset
620
42790
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
621 /* 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
622 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
623 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
624 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
625 connection, G_CONNECT_DEFAULT);
b8ced4292cff IRCv3: request the account-tag capability if it's available
Gary Kramlich <grim@reaperworld.com>
parents: 42787
diff changeset
626
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
627 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
628 if(local_error != NULL) {
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
629 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
630
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
631 g_clear_object(&resolver);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
632 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
633
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
634 return FALSE;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
635 }
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
636
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
637 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
638 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
639
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
640 return TRUE;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
641 }
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
642
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
643 static gboolean
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
644 purple_ircv3_connection_disconnect(PurpleConnection *purple_connection,
42794
80cbeec14238 Fix SIGSEGV when disconnecting an account
Markus Fischer <ivanhoe@fiscari.de>
parents: 42792
diff changeset
645 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
646 {
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
647 PurpleIRCv3Connection *connection = NULL;
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
648
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
649 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
650
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
651 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
652
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
653 /* TODO: send QUIT command. */
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
654
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
655 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
656
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
657 return TRUE;
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
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
660 /******************************************************************************
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
661 * GObject Implementation
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
662 *****************************************************************************/
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
663 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
664 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
665 GValue *value, GParamSpec *pspec)
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
666 {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
667 PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
668
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
669 switch(param_id) {
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
670 case PROP_CLIENT:
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
671 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
672 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
673 break;
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
674 default:
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
675 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
676 break;
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
677 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
678 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
679
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
680 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
681 purple_ircv3_connection_dispose(GObject *obj) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
682 PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
683
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
684 g_clear_object(&connection->client);
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
685 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
686
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
687 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
688 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
689
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
690 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
691 purple_ircv3_connection_finalize(GObject *obj) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
692 PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
693
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
694 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
695
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
696 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
697 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
698
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
699 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
700 purple_ircv3_connection_constructed(GObject *obj) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
701 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
702 PurpleAccount *account = NULL;
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
703 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
704 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
705 const char *username = NULL;
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
706 char *title = NULL;
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
707
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
708 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
709
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
710 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
711
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
712 title = g_strdup_printf(_("status for %s"),
42803
984f8dfabb47 Update the protocols to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42794
diff changeset
713 purple_account_get_username(account));
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
714
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
715 /* 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
716 username = purple_account_get_username(account);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
717 userparts = g_strsplit(username, "@", 2);
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
718 purple_connection_set_display_name(PURPLE_CONNECTION(connection),
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
719 userparts[0]);
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
720 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
721
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
722 /* Free the userparts vector. */
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
723 g_strfreev(userparts);
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
724
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
725 /* 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
726 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
727 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
728 account,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
729 connection->server_name);
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
730
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
731 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
732 /* Create our status conversation. */
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
733 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
734 PURPLE_TYPE_CONVERSATION,
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
735 "account", account,
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
736 "id", connection->server_name,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
737 "name", connection->server_name,
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
738 "title", title,
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
739 NULL);
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
740
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
741 purple_conversation_manager_register(conversation_manager,
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
742 connection->status_conversation);
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
743 } else {
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
744 /* 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
745 g_object_ref(connection->status_conversation);
42506
bf4beafd15a3 IRCv3: Reuse existing status window if it exists
Gary Kramlich <grim@reaperworld.com>
parents: 42505
diff changeset
746 }
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
747
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
748 g_clear_pointer(&title, g_free);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
749 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
750
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
751 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
752 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
753 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
754
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
755 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
756 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
757 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
758
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
759 static void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
760 purple_ircv3_connection_class_init(PurpleIRCv3ConnectionClass *klass) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
761 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
762 PurpleConnectionClass *connection_class = PURPLE_CONNECTION_CLASS(klass);
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
763
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
764 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
765 obj_class->constructed = purple_ircv3_connection_constructed;
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
766 obj_class->dispose = purple_ircv3_connection_dispose;
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
767 obj_class->finalize = purple_ircv3_connection_finalize;
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
768
41870
7668d023ae05 Update the IRCv3 protocol plugin to the new connection setup
Gary Kramlich <grim@reaperworld.com>
parents: 41814
diff changeset
769 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
770 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
771
f8940ebd4eee Back out the PurpleProtocol->login change that returned a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents: 41812
diff changeset
772 /**
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
773 * PurpleIRCv3Connection:client:
42013
5634642aca06 Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42000
diff changeset
774 *
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
775 * 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
776 *
42619
3dd7cd0eabf1 Remove the micro version from Since tags in IRCv3 prpl
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42568
diff changeset
777 * Since: 3.0
41954
558106ebf999 Various clean ups to the IRCv3 connection process
Gary Kramlich <grim@reaperworld.com>
parents: 41951
diff changeset
778 */
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
779 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
780 "client", NULL, NULL,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
781 IBIS_TYPE_CLIENT,
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
782 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
42530
55b30ce86f17 IRCv3: Implement basic CTCP support
Gary Kramlich <grim@reaperworld.com>
parents: 42513
diff changeset
783
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
784 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
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 /******************************************************************************
42000
0b26ebc842db Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
788 * Internal API
41783
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
789 *****************************************************************************/
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
790 void
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
791 purple_ircv3_connection_register(GPluginNativePlugin *plugin) {
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
792 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
793 }
5ea6c18ef7a8 Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
794
42000
0b26ebc842db Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
795 /******************************************************************************
0b26ebc842db Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
796 * Public API
0b26ebc842db Make purple_ircv3_connection_writef public
Gary Kramlich <grim@reaperworld.com>
parents: 41977
diff changeset
797 *****************************************************************************/
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
798 IbisClient *
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
799 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
800 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
801
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
802 return connection->client;
42013
5634642aca06 Add a registered property to PurpleIRCv3Connection
Gary Kramlich <grim@reaperworld.com>
parents: 42000
diff changeset
803 }
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
804
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
805 void
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
806 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
807 IbisMessage *ibis_message)
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
808 {
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
809 PurpleMessage *message = NULL;
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
810 GString *str = NULL;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42288
diff changeset
811 GStrv params = NULL;
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
812 char *stripped = NULL;
42333
a34601ac633c Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents: 42288
diff changeset
813 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
814
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
815 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
816 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
817
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
818 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
819
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
820 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
821
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
822 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
823 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
824 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
825
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
826 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
827
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
828 g_free(joined);
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
829 }
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
830
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
831 stripped = ibis_formatting_strip(str->str);
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
832 g_string_free(str, TRUE);
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
833
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
834 message = g_object_new(
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
835 PURPLE_TYPE_MESSAGE,
42769
c488d7af2923 Move the IRCv3 protocol plugin to our new Ibis library
Gary Kramlich <grim@reaperworld.com>
parents: 42653
diff changeset
836 "author", ibis_message_get_source(ibis_message),
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
837 "contents", stripped,
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
838 NULL);
42505
cc095f9ce1f3 IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents: 42494
diff changeset
839 g_free(stripped);
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
840
42879
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
841 purple_conversation_write_message(connection->status_conversation,
dc1e61fb9f00 Make PurpleIRCv3.Protocol and PurpleIRCv3.Connection Final
Gary Kramlich <grim@reaperworld.com>
parents: 42867
diff changeset
842 message);
42275
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
843
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
844 g_clear_object(&message);
7568bf87e388 Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents: 42271
diff changeset
845 }
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
846
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
847 gboolean
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
848 purple_ircv3_connection_is_channel(PurpleIRCv3Connection *connection,
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
849 const char *id)
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
850 {
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
851 g_return_val_if_fail(PURPLE_IRCV3_IS_CONNECTION(connection), FALSE);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
852 g_return_val_if_fail(id != NULL, FALSE);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
853
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
854 return (id[0] == '#');
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
855 }
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
856
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
857 PurpleConversation *
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
858 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
859 const char *id)
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
860 {
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
861 PurpleAccount *account = NULL;
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
862 PurpleConversation *conversation = NULL;
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
863 PurpleConversationManager *manager = NULL;
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
864
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
865 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
866 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
867
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
868 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
869 manager = purple_conversation_manager_get_default();
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
870 conversation = purple_conversation_manager_find_with_id(manager, account,
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
871 id);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
872
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
873 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
874 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
875
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
876 if(purple_ircv3_connection_is_channel(connection, 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
877 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
878 }
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
879
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
880 conversation = g_object_new(
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
881 PURPLE_TYPE_CONVERSATION,
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
882 "account", account,
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
883 "id", id,
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
884 "name", id,
42770
3e1f34d33c9a IRCv3: Make sure to set the title property when creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42769
diff changeset
885 "title", id,
42494
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
886 "type", type,
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
887 NULL);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
888
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
889 purple_conversation_manager_register(manager, conversation);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
890
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
891 /* 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
892 * 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
893 */
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
894 g_object_unref(conversation);
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
895 }
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
896
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
897 return conversation;
4d6baa511e52 IRCv3: create some helper functions for finding/creating conversations
Gary Kramlich <grim@reaperworld.com>
parents: 42333
diff changeset
898 }
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
899
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
900 PurpleContact *
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
901 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
902 IbisMessage *message)
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
903 {
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
904 PurpleAccount *account = NULL;
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
905 PurpleContact *contact = NULL;
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
906 PurpleContactManager *manager = NULL;
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
907 IbisTags *tags = NULL;
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
908 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
909 char *nick = NULL;
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
910
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
911 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
912 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
913
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
914 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
915 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
916 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
917
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
918 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
919 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
920 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
921 account_tag);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
922 }
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
923 }
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
924
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
925 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
926 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
927
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
928 /* 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
929 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
930 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
931 }
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
932
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
933 /* 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
934 if(!PURPLE_IS_CONTACT(contact)) {
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
935 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
936 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
937
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
938 purple_contact_manager_add(manager, contact);
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
939 }
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
940
42815
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
941 purple_contact_info_set_sid(PURPLE_CONTACT_INFO(contact), source);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
942
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
943 g_free(nick);
95bb2ae83de7 IRCv3: Use Ibis.Message in PurpleIRCv3.Connection.find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42803
diff changeset
944
42513
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
945 return contact;
482ba61e5123 IRCv3: Add an ircv3_connection_find_or_create_contact
Gary Kramlich <grim@reaperworld.com>
parents: 42511
diff changeset
946 }

mercurial