comparison plugins/irc.c @ 1673:0ded38ffc7c8

[gaim-migrate @ 1683] IRC got whois. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sat, 31 Mar 2001 06:49:06 +0000
parents 7cb0cebd6d87
children 1127fa1b4c02
comparison
equal deleted inserted replaced
1672:7cb0cebd6d87 1673:0ded38ffc7c8
397 397
398 /* And our necessary garbage collection */ 398 /* And our necessary garbage collection */
399 g_free(u_errormsg); 399 g_free(u_errormsg);
400 } 400 }
401 401
402 /* This should be a whois response. I only care about the first (311) one. I might do
403 * the other's later. They're boring. */
404
405 if (((strstr(buf, " 311 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) {
406 char **res;
407
408 res = g_strsplit(buf, " ", 7);
409
410 if (!strcmp(res[1], "311"))
411 {
412 char buf[8192];
413
414 g_snprintf(buf, 4096, "<b>Nick:</b> %s<br>"
415 "<b>Host:</b> %s@%s<br>"
416 "<b>Name:</b> %s<br>", res[3], res[4], res[5], res[7]+1);
417
418 g_show_info_text(buf);
419 }
420
421 g_strfreev(res);
422 }
423
402 /* Parse the list of names that we receive when we first sign on to 424 /* Parse the list of names that we receive when we first sign on to
403 * a channel */ 425 * a channel */
404 426
405 if (((strstr(buf, " 353 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) { 427 if (((strstr(buf, " 353 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) {
406 gchar u_host[255]; 428 gchar u_host[255];
1164 g_snprintf(buf, BUF_LEN, "PRIVMSG %s :%cPING %ld%c\n", who, '\001', time((time_t *)NULL), '\001'); 1186 g_snprintf(buf, BUF_LEN, "PRIVMSG %s :%cPING %ld%c\n", who, '\001', time((time_t *)NULL), '\001');
1165 1187
1166 write(idata->fd, buf, strlen(buf)); 1188 write(idata->fd, buf, strlen(buf));
1167 } 1189 }
1168 1190
1191 /* Do a whois check on someone :-) */
1192 static void irc_get_info(struct gaim_connection *gc, char *who)
1193 {
1194 struct irc_data *idata = (struct irc_data *)gc->proto_data;
1195 char buf[BUF_LEN];
1196
1197 if ((who[0] == '@') || (who[0] == '+') && (strlen(who)>1))
1198 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who+1);
1199 else
1200 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who);
1201 write(idata->fd, buf, strlen(buf));
1202 }
1203
1204 static void irc_send_whois(GtkObject * w, char *who)
1205 {
1206 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w);
1207 irc_get_info(gc, who);
1208 }
1169 1209
1170 static void irc_buddy_menu(GtkWidget * menu, struct gaim_connection *gc, char *who) 1210 static void irc_buddy_menu(GtkWidget * menu, struct gaim_connection *gc, char *who)
1171 { 1211 {
1172 GtkWidget *button; 1212 GtkWidget *button;
1173 1213
1174 button = gtk_menu_item_new_with_label("Ping"); 1214 button = gtk_menu_item_new_with_label("Ping");
1175 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_ping), who); 1215 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_ping), who);
1216 gtk_object_set_user_data(GTK_OBJECT(button), gc);
1217 gtk_menu_append(GTK_MENU(menu), button);
1218 gtk_widget_show(button);
1219
1220 button = gtk_menu_item_new_with_label("Whois");
1221 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_whois), who);
1176 gtk_object_set_user_data(GTK_OBJECT(button), gc); 1222 gtk_object_set_user_data(GTK_OBJECT(button), gc);
1177 gtk_menu_append(GTK_MENU(menu), button); 1223 gtk_menu_append(GTK_MENU(menu), button);
1178 gtk_widget_show(button); 1224 gtk_widget_show(button);
1179 } 1225 }
1180 1226
1192 ret->close = irc_close; 1238 ret->close = irc_close;
1193 ret->send_im = irc_send_im; 1239 ret->send_im = irc_send_im;
1194 ret->join_chat = irc_join_chat; 1240 ret->join_chat = irc_join_chat;
1195 ret->chat_leave = irc_chat_leave; 1241 ret->chat_leave = irc_chat_leave;
1196 ret->chat_send = irc_chat_send; 1242 ret->chat_send = irc_chat_send;
1243 ret->get_info = irc_get_info;
1197 1244
1198 my_protocol = ret; 1245 my_protocol = ret;
1199 } 1246 }
1200 1247
1201 char *gaim_plugin_init(GModule * handle) 1248 char *gaim_plugin_init(GModule * handle)