Mercurial > pidgin
comparison libpurple/protocols/irc/msgs.c @ 15446:8c81db398f56
This should fix up IRC logins for servers which do not provide an
MOTD, which is not required by the spec. All servers MUST send 251 &
255 numerics, so now we key off those. This fixes several IRC bugs in
the sourceforge tracker, which should be updated upon release.
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Sun, 28 Jan 2007 17:02:31 +0000 |
parents | 8ff4af28c9f9 |
children | 79f25bbe69bf |
comparison
equal
deleted
inserted
replaced
15445:910f4be8fc73 | 15446:8c81db398f56 |
---|---|
90 char *val; | 90 char *val; |
91 if (!strncmp(features[i], "PREFIX=", 7)) { | 91 if (!strncmp(features[i], "PREFIX=", 7)) { |
92 if ((val = strchr(features[i] + 7, ')')) != NULL) | 92 if ((val = strchr(features[i] + 7, ')')) != NULL) |
93 mode_chars = g_strdup(val + 1); | 93 mode_chars = g_strdup(val + 1); |
94 } | 94 } |
95 } | |
96 } | |
97 | |
98 void irc_msg_luser(struct irc_conn *irc, const char *name, const char *from, char **args) | |
99 { | |
100 GaimConnection *gc; | |
101 GaimStatus *status; | |
102 GaimBlistNode *gnode, *cnode, *bnode; | |
103 | |
104 if (!args || !args[0] || !args[1]) | |
105 return; | |
106 | |
107 gc = gaim_account_get_connection(irc->account); | |
108 if (!gc) | |
109 return; | |
110 | |
111 if (!strcmp(name, "251")) { | |
112 /* 251 is required, so we pluck our nick from here */ | |
113 gaim_connection_set_display_name(gc, args[0]); | |
114 } else if (!strcmp(name, "255")) { | |
115 gaim_connection_set_state(gc, GAIM_CONNECTED); | |
116 | |
117 /* If we're away then set our away message */ | |
118 status = gaim_account_get_active_status(irc->account); | |
119 if (!gaim_status_get_type(status) != GAIM_STATUS_AVAILABLE) { | |
120 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
121 prpl_info->set_status(irc->account, status); | |
122 } | |
123 | |
124 /* this used to be in the core, but it's not now */ | |
125 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
126 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
127 continue; | |
128 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
129 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
130 continue; | |
131 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
132 GaimBuddy *b; | |
133 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
134 continue; | |
135 b = (GaimBuddy *)bnode; | |
136 if(b->account == gc->account) { | |
137 struct irc_buddy *ib = g_new0(struct irc_buddy, 1); | |
138 ib->name = g_strdup(b->name); | |
139 g_hash_table_insert(irc->buddies, ib->name, ib); | |
140 } | |
141 } | |
142 } | |
143 } | |
144 | |
145 irc_blist_timeout(irc); | |
146 if (!irc->timer) | |
147 irc->timer = gaim_timeout_add(45000, (GSourceFunc)irc_blist_timeout, (gpointer)irc); | |
95 } | 148 } |
96 } | 149 } |
97 | 150 |
98 void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args) | 151 void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args) |
99 { | 152 { |
463 } | 516 } |
464 } | 517 } |
465 | 518 |
466 void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) | 519 void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) |
467 { | 520 { |
468 GaimConnection *gc; | |
469 char *escaped; | 521 char *escaped; |
470 if (!strcmp(name, "375")) { | |
471 gc = gaim_account_get_connection(irc->account); | |
472 if (gc) | |
473 gaim_connection_set_display_name(gc, args[0]); | |
474 } | |
475 | 522 |
476 if (!irc->motd) | 523 if (!irc->motd) |
477 irc->motd = g_string_new(""); | 524 irc->motd = g_string_new(""); |
525 | |
526 if (!strcmp(name, "375")) { | |
527 if (irc->motd) | |
528 g_string_free(irc->motd, TRUE); | |
529 irc->motd = g_string_new(""); | |
530 return; | |
531 } else if (!strcmp(name, "376")) { | |
532 /* We no longer have to do anything for ENDMOTD */ | |
533 return; | |
534 } | |
535 | |
536 if (!irc->motd) { | |
537 gaim_debug_error("irc", "IRC server sent MOTD without STARTMOTD\n"); | |
538 return; | |
539 } | |
478 | 540 |
479 escaped = g_markup_escape_text(args[1], -1); | 541 escaped = g_markup_escape_text(args[1], -1); |
480 g_string_append_printf(irc->motd, "%s<br>", escaped); | 542 g_string_append_printf(irc->motd, "%s<br>", escaped); |
481 g_free(escaped); | 543 g_free(escaped); |
482 } | |
483 | |
484 void irc_msg_endmotd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
485 { | |
486 GaimConnection *gc; | |
487 GaimStatus *status; | |
488 GaimBlistNode *gnode, *cnode, *bnode; | |
489 | |
490 gc = gaim_account_get_connection(irc->account); | |
491 if (!gc) | |
492 return; | |
493 | |
494 gaim_connection_set_state(gc, GAIM_CONNECTED); | |
495 | |
496 /* If we're away then set our away message */ | |
497 status = gaim_account_get_active_status(irc->account); | |
498 if (!gaim_status_get_type(status) != GAIM_STATUS_AVAILABLE) | |
499 { | |
500 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
501 prpl_info->set_status(irc->account, status); | |
502 } | |
503 | |
504 /* this used to be in the core, but it's not now */ | |
505 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
506 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
507 continue; | |
508 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
509 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
510 continue; | |
511 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
512 GaimBuddy *b; | |
513 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
514 continue; | |
515 b = (GaimBuddy *)bnode; | |
516 if(b->account == gc->account) { | |
517 struct irc_buddy *ib = g_new0(struct irc_buddy, 1); | |
518 ib->name = g_strdup(b->name); | |
519 g_hash_table_insert(irc->buddies, ib->name, ib); | |
520 } | |
521 } | |
522 } | |
523 } | |
524 | |
525 irc_blist_timeout(irc); | |
526 if (!irc->timer) | |
527 irc->timer = gaim_timeout_add(45000, (GSourceFunc)irc_blist_timeout, (gpointer)irc); | |
528 } | 544 } |
529 | 545 |
530 void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) | 546 void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) |
531 { | 547 { |
532 GaimConnection *gc; | 548 GaimConnection *gc; |