comparison libpurple/protocols/irc/msgs.c @ 32786:31e66fce43d1

disapproval of revision '132d9cb629620d7653e479a7b0cea75f35b2abdf'
author Ethan Blanton <elb@pidgin.im>
date Sat, 05 May 2012 17:12:13 +0000
parents f911cdafdcd8
children bcea57ced98c
comparison
equal deleted inserted replaced
32785:f911cdafdcd8 32786:31e66fce43d1
110 irc_blist_timeout(irc); 110 irc_blist_timeout(irc);
111 if (!irc->timer) 111 if (!irc->timer)
112 irc->timer = purple_timeout_add_seconds(45, (GSourceFunc)irc_blist_timeout, (gpointer)irc); 112 irc->timer = purple_timeout_add_seconds(45, (GSourceFunc)irc_blist_timeout, (gpointer)irc);
113 } 113 }
114 114
115 /* This function is ugly, but it's really an error handler. */
116 void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) 115 void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args)
117 { 116 {
118 int i, directed_magic = TRUE; 117 char *clean;
119 char *convname, *end, *tmp, *cur;
120 PurpleConversation *convo;
121
122 for (cur = args[0], i = 0; i < 4; i++) {
123 end = strchr(cur, ' ');
124 if (cur == NULL) {
125 goto undirected;
126 }
127 /* Check for 3-digit numeric in second position */
128 if (i == 1 && (end - cur != 3
129 || !isdigit(cur[0]) || !isdigit(cur[1])
130 || !isdigit(cur[2]))) {
131 goto undirected;
132 }
133 /* Hack! */
134 if (i != 3) {
135 cur = end + 1;
136 }
137 }
138
139 /* At this point, cur is the beginning of the fourth position,
140 * end is the following space, and there are remaining
141 * arguments. We'll check to see if this argument is a
142 * currently active conversation (private message or channel,
143 * either one), and print the numeric to that conversation if it
144 * is. */
145
146 tmp = g_strndup(cur, end - cur);
147 convname = purple_utf8_salvage(tmp);
148 g_free(tmp);
149
150 /* Check for an existing conversation */
151 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY,
152 convname,
153 irc->account);
154 g_free(convname);
155
156 if (convo == NULL) {
157 goto undirected;
158 }
159
160 tmp = purple_utf8_salvage(args[0]);
161 purple_conversation_write(convo, "", tmp,
162 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG
163 |PURPLE_MESSAGE_RAW|PURPLE_MESSAGE_NO_LINKIFY,
164 time(NULL));
165 g_free(tmp);
166 return;
167
168 undirected:
169 /* This, too, should be escaped somehow (smarter) */ 118 /* This, too, should be escaped somehow (smarter) */
170 tmp = purple_utf8_salvage(args[0]); 119 clean = purple_utf8_salvage(args[0]);
171 purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", tmp); 120 purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", clean);
172 g_free(tmp); 121 g_free(clean);
173 } 122 }
174 123
175 void irc_msg_features(struct irc_conn *irc, const char *name, const char *from, char **args) 124 void irc_msg_features(struct irc_conn *irc, const char *name, const char *from, char **args)
176 { 125 {
177 gchar **features; 126 gchar **features;