Changes in irc_commands.c [f9756bd:1cda4f3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_commands.c
rf9756bd r1cda4f3 30 30 static void irc_cmd_pass( irc_t *irc, char **cmd ) 31 31 { 32 if( irc->status & USTATUS_LOGGED_IN ) 33 { 34 char *send_cmd[] = { "identify", cmd[1], NULL }; 35 36 /* We're already logged in, this client seems to send the PASS 37 command last. (Possibly it won't send it at all if it turns 38 out we don't require it, which will break this feature.) 39 Try to identify using the given password. */ 40 return root_command( irc, send_cmd ); 41 } 42 /* Handling in pre-logged-in state, first see if this server is 43 password-protected: */ 44 else if( global.conf->auth_pass && 45 ( strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? 46 md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : 47 strcmp( cmd[1], global.conf->auth_pass ) == 0 ) ) 48 { 49 irc->status |= USTATUS_AUTHORIZED; 32 if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 ) 33 { 34 irc->status = USTATUS_AUTHORIZED; 50 35 irc_check_login( irc ); 51 36 } 52 else if( global.conf->auth_pass )37 else 53 38 { 54 39 irc_reply( irc, 464, ":Incorrect password" ); 55 }56 else57 {58 /* Remember the password and try to identify after USER/NICK. */59 irc_setpass( irc, cmd[1] );60 irc_check_login( irc );61 40 } 62 41 } … … 109 88 static void irc_cmd_oper( irc_t *irc, char **cmd ) 110 89 { 111 if( global.conf->oper_pass && 112 ( strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? 113 md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : 114 strcmp( cmd[2], global.conf->oper_pass ) == 0 ) ) 90 if( global.conf->oper_pass && strcmp( cmd[2], global.conf->oper_pass ) == 0 ) 115 91 { 116 92 irc_umode_set( irc, "+o", 1 ); … … 143 119 if( cmd[2] ) 144 120 irc_umode_set( irc, cmd[2], 0 ); 145 else146 irc_reply( irc, 221, "+%s", irc->umode );147 121 } 148 122 else … … 158 132 static void irc_cmd_part( irc_t *irc, char **cmd ) 159 133 { 160 struct groupchat*c;134 struct conversation *c; 161 135 162 136 if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) … … 168 142 irc_join( irc, u, irc->channel ); 169 143 } 170 else if( ( c = irc_chat_by_channel( irc,cmd[1] ) ) )144 else if( ( c = conv_findchannel( cmd[1] ) ) ) 171 145 { 172 146 user_t *u = user_find( irc, irc->nick ); … … 174 148 irc_part( irc, u, c->channel ); 175 149 176 if( c-> ic)150 if( c->gc && c->gc->prpl ) 177 151 { 178 152 c->joined = 0; 179 c-> ic->acc->prpl->chat_leave( c);153 c->gc->prpl->chat_leave( c->gc, c->id ); 180 154 } 181 155 } … … 197 171 user_t *u = user_find( irc, cmd[1] + 1 ); 198 172 199 if( u && u-> ic && u->ic->acc->prpl->chat_with)173 if( u && u->gc && u->gc->prpl && u->gc->prpl->chat_open ) 200 174 { 201 175 irc_reply( irc, 403, "%s :Initializing groupchat in a different channel", cmd[1] ); 202 176 203 if( !u-> ic->acc->prpl->chat_with( u->ic, u->handle ) )177 if( !u->gc->prpl->chat_open( u->gc, u->handle ) ) 204 178 { 205 irc_usermsg( irc, "Could not open a groupchat with %s .", u->nick );179 irc_usermsg( irc, "Could not open a groupchat with %s, maybe you don't have a connection to him/her yet?", u->nick ); 206 180 } 207 181 } … … 225 199 { 226 200 char *nick = cmd[1], *channel = cmd[2]; 227 struct groupchat *c = irc_chat_by_channel( irc,channel );201 struct conversation *c = conv_findchannel( channel ); 228 202 user_t *u = user_find( irc, nick ); 229 203 230 if( u && c && ( u-> ic == c->ic ) )231 if( c-> ic && c->ic->acc->prpl->chat_invite )232 { 233 c-> ic->acc->prpl->chat_invite( c, u->handle, NULL);204 if( u && c && ( u->gc == c->gc ) ) 205 if( c->gc && c->gc->prpl && c->gc->prpl->chat_invite ) 206 { 207 c->gc->prpl->chat_invite( c->gc, c->id, "", u->handle ); 234 208 irc_reply( irc, 341, "%s %s", nick, channel ); 235 209 return; … … 254 228 { 255 229 unsigned int i; 256 char *t = set_getstr( &irc->set, "default_target" );230 char *t = set_getstr( irc, "default_target" ); 257 231 258 232 if( g_strcasecmp( t, "last" ) == 0 && irc->last_target ) … … 278 252 if( cmd[1] != irc->last_target ) 279 253 { 280 g_free( irc->last_target ); 254 if( irc->last_target ) 255 g_free( irc->last_target ); 281 256 irc->last_target = g_strdup( cmd[1] ); 282 257 } … … 286 261 irc->is_private = 1; 287 262 } 288 irc_send( irc, cmd[1], cmd[2], ( g_strcasecmp( cmd[0], "NOTICE" ) == 0 ) ? OPT_AWAY : 0 );263 irc_send( irc, cmd[1], cmd[2], ( g_strcasecmp( cmd[0], "NOTICE" ) == 0 ) ? IM_FLAG_AWAY : 0 ); 289 264 } 290 265 } … … 294 269 char *channel = cmd[1]; 295 270 user_t *u = irc->users; 296 struct groupchat*c;271 struct conversation *c; 297 272 GList *l; 298 273 … … 310 285 u = u->next; 311 286 } 312 else if( ( c = irc_chat_by_channel( irc,channel ) ) )287 else if( ( c = conv_findchannel( channel ) ) ) 313 288 for( l = c->in_room; l; l = l->next ) 314 289 { 315 if( ( u = user_findhandle( c-> ic, l->data ) ) )290 if( ( u = user_findhandle( c->gc, l->data ) ) ) 316 291 irc_reply( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname ); 317 292 } … … 356 331 for( i = 1; cmd[i]; i ++ ) 357 332 { 358 char *this, *next; 359 360 this = cmd[i]; 361 while( *this ) 362 { 363 if( ( next = strchr( this, ' ' ) ) ) 364 *next = 0; 365 366 if( ( u = user_find( irc, this ) ) && u->online ) 367 { 368 lenleft -= strlen( u->nick ) + 1; 369 370 if( lenleft < 0 ) 371 break; 372 373 strcat( buff, u->nick ); 374 strcat( buff, " " ); 375 } 376 377 if( next ) 378 { 379 *next = ' '; 380 this = next + 1; 381 } 382 else 333 if( ( u = user_find( irc, cmd[i] ) ) && u->online ) 334 { 335 /* [SH] Make sure we don't use too much buffer space. */ 336 lenleft -= strlen( u->nick ) + 1; 337 338 if( lenleft < 0 ) 383 339 { 384 340 break; 385 } 386 } 387 388 /* *sigh* */ 389 if( lenleft < 0 ) 390 break; 391 } 392 341 } 342 343 /* [SH] Add the nick to the buffer. Note 344 * that an extra space is always added. Even 345 * if it's the last nick in the list. Who 346 * cares? 347 */ 348 349 strcat( buff, u->nick ); 350 strcat( buff, " " ); 351 } 352 } 353 354 /* [WvG] Well, maybe someone cares, so why not remove it? */ 393 355 if( strlen( buff ) > 0 ) 394 356 buff[strlen(buff)-1] = '\0'; … … 444 406 static void irc_cmd_topic( irc_t *irc, char **cmd ) 445 407 { 446 char *channel = cmd[1]; 447 char *topic = cmd[2]; 448 449 if( topic ) 450 { 451 /* Send the topic */ 452 struct groupchat *c = irc_chat_by_channel( irc, channel ); 453 if( c && c->ic && c->ic->acc->prpl->chat_topic ) 454 c->ic->acc->prpl->chat_topic( c, topic ); 455 } 456 else 457 { 458 /* Get the topic */ 459 irc_topic( irc, channel ); 460 } 408 if( cmd[2] ) 409 irc_reply( irc, 482, "%s :Cannot change topic", cmd[1] ); 410 else 411 irc_topic( irc, cmd[1] ); 461 412 } 462 413 … … 494 445 for( a = irc->accounts; a; a = a->next ) 495 446 { 496 struct im_connection *ic = a->ic;497 498 if( ic && ic->flags & OPT_LOGGED_IN )499 imc_set_away( ic, u->away );447 struct gaim_connection *gc = a->gc; 448 449 if( gc && gc->flags & OPT_LOGGED_IN ) 450 bim_set_away( gc, u->away ); 500 451 } 501 452 } … … 510 461 irc_reply( irc, 311, "%s %s %s * :%s", u->nick, u->user, u->host, u->realname ); 511 462 512 if( u->ic ) 513 irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user, 514 u->ic->acc->server && *u->ic->acc->server ? u->ic->acc->server : "", 515 u->ic->acc->prpl->name ); 463 if( u->gc ) 464 irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc->user->username, 465 *u->gc->user->proto_opt[0] ? u->gc->user->proto_opt[0] : "", u->gc->prpl->name ); 516 466 else 517 467 irc_reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO ); … … 579 529 580 530 for( h = global.help; h; h = h->next ) 581 irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS help ", h-> title);531 irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS help ", h->string ); 582 532 583 533 for( s = irc->set; s; s = s->next ) … … 594 544 ipc_to_master( cmd ); 595 545 596 irc_reply( irc, 382, "%s :Rehashing", global.conf_file ); 546 #ifndef _WIN32 547 irc_reply( irc, 382, "%s :Rehashing", CONF_FILE ); 548 #endif 597 549 } 598 550 599 551 static const command_t irc_commands[] = { 600 { "pass", 1, irc_cmd_pass, 0},552 { "pass", 1, irc_cmd_pass, IRC_CMD_PRE_LOGIN }, 601 553 { "user", 4, irc_cmd_user, IRC_CMD_PRE_LOGIN }, 602 554 { "nick", 1, irc_cmd_nick, 0 }, … … 627 579 { "die", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 628 580 { "wallops", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 629 { " wall", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },581 { "lilo", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 630 582 { "rehash", 0, irc_cmd_rehash, IRC_CMD_OPER_ONLY }, 631 583 { "restart", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, … … 647 599 for( n_arg = 0; cmd[n_arg]; n_arg ++ ); n_arg --; 648 600 649 if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status &USTATUS_LOGGED_IN )601 if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status >= USTATUS_LOGGED_IN ) 650 602 { 651 603 irc_reply( irc, 462, ":Only allowed before logging in" ); 652 604 } 653 else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && !( irc->status & USTATUS_LOGGED_IN ))605 else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && irc->status < USTATUS_LOGGED_IN ) 654 606 { 655 607 irc_reply( irc, 451, ":Register first" ); … … 674 626 } 675 627 676 return; 677 } 678 679 if( irc->status >= USTATUS_LOGGED_IN ) 680 irc_reply( irc, 421, "%s :Unknown command", cmd[0] ); 681 } 628 break; 629 } 630 }
Note: See TracChangeset
for help on using the changeset viewer.