libpurple/protocols/irc/msgs.c

Sat, 21 Sep 2013 17:01:08 +0530

author
Ankit Vani <a@nevitus.org>
date
Sat, 21 Sep 2013 17:01:08 +0530
branch
soc.2013.gobjectification.plugins
changeset 36782
64936dae41a3
parent 36719
0d7682bdf828
parent 34955
854143116575
child 36838
9dd39a792240
permissions
-rw-r--r--

Merged soc.2013.gobjectification branch

6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1 /**
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
2 * @file msgs.c
13786
ec07d27800aa [gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents: 13667
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
4 * purple
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
5 *
32117
6d49fa9e996c Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents: 32037
diff changeset
6 * Copyright (C) 2003, 2012 Ethan Blanton <elb@pidgin.im>
13786
ec07d27800aa [gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents: 13667
diff changeset
7 *
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
11 * (at your option) any later version.
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
12 *
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
16 * GNU General Public License for more details.
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
17 *
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
19 * 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: 17409
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
21 */
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
22
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
23 #include "internal.h"
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
24
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
25 #include "conversation.h"
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 34678
diff changeset
26 #include "buddylist.h"
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
27 #include "notify.h"
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
28 #include "util.h"
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
29 #include "debug.h"
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
30 #include "irc.h"
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
31
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
32 #include <stdio.h>
22798
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
33 #include <stdlib.h>
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
34
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
35 #ifdef HAVE_CYRUS_SASL
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
36 #include <sasl/sasl.h>
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
37 #endif
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
38
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
39 static char *irc_mask_nick(const char *mask);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
40 static char *irc_mask_userhost(const char *mask);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
41 static void irc_chat_remove_buddy(PurpleChatConversation *chat, char *data[2]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
42 static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc);
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
43 static void irc_connected(struct irc_conn *irc, const char *nick);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
44
13525
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
45 static void irc_msg_handle_privmsg(struct irc_conn *irc, const char *name,
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
46 const char *from, const char *to,
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
47 const char *rawmsg, gboolean notice);
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
48
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
49 #ifdef HAVE_CYRUS_SASL
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
50 static void irc_sasl_finish(struct irc_conn *irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
51 #endif
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
52
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
53 static char *irc_mask_nick(const char *mask)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
54 {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
55 char *end, *buf;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
56
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
57 end = strchr(mask, '!');
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
58 if (!end)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
59 buf = g_strdup(mask);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
60 else
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
61 buf = g_strndup(mask, end - mask);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
62
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
63 return buf;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
64 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
65
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
66 static char *irc_mask_userhost(const char *mask)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
67 {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
68 return g_strdup(strchr(mask, '!') + 1);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
69 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
70
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
71 static void irc_chat_remove_buddy(PurpleChatConversation *chat, char *data[2])
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
72 {
22795
2b1d41a575f5 Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents: 22471
diff changeset
73 char *message, *stripped;
10730
cc7807276e53 [gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10712
diff changeset
74
22795
2b1d41a575f5 Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents: 22471
diff changeset
75 stripped = data[1] ? irc_mirc2txt(data[1]) : NULL;
2b1d41a575f5 Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents: 22471
diff changeset
76 message = g_strdup_printf("quit: %s", stripped);
2b1d41a575f5 Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents: 22471
diff changeset
77 g_free(stripped);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
78
34653
88ae47a7d595 Updated protocols for the API changes
Ankit Vani <a@nevitus.org>
parents: 34632
diff changeset
79 if (purple_chat_conversation_has_user(chat, data[0]))
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
80 purple_chat_conversation_remove_user(chat, data[0], message);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
81
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
82 g_free(message);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
83 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
84
17170
609d6acda6aa Oops; I made some errors in the last commit. This is a fix of my
Ethan Blanton <elb@pidgin.im>
parents: 17169
diff changeset
85 static void irc_connected(struct irc_conn *irc, const char *nick)
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
86 {
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
87 PurpleConnection *gc;
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
88 PurpleStatus *status;
27199
ab2af9d15cba Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents: 27044
diff changeset
89 GSList *buddies;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23582
diff changeset
90 PurpleAccount *account;
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
91
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
92 if ((gc = purple_account_get_connection(irc->account)) == NULL
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
93 || PURPLE_CONNECTION_IS_CONNECTED(gc))
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
94 return;
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
95
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
96 purple_connection_set_display_name(gc, nick);
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
97 purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23582
diff changeset
98 account = purple_connection_get_account(gc);
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
99
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
100 /* If we're away then set our away message */
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
101 status = purple_account_get_active_status(irc->account);
34855
9c289149eed4 Global replaces according to GObject status API
Ankit Vani <a@nevitus.org>
parents: 34750
diff changeset
102 if (purple_status_type_get_primitive(purple_status_get_status_type(status)) != PURPLE_STATUS_AVAILABLE) {
36623
caaadef03507 Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents: 36579
diff changeset
103 PurpleProtocol *protocol = purple_connection_get_protocol(gc);
36719
0d7682bdf828 Updated protocol iface calls
Ankit Vani <a@nevitus.org>
parents: 36690
diff changeset
104 purple_protocol_server_iface_set_status(protocol, irc->account, status);
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
105 }
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
106
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
107 /* this used to be in the core, but it's not now */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
108 for (buddies = purple_blist_find_buddies(account, NULL); buddies;
27199
ab2af9d15cba Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents: 27044
diff changeset
109 buddies = g_slist_delete_link(buddies, buddies))
24940
d4e0dc304741 updated irc to use the api rather than structs directly
Gary Kramlich <grim@reaperworld.com>
parents: 24416
diff changeset
110 {
27199
ab2af9d15cba Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents: 27044
diff changeset
111 PurpleBuddy *b = buddies->data;
ab2af9d15cba Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents: 27044
diff changeset
112 struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
ab2af9d15cba Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents: 27044
diff changeset
113 ib->name = g_strdup(purple_buddy_get_name(b));
28118
ba26e203a9ca irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
114 ib->ref = 1;
ba26e203a9ca irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
115 g_hash_table_replace(irc->buddies, ib->name, ib);
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
116 }
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
117
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
118 irc_blist_timeout(irc);
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
119 if (!irc->timer)
25716
1b5be208d5ba applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents: 25707
diff changeset
120 irc->timer = purple_timeout_add_seconds(45, (GSourceFunc)irc_blist_timeout, (gpointer)irc);
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
121 }
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
122
32127
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
123 /* This function is ugly, but it's really an error handler. */
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
124 void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
125 {
32127
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
126 int i;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
127 const char *end, *cur, *numeric = NULL;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
128 char *clean, *tmp, *convname;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
129 PurpleConversation *convo;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
130
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
131 for (cur = args[0], i = 0; i < 4; i++) {
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
132 end = strchr(cur, ' ');
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
133 if (end == NULL) {
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
134 goto undirected;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
135 }
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
136 /* Check for 3-digit numeric in second position */
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
137 if (i == 1) {
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
138 if (end - cur != 3
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
139 || !isdigit(cur[0]) || !isdigit(cur[1])
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
140 || !isdigit(cur[2])) {
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
141 goto undirected;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
142 }
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
143 /* Save the numeric for printing to the channel */
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
144 numeric = cur;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
145 }
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
146 /* Don't advance cur if we're on the final iteration. */
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
147 if (i != 3) {
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
148 cur = end + 1;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
149 }
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
150 }
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
151
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
152 /* At this point, cur is the beginning of the fourth position,
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
153 * end is the following space, and there are remaining
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
154 * arguments. We'll check to see if this argument is a
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
155 * currently active conversation (private message or channel,
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
156 * either one), and print the numeric to that conversation if it
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
157 * is. */
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
158
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
159 tmp = g_strndup(cur, end - cur);
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
160 convname = purple_utf8_salvage(tmp);
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
161 g_free(tmp);
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
162
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
163 /* Check for an existing conversation */
34629
3c3bed0fd13c Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
164 convo = purple_conversations_find_with_account(convname, irc->account);
32127
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
165 g_free(convname);
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
166
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
167 if (convo == NULL) {
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
168 goto undirected;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
169 }
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
170
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
171 /* end + 1 is the first argument past the target. The initial
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
172 * arguments we've skipped are routing info, numeric, recipient
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
173 * (this account's nick, most likely), and target (this
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
174 * channel). If end + 1 is an ASCII :, skip it, because it's
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
175 * meaningless in this context. This won't catch all
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
176 * :-arguments, but it'll catch the easy case. */
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
177 if (*++end == ':') {
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
178 end++;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
179 }
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
180
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
181 /* We then print "numeric: remainder". */
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
182 clean = purple_utf8_salvage(end);
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
183 tmp = g_strdup_printf("%.3s: %s", numeric, clean);
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
184 g_free(clean);
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
185 purple_conversation_write(convo, "", tmp,
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
186 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
187 |PURPLE_MESSAGE_RAW|PURPLE_MESSAGE_NO_LINKIFY,
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
188 time(NULL));
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
189 g_free(tmp);
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
190 return;
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
191
9c23321e1b68 Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents: 32123
diff changeset
192 undirected:
24763
67d9d4c975c0 Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24416
diff changeset
193 /* This, too, should be escaped somehow (smarter) */
32119
86a4c1ba3c1f disapproval of revision '708334868aba738134af61e8dab50f6f14a1e872'
Ethan Blanton <elb@pidgin.im>
parents: 32118
diff changeset
194 clean = purple_utf8_salvage(args[0]);
86a4c1ba3c1f disapproval of revision '708334868aba738134af61e8dab50f6f14a1e872'
Ethan Blanton <elb@pidgin.im>
parents: 32118
diff changeset
195 purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", clean);
86a4c1ba3c1f disapproval of revision '708334868aba738134af61e8dab50f6f14a1e872'
Ethan Blanton <elb@pidgin.im>
parents: 32118
diff changeset
196 g_free(clean);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
197 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
198
15501
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
199 void irc_msg_features(struct irc_conn *irc, const char *name, const char *from, char **args)
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
200 {
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
201 gchar **features;
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
202 int i;
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
203
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
204 if (!args || !args[0] || !args[1])
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
205 return;
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
206
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
207 features = g_strsplit(args[1], " ", -1);
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
208 for (i = 0; features[i]; i++) {
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
209 char *val;
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
210 if (!strncmp(features[i], "PREFIX=", 7)) {
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
211 if ((val = strchr(features[i] + 7, ')')) != NULL)
16167
8536102557ba Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
212 irc->mode_chars = g_strdup(val + 1);
15501
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
213 }
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
214 }
21684
c7881e1b73c7 another patch from my coworker Andrew Gaul that plugged a leak, I fixed it
Ka-Hing Cheung <khc@pidgin.im>
parents: 21279
diff changeset
215
c7881e1b73c7 another patch from my coworker Andrew Gaul that plugged a leak, I fixed it
Ka-Hing Cheung <khc@pidgin.im>
parents: 21279
diff changeset
216 g_strfreev(features);
15501
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
217 }
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
218
15508
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
219 void irc_msg_luser(struct irc_conn *irc, const char *name, const char *from, char **args)
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
220 {
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
221 if (!args || !args[0])
15508
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
222 return;
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
223
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
224 if (!strcmp(name, "251")) {
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
225 /* 251 is required, so we pluck our nick from here and
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
226 * finalize connection */
17170
609d6acda6aa Oops; I made some errors in the last commit. This is a fix of my
Ethan Blanton <elb@pidgin.im>
parents: 17169
diff changeset
227 irc_connected(irc, args[0]);
16893
f7c5d28375a8 Fix broken IRC servers which do not send a 255 numeric
Ethan Blanton <elb@pidgin.im>
parents: 16474
diff changeset
228 /* Some IRC servers seem to not send a 255 numeric, so
f7c5d28375a8 Fix broken IRC servers which do not send a 255 numeric
Ethan Blanton <elb@pidgin.im>
parents: 16474
diff changeset
229 * I guess we can't require it; 251 will do. */
f7c5d28375a8 Fix broken IRC servers which do not send a 255 numeric
Ethan Blanton <elb@pidgin.im>
parents: 16474
diff changeset
230 /* } else if (!strcmp(name, "255")) { */
15508
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
231 }
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
232 }
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
233
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
234 void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
235 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
236 PurpleConnection *gc;
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
237 char *msg;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
238
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
239 if (!args || !args[1])
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
240 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
241
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
242 if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) {
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
243 /* We're doing a whois, show this in the whois dialog */
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
244 irc_msg_whois(irc, name, from, args);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
245 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
246 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
247
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
248 gc = purple_account_get_connection(irc->account);
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
249 if (gc) {
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
250 msg = g_markup_escape_text(args[2], -1);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
251 serv_got_im(gc, args[1], msg, PURPLE_MESSAGE_AUTO_RESP, time(NULL));
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
252 g_free(msg);
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
253 }
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
254 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
255
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
256 void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
257 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
258 PurpleConnection *gc = purple_account_get_connection(irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
259
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
260 if (!args || !args[1] || !gc)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
261 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
262
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
263 purple_notify_error(gc, NULL, _("Bad mode"), args[1],
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
264 purple_request_cpar_from_connection(gc));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
265 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
266
22798
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
267 void irc_msg_ban(struct irc_conn *irc, const char *name, const char *from, char **args)
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
268 {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
269 PurpleChatConversation *chat;
22798
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
270
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
271 if (!args || !args[0] || !args[1])
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
272 return;
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
273
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
274 chat = purple_conversations_find_chat_with_account(args[1], irc->account);
22798
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
275
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
276 if (!strcmp(name, "367")) {
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
277 char *msg = NULL;
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
278 /* Ban list entry */
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
279 if (!args[2])
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
280 return;
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
281 if (args[3] && args[4]) {
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
282 /* This is an extended syntax, not in RFC 1459 */
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
283 int t1 = atoi(args[4]);
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
284 time_t t2 = time(NULL);
24416
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 23582
diff changeset
285 char *time = purple_str_seconds_to_string(t2 - t1);
23582
5b97b0d87d34 Use a more friendly format for the timestamp in the banlist.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23576
diff changeset
286 msg = g_strdup_printf(_("Ban on %s by %s, set %s ago"),
24416
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 23582
diff changeset
287 args[2], args[3], time);
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 23582
diff changeset
288 g_free(time);
22798
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
289 } else {
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
290 msg = g_strdup_printf(_("Ban on %s"), args[2]);
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
291 }
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
292 if (chat) {
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
293 purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", msg,
22798
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
294 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
295 time(NULL));
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
296 } else {
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
297 purple_debug_info("irc", "%s\n", msg);
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
298 }
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
299 g_free(msg);
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
300 } else if (!strcmp(name, "368")) {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
301 if (!chat)
22798
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
302 return;
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
303 /* End of ban list */
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
304 purple_conversation_write_message(PURPLE_CONVERSATION(chat), "",
22798
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
305 _("End of ban list"),
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
306 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
307 time(NULL));
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
308 }
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
309 }
a501b4137c64 Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents: 22795
diff changeset
310
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
311 void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
312 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
313 PurpleConnection *gc = purple_account_get_connection(irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
314 char *buf;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
315
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
316 if (!args || !args[1] || !gc)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
317 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
318
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
319 buf = g_strdup_printf(_("You are banned from %s."), args[1]);
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
320 purple_notify_error(gc, _("Banned"), _("Banned"), buf,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
321 purple_request_cpar_from_connection(gc));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
322 g_free(buf);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
323 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
324
10659
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
325 void irc_msg_banfull(struct irc_conn *irc, const char *name, const char *from, char **args)
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
326 {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
327 PurpleChatConversation *chat;
10659
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
328 char *buf, *nick;
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
329
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
330 if (!args || !args[0] || !args[1] || !args[2])
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
331 return;
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
332
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
333 chat = purple_conversations_find_chat_with_account(args[1], irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
334 if (!chat)
10659
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
335 return;
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
336
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
337 nick = g_markup_escape_text(args[2], -1);
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
338 buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick);
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
339 g_free(nick);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
340 purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", buf,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
341 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
10659
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
342 time(NULL));
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
343 g_free(buf);
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
344 }
caf16376fba0 [gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10637
diff changeset
345
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
346 void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
347 {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
348 PurpleChatConversation *chat;
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
349 char *buf, *escaped;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
350
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
351 if (!args || !args[1] || !args[2])
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
352 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
353
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
354 chat = purple_conversations_find_chat_with_account(args[1], irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
355 if (!chat) /* XXX punt on channels we are not in for now */
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
356 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
357
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
358 escaped = (args[3] != NULL) ? g_markup_escape_text(args[3], -1) : NULL;
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
359 buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : "");
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
360 purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
361 g_free(escaped);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
362 g_free(buf);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
363
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
364 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
365 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
366
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
367 void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
368 {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
369 if (!irc->whois.nick) {
16474
bc8580a69dba /whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents: 16167
diff changeset
370 purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected %s reply for %s\n", !strcmp(name, "314") ? "WHOWAS" : "WHOIS"
bc8580a69dba /whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents: 16167
diff changeset
371 , args[1]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
372 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
373 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
374
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
375 if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) {
16474
bc8580a69dba /whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents: 16167
diff changeset
376 purple_debug(PURPLE_DEBUG_WARNING, "irc", "Got %s reply for %s while waiting for %s\n", !strcmp(name, "314") ? "WHOWAS" : "WHOIS"
bc8580a69dba /whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents: 16167
diff changeset
377 , args[1], irc->whois.nick);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
378 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
379 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
380
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
381 if (!strcmp(name, "301")) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
382 irc->whois.away = g_strdup(args[2]);
16474
bc8580a69dba /whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents: 16167
diff changeset
383 } else if (!strcmp(name, "311") || !strcmp(name, "314")) {
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
384 irc->whois.userhost = g_strdup_printf("%s@%s", args[2], args[3]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
385 irc->whois.name = g_strdup(args[5]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
386 } else if (!strcmp(name, "312")) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
387 irc->whois.server = g_strdup(args[2]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
388 irc->whois.serverinfo = g_strdup(args[3]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
389 } else if (!strcmp(name, "313")) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
390 irc->whois.ircop = 1;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
391 } else if (!strcmp(name, "317")) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
392 irc->whois.idle = atoi(args[2]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
393 if (args[3])
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
394 irc->whois.signon = (time_t)atoi(args[3]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
395 } else if (!strcmp(name, "319")) {
25703
5e04772797b3 applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents: 24763
diff changeset
396 if (irc->whois.channels == NULL) {
5e04772797b3 applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents: 24763
diff changeset
397 irc->whois.channels = g_string_new(args[2]);
5e04772797b3 applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents: 24763
diff changeset
398 } else {
5e04772797b3 applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents: 24763
diff changeset
399 irc->whois.channels = g_string_append(irc->whois.channels, args[2]);
5e04772797b3 applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents: 24763
diff changeset
400 }
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
401 } else if (!strcmp(name, "320")) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
402 irc->whois.identified = 1;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
403 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
404 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
405
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
406 void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
407 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
408 PurpleConnection *gc;
15215
3b4c0490b8b0 [gaim-migrate @ 17939]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
409 char *tmp, *tmp2;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
410 PurpleNotifyUserInfo *user_info;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
411
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
412 if (!irc->whois.nick) {
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31284
diff changeset
413 purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected End of %s for %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS"
16474
bc8580a69dba /whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents: 16167
diff changeset
414 , args[1]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
415 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
416 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
417 if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) {
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31284
diff changeset
418 purple_debug(PURPLE_DEBUG_WARNING, "irc", "Received end of %s for %s, expecting %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS"
16474
bc8580a69dba /whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents: 16167
diff changeset
419 , args[1], irc->whois.nick);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
420 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
421 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
422
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
423 user_info = purple_notify_user_info_new();
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
424
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
425 tmp2 = g_markup_escape_text(args[1], -1);
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
426 tmp = g_strdup_printf("%s%s%s", tmp2,
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
427 (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""),
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
428 (irc->whois.identified ? _(" <i>(identified)</i>") : ""));
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 32162
diff changeset
429 purple_notify_user_info_add_pair_html(user_info, _("Nick"), tmp);
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
430 g_free(tmp2);
10634
36376a661022 [gaim-migrate @ 12114]
Ethan Blanton <elb@pidgin.im>
parents: 10633
diff changeset
431 g_free(tmp);
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
432
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
433 if (irc->whois.away) {
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
434 purple_notify_user_info_add_pair_plaintext(user_info, _("Away"), irc->whois.away);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
435 g_free(irc->whois.away);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
436 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
437 if (irc->whois.userhost) {
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
438 purple_notify_user_info_add_pair_plaintext(user_info, _("Username"), irc->whois.userhost);
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
439 purple_notify_user_info_add_pair_plaintext(user_info, _("Real name"), irc->whois.name);
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
440 g_free(irc->whois.userhost);
9589
229d4c811c01 [gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9558
diff changeset
441 g_free(irc->whois.name);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
442 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
443 if (irc->whois.server) {
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
444 tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo);
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
445 purple_notify_user_info_add_pair_plaintext(user_info, _("Server"), tmp);
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
446 g_free(tmp);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
447 g_free(irc->whois.server);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
448 g_free(irc->whois.serverinfo);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
449 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
450 if (irc->whois.channels) {
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
451 purple_notify_user_info_add_pair_plaintext(user_info, _("Currently on"), irc->whois.channels->str);
25703
5e04772797b3 applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents: 24763
diff changeset
452 g_string_free(irc->whois.channels, TRUE);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
453 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
454 if (irc->whois.idle) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
455 gchar *timex = purple_str_seconds_to_string(irc->whois.idle);
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
456 purple_notify_user_info_add_pair_plaintext(user_info, _("Idle for"), timex);
6357
f83643b0a067 [gaim-migrate @ 6856]
Mark Doliner <markdoliner@pidgin.im>
parents: 6351
diff changeset
457 g_free(timex);
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
458 purple_notify_user_info_add_pair_plaintext(user_info,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
459 _("Online since"), purple_date_format_full(localtime(&irc->whois.signon)));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
460 }
32162
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
461 if (!strcmp(irc->whois.nick, "elb")) {
cf848cd25330 Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents: 32157
diff changeset
462 purple_notify_user_info_add_pair_plaintext(user_info,
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 14731
diff changeset
463 _("<b>Defining adjective:</b>"), _("Glorious"));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
464 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
465
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
466 gc = purple_account_get_connection(irc->account);
7062
26abb8b189ce [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
467
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
468 purple_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
469 purple_notify_user_info_destroy(user_info);
7062
26abb8b189ce [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
470
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10246
diff changeset
471 g_free(irc->whois.nick);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
472 memset(&irc->whois, 0, sizeof(irc->whois));
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
473 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
474
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
475 void irc_msg_who(struct irc_conn *irc, const char *name, const char *from, char **args)
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
476 {
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
477 if (!strcmp(name, "352")) {
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 34169
diff changeset
478 PurpleChatConversation *chat;
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
479 PurpleChatUser *cb;
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
480
32037
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
481 char *cur, *userhost, *realname;
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
482
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
483 PurpleChatUserFlags flags;
32037
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
484
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
485 if (!args || !args[0] || !args[1] || !args[2] || !args[3]
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
486 || !args[4] || !args[5] || !args[6] || !args[7]) {
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
487 purple_debug(PURPLE_DEBUG_ERROR, "irc",
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
488 "Got a WHO response with not enough arguments\n");
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
489 return;
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
490 }
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
491
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
492 chat = purple_conversations_find_chat_with_account(args[1], irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
493 if (!chat) {
32037
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
494 purple_debug(PURPLE_DEBUG_ERROR, "irc","Got a WHO response for %s, which doesn't exist\n", args[1]);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
495 return;
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
496 }
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
497
34671
ca9b45be7a63 Renamed chat buddy to chat user in a few more places
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
498 cb = purple_chat_conversation_find_user(chat, args[5]);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
499 if (!cb) {
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
500 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a WHO response for %s who isn't a buddy.\n", args[5]);
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
501 return;
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
502 }
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
503
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
504 userhost = g_strdup_printf("%s@%s", args[2], args[3]);
32037
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
505
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
506 /* The final argument is a :-argument, but annoyingly
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
507 * contains two "words", the hop count and real name. */
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
508 for (cur = args[7]; *cur; cur++) {
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
509 if (*cur == ' ') {
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
510 cur++;
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
511 break;
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
512 }
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
513 }
619f32df41f1 Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents: 32019
diff changeset
514 realname = g_strdup(cur);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
515
34676
b70177e7a8b7 Removed attributes from PurpleChatUser. Used g_object_[gs]et_data()/g_object_[gs]et_data_full() instead
Ankit Vani <a@nevitus.org>
parents: 34671
diff changeset
516 g_object_set_data_full(G_OBJECT(cb), "userhost", userhost, (GDestroyNotify)g_free);
b70177e7a8b7 Removed attributes from PurpleChatUser. Used g_object_[gs]et_data()/g_object_[gs]et_data_full() instead
Ankit Vani <a@nevitus.org>
parents: 34671
diff changeset
517 g_object_set_data_full(G_OBJECT(cb), "realname", realname, (GDestroyNotify)g_free);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
518
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
519 flags = purple_chat_user_get_flags(cb);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
520
32117
6d49fa9e996c Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents: 32037
diff changeset
521 /* FIXME: I'm not sure this is really a good idea, now
6d49fa9e996c Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents: 32037
diff changeset
522 * that we no longer do periodic WHO. It seems to me
6d49fa9e996c Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents: 32037
diff changeset
523 * like it's more likely to be confusing than not.
6d49fa9e996c Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents: 32037
diff changeset
524 * Comments? */
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
525 if (args[6][0] == 'G' && !(flags & PURPLE_CHAT_USER_AWAY)) {
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
526 purple_chat_user_set_flags(cb, flags | PURPLE_CHAT_USER_AWAY);
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
527 } else if(args[6][0] == 'H' && (flags & PURPLE_CHAT_USER_AWAY)) {
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
528 purple_chat_user_set_flags(cb, flags & ~PURPLE_CHAT_USER_AWAY);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
529 }
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
530 }
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
531 }
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
532
8114
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
533 void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args)
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
534 {
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
535 if (!irc->roomlist)
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
536 return;
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
537
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
538 if (!strcmp(name, "321")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
539 purple_roomlist_set_in_progress(irc->roomlist, TRUE);
8114
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
540 return;
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
541 }
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
542
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
543 if (!strcmp(name, "323")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
544 purple_roomlist_set_in_progress(irc->roomlist, FALSE);
34932
1b74e5c63144 Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34855
diff changeset
545 g_object_unref(irc->roomlist);
8114
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
546 irc->roomlist = NULL;
13667
9ebf0007d912 [gaim-migrate @ 16068]
Richard Laager <rlaager@pidgin.im>
parents: 13647
diff changeset
547 return;
8114
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
548 }
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
549
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
550 if (!strcmp(name, "322")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
551 PurpleRoomlistRoom *room;
17409
1205b4f7bb82 This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents: 17297
diff changeset
552 char *topic;
8114
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
553
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
554 if (!args[0] || !args[1] || !args[2] || !args[3])
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
555 return;
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
556
22994
b30be6210442 Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents: 22983
diff changeset
557 if (!purple_roomlist_get_in_progress(irc->roomlist)) {
b30be6210442 Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents: 22983
diff changeset
558 purple_debug_warning("irc", "Buggy server didn't send RPL_LISTSTART.\n");
b30be6210442 Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents: 22983
diff changeset
559 purple_roomlist_set_in_progress(irc->roomlist, TRUE);
b30be6210442 Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents: 22983
diff changeset
560 }
b30be6210442 Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents: 22983
diff changeset
561
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
562 room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
563 purple_roomlist_room_add_field(irc->roomlist, room, args[1]);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
564 purple_roomlist_room_add_field(irc->roomlist, room, GINT_TO_POINTER(strtol(args[2], NULL, 10)));
17409
1205b4f7bb82 This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents: 17297
diff changeset
565 topic = irc_mirc2txt(args[3]);
1205b4f7bb82 This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents: 17297
diff changeset
566 purple_roomlist_room_add_field(irc->roomlist, room, topic);
1205b4f7bb82 This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents: 17297
diff changeset
567 g_free(topic);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
568 purple_roomlist_room_add(irc->roomlist, room);
8114
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
569 }
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
570 }
201c03cf6c5f [gaim-migrate @ 8818]
Tim Ringenbach <marv@pidgin.im>
parents: 7877
diff changeset
571
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
572 void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
573 {
9762
125f77c00102 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9741
diff changeset
574 char *chan, *topic, *msg, *nick, *tmp, *tmp2;
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
575 PurpleChatConversation *chat;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
576
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
577 if (!strcmp(name, "topic")) {
28465
615584769b59 Fix parsing of invalid IRC TOPIC messages which contain no actual topic
Ethan Blanton <elb@pidgin.im>
parents: 28118
diff changeset
578 if (!args[0] || !args[1])
615584769b59 Fix parsing of invalid IRC TOPIC messages which contain no actual topic
Ethan Blanton <elb@pidgin.im>
parents: 28118
diff changeset
579 return;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
580 chan = args[0];
8529
a598c585c575 [gaim-migrate @ 9268]
Ethan Blanton <elb@pidgin.im>
parents: 8504
diff changeset
581 topic = irc_mirc2txt (args[1]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
582 } else {
28465
615584769b59 Fix parsing of invalid IRC TOPIC messages which contain no actual topic
Ethan Blanton <elb@pidgin.im>
parents: 28118
diff changeset
583 if (!args[0] || !args[1] || !args[2])
28493
52da59867b93 Oh boy, fix a missing semi-colon
Mark Doliner <markdoliner@pidgin.im>
parents: 28465
diff changeset
584 return;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
585 chan = args[1];
8529
a598c585c575 [gaim-migrate @ 9268]
Ethan Blanton <elb@pidgin.im>
parents: 8504
diff changeset
586 topic = irc_mirc2txt (args[2]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
587 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
588
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
589 chat = purple_conversations_find_chat_with_account(chan, irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
590 if (!chat) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
591 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan);
13647
c0dd11a3254c [gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents: 13638
diff changeset
592 g_free(topic);
c0dd11a3254c [gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents: 13638
diff changeset
593 return;
c0dd11a3254c [gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents: 13638
diff changeset
594 }
c0dd11a3254c [gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents: 13638
diff changeset
595
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
596 /* If this is an interactive update, print it out */
10732
5e314ab498bf [gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents: 10730
diff changeset
597 tmp = g_markup_escape_text(topic, -1);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
598 tmp2 = purple_markup_linkify(tmp);
9762
125f77c00102 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9741
diff changeset
599 g_free(tmp);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
600 if (!strcmp(name, "topic")) {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
601 const char *current_topic = purple_chat_conversation_get_topic(chat);
13534
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
602 if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0))
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
603 {
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
604 char *nick_esc;
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
605 nick = irc_mask_nick(from);
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
606 nick_esc = g_markup_escape_text(nick, -1);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
607 purple_chat_conversation_set_topic(chat, nick, topic);
13534
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
608 if (*tmp2)
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
609 msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick_esc, tmp2);
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
610 else
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
611 msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc);
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
612 g_free(nick_esc);
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
613 g_free(nick);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
614 purple_conversation_write_message(PURPLE_CONVERSATION(chat), from,
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
615 msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
13534
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
616 g_free(msg);
637a369ac8b0 [gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents: 13525
diff changeset
617 }
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
618 } else {
13395
3174cf554db2 [gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents: 13120
diff changeset
619 char *chan_esc = g_markup_escape_text(chan, -1);
3174cf554db2 [gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents: 13120
diff changeset
620 msg = g_strdup_printf(_("The topic for %s is: %s"), chan_esc, tmp2);
3174cf554db2 [gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents: 13120
diff changeset
621 g_free(chan_esc);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
622 purple_chat_conversation_set_topic(chat, NULL, topic);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
623 purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", msg,
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
624 PURPLE_MESSAGE_SYSTEM, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
625 g_free(msg);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
626 }
9762
125f77c00102 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9741
diff changeset
627 g_free(tmp2);
8529
a598c585c575 [gaim-migrate @ 9268]
Ethan Blanton <elb@pidgin.im>
parents: 8504
diff changeset
628 g_free(topic);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
629 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
630
33544
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
631 void irc_msg_topicinfo(struct irc_conn *irc, const char *name, const char *from, char **args)
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
632 {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
633 PurpleChatConversation *chat;
33544
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
634 struct tm *tm;
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
635 time_t t;
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
636 char *msg, *timestamp, *datestamp;
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
637
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
638 if (!args || !args[1] || !args[2] || !args[3])
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
639 return;
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
640
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
641 chat = purple_conversations_find_chat_with_account(args[1], irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
642 if (!chat) {
33544
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
643 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got topic info for %s, which doesn't exist\n", args[1]);
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
644 return;
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
645 }
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
646
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
647 t = (time_t)atol(args[3]);
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
648 if (t == 0) {
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
649 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got apparently nonsensical topic timestamp %s\n", args[3]);
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
650 return;
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
651 }
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
652 tm = localtime(&t);
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
653
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
654 timestamp = g_strdup(purple_time_format(tm));
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
655 datestamp = g_strdup(purple_date_format_short(tm));
33729
ad9fe0ad7f39 The "Topic set" message should be translateable. Refs #13317
Daniel Atallah <datallah@pidgin.im>
parents: 33544
diff changeset
656 msg = g_strdup_printf(_("Topic for %s set by %s at %s on %s"), args[1], args[2], timestamp, datestamp);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
657 purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", msg,
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
658 PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LINKIFY, time(NULL));
33544
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
659 g_free(timestamp);
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
660 g_free(datestamp);
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
661 g_free(msg);
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
662 }
3780e4cb9738 Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents: 33407
diff changeset
663
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
664 void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
665 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
666 PurpleConnection *gc = purple_account_get_connection(irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
667 char *buf;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
668
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
669 if (!args || !args[1] || !gc)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
670 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
671
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
672 buf = g_strdup_printf(_("Unknown message '%s'"), args[1]);
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
673 purple_notify_error(gc, _("Unknown message"), buf, _("The IRC server "
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
674 "received a message it did not understand."),
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
675 purple_request_cpar_from_connection(gc));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
676 g_free(buf);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
677 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
678
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
679 void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
680 {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
681 char *names, *cur, *end, *tmp, *msg;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
682 PurpleConversation *convo;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
683
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
684 if (!strcmp(name, "366")) {
34625
03d62b1660fc Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
685 convo = purple_conversations_find_with_account(args[1], irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
686 if (!convo) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
687 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
688 g_string_free(irc->names, TRUE);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
689 irc->names = NULL;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
690 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
691 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
692
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
693 names = cur = g_string_free(irc->names, FALSE);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
694 irc->names = NULL;
34678
40a30f74a7b8 Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents: 34676
diff changeset
695 if (g_object_get_data(G_OBJECT(convo), IRC_NAMES_FLAG)) {
11026
1f13c483db00 [gaim-migrate @ 12901]
Daniel Atallah <datallah@pidgin.im>
parents: 10816
diff changeset
696 msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : "");
34629
3c3bed0fd13c Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
697 purple_conversation_write_message(convo, "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
698 g_free(msg);
32019
15434d17f320 Fix potential crash when NAMES is empty.
James McLaughlin <jamie@lacewing-project.org>
parents: 31936
diff changeset
699 } else if (cur != NULL) {
6407
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
700 GList *users = NULL;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
701 GList *flags = NULL;
6407
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
702
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
703 while (*cur) {
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
704 PurpleChatUserFlags f = PURPLE_CHAT_USER_NONE;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
705 end = strchr(cur, ' ');
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
706 if (!end)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
707 end = cur + strlen(cur);
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
708 if (*cur == '@') {
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
709 f = PURPLE_CHAT_USER_OP;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
710 cur++;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
711 } else if (*cur == '%') {
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
712 f = PURPLE_CHAT_USER_HALFOP;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
713 cur++;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
714 } else if(*cur == '+') {
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
715 f = PURPLE_CHAT_USER_VOICE;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
716 cur++;
16167
8536102557ba Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
717 } else if(irc->mode_chars
8536102557ba Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
718 && strchr(irc->mode_chars, *cur)) {
22471
aa32d9ed764d Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21736
diff changeset
719 if (*cur == '~')
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
720 f = PURPLE_CHAT_USER_FOUNDER;
15501
8547fa591578 Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents: 15444
diff changeset
721 cur++;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
722 }
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
723 tmp = g_strndup(cur, end - cur);
11869
e77f2f29b09d [gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11535
diff changeset
724 users = g_list_prepend(users, tmp);
e77f2f29b09d [gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11535
diff changeset
725 flags = g_list_prepend(flags, GINT_TO_POINTER(f));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
726 cur = end;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
727 if (*cur)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
728 cur++;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
729 }
6407
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
730
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
731 if (users != NULL) {
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
732 GList *l;
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
733
34629
3c3bed0fd13c Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
734 purple_chat_conversation_add_users(PURPLE_CHAT_CONVERSATION(convo), users, NULL, flags, FALSE);
6407
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
735
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
736 for (l = users; l != NULL; l = l->next)
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
737 g_free(l->data);
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
738
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
739 g_list_free(users);
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
740 g_list_free(flags);
6407
d67b6a6ba7d2 [gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
741 }
15516
07e9a078cc06 This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents: 15508
diff changeset
742
34678
40a30f74a7b8 Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents: 34676
diff changeset
743 g_object_set_data(G_OBJECT(convo), IRC_NAMES_FLAG,
15516
07e9a078cc06 This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents: 15508
diff changeset
744 GINT_TO_POINTER(TRUE));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
745 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
746 g_free(names);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
747 } else {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
748 if (!irc->names)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
749 irc->names = g_string_new("");
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
750
15313
b6ae2956a561 [gaim-migrate @ 18041]
Ethan Blanton <elb@pidgin.im>
parents: 15215
diff changeset
751 if (irc->names->len && irc->names->str[irc->names->len - 1] != ' ')
b6ae2956a561 [gaim-migrate @ 18041]
Ethan Blanton <elb@pidgin.im>
parents: 15215
diff changeset
752 irc->names = g_string_append_c(irc->names, ' ');
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
753 irc->names = g_string_append(irc->names, args[3]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
754 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
755 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
756
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
757 void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
758 {
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
759 char *escaped;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
760
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
761 if (!args || !args[0])
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
762 return;
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
763
15508
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
764 if (!strcmp(name, "375")) {
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
765 if (irc->motd)
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
766 g_string_free(irc->motd, TRUE);
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
767 irc->motd = g_string_new("");
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
768 return;
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
769 } else if (!strcmp(name, "376")) {
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
770 /* dircproxy 1.0.5 does not send 251 on reconnection, so
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
771 * finalize the connection here if it is not already done. */
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
772 irc_connected(irc, args[0]);
15508
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
773 return;
31229
4bef370d8a92 Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 30270
diff changeset
774 } else if (!strcmp(name, "422")) {
4bef370d8a92 Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 30270
diff changeset
775 /* in case there is no 251, and no MOTD set, finalize the connection.
4bef370d8a92 Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 30270
diff changeset
776 * (and clear the motd for good measure). */
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31284
diff changeset
777
31229
4bef370d8a92 Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 30270
diff changeset
778 if (irc->motd)
4bef370d8a92 Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 30270
diff changeset
779 g_string_free(irc->motd, TRUE);
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31284
diff changeset
780
31229
4bef370d8a92 Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 30270
diff changeset
781 irc_connected(irc, args[0]);
4bef370d8a92 Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 30270
diff changeset
782 return;
15508
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
783 }
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
784
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
785 if (!irc->motd) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
786 purple_debug_error("irc", "IRC server sent MOTD without STARTMOTD\n");
15508
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
787 return;
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
788 }
51a669b06193 This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents: 15501
diff changeset
789
17169
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
790 if (!args[1])
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
791 return;
daa8fdad4564 Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents: 16993
diff changeset
792
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
793 escaped = g_markup_escape_text(args[1], -1);
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
794 g_string_append_printf(irc->motd, "%s<br>", escaped);
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
795 g_free(escaped);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
796 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
797
10564
1ee5ae99711d [gaim-migrate @ 11946]
Don Seiler <rizzo@gentoo.org>
parents: 10551
diff changeset
798 void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args)
1ee5ae99711d [gaim-migrate @ 11946]
Don Seiler <rizzo@gentoo.org>
parents: 10551
diff changeset
799 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
800 PurpleConnection *gc;
10564
1ee5ae99711d [gaim-migrate @ 11946]
Don Seiler <rizzo@gentoo.org>
parents: 10551
diff changeset
801
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
802 gc = purple_account_get_connection(irc->account);
10564
1ee5ae99711d [gaim-migrate @ 11946]
Don Seiler <rizzo@gentoo.org>
parents: 10551
diff changeset
803 if (gc == NULL || args == NULL || args[2] == NULL)
1ee5ae99711d [gaim-migrate @ 11946]
Don Seiler <rizzo@gentoo.org>
parents: 10551
diff changeset
804 return;
1ee5ae99711d [gaim-migrate @ 11946]
Don Seiler <rizzo@gentoo.org>
parents: 10551
diff changeset
805
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
806 purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"),
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
807 _("The IRC server's local time is:"), args[2], NULL, NULL,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
808 purple_request_cpar_from_connection(gc));
10564
1ee5ae99711d [gaim-migrate @ 11946]
Don Seiler <rizzo@gentoo.org>
parents: 10551
diff changeset
809 }
1ee5ae99711d [gaim-migrate @ 11946]
Don Seiler <rizzo@gentoo.org>
parents: 10551
diff changeset
810
7877
e523a7081aaf [gaim-migrate @ 8531]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
811 void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args)
e523a7081aaf [gaim-migrate @ 8531]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
812 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
813 PurpleConnection *gc = purple_account_get_connection(irc->account);
7877
e523a7081aaf [gaim-migrate @ 8531]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
814
e523a7081aaf [gaim-migrate @ 8531]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
815 if (gc == NULL || args == NULL || args[1] == NULL)
e523a7081aaf [gaim-migrate @ 8531]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
816 return;
e523a7081aaf [gaim-migrate @ 8531]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
817
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
818 purple_notify_error(gc, NULL, _("No such channel"), args[1],
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
819 purple_request_cpar_from_connection(gc));
7877
e523a7081aaf [gaim-migrate @ 8531]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
820 }
e523a7081aaf [gaim-migrate @ 8531]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
821
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
822 void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
823 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
824 PurpleConnection *gc;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
825 PurpleConversation *convo;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
826
34625
03d62b1660fc Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
827 convo = purple_conversations_find_with_account(args[1], irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
828 if (convo) {
34629
3c3bed0fd13c Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
829 purple_conversation_write_message(convo, args[1],
3c3bed0fd13c Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
830 PURPLE_IS_IM_CONVERSATION(convo) ? _("User is not logged in") : _("no such channel"),
3c3bed0fd13c Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
831 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
3c3bed0fd13c Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
832
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
833 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
834 if ((gc = purple_account_get_connection(irc->account)) == NULL)
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
835 return;
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
836 purple_notify_error(gc, NULL, _("No such nick or channel"),
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
837 args[1], purple_request_cpar_from_connection(gc));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
838 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
839
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
840 if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) {
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
841 g_free(irc->whois.nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
842 irc->whois.nick = NULL;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
843 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
844 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
845
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
846 void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
847 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
848 PurpleConnection *gc;
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
849 PurpleChatConversation *chat;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
850
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
851 chat = purple_conversations_find_chat_with_account(args[1], irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
852 if (chat) {
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
853 purple_conversation_write_message(PURPLE_CONVERSATION(chat), args[1], args[2],
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
854 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
855 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
856 if ((gc = purple_account_get_connection(irc->account)) == NULL)
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
857 return;
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
858 purple_notify_error(gc, NULL, _("Could not send"), args[2],
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
859 purple_request_cpar_from_connection(gc));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
860 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
861 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
862
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
863 void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
864 {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
865 PurpleChatConversation *chat = purple_conversations_find_chat_with_account(args[1], irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
866
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
867 purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
868 if (chat) {
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
869 /*g_slist_remove(irc->gc->buddy_chats, chat);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
870 purple_conversation_set_account(chat, NULL);*/
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
871 purple_conversation_write_message(PURPLE_CONVERSATION(chat), args[1], args[2],
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
872 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
873 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
874 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
875
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
876 void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
877 {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
878 PurpleChatConversation *chat;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
879
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
880 if (!args || !args[1] || !args[2])
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
881 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
882
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
883 chat = purple_conversations_find_chat_with_account(args[1], irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
884 if (!chat)
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
885 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
886
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
887 purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", args[2], PURPLE_MESSAGE_SYSTEM, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
888 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
889
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
890 void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
891 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
892 PurpleConnection *gc = purple_account_get_connection(irc->account);
22876
824abbeefcc2 Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents: 22870
diff changeset
893 GHashTable *components;
824abbeefcc2 Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents: 22870
diff changeset
894 gchar *nick;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
895
22876
824abbeefcc2 Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents: 22870
diff changeset
896 if (!args || !args[1] || !gc)
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
897 return;
22876
824abbeefcc2 Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents: 22870
diff changeset
898
824abbeefcc2 Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents: 22870
diff changeset
899 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
824abbeefcc2 Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents: 22870
diff changeset
900 nick = irc_mask_nick(from);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
901
22870
25b482330fec Use g_strdup to match the subsequent g_free.
Daniel Atallah <datallah@pidgin.im>
parents: 22798
diff changeset
902 g_hash_table_insert(components, g_strdup("channel"), g_strdup(args[1]));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
903
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
904 serv_got_chat_invite(gc, args[1], nick, NULL, components);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
905 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
906 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
907
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
908 void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
909 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
910 PurpleConnection *gc = purple_account_get_connection(irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
911 char *buf;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
912
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
913 if (!args || !args[1] || !gc)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
914 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
915
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
916 buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]);
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
917 purple_notify_error(gc, _("Invitation only"), _("Invitation only"), buf,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
918 purple_request_cpar_from_connection(gc));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
919 g_free(buf);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
920 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
921
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
922 void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
923 {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
924 char **nicks;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
925 struct irc_buddy *ib;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
926 int i;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
927
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
928 if (!args || !args[1])
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
929 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
930
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
931 nicks = g_strsplit(args[1], " ", -1);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
932 for (i = 0; nicks[i]; i++) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
933 if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
934 continue;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
935 }
31284
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
936 ib->new_online_status = TRUE;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
937 }
6350
22dfc953f2fb [gaim-migrate @ 6849]
Ethan Blanton <elb@pidgin.im>
parents: 6333
diff changeset
938 g_strfreev(nicks);
22dfc953f2fb [gaim-migrate @ 6849]
Ethan Blanton <elb@pidgin.im>
parents: 6333
diff changeset
939
31284
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
940 if (irc->ison_outstanding)
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
941 irc_buddy_query(irc);
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
942
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
943 if (!irc->ison_outstanding)
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
944 g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
945 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
946
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
947 static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
948 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
949 PurpleConnection *gc = purple_account_get_connection(irc->account);
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
950 PurpleBuddy *buddy = purple_blist_find_buddy(irc->account, name);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
951
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
952 if (!gc || !buddy)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
953 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
954
31284
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
955 if (ib->online && !ib->new_online_status) {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
956 purple_protocol_got_user_status(irc->account, name, "offline", NULL);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
957 ib->online = FALSE;
31284
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
958 } else if (!ib->online && ib->new_online_status) {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
959 purple_protocol_got_user_status(irc->account, name, "available", NULL);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
960 ib->online = TRUE;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
961 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
962 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
963
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
964 void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
965 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
966 PurpleConnection *gc = purple_account_get_connection(irc->account);
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 34169
diff changeset
967 PurpleChatConversation *chat;
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
968 PurpleChatUser *cb;
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
969
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
970 char *nick = irc_mask_nick(from), *userhost, *buf;
9238
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
971 struct irc_buddy *ib;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
972 static int id = 1;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
973
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
974 if (!gc) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
975 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
976 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
977 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
978
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
979 if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) {
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
980 /* We are joining a channel for the first time */
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
981 serv_got_joined_chat(gc, id++, args[0]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
982 g_free(nick);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
983 chat = purple_conversations_find_chat_with_account(args[0], irc->account);
15516
07e9a078cc06 This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents: 15508
diff changeset
984
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
985 if (chat == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
986 purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]);
13938
dbafabe02e9e [gaim-migrate @ 16351]
Ethan Blanton <elb@pidgin.im>
parents: 13786
diff changeset
987 return;
dbafabe02e9e [gaim-migrate @ 16351]
Ethan Blanton <elb@pidgin.im>
parents: 13786
diff changeset
988 }
34678
40a30f74a7b8 Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents: 34676
diff changeset
989 g_object_set_data(G_OBJECT(chat), IRC_NAMES_FLAG,
15516
07e9a078cc06 This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents: 15508
diff changeset
990 GINT_TO_POINTER(FALSE));
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
991
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
992 // Get the real name and user host for all participants.
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
993 buf = irc_format(irc, "vc", "WHO", args[0]);
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
994 irc_send(irc, buf);
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
995 g_free(buf);
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
996
20194
fee478bb059b applied changes from 26c05ed157a02643cbb12b04045422b123312bcf
Ethan Blanton <elb@pidgin.im>
parents: 19859
diff changeset
997 /* Until purple_conversation_present does something that
24763
67d9d4c975c0 Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24416
diff changeset
998 * one would expect in Pidgin, this call produces buggy
67d9d4c975c0 Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24416
diff changeset
999 * behavior both for the /join and auto-join cases. */
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1000 /* purple_conversation_present(chat); */
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1001 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1002 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1003
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1004 chat = purple_conversations_find_chat_with_account(args[0], irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1005 if (chat == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1006 purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1007 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1008 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1009 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1010
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1011 userhost = irc_mask_userhost(from);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
1012
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1013 purple_chat_conversation_add_user(chat, nick, userhost, PURPLE_CHAT_USER_NONE, TRUE);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
1014
34671
ca9b45be7a63 Renamed chat buddy to chat user in a few more places
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
1015 cb = purple_chat_conversation_find_user(chat, nick);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
1016
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
1017 if (cb) {
34676
b70177e7a8b7 Removed attributes from PurpleChatUser. Used g_object_[gs]et_data()/g_object_[gs]et_data_full() instead
Ankit Vani <a@nevitus.org>
parents: 34671
diff changeset
1018 g_object_set_data_full(G_OBJECT(cb), "userhost", userhost, (GDestroyNotify)g_free);
31565
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
1019 }
1138b2c998ec propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31451
diff changeset
1020
9238
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
1021 if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) {
31284
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
1022 ib->new_online_status = TRUE;
9238
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
1023 irc_buddy_status(nick, ib, irc);
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
1024 }
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
1025
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1026 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1027 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1028
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1029 void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1030 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1031 PurpleConnection *gc = purple_account_get_connection(irc->account);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1032 PurpleChatConversation *chat = purple_conversations_find_chat_with_account(args[0], irc->account);
12855
5215e8d13a49 [gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents: 12216
diff changeset
1033 char *nick = irc_mask_nick(from), *buf;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1034
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1035 if (!gc) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1036 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1037 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1038 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1039
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1040 if (!chat) {
30270
8380aae8b132 I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 29286
diff changeset
1041 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Received a KICK for unknown channel %s\n", args[0]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1042 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1043 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1044 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1045
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1046 if (!purple_utf8_strcasecmp(purple_connection_get_display_name(gc), args[1])) {
12855
5215e8d13a49 [gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents: 12216
diff changeset
1047 buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1048 purple_conversation_write_message(PURPLE_CONVERSATION(chat), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1049 g_free(buf);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1050 serv_got_chat_left(gc, purple_chat_conversation_get_id(chat));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1051 } else {
12855
5215e8d13a49 [gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents: 12216
diff changeset
1052 buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1053 purple_chat_conversation_remove_user(chat, args[1], buf);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1054 g_free(buf);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1055 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1056
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1057 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1058 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1059 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1060
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1061 void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1062 {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1063 PurpleChatConversation *chat;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1064 char *nick = irc_mask_nick(from), *buf;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1065
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1066 if (*args[0] == '#' || *args[0] == '&') { /* Channel */
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
1067 char *escaped;
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1068 chat = purple_conversations_find_chat_with_account(args[0], irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1069 if (!chat) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1070 purple_debug(PURPLE_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1071 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1072 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1073 }
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
1074 escaped = (args[2] != NULL) ? g_markup_escape_text(args[2], -1) : NULL;
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
1075 buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1076 purple_conversation_write_message(PURPLE_CONVERSATION(chat), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
1077 g_free(escaped);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1078 g_free(buf);
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1079 if(args[2]) {
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1080 PurpleChatUser *cb;
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1081 PurpleChatUserFlags newflag, flags;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1082 char *mcur, *cur, *end, *user;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1083 gboolean add = FALSE;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1084 mcur = args[1];
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1085 cur = args[2];
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1086 while (*cur && *mcur) {
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1087 if ((*mcur == '+') || (*mcur == '-')) {
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1088 add = (*mcur == '+') ? TRUE : FALSE;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1089 mcur++;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1090 continue;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1091 }
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1092 end = strchr(cur, ' ');
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1093 if (!end)
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1094 end = cur + strlen(cur);
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1095 user = g_strndup(cur, end - cur);
34671
ca9b45be7a63 Renamed chat buddy to chat user in a few more places
Ankit Vani <a@nevitus.org>
parents: 34670
diff changeset
1096 cb = purple_chat_conversation_find_user(chat, user);
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1097 flags = purple_chat_user_get_flags(cb);
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1098 newflag = PURPLE_CHAT_USER_NONE;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1099 if (*mcur == 'o')
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1100 newflag = PURPLE_CHAT_USER_OP;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1101 else if (*mcur =='h')
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1102 newflag = PURPLE_CHAT_USER_HALFOP;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1103 else if (*mcur == 'v')
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1104 newflag = PURPLE_CHAT_USER_VOICE;
22471
aa32d9ed764d Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21736
diff changeset
1105 else if(irc->mode_chars
aa32d9ed764d Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21736
diff changeset
1106 && strchr(irc->mode_chars, '~') && (*mcur == 'q'))
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1107 newflag = PURPLE_CHAT_USER_FOUNDER;
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1108 if (newflag) {
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1109 if (add)
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1110 flags |= newflag;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1111 else
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1112 flags &= ~newflag;
34670
9bd5bd903dc7 Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents: 34653
diff changeset
1113 purple_chat_user_set_flags(cb, flags);
9554
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1114 }
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1115 g_free(user);
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1116 cur = end;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1117 if (*cur)
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1118 cur++;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1119 if (*mcur)
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1120 mcur++;
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1121 }
1609ba3612c3 [gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9518
diff changeset
1122 }
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1123 } else { /* User */
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1124 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1125 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1126 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1127
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1128 void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1129 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1130 PurpleConnection *gc = purple_account_get_connection(irc->account);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1131 PurpleIMConversation *im;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1132 GSList *chats;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1133 char *nick = irc_mask_nick(from);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1134
23118
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1135 irc->nickused = FALSE;
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1136
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1137 if (!gc) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1138 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1139 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1140 }
34750
826c1611ef90 Refactored protocols to use the initial GObject connection API.
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
1141 chats = purple_connection_get_active_chats(gc);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1142
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1143 if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1144 purple_connection_set_display_name(gc, args[0]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1145 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1146
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1147 while (chats) {
34629
3c3bed0fd13c Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
1148 PurpleChatConversation *chat = PURPLE_CHAT_CONVERSATION(chats->data);
9593
4231c290edfe [gaim-migrate @ 10436]
Ethan Blanton <elb@pidgin.im>
parents: 9589
diff changeset
1149 /* This is ugly ... */
34653
88ae47a7d595 Updated protocols for the API changes
Ankit Vani <a@nevitus.org>
parents: 34632
diff changeset
1150 if (purple_chat_conversation_has_user(chat, nick))
34622
753f46dd000f Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents: 34169
diff changeset
1151 purple_chat_conversation_rename_user(chat, nick, args[0]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1152 chats = chats->next;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1153 }
10617
c9d55f2363c4 [gaim-migrate @ 12081]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
1154
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1155 im = purple_conversations_find_im_with_account(nick,
10617
c9d55f2363c4 [gaim-migrate @ 12081]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
1156 irc->account);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1157 if (im != NULL)
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1158 purple_conversation_set_name(PURPLE_CONVERSATION(im), args[0]);
10617
c9d55f2363c4 [gaim-migrate @ 12081]
Ethan Blanton <elb@pidgin.im>
parents: 10564
diff changeset
1159
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1160 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1161 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1162
10633
ac455de21138 [gaim-migrate @ 12113]
Ethan Blanton <elb@pidgin.im>
parents: 10617
diff changeset
1163 void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args)
ac455de21138 [gaim-migrate @ 12113]
Ethan Blanton <elb@pidgin.im>
parents: 10617
diff changeset
1164 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1165 PurpleConnection *gc = purple_account_get_connection(irc->account);
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1166 if (purple_connection_get_state(gc) == PURPLE_CONNECTION_CONNECTED) {
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1167 purple_notify_error(gc, _("Invalid nickname"), _("Invalid "
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1168 "nickname"), _("Your selected nickname was rejected by "
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1169 "the server. It probably contains invalid characters."),
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1170 purple_request_cpar_from_connection(gc));
13057
329564dcd96c [gaim-migrate @ 15419]
Ethan Blanton <elb@pidgin.im>
parents: 12855
diff changeset
1171
329564dcd96c [gaim-migrate @ 15419]
Ethan Blanton <elb@pidgin.im>
parents: 12855
diff changeset
1172 } else {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 32037
diff changeset
1173 purple_connection_error (gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21152
diff changeset
1174 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
20440
42e5e5445a2f Move prpl-irc to purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents: 19859
diff changeset
1175 _("Your selected account name was rejected by the server. It probably contains invalid characters."));
13057
329564dcd96c [gaim-migrate @ 15419]
Ethan Blanton <elb@pidgin.im>
parents: 12855
diff changeset
1176 }
10633
ac455de21138 [gaim-migrate @ 12113]
Ethan Blanton <elb@pidgin.im>
parents: 10617
diff changeset
1177 }
ac455de21138 [gaim-migrate @ 12113]
Ethan Blanton <elb@pidgin.im>
parents: 10617
diff changeset
1178
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1179 void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1180 {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1181 char *newnick, *buf, *end;
25705
8bb42bb17cc8 applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents: 25703
diff changeset
1182 PurpleConnection *gc = purple_account_get_connection(irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1183
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1184 if (!args || !args[1])
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1185 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1186
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1187 if (gc && purple_connection_get_state(gc) == PURPLE_CONNECTION_CONNECTED) {
25705
8bb42bb17cc8 applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents: 25703
diff changeset
1188 /* We only want to do the following dance if the connection
8bb42bb17cc8 applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents: 25703
diff changeset
1189 has not been successfully completed. If it has, just
8bb42bb17cc8 applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents: 25703
diff changeset
1190 notify the user that their /nick command didn't go. */
26825
6d3bb5625183 Notify the user if an IRC /nick command fails, rather than trying fallbacks.
Ethan Blanton <elb@pidgin.im>
parents: 26752
diff changeset
1191 buf = g_strdup_printf(_("The nickname \"%s\" is already being used."),
25705
8bb42bb17cc8 applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents: 25703
diff changeset
1192 irc->reqnick);
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1193 purple_notify_error(gc, _("Nickname in use"), _("Nickname in "
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1194 "use"), buf, purple_request_cpar_from_connection(gc));
25705
8bb42bb17cc8 applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents: 25703
diff changeset
1195 g_free(buf);
8bb42bb17cc8 applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents: 25703
diff changeset
1196 g_free(irc->reqnick);
25706
cbaf3afc17c6 applied changes from 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents: 25705
diff changeset
1197 irc->reqnick = NULL;
25707
e1b69b86aa3c Hand-pluck of 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents: 25706
diff changeset
1198 return;
25705
8bb42bb17cc8 applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents: 25703
diff changeset
1199 }
8bb42bb17cc8 applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents: 25703
diff changeset
1200
23118
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1201 if (strlen(args[1]) < strlen(irc->reqnick) || irc->nickused)
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1202 newnick = g_strdup(args[1]);
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1203 else
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1204 newnick = g_strdup_printf("%s0", args[1]);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1205 end = newnick + strlen(newnick) - 1;
11386
89c0c029ecfd [gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents: 11338
diff changeset
1206 /* try fallbacks */
89c0c029ecfd [gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents: 11338
diff changeset
1207 if((*end < '9') && (*end >= '1')) {
89c0c029ecfd [gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents: 11338
diff changeset
1208 *end = *end + 1;
89c0c029ecfd [gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents: 11338
diff changeset
1209 } else *end = '1';
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1210
23118
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1211 g_free(irc->reqnick);
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1212 irc->reqnick = newnick;
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1213 irc->nickused = TRUE;
7ba846a8187f Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22994
diff changeset
1214
23576
e2978ee98aa7 set the purple connection name to the one we are about to try
Ka-Hing Cheung <khc@pidgin.im>
parents: 23475
diff changeset
1215 purple_connection_set_display_name(
e2978ee98aa7 set the purple connection name to the one we are about to try
Ka-Hing Cheung <khc@pidgin.im>
parents: 23475
diff changeset
1216 purple_account_get_connection(irc->account), newnick);
e2978ee98aa7 set the purple connection name to the one we are about to try
Ka-Hing Cheung <khc@pidgin.im>
parents: 23475
diff changeset
1217
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1218 buf = irc_format(irc, "vn", "NICK", newnick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1219 irc_send(irc, buf);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1220 g_free(buf);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1221 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1222
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1223 void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1224 {
13525
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1225 if (!args || !args[0] || !args[1])
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1226 return;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1227
13525
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1228 irc_msg_handle_privmsg(irc, name, from, args[0], args[1], TRUE);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1229 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1230
6718
c535c7b09353 [gaim-migrate @ 7245]
Ethan Blanton <elb@pidgin.im>
parents: 6714
diff changeset
1231 void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args)
c535c7b09353 [gaim-migrate @ 7245]
Ethan Blanton <elb@pidgin.im>
parents: 6714
diff changeset
1232 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1233 PurpleConnection *gc = purple_account_get_connection(irc->account);
6718
c535c7b09353 [gaim-migrate @ 7245]
Ethan Blanton <elb@pidgin.im>
parents: 6714
diff changeset
1234
6753
7d8e93748f43 [gaim-migrate @ 7285]
Ethan Blanton <elb@pidgin.im>
parents: 6718
diff changeset
1235 if (!args || !args[2] || !gc)
6718
c535c7b09353 [gaim-migrate @ 7245]
Ethan Blanton <elb@pidgin.im>
parents: 6714
diff changeset
1236 return;
c535c7b09353 [gaim-migrate @ 7245]
Ethan Blanton <elb@pidgin.im>
parents: 6714
diff changeset
1237
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1238 purple_notify_error(gc, _("Cannot change nick"),
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1239 _("Could not change nick"), args[2],
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1240 purple_request_cpar_from_connection(gc));
6718
c535c7b09353 [gaim-migrate @ 7245]
Ethan Blanton <elb@pidgin.im>
parents: 6714
diff changeset
1241 }
c535c7b09353 [gaim-migrate @ 7245]
Ethan Blanton <elb@pidgin.im>
parents: 6714
diff changeset
1242
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1243 void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1244 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1245 PurpleConnection *gc = purple_account_get_connection(irc->account);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1246 PurpleChatConversation *chat;
22983
861402a1fe68 Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents: 22876
diff changeset
1247 char *nick, *msg, *channel;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1248
8186
3b37807ed6f2 [gaim-migrate @ 8907]
Ethan Blanton <elb@pidgin.im>
parents: 8163
diff changeset
1249 if (!args || !args[0] || !gc)
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1250 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1251
22983
861402a1fe68 Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents: 22876
diff changeset
1252 /* Undernet likes to :-quote the channel name, for no good reason
24763
67d9d4c975c0 Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24416
diff changeset
1253 * that I can see. This catches that. */
22983
861402a1fe68 Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents: 22876
diff changeset
1254 channel = (args[0][0] == ':') ? &args[0][1] : args[0];
861402a1fe68 Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents: 22876
diff changeset
1255
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1256 chat = purple_conversations_find_chat_with_account(channel, irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1257 if (!chat) {
22983
861402a1fe68 Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents: 22876
diff changeset
1258 purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", channel);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1259 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1260 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1261
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1262 nick = irc_mask_nick(from);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1263 if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) {
29286
f9996ff32055 irc: Avoid a g_log error when parting a chatroom.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28493
diff changeset
1264 char *escaped = args[1] ? g_markup_escape_text(args[1], -1) : NULL;
8186
3b37807ed6f2 [gaim-migrate @ 8907]
Ethan Blanton <elb@pidgin.im>
parents: 8163
diff changeset
1265 msg = g_strdup_printf(_("You have parted the channel%s%s"),
24763
67d9d4c975c0 Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24416
diff changeset
1266 (args[1] && *args[1]) ? ": " : "",
67d9d4c975c0 Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24416
diff changeset
1267 (escaped && *escaped) ? escaped : "");
12855
5215e8d13a49 [gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents: 12216
diff changeset
1268 g_free(escaped);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1269 purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel, msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1270 g_free(msg);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1271 serv_got_chat_left(gc, purple_chat_conversation_get_id(chat));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1272 } else {
22795
2b1d41a575f5 Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents: 22471
diff changeset
1273 msg = args[1] ? irc_mirc2txt(args[1]) : NULL;
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1274 purple_chat_conversation_remove_user(chat, nick, msg);
22795
2b1d41a575f5 Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents: 22471
diff changeset
1275 g_free(msg);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1276 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1277 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1278 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1279
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1280 void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1281 {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1282 char *buf;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1283 if (!args || !args[0])
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1284 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1285
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1286 buf = irc_format(irc, "v:", "PONG", args[0]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1287 irc_send(irc, buf);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1288 g_free(buf);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1289 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1290
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1291 void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1292 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1293 PurpleConversation *convo;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1294 PurpleConnection *gc;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1295 char **parts, *msg;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1296 time_t oldstamp;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1297
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1298 if (!args || !args[1])
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1299 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1300
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1301 parts = g_strsplit(args[1], " ", 2);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1302
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1303 if (!parts[0] || !parts[1]) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1304 g_strfreev(parts);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1305 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1306 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1307
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1308 if (sscanf(parts[1], "%lu", &oldstamp) != 1) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1309 msg = g_strdup(_("Error: invalid PONG from server"));
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1310 } else {
6350
22dfc953f2fb [gaim-migrate @ 6849]
Ethan Blanton <elb@pidgin.im>
parents: 6333
diff changeset
1311 msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1312 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1313
34625
03d62b1660fc Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents: 34622
diff changeset
1314 convo = purple_conversations_find_with_account(parts[0], irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1315 g_strfreev(parts);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1316 if (convo) {
34629
3c3bed0fd13c Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
1317 purple_conversation_write_message(convo, "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1318 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1319 gc = purple_account_get_connection(irc->account);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1320 if (!gc) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1321 g_free(msg);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1322 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1323 }
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1324 purple_notify_info(gc, NULL, "PONG", msg,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1325 purple_request_cpar_from_connection(gc));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1326 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1327 g_free(msg);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1328 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1329
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1330 void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1331 {
13525
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1332 if (!args || !args[0] || !args[1])
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1333 return;
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1334
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1335 irc_msg_handle_privmsg(irc, name, from, args[0], args[1], FALSE);
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1336 }
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1337
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1338 static void irc_msg_handle_privmsg(struct irc_conn *irc, const char *name, const char *from, const char *to, const char *rawmsg, gboolean notice)
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1339 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1340 PurpleConnection *gc = purple_account_get_connection(irc->account);
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1341 PurpleChatConversation *chat;
13525
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1342 char *tmp;
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1343 char *msg;
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1344 char *nick;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1345
13525
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1346 if (!gc)
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1347 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1348
13525
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1349 nick = irc_mask_nick(from);
e5dc8090a9b0 [gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents: 13523
diff changeset
1350 tmp = irc_parse_ctcp(irc, nick, to, rawmsg, notice);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1351 if (!tmp) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1352 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1353 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1354 }
8163
8f33bb0f433d [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
1355
20217
9249f67ef61e applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents: 20194
diff changeset
1356 msg = irc_escape_privmsg(tmp, -1);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1357 g_free(tmp);
8163
8f33bb0f433d [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
1358
8f33bb0f433d [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
1359 tmp = irc_mirc2html(msg);
8f33bb0f433d [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
1360 g_free(msg);
8f33bb0f433d [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
1361 msg = tmp;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1362 if (notice) {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1363 tmp = g_strdup_printf("(notice) %s", msg);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1364 g_free(msg);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1365 msg = tmp;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1366 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1367
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1368 if (!purple_utf8_strcasecmp(to, purple_connection_get_display_name(gc))) {
6982
12f08de92674 [gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents: 6753
diff changeset
1369 serv_got_im(gc, nick, msg, 0, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1370 } else {
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1371 chat = purple_conversations_find_chat_with_account(irc_nick_skip_mode(irc, to), irc->account);
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1372 if (chat)
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1373 serv_got_chat_in(gc, purple_chat_conversation_get_id(chat), nick, 0, msg, time(NULL));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1374 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1375 purple_debug_error("irc", "Got a %s on %s, which does not exist\n",
24763
67d9d4c975c0 Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24416
diff changeset
1376 notice ? "NOTICE" : "PRIVMSG", to);
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1377 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1378 g_free(msg);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1379 g_free(nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1380 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1381
6714
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1382 void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args)
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1383 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1384 PurpleConnection *gc = purple_account_get_connection(irc->account);
6714
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1385 char *msg;
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1386
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1387 if (!args || !args[1] || !args[2] || !gc)
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1388 return;
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1389
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34629
diff changeset
1390 if (purple_conversations_find_chat_with_account(args[1], irc->account)) {
17297
4541badae267 This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents: 17170
diff changeset
1391 /* This is a channel we're already in; for some reason,
4541badae267 This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents: 17170
diff changeset
1392 * freenode feels the need to notify us that in some
4541badae267 This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents: 17170
diff changeset
1393 * hypothetical other situation this might not have
4541badae267 This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents: 17170
diff changeset
1394 * succeeded. Suppress that. */
4541badae267 This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents: 17170
diff changeset
1395 return;
4541badae267 This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents: 17170
diff changeset
1396 }
4541badae267 This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents: 17170
diff changeset
1397
16993
536c1485c139 Handle channel joins when registration is required more gracefully.
Ethan Blanton <elb@pidgin.im>
parents: 16893
diff changeset
1398 msg = g_strdup_printf(_("Cannot join %s: Registration is required."), args[1]);
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1399 purple_notify_error(gc, _("Cannot join channel"), msg, args[2],
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1400 purple_request_cpar_from_connection(gc));
6714
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1401 g_free(msg);
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1402 }
414a52265486 [gaim-migrate @ 7240]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
1403
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1404 void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1405 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1406 PurpleConnection *gc = purple_account_get_connection(irc->account);
9238
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
1407 struct irc_buddy *ib;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1408 char *data[2];
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1409
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1410 if (!args || !args[0] || !gc)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1411 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1412
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1413 data[0] = irc_mask_nick(from);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1414 data[1] = args[0];
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1415 /* XXX this should have an API, I shouldn't grab this directly */
34750
826c1611ef90 Refactored protocols to use the initial GObject connection API.
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
1416 g_slist_foreach(purple_connection_get_active_chats(gc),
826c1611ef90 Refactored protocols to use the initial GObject connection API.
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
1417 (GFunc)irc_chat_remove_buddy, data);
9238
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
1418
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
1419 if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) {
31284
893f2d78d438 Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents: 31229
diff changeset
1420 ib->new_online_status = FALSE;
9238
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
1421 irc_buddy_status(data[0], ib, irc);
b7c5daf5748e [gaim-migrate @ 10036]
Tim Ringenbach <marv@pidgin.im>
parents: 9057
diff changeset
1422 }
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1423 g_free(data[0]);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1424
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1425 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1426 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1427
10712
2aded9e9abd4 [gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents: 10659
diff changeset
1428 void irc_msg_unavailable(struct irc_conn *irc, const char *name, const char *from, char **args)
2aded9e9abd4 [gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents: 10659
diff changeset
1429 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1430 PurpleConnection *gc = purple_account_get_connection(irc->account);
10712
2aded9e9abd4 [gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents: 10659
diff changeset
1431
2aded9e9abd4 [gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents: 10659
diff changeset
1432 if (!args || !args[1])
2aded9e9abd4 [gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents: 10659
diff changeset
1433 return;
2aded9e9abd4 [gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents: 10659
diff changeset
1434
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1435 purple_notify_error(gc, NULL, _("Nick or channel is temporarily "
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1436 "unavailable."), args[1],
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1437 purple_request_cpar_from_connection(gc));
10712
2aded9e9abd4 [gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents: 10659
diff changeset
1438 }
2aded9e9abd4 [gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents: 10659
diff changeset
1439
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1440 void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1441 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15516
diff changeset
1442 PurpleConnection *gc = purple_account_get_connection(irc->account);
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10751
diff changeset
1443 char *nick, *msg;
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1444
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1445 if (!args || !args[0] || !gc)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1446 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1447
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1448 nick = irc_mask_nick(from);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1449 msg = g_strdup_printf (_("Wallops from %s"), nick);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1450 g_free(nick);
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1451 purple_notify_info(gc, NULL, msg, args[0],
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34169
diff changeset
1452 purple_request_cpar_from_connection(gc));
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1453 g_free(msg);
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1454 }
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1455
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1456 #ifdef HAVE_CYRUS_SASL
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1457 static int
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1458 irc_sasl_cb_secret(sasl_conn_t *conn, void *ctx, int id, sasl_secret_t **secret)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1459 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1460 struct irc_conn *irc = ctx;
33407
8003b9b9e602 Fix a few warnings in the IRC SASL code
Daniel Atallah <datallah@pidgin.im>
parents: 33404
diff changeset
1461 sasl_secret_t *sasl_secret;
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1462 const char *pw;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1463 size_t len;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1464
34169
488d3280e151 Replace g_free with purple_str_wipe, correct line breaking
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34149
diff changeset
1465 pw = purple_connection_get_password(purple_account_get_connection(
488d3280e151 Replace g_free with purple_str_wipe, correct line breaking
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34149
diff changeset
1466 irc->account));
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1467
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1468 if (!conn || !secret || id != SASL_CB_PASS)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1469 return SASL_BADPARAM;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1470
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1471 len = strlen(pw);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1472 /* Not an off-by-one because sasl_secret_t defines char data[1] */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1473 /* TODO: This can probably be moved to glib's allocator */
33407
8003b9b9e602 Fix a few warnings in the IRC SASL code
Daniel Atallah <datallah@pidgin.im>
parents: 33404
diff changeset
1474 sasl_secret = malloc(sizeof(sasl_secret_t) + len);
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1475 if (!sasl_secret)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1476 return SASL_NOMEM;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1477
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1478 sasl_secret->len = len;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1479 strcpy((char*)sasl_secret->data, pw);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1480
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1481 *secret = sasl_secret;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1482 return SASL_OK;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1483 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1484
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1485 static int
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1486 irc_sasl_cb_log(void *context, int level, const char *message)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1487 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1488 if(level <= SASL_LOG_TRACE)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1489 purple_debug_info("sasl", "%s\n", message);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1490
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1491 return SASL_OK;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1492 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1493
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1494 static int
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1495 irc_sasl_cb_simple(void *ctx, int id, const char **res, unsigned *len)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1496 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1497 struct irc_conn *irc = ctx;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1498 PurpleConnection *gc = purple_account_get_connection(irc->account);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1499
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1500 switch(id) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1501 case SASL_CB_AUTHNAME:
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1502 *res = purple_connection_get_display_name(gc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1503 break;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1504 case SASL_CB_USER:
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1505 *res = "";
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1506 break;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1507 default:
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1508 return SASL_BADPARAM;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1509 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1510 if (len) *len = strlen((char *)*res);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1511 return SASL_OK;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1512 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1513
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1514 static void
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1515 irc_auth_start_cyrus(struct irc_conn *irc)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1516 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1517 int ret = 0;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1518 char *buf;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1519 sasl_security_properties_t secprops;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1520 PurpleAccount *account = irc->account;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1521 PurpleConnection *gc = purple_account_get_connection(account);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1522
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1523 gboolean plaintext;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1524 gboolean again = FALSE;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1525
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1526 /* Set up security properties and options */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1527 secprops.min_ssf = 0;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1528 secprops.security_flags = SASL_SEC_NOANONYMOUS;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1529
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1530 if (!irc->gsc) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1531 secprops.max_ssf = -1;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1532 secprops.maxbufsize = 4096;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1533 plaintext = purple_account_get_bool(account, "auth_plain_in_clear", FALSE);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1534 if (!plaintext)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1535 secprops.security_flags |= SASL_SEC_NOPLAINTEXT;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1536 } else {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1537 secprops.max_ssf = 0;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1538 secprops.maxbufsize = 0;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1539 plaintext = TRUE;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1540 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1541
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1542 secprops.property_names = 0;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1543 secprops.property_values = 0;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1544
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1545 do {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1546 gchar *tmp = NULL;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1547 again = FALSE;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1548
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1549 ret = sasl_client_new("irc", irc->server, NULL, NULL, irc->sasl_cb, 0, &irc->sasl_conn);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1550
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1551 if (ret != SASL_OK) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1552 purple_debug_error("irc", "sasl_client_new failed: %d\n", ret);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1553 tmp = g_strdup_printf(_("Failed to initialize SASL authentication: %s"),
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1554 sasl_errdetail(irc->sasl_conn));
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1555 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1556 PURPLE_CONNECTION_ERROR_OTHER_ERROR, tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1557 g_free(tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1558 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1559 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1560
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1561 sasl_setprop(irc->sasl_conn, SASL_AUTH_EXTERNAL, irc->account->username);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1562 sasl_setprop(irc->sasl_conn, SASL_SEC_PROPS, &secprops);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1563
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1564 ret = sasl_client_start(irc->sasl_conn, irc->sasl_mechs->str, NULL, NULL, NULL, &irc->current_mech);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1565
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1566 switch (ret) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1567 case SASL_OK:
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1568 case SASL_CONTINUE:
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1569 irc->mech_works = FALSE;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1570 break;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1571 case SASL_NOMECH:
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1572 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1573 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1574 _("SASL authentication failed: No worthy authentication mechanisms found."));
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1575
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1576 irc_sasl_finish(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1577 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1578 case SASL_BADPARAM:
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1579 case SASL_NOMEM:
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1580 tmp = g_strdup_printf(_("SASL authentication failed: %s"), sasl_errdetail(irc->sasl_conn));
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1581 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1582 PURPLE_CONNECTION_ERROR_OTHER_ERROR, tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1583 g_free(tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1584
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1585 irc_sasl_finish(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1586 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1587 default:
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1588 purple_debug_error("irc", "sasl_client_start failed: %s\n", sasl_errdetail(irc->sasl_conn));
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1589
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1590 if (irc->current_mech && *irc->current_mech) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1591 char *pos;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1592 if ((pos = strstr(irc->sasl_mechs->str, irc->current_mech))) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1593 size_t index = pos - irc->sasl_mechs->str;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1594 g_string_erase(irc->sasl_mechs, index, strlen(irc->current_mech));
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1595
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1596 /* Remove space which separated this mech from the next */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1597 if ((irc->sasl_mechs->str)[index] == ' ') {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1598 g_string_erase(irc->sasl_mechs, index, 1);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1599 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1600 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1601
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1602 again = TRUE;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1603 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1604 irc_sasl_finish(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1605 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1606 } while (again);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1607
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1608 purple_debug_info("irc", "Using SASL: %s\n", irc->current_mech);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1609
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1610 buf = irc_format(irc, "vv", "AUTHENTICATE", irc->current_mech);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1611 irc_send(irc, buf);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1612 g_free(buf);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1613 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1614
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1615 /* SASL authentication */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1616 void
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1617 irc_msg_cap(struct irc_conn *irc, const char *name, const char *from, char **args)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1618 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1619 int ret = 0;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1620 int id = 0;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1621 PurpleConnection *gc = purple_account_get_connection(irc->account);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1622 const char *mech_list = NULL;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1623
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1624 if (!args[1] || !args[2] || strncmp(args[2], "sasl ", 6))
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1625 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1626 if (strncmp(args[1], "ACK", 4)) {
33407
8003b9b9e602 Fix a few warnings in the IRC SASL code
Daniel Atallah <datallah@pidgin.im>
parents: 33404
diff changeset
1627 const char *tmp = _("SASL authentication failed: Server does not support SASL authentication.");
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1628 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1629 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1630
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1631 irc_sasl_finish(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1632 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1633 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1634
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1635 if ((ret = sasl_client_init(NULL)) != SASL_OK) {
33407
8003b9b9e602 Fix a few warnings in the IRC SASL code
Daniel Atallah <datallah@pidgin.im>
parents: 33404
diff changeset
1636 const char *tmp = _("SASL authentication failed: Initializing SASL failed.");
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1637 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1638 PURPLE_CONNECTION_ERROR_OTHER_ERROR, tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1639 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1640 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1641
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1642 irc->sasl_cb = g_new0(sasl_callback_t, 5);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1643
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1644 irc->sasl_cb[id].id = SASL_CB_AUTHNAME;
33891
8b4a41b6fe60 Fix warnings in irc, msn and mxit protocols
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33811
diff changeset
1645 irc->sasl_cb[id].proc = (int (*)(void))irc_sasl_cb_simple; /* sasl_getsimple_t */
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1646 irc->sasl_cb[id].context = (void *)irc;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1647 id++;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1648
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1649 irc->sasl_cb[id].id = SASL_CB_USER;
33891
8b4a41b6fe60 Fix warnings in irc, msn and mxit protocols
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33811
diff changeset
1650 irc->sasl_cb[id].proc = (int (*)(void))irc_sasl_cb_simple; /* sasl_getsimple_t */
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1651 irc->sasl_cb[id].context = (void *)irc;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1652 id++;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1653
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1654 irc->sasl_cb[id].id = SASL_CB_PASS;
33891
8b4a41b6fe60 Fix warnings in irc, msn and mxit protocols
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33811
diff changeset
1655 irc->sasl_cb[id].proc = (int (*)(void))irc_sasl_cb_secret; /* sasl_getsecret_t */
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1656 irc->sasl_cb[id].context = (void *)irc;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1657 id++;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1658
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1659 irc->sasl_cb[id].id = SASL_CB_LOG;
33891
8b4a41b6fe60 Fix warnings in irc, msn and mxit protocols
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33811
diff changeset
1660 irc->sasl_cb[id].proc = (int (*)(void))irc_sasl_cb_log; /* sasl_log_t */
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1661 irc->sasl_cb[id].context = (void *)irc;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1662 id++;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1663
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1664 irc->sasl_cb[id].id = SASL_CB_LIST_END;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1665
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1666 /* We need to do this to be able to list the mechanisms. */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1667 ret = sasl_client_new("irc", irc->server, NULL, NULL, irc->sasl_cb, 0, &irc->sasl_conn);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1668
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1669 sasl_listmech(irc->sasl_conn, NULL, "", " ", "", &mech_list, NULL, NULL);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1670 purple_debug_info("irc", "SASL: we have available: %s\n", mech_list);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1671
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1672 if (ret != SASL_OK) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1673 gchar *tmp;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1674
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1675 purple_debug_error("irc", "sasl_client_new failed: %d\n", ret);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1676 tmp = g_strdup_printf(_("Failed to initialize SASL authentication: %s"),
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1677 sasl_errdetail(irc->sasl_conn));
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1678 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1679 PURPLE_CONNECTION_ERROR_OTHER_ERROR, tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1680 g_free(tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1681
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1682 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1683 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1684
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1685 irc->sasl_mechs = g_string_new(mech_list);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1686
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1687 irc_auth_start_cyrus(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1688 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1689
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1690 void
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1691 irc_msg_auth(struct irc_conn *irc, char *arg)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1692 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1693 PurpleConnection *gc = purple_account_get_connection(irc->account);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1694 char *buf, *authinfo;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1695 char *serverin = NULL;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1696 unsigned serverinlen = 0;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1697 const gchar *c_out;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1698 unsigned int clen;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1699 int ret;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1700
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1701 irc->mech_works = TRUE;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1702
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1703 if (!arg)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1704 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1705
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1706 if (arg[0] != '+') {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1707 serverin = arg;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1708 serverinlen = strlen(serverin);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1709 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1710
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1711 ret = sasl_client_step(irc->sasl_conn, serverin, serverinlen,
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1712 NULL, &c_out, &clen);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1713
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1714 if (ret != SASL_OK && ret != SASL_CONTINUE) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1715
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1716 gchar *tmp = g_strdup_printf(_("SASL authentication failed: %s"),
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1717 sasl_errdetail(irc->sasl_conn));
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1718 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1719 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1720 g_free(tmp);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1721
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1722 irc_sasl_finish(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1723
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1724 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1725 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1726
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1727 authinfo = purple_base64_encode((const guchar*)c_out, clen);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1728
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1729 buf = irc_format(irc, "vv", "AUTHENTICATE", authinfo);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1730 irc_send(irc, buf);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1731 g_free(buf);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1732 g_free(authinfo);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1733 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1734
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1735 void
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1736 irc_msg_authok(struct irc_conn *irc, const char *name, const char *from, char **args)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1737 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1738 char *buf;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1739
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1740 sasl_dispose(&irc->sasl_conn);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1741 irc->sasl_conn = NULL;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1742 purple_debug_info("irc", "Succesfully authenticated using SASL.\n");
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1743
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1744 /* Finish auth session */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1745 buf = irc_format(irc, "vv", "CAP", "END");
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1746 irc_send(irc, buf);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1747 g_free(buf);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1748 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1749
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1750 void
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1751 irc_msg_authtryagain(struct irc_conn *irc, const char *name, const char *from, char **args)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1752 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1753 PurpleConnection *gc = purple_account_get_connection(irc->account);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1754
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1755 /* We already received at least one AUTHENTICATE reply from the
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1756 * server. This suggests it supports this mechanism, but the
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1757 * password was incorrect. It would be better to abort and inform
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1758 * the user than to try again with a different mechanism, so they
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1759 * aren't told the server supports no worthy mechanisms.
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1760 */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1761 if (irc->mech_works) {
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1762 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1763 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Incorrect Password"));
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1764
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1765 irc_sasl_finish(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1766
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1767 return;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1768 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1769
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1770 if (irc->current_mech) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1771 char *pos;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1772 if ((pos = strstr(irc->sasl_mechs->str, irc->current_mech))) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1773 size_t index = pos - irc->sasl_mechs->str;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1774 g_string_erase(irc->sasl_mechs, index, strlen(irc->current_mech));
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1775
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1776 /* Remove space which separated this mech from the next */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1777 if ((irc->sasl_mechs->str)[index] == ' ') {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1778 g_string_erase(irc->sasl_mechs, index, 1);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1779 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1780 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1781 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1782 if (*irc->sasl_mechs->str) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1783 sasl_dispose(&irc->sasl_conn);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1784
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1785 purple_debug_info("irc", "Now trying with %s\n", irc->sasl_mechs->str);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1786 irc_auth_start_cyrus(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1787 } else {
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1788 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1789 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1790 _("SASL authentication failed: No worthy mechanisms found"));
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1791
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1792 irc_sasl_finish(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1793 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1794 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1795
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1796 void
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1797 irc_msg_authfail(struct irc_conn *irc, const char *name, const char *from, char **args)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1798 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1799 PurpleConnection *gc = purple_account_get_connection(irc->account);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1800
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1801 /* Only show an error if we did not abort ourselves. */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1802 if (irc->sasl_conn) {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1803 purple_debug_info("irc", "SASL authentication failed: %s", sasl_errdetail(irc->sasl_conn));
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1804
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33760
diff changeset
1805 purple_connection_error (gc,
33404
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1806 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Incorrect Password"));
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1807 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1808
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1809 irc_sasl_finish(irc);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1810 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1811
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1812 static void
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1813 irc_sasl_finish(struct irc_conn *irc)
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1814 {
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1815 char *buf;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1816
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1817 sasl_dispose(&irc->sasl_conn);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1818 irc->sasl_conn = NULL;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1819
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1820 g_free(irc->sasl_cb);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1821 irc->sasl_cb = NULL;
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1822
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1823 /* Auth failed, abort */
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1824 buf = irc_format(irc, "vv", "CAP", "END");
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1825 irc_send(irc, buf);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1826 g_free(buf);
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1827 }
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1828 #endif
bbd52f93184e Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 32127
diff changeset
1829
6333
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1830 void irc_msg_ignore(struct irc_conn *irc, const char *name, const char *from, char **args)
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1831 {
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1832 return;
551f4a5b3c33 [gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
diff changeset
1833 }

mercurial