Changes in / [ba3a8a5:ced1e17]
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rba3a8a5 rced1e17 10 10 11 11 # Program variables 12 objects = account.o bitlbee.o c rypting.o help.o ipc.o irc.o irc_commands.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) user.o12 objects = account.o bitlbee.o chat.o crypting.o help.o ipc.o irc.o irc_commands.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) user.o 13 13 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h user.h lib/events.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/nogaim.h 14 14 subdirs = lib protocols -
account.c
rba3a8a5 rced1e17 190 190 { 191 191 account_t *a, *l = NULL; 192 struct chat *c, *nc; 192 193 193 194 if( acc->ic ) … … 202 203 else 203 204 irc->accounts = a->next; 205 206 for( c = irc->chatrooms; c; c = nc ) 207 { 208 nc = c->next; 209 if( acc == c->acc ) 210 chat_del( irc, c ); 211 } 204 212 205 213 while( a->set ) -
bitlbee.h
rba3a8a5 rced1e17 129 129 #include "account.h" 130 130 #include "nick.h" 131 #include "chat.h" 131 132 #include "conf.h" 132 133 #include "log.h" -
doc/user-guide/commands.xml
rba3a8a5 rced1e17 125 125 <description> 126 126 <para> 127 This command gives you a list of all the accounts known by BitlBee , including the numbers you'll need for most account commands.127 This command gives you a list of all the accounts known by BitlBee. 128 128 </para> 129 129 </description> … … 138 138 <description> 139 139 <para> 140 This accountcan be used to change various settings for IM accounts. For all protocols, this command can be used to change the handle or the password BitlBee uses to log in and if it should be logged in automatically. Some protocols have additional settings. You can see the settings available for a connection by typing <emphasis>account set <account id></emphasis>.140 This command can be used to change various settings for IM accounts. For all protocols, this command can be used to change the handle or the password BitlBee uses to log in and if it should be logged in automatically. Some protocols have additional settings. You can see the settings available for a connection by typing <emphasis>account set <account id></emphasis>. 141 141 </para> 142 142 143 143 <para> 144 For more infomation about a setting, see <emphasis>help set <setting></emphasis>. For details about the syntax of this command, see <emphasis>help set</emphasis>.144 For more infomation about a setting, see <emphasis>help set <setting></emphasis>. 145 145 </para> 146 146 147 147 <para> 148 148 The account ID can be a number (see <emphasis>account list</emphasis>), the protocol name or (part of) the screenname, as long as it matches only one connection. 149 </para> 150 </description> 151 </bitlbee-command> 152 </bitlbee-command> 153 154 <bitlbee-command name="chat"> 155 <short-description>Chatroom list maintenance</short-description> 156 <syntax>chat <action> [<arguments>]</syntax> 157 158 <description> 159 160 <para> 161 Available actions: add, del, list, with and set. See <emphasis>help chat <action></emphasis> for more information. 162 </para> 163 164 </description> 165 166 <bitlbee-command name="add"> 167 <syntax>chat add <account> <room> [<channel>]</syntax> 168 169 <description> 170 <para> 171 Add a chatroom to the list of chatrooms you're interested in. BitlBee needs this list to map room names to a proper IRC channel name. 172 </para> 173 174 <para> 175 After adding a room to your list, you can simply use the IRC /join command to enter the room. Also, you can tell BitlBee to automatically join the room when you log in. (See <emphasis>chat set</emphasis>) 176 </para> 177 </description> 178 179 </bitlbee-command> 180 181 <bitlbee-command name="del"> 182 <syntax>chat del <chat id></syntax> 183 184 <description> 185 <para> 186 This commands deletes an chatroom from your list. 187 </para> 188 189 <para> 190 The room ID can be a number (see <emphasis>chat list</emphasis>), or (part of) the name of the room/channel. 191 </para> 192 </description> 193 </bitlbee-command> 194 195 <bitlbee-command name="list"> 196 <syntax>chat list</syntax> 197 198 <description> 199 <para> 200 This command gives you a list of all the chatrooms known by BitlBee. 201 </para> 202 </description> 203 </bitlbee-command> 204 205 <bitlbee-command name="with"> 206 <syntax>chat with <nickname></syntax> 207 208 <description> 209 <para> 210 While most <emphasis>chat</emphasis> subcommands are about named chatrooms, this command can be used to open an unnamed groupchat with one or more persons. This command is what <emphasis>/join #nickname</emphasis> used to do in older BitlBee versions. 211 </para> 212 </description> 213 </bitlbee-command> 214 215 <bitlbee-command name="set"> 216 <syntax>chat set <chat id></syntax> 217 <syntax>chat set <chat id>/<setting></syntax> 218 <syntax>chat set <chat id>/<setting> <value></syntax> 219 <syntax>chat set -del <chat id>/<setting></syntax> 220 221 <description> 222 <para> 223 This command can be used to change various settings for chatrooms. 224 </para> 225 226 <para> 227 For more infomation about a setting, see <emphasis>help set <setting></emphasis>. 228 </para> 229 230 <para> 231 The room ID can be a number (see <emphasis>chat list</emphasis>), or (part of) the name of the room/channel. 149 232 </para> 150 233 </description> … … 303 386 </bitlbee-setting> 304 387 388 <bitlbee-setting name="auto_join" type="boolean" scope="chat"> 389 <default>false</default> 390 391 <description> 392 <para> 393 With this option enabled, BitlBee will automatically join this chatroom when you log in. 394 </para> 395 </description> 396 </bitlbee-setting> 397 305 398 <bitlbee-setting name="auto_reconnect" type="boolean" scope="both"> 306 399 <default>false</default> … … 486 579 </bitlbee-setting> 487 580 581 <bitlbee-setting name="nick" type="string" scope="chat"> 582 583 <description> 584 <para> 585 You can use this option to set your nickname in a chatroom. You won't see this nickname yourself, but other people in the room will. By default, BitlBee will use your username as the chatroom nickname. 586 </para> 587 </description> 588 </bitlbee-setting> 589 488 590 <bitlbee-setting name="ops" type="string" scope="global"> 489 591 <default>both</default> … … 854 956 855 957 </bitlbee-command> 856 857 <bitlbee-command name="join_chat">858 <short-description>Join a named groupchat/conference room</short-description>859 <syntax>join_chat <connection> <room name> [<channel name>] [<room nickname>] [<password>]</syntax>860 861 <description>862 <para>863 On most IM-networks groupchats can be started using the /join command. (<emphasis>/join #foo</emphasis> to start a chatroom with you and <emphasis>foo</emphasis>) This doesn't work with names groupchats though (which exist on Jabber networks and AIM, for example), instead you can use this command.864 </para>865 866 <para>867 The first two arguments are required. <emphasis>room name</emphasis> is the name of the chatroom on the IM-network. <emphasis>channel name</emphasis> is the IRC channel name BitlBee should map this to. <emphasis>room nickname</emphasis> is the nickname you want to have in this channel. If you don't give these options, BitlBee will do the right guesses.868 </para>869 870 <para>871 The following command will join you to the chatroom called <emphasis>bitlbee@conference.bitlbee.org</emphasis>. The channel will be called <emphasis>&bitlbee-help</emphasis> because <emphasis>&bitlbee</emphasis> will already be in use. Your nickname will be <emphasis>help-me</emphasis>.872 </para>873 </description>874 875 <ircexample>876 <ircline nick="wilmer">join_chat jabber bitlbee@conference.bitlbee.org &bitlbee-help help-me</ircline>877 </ircexample>878 879 </bitlbee-command>880 958 </chapter> -
doc/user-guide/misc.xml
rba3a8a5 rced1e17 69 69 70 70 <para> 71 If you want to start a groupchat with the person <emphasis>lisa_msn</emphasis> in it, just join the channel <emphasis>#lisa_msn</emphasis>. BitlBee will refuse to join you to the channel with that name, but itwill create a new virtual channel with root, you and lisa_msn in it.71 To open a groupchat, use the <emphasis>chat with</emphasis> command. For example, to start a groupchat with the person <emphasis>lisa_msn</emphasis> in it, just type <emphasis>chat with lisa_msn</emphasis>. BitlBee will create a new virtual channel with root, you and lisa_msn in it. 72 72 </para> 73 73 74 74 <para> 75 Of course a channel with only two people isn't really exciting yet. So the next step is to invite some other people to the channel. For this, you can use the <emphasis>/invite</emphasis> command of your IRC client. Please do keep in mind that all the people have to be on the same network and contact list! You can't invite Yahoo! buddies into an MSN groupchat.75 Then, just use the ordinary IRC <emphasis>/invite</emphasis> command to invite more people. Please do keep in mind that all the people have to be on the same network and contact list! You can't invite Yahoo! buddies into an MSN groupchat. 76 76 </para> 77 77 78 78 <para> 79 Some protocols (like Jabber) also support named groupchats. BitlBee now supports these too. You can use the <emphasis> join_chat</emphasis> command to join them. See <emphasis>help join_chat</emphasis> for more information.79 Some protocols (like Jabber) also support named groupchats. BitlBee now supports these too. You can use the <emphasis>chat add</emphasis> command to join them. See <emphasis>help chat_add</emphasis> for more information. 80 80 </para> 81 81 -
irc.c
rba3a8a5 rced1e17 781 781 irc_reply( irc, 3, ":%s", IRCD_INFO ); 782 782 irc_reply( irc, 4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES ); 783 irc_reply( irc, 5, "PREFIX=(ov)@+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 ); 783 irc_reply( irc, 5, "PREFIX=(ov)@+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee " 784 "CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", 785 CTYPES, CMODES, MAX_NICK_LENGTH - 1 ); 784 786 irc_motd( irc ); 785 787 irc->umode[0] = '\0'; … … 1022 1024 user_t *u = NULL; 1023 1025 1024 if( *nick == '#' || *nick == '&')1026 if( strchr( CTYPES, *nick ) ) 1025 1027 { 1026 1028 if( !( c = irc_chat_by_channel( irc, nick ) ) ) -
irc.h
rba3a8a5 rced1e17 38 38 #define CMODE "t" 39 39 #define UMODE "s" 40 #define CTYPES "&#" 40 41 41 42 typedef enum … … 47 48 USTATUS_SHUTDOWN = 8 48 49 } irc_status_t; 49 50 typedef struct channel51 {52 char *name;53 } channel_t;54 50 55 51 typedef struct irc … … 87 83 struct query *queries; 88 84 struct account *accounts; 85 struct chat *chatrooms; 89 86 90 87 struct __USER *users; … … 100 97 101 98 #include "user.h" 102 // #include "nick.h"103 99 104 100 extern GSList *irc_connection_list; -
irc_commands.c
rba3a8a5 rced1e17 125 125 static void irc_cmd_mode( irc_t *irc, char **cmd ) 126 126 { 127 if( *cmd[1] == '#' || *cmd[1] == '&')127 if( strchr( CTYPES, *cmd[1] ) ) 128 128 { 129 129 if( cmd[2] ) … … 193 193 else if( cmd[1] ) 194 194 { 195 if( ( cmd[1][0] == '#' || cmd[1][0] == '&' ) && cmd[1][1] ) 196 { 197 user_t *u = user_find( irc, cmd[1] + 1 ); 198 199 if( u && u->ic && u->ic->acc->prpl->chat_with ) 200 { 201 irc_reply( irc, 403, "%s :Initializing groupchat in a different channel", cmd[1] ); 202 203 if( !u->ic->acc->prpl->chat_with( u->ic, u->handle ) ) 204 { 205 irc_usermsg( irc, "Could not open a groupchat with %s.", u->nick ); 206 } 207 } 208 else if( u ) 209 { 210 irc_reply( irc, 403, "%s :Groupchats are not possible with %s", cmd[1], cmd[1]+1 ); 211 } 212 else 213 { 214 irc_reply( irc, 403, "%s :No such nick", cmd[1] ); 215 } 195 struct chat *c; 196 user_t *u; 197 198 if( strchr( CTYPES, cmd[1][0] ) == NULL || cmd[1][1] == 0 ) 199 { 200 irc_reply( irc, 403, "%s :No such channel", cmd[1] ); 201 return; 202 } 203 204 if( ( c = chat_bychannel( irc, cmd[1] ) ) ) 205 { 206 chat_join( irc, c ); 216 207 } 217 208 else -
protocols/nogaim.c
rba3a8a5 rced1e17 249 249 void imcb_connected( struct im_connection *ic ) 250 250 { 251 irc_t *irc = ic->irc; 252 struct chat *c; 251 253 user_t *u; 252 254 … … 271 273 exponential backoff timer. */ 272 274 ic->acc->auto_reconnect_delay = 0; 275 276 for( c = irc->chatrooms; c; c = c->next ) 277 { 278 if( c->acc != ic->acc ) 279 continue; 280 281 if( set_getbool( &c->set, "auto_join" ) ) 282 chat_join( irc, c ); 283 } 273 284 } 274 285 -
root_commands.c
rba3a8a5 rced1e17 78 78 } 79 79 80 #define MIN_ARGS( x, y... ) \ 81 do \ 82 { \ 83 int blaat; \ 84 for( blaat = 0; blaat <= x; blaat ++ ) \ 85 if( cmd[blaat] == NULL ) \ 86 { \ 87 irc_usermsg( irc, "Not enough parameters given (need %d).", x ); \ 88 return y; \ 89 } \ 90 } while( 0 ) 91 80 92 void root_command( irc_t *irc, char *cmd[] ) 81 93 { … … 88 100 if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) 89 101 { 90 if( !cmd[commands[i].required_parameters] ) 91 { 92 irc_usermsg( irc, "Not enough parameters given (need %d)", commands[i].required_parameters ); 93 return; 94 } 102 MIN_ARGS( commands[i].required_parameters ); 103 95 104 commands[i].execute( irc, cmd ); 96 105 return; … … 250 259 } 251 260 261 typedef set_t** (*cmd_set_findhead)( irc_t*, char* ); 262 263 static int cmd_set_real( irc_t *irc, char **cmd, cmd_set_findhead findhead ) 264 { 265 char *set_full = NULL, *set_name = NULL, *tmp; 266 set_t **head; 267 268 if( cmd[1] && g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) 269 { 270 MIN_ARGS( 2, 0 ); 271 set_full = cmd[2]; 272 } 273 else 274 set_full = cmd[1]; 275 276 if( findhead == NULL ) 277 { 278 set_name = set_full; 279 280 head = &irc->set; 281 } 282 else 283 { 284 char *id; 285 286 if( ( tmp = strchr( set_full, '/' ) ) ) 287 { 288 id = g_strndup( set_full, ( tmp - set_full ) ); 289 set_name = tmp + 1; 290 } 291 else 292 { 293 id = g_strdup( set_full ); 294 } 295 296 if( ( head = findhead( irc, id ) ) == NULL ) 297 { 298 g_free( id ); 299 irc_usermsg( irc, "Could not find setting." ); 300 return 0; 301 } 302 g_free( id ); 303 } 304 305 if( cmd[1] && cmd[2] && set_name ) 306 { 307 set_t *s = set_find( head, set_name ); 308 int st; 309 310 /* 311 FIXME: Make these work again. Probably a gross hack. 312 313 if( a->ic && s && s->flags & ACC_SET_OFFLINE_ONLY ) 314 { 315 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "off" ); 316 return 0; 317 } 318 else if( !a->ic && s && s->flags & ACC_SET_ONLINE_ONLY ) 319 { 320 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "on" ); 321 return 0; 322 } 323 */ 324 325 if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) 326 st = set_reset( head, set_name ); 327 else 328 st = set_setstr( head, set_name, cmd[2] ); 329 330 if( set_getstr( head, set_name ) == NULL ) 331 { 332 if( st ) 333 irc_usermsg( irc, "Setting changed successfully" ); 334 else 335 irc_usermsg( irc, "Failed to change setting" ); 336 } 337 else 338 { 339 cmd_showset( irc, head, set_name ); 340 } 341 } 342 else if( set_name ) 343 { 344 cmd_showset( irc, head, set_name ); 345 } 346 else 347 { 348 set_t *s = *head; 349 while( s ) 350 { 351 cmd_showset( irc, &s, s->key ); 352 s = s->next; 353 } 354 } 355 356 return 1; 357 } 358 359 static set_t **cmd_account_set_findhead( irc_t *irc, char *id ) 360 { 361 account_t *a; 362 363 if( ( a = account_get( irc, id ) ) ) 364 return &a->set; 365 else 366 return NULL; 367 } 368 252 369 static void cmd_account( irc_t *irc, char **cmd ) 253 370 { … … 264 381 struct prpl *prpl; 265 382 266 if( cmd[2] == NULL || cmd[3] == NULL || cmd[4] == NULL ) 267 { 268 irc_usermsg( irc, "Not enough parameters" ); 269 return; 270 } 271 272 prpl = find_protocol(cmd[2]); 383 MIN_ARGS( 4 ); 384 385 prpl = find_protocol( cmd[2] ); 273 386 274 387 if( prpl == NULL ) … … 290 403 else if( g_strcasecmp( cmd[1], "del" ) == 0 ) 291 404 { 292 if( !cmd[2] ) 293 { 294 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); 295 } 296 else if( !( a = account_get( irc, cmd[2] ) ) ) 405 MIN_ARGS( 2 ); 406 407 if( !( a = account_get( irc, cmd[2] ) ) ) 297 408 { 298 409 irc_usermsg( irc, "Invalid account" ); … … 422 533 else if( g_strcasecmp( cmd[1], "set" ) == 0 ) 423 534 { 424 char *acc_handle, *set_name = NULL, *tmp; 425 426 if( !cmd[2] ) 427 { 428 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); 429 return; 430 } 431 432 if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) 433 acc_handle = g_strdup( cmd[3] ); 434 else 435 acc_handle = g_strdup( cmd[2] ); 436 437 if( !acc_handle ) 438 { 439 irc_usermsg( irc, "Not enough parameters given (need %d)", 3 ); 440 return; 441 } 442 443 if( ( tmp = strchr( acc_handle, '/' ) ) ) 444 { 445 *tmp = 0; 446 set_name = tmp + 1; 447 } 448 449 if( ( a = account_get( irc, acc_handle ) ) == NULL ) 450 { 451 g_free( acc_handle ); 452 irc_usermsg( irc, "Invalid account" ); 453 return; 454 } 455 456 if( cmd[3] && set_name ) 457 { 458 set_t *s = set_find( &a->set, set_name ); 459 int st; 460 461 if( a->ic && s && s->flags & ACC_SET_OFFLINE_ONLY ) 462 { 463 g_free( acc_handle ); 464 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "off" ); 465 return; 466 } 467 else if( !a->ic && s && s->flags & ACC_SET_ONLINE_ONLY ) 468 { 469 g_free( acc_handle ); 470 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "on" ); 471 return; 472 } 473 474 if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) 475 st = set_reset( &a->set, set_name ); 476 else 477 st = set_setstr( &a->set, set_name, cmd[3] ); 478 479 if( set_getstr( &a->set, set_name ) == NULL ) 480 { 481 if( st ) 482 irc_usermsg( irc, "Setting changed successfully" ); 483 else 484 irc_usermsg( irc, "Failed to change setting" ); 485 } 486 else 487 { 488 cmd_showset( irc, &a->set, set_name ); 489 } 490 } 491 else if( set_name ) 492 { 493 cmd_showset( irc, &a->set, set_name ); 494 } 495 else 496 { 497 set_t *s = a->set; 498 while( s ) 499 { 500 cmd_showset( irc, &s, s->key ); 501 s = s->next; 502 } 503 } 504 505 g_free( acc_handle ); 506 } 507 else 508 { 509 irc_usermsg( irc, "Unknown command: account %s. Please use \x02help commands\x02 to get a list of available commands.", cmd[1] ); 535 MIN_ARGS( 2 ); 536 537 cmd_set_real( irc, cmd + 1, cmd_account_set_findhead ); 538 } 539 else 540 { 541 irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "account", cmd[1] ); 510 542 } 511 543 } … … 837 869 static void cmd_set( irc_t *irc, char **cmd ) 838 870 { 839 char *set_name = cmd[1]; 840 841 if( cmd[1] && cmd[2] ) 842 { 843 int st; 844 845 if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) 846 { 847 st = set_reset( &irc->set, cmd[2] ); 848 set_name = cmd[2]; 849 } 850 else 851 { 852 st = set_setstr( &irc->set, cmd[1], cmd[2] ); 853 } 854 855 /* Normally we just show the variable's new/unchanged 856 value as feedback to the user, but this has always 857 caused confusion when changing the password. Give 858 other feedback instead: */ 859 if( set_getstr( &irc->set, set_name ) == NULL ) 860 { 861 if( st ) 862 irc_usermsg( irc, "Setting changed successfully" ); 863 else 864 irc_usermsg( irc, "Failed to change setting" ); 865 } 866 else 867 { 868 cmd_showset( irc, &irc->set, set_name ); 869 } 870 } 871 else if( set_name ) 872 { 873 cmd_showset( irc, &irc->set, set_name ); 874 875 if( strchr( set_name, '/' ) ) 876 irc_usermsg( irc, "Warning: / found in setting name, you're probably looking for the `account set' command." ); 877 } 878 else 879 { 880 set_t *s = irc->set; 881 while( s ) 882 { 883 cmd_showset( irc, &s, s->key ); 884 s = s->next; 885 } 886 } 871 cmd_set_real( irc, cmd, NULL ); 887 872 } 888 873 … … 1007 992 static void cmd_join_chat( irc_t *irc, char **cmd ) 1008 993 { 994 irc_usermsg( irc, "This command is now obsolete. " 995 "Please try the `chat' command instead." ); 996 } 997 998 static set_t **cmd_chat_set_findhead( irc_t *irc, char *id ) 999 { 1000 struct chat *c; 1001 1002 if( ( c = chat_get( irc, id ) ) ) 1003 return &c->set; 1004 else 1005 return NULL; 1006 } 1007 1008 static void cmd_chat( irc_t *irc, char **cmd ) 1009 { 1010 account_t *acc; 1011 struct chat *c; 1012 1013 if( g_strcasecmp( cmd[1], "add" ) == 0 ) 1014 { 1015 char *channel, *s; 1016 1017 MIN_ARGS( 3 ); 1018 1019 if( !( acc = account_get( irc, cmd[2] ) ) ) 1020 { 1021 irc_usermsg( irc, "Invalid account" ); 1022 return; 1023 } 1024 1025 if( cmd[4] == NULL ) 1026 { 1027 channel = g_strdup( cmd[3] ); 1028 if( ( s = strchr( channel, '@' ) ) ) 1029 *s = 0; 1030 } 1031 else 1032 { 1033 channel = g_strdup( cmd[4] ); 1034 } 1035 1036 if( strchr( CTYPES, channel[0] ) == NULL ) 1037 { 1038 s = g_strdup_printf( "%c%s", CTYPES[0], channel ); 1039 g_free( channel ); 1040 channel = s; 1041 } 1042 1043 if( ( c = chat_add( irc, acc, cmd[3], channel ) ) ) 1044 irc_usermsg( irc, "Chatroom added successfully." ); 1045 else 1046 irc_usermsg( irc, "Could not add chatroom." ); 1047 1048 g_free( channel ); 1049 } 1050 else if( g_strcasecmp( cmd[1], "list" ) == 0 ) 1051 { 1052 int i = 0; 1053 1054 if( strchr( irc->umode, 'b' ) ) 1055 irc_usermsg( irc, "Chatroom list:" ); 1056 1057 for( c = irc->chatrooms; c; c = c->next ) 1058 { 1059 irc_usermsg( irc, "%2d. %s(%s) %s, %s", i, c->acc->prpl->name, 1060 c->acc->user, c->handle, c->channel ); 1061 1062 i ++; 1063 } 1064 irc_usermsg( irc, "End of chatroom list" ); 1065 } 1066 else if( g_strcasecmp( cmd[1], "set" ) == 0 ) 1067 { 1068 cmd_set_real( irc, cmd + 1, cmd_chat_set_findhead ); 1069 } 1070 else if( g_strcasecmp( cmd[1], "del" ) == 0 ) 1071 { 1072 MIN_ARGS( 2 ); 1073 1074 if( ( c = chat_get( irc, cmd[2] ) ) ) 1075 { 1076 chat_del( irc, c ); 1077 } 1078 else 1079 { 1080 irc_usermsg( irc, "Could not remove chat." ); 1081 } 1082 } 1083 else if( g_strcasecmp( cmd[1], "with" ) == 0 ) 1084 { 1085 user_t *u; 1086 1087 MIN_ARGS( 2 ); 1088 1089 if( ( u = user_find( irc, cmd[2] ) ) && u->ic && u->ic->acc->prpl->chat_with ) 1090 { 1091 if( !u->ic->acc->prpl->chat_with( u->ic, u->handle ) ) 1092 { 1093 irc_usermsg( irc, "(Possible) failure while trying to open " 1094 "a groupchat with %s.", u->nick ); 1095 } 1096 } 1097 else 1098 { 1099 irc_usermsg( irc, "Can't open a groupchat with %s.", cmd[2] ); 1100 } 1101 } 1102 else 1103 { 1104 irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); 1105 } 1106 1107 1108 1109 #if 0 1009 1110 account_t *a; 1010 1111 struct im_connection *ic; … … 1032 1133 if( cmd[3] ) 1033 1134 { 1034 if( cmd[3][0] != '#' && cmd[3][0] != '&')1135 if( strchr( CTYPES, cmd[3][0] ) == NULL ) 1035 1136 channel = g_strdup_printf( "&%s", cmd[3] ); 1036 1137 else … … 1075 1176 g_free( channel ); 1076 1177 } 1178 #endif 1077 1179 } 1078 1180 … … 1097 1199 { "qlist", 0, cmd_qlist, 0 }, 1098 1200 { "join_chat", 2, cmd_join_chat, 0 }, 1201 { "chat", 1, cmd_chat, 0 }, 1099 1202 { NULL } 1100 1203 }; -
storage_xml.c
rba3a8a5 rced1e17 54 54 char *current_setting; 55 55 account_t *current_account; 56 struct chat *current_chat; 57 set_t **current_set_head; 56 58 char *given_nick; 57 59 char *given_pass; … … 172 174 173 175 if( ( setting = xml_attr( attr_names, attr_values, "name" ) ) ) 176 { 177 if( xd->current_chat != NULL ) 178 xd->current_set_head = &xd->current_chat->set; 179 else if( xd->current_account != NULL ) 180 xd->current_set_head = &xd->current_account->set; 181 else 182 xd->current_set_head = &xd->irc->set; 183 174 184 xd->current_setting = g_strdup( setting ); 185 } 175 186 else 176 187 g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, … … 194 205 } 195 206 } 207 else if( g_strcasecmp( element_name, "chat" ) == 0 ) 208 { 209 char *handle, *channel; 210 211 handle = xml_attr( attr_names, attr_values, "handle" ); 212 channel = xml_attr( attr_names, attr_values, "channel" ); 213 214 if( xd->current_account && handle && channel ) 215 { 216 xd->current_chat = chat_add( xd->irc, xd->current_account, handle, channel ); 217 } 218 else 219 { 220 g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, 221 "Missing attributes for %s element", element_name ); 222 } 223 } 196 224 else 197 225 { … … 214 242 xd->current_account = NULL; 215 243 } 244 else if( g_strcasecmp( element_name, "chat" ) == 0 ) 245 { 246 xd->current_chat = NULL; 247 } 216 248 } 217 249 … … 220 252 char text[text_len+1]; 221 253 struct xml_parsedata *xd = data; 222 irc_t *irc = xd->irc;223 254 224 255 strncpy( text, text_orig, text_len ); … … 233 264 else if( g_strcasecmp( g_markup_parse_context_get_element( ctx ), "setting" ) == 0 && xd->current_setting ) 234 265 { 235 set_setstr( xd->current_account ? &xd->current_account->set : &irc->set, 236 xd->current_setting, (char*) text ); 266 set_setstr( xd->current_set_head, xd->current_setting, (char*) text ); 237 267 g_free( xd->current_setting ); 238 268 xd->current_setting = NULL; … … 397 427 398 428 for( set = irc->set; set; set = set->next ) 399 if( set->value && set->def)429 if( set->value ) 400 430 if( !xml_printf( fd, 1, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) ) 401 431 goto write_error; … … 406 436 char *pass_b64; 407 437 int pass_len; 438 struct chat *c; 408 439 409 440 pass_len = arc_encode( acc->pass, strlen( acc->pass ), (unsigned char**) &pass_cr, irc->password, 12 ); … … 424 455 425 456 for( set = acc->set; set; set = set->next ) 426 if( set->value && set->def &&!( set->flags & ACC_SET_NOSAVE ) )457 if( set->value && !( set->flags & ACC_SET_NOSAVE ) ) 427 458 if( !xml_printf( fd, 2, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) ) 428 459 goto write_error; … … 438 469 goto write_error; 439 470 471 for( c = irc->chatrooms; c; c = c->next ) 472 { 473 if( c->acc != acc ) 474 continue; 475 476 if( !xml_printf( fd, 2, "<chat handle=\"%s\" channel=\"%s\" type=\"%s\">\n", 477 c->handle, c->channel, "room" ) ) 478 goto write_error; 479 480 for( set = c->set; set; set = set->next ) 481 if( set->value && !( set->flags & ACC_SET_NOSAVE ) ) 482 if( !xml_printf( fd, 3, "<setting name=\"%s\">%s</setting>\n", 483 set->key, set->value ) ) 484 goto write_error; 485 486 if( !xml_printf( fd, 2, "</chat>\n" ) ) 487 goto write_error; 488 } 489 440 490 if( !xml_printf( fd, 1, "</account>\n" ) ) 441 491 goto write_error;
Note: See TracChangeset
for help on using the changeset viewer.