Mon, 08 Mar 2021 23:22:02 -0600
Modernize PurpleProtocol
* Migrate PurpleProtocol to the `G_DECLARE_DERIVABLE_TYPE` and `G_DEFINE_TYPE` macros.
* Rename `purple_protocol_class_*` to `purple_protocol_*`.
* Move the class properties to instance properties and add accessors as necessary.
Testing Done:
Ran locally and connected with bonjour, facebook, irc, and xmpp. Verified that the other prpls are loading and visible in the account manager.
Bugs closed: PIDGIN-17492
Reviewed at https://reviews.imfreedom.org/r/552/
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
1 | /** |
| 15884 | 2 | * purple |
| 2086 | 3 | * |
| 15884 | 4 | * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> |
|
32117
6d49fa9e996c
Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents:
31950
diff
changeset
|
5 | * Copyright (C) 2003, 2012 Ethan Blanton <elb@pidgin.im> |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
6 | * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> |
| 2086 | 7 | * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
|
6459
b5169664b142
[gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
8 | * |
| 2086 | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by | |
| 11 | * the Free Software Foundation; either version 2 of the License, or | |
| 12 | * (at your option) any later version. | |
| 13 | * | |
| 14 | * This program is distributed in the hope that it will be useful, | |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | * GNU General Public License for more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU General Public License | |
| 20 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19785
diff
changeset
|
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 2086 | 22 | */ |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
23 | |
|
40462
24ed25d87550
Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
24 | #include <errno.h> |
|
24ed25d87550
Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
25 | |
|
40441
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
26 | #include <glib/gi18n-lib.h> |
|
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
27 | |
|
39961
d508d5b5dd22
Update the irc prpl to only use purple.h
Gary Kramlich <grim@reaperworld.com>
parents:
39921
diff
changeset
|
28 | #include <purple.h> |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
29 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
30 | #include "irc.h" |
|
4422
d7d5938502f0
[gaim-migrate @ 4695]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4416
diff
changeset
|
31 | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
32 | #define PING_TIMEOUT 60 |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
33 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
34 | static void irc_ison_buddy_init(char *name, struct irc_buddy *ib, GList **list); |
| 2086 | 35 | |
| 15884 | 36 | static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b); |
| 37 | static GList *irc_status_types(PurpleAccount *account); | |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
38 | static GList *irc_get_actions(PurpleProtocolClient *client, PurpleConnection *gc); |
| 15884 | 39 | /* static GList *irc_chat_info(PurpleConnection *gc); */ |
| 40 | static void irc_login(PurpleAccount *account); | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
41 | static void irc_login_cb(GObject *source, GAsyncResult *res, gpointer user_data); |
| 15884 | 42 | static void irc_close(PurpleConnection *gc); |
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40462
diff
changeset
|
43 | static int irc_im_send(PurpleProtocolIM *im, PurpleConnection *gc, PurpleMessage *msg); |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
44 | static int irc_chat_send(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, int id, PurpleMessage *msg); |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
45 | static void irc_chat_join(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, GHashTable *data); |
|
39637
3431d9e4eefd
Inline the irc_read_input function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39480
diff
changeset
|
46 | static void irc_read_input_cb(GObject *source, GAsyncResult *res, gpointer data); |
| 3751 | 47 | |
| 7711 | 48 | static guint irc_nick_hash(const char *nick); |
| 49 | static gboolean irc_nick_equal(const char *nick1, const char *nick2); | |
| 50 | static void irc_buddy_free(struct irc_buddy *ib); | |
| 51 | ||
|
36544
1bf8b6ef5aea
Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents:
36543
diff
changeset
|
52 | PurpleProtocol *_irc_protocol = NULL; |
| 7711 | 53 | |
|
39358
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
54 | static gint |
|
39833
cd90938cd6f7
Silence various discarded const warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
55 | irc_uri_handler_match_server(PurpleAccount *account, const gchar *match_server) |
|
39358
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
56 | { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
57 | const gchar *protocol_id; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
58 | const gchar *username; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
59 | gchar *server; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
60 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
61 | protocol_id = purple_account_get_protocol_id(account); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
62 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
63 | if (!purple_strequal(protocol_id, "prpl-irc") || |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
64 | !purple_account_is_connected(account)) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
65 | return -1; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
66 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
67 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
68 | if (match_server == NULL || match_server[0] == '\0') { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
69 | /* No server specified, match any IRC account */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
70 | return 0; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
71 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
72 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
73 | username = purple_account_get_username(account); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
74 | server = strchr(username, '@'); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
75 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
76 | /* +1 to skip '@' */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
77 | if (server == NULL || !purple_strequal(match_server, server + 1)) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
78 | return -1; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
79 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
80 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
81 | return 0; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
82 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
83 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
84 | static gboolean |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
85 | irc_uri_handler(const gchar *scheme, const gchar *uri, GHashTable *params) |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
86 | { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
87 | gchar *target; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
88 | gchar *server; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
89 | GList *accounts; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
90 | GList *account_node; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
91 | gchar **target_tokens; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
92 | PurpleAccount *account; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
93 | gchar **modifier; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
94 | gboolean isnick = FALSE; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
95 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
96 | g_return_val_if_fail(uri != NULL, FALSE); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
97 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
98 | if (!purple_strequal(scheme, "irc")) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
99 | /* Not a scheme we handle here */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
100 | return FALSE; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
101 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
102 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
103 | if (g_str_has_prefix(uri, "//")) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
104 | /* Skip initial '//' if it exists */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
105 | uri += 2; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
106 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
107 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
108 | /* Find the target (aka room or user) */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
109 | target = strchr(uri, '/'); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
110 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
111 | /* [1] to skip the '/' */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
112 | if (target == NULL || target[1] == '\0') { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
113 | purple_debug_warning("irc", |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
114 | "URI missing valid target: %s", uri); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
115 | return FALSE; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
116 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
117 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
118 | server = g_strndup(uri, target - uri); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
119 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
120 | /* Find account with correct server */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
121 | accounts = purple_accounts_get_all(); |
|
39833
cd90938cd6f7
Silence various discarded const warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
122 | account_node = g_list_find_custom( |
|
cd90938cd6f7
Silence various discarded const warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
123 | accounts, server, (GCompareFunc)irc_uri_handler_match_server); |
|
39358
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
124 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
125 | if (account_node == NULL) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
126 | purple_debug_warning("irc", |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
127 | "No account online on '%s' for handling URI", |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
128 | server); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
129 | g_free(server); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
130 | return FALSE; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
131 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
132 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
133 | account = account_node->data; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
134 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
135 | /* Tokenize modifiers, +1 to skip the initial '/' */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
136 | target_tokens = g_strsplit(target + 1, ",", 0); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
137 | target = g_strdup_printf("#%s", target_tokens[0]); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
138 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
139 | /* Parse modifiers, start at 1 to skip the actual target */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
140 | for (modifier = target_tokens + 1; *modifier != NULL; ++modifier) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
141 | if (purple_strequal(*modifier, "isnick")) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
142 | isnick = TRUE; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
143 | break; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
144 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
145 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
146 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
147 | g_strfreev(target_tokens); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
148 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
149 | if (isnick) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
150 | PurpleIMConversation *im; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
151 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
152 | /* 'server' isn't needed here. Free it immediately. */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
153 | g_free(server); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
154 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
155 | /* +1 to skip '#' target prefix */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
156 | im = purple_im_conversation_new(account, target + 1); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
157 | g_free(target); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
158 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
159 | purple_conversation_present(PURPLE_CONVERSATION(im)); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
160 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
161 | if (params != NULL) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
162 | const gchar *msg = g_hash_table_lookup(params, "msg"); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
163 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
164 | if (msg != NULL) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
165 | purple_conversation_send_confirm( |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
166 | PURPLE_CONVERSATION(im), msg); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
167 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
168 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
169 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
170 | return TRUE; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
171 | } else { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
172 | GHashTable *components; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
173 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
174 | components = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
175 | NULL, g_free); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
176 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
177 | /* Transfer ownership of these to the hash table */ |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
178 | g_hash_table_insert(components, "server", server); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
179 | g_hash_table_insert(components, "channel", target); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
180 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
181 | if (params != NULL) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
182 | const gchar *key = g_hash_table_lookup(params, "key"); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
183 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
184 | if (key != NULL) { |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
185 | g_hash_table_insert(components, "password", |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
186 | g_strdup(key)); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
187 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
188 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
189 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
190 | purple_serv_join_chat(purple_account_get_connection(account), |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
191 | components); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
192 | g_hash_table_destroy(components); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
193 | return TRUE; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
194 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
195 | |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
196 | return FALSE; |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
197 | } |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
198 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
199 | static void irc_view_motd(PurpleProtocolAction *action) |
| 7148 | 200 | { |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
201 | PurpleConnection *gc = action->connection; |
| 7148 | 202 | struct irc_conn *irc; |
|
36261
88ce4f534696
Display IRC MOTD in font-family: monospace. Fixes #13727
Ethan Blanton <elb@fiji-systems.com>
parents:
35171
diff
changeset
|
203 | char *title, *body; |
| 7148 | 204 | |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
205 | if (gc == NULL || purple_connection_get_protocol_data(gc) == NULL) { |
|
40765
a5381c20e802
Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40708
diff
changeset
|
206 | purple_debug_error("irc", "got MOTD request for NULL gc"); |
| 7148 | 207 | return; |
| 208 | } | |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
209 | irc = purple_connection_get_protocol_data(gc); |
| 7148 | 210 | if (irc->motd == NULL) { |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34321
diff
changeset
|
211 | purple_notify_error(gc, _("Error displaying MOTD"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34321
diff
changeset
|
212 | _("No MOTD available"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34321
diff
changeset
|
213 | _("There is no MOTD associated with this connection."), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34321
diff
changeset
|
214 | purple_request_cpar_from_connection(gc)); |
| 7148 | 215 | return; |
| 216 | } | |
| 217 | title = g_strdup_printf(_("MOTD for %s"), irc->server); | |
|
36261
88ce4f534696
Display IRC MOTD in font-family: monospace. Fixes #13727
Ethan Blanton <elb@fiji-systems.com>
parents:
35171
diff
changeset
|
218 | body = g_strdup_printf("<span style=\"font-family: monospace;\">%s</span>", irc->motd->str); |
|
88ce4f534696
Display IRC MOTD in font-family: monospace. Fixes #13727
Ethan Blanton <elb@fiji-systems.com>
parents:
35171
diff
changeset
|
219 | purple_notify_formatted(gc, title, title, NULL, body, NULL, NULL); |
|
14534
c9d0843d8c19
[gaim-migrate @ 17188]
Daniel Atallah <datallah@pidgin.im>
parents:
14324
diff
changeset
|
220 | g_free(title); |
|
36264
14555e001a59
Fix leak in previous commit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
36261
diff
changeset
|
221 | g_free(body); |
| 7148 | 222 | } |
| 223 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
224 | static int |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
225 | irc_send_raw(PurpleProtocolServer *protocol_server, PurpleConnection *gc, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
226 | const gchar *buf, gint len) |
| 14604 | 227 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
228 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
31929
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
229 | if (len == -1) { |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
230 | len = strlen(buf); |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
231 | } |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
232 | irc_send_len(irc, buf, len); |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
233 | return len; |
| 14604 | 234 | } |
| 235 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
236 | static void |
|
39167
b88f98cd9ba5
irc: Port to use refactored PurpleQueuedOutputStream
Mike Ruprecht <cmaiku@gmail.com>
parents:
39005
diff
changeset
|
237 | irc_push_bytes_cb(GObject *source, GAsyncResult *res, gpointer data) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
238 | { |
|
39167
b88f98cd9ba5
irc: Port to use refactored PurpleQueuedOutputStream
Mike Ruprecht <cmaiku@gmail.com>
parents:
39005
diff
changeset
|
239 | PurpleQueuedOutputStream *stream = PURPLE_QUEUED_OUTPUT_STREAM(source); |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
240 | PurpleConnection *gc = data; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
241 | gboolean result; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
242 | GError *error = NULL; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
243 | |
|
39167
b88f98cd9ba5
irc: Port to use refactored PurpleQueuedOutputStream
Mike Ruprecht <cmaiku@gmail.com>
parents:
39005
diff
changeset
|
244 | result = purple_queued_output_stream_push_bytes_finish(stream, |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
245 | res, &error); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
246 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
247 | if (!result) { |
|
39167
b88f98cd9ba5
irc: Port to use refactored PurpleQueuedOutputStream
Mike Ruprecht <cmaiku@gmail.com>
parents:
39005
diff
changeset
|
248 | purple_queued_output_stream_clear_queue(stream); |
|
b88f98cd9ba5
irc: Port to use refactored PurpleQueuedOutputStream
Mike Ruprecht <cmaiku@gmail.com>
parents:
39005
diff
changeset
|
249 | |
|
39921
a9c92a82f4c8
Don't pass literals to g_set_error / g_error_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39917
diff
changeset
|
250 | g_prefix_error(&error, "%s", _("Lost connection with server: ")); |
|
37960
3ead1b62bc55
irc: Use new purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37958
diff
changeset
|
251 | purple_connection_take_error(gc, error); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
252 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
253 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
254 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
255 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
256 | int irc_send(struct irc_conn *irc, const char *buf) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
257 | { |
|
31929
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
258 | return irc_send_len(irc, buf, strlen(buf)); |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
259 | } |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
260 | |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
261 | int irc_send_len(struct irc_conn *irc, const char *buf, int buflen) |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
262 | { |
|
38300
d1911127d944
irc: update buflen if irc-sending-text changed the text to send
dx <dx@dxzone.com.ar>
parents:
36264
diff
changeset
|
263 | char *tosend = g_strdup(buf); |
|
37668
a658571d344d
irc: Store strlen() value to avoid calling it twice in irc_send_len()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37667
diff
changeset
|
264 | int len; |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
265 | GBytes *data; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
266 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
267 | purple_signal_emit(_irc_protocol, "irc-sending-text", purple_account_get_connection(irc->account), &tosend); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36264
diff
changeset
|
268 | |
| 14683 | 269 | if (tosend == NULL) |
| 270 | return 0; | |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
271 | |
|
38907
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
38759
diff
changeset
|
272 | if (purple_debug_is_verbose()) { |
|
40519
974dbfd7e52f
Remove and replace a number of the purple utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
40507
diff
changeset
|
273 | gchar *clean = g_utf8_make_valid(tosend, -1); |
|
38907
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
38759
diff
changeset
|
274 | clean = g_strstrip(clean); |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
38759
diff
changeset
|
275 | purple_debug_misc("irc", "<< %s\n", clean); |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
38759
diff
changeset
|
276 | g_free(clean); |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
38759
diff
changeset
|
277 | } |
|
d184ca7f413e
irc: show protocol debug if PURPLE_VERBOSE_DEBUG=1
dx <dx@dxzone.com.ar>
parents:
38759
diff
changeset
|
278 | |
|
37668
a658571d344d
irc: Store strlen() value to avoid calling it twice in irc_send_len()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37667
diff
changeset
|
279 | len = strlen(tosend); |
|
a658571d344d
irc: Store strlen() value to avoid calling it twice in irc_send_len()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37667
diff
changeset
|
280 | data = g_bytes_new_take(tosend, len); |
|
39167
b88f98cd9ba5
irc: Port to use refactored PurpleQueuedOutputStream
Mike Ruprecht <cmaiku@gmail.com>
parents:
39005
diff
changeset
|
281 | purple_queued_output_stream_push_bytes_async(irc->output, data, |
|
b88f98cd9ba5
irc: Port to use refactored PurpleQueuedOutputStream
Mike Ruprecht <cmaiku@gmail.com>
parents:
39005
diff
changeset
|
282 | G_PRIORITY_DEFAULT, irc->cancellable, irc_push_bytes_cb, |
|
b88f98cd9ba5
irc: Port to use refactored PurpleQueuedOutputStream
Mike Ruprecht <cmaiku@gmail.com>
parents:
39005
diff
changeset
|
283 | purple_account_get_connection(irc->account)); |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
284 | g_bytes_unref(data); |
|
38300
d1911127d944
irc: update buflen if irc-sending-text changed the text to send
dx <dx@dxzone.com.ar>
parents:
36264
diff
changeset
|
285 | |
|
37668
a658571d344d
irc: Store strlen() value to avoid calling it twice in irc_send_len()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37667
diff
changeset
|
286 | return len; |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2171
diff
changeset
|
287 | } |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2171
diff
changeset
|
288 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
289 | /* XXX I don't like messing directly with these buddies */ |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
290 | gboolean irc_blist_timeout(struct irc_conn *irc) |
| 2086 | 291 | { |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
292 | if (irc->ison_outstanding) { |
|
2137
b0c18ea1dee8
[gaim-migrate @ 2147]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2131
diff
changeset
|
293 | return TRUE; |
| 2086 | 294 | } |
|
4416
008b56d257e1
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
295 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
296 | g_hash_table_foreach(irc->buddies, (GHFunc)irc_ison_buddy_init, |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
297 | (gpointer *)&irc->buddies_outstanding); |
|
4416
008b56d257e1
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
298 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
299 | irc_buddy_query(irc); |
|
21736
8de85200908d
applied changes from 5dc4cf40c038206bcf06fe7407e1e308b0264e32
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21503
diff
changeset
|
300 | |
|
2131
ef072ae1b2b8
[gaim-migrate @ 2141]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2123
diff
changeset
|
301 | return TRUE; |
| 2086 | 302 | } |
| 303 | ||
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
304 | void irc_buddy_query(struct irc_conn *irc) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
305 | { |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
306 | GList *lp; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
307 | GString *string; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
308 | struct irc_buddy *ib; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
309 | char *buf; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
310 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
311 | string = g_string_sized_new(512); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
312 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
313 | while ((lp = g_list_first(irc->buddies_outstanding))) { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
314 | ib = (struct irc_buddy *)lp->data; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
315 | if (string->len + strlen(ib->name) + 1 > 450) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
316 | break; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
317 | g_string_append_printf(string, "%s ", ib->name); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
318 | ib->new_online_status = FALSE; |
|
35758
87c51487e197
Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
319 | irc->buddies_outstanding = g_list_delete_link(irc->buddies_outstanding, lp); |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
320 | } |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
321 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
322 | if (string->len) { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
323 | buf = irc_format(irc, "vn", "ISON", string->str); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
324 | irc_send(irc, buf); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
325 | g_free(buf); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
326 | irc->ison_outstanding = TRUE; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
327 | } else |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
328 | irc->ison_outstanding = FALSE; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
329 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
330 | g_string_free(string, TRUE); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
331 | } |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
332 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
333 | static void irc_ison_buddy_init(char *name, struct irc_buddy *ib, GList **list) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
334 | { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
335 | *list = g_list_append(*list, ib); |
| 3511 | 336 | } |
| 337 | ||
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
338 | |
|
9553
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
339 | static void irc_ison_one(struct irc_conn *irc, struct irc_buddy *ib) |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
340 | { |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
341 | char *buf; |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
342 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
343 | if (irc->buddies_outstanding != NULL) { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
344 | irc->buddies_outstanding = g_list_append(irc->buddies_outstanding, ib); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
345 | return; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
346 | } |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
347 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
348 | ib->new_online_status = FALSE; |
|
9553
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
349 | buf = irc_format(irc, "vn", "ISON", ib->name); |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
350 | irc_send(irc, buf); |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
351 | g_free(buf); |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
352 | } |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
353 | |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
354 | |
| 15884 | 355 | static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b) |
| 3029 | 356 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
357 | return "irc"; |
|
2339
b42203c69d52
[gaim-migrate @ 2352]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2331
diff
changeset
|
358 | } |
|
b42203c69d52
[gaim-migrate @ 2352]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2331
diff
changeset
|
359 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
360 | static GList * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
361 | irc_protocol_get_account_options(PurpleProtocol *protocol) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
362 | PurpleAccountOption *option; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
363 | GList *opts = NULL; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
364 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
365 | option = purple_account_option_int_new(_("Port"), "port", |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
366 | IRC_DEFAULT_PORT); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
367 | opts = g_list_append(opts, option); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
368 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
369 | option = purple_account_option_string_new(_("Encodings"), "encoding", |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
370 | IRC_DEFAULT_CHARSET); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
371 | opts = g_list_append(opts, option); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
372 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
373 | option = purple_account_option_bool_new(_("Auto-detect incoming UTF-8"), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
374 | "autodetect_utf8", |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
375 | IRC_DEFAULT_AUTODETECT); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
376 | opts = g_list_append(opts, option); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
377 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
378 | option = purple_account_option_string_new(_("Ident name"), "username", ""); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
379 | opts = g_list_append(opts, option); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
380 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
381 | option = purple_account_option_string_new(_("Real name"), "realname", ""); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
382 | opts = g_list_append(opts, option); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
383 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
384 | /* |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
385 | option = purple_account_option_string_new(_("Quit message"), "quitmsg", |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
386 | IRC_DEFAULT_QUIT); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
387 | opts = g_list_append(opts, option); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
388 | */ |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
389 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
390 | option = purple_account_option_bool_new(_("Use SSL"), "ssl", FALSE); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
391 | opts = g_list_append(opts, option); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
392 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
393 | #ifdef HAVE_CYRUS_SASL |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
394 | option = purple_account_option_bool_new(_("Authenticate with SASL"), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
395 | "sasl", FALSE); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
396 | opts = g_list_append(opts, option); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
397 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
398 | option = purple_account_option_bool_new(_("Allow plaintext SASL auth over " |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
399 | "unencrypted connection"), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
400 | "auth_plain_in_clear", FALSE); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
401 | opts = g_list_append(opts, option); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
402 | #endif |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
403 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
404 | return opts; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
405 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
406 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
407 | static GList * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
408 | irc_protocol_get_user_splits(PurpleProtocol *protocol) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
409 | PurpleAccountUserSplit *split; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
410 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
411 | split = purple_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
412 | '@'); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
413 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
414 | return g_list_append(NULL, split); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
415 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
416 | |
| 15884 | 417 | static GList *irc_status_types(PurpleAccount *account) |
| 2086 | 418 | { |
| 15884 | 419 | PurpleStatusType *type; |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
420 | GList *types = NULL; |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
421 | |
| 15884 | 422 | type = purple_status_type_new(PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE); |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
423 | types = g_list_append(types, type); |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
424 | |
| 15884 | 425 | type = purple_status_type_new_with_attrs( |
| 426 | PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, | |
|
35005
bff56dfca65d
Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
427 | "message", _("Message"), purple_value_new(G_TYPE_STRING), |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
428 | NULL); |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
429 | types = g_list_append(types, type); |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
430 | |
| 15884 | 431 | type = purple_status_type_new(PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE); |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
432 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
433 | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
434 | return types; |
| 3452 | 435 | } |
| 436 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
437 | static GList * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
438 | irc_get_actions(PurpleProtocolClient *client, PurpleConnection *gc) { |
| 7148 | 439 | GList *list = NULL; |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
440 | PurpleProtocolAction *act = NULL; |
| 7148 | 441 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
442 | act = purple_protocol_action_new(_("View MOTD"), irc_view_motd); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
443 | list = g_list_append(list, act); |
| 7148 | 444 | |
| 445 | return list; | |
| 446 | } | |
| 447 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
448 | static GList * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
449 | irc_chat_join_info(PurpleProtocolChat *protocol_chat, PurpleConnection *gc) { |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
450 | GList *m = NULL; |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
451 | PurpleProtocolChatEntry *pce; |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
452 | |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
453 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7711
diff
changeset
|
454 | pce->label = _("_Channel:"); |
| 5234 | 455 | pce->identifier = "channel"; |
|
10954
cd5771cb6cf8
[gaim-migrate @ 12754]
Richard Laager <rlaager@pidgin.im>
parents:
10903
diff
changeset
|
456 | pce->required = TRUE; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
457 | m = g_list_append(m, pce); |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
458 | |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
459 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7711
diff
changeset
|
460 | pce->label = _("_Password:"); |
| 5234 | 461 | pce->identifier = "password"; |
| 6499 | 462 | pce->secret = TRUE; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
463 | m = g_list_append(m, pce); |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
464 | |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
465 | return m; |
| 2086 | 466 | } |
| 467 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
468 | static GHashTable * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
469 | irc_chat_info_defaults(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
470 | const gchar *chat_name) |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
471 | { |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
472 | GHashTable *defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
473 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
474 | defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
475 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
476 | if (chat_name != NULL) |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
477 | g_hash_table_insert(defaults, "channel", g_strdup(chat_name)); |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
478 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
479 | return defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
480 | } |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
481 | |
| 15884 | 482 | static void irc_login(PurpleAccount *account) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
483 | { |
| 15884 | 484 | PurpleConnection *gc; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
485 | struct irc_conn *irc; |
| 10494 | 486 | char **userparts; |
| 15884 | 487 | const char *username = purple_account_get_username(account); |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
488 | GSocketClient *client; |
|
37963
79ff4f061fcf
irc: Use new purple_gio_socket_client_new() helper function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37960
diff
changeset
|
489 | GError *error = NULL; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
490 | |
| 15884 | 491 | gc = purple_account_get_connection(account); |
|
36055
33978dc8ef6f
Remove redundant OPT_PROTO_IM_IMAGE (use \!PURPLE_CONNECTION_FLAG_NO_IMAGES instead)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
492 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_NEWLINES | |
|
33978dc8ef6f
Remove redundant OPT_PROTO_IM_IMAGE (use \!PURPLE_CONNECTION_FLAG_NO_IMAGES instead)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
493 | PURPLE_CONNECTION_FLAG_NO_IMAGES); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
494 | |
| 6752 | 495 | if (strpbrk(username, " \t\v\r\n") != NULL) { |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37963
diff
changeset
|
496 | purple_connection_take_error(gc, g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37963
diff
changeset
|
497 | PURPLE_CONNECTION_ERROR, |
| 21279 | 498 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37963
diff
changeset
|
499 | _("IRC nick and server may not contain whitespace"))); |
| 6752 | 500 | return; |
| 501 | } | |
| 502 | ||
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
503 | irc = g_new0(struct irc_conn, 1); |
|
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
504 | purple_connection_set_protocol_data(gc, irc); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
505 | irc->account = account; |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
506 | irc->cancellable = g_cancellable_new(); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
507 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
508 | userparts = g_strsplit(username, "@", 2); |
| 15884 | 509 | purple_connection_set_display_name(gc, userparts[0]); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
510 | irc->server = g_strdup(userparts[1]); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
511 | g_strfreev(userparts); |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
512 | |
|
10159
5e8afc7db137
[gaim-migrate @ 11240]
Mark Doliner <markdoliner@pidgin.im>
parents:
10010
diff
changeset
|
513 | irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal, |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
514 | NULL, (GDestroyNotify)irc_buddy_free); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
515 | irc->cmds = g_hash_table_new(g_str_hash, g_str_equal); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
516 | irc_cmd_table_build(irc); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
517 | irc->msgs = g_hash_table_new(g_str_hash, g_str_equal); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
518 | irc_msg_table_build(irc); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
519 | |
| 15884 | 520 | purple_connection_update_progress(gc, _("Connecting"), 1, 2); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
521 | |
|
37963
79ff4f061fcf
irc: Use new purple_gio_socket_client_new() helper function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37960
diff
changeset
|
522 | client = purple_gio_socket_client_new(account, &error); |
|
79ff4f061fcf
irc: Use new purple_gio_socket_client_new() helper function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37960
diff
changeset
|
523 | |
|
79ff4f061fcf
irc: Use new purple_gio_socket_client_new() helper function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37960
diff
changeset
|
524 | if (client == NULL) { |
|
79ff4f061fcf
irc: Use new purple_gio_socket_client_new() helper function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37960
diff
changeset
|
525 | purple_connection_take_error(gc, error); |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
526 | return; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
527 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
528 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
529 | /* Optionally use TLS if it's set in the account settings */ |
|
37963
79ff4f061fcf
irc: Use new purple_gio_socket_client_new() helper function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37960
diff
changeset
|
530 | g_socket_client_set_tls(client, |
|
79ff4f061fcf
irc: Use new purple_gio_socket_client_new() helper function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37960
diff
changeset
|
531 | purple_account_get_bool(account, "ssl", FALSE)); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
532 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
533 | g_socket_client_connect_to_host_async(client, irc->server, |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
534 | purple_account_get_int(account, "port", |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
535 | g_socket_client_get_tls(client) ? |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
536 | IRC_DEFAULT_SSL_PORT : |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
537 | IRC_DEFAULT_PORT), |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
538 | irc->cancellable, irc_login_cb, gc); |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
539 | g_object_unref(client); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
540 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
541 | |
| 15884 | 542 | static gboolean do_login(PurpleConnection *gc) { |
|
40549
141508c66433
Use the irc nick as the ident when the user has not specified on. Fixes PIDGIN-17435
Gary Kramlich <grim@reaperworld.com>
parents:
40519
diff
changeset
|
543 | char *buf = NULL; |
|
31646
ebe3510fbdb1
Send * as our local hostname for the USER message at signon.
Ethan Blanton <elb@pidgin.im>
parents:
31595
diff
changeset
|
544 | char *server; |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
545 | const char *nickname, *identname, *realname; |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
546 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
| 15884 | 547 | const char *pass = purple_connection_get_password(gc); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
548 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
549 | const gboolean use_sasl = purple_account_get_bool(irc->account, "sasl", FALSE); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
550 | #endif |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
551 | |
| 10555 | 552 | if (pass && *pass) { |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
553 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
554 | if (use_sasl) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
555 | buf = irc_format(irc, "vv:", "CAP", "REQ", "sasl"); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
556 | else /* intended to fall through */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
557 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
558 | buf = irc_format(irc, "v:", "PASS", pass); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
559 | if (irc_send(irc, buf) < 0) { |
|
10903
7d32f4448a95
[gaim-migrate @ 12630]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10740
diff
changeset
|
560 | g_free(buf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
561 | return FALSE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
562 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
563 | g_free(buf); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
564 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
565 | |
|
40549
141508c66433
Use the irc nick as the ident when the user has not specified on. Fixes PIDGIN-17435
Gary Kramlich <grim@reaperworld.com>
parents:
40519
diff
changeset
|
566 | nickname = purple_connection_get_display_name(gc); |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
567 | |
|
40549
141508c66433
Use the irc nick as the ident when the user has not specified on. Fixes PIDGIN-17435
Gary Kramlich <grim@reaperworld.com>
parents:
40519
diff
changeset
|
568 | realname = purple_account_get_string(irc->account, "realname", ""); |
|
141508c66433
Use the irc nick as the ident when the user has not specified on. Fixes PIDGIN-17435
Gary Kramlich <grim@reaperworld.com>
parents:
40519
diff
changeset
|
569 | if(realname == NULL || *realname == '\0') { |
|
141508c66433
Use the irc nick as the ident when the user has not specified on. Fixes PIDGIN-17435
Gary Kramlich <grim@reaperworld.com>
parents:
40519
diff
changeset
|
570 | realname = IRC_DEFAULT_ALIAS; |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
571 | } |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
572 | |
|
40549
141508c66433
Use the irc nick as the ident when the user has not specified on. Fixes PIDGIN-17435
Gary Kramlich <grim@reaperworld.com>
parents:
40519
diff
changeset
|
573 | identname = purple_account_get_string(irc->account, "username", ""); |
|
141508c66433
Use the irc nick as the ident when the user has not specified on. Fixes PIDGIN-17435
Gary Kramlich <grim@reaperworld.com>
parents:
40519
diff
changeset
|
574 | if(identname == NULL || *identname == '\0') { |
|
141508c66433
Use the irc nick as the ident when the user has not specified on. Fixes PIDGIN-17435
Gary Kramlich <grim@reaperworld.com>
parents:
40519
diff
changeset
|
575 | identname = nickname; |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
576 | } |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
577 | |
|
23905
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
578 | if (*irc->server == ':') { |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
579 | /* Same as hostname, above. */ |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
580 | server = g_strdup_printf("0%s", irc->server); |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
581 | } else { |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
582 | server = g_strdup(irc->server); |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
583 | } |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
584 | |
|
40549
141508c66433
Use the irc nick as the ident when the user has not specified on. Fixes PIDGIN-17435
Gary Kramlich <grim@reaperworld.com>
parents:
40519
diff
changeset
|
585 | buf = irc_format(irc, "vvvv:", "USER", identname, "*", server, realname); |
|
23905
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
586 | g_free(server); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
587 | if (irc_send(irc, buf) < 0) { |
|
10903
7d32f4448a95
[gaim-migrate @ 12630]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10740
diff
changeset
|
588 | g_free(buf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
589 | return FALSE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
590 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
591 | g_free(buf); |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
592 | buf = irc_format(irc, "vn", "NICK", nickname); |
|
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
593 | irc->reqnick = g_strdup(nickname); |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22277
diff
changeset
|
594 | irc->nickused = FALSE; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
595 | if (irc_send(irc, buf) < 0) { |
|
10903
7d32f4448a95
[gaim-migrate @ 12630]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10740
diff
changeset
|
596 | g_free(buf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
597 | return FALSE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
598 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
599 | g_free(buf); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
600 | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
601 | irc->recv_time = time(NULL); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
602 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
603 | return TRUE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
604 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
605 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
606 | static void |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
607 | irc_login_cb(GObject *source, GAsyncResult *res, gpointer user_data) |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
608 | { |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
609 | PurpleConnection *gc = user_data; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
610 | GSocketConnection *conn; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
611 | GError *error = NULL; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
612 | struct irc_conn *irc; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
613 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
614 | conn = g_socket_client_connect_to_host_finish(G_SOCKET_CLIENT(source), |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
615 | res, &error); |
|
14173
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
616 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
617 | if (conn == NULL) { |
|
39921
a9c92a82f4c8
Don't pass literals to g_set_error / g_error_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39917
diff
changeset
|
618 | g_prefix_error(&error, "%s", _("Unable to connect: ")); |
|
37960
3ead1b62bc55
irc: Use new purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37958
diff
changeset
|
619 | purple_connection_take_error(gc, error); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
620 | return; |
| 8778 | 621 | } |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
622 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
623 | irc = purple_connection_get_protocol_data(gc); |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
624 | irc->conn = conn; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
625 | irc->output = purple_queued_output_stream_new( |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
626 | g_io_stream_get_output_stream(G_IO_STREAM(irc->conn))); |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
627 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
628 | if (do_login(gc)) { |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
629 | irc->input = g_data_input_stream_new( |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
630 | g_io_stream_get_input_stream( |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
631 | G_IO_STREAM(irc->conn))); |
|
39637
3431d9e4eefd
Inline the irc_read_input function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39480
diff
changeset
|
632 | g_data_input_stream_read_line_async(irc->input, |
|
3431d9e4eefd
Inline the irc_read_input function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39480
diff
changeset
|
633 | G_PRIORITY_DEFAULT, irc->cancellable, |
|
3431d9e4eefd
Inline the irc_read_input function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39480
diff
changeset
|
634 | irc_read_input_cb, gc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
635 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
636 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
637 | |
| 15884 | 638 | static void irc_close(PurpleConnection *gc) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
639 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
640 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
641 | |
| 6752 | 642 | if (irc == NULL) |
| 643 | return; | |
| 644 | ||
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
645 | if (irc->conn != NULL) |
|
14173
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
646 | irc_cmd_quit(irc, "quit", NULL, NULL); |
|
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
647 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
648 | if (irc->cancellable != NULL) { |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
649 | g_cancellable_cancel(irc->cancellable); |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
650 | g_clear_object(&irc->cancellable); |
|
32682
d52f33b99db7
IRC: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32679
diff
changeset
|
651 | } |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
652 | |
|
37957
1c33866c1ae9
irc: Use new purple_gio_graceful_close() function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37668
diff
changeset
|
653 | if (irc->conn != NULL) { |
|
1c33866c1ae9
irc: Use new purple_gio_graceful_close() function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37668
diff
changeset
|
654 | purple_gio_graceful_close(G_IO_STREAM(irc->conn), |
|
1c33866c1ae9
irc: Use new purple_gio_graceful_close() function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37668
diff
changeset
|
655 | G_INPUT_STREAM(irc->input), |
|
1c33866c1ae9
irc: Use new purple_gio_graceful_close() function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37668
diff
changeset
|
656 | G_OUTPUT_STREAM(irc->output)); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
657 | } |
|
37957
1c33866c1ae9
irc: Use new purple_gio_graceful_close() function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37668
diff
changeset
|
658 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
659 | g_clear_object(&irc->input); |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
660 | g_clear_object(&irc->output); |
|
37957
1c33866c1ae9
irc: Use new purple_gio_graceful_close() function
Mike Ruprecht <cmaiku@gmail.com>
parents:
37668
diff
changeset
|
661 | g_clear_object(&irc->conn); |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
662 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
663 | if (irc->timer) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
664 | g_source_remove(irc->timer); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
665 | g_hash_table_destroy(irc->cmds); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
666 | g_hash_table_destroy(irc->msgs); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
667 | g_hash_table_destroy(irc->buddies); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
668 | if (irc->motd) |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
669 | g_string_free(irc->motd, TRUE); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
670 | g_free(irc->server); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
671 | |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
672 | g_free(irc->mode_chars); |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22277
diff
changeset
|
673 | g_free(irc->reqnick); |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
674 | |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
675 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
676 | if (irc->sasl_conn) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
677 | sasl_dispose(&irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
678 | irc->sasl_conn = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
679 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
680 | g_free(irc->sasl_cb); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
681 | if(irc->sasl_mechs) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
682 | g_string_free(irc->sasl_mechs, TRUE); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
683 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
684 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
685 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
686 | g_free(irc); |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
687 | } |
|
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
688 | |
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40462
diff
changeset
|
689 | static int irc_im_send(PurpleProtocolIM *im, PurpleConnection *gc, PurpleMessage *msg) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
690 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
691 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
692 | char *plain; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
693 | const char *args[2]; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
694 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
695 | args[0] = irc_nick_skip_mode(irc, purple_message_get_recipient(msg)); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
696 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
697 | purple_markup_html_to_xhtml(purple_message_get_contents(msg), |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
698 | NULL, &plain); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
699 | args[1] = plain; |
| 9442 | 700 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
701 | irc_cmd_privmsg(irc, "msg", NULL, args); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
702 | g_free(plain); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
703 | return 1; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
704 | } |
| 2086 | 705 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
706 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
707 | irc_get_info(PurpleProtocolServer *protocol_server, PurpleConnection *gc, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
708 | const gchar *who) |
| 2086 | 709 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
710 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
10618
6613664e683c
[gaim-migrate @ 12083]
Daniel Atallah <datallah@pidgin.im>
parents:
10555
diff
changeset
|
711 | const char *args[2]; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
712 | args[0] = who; |
| 10624 | 713 | args[1] = NULL; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
714 | irc_cmd_whois(irc, "whois", NULL, args); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
715 | } |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
716 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
717 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
718 | irc_set_status(PurpleProtocolServer *protocol_server, PurpleAccount *account, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
719 | PurpleStatus *status) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
720 | { |
| 15884 | 721 | PurpleConnection *gc = purple_account_get_connection(account); |
|
13438
f57f4ecc3302
[gaim-migrate @ 15812]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
722 | struct irc_conn *irc; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
723 | const char *args[1]; |
| 15884 | 724 | const char *status_id = purple_status_get_id(status); |
| 2086 | 725 | |
|
13438
f57f4ecc3302
[gaim-migrate @ 15812]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
726 | g_return_if_fail(gc != NULL); |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
727 | irc = purple_connection_get_protocol_data(gc); |
| 10646 | 728 | |
| 15884 | 729 | if (!purple_status_is_active(status)) |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
730 | return; |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
731 | |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
732 | args[0] = NULL; |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
733 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36264
diff
changeset
|
734 | if (purple_strequal(status_id, "away")) { |
| 15884 | 735 | args[0] = purple_status_get_attr_string(status, "message"); |
|
12001
512c45efaccb
[gaim-migrate @ 14294]
Mark Doliner <markdoliner@pidgin.im>
parents:
11837
diff
changeset
|
736 | if ((args[0] == NULL) || (*args[0] == '\0')) |
|
512c45efaccb
[gaim-migrate @ 14294]
Mark Doliner <markdoliner@pidgin.im>
parents:
11837
diff
changeset
|
737 | args[0] = _("Away"); |
| 10646 | 738 | irc_cmd_away(irc, "away", NULL, args); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36264
diff
changeset
|
739 | } else if (purple_strequal(status_id, "available")) { |
|
12210
d7e2c9f73e16
[gaim-migrate @ 14512]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
740 | irc_cmd_away(irc, "back", NULL, args); |
| 10646 | 741 | } |
| 4916 | 742 | } |
| 743 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
744 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
745 | irc_add_buddy(PurpleProtocolServer *protocol_server, PurpleConnection *gc, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
746 | PurpleBuddy *buddy, PurpleGroup *group, const gchar *message) |
| 3029 | 747 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
748 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
749 | struct irc_buddy *ib; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
750 | const char *bname = purple_buddy_get_name(buddy); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
751 | |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
752 | ib = g_hash_table_lookup(irc->buddies, bname); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
753 | if (ib != NULL) { |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
754 | ib->ref++; |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
755 | purple_protocol_got_user_status(irc->account, bname, |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
756 | ib->online ? "available" : "offline", NULL); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
757 | } else { |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
758 | ib = g_new0(struct irc_buddy, 1); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
759 | ib->name = g_strdup(bname); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
760 | ib->ref = 1; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
761 | g_hash_table_replace(irc->buddies, ib->name, ib); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
762 | } |
| 9238 | 763 | |
|
9553
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
764 | /* if the timer isn't set, this is during signon, so we don't want to flood |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
765 | * ourself off with ISON's, so we don't, but after that we want to know when |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
766 | * someone's online asap */ |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
767 | if (irc->timer) |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
768 | irc_ison_one(irc, ib); |
| 3029 | 769 | } |
| 3622 | 770 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
771 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
772 | irc_remove_buddy(PurpleProtocolServer *protocol_server, PurpleConnection *gc, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
773 | PurpleBuddy *buddy, PurpleGroup *group) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
774 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
775 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
776 | struct irc_buddy *ib; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
777 | |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
778 | ib = g_hash_table_lookup(irc->buddies, purple_buddy_get_name(buddy)); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
779 | if (ib && --ib->ref == 0) { |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
780 | g_hash_table_remove(irc->buddies, purple_buddy_get_name(buddy)); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
781 | } |
| 3616 | 782 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
783 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
784 | static void |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
785 | irc_read_input_cb(GObject *source, GAsyncResult *res, gpointer data) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
786 | { |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
787 | PurpleConnection *gc = data; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
788 | struct irc_conn *irc; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
789 | gchar *line; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
790 | gsize len; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
791 | gsize start = 0; |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
792 | GError *error = NULL; |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
793 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
794 | line = g_data_input_stream_read_line_finish( |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
795 | G_DATA_INPUT_STREAM(source), res, &len, &error); |
| 3616 | 796 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
797 | if (line == NULL && error != NULL) { |
|
39921
a9c92a82f4c8
Don't pass literals to g_set_error / g_error_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39917
diff
changeset
|
798 | g_prefix_error(&error, "%s", _("Lost connection with server: ")); |
|
37960
3ead1b62bc55
irc: Use new purple_connection_take_error()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37958
diff
changeset
|
799 | purple_connection_take_error(gc, error); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
800 | return; |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
801 | } else if (line == NULL) { |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37963
diff
changeset
|
802 | purple_connection_take_error(gc, g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37963
diff
changeset
|
803 | PURPLE_CONNECTION_ERROR, |
| 21279 | 804 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37963
diff
changeset
|
805 | _("Server closed the connection"))); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
806 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
807 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
808 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
809 | irc = purple_connection_get_protocol_data(gc); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
810 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
811 | purple_connection_update_last_received(gc); |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
812 | |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
813 | if (len > 0 && line[len - 1] == '\r') |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
814 | line[len - 1] = '\0'; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
815 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
816 | /* This is a hack to work around the fact that marv gets messages |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
817 | * with null bytes in them while using some weird irc server at work |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
818 | */ |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
819 | while (start < len && line[start] == '\0') |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
820 | ++start; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
821 | |
|
39917
45dbd7582a5a
Simplify some conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39896
diff
changeset
|
822 | if (start < len) { |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
823 | irc_parse_msg(irc, line + start); |
|
39917
45dbd7582a5a
Simplify some conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39896
diff
changeset
|
824 | } |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
825 | |
|
37667
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
826 | g_free(line); |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
827 | |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
828 | g_data_input_stream_read_line_async(irc->input, |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
829 | G_PRIORITY_DEFAULT, irc->cancellable, |
|
4523af5dc59c
irc: Port to use Gio directly for the main connection
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
830 | irc_read_input_cb, gc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
831 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
832 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
833 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
834 | irc_chat_join(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
835 | GHashTable *data) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
836 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
837 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
838 | const char *args[2]; |
| 3616 | 839 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
840 | args[0] = g_hash_table_lookup(data, "channel"); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
841 | args[1] = g_hash_table_lookup(data, "password"); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
842 | irc_cmd_join(irc, "join", NULL, args); |
| 3622 | 843 | } |
| 844 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
845 | static gchar * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
846 | irc_get_chat_name(PurpleProtocolChat *protocol_chat, GHashTable *data) { |
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
847 | return g_strdup(g_hash_table_lookup(data, "channel")); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
848 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
849 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
850 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
851 | irc_chat_invite(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
852 | gint id, const gchar *message, const gchar *name) |
| 3751 | 853 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
854 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
855 | PurpleConversation *convo = PURPLE_CONVERSATION(purple_conversations_find_chat(gc, id)); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
856 | const char *args[2]; |
| 3751 | 857 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
858 | if (!convo) { |
|
40765
a5381c20e802
Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40708
diff
changeset
|
859 | purple_debug_error("irc", "Got chat invite request for bogus chat"); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
860 | return; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
861 | } |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
862 | args[0] = name; |
| 15884 | 863 | args[1] = purple_conversation_get_name(convo); |
| 864 | irc_cmd_invite(irc, "invite", purple_conversation_get_name(convo), args); | |
| 3707 | 865 | } |
| 866 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
867 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
868 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
869 | irc_chat_leave(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
870 | gint id) |
| 3707 | 871 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
872 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
873 | PurpleConversation *convo = PURPLE_CONVERSATION(purple_conversations_find_chat(gc, id)); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
874 | const char *args[2]; |
| 5298 | 875 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
876 | if (!convo) |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
877 | return; |
| 3735 | 878 | |
| 15884 | 879 | args[0] = purple_conversation_get_name(convo); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
880 | args[1] = NULL; |
| 15884 | 881 | irc_cmd_part(irc, "part", purple_conversation_get_name(convo), args); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35265
diff
changeset
|
882 | purple_serv_got_chat_left(gc, id); |
| 3735 | 883 | } |
| 884 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
885 | static gint |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
886 | irc_chat_send(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, gint id, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
887 | PurpleMessage *msg) |
| 3735 | 888 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
889 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
890 | PurpleConversation *convo = PURPLE_CONVERSATION(purple_conversations_find_chat(gc, id)); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
891 | const char *args[2]; |
| 8163 | 892 | char *tmp; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
893 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
894 | if (!convo) { |
|
40765
a5381c20e802
Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40708
diff
changeset
|
895 | purple_debug_error("irc", "chat send on nonexistent chat"); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
896 | return -EINVAL; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
897 | } |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
898 | purple_markup_html_to_xhtml(purple_message_get_contents(msg), NULL, &tmp); |
|
32617
c74b4bd27e37
Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents:
32338
diff
changeset
|
899 | args[0] = purple_conversation_get_name(convo); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
900 | args[1] = tmp; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
901 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
902 | irc_cmd_privmsg(irc, "msg", NULL, args); |
| 8163 | 903 | |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
904 | /* TODO: use msg */ |
|
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
905 | purple_serv_got_chat_in(gc, id, purple_connection_get_display_name(gc), |
|
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
906 | purple_message_get_flags(msg), |
|
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
907 | purple_message_get_contents(msg), time(NULL)); |
| 8163 | 908 | g_free(tmp); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
909 | return 0; |
| 3707 | 910 | } |
| 911 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
912 | static guint irc_nick_hash(const char *nick) |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
913 | { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
914 | char *lc; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
915 | guint bucket; |
|
6270
e3cb3b0c6c82
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
916 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
917 | lc = g_utf8_strdown(nick, -1); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
918 | bucket = g_str_hash(lc); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
919 | g_free(lc); |
|
6270
e3cb3b0c6c82
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
920 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
921 | return bucket; |
| 3029 | 922 | } |
| 923 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
924 | static gboolean irc_nick_equal(const char *nick1, const char *nick2) |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
925 | { |
| 15884 | 926 | return (purple_utf8_strcasecmp(nick1, nick2) == 0); |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
927 | } |
|
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
928 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
929 | static void irc_buddy_free(struct irc_buddy *ib) |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
930 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
931 | g_free(ib->name); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
932 | g_free(ib); |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
933 | } |
|
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
934 | |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
935 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
936 | irc_chat_set_topic(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40637
diff
changeset
|
937 | gint id, const gchar *topic) |
| 9154 | 938 | { |
| 939 | char *buf; | |
| 940 | const char *name = NULL; | |
| 941 | struct irc_conn *irc; | |
| 942 | ||
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
943 | irc = purple_connection_get_protocol_data(gc); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
944 | name = purple_conversation_get_name(PURPLE_CONVERSATION( |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
945 | purple_conversations_find_chat(gc, id))); |
| 9154 | 946 | |
| 947 | if (name == NULL) | |
| 948 | return; | |
| 949 | ||
| 950 | buf = irc_format(irc, "vt:", "TOPIC", name, topic); | |
| 951 | irc_send(irc, buf); | |
| 952 | g_free(buf); | |
| 953 | } | |
| 954 | ||
| 15884 | 955 | static PurpleRoomlist *irc_roomlist_get_list(PurpleConnection *gc) |
| 8114 | 956 | { |
| 957 | struct irc_conn *irc; | |
| 958 | GList *fields = NULL; | |
| 15884 | 959 | PurpleRoomlistField *f; |
| 8352 | 960 | char *buf; |
| 8114 | 961 | |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
962 | irc = purple_connection_get_protocol_data(gc); |
| 8114 | 963 | |
| 964 | if (irc->roomlist) | |
|
34932
1b74e5c63144
Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34904
diff
changeset
|
965 | g_object_unref(irc->roomlist); |
| 8114 | 966 | |
| 15884 | 967 | irc->roomlist = purple_roomlist_new(purple_connection_get_account(gc)); |
| 8114 | 968 | |
| 15884 | 969 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "channel", TRUE); |
| 8114 | 970 | fields = g_list_append(fields, f); |
| 971 | ||
| 15884 | 972 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_INT, _("Users"), "users", FALSE); |
| 8114 | 973 | fields = g_list_append(fields, f); |
| 974 | ||
| 15884 | 975 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, _("Topic"), "topic", FALSE); |
| 8114 | 976 | fields = g_list_append(fields, f); |
| 977 | ||
| 15884 | 978 | purple_roomlist_set_fields(irc->roomlist, fields); |
| 8114 | 979 | |
| 8352 | 980 | buf = irc_format(irc, "v", "LIST"); |
| 981 | irc_send(irc, buf); | |
| 982 | g_free(buf); | |
| 8114 | 983 | |
| 984 | return irc->roomlist; | |
| 985 | } | |
| 986 | ||
| 15884 | 987 | static void irc_roomlist_cancel(PurpleRoomlist *list) |
| 8114 | 988 | { |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
989 | PurpleAccount *account = purple_roomlist_get_account(list); |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
990 | PurpleConnection *gc = purple_account_get_connection(account); |
| 8114 | 991 | struct irc_conn *irc; |
| 992 | ||
| 993 | if (gc == NULL) | |
| 994 | return; | |
| 995 | ||
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
996 | irc = purple_connection_get_protocol_data(gc); |
| 8114 | 997 | |
| 15884 | 998 | purple_roomlist_set_in_progress(list, FALSE); |
| 8114 | 999 | |
| 1000 | if (irc->roomlist == list) { | |
| 1001 | irc->roomlist = NULL; | |
|
34932
1b74e5c63144
Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34904
diff
changeset
|
1002 | g_object_unref(list); |
| 8114 | 1003 | } |
| 1004 | } | |
| 1005 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
1006 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40697
diff
changeset
|
1007 | irc_keepalive(PurpleProtocolServer *protocol_server, PurpleConnection *gc) { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
1008 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
1009 | if ((time(NULL) - irc->recv_time) > PING_TIMEOUT) |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
1010 | irc_cmd_ping(irc, NULL, NULL, NULL); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
1011 | } |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
1012 | |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
1013 | static const char * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
1014 | irc_normalize(PurpleProtocolClient *client, PurpleAccount *account, |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
1015 | const char *who) |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
1016 | { |
|
40637
08cb47165790
Fix a bug in purple_protocol_client_normalize which was requiring an account. Also remove the account parameter from purple_normalize_nocase as it wasn't used there.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
1017 | return purple_normalize_nocase(who); |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
1018 | } |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
1019 | |
|
34321
f60fcab02bd4
Reconsidered characters count callback for prpl API: make it per-conversation and distinguish infinite from undefined
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
1020 | static gssize |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
1021 | irc_get_max_message_size(PurpleProtocolClient *client, |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
1022 | PurpleConversation *conv) |
| 2086 | 1023 | { |
|
34321
f60fcab02bd4
Reconsidered characters count callback for prpl API: make it per-conversation and distinguish infinite from undefined
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
1024 | /* TODO: this static value is got from pidgin-otr, but it depends on |
|
f60fcab02bd4
Reconsidered characters count callback for prpl API: make it per-conversation and distinguish infinite from undefined
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
1025 | * some factors, for example IRC channel name. */ |
|
34312
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33600
diff
changeset
|
1026 | return 417; |
| 14683 | 1027 | } |
| 1028 | ||
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
1029 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1030 | irc_protocol_init(IRCProtocol *self) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1031 | { |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1032 | } |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1033 | |
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
1034 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1035 | irc_protocol_class_init(IRCProtocolClass *klass) |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1036 | { |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1037 | PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1038 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1039 | protocol_class->login = irc_login; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1040 | protocol_class->close = irc_close; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1041 | protocol_class->status_types = irc_status_types; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1042 | protocol_class->list_icon = irc_blist_icon; |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1043 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1044 | protocol_class->get_account_options = irc_protocol_get_account_options; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1045 | protocol_class->get_user_splits = irc_protocol_get_user_splits; |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1046 | } |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1047 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1048 | static void |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1049 | irc_protocol_class_finalize(G_GNUC_UNUSED IRCProtocolClass *klass) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1050 | { |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1051 | } |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1052 | |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1053 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
1054 | irc_protocol_client_iface_init(PurpleProtocolClientInterface *client_iface) |
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
1055 | { |
|
36729
7f9fac14ed60
Temporarily replaced PurpleProtocolInterface with PurpleProtocolClientIface in protocols
Ankit Vani <a@nevitus.org>
parents:
36714
diff
changeset
|
1056 | client_iface->get_actions = irc_get_actions; |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40549
diff
changeset
|
1057 | client_iface->normalize = irc_normalize; |
|
36729
7f9fac14ed60
Temporarily replaced PurpleProtocolInterface with PurpleProtocolClientIface in protocols
Ankit Vani <a@nevitus.org>
parents:
36714
diff
changeset
|
1058 | client_iface->get_max_message_size = irc_get_max_message_size; |
| 2086 | 1059 | } |
| 9130 | 1060 | |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1061 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
1062 | irc_protocol_server_iface_init(PurpleProtocolServerInterface *server_iface) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1063 | { |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1064 | server_iface->set_status = irc_set_status; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1065 | server_iface->get_info = irc_get_info; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1066 | server_iface->add_buddy = irc_add_buddy; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1067 | server_iface->remove_buddy = irc_remove_buddy; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1068 | server_iface->keepalive = irc_keepalive; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1069 | server_iface->send_raw = irc_send_raw; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1070 | } |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1071 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1072 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
1073 | irc_protocol_im_iface_init(PurpleProtocolIMInterface *im_iface) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1074 | { |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1075 | im_iface->send = irc_im_send; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1076 | } |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1077 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1078 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
1079 | irc_protocol_chat_iface_init(PurpleProtocolChatInterface *chat_iface) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1080 | { |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1081 | chat_iface->info = irc_chat_join_info; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1082 | chat_iface->info_defaults = irc_chat_info_defaults; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1083 | chat_iface->join = irc_chat_join; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1084 | chat_iface->get_name = irc_get_chat_name; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1085 | chat_iface->invite = irc_chat_invite; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1086 | chat_iface->leave = irc_chat_leave; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1087 | chat_iface->send = irc_chat_send; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1088 | chat_iface->set_topic = irc_chat_set_topic; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1089 | } |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1090 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1091 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39672
diff
changeset
|
1092 | irc_protocol_roomlist_iface_init(PurpleProtocolRoomlistInterface *roomlist_iface) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1093 | { |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1094 | roomlist_iface->get_list = irc_roomlist_get_list; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1095 | roomlist_iface->cancel = irc_roomlist_cancel; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1096 | } |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1097 | |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1098 | static void |
|
38827
3573c82d32d8
Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
38433
diff
changeset
|
1099 | irc_protocol_xfer_iface_init(PurpleProtocolXferInterface *xfer_iface) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1100 | { |
|
39005
6a56e1366809
xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38929
diff
changeset
|
1101 | xfer_iface->send_file = irc_dccsend_send_file; |
|
6a56e1366809
xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38929
diff
changeset
|
1102 | xfer_iface->new_xfer = irc_dccsend_new_xfer; |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1103 | } |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1104 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1105 | G_DEFINE_DYNAMIC_TYPE_EXTENDED( |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1106 | IRCProtocol, irc_protocol, PURPLE_TYPE_PROTOCOL, 0, |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1107 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1108 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CLIENT, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1109 | irc_protocol_client_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1110 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1111 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_SERVER, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1112 | irc_protocol_server_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1113 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1114 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_IM, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1115 | irc_protocol_im_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1116 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1117 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CHAT, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1118 | irc_protocol_chat_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1119 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1120 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_ROOMLIST, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1121 | irc_protocol_roomlist_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1122 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1123 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_XFER, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1124 | irc_protocol_xfer_iface_init)); |
| 9130 | 1125 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1126 | static PurpleProtocol * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1127 | irc_protocol_new(void) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1128 | return PURPLE_PROTOCOL(g_object_new( |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1129 | IRC_TYPE_PROTOCOL, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1130 | "id", "prpl-irc", |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1131 | "name", "IRC", |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1132 | "options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1133 | OPT_PROTO_SLASH_COMMANDS_NATIVE, |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1134 | NULL)); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1135 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1136 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1137 | static PurplePluginInfo * |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1138 | plugin_query(GError **error) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1139 | { |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1140 | return purple_plugin_info_new( |
|
36985
9faafe43603e
Rename protocol plugin IDs to prpl-*
Ankit Vani <a@nevitus.org>
parents:
36984
diff
changeset
|
1141 | "id", "prpl-irc", |
|
36638
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
1142 | "name", "IRC Protocol", |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1143 | "version", DISPLAY_VERSION, |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1144 | "category", N_("Protocol"), |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1145 | "summary", N_("IRC Protocol Plugin"), |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1146 | "description", N_("The IRC Protocol Plugin that Sucks Less"), |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1147 | "website", PURPLE_WEBSITE, |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1148 | "abi-version", PURPLE_ABI_VERSION, |
|
36653
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36648
diff
changeset
|
1149 | "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL | |
|
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36648
diff
changeset
|
1150 | PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD, |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1151 | NULL |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1152 | ); |
| 36522 | 1153 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1154 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1155 | static gboolean |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1156 | plugin_load(PurplePlugin *plugin, GError **error) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1157 | { |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1158 | PurpleProtocolManager *manager = purple_protocol_manager_get_default(); |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1159 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1160 | irc_protocol_register_type(G_TYPE_MODULE(plugin)); |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36690
diff
changeset
|
1161 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39480
diff
changeset
|
1162 | irc_xfer_register(G_TYPE_MODULE(plugin)); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39480
diff
changeset
|
1163 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40800
diff
changeset
|
1164 | _irc_protocol = irc_protocol_new(); |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1165 | if(!purple_protocol_manager_register(manager, _irc_protocol, error)) { |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1166 | g_clear_object(&_irc_protocol); |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1167 | |
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
1168 | return FALSE; |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1169 | } |
| 9130 | 1170 | |
| 15884 | 1171 | purple_prefs_remove("/plugins/prpl/irc/quitmsg"); |
| 1172 | purple_prefs_remove("/plugins/prpl/irc"); | |
| 11073 | 1173 | |
| 9130 | 1174 | irc_register_commands(); |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36663
diff
changeset
|
1175 | |
|
36648
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1176 | purple_signal_register(_irc_protocol, "irc-sending-text", |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1177 | purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1178 | PURPLE_TYPE_CONNECTION, |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1179 | G_TYPE_POINTER); /* pointer to a string */ |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1180 | purple_signal_register(_irc_protocol, "irc-receiving-text", |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1181 | purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1182 | PURPLE_TYPE_CONNECTION, |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1183 | G_TYPE_POINTER); /* pointer to a string */ |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1184 | |
|
39358
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
1185 | purple_signal_connect(purple_get_core(), "uri-handler", plugin, |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
1186 | PURPLE_CALLBACK(irc_uri_handler), NULL); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
1187 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1188 | return TRUE; |
| 2086 | 1189 | } |
| 1190 | ||
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1191 | static gboolean |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1192 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1193 | { |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1194 | PurpleProtocolManager *manager = purple_protocol_manager_get_default(); |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1195 | |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1196 | if(!purple_protocol_manager_unregister(manager, _irc_protocol, error)) { |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1197 | return FALSE; |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1198 | } |
|
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1199 | |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36663
diff
changeset
|
1200 | irc_unregister_commands(); |
|
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36663
diff
changeset
|
1201 | |
|
39358
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
1202 | purple_signal_disconnect(purple_get_core(), "uri-handler", plugin, |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
1203 | PURPLE_CALLBACK(irc_uri_handler)); |
|
67d2df968e67
irc: Implement URI handler
Mike Ruprecht <cmaiku@gmail.com>
parents:
39167
diff
changeset
|
1204 | |
|
40800
be00e9c87cb7
Convert all of the protocols to use the new protocol_manager_ api
Gary Kramlich <grim@reaperworld.com>
parents:
40765
diff
changeset
|
1205 | g_clear_object(&_irc_protocol); |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1206 | |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1207 | return TRUE; |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1208 | } |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1209 | |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36690
diff
changeset
|
1210 | PURPLE_PLUGIN_INIT(irc, plugin_query, plugin_load, plugin_unload); |