Wed, 06 Jul 2011 22:04:06 +0000
Fix debug message for IRC periodic WHO
| 6333 | 1 | /** |
| 2 | * @file msgs.c | |
|
13786
ec07d27800aa
[gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents:
13667
diff
changeset
|
3 | * |
| 15884 | 4 | * purple |
| 6333 | 5 | * |
| 6 | * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | |
|
13786
ec07d27800aa
[gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents:
13667
diff
changeset
|
7 | * |
| 6333 | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 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 | 21 | */ |
| 22 | ||
| 23 | #include "internal.h" | |
| 24 | ||
| 25 | #include "conversation.h" | |
| 26 | #include "blist.h" | |
| 27 | #include "notify.h" | |
| 28 | #include "util.h" | |
| 29 | #include "debug.h" | |
| 30 | #include "irc.h" | |
| 31 | ||
| 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 | 34 | |
| 35 | static char *irc_mask_nick(const char *mask); | |
| 36 | static char *irc_mask_userhost(const char *mask); | |
| 15884 | 37 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]); |
| 6333 | 38 | 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
|
39 | static void irc_connected(struct irc_conn *irc, const char *nick); |
| 6333 | 40 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
41 | 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
|
42 | const char *from, const char *to, |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
43 | const char *rawmsg, gboolean notice); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
44 | |
| 6333 | 45 | static char *irc_mask_nick(const char *mask) |
| 46 | { | |
| 47 | char *end, *buf; | |
| 48 | ||
| 49 | end = strchr(mask, '!'); | |
| 50 | if (!end) | |
| 51 | buf = g_strdup(mask); | |
| 52 | else | |
| 53 | buf = g_strndup(mask, end - mask); | |
| 54 | ||
| 55 | return buf; | |
| 56 | } | |
| 57 | ||
| 58 | static char *irc_mask_userhost(const char *mask) | |
| 59 | { | |
| 60 | return g_strdup(strchr(mask, '!') + 1); | |
| 61 | } | |
| 62 | ||
| 15884 | 63 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]) |
| 6333 | 64 | { |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
65 | char *message, *stripped; |
|
10730
cc7807276e53
[gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10712
diff
changeset
|
66 | |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
67 | 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
|
68 | 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
|
69 | g_free(stripped); |
| 6333 | 70 | |
| 15884 | 71 | if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(convo), data[0])) |
| 72 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), data[0], message); | |
| 6333 | 73 | |
| 74 | g_free(message); | |
| 75 | } | |
| 76 | ||
|
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
|
77 | 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
|
78 | { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
79 | PurpleConnection *gc; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
80 | PurpleStatus *status; |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
81 | GSList *buddies; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23582
diff
changeset
|
82 | 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
|
83 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
84 | 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
|
85 | || 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
|
86 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
87 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
88 | purple_connection_set_display_name(gc, nick); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
89 | purple_connection_set_state(gc, PURPLE_CONNECTED); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23582
diff
changeset
|
90 | 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
|
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 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
|
93 | status = purple_account_get_active_status(irc->account); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
94 | if (!purple_status_get_type(status) != PURPLE_STATUS_AVAILABLE) { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
95 | PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
96 | prpl_info->set_status(irc->account, status); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
97 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
98 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
99 | /* this used to be in the core, but it's not now */ |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
100 | for (buddies = purple_find_buddies(account, NULL); buddies; |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
101 | 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
|
102 | { |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
103 | PurpleBuddy *b = buddies->data; |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
104 | 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
|
105 | 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
|
106 | ib->ref = 1; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27361
diff
changeset
|
107 | 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
|
108 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
109 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
110 | 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
|
111 | if (!irc->timer) |
|
25716
1b5be208d5ba
applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents:
25707
diff
changeset
|
112 | irc->timer = purple_timeout_add_seconds(45, (GSourceFunc)irc_blist_timeout, (gpointer)irc); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
113 | if (!irc->who_channel_timer) |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
114 | irc->who_channel_timer = purple_timeout_add_seconds(300, (GSourceFunc)irc_who_channel_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
|
115 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
116 | |
| 6333 | 117 | void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 118 | { | |
|
23168
2928661d7518
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23118
diff
changeset
|
119 | char *clean; |
|
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
|
120 | /* This, too, should be escaped somehow (smarter) */ |
|
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
|
121 | clean = purple_utf8_salvage(args[0]); |
|
23168
2928661d7518
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23118
diff
changeset
|
122 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", clean); |
|
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
|
123 | g_free(clean); |
| 6333 | 124 | } |
| 125 | ||
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
126 | 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
|
127 | { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
128 | gchar **features; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
129 | int i; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
130 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
131 | 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
|
132 | return; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
133 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
134 | 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
|
135 | 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
|
136 | char *val; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
137 | 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
|
138 | 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
|
139 | 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
|
140 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
141 | } |
|
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
|
142 | |
|
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
|
143 | 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
|
144 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
145 | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
146 | 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
|
147 | { |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
148 | 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
|
149 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
150 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
151 | 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
|
152 | /* 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
|
153 | * 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
|
154 | 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
|
155 | /* 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
|
156 | * 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
|
157 | /* } 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
|
158 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
159 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
160 | |
| 6333 | 161 | void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 162 | { | |
| 15884 | 163 | PurpleConnection *gc; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
164 | char *msg; |
| 6333 | 165 | |
| 166 | if (!args || !args[1]) | |
| 167 | return; | |
| 168 | ||
| 15884 | 169 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 170 | /* We're doing a whois, show this in the whois dialog */ |
| 171 | irc_msg_whois(irc, name, from, args); | |
| 172 | return; | |
| 173 | } | |
| 174 | ||
| 15884 | 175 | gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
176 | if (gc) { |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
177 | msg = g_markup_escape_text(args[2], -1); |
| 15884 | 178 | 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
|
179 | g_free(msg); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
180 | } |
| 6333 | 181 | } |
| 182 | ||
| 183 | void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 184 | { | |
| 15884 | 185 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 186 | |
| 187 | if (!args || !args[1] || !gc) | |
| 188 | return; | |
| 189 | ||
| 15884 | 190 | purple_notify_error(gc, NULL, _("Bad mode"), args[1]); |
| 6333 | 191 | } |
| 192 | ||
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
193 | 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
|
194 | { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
195 | PurpleConversation *convo; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
196 | |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
197 | 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
|
198 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
199 | |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
200 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
201 | args[1], irc->account); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
202 | |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
203 | 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
|
204 | 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
|
205 | /* 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
|
206 | 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
|
207 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
208 | 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
|
209 | /* 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
|
210 | 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
|
211 | time_t t2 = time(NULL); |
| 24416 | 212 | 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
|
213 | msg = g_strdup_printf(_("Ban on %s by %s, set %s ago"), |
| 24416 | 214 | args[2], args[3], time); |
| 215 | 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
|
216 | } else { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
217 | 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
|
218 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
219 | if (convo) { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
220 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
221 | 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
|
222 | time(NULL)); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
223 | } else { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
224 | 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
|
225 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
226 | 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
|
227 | } else if (!strcmp(name, "368")) { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
228 | if (!convo) |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
229 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
230 | /* 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
|
231 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
232 | _("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
|
233 | 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
|
234 | time(NULL)); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
235 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
236 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
237 | |
| 6333 | 238 | void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 239 | { | |
| 15884 | 240 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 241 | char *buf; |
| 242 | ||
| 243 | if (!args || !args[1] || !gc) | |
| 244 | return; | |
| 245 | ||
| 246 | buf = g_strdup_printf(_("You are banned from %s."), args[1]); | |
| 15884 | 247 | purple_notify_error(gc, _("Banned"), _("Banned"), buf); |
| 6333 | 248 | g_free(buf); |
| 249 | } | |
| 250 | ||
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
251 | 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
|
252 | { |
| 15884 | 253 | PurpleConversation *convo; |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
254 | char *buf, *nick; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
255 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
256 | if (!args || !args[0] || !args[1] || !args[2]) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
257 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
258 | |
| 15884 | 259 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
260 | if (!convo) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
261 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
262 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
263 | nick = g_markup_escape_text(args[2], -1); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
264 | buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
265 | g_free(nick); |
| 15884 | 266 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, |
| 267 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, | |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
268 | time(NULL)); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
269 | g_free(buf); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
270 | } |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
271 | |
| 6333 | 272 | void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 273 | { | |
| 15884 | 274 | PurpleConversation *convo; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
275 | char *buf, *escaped; |
| 6333 | 276 | |
| 277 | if (!args || !args[1] || !args[2]) | |
| 278 | return; | |
| 279 | ||
| 15884 | 280 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 281 | if (!convo) /* XXX punt on channels we are not in for now */ |
| 282 | return; | |
| 283 | ||
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
284 | 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
|
285 | buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : ""); |
| 15884 | 286 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
287 | g_free(escaped); |
| 6333 | 288 | g_free(buf); |
| 289 | ||
| 290 | return; | |
| 291 | } | |
| 292 | ||
| 293 | void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 294 | { | |
| 295 | if (!irc->whois.nick) { | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
296 | 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
|
297 | , args[1]); |
| 6333 | 298 | return; |
| 299 | } | |
| 300 | ||
| 15884 | 301 | 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
|
302 | 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
|
303 | , args[1], irc->whois.nick); |
| 6333 | 304 | return; |
| 305 | } | |
| 306 | ||
| 307 | if (!strcmp(name, "301")) { | |
| 308 | irc->whois.away = g_strdup(args[2]); | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
309 | } else if (!strcmp(name, "311") || !strcmp(name, "314")) { |
| 6333 | 310 | irc->whois.userhost = g_strdup_printf("%s@%s", args[2], args[3]); |
| 311 | irc->whois.name = g_strdup(args[5]); | |
| 312 | } else if (!strcmp(name, "312")) { | |
| 313 | irc->whois.server = g_strdup(args[2]); | |
| 314 | irc->whois.serverinfo = g_strdup(args[3]); | |
| 315 | } else if (!strcmp(name, "313")) { | |
| 316 | irc->whois.ircop = 1; | |
| 317 | } else if (!strcmp(name, "317")) { | |
| 318 | irc->whois.idle = atoi(args[2]); | |
| 319 | if (args[3]) | |
| 320 | irc->whois.signon = (time_t)atoi(args[3]); | |
| 321 | } else if (!strcmp(name, "319")) { | |
|
25703
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
322 | if (irc->whois.channels == NULL) { |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
323 | irc->whois.channels = g_string_new(args[2]); |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
324 | } else { |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
325 | 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
|
326 | } |
| 6333 | 327 | } else if (!strcmp(name, "320")) { |
| 328 | irc->whois.identified = 1; | |
| 329 | } | |
| 330 | } | |
| 331 | ||
| 332 | void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 333 | { | |
| 15884 | 334 | PurpleConnection *gc; |
|
15215
3b4c0490b8b0
[gaim-migrate @ 17939]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
335 | char *tmp, *tmp2; |
| 15884 | 336 | PurpleNotifyUserInfo *user_info; |
| 6333 | 337 | |
| 338 | if (!irc->whois.nick) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
339 | 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
|
340 | , args[1]); |
| 6333 | 341 | return; |
| 342 | } | |
| 15884 | 343 | if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
344 | 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
|
345 | , args[1], irc->whois.nick); |
| 6333 | 346 | return; |
| 347 | } | |
| 348 | ||
| 15884 | 349 | user_info = purple_notify_user_info_new(); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
350 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
351 | tmp2 = g_markup_escape_text(args[1], -1); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
352 | tmp = g_strdup_printf("%s%s%s", tmp2, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
353 | (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""), |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
354 | (irc->whois.identified ? _(" <i>(identified)</i>") : "")); |
| 15884 | 355 | purple_notify_user_info_add_pair(user_info, _("Nick"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
356 | g_free(tmp2); |
| 10634 | 357 | g_free(tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
358 | |
| 6333 | 359 | if (irc->whois.away) { |
| 10634 | 360 | tmp = g_markup_escape_text(irc->whois.away, strlen(irc->whois.away)); |
| 6333 | 361 | g_free(irc->whois.away); |
| 15884 | 362 | purple_notify_user_info_add_pair(user_info, _("Away"), tmp); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
363 | g_free(tmp); |
| 6333 | 364 | } |
| 365 | if (irc->whois.userhost) { | |
| 10634 | 366 | tmp = g_markup_escape_text(irc->whois.name, strlen(irc->whois.name)); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
367 | g_free(irc->whois.name); |
| 15884 | 368 | purple_notify_user_info_add_pair(user_info, _("Username"), irc->whois.userhost); |
| 369 | purple_notify_user_info_add_pair(user_info, _("Real name"), tmp); | |
| 6333 | 370 | g_free(irc->whois.userhost); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
371 | g_free(tmp); |
| 6333 | 372 | } |
| 373 | if (irc->whois.server) { | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
374 | tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo); |
| 15884 | 375 | purple_notify_user_info_add_pair(user_info, _("Server"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
376 | g_free(tmp); |
| 6333 | 377 | g_free(irc->whois.server); |
| 378 | g_free(irc->whois.serverinfo); | |
| 379 | } | |
| 380 | if (irc->whois.channels) { | |
|
25703
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
381 | purple_notify_user_info_add_pair(user_info, _("Currently on"), irc->whois.channels->str); |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
382 | g_string_free(irc->whois.channels, TRUE); |
| 6333 | 383 | } |
| 384 | if (irc->whois.idle) { | |
| 15884 | 385 | gchar *timex = purple_str_seconds_to_string(irc->whois.idle); |
| 386 | purple_notify_user_info_add_pair(user_info, _("Idle for"), timex); | |
|
6357
f83643b0a067
[gaim-migrate @ 6856]
Mark Doliner <markdoliner@pidgin.im>
parents:
6351
diff
changeset
|
387 | g_free(timex); |
| 15884 | 388 | purple_notify_user_info_add_pair(user_info, |
| 389 | _("Online since"), purple_date_format_full(localtime(&irc->whois.signon))); | |
| 6333 | 390 | } |
| 391 | if (!strcmp(irc->whois.nick, "Paco-Paco")) { | |
| 15884 | 392 | purple_notify_user_info_add_pair(user_info, |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
393 | _("<b>Defining adjective:</b>"), _("Glorious")); |
| 6333 | 394 | } |
| 395 | ||
| 15884 | 396 | gc = purple_account_get_connection(irc->account); |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
397 | |
| 15884 | 398 | purple_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL); |
| 399 | purple_notify_user_info_destroy(user_info); | |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
400 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
401 | g_free(irc->whois.nick); |
| 6333 | 402 | memset(&irc->whois, 0, sizeof(irc->whois)); |
| 403 | } | |
| 404 | ||
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
405 | 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
|
406 | { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
407 | if (!strcmp(name, "352")) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
408 | PurpleConversation *conv; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
409 | PurpleConvChat *chat; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
410 | PurpleConvChatBuddy *cb; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
411 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
412 | char *userhost, *realname; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
413 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
414 | PurpleConvChatBuddyFlags flags; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
415 | GList *keys = NULL, *values = NULL; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
416 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
417 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
418 | if (!conv) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
419 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a WHO response for %s, which doesn't exist\n", args[1]); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
420 | return; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
421 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
422 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
423 | cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), args[5]); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
424 | if (!cb) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
425 | 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
|
426 | return; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
427 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
428 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
429 | chat = PURPLE_CONV_CHAT(conv); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
430 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
431 | userhost = g_strdup_printf("%s@%s", args[2], args[3]); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
432 | realname = g_strdup(args[8]); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
433 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
434 | keys = g_list_prepend(keys, "userhost"); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
435 | values = g_list_prepend(values, userhost); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
436 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
437 | keys = g_list_prepend(keys, "realname"); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
438 | values = g_list_prepend(values, realname); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
439 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
440 | purple_conv_chat_cb_set_attributes(chat, cb, keys, values); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
441 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
442 | g_list_free(keys); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
443 | g_list_free(values); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
444 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
445 | g_free(userhost); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
446 | g_free(realname); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
447 | |
|
31936
ca4f3c0aa125
irc: Save one useless hash table lookup
Paul Aurich <darkrain42@pidgin.im>
parents:
31565
diff
changeset
|
448 | flags = cb->flags; |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
449 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
450 | if (args[6][0] == 'G' && !(flags & PURPLE_CBFLAGS_AWAY)) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
451 | purple_conv_chat_user_set_flags(chat, cb->name, flags | PURPLE_CBFLAGS_AWAY); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
452 | } else if(args[6][0] == 'H' && (flags & PURPLE_CBFLAGS_AWAY)) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
453 | purple_conv_chat_user_set_flags(chat, cb->name, flags & ~PURPLE_CBFLAGS_AWAY); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
454 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
455 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
456 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
457 | |
| 8114 | 458 | void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 459 | { | |
| 460 | if (!irc->roomlist) | |
| 461 | return; | |
| 462 | ||
| 463 | if (!strcmp(name, "321")) { | |
| 15884 | 464 | purple_roomlist_set_in_progress(irc->roomlist, TRUE); |
| 8114 | 465 | return; |
| 466 | } | |
| 467 | ||
| 468 | if (!strcmp(name, "323")) { | |
| 15884 | 469 | purple_roomlist_set_in_progress(irc->roomlist, FALSE); |
| 470 | purple_roomlist_unref(irc->roomlist); | |
| 8114 | 471 | irc->roomlist = NULL; |
|
13667
9ebf0007d912
[gaim-migrate @ 16068]
Richard Laager <rlaager@pidgin.im>
parents:
13647
diff
changeset
|
472 | return; |
| 8114 | 473 | } |
| 474 | ||
| 475 | if (!strcmp(name, "322")) { | |
| 15884 | 476 | PurpleRoomlistRoom *room; |
|
17409
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17297
diff
changeset
|
477 | char *topic; |
| 8114 | 478 | |
| 479 | if (!args[0] || !args[1] || !args[2] || !args[3]) | |
| 480 | return; | |
| 481 | ||
|
22994
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
482 | 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
|
483 | 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
|
484 | 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
|
485 | } |
|
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
486 | |
| 15884 | 487 | room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL); |
| 488 | purple_roomlist_room_add_field(irc->roomlist, room, args[1]); | |
| 489 | 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
|
490 | 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
|
491 | 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
|
492 | g_free(topic); |
| 15884 | 493 | purple_roomlist_room_add(irc->roomlist, room); |
| 8114 | 494 | } |
| 495 | } | |
| 496 | ||
| 6333 | 497 | void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 498 | { | |
| 9762 | 499 | char *chan, *topic, *msg, *nick, *tmp, *tmp2; |
| 15884 | 500 | PurpleConversation *convo; |
| 6333 | 501 | |
| 502 | 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
|
503 | 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
|
504 | return; |
| 6333 | 505 | chan = args[0]; |
| 8529 | 506 | topic = irc_mirc2txt (args[1]); |
| 6333 | 507 | } else { |
|
28465
615584769b59
Fix parsing of invalid IRC TOPIC messages which contain no actual topic
Ethan Blanton <elb@pidgin.im>
parents:
28118
diff
changeset
|
508 | 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
|
509 | return; |
| 6333 | 510 | chan = args[1]; |
| 8529 | 511 | topic = irc_mirc2txt (args[2]); |
| 6333 | 512 | } |
| 513 | ||
| 15884 | 514 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, chan, irc->account); |
|
13647
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
515 | if (!convo) { |
| 15884 | 516 | 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
|
517 | g_free(topic); |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
518 | return; |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
519 | } |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
520 | |
| 6333 | 521 | /* If this is an interactive update, print it out */ |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
522 | tmp = g_markup_escape_text(topic, -1); |
| 15884 | 523 | tmp2 = purple_markup_linkify(tmp); |
| 9762 | 524 | g_free(tmp); |
| 6333 | 525 | if (!strcmp(name, "topic")) { |
| 15884 | 526 | const char *current_topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(convo)); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
527 | if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0)) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
528 | { |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
529 | char *nick_esc; |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
530 | nick = irc_mask_nick(from); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
531 | nick_esc = g_markup_escape_text(nick, -1); |
| 15884 | 532 | purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), nick, topic); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
533 | if (*tmp2) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
534 | 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
|
535 | else |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
536 | msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
537 | g_free(nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
538 | g_free(nick); |
| 15884 | 539 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), from, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
540 | g_free(msg); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
541 | } |
| 6333 | 542 | } else { |
|
13395
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
543 | char *chan_esc = g_markup_escape_text(chan, -1); |
|
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
544 | 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
|
545 | g_free(chan_esc); |
| 15884 | 546 | purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic); |
| 547 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
| 6333 | 548 | g_free(msg); |
| 549 | } | |
| 9762 | 550 | g_free(tmp2); |
| 8529 | 551 | g_free(topic); |
| 6333 | 552 | } |
| 553 | ||
| 554 | void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 555 | { | |
| 15884 | 556 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 557 | char *buf; |
| 558 | ||
| 559 | if (!args || !args[1] || !gc) | |
| 560 | return; | |
| 561 | ||
| 562 | buf = g_strdup_printf(_("Unknown message '%s'"), args[1]); | |
| 15884 | 563 | purple_notify_error(gc, _("Unknown message"), buf, _("The IRC server received a message it did not understand.")); |
| 6333 | 564 | g_free(buf); |
| 565 | } | |
| 566 | ||
| 567 | void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 568 | { | |
| 569 | char *names, *cur, *end, *tmp, *msg; | |
| 15884 | 570 | PurpleConversation *convo; |
| 6333 | 571 | |
| 572 | if (!strcmp(name, "366")) { | |
| 15884 | 573 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 574 | if (!convo) { |
| 15884 | 575 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]); |
| 6333 | 576 | g_string_free(irc->names, TRUE); |
| 577 | irc->names = NULL; | |
| 578 | return; | |
| 579 | } | |
| 580 | ||
| 581 | names = cur = g_string_free(irc->names, FALSE); | |
| 582 | irc->names = NULL; | |
| 15884 | 583 | if (purple_conversation_get_data(convo, IRC_NAMES_FLAG)) { |
|
11026
1f13c483db00
[gaim-migrate @ 12901]
Daniel Atallah <datallah@pidgin.im>
parents:
10816
diff
changeset
|
584 | msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : ""); |
| 15884 | 585 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) |
| 586 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 587 | else |
| 15884 | 588 | purple_conv_im_write(PURPLE_CONV_IM(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 589 | g_free(msg); |
| 590 | } else { | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
591 | GList *users = NULL; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
592 | GList *flags = NULL; |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
593 | |
| 6333 | 594 | while (*cur) { |
| 15884 | 595 | PurpleConvChatBuddyFlags f = PURPLE_CBFLAGS_NONE; |
| 6333 | 596 | end = strchr(cur, ' '); |
| 597 | if (!end) | |
| 598 | end = cur + strlen(cur); | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
599 | if (*cur == '@') { |
| 15884 | 600 | f = PURPLE_CBFLAGS_OP; |
| 6333 | 601 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
602 | } else if (*cur == '%') { |
| 15884 | 603 | f = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
604 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
605 | } else if(*cur == '+') { |
| 15884 | 606 | f = PURPLE_CBFLAGS_VOICE; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
607 | cur++; |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
608 | } 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
|
609 | && 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
|
610 | if (*cur == '~') |
|
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
611 | f = PURPLE_CBFLAGS_FOUNDER; |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
612 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
613 | } |
| 6333 | 614 | tmp = g_strndup(cur, end - cur); |
|
11869
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
615 | users = g_list_prepend(users, tmp); |
|
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
616 | flags = g_list_prepend(flags, GINT_TO_POINTER(f)); |
| 6333 | 617 | cur = end; |
| 618 | if (*cur) | |
| 619 | cur++; | |
| 620 | } | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
621 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
622 | if (users != NULL) { |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
623 | GList *l; |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
624 | |
| 15884 | 625 | purple_conv_chat_add_users(PURPLE_CONV_CHAT(convo), users, NULL, flags, FALSE); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
626 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
627 | for (l = users; l != NULL; l = l->next) |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
628 | g_free(l->data); |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
629 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
630 | g_list_free(users); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
631 | g_list_free(flags); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
632 | } |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
633 | |
| 15884 | 634 | purple_conversation_set_data(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
|
635 | GINT_TO_POINTER(TRUE)); |
| 6333 | 636 | } |
| 637 | g_free(names); | |
| 638 | } else { | |
| 639 | if (!irc->names) | |
| 640 | irc->names = g_string_new(""); | |
| 641 | ||
| 15313 | 642 | if (irc->names->len && irc->names->str[irc->names->len - 1] != ' ') |
| 643 | irc->names = g_string_append_c(irc->names, ' '); | |
| 6333 | 644 | irc->names = g_string_append(irc->names, args[3]); |
| 645 | } | |
| 646 | } | |
| 647 | ||
| 648 | void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 649 | { | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
650 | char *escaped; |
| 6333 | 651 | |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
652 | 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
|
653 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
654 | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
655 | 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
|
656 | 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
|
657 | 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
|
658 | 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
|
659 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
660 | } 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
|
661 | /* 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
|
662 | * 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
|
663 | 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
|
664 | return; |
|
31229
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
665 | } 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
|
666 | /* 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
|
667 | * (and clear the motd for good measure). */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
668 | |
|
31229
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
669 | 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
|
670 | g_string_free(irc->motd, TRUE); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
671 | |
|
31229
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
672 | 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
|
673 | 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
|
674 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
675 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
676 | if (!irc->motd) { |
| 15884 | 677 | 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
|
678 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
679 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
680 | |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
681 | 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
|
682 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
683 | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
684 | escaped = g_markup_escape_text(args[1], -1); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
685 | g_string_append_printf(irc->motd, "%s<br>", escaped); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
686 | g_free(escaped); |
| 6333 | 687 | } |
| 688 | ||
| 10564 | 689 | void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 690 | { | |
| 15884 | 691 | PurpleConnection *gc; |
| 10564 | 692 | |
| 15884 | 693 | gc = purple_account_get_connection(irc->account); |
| 10564 | 694 | if (gc == NULL || args == NULL || args[2] == NULL) |
| 695 | return; | |
| 696 | ||
| 15884 | 697 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"), |
| 10564 | 698 | _("The IRC server's local time is:"), |
| 699 | args[2], NULL, NULL); | |
| 700 | } | |
| 701 | ||
| 7877 | 702 | void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 703 | { | |
| 15884 | 704 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 7877 | 705 | |
| 706 | if (gc == NULL || args == NULL || args[1] == NULL) | |
| 707 | return; | |
| 708 | ||
| 15884 | 709 | purple_notify_error(gc, NULL, _("No such channel"), args[1]); |
| 7877 | 710 | } |
| 711 | ||
| 6333 | 712 | void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 713 | { | |
| 15884 | 714 | PurpleConnection *gc; |
| 715 | PurpleConversation *convo; | |
| 6333 | 716 | |
| 15884 | 717 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 718 | if (convo) { |
| 15884 | 719 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) /* does this happen? */ |
| 720 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], _("no such channel"), | |
| 721 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 722 | else |
| 15884 | 723 | purple_conv_im_write(PURPLE_CONV_IM(convo), args[1], _("User is not logged in"), |
| 724 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 725 | } else { |
| 15884 | 726 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 727 | return; |
| 15884 | 728 | purple_notify_error(gc, NULL, _("No such nick or channel"), args[1]); |
| 6333 | 729 | } |
| 730 | ||
| 15884 | 731 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 732 | g_free(irc->whois.nick); |
| 733 | irc->whois.nick = NULL; | |
| 734 | } | |
| 735 | } | |
| 736 | ||
| 737 | void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 738 | { | |
| 15884 | 739 | PurpleConnection *gc; |
| 740 | PurpleConversation *convo; | |
| 6333 | 741 | |
| 15884 | 742 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 743 | if (convo) { |
| 15884 | 744 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 745 | } else { |
| 15884 | 746 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 747 | return; |
| 15884 | 748 | purple_notify_error(gc, NULL, _("Could not send"), args[2]); |
| 6333 | 749 | } |
| 750 | } | |
| 751 | ||
| 752 | void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 753 | { | |
| 15884 | 754 | PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 755 | |
| 15884 | 756 | purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); |
| 6333 | 757 | if (convo) { |
| 758 | /*g_slist_remove(irc->gc->buddy_chats, convo); | |
| 15884 | 759 | purple_conversation_set_account(convo, NULL);*/ |
| 760 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 761 | } |
| 762 | } | |
| 763 | ||
| 764 | void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 765 | { | |
| 15884 | 766 | PurpleConversation *convo; |
| 6333 | 767 | |
| 768 | if (!args || !args[1] || !args[2]) | |
| 769 | return; | |
| 770 | ||
| 15884 | 771 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 772 | if (!convo) |
| 773 | return; | |
| 774 | ||
| 15884 | 775 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", args[2], PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 776 | } |
| 777 | ||
| 778 | void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 779 | { | |
| 15884 | 780 | 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
|
781 | GHashTable *components; |
|
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
782 | gchar *nick; |
| 6333 | 783 | |
|
22876
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
784 | if (!args || !args[1] || !gc) |
| 6333 | 785 | return; |
|
22876
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
786 | |
|
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
787 | 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
|
788 | nick = irc_mask_nick(from); |
| 6333 | 789 | |
|
22870
25b482330fec
Use g_strdup to match the subsequent g_free.
Daniel Atallah <datallah@pidgin.im>
parents:
22798
diff
changeset
|
790 | g_hash_table_insert(components, g_strdup("channel"), g_strdup(args[1])); |
| 6333 | 791 | |
| 792 | serv_got_chat_invite(gc, args[1], nick, NULL, components); | |
| 793 | g_free(nick); | |
| 794 | } | |
| 795 | ||
| 796 | void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 797 | { | |
| 15884 | 798 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 799 | char *buf; |
| 800 | ||
| 801 | if (!args || !args[1] || !gc) | |
| 802 | return; | |
| 803 | ||
| 804 | buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]); | |
| 15884 | 805 | purple_notify_error(gc, _("Invitation only"), _("Invitation only"), buf); |
| 6333 | 806 | g_free(buf); |
| 807 | } | |
| 808 | ||
| 809 | void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 810 | { | |
| 811 | char **nicks; | |
| 812 | struct irc_buddy *ib; | |
| 813 | int i; | |
| 814 | ||
| 815 | if (!args || !args[1]) | |
| 816 | return; | |
| 817 | ||
| 818 | nicks = g_strsplit(args[1], " ", -1); | |
| 819 | for (i = 0; nicks[i]; i++) { | |
| 820 | if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) { | |
| 821 | continue; | |
| 822 | } | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
823 | ib->new_online_status = TRUE; |
| 6333 | 824 | } |
| 6350 | 825 | g_strfreev(nicks); |
| 826 | ||
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
827 | if (irc->ison_outstanding) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
828 | irc_buddy_query(irc); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
829 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
830 | if (!irc->ison_outstanding) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
831 | g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc); |
| 6333 | 832 | } |
| 833 | ||
| 834 | static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc) | |
| 835 | { | |
| 15884 | 836 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 837 | PurpleBuddy *buddy = purple_find_buddy(irc->account, name); | |
| 6333 | 838 | |
| 839 | if (!gc || !buddy) | |
| 840 | return; | |
| 841 | ||
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
842 | if (ib->online && !ib->new_online_status) { |
| 15884 | 843 | purple_prpl_got_user_status(irc->account, name, "offline", NULL); |
| 6333 | 844 | ib->online = FALSE; |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
845 | } else if (!ib->online && ib->new_online_status) { |
| 15884 | 846 | purple_prpl_got_user_status(irc->account, name, "available", NULL); |
| 6333 | 847 | ib->online = TRUE; |
| 848 | } | |
| 849 | } | |
| 850 | ||
| 851 | void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 852 | { | |
| 15884 | 853 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 854 | PurpleConversation *convo; | |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
855 | PurpleConvChat *chat; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
856 | PurpleConvChatBuddy *cb; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
857 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
858 | char *nick = irc_mask_nick(from), *userhost, *buf; |
| 9238 | 859 | struct irc_buddy *ib; |
| 6333 | 860 | static int id = 1; |
| 861 | ||
| 862 | if (!gc) { | |
| 863 | g_free(nick); | |
| 864 | return; | |
| 865 | } | |
| 866 | ||
| 15884 | 867 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 6333 | 868 | /* We are joining a channel for the first time */ |
| 869 | serv_got_joined_chat(gc, id++, args[0]); | |
| 870 | g_free(nick); | |
| 15884 | 871 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
| 13938 | 872 | args[0], |
| 873 | irc->account); | |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
874 | |
| 13938 | 875 | if (convo == NULL) { |
| 15884 | 876 | purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]); |
| 13938 | 877 | return; |
| 878 | } | |
| 15884 | 879 | purple_conversation_set_data(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
|
880 | GINT_TO_POINTER(FALSE)); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
881 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
882 | // 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
|
883 | 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
|
884 | irc_send(irc, buf); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
885 | g_free(buf); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
886 | |
|
20194
fee478bb059b
applied changes from 26c05ed157a02643cbb12b04045422b123312bcf
Ethan Blanton <elb@pidgin.im>
parents:
19859
diff
changeset
|
887 | /* 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
|
888 | * 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
|
889 | * behavior both for the /join and auto-join cases. */ |
|
20194
fee478bb059b
applied changes from 26c05ed157a02643cbb12b04045422b123312bcf
Ethan Blanton <elb@pidgin.im>
parents:
19859
diff
changeset
|
890 | /* purple_conversation_present(convo); */ |
| 6333 | 891 | return; |
| 892 | } | |
| 893 | ||
| 15884 | 894 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 895 | if (convo == NULL) { |
| 15884 | 896 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); |
| 6333 | 897 | g_free(nick); |
| 898 | return; | |
| 899 | } | |
| 900 | ||
| 901 | userhost = irc_mask_userhost(from); | |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
902 | chat = PURPLE_CONV_CHAT(convo); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
903 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
904 | purple_conv_chat_add_user(chat, nick, userhost, PURPLE_CBFLAGS_NONE, TRUE); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
905 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
906 | cb = purple_conv_chat_cb_find(chat, nick); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
907 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
908 | if (cb) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
909 | purple_conv_chat_cb_set_attribute(chat, cb, "userhost", userhost); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
910 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
911 | |
| 9238 | 912 | 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
|
913 | ib->new_online_status = TRUE; |
| 9238 | 914 | irc_buddy_status(nick, ib, irc); |
| 915 | } | |
| 916 | ||
| 6333 | 917 | g_free(userhost); |
| 918 | g_free(nick); | |
| 919 | } | |
| 920 | ||
| 921 | void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 922 | { | |
| 15884 | 923 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 924 | PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
925 | char *nick = irc_mask_nick(from), *buf; |
| 6333 | 926 | |
| 927 | if (!gc) { | |
| 928 | g_free(nick); | |
| 929 | return; | |
| 930 | } | |
| 931 | ||
| 932 | if (!convo) { | |
|
30270
8380aae8b132
I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29286
diff
changeset
|
933 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Received a KICK for unknown channel %s\n", args[0]); |
| 6333 | 934 | g_free(nick); |
| 935 | return; | |
| 936 | } | |
| 937 | ||
| 15884 | 938 | 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
|
939 | buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]); |
| 15884 | 940 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 941 | g_free(buf); |
| 15884 | 942 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 943 | } else { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
944 | buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]); |
| 15884 | 945 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), args[1], buf); |
| 6333 | 946 | g_free(buf); |
| 947 | } | |
| 948 | ||
| 949 | g_free(nick); | |
| 950 | return; | |
| 951 | } | |
| 952 | ||
| 953 | void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 954 | { | |
| 15884 | 955 | PurpleConversation *convo; |
| 6333 | 956 | char *nick = irc_mask_nick(from), *buf; |
| 957 | ||
| 958 | if (*args[0] == '#' || *args[0] == '&') { /* Channel */ | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
959 | char *escaped; |
| 15884 | 960 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 961 | if (!convo) { |
| 15884 | 962 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); |
| 6333 | 963 | g_free(nick); |
| 964 | return; | |
| 965 | } | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
966 | 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
|
967 | buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick); |
| 15884 | 968 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
969 | g_free(escaped); |
| 6333 | 970 | g_free(buf); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
971 | if(args[2]) { |
| 15884 | 972 | PurpleConvChatBuddyFlags newflag, flags; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
973 | char *mcur, *cur, *end, *user; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
974 | gboolean add = FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
975 | mcur = args[1]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
976 | cur = args[2]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
977 | while (*cur && *mcur) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
978 | if ((*mcur == '+') || (*mcur == '-')) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
979 | add = (*mcur == '+') ? TRUE : FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
980 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
981 | continue; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
982 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
983 | end = strchr(cur, ' '); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
984 | if (!end) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
985 | end = cur + strlen(cur); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
986 | user = g_strndup(cur, end - cur); |
| 15884 | 987 | flags = purple_conv_chat_user_get_flags(PURPLE_CONV_CHAT(convo), user); |
| 988 | newflag = PURPLE_CBFLAGS_NONE; | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
989 | if (*mcur == 'o') |
| 15884 | 990 | newflag = PURPLE_CBFLAGS_OP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
991 | else if (*mcur =='h') |
| 15884 | 992 | newflag = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
993 | else if (*mcur == 'v') |
| 15884 | 994 | newflag = PURPLE_CBFLAGS_VOICE; |
|
22471
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
995 | 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
|
996 | && strchr(irc->mode_chars, '~') && (*mcur == 'q')) |
|
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
997 | newflag = PURPLE_CBFLAGS_FOUNDER; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
998 | if (newflag) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
999 | if (add) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1000 | flags |= newflag; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1001 | else |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1002 | flags &= ~newflag; |
| 15884 | 1003 | purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(convo), user, flags); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1004 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1005 | g_free(user); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1006 | cur = end; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1007 | if (*cur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1008 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1009 | if (*mcur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1010 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1011 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1012 | } |
| 6333 | 1013 | } else { /* User */ |
| 1014 | } | |
| 1015 | g_free(nick); | |
| 1016 | } | |
| 1017 | ||
| 1018 | void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1019 | { | |
| 15884 | 1020 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1021 | PurpleConversation *conv; | |
| 6333 | 1022 | GSList *chats; |
| 1023 | char *nick = irc_mask_nick(from); | |
| 1024 | ||
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1025 | 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
|
1026 | |
| 6333 | 1027 | if (!gc) { |
| 1028 | g_free(nick); | |
| 1029 | return; | |
| 1030 | } | |
| 1031 | chats = gc->buddy_chats; | |
| 1032 | ||
| 15884 | 1033 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 1034 | purple_connection_set_display_name(gc, args[0]); | |
| 6333 | 1035 | } |
| 1036 | ||
| 1037 | while (chats) { | |
| 15884 | 1038 | PurpleConvChat *chat = PURPLE_CONV_CHAT(chats->data); |
| 9593 | 1039 | /* This is ugly ... */ |
| 15884 | 1040 | if (purple_conv_chat_find_user(chat, nick)) |
| 1041 | purple_conv_chat_rename_user(chat, nick, args[0]); | |
| 6333 | 1042 | chats = chats->next; |
| 1043 | } | |
| 10617 | 1044 | |
| 15884 | 1045 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, nick, |
| 10617 | 1046 | irc->account); |
| 1047 | if (conv != NULL) | |
| 15884 | 1048 | purple_conversation_set_name(conv, args[0]); |
| 10617 | 1049 | |
| 6333 | 1050 | g_free(nick); |
| 1051 | } | |
| 1052 | ||
| 10633 | 1053 | void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1054 | { | |
| 15884 | 1055 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1056 | if (purple_connection_get_state(gc) == PURPLE_CONNECTED) { | |
| 1057 | purple_notify_error(gc, _("Invalid nickname"), | |
| 13057 | 1058 | _("Invalid nickname"), |
| 1059 | _("Your selected nickname was rejected by the server. It probably contains invalid characters.")); | |
| 1060 | ||
| 1061 | } else { | |
| 21279 | 1062 | purple_connection_error_reason (gc, |
| 1063 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, | |
|
20440
42e5e5445a2f
Move prpl-irc to purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1064 | _("Your selected account name was rejected by the server. It probably contains invalid characters.")); |
| 13057 | 1065 | } |
| 10633 | 1066 | } |
| 1067 | ||
| 6333 | 1068 | void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1069 | { | |
| 1070 | char *newnick, *buf, *end; | |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1071 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 1072 | |
| 1073 | if (!args || !args[1]) | |
| 1074 | return; | |
| 1075 | ||
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1076 | if (gc && purple_connection_get_state(gc) == PURPLE_CONNECTED) { |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1077 | /* 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
|
1078 | has not been successfully completed. If it has, just |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1079 | 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
|
1080 | 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
|
1081 | irc->reqnick); |
|
26825
6d3bb5625183
Notify the user if an IRC /nick command fails, rather than trying fallbacks.
Ethan Blanton <elb@pidgin.im>
parents:
26752
diff
changeset
|
1082 | purple_notify_error(gc, _("Nickname in use"), |
|
6d3bb5625183
Notify the user if an IRC /nick command fails, rather than trying fallbacks.
Ethan Blanton <elb@pidgin.im>
parents:
26752
diff
changeset
|
1083 | _("Nickname in use"), buf); |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1084 | g_free(buf); |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1085 | g_free(irc->reqnick); |
|
25706
cbaf3afc17c6
applied changes from 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents:
25705
diff
changeset
|
1086 | irc->reqnick = NULL; |
|
25707
e1b69b86aa3c
Hand-pluck of 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents:
25706
diff
changeset
|
1087 | return; |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1088 | } |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1089 | |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1090 | 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
|
1091 | 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
|
1092 | else |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1093 | newnick = g_strdup_printf("%s0", args[1]); |
| 6333 | 1094 | end = newnick + strlen(newnick) - 1; |
|
11386
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1095 | /* try fallbacks */ |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1096 | if((*end < '9') && (*end >= '1')) { |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1097 | *end = *end + 1; |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1098 | } else *end = '1'; |
| 6333 | 1099 | |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1100 | 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
|
1101 | 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
|
1102 | 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
|
1103 | |
|
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
|
1104 | 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
|
1105 | 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
|
1106 | |
| 6333 | 1107 | buf = irc_format(irc, "vn", "NICK", newnick); |
| 1108 | irc_send(irc, buf); | |
| 1109 | g_free(buf); | |
| 1110 | } | |
| 1111 | ||
| 1112 | void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1113 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1114 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1115 | return; |
| 6333 | 1116 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1117 | irc_msg_handle_privmsg(irc, name, from, args[0], args[1], TRUE); |
| 6333 | 1118 | } |
| 1119 | ||
| 6718 | 1120 | void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1121 | { | |
| 15884 | 1122 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6718 | 1123 | |
| 6753 | 1124 | if (!args || !args[2] || !gc) |
| 6718 | 1125 | return; |
| 1126 | ||
| 15884 | 1127 | purple_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), args[2]); |
| 6718 | 1128 | } |
| 1129 | ||
| 6333 | 1130 | void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1131 | { | |
| 15884 | 1132 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1133 | PurpleConversation *convo; | |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1134 | char *nick, *msg, *channel; |
| 6333 | 1135 | |
| 8186 | 1136 | if (!args || !args[0] || !gc) |
| 6333 | 1137 | return; |
| 1138 | ||
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1139 | /* 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
|
1140 | * 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
|
1141 | 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
|
1142 | |
|
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1143 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, channel, irc->account); |
| 6333 | 1144 | if (!convo) { |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1145 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", channel); |
| 6333 | 1146 | return; |
| 1147 | } | |
| 1148 | ||
| 1149 | nick = irc_mask_nick(from); | |
| 15884 | 1150 | 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
|
1151 | char *escaped = args[1] ? g_markup_escape_text(args[1], -1) : NULL; |
| 8186 | 1152 | 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
|
1153 | (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
|
1154 | (escaped && *escaped) ? escaped : ""); |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
1155 | g_free(escaped); |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1156 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), channel, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 1157 | g_free(msg); |
| 15884 | 1158 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 1159 | } else { |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
1160 | msg = args[1] ? irc_mirc2txt(args[1]) : NULL; |
|
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
1161 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nick, msg); |
|
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
1162 | g_free(msg); |
| 6333 | 1163 | } |
| 1164 | g_free(nick); | |
| 1165 | } | |
| 1166 | ||
| 1167 | void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1168 | { | |
| 1169 | char *buf; | |
| 1170 | if (!args || !args[0]) | |
| 1171 | return; | |
| 1172 | ||
| 1173 | buf = irc_format(irc, "v:", "PONG", args[0]); | |
| 1174 | irc_send(irc, buf); | |
| 1175 | g_free(buf); | |
| 1176 | } | |
| 1177 | ||
| 1178 | void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1179 | { | |
| 15884 | 1180 | PurpleConversation *convo; |
| 1181 | PurpleConnection *gc; | |
| 6333 | 1182 | char **parts, *msg; |
| 1183 | time_t oldstamp; | |
| 1184 | ||
| 1185 | if (!args || !args[1]) | |
| 1186 | return; | |
| 1187 | ||
| 1188 | parts = g_strsplit(args[1], " ", 2); | |
| 1189 | ||
| 1190 | if (!parts[0] || !parts[1]) { | |
| 1191 | g_strfreev(parts); | |
| 1192 | return; | |
| 1193 | } | |
| 1194 | ||
| 1195 | if (sscanf(parts[1], "%lu", &oldstamp) != 1) { | |
| 1196 | msg = g_strdup(_("Error: invalid PONG from server")); | |
| 1197 | } else { | |
| 6350 | 1198 | msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp); |
| 6333 | 1199 | } |
| 1200 | ||
| 15884 | 1201 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, parts[0], irc->account); |
| 6333 | 1202 | g_strfreev(parts); |
| 1203 | if (convo) { | |
| 15884 | 1204 | if (purple_conversation_get_type (convo) == PURPLE_CONV_TYPE_CHAT) |
| 1205 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 1206 | else |
| 15884 | 1207 | purple_conv_im_write(PURPLE_CONV_IM(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 1208 | } else { |
| 15884 | 1209 | gc = purple_account_get_connection(irc->account); |
| 6333 | 1210 | if (!gc) { |
| 1211 | g_free(msg); | |
| 1212 | return; | |
| 1213 | } | |
| 15884 | 1214 | purple_notify_info(gc, NULL, "PONG", msg); |
| 6333 | 1215 | } |
| 1216 | g_free(msg); | |
| 1217 | } | |
| 1218 | ||
| 1219 | void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1220 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1221 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1222 | return; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1223 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1224 | 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
|
1225 | } |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1226 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1227 | 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
|
1228 | { |
| 15884 | 1229 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1230 | PurpleConversation *convo; | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1231 | char *tmp; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1232 | char *msg; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1233 | char *nick; |
| 6333 | 1234 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1235 | if (!gc) |
| 6333 | 1236 | return; |
| 1237 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1238 | nick = irc_mask_nick(from); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1239 | tmp = irc_parse_ctcp(irc, nick, to, rawmsg, notice); |
| 6333 | 1240 | if (!tmp) { |
| 1241 | g_free(nick); | |
| 1242 | return; | |
| 1243 | } | |
| 8163 | 1244 | |
|
20217
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
20194
diff
changeset
|
1245 | msg = irc_escape_privmsg(tmp, -1); |
| 6333 | 1246 | g_free(tmp); |
| 8163 | 1247 | |
| 1248 | tmp = irc_mirc2html(msg); | |
| 1249 | g_free(msg); | |
| 1250 | msg = tmp; | |
| 6333 | 1251 | if (notice) { |
| 1252 | tmp = g_strdup_printf("(notice) %s", msg); | |
| 1253 | g_free(msg); | |
| 1254 | msg = tmp; | |
| 1255 | } | |
| 1256 | ||
| 15884 | 1257 | 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
|
1258 | serv_got_im(gc, nick, msg, 0, time(NULL)); |
| 6333 | 1259 | } else { |
|
27044
bc111170ee11
This allows incoming channel messages with op/voice/etc. mode characters.
Marcos García Ochoa <magao@bigfoot.com>
parents:
26855
diff
changeset
|
1260 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, irc_nick_skip_mode(irc, to), irc->account); |
| 6333 | 1261 | if (convo) |
| 15884 | 1262 | serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)), nick, 0, msg, time(NULL)); |
| 6333 | 1263 | else |
| 15884 | 1264 | 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
|
1265 | notice ? "NOTICE" : "PRIVMSG", to); |
| 6333 | 1266 | } |
| 1267 | g_free(msg); | |
| 1268 | g_free(nick); | |
| 1269 | } | |
| 1270 | ||
| 6714 | 1271 | void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1272 | { | |
| 15884 | 1273 | PurpleConnection *gc = purple_account_get_connection(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
|
1274 | PurpleConversation *convo; |
| 6714 | 1275 | char *msg; |
| 1276 | ||
| 1277 | if (!args || !args[1] || !args[2] || !gc) | |
| 1278 | return; | |
| 1279 | ||
|
17297
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1280 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1281 | if (convo) { |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1282 | /* 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
|
1283 | * 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
|
1284 | * 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
|
1285 | * 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
|
1286 | return; |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1287 | } |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1288 | |
|
16993
536c1485c139
Handle channel joins when registration is required more gracefully.
Ethan Blanton <elb@pidgin.im>
parents:
16893
diff
changeset
|
1289 | msg = g_strdup_printf(_("Cannot join %s: Registration is required."), args[1]); |
| 15884 | 1290 | purple_notify_error(gc, _("Cannot join channel"), msg, args[2]); |
| 6714 | 1291 | g_free(msg); |
| 1292 | } | |
| 1293 | ||
| 6333 | 1294 | void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1295 | { | |
| 15884 | 1296 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 9238 | 1297 | struct irc_buddy *ib; |
| 6333 | 1298 | char *data[2]; |
| 1299 | ||
| 1300 | if (!args || !args[0] || !gc) | |
| 1301 | return; | |
| 1302 | ||
| 1303 | data[0] = irc_mask_nick(from); | |
| 1304 | data[1] = args[0]; | |
| 1305 | /* XXX this should have an API, I shouldn't grab this directly */ | |
| 1306 | g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data); | |
| 9238 | 1307 | |
| 1308 | 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
|
1309 | ib->new_online_status = FALSE; |
| 9238 | 1310 | irc_buddy_status(data[0], ib, irc); |
| 1311 | } | |
| 6333 | 1312 | g_free(data[0]); |
| 1313 | ||
| 1314 | return; | |
| 1315 | } | |
| 1316 | ||
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1317 | 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
|
1318 | { |
| 15884 | 1319 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1320 | |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1321 | if (!args || !args[1]) |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1322 | return; |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1323 | |
| 15884 | 1324 | purple_notify_error(gc, NULL, _("Nick or channel is temporarily unavailable."), args[1]); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1325 | } |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1326 | |
| 6333 | 1327 | void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1328 | { | |
| 15884 | 1329 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1330 | char *nick, *msg; |
| 6333 | 1331 | |
| 1332 | if (!args || !args[0] || !gc) | |
| 1333 | return; | |
| 1334 | ||
| 1335 | nick = irc_mask_nick(from); | |
| 1336 | msg = g_strdup_printf (_("Wallops from %s"), nick); | |
| 1337 | g_free(nick); | |
| 15884 | 1338 | purple_notify_info(gc, NULL, msg, args[0]); |
| 6333 | 1339 | g_free(msg); |
| 1340 | } | |
| 1341 | ||
| 1342 | void irc_msg_ignore(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1343 | { | |
| 1344 | return; | |
| 1345 | } |