Sun, 09 Oct 2022 04:43:37 -0500
Update PurpleProtocolClass->login to return a PurpleConnection
Testing Done:
Connected a demo, ircv3, and xmpp account.
Reviewed at https://reviews.imfreedom.org/r/1912/
|
41750
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include <glib/gi18n-lib.h> |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #include "purpleircv3protocol.h" |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
23 | #include "purpleircv3connection.h" |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
24 | #include "purpleircv3core.h" |
|
41772
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
25 | |
|
41750
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | typedef struct { |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | gboolean dummy; |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | } PurpleIRCv3ProtocolPrivate; |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | /****************************************************************************** |
|
41772
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
31 | * PurpleProtocol Implementation |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
32 | *****************************************************************************/ |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
33 | static GList * |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
34 | purple_ircv3_protocol_get_user_splits(G_GNUC_UNUSED PurpleProtocol *protocol) { |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
35 | PurpleAccountUserSplit *split = NULL; |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
36 | GList *splits = NULL; |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
37 | |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
38 | split = purple_account_user_split_new(_("Server"), |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
39 | PURPLE_IRCV3_DEFAULT_SERVER, |
|
41772
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
40 | '@'); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
41 | splits = g_list_append(splits, split); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
42 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
43 | return splits; |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
44 | } |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
45 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
46 | static GList * |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
47 | purple_ircv3_protocol_get_account_options(G_GNUC_UNUSED PurpleProtocol *protocol) |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
48 | { |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
49 | PurpleAccountOption *option; |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
50 | GList *options = NULL; |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
51 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
52 | option = purple_account_option_int_new(_("Port"), "port", |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
53 | PURPLE_IRCV3_DEFAULT_TLS_PORT); |
|
41772
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
54 | options = g_list_append(options, option); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
55 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
56 | option = purple_account_option_bool_new(_("Use TLS"), "use-tls", TRUE); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
57 | options = g_list_append(options, option); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
58 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
59 | option = purple_account_option_string_new(_("Ident name"), "ident", ""); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
60 | options = g_list_append(options, option); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
61 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
62 | option = purple_account_option_string_new(_("Real name"), "real-name", ""); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
63 | options = g_list_append(options, option); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
64 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
65 | option = purple_account_option_string_new(_("SASL login name"), |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
66 | "sasl-login-name", ""); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
67 | options = g_list_append(options, option); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
68 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
69 | option = purple_account_option_bool_new(_("Allow plaintext SASL auth over " |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
70 | "unencrypted connection"), |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
71 | "plain-sasl-in-clear", FALSE); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
72 | options = g_list_append(options, option); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
73 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
74 | option = purple_account_option_int_new(_("Seconds between sending " |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
75 | "messages"), |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
76 | "rate-limit-interval", 2); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
77 | options = g_list_append(options, option); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
78 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
79 | option = purple_account_option_int_new(_("Maximum messages to send at " |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
80 | "once"), |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
81 | "rate-limit-burst", 5); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
82 | options = g_list_append(options, option); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
83 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
84 | return options; |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
85 | } |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
86 | |
|
41799
d567f89d6a9b
Update PurpleProtocolClass->login to return a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents:
41787
diff
changeset
|
87 | static PurpleConnection * |
|
d567f89d6a9b
Update PurpleProtocolClass->login to return a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents:
41787
diff
changeset
|
88 | purple_ircv3_protocol_login(PurpleProtocol *protocol, PurpleAccount *account, |
|
d567f89d6a9b
Update PurpleProtocolClass->login to return a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents:
41787
diff
changeset
|
89 | const char *password) |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
90 | { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
91 | PurpleIRCv3Connection *connection = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
92 | PurpleConnection *purple_connection = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
93 | GError *error = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
94 | |
|
41799
d567f89d6a9b
Update PurpleProtocolClass->login to return a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents:
41787
diff
changeset
|
95 | purple_connection = purple_connection_new(protocol, account, password); |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
96 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
97 | connection = purple_ircv3_connection_new(account); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
98 | if(!purple_ircv3_connection_valid(connection, &error)) { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
99 | purple_connection_take_error(purple_connection, error); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
100 | |
|
41799
d567f89d6a9b
Update PurpleProtocolClass->login to return a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents:
41787
diff
changeset
|
101 | return purple_connection; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
102 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
103 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
104 | g_object_set_data_full(G_OBJECT(purple_connection), |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
105 | PURPLE_IRCV3_CONNECTION_KEY, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
106 | connection, g_object_unref); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
107 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
108 | purple_ircv3_connection_connect(connection); |
|
41799
d567f89d6a9b
Update PurpleProtocolClass->login to return a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents:
41787
diff
changeset
|
109 | |
|
d567f89d6a9b
Update PurpleProtocolClass->login to return a PurpleConnection
Gary Kramlich <grim@reaperworld.com>
parents:
41787
diff
changeset
|
110 | return purple_connection; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
111 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
112 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
113 | static void |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
114 | purple_ircv3_protocol_close(G_GNUC_UNUSED PurpleProtocol *protocol, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
115 | PurpleConnection *purple_connection) |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
116 | { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
117 | PurpleIRCv3Connection *connection = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
118 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
119 | connection = g_object_get_data(G_OBJECT(purple_connection), |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
120 | PURPLE_IRCV3_CONNECTION_KEY); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
121 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
122 | purple_ircv3_connection_close(connection); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
123 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
124 | /* Set our connection data to NULL which will remove the last reference. */ |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
125 | g_object_set_data(G_OBJECT(purple_connection), PURPLE_IRCV3_CONNECTION_KEY, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
126 | NULL); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
127 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
128 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
129 | static GList * |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
130 | purple_ircv3_protocol_status_types(G_GNUC_UNUSED PurpleProtocol *protocol, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
131 | PurpleAccount *account) |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
132 | { |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
133 | PurpleStatusType *type = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
134 | GList *types = NULL; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
135 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
136 | type = purple_status_type_new(PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
137 | types = g_list_append(types, type); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
138 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
139 | type = purple_status_type_new_with_attrs( |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
140 | PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
141 | "message", _("Message"), purple_value_new(G_TYPE_STRING), |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
142 | NULL); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
143 | types = g_list_append(types, type); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
144 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
145 | type = purple_status_type_new(PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
146 | types = g_list_append(types, type); |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
147 | |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
148 | return types; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
149 | } |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
150 | |
|
41772
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
151 | /****************************************************************************** |
|
41750
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | * GObject Implementation |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | *****************************************************************************/ |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | G_DEFINE_DYNAMIC_TYPE_EXTENDED( |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | PurpleIRCv3Protocol, purple_ircv3_protocol, PURPLE_TYPE_PROTOCOL, 0, |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | G_ADD_PRIVATE_DYNAMIC(PurpleIRCv3Protocol)) |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | static void |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | purple_ircv3_protocol_init(PurpleIRCv3Protocol *protocol) { |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | } |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | static void |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | purple_ircv3_protocol_class_finalize(PurpleIRCv3ProtocolClass *klass) { |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | } |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | static void |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | purple_ircv3_protocol_class_init(PurpleIRCv3ProtocolClass *klass) { |
|
41772
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
168 | PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass); |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
169 | |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
170 | protocol_class->get_user_splits = purple_ircv3_protocol_get_user_splits; |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
171 | protocol_class->get_account_options = |
|
e393090804c1
Add user splits and account options to the IRCv3 protocol
Gary Kramlich <grim@reaperworld.com>
parents:
41750
diff
changeset
|
172 | purple_ircv3_protocol_get_account_options; |
|
41783
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
173 | protocol_class->login = purple_ircv3_protocol_login; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
174 | protocol_class->close = purple_ircv3_protocol_close; |
|
5ea6c18ef7a8
Add the ability to connect to IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41772
diff
changeset
|
175 | protocol_class->status_types = purple_ircv3_protocol_status_types; |
|
41750
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | } |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | /****************************************************************************** |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | * GObject Implementation |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | *****************************************************************************/ |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | void |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | purple_ircv3_protocol_register(GPluginNativePlugin *plugin) { |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | purple_ircv3_protocol_register_type(G_TYPE_MODULE(plugin)); |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | } |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | PurpleProtocol * |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | purple_ircv3_protocol_new(void) { |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | return g_object_new( |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | PURPLE_IRCV3_TYPE_PROTOCOL, |
|
41787
d25e0133b9ea
Fix the ircv3 protocol id
Gary Kramlich <grim@reaperworld.com>
parents:
41783
diff
changeset
|
190 | "id", "prpl-ircv3", |
|
41750
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | "name", "IRCv3", |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | "description", _("Version 3 of Internet Relay Chat (IRC)."), |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | "icon-name", "im-ircv3", |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | "icon-resource-path", "/im/pidgin/libpurple/ircv3/icons", |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | "options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL | |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | OPT_PROTO_SLASH_COMMANDS_NATIVE, |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | NULL); |
|
7ab7d79ac0c5
Create a skeleton for the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | } |