Changes in / [eda0270:6398094]
- Files:
-
- 22 added
- 30 deleted
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
reda0270 r6398094 10 10 11 11 # Program variables 12 objects = account.o bitlbee.o conf.o crypting.o help.o i pc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) unix.o user.o12 objects = account.o bitlbee.o conf.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_text.o unix.o url.o user.o util.o 13 13 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ini.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h url.h user.h protocols/http_client.h protocols/md5.h protocols/nogaim.h protocols/proxy.h protocols/sha.h protocols/ssl_client.h 14 subdirs = protocols lib14 subdirs = protocols 15 15 16 16 # Expansion of variables … … 42 42 43 43 distclean: clean $(subdirs) 44 rm -f Makefile.settings config.h bitlbee.pc44 rm -f Makefile.settings config.h 45 45 find . -name 'DEADJOE' -o -name '*.orig' -o -name '*.rej' -o -name '*~' -exec rm -f {} \; 46 46 -
account.c
reda0270 r6398094 31 31 { 32 32 account_t *a; 33 set_t *s;34 33 35 34 if( irc->accounts ) 36 35 { 37 36 for( a = irc->accounts; a->next; a = a->next ); 38 a = a->next = g_new0 ( account_t, 1 );37 a = a->next = g_new0 ( account_t, 1 ); 39 38 } 40 39 else … … 46 45 a->user = g_strdup( user ); 47 46 a->pass = g_strdup( pass ); 48 a->auto_connect = 1;49 47 a->irc = irc; 50 48 51 s = set_add( &a->set, "auto_connect", "true", set_eval_account, a );52 s->flags |= ACC_SET_NOSAVE;53 54 s = set_add( &a->set, "password", NULL, set_eval_account, a );55 s->flags |= ACC_SET_NOSAVE;56 57 s = set_add( &a->set, "username", NULL, set_eval_account, a );58 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY;59 set_setstr( &a->set, "username", user );60 61 a->nicks = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, g_free );62 63 /* This function adds some more settings (and might want to do more64 things that have to be done now, although I can't think of anything. */65 if( prpl->acc_init )66 prpl->acc_init( a );67 68 49 return( a ); 69 }70 71 char *set_eval_account( set_t *set, char *value )72 {73 account_t *acc = set->data;74 75 /* Double-check: We refuse to edit on-line accounts. */76 if( set->flags & ACC_SET_OFFLINE_ONLY && acc->gc )77 return NULL;78 79 if( strcmp( set->key, "username" ) == 0 )80 {81 g_free( acc->user );82 acc->user = g_strdup( value );83 return value;84 }85 else if( strcmp( set->key, "password" ) == 0 )86 {87 g_free( acc->pass );88 acc->pass = g_strdup( value );89 return NULL; /* password shouldn't be visible in plaintext! */90 }91 else if( strcmp( set->key, "server" ) == 0 )92 {93 g_free( acc->server );94 if( *value )95 acc->server = g_strdup( value );96 else97 acc->server = NULL;98 return value;99 }100 else if( strcmp( set->key, "auto_connect" ) == 0 )101 {102 if( !is_bool( value ) )103 return NULL;104 105 acc->auto_connect = bool2int( value );106 return value;107 }108 109 return NULL;110 50 } 111 51 … … 128 68 for( a = irc->accounts; a; a = a->next ) 129 69 if( a->prpl == proto && 130 a->prpl-> handle_cmp( handle, a->user ) == 0 )70 a->prpl->cmp_buddynames( handle, a->user ) == 0 ) 131 71 ret = a; 132 72 } … … 189 129 } 190 130 191 while( a->set )192 set_del( &a->set, a->set->key );193 194 g_hash_table_destroy( a->nicks );195 196 131 g_free( a->user ); 197 132 g_free( a->pass ); … … 207 142 void account_on( irc_t *irc, account_t *a ) 208 143 { 144 struct aim_user *u; 145 209 146 if( a->gc ) 210 147 { … … 215 152 cancel_auto_reconnect( a ); 216 153 154 u = g_new0 ( struct aim_user, 1 ); 155 u->irc = irc; 156 u->prpl = a->prpl; 157 strncpy( u->username, a->user, sizeof( u->username ) - 1 ); 158 strncpy( u->password, a->pass, sizeof( u->password ) - 1 ); 159 if( a->server) strncpy( u->proto_opt[0], a->server, sizeof( u->proto_opt[0] ) - 1 ); 160 161 a->gc = (struct gaim_connection *) u; /* Bit hackish :-/ */ 217 162 a->reconnect = 0; 218 a->prpl->login( a ); 163 164 a->prpl->login( u ); 219 165 } 220 166 -
account.h
reda0270 r6398094 34 34 char *server; 35 35 36 int auto_connect;37 36 int reconnect; 38 39 set_t *set;40 GHashTable *nicks;41 37 42 38 struct irc *irc; … … 51 47 void account_off( irc_t *irc, account_t *a ); 52 48 53 char *set_eval_account( set_t *set, char *value );54 55 #define ACC_SET_NOSAVE 156 #define ACC_SET_OFFLINE_ONLY 257 #define ACC_SET_ONLINE_ONLY 458 59 49 #endif -
bitlbee.c
reda0270 r6398094 310 310 irc_t *irc; 311 311 312 /* Since we're fork()ing here, let's make sure we won't313 get the same random numbers as the parent/siblings. */314 srand( time( NULL ) ^ getpid() );315 316 312 /* Close the listening socket, we're a client. */ 317 313 close( global.listen_socket ); -
bitlbee.h
reda0270 r6398094 124 124 #include "commands.h" 125 125 #include "account.h" 126 #include "nick.h"127 126 #include "conf.h" 128 127 #include "log.h" … … 131 130 #include "query.h" 132 131 #include "sock.h" 133 #include " misc.h"132 #include "util.h" 134 133 #include "proxy.h" 135 134 -
conf.c
reda0270 r6398094 34 34 #include "ipc.h" 35 35 36 #include "pro xy.h"36 #include "protocols/proxy.h" 37 37 38 38 char *CONF_FILE; … … 55 55 conf->nofork = 0; 56 56 conf->verbose = 0; 57 conf->primary_storage = "xml"; 58 conf->migrate_storage = g_strsplit( "text", ",", -1 ); 57 conf->primary_storage = "text"; 59 58 conf->runmode = RUNMODE_INETD; 60 59 conf->authmode = AUTHMODE_OPEN; … … 323 322 if( g_strcasecmp( ini->section, "defaults" ) == 0 ) 324 323 { 325 set_t *s = set_find( &irc->set, ini->key );324 set_t *s = set_find( irc, ini->key ); 326 325 327 326 if( s ) -
configure
reda0270 r6398094 31 31 32 32 events=glib 33 ldap=auto34 33 ssl=auto 35 34 … … 67 66 68 67 --ipv6=0/1 IPv6 socket support $ipv6 69 70 --ldap=0/1/auto LDAP support $ldap71 68 72 69 --events=... Event handler (glib, libevent) $events … … 144 141 fi 145 142 146 echo CFLAGS+=-I`pwd` -I`pwd`/ lib -I`pwd`/protocols -I. >> Makefile.settings143 echo CFLAGS+=-I`pwd` -I`pwd`/protocols -I. >> Makefile.settings 147 144 148 145 echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings 149 146 150 147 if [ -n "$CC" ]; then 151 CC=$CC148 echo "CC=$CC" >> Makefile.settings; 152 149 elif type gcc > /dev/null 2> /dev/null; then 153 CC=gcc150 echo "CC=gcc" >> Makefile.settings; 154 151 elif type cc > /dev/null 2> /dev/null; then 155 CC=cc152 echo "CC=cc" >> Makefile.settings; 156 153 else 157 154 echo 'Cannot find a C compiler, aborting.' 158 155 exit 1; 159 156 fi 160 161 echo "CC=$CC" >> Makefile.settings;162 157 163 158 if [ -n "$LD" ]; then … … 237 232 } 238 233 239 detect_ldap() 240 { 241 TMPFILE=`mktemp` 242 if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then 243 cat<<EOF>>Makefile.settings 244 EFLAGS+=-lldap 245 CFLAGS+= 246 EOF 247 ldap=1 248 rm -f $TMPFILE 249 ret=1 234 if [ "$msn" = 1 -o "$jabber" = 1 ]; then 235 if [ "$ssl" = "auto" ]; then 236 detect_gnutls 237 if [ "$ret" = "0" ]; then 238 detect_nss 239 fi; 240 elif [ "$ssl" = "gnutls" ]; then 241 detect_gnutls; 242 elif [ "$ssl" = "nss" ]; then 243 detect_nss; 244 elif [ "$ssl" = "openssl" ]; then 245 echo 246 echo 'No detection code exists for OpenSSL. Make sure that you have a complete' 247 echo 'install of OpenSSL (including devel/header files) before reporting' 248 echo 'compilation problems.' 249 echo 250 echo 'Also, keep in mind that the OpenSSL is, according to some people, not' 251 echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better' 252 echo 'supported by us. However, on many BSD machines, OpenSSL can be considered' 253 echo 'part of the operating system, which makes it GPL-compatible.' 254 echo 255 echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2' 256 echo ' http://www.gnome.org/~markmc/openssl-and-the-gpl.html' 257 echo 258 echo 'Please note that distributing a BitlBee binary which links to OpenSSL is' 259 echo 'probably illegal. If you want to create and distribute a binary BitlBee' 260 echo 'package, you really should use GnuTLS or NSS instead.' 261 echo 262 echo 'Also, the OpenSSL license requires us to say this:' 263 echo ' * "This product includes software developed by the OpenSSL Project' 264 echo ' * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"' 265 266 echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings 267 268 ret=1; 269 elif [ "$ssl" = "bogus" ]; then 270 echo 271 echo 'Using bogus SSL code. This will not make the MSN module work, but it will' 272 echo 'allow you to use the Jabber module - although without working SSL support.' 273 274 ret=1; 250 275 else 251 ldap=0 252 ret=0 253 fi 254 } 255 256 if [ "$ssl" = "auto" ]; then 257 detect_gnutls 258 if [ "$ret" = "0" ]; then 259 detect_nss 260 fi 261 elif [ "$ssl" = "gnutls" ]; then 262 detect_gnutls 263 elif [ "$ssl" = "nss" ]; then 264 detect_nss 265 elif [ "$ssl" = "openssl" ]; then 266 echo 267 echo 'No detection code exists for OpenSSL. Make sure that you have a complete' 268 echo 'install of OpenSSL (including devel/header files) before reporting' 269 echo 'compilation problems.' 270 echo 271 echo 'Also, keep in mind that the OpenSSL is, according to some people, not' 272 echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better' 273 echo 'supported by us. However, on many BSD machines, OpenSSL can be considered' 274 echo 'part of the operating system, which makes it GPL-compatible.' 275 echo 276 echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2' 277 echo ' http://www.gnome.org/~markmc/openssl-and-the-gpl.html' 278 echo 279 echo 'Please note that distributing a BitlBee binary which links to OpenSSL is' 280 echo 'probably illegal. If you want to create and distribute a binary BitlBee' 281 echo 'package, you really should use GnuTLS or NSS instead.' 282 echo 283 echo 'Also, the OpenSSL license requires us to say this:' 284 echo ' * "This product includes software developed by the OpenSSL Project' 285 echo ' * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"' 286 287 echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings 288 289 ret=1 290 elif [ "$ssl" = "bogus" ]; then 291 echo 292 echo 'Using bogus SSL code. This means some features have to be disabled.' 293 294 ## Yes, you, at the console! How can you authenticate if you don't have any SSL!? 295 if [ "$msn" = "1" ]; then 296 echo 297 echo 'Real SSL support is necessary for MSN authentication, will build without' 298 echo 'MSN protocol support.' 299 msn=0 276 echo 277 echo 'ERROR: Unknown SSL library specified.' 278 exit 1; 300 279 fi 301 280 302 ret=1 303 else 304 echo 305 echo 'ERROR: Unknown SSL library specified.' 306 exit 1 307 fi 308 309 if [ "$ret" = "0" ]; then 310 echo 311 echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' 312 echo ' Please note that this script doesn'\''t have detection code for OpenSSL,' 313 echo ' so if you want to use that, you have to select it by hand. If you don'\''t' 314 echo ' need SSL support, you can select the "bogus" SSL library. (--ssl=bogus)' 281 if [ "$ret" = "0" ]; then 282 echo 283 echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' 284 echo ' This is necessary for MSN and full Jabber support. To continue,' 285 echo ' install a suitable SSL library or disable MSN support (--msn=0).' 286 echo ' If you want Jabber without SSL support you can try --ssl=bogus.' 287 288 exit 1; 289 fi; 315 290 316 exit 1 317 fi; 318 319 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings 320 321 STORAGES="text xml" 322 323 if [ "$ldap" = "auto" ]; then 324 detect_ldap 325 fi 326 327 if [ "$ldap" = 0 ]; then 328 echo "#undef WITH_LDAP" >> config.h 329 elif [ "$ldap" = 1 ]; then 330 echo "#define WITH_LDAP 1" >> config.h 331 STORAGES="$STORAGES ldap" 332 fi 333 334 for i in $STORAGES; do 335 STORAGE_OBJS="$STORAGE_OBJS storage_$i.o" 336 done 337 echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings 291 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings 292 fi 338 293 339 294 if [ "$strip" = 0 ]; then … … 349 304 elif type strip > /dev/null 2> /dev/null; then 350 305 echo "STRIP=strip" >> Makefile.settings; 306 elif /bin/test -x /usr/ccs/bin/strip; then 307 echo "STRIP=/usr/ccs/bin/strip" >> Makefile.settings; 351 308 else 352 309 echo … … 427 384 if [ "$protocols" = "PROTOCOLS = " ]; then 428 385 echo "WARNING: You haven't selected any communication protocol to compile!" 429 echo " Bitl Bee will run, but you will be unable to connect to IM servers!"386 echo " Bitlbee will run, but you will be unable to connect to IM servers!" 430 387 fi 431 388 … … 462 419 463 420 if [ "$debug" = "1" ]; then 464 echo ' Debugging enabled.' 465 else 466 echo ' Debugging disabled.' 421 echo ' Debugging enabled.'; 422 else 423 echo ' Debugging disabled.'; 467 424 fi 468 425 469 426 if [ "$strip" = "1" ]; then 470 echo ' Binary stripping enabled.' 471 else 472 echo ' Binary stripping disabled.' 473 fi 474 475 echo ' Using event handler: '$events 476 echo ' Using SSL library: '$ssl 477 echo ' Building with these storage backends: '$STORAGES 427 echo ' Binary stripping enabled.'; 428 else 429 echo ' Binary stripping disabled.'; 430 fi 431 432 echo ' Using event handler: '$events; 433 echo ' Using SSL library: '$ssl; 434 435 #if [ "$flood" = "0" ]; then 436 # echo ' Flood protection disabled.'; 437 #else 438 # echo ' Flood protection enabled.'; 439 #fi 478 440 479 441 if [ -n "$protocols" ]; then 480 echo ' Building with these protocols:' $protocols 481 else 482 echo ' Building without IM-protocol support. We wish you a lot of fun...' 483 fi 442 echo ' Building with these protocols:' $protocols; 443 else 444 echo ' Building without IM-protocol support. We wish you a lot of fun...'; 445 fi -
doc/user-guide/commands.xml
reda0270 r6398094 11 11 12 12 <para> 13 Available actions: add, del, list, on, off and set. See <emphasis>help account <action></emphasis> for more information.13 Available actions: add, del, list, on, off. See <emphasis>help account <action></emphasis> for more information. 14 14 </para> 15 15 … … 26 26 27 27 <bitlbee-command name="jabber"> 28 <syntax>account add jabber <handle @server.tld> <password> [<servertag>]</syntax>28 <syntax>account add jabber <handle> <password> [<servertag>]</syntax> 29 29 30 30 <description> 31 31 <para> 32 Note that the servertag argument is optional. You only have to use it if the part after the @ in your handle isn't the hostname of your Jabber server, or if you want to use SSL/connect to a non-standard port number. The format is simple: [<servername>[:<portnumber>][:ssl]]. 33 </para> 34 </description> 35 36 <description> 37 <para> 38 Google Talk uses the Jabber protocol. Please note that Google talk is SSL-only, but officially reachable over both port 5222 and 5223. Usually BitlBee users have to connect via port 5223, for example like this: 32 Note that the servertag argument is optional. You only have to use it if the part after the @ in your handle isn't the hostname of your Jabber server, or if you want to use SSL/connect to a non-standard port number. The format is simple: [<servername>[:<portnumber>][:ssl]]. For example, this is how you can connect to Google Talk: 39 33 </para> 40 34 </description> … … 44 38 <ircline nick="root">Account successfully added</ircline> 45 39 </ircexample> 40 41 <description> 42 <para> 43 Note that Google talk is SSL-only, but officially reachable over both port 5222 and 5223. However, for some people only port 5222 works, for some people only 5223. This is something you'll have to try out. 44 </para> 45 </description> 46 46 </bitlbee-command> 47 47 48 48 <bitlbee-command name="msn"> 49 <syntax>account add msn <handle @server.tld> <password></syntax>49 <syntax>account add msn <handle> <password></syntax> 50 50 51 51 <description> … … 103 103 <description> 104 104 <para> 105 This command will try to log into the specified account. If no account is specified, BitlBee will log into all the accounts that have the auto_connect flag set.105 This command will try to log into the specified account. If no account is specified, BitlBee will log into all the accounts. (Including accounts awaiting a reconnection) 106 106 </para> 107 107 … … 118 118 <description> 119 119 <para> 120 This command disconnects the connection for the specified account. If no account is specified, BitlBee will deactivate all active accounts and cancel all pending reconnects.120 This command disconnects the connection for the specified account. If no account is specified, BitlBee will deactivate all active accounts. (Including accounts awaiting a reconnection) 121 121 </para> 122 122 … … 133 133 <para> 134 134 This command gives you a list of all the accounts known by BitlBee, including the numbers you'll need for most account commands. 135 </para>136 </description>137 </bitlbee-command>138 139 <bitlbee-command name="set">140 <syntax>account set <account id></syntax>141 <syntax>account set <account id>/<setting></syntax>142 <syntax>account set <account id>/<setting> <value></syntax>143 144 <description>145 <para>146 This account 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>.147 </para>148 149 <para>150 For more infomation about a setting, see <emphasis>help set <setting></emphasis>.151 </para>152 153 <para>154 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.155 135 </para> 156 136 </description> … … 296 276 </bitlbee-command> 297 277 298 <bitlbee-setting name="auto_connect" type="boolean">299 <default>True</default>300 301 <description>302 <para>303 With this option enabled, when you identify BitlBee will automatically connect to your accounts, with this disabled it will not do this.304 </para>305 306 <para>307 This setting can also be changed for specific accounts using the <emphasis>account set</emphasis> command. (However, these values will be ignored if the global <emphasis>auto_connect</emphasis> setting is disabled!)308 </para>309 </description>310 </bitlbee-setting>311 312 <bitlbee-setting name="auto_reconnect" type="boolean">313 <default>False</default>314 315 <description>316 <para>317 If an IM-connections breaks, you're supposed to bring it back up yourself. Having BitlBee do this automatically might not always be a good idea, for several reasons. If you want the connections to be restored automatically, you can enable this setting.318 </para>319 320 <para>321 See also the <emphasis>auto_reconnect_delay</emphasis> setting.322 </para>323 </description>324 325 </bitlbee-setting>326 327 <bitlbee-setting name="auto_reconnect_delay" type="integer">328 <default>300</default>329 330 <description>331 <para>332 Tell BitlBee after how many seconds it should attempt to bring an IM-connection back up after a crash. It's not a good idea to set this value very low, it will cause too much useless traffic when an IM-server is down for a few hours.333 </para>334 335 <para>336 See also the <emphasis>auto_reconnect</emphasis> setting.337 </para>338 </description>339 </bitlbee-setting>340 341 <bitlbee-setting name="away_devoice" type="boolean">342 <default>True</default>343 344 <description>345 <para>346 With this option enabled, the root user devoices people when they go away (just away, not offline) and gives the voice back when they come back. You might dislike the voice-floods you'll get if your contact list is huge, so this option can be disabled.347 </para>348 </description>349 </bitlbee-setting>350 351 <bitlbee-setting name="buddy_sendbuffer" type="boolean">352 <default>False</default>353 354 <description>355 <para>356 By default, when you send a message to someone, BitlBee forwards this message to the user immediately. When you paste a large number of lines, the lines will be sent in separate messages, which might not be very nice to read. If you enable this setting, BitlBee will buffer your messages and wait for more data.357 </para>358 359 <para>360 Using the <emphasis>buddy_sendbuffer_delay</emphasis> setting you can specify the number of seconds BitlBee should wait for more data before the complete message is sent.361 </para>362 363 <para>364 Please note that if you remove a buddy from your list (or if the connection to that user drops) and there's still data in the buffer, this data will be lost. BitlBee will not try to send the message to the user in those cases.365 </para>366 </description>367 </bitlbee-setting>368 369 <bitlbee-setting name="buddy_sendbuffer_delay" type="integer">370 <default>200</default>371 372 <description>373 374 <para>375 Tell BitlBee after how many (mili)seconds a buffered message should be sent. Values greater than 5 will be interpreted as miliseconds, 5 and lower as seconds.376 </para>377 378 <para>379 See also the <emphasis>buddy_sendbuffer</emphasis> setting.380 </para>381 </description>382 </bitlbee-setting>383 384 278 <bitlbee-setting name="charset" type="string"> 385 279 <default>iso8859-1</default> … … 398 292 </bitlbee-setting> 399 293 294 <bitlbee-setting name="private" type="boolean"> 295 <default>True</default> 296 297 <description> 298 299 <para> 300 If value is true, messages from users will appear in separate query windows. If false, messages from users will appear in the control channel. 301 </para> 302 303 <para> 304 This setting is remembered (during one session) per-user, this setting only changes the default state. This option takes effect as soon as you reconnect. 305 </para> 306 </description> 307 </bitlbee-setting> 308 309 <bitlbee-setting name="save_on_quit" type="boolean"> 310 <default>True</default> 311 312 <description> 313 <para> 314 If enabled causes BitlBee to save all current settings and account details when user disconnects. This is enabled by default, and these days there's not really a reason to have it disabled anymore. 315 </para> 316 </description> 317 </bitlbee-setting> 318 319 <bitlbee-setting name="strip_html" type="boolean"> 320 <default>True</default> 321 322 <description> 323 <para> 324 Determines what BitlBee should do with HTML in messages. Normally this is turned on and HTML will be stripped from messages, if BitlBee thinks there is HTML. 325 </para> 326 <para> 327 If BitlBee fails to detect this sometimes (most likely in AIM messages over an ICQ connection), you can set this setting to <emphasis>always</emphasis>, but this might sometimes accidentally strip non-HTML things too. 328 </para> 329 </description> 330 </bitlbee-setting> 331 400 332 <bitlbee-setting name="debug" type="boolean"> 401 333 <default>False</default> … … 408 340 </bitlbee-setting> 409 341 410 <bitlbee-setting name="default_target" type="string"> 411 <default>root</default> 412 <possible-values>root, last</possible-values> 413 414 <description> 415 <para> 416 With this value set to <emphasis>root</emphasis>, lines written in the control channel without any nickname in front of them will be interpreted as commands. If you want BitlBee to send those lines to the last person you addressed in the control channel, set this to <emphasis>last</emphasis>. 417 </para> 418 </description> 419 </bitlbee-setting> 420 421 <bitlbee-setting name="display_name" type="string"> 422 <description> 423 <para> 424 Currently only available for MSN connections. This setting allows you to read and change your "friendly name" for this connection. Since this is a server-side setting, it can't be changed when the account is off-line. 425 </para> 426 </description> 427 </bitlbee-setting> 428 429 <bitlbee-setting name="display_namechanges" type="boolean"> 342 <bitlbee-setting name="to_char" type="string"> 343 <default>": "</default> 344 345 <description> 346 347 <para> 348 It's customary that messages meant for one specific person on an IRC channel are prepended by his/her alias followed by a colon ':'. BitlBee does this by default. If you prefer a different character, you can set it using <emphasis>set to_char</emphasis>. 349 </para> 350 351 <para> 352 Please note that this setting is only used for incoming messages. For outgoing messages you can use ':' (colon) or ',' to separate the destination nick from the message, and this is not configurable. 353 </para> 354 </description> 355 </bitlbee-setting> 356 357 <bitlbee-setting name="typing_notice" type="boolean"> 430 358 <default>False</default> 431 359 432 <para> 433 With this option enabled, root will inform you when someone in your buddy list changes his/her "friendly name". 434 </para> 360 <description> 361 <para> 362 Sends you a /notice when a user starts typing a message (if the protocol supports it, MSN for example). This is a bug, not a feature. (But please don't report it.. ;-) You don't want to use it. Really. In fact the typing-notification is just one of the least useful 'innovations' ever. It's just there because some guy will probably ask me about it anyway. ;-) 363 </para> 364 </description> 365 </bitlbee-setting> 366 367 <bitlbee-setting name="ops" type="string"> 368 <default>both</default> 369 <possible-values>both, root, user, none</possible-values> 370 371 <description> 372 <para> 373 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can change these states using this setting. 374 </para> 375 376 <para> 377 The value "both" means both user and root get ops. "root" means, well, just root. "user" means just the user. "none" means nobody will get operator status. 378 </para> 379 </description> 380 </bitlbee-setting> 381 382 <bitlbee-setting name="away_devoice" type="boolean"> 383 <default>True</default> 384 385 <description> 386 <para> 387 With this option enabled, the root user devoices people when they go away (just away, not offline) and gives the voice back when they come back. You might dislike the voice-floods you'll get if your contact list is huge, so this option can be disabled. 388 </para> 389 </description> 435 390 </bitlbee-setting> 436 391 … … 462 417 </bitlbee-setting> 463 418 464 <bitlbee-setting name=" lcnicks" type="boolean">419 <bitlbee-setting name="auto_connect" type="boolean"> 465 420 <default>True</default> 466 421 467 422 <description> 468 423 <para> 469 Hereby you can change whether you want all lower case nick names or leave the case as it intended by your peer. 470 </para> 471 </description> 472 473 </bitlbee-setting> 474 475 <bitlbee-setting name="ops" type="string"> 476 <default>both</default> 477 <possible-values>both, root, user, none</possible-values> 478 479 <description> 480 <para> 481 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can change these states using this setting. 482 </para> 483 484 <para> 485 The value "both" means both user and root get ops. "root" means, well, just root. "user" means just the user. "none" means nobody will get operator status. 486 </para> 487 </description> 424 With this option enabled, when you identify BitlBee will automatically connect to your accounts, with this disabled it will not do this. 425 </para> 426 </description> 427 </bitlbee-setting> 428 429 <bitlbee-setting name="auto_reconnect" type="boolean"> 430 <default>False</default> 431 432 <description> 433 <para> 434 If an IM-connections breaks, you're supposed to bring it back up yourself. Having BitlBee do this automatically might not always be a good idea, for several reasons. If you want the connections to be restored automatically, you can enable this setting. 435 </para> 436 437 <para> 438 See also the <emphasis>auto_reconnect_delay</emphasis> setting. 439 </para> 440 </description> 441 442 </bitlbee-setting> 443 444 <bitlbee-setting name="auto_reconnect_delay" type="integer"> 445 <default>300</default> 446 447 <description> 448 449 <para> 450 Tell BitlBee after how many seconds it should attempt to bring an IM-connection back up after a crash. It's not a good idea to set this value very low, it will cause too much useless traffic when an IM-server is down for a few hours. 451 </para> 452 453 <para> 454 See also the <emphasis>auto_reconnect</emphasis> setting. 455 </para> 456 </description> 457 </bitlbee-setting> 458 459 <bitlbee-setting name="buddy_sendbuffer" type="boolean"> 460 <default>False</default> 461 462 <description> 463 464 <para> 465 By default, when you send a message to someone, BitlBee forwards this message to the user immediately. When you paste a large number of lines, the lines will be sent in separate messages, which might not be very nice to read. If you enable this setting, BitlBee will buffer your messages and wait for more data. 466 </para> 467 468 <para> 469 Using the <emphasis>buddy_sendbuffer_delay</emphasis> setting you can specify the number of seconds BitlBee should wait for more data before the complete message is sent. 470 </para> 471 472 <para> 473 Please note that if you remove a buddy from your list (or if the connection to that user drops) and there's still data in the buffer, this data will be lost. BitlBee will not try to send the message to the user in those cases. 474 </para> 475 </description> 476 477 </bitlbee-setting> 478 479 <bitlbee-setting name="buddy_sendbuffer_delay" type="integer"> 480 <default>200</default> 481 482 <description> 483 484 <para> 485 Tell BitlBee after how many (mili)seconds a buffered message should be sent. Values greater than 5 will be interpreted as miliseconds, 5 and lower as seconds. 486 </para> 487 488 <para> 489 See also the <emphasis>buddy_sendbuffer</emphasis> setting. 490 </para> 491 </description> 492 493 </bitlbee-setting> 494 495 <bitlbee-setting name="default_target" type="string"> 496 <default>root</default> 497 <possible-values>root, last</possible-values> 498 499 <description> 500 <para> 501 With this value set to <emphasis>root</emphasis>, lines written in the control channel without any nickname in front of them will be interpreted as commands. If you want BitlBee to send those lines to the last person you addressed in the control channel, set this to <emphasis>last</emphasis>. 502 </para> 503 </description> 504 505 </bitlbee-setting> 506 507 <bitlbee-setting name="display_namechanges" type="boolean"> 508 <default>False</default> 509 510 <para> 511 With this option enabled, root will inform you when someone in your buddy list changes his/her "friendly name". 512 </para> 488 513 </bitlbee-setting> 489 514 … … 491 516 <description> 492 517 <para> 493 Use this global setting to change your "NickServ" password. 494 </para> 495 496 <para> 497 This setting is also available for all IM accounts to change the password BitlBee uses to connect to the service. 498 </para> 499 500 <para> 501 Note that BitlBee will always say this setting is empty. This doesn't mean there is no password, it just means that, for security reasons, BitlBee stores passwords somewhere else so they can't just be retrieved in plain text. 502 </para> 503 </description> 504 </bitlbee-setting> 505 506 <bitlbee-setting name="port" type="integer"> 507 <description> 508 <para> 509 Currently only available for Jabber connections. Specifies the port number to connect to. Usually this should be set to 5222, or 5223 for SSL-connections. 510 </para> 511 </description> 512 </bitlbee-setting> 513 514 <bitlbee-setting name="private" type="boolean"> 515 <default>True</default> 516 517 <description> 518 <para> 519 If value is true, messages from users will appear in separate query windows. If false, messages from users will appear in the control channel. 520 </para> 521 522 <para> 523 This setting is remembered (during one session) per-user, this setting only changes the default state. This option takes effect as soon as you reconnect. 518 Use this setting to change your "NickServ" password. 524 519 </para> 525 520 </description> … … 541 536 </bitlbee-setting> 542 537 543 <bitlbee-setting name="resource" type="string"> 544 <default>BitlBee</default> 545 546 <description> 547 <para> 548 Can be set for Jabber connections. You can use this to connect to your Jabber account from multiple clients at once, with every client using a different resource string. 549 </para> 550 </description> 551 </bitlbee-setting> 552 553 <bitlbee-setting name="save_on_quit" type="boolean"> 538 <bitlbee-setting name="lcnicks" type="boolean"> 554 539 <default>True</default> 555 540 556 541 <description> 557 542 <para> 558 If enabled causes BitlBee to save all current settings and account details when user disconnects. This is enabled by default, and these days there's not really a reason to have it disabled anymore. 559 </para> 560 </description> 561 </bitlbee-setting> 562 563 <bitlbee-setting name="server" type="string"> 564 <description> 565 <para> 566 Can be set for Jabber- and OSCAR-connections. For OSCAR, this must be set to <emphasis>login.icq.com</emphasis> if it's an ICQ connection, or <emphasis>login.oscar.aol.com</emphasis> if it's an AIM connection. For Jabber, you have to set this if the servername isn't equal to the part after the @ in the Jabber handle. 567 </para> 568 </description> 569 </bitlbee-setting> 570 571 <bitlbee-setting name="ssl" type="boolean"> 572 <default>False</default> 573 574 <description> 575 <para> 576 Currently only available for Jabber connections. Set this to true if the server accepts SSL connections. 577 </para> 578 </description> 579 </bitlbee-setting> 580 581 <bitlbee-setting name="strip_html" type="boolean"> 582 <default>True</default> 583 584 <description> 585 <para> 586 Determines what BitlBee should do with HTML in messages. Normally this is turned on and HTML will be stripped from messages, if BitlBee thinks there is HTML. 587 </para> 588 <para> 589 If BitlBee fails to detect this sometimes (most likely in AIM messages over an ICQ connection), you can set this setting to <emphasis>always</emphasis>, but this might sometimes accidentally strip non-HTML things too. 590 </para> 591 </description> 592 </bitlbee-setting> 593 594 <bitlbee-setting name="to_char" type="string"> 595 <default>": "</default> 596 597 <description> 598 <para> 599 It's customary that messages meant for one specific person on an IRC channel are prepended by his/her alias followed by a colon ':'. BitlBee does this by default. If you prefer a different character, you can set it using <emphasis>set to_char</emphasis>. 600 </para> 601 602 <para> 603 Please note that this setting is only used for incoming messages. For outgoing messages you can use ':' (colon) or ',' to separate the destination nick from the message, and this is not configurable. 604 </para> 605 </description> 606 </bitlbee-setting> 607 608 <bitlbee-setting name="typing_notice" type="boolean"> 609 <default>False</default> 610 611 <description> 612 <para> 613 Sends you a /notice when a user starts typing a message (if the protocol supports it, MSN for example). This is a bug, not a feature. (But please don't report it.. ;-) You don't want to use it. Really. In fact the typing-notification is just one of the least useful 'innovations' ever. It's just there because some guy will probably ask me about it anyway. ;-) 614 </para> 615 </description> 543 Hereby you can change whether you want all lower case nick names or leave the case as it intended by your peer. 544 </para> 545 </description> 546 616 547 </bitlbee-setting> 617 548 -
doc/user-guide/help.xsl
reda0270 r6398094 7 7 version="1.1"> 8 8 9 <xsl:output method="text" encoding=" utf-8" standalone="yes"/>9 <xsl:output method="text" encoding="iso-8859-1" standalone="yes"/> 10 10 <xsl:strip-space elements="*"/> 11 11 -
irc.c
reda0270 r6398094 33 33 GSList *irc_connection_list = NULL; 34 34 35 static char *passchange( irc_t *irc, void *set, char *value ) 36 { 37 irc_setpass( irc, value ); 38 irc_usermsg( irc, "Password successfully changed" ); 39 return NULL; 35 static char *passchange (irc_t *irc, void *set, char *value) 36 { 37 irc_setpass (irc, value); 38 return (NULL); 40 39 } 41 40 … … 124 123 irc_connection_list = g_slist_append( irc_connection_list, irc ); 125 124 126 set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc);127 set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc);128 set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc);129 set_add( &irc->set, "auto_reconnect_delay", "300", set_eval_int, irc);130 set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc);131 set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc);132 set_add( &irc->set, "charset", "iso8859-1", set_eval_charset, irc);133 set_add( &irc->set, "debug", "false", set_eval_bool, irc);134 set_add( &irc->set, "default_target", "root", NULL, irc);135 set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc);136 set_add( &irc->set, "handle_unknown", "root", NULL, irc);137 set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc);138 set_add( &irc->set, "ops", "both", set_eval_ops, irc);139 set_add( &irc->set, "password", NULL, passchange, irc);140 set_add( &irc->set, "private", "true", set_eval_bool, irc);141 set_add( &irc->set, "query_order", "lifo", NULL, irc);142 set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc);143 set_add( &irc->set, "strip_html", "true", NULL, irc);144 set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc);145 set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc);125 set_add( irc, "away_devoice", "true", set_eval_away_devoice ); 126 set_add( irc, "auto_connect", "true", set_eval_bool ); 127 set_add( irc, "auto_reconnect", "false", set_eval_bool ); 128 set_add( irc, "auto_reconnect_delay", "300", set_eval_int ); 129 set_add( irc, "buddy_sendbuffer", "false", set_eval_bool ); 130 set_add( irc, "buddy_sendbuffer_delay", "200", set_eval_int ); 131 set_add( irc, "charset", "iso8859-1", set_eval_charset ); 132 set_add( irc, "debug", "false", set_eval_bool ); 133 set_add( irc, "default_target", "root", NULL ); 134 set_add( irc, "display_namechanges", "false", set_eval_bool ); 135 set_add( irc, "handle_unknown", "root", NULL ); 136 set_add( irc, "lcnicks", "true", set_eval_bool ); 137 set_add( irc, "ops", "both", set_eval_ops ); 138 set_add( irc, "private", "true", set_eval_bool ); 139 set_add( irc, "query_order", "lifo", NULL ); 140 set_add( irc, "save_on_quit", "true", set_eval_bool ); 141 set_add( irc, "strip_html", "true", NULL ); 142 set_add( irc, "to_char", ": ", set_eval_to_char ); 143 set_add( irc, "typing_notice", "false", set_eval_bool ); 144 set_add( irc, "password", NULL, passchange); 146 145 147 146 conf_loaddefaults( irc ); … … 207 206 void irc_free(irc_t * irc) 208 207 { 209 account_t *account ;208 account_t *account, *accounttmp; 210 209 user_t *user, *usertmp; 210 nick_t *nick, *nicktmp; 211 211 help_t *helpnode, *helpnodetmp; 212 set_t *setnode, *setnodetmp; 212 213 213 214 log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd ); 214 215 215 if( irc->status & USTATUS_IDENTIFIED && set_getint( &irc->set, "save_on_quit" ) )216 if( irc->status & USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) ) 216 217 if( storage_save( irc, TRUE ) != STORAGE_OK ) 217 218 irc_usermsg( irc, "Error while saving settings!" ); … … 253 254 query_del(irc, irc->queries); 254 255 255 while (irc->accounts) 256 account_del(irc, irc->accounts); 257 258 while (irc->set) 259 set_del(&irc->set, irc->set->key); 256 if (irc->accounts != NULL) { 257 account = irc->accounts; 258 while (account != NULL) { 259 g_free(account->user); 260 g_free(account->pass); 261 g_free(account->server); 262 accounttmp = account; 263 account = account->next; 264 g_free(accounttmp); 265 } 266 } 260 267 261 268 if (irc->users != NULL) { … … 282 289 g_hash_table_destroy(irc->watches); 283 290 291 if (irc->nicks != NULL) { 292 nick = irc->nicks; 293 while (nick != NULL) { 294 g_free(nick->nick); 295 g_free(nick->handle); 296 297 nicktmp = nick; 298 nick = nick->next; 299 g_free(nicktmp); 300 } 301 } 284 302 if (irc->help != NULL) { 285 303 helpnode = irc->help; … … 292 310 } 293 311 } 312 if (irc->set != NULL) { 313 setnode = irc->set; 314 while (setnode != NULL) { 315 g_free(setnode->key); 316 g_free(setnode->def); 317 g_free(setnode->value); 318 319 setnodetmp = setnode; 320 setnode = setnode->next; 321 g_free(setnodetmp); 322 } 323 } 294 324 g_free(irc); 295 325 … … 302 332 void irc_setpass (irc_t *irc, const char *pass) 303 333 { 304 g_free (irc->password);334 if (irc->password) g_free (irc->password); 305 335 306 336 if (pass) { 307 337 irc->password = g_strdup (pass); 338 irc_usermsg (irc, "Password successfully changed"); 308 339 } else { 309 340 irc->password = NULL; … … 336 367 } 337 368 338 if( ( cs = set_getstr( &irc->set, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )369 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 339 370 { 340 371 conv[IRC_MAX_LINE] = 0; … … 556 587 557 588 strip_newlines( line ); 558 if( ( cs = set_getstr( &irc->set, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )589 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 559 590 { 560 591 char conv[IRC_MAX_LINE+1]; … … 639 670 } 640 671 641 if( u->gc && !u->away && set_get bool( &irc->set, "away_devoice" ) )672 if( u->gc && !u->away && set_getint( irc, "away_devoice" ) ) 642 673 strcat( namelist, "+" ); 643 674 else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) || … … 652 683 { 653 684 GList *l; 654 char *ops = set_getstr( &irc->set, "ops" );655 685 656 686 /* root and the user aren't in the channel userlist but should … … 900 930 { 901 931 char *nick, *s; 902 char reason[ 128];932 char reason[64]; 903 933 904 934 if( u->gc && u->gc->flags & OPT_LOGGING_OUT ) 905 935 { 906 if( u->gc-> acc->server)936 if( u->gc->user->proto_opt[0][0] ) 907 937 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, 908 u->gc-> acc->server);938 u->gc->user->proto_opt[0] ); 909 939 else if( ( s = strchr( u->gc->username, '@' ) ) ) 910 940 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, … … 912 942 else 913 943 g_snprintf( reason, sizeof( reason ), "%s %s.%s", irc->myhost, 914 u->gc-> acc->prpl->name, irc->myhost );944 u->gc->prpl->name, irc->myhost ); 915 945 916 946 /* proto_opt might contain garbage after the : */ … … 988 1018 else if( g_strncasecmp( s + 1, "TYPING", 6 ) == 0 ) 989 1019 { 990 if( u && u->gc && u->gc-> acc->prpl->send_typing && strlen( s ) >= 10 )1020 if( u && u->gc && u->gc->prpl->send_typing && strlen( s ) >= 10 ) 991 1021 { 992 1022 time_t current_typing_notice = time( NULL ); … … 994 1024 if( current_typing_notice - u->last_typing_notice >= 5 ) 995 1025 { 996 u->gc-> acc->prpl->send_typing( u->gc, u->handle, s[8] == '1' );1026 u->gc->prpl->send_typing( u->gc, u->handle, s[8] == '1' ); 997 1027 u->last_typing_notice = current_typing_notice; 998 1028 } … … 1027 1057 } 1028 1058 } 1029 else if( c && c->gc && c->gc-> acc && c->gc->acc->prpl )1059 else if( c && c->gc && c->gc->prpl ) 1030 1060 { 1031 1061 return( bim_chat_msg( c->gc, c->id, s ) ); … … 1059 1089 if( !u || !u->gc ) return; 1060 1090 1061 if( set_getint( &irc->set, "buddy_sendbuffer" ) && set_getint( &irc->set, "buddy_sendbuffer_delay" ) > 0 )1091 if( set_getint( irc, "buddy_sendbuffer" ) && set_getint( irc, "buddy_sendbuffer_delay" ) > 0 ) 1062 1092 { 1063 1093 int delay; … … 1086 1116 strcat( u->sendbuf, "\n" ); 1087 1117 1088 delay = set_getint( &irc->set, "buddy_sendbuffer_delay" );1118 delay = set_getint( irc, "buddy_sendbuffer_delay" ); 1089 1119 if( delay <= 5 ) 1090 1120 delay *= 1000; … … 1151 1181 int len = strlen( irc->nick) + 3; 1152 1182 prefix = g_new (char, len ); 1153 g_snprintf( prefix, len, "%s%s", irc->nick, set_getstr( &irc->set, "to_char" ) );1183 g_snprintf( prefix, len, "%s%s", irc->nick, set_getstr( irc, "to_char" ) ); 1154 1184 prefix[len-1] = 0; 1155 1185 } -
irc.h
reda0270 r6398094 98 98 99 99 #include "user.h" 100 //#include "nick.h"100 #include "nick.h" 101 101 102 102 extern GSList *irc_connection_list; -
irc_commands.c
reda0270 r6398094 150 150 irc_part( irc, u, c->channel ); 151 151 152 if( c->gc )152 if( c->gc && c->gc->prpl ) 153 153 { 154 154 c->joined = 0; 155 c->gc-> acc->prpl->chat_leave( c->gc, c->id );155 c->gc->prpl->chat_leave( c->gc, c->id ); 156 156 } 157 157 } … … 173 173 user_t *u = user_find( irc, cmd[1] + 1 ); 174 174 175 if( u && u->gc && u->gc-> acc->prpl->chat_open )175 if( u && u->gc && u->gc->prpl && u->gc->prpl->chat_open ) 176 176 { 177 177 irc_reply( irc, 403, "%s :Initializing groupchat in a different channel", cmd[1] ); 178 178 179 if( !u->gc-> acc->prpl->chat_open( u->gc, u->handle ) )179 if( !u->gc->prpl->chat_open( u->gc, u->handle ) ) 180 180 { 181 181 irc_usermsg( irc, "Could not open a groupchat with %s.", u->nick ); … … 205 205 206 206 if( u && c && ( u->gc == c->gc ) ) 207 if( c->gc && c->gc-> acc->prpl->chat_invite )208 { 209 c->gc-> acc->prpl->chat_invite( c->gc, c->id, "", u->handle );207 if( c->gc && c->gc->prpl && c->gc->prpl->chat_invite ) 208 { 209 c->gc->prpl->chat_invite( c->gc, c->id, "", u->handle ); 210 210 irc_reply( irc, 341, "%s %s", nick, channel ); 211 211 return; … … 230 230 { 231 231 unsigned int i; 232 char *t = set_getstr( &irc->set, "default_target" );232 char *t = set_getstr( irc, "default_target" ); 233 233 234 234 if( g_strcasecmp( t, "last" ) == 0 && irc->last_target ) … … 477 477 478 478 if( u->gc ) 479 irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc->acc->user, 480 u->gc->acc->server && *u->gc->acc->server ? u->gc->acc->server : "", 481 u->gc->acc->prpl->name ); 479 irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc->user->username, 480 *u->gc->user->proto_opt[0] ? u->gc->user->proto_opt[0] : "", u->gc->prpl->name ); 482 481 else 483 482 irc_reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO ); -
nick.c
reda0270 r6398094 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-200 6Wilmer van der Gaast and others *4 * Copyright 2002-2004 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 27 27 #include "bitlbee.h" 28 28 29 /* Store handles in lower case and strip spaces, because AIM is braindead. */ 30 static char *clean_handle( const char *orig ) 31 { 32 char *new = g_malloc( strlen( orig ) + 1 ); 33 int i = 0; 34 35 do { 36 if (*orig != ' ') 37 new[i++] = tolower( *orig ); 38 } 39 while (*(orig++)); 40 41 return new; 42 } 43 44 void nick_set( account_t *acc, const char *handle, const char *nick ) 45 { 46 char *store_handle, *store_nick = g_malloc( MAX_NICK_LENGTH + 1 ); 47 48 store_handle = clean_handle( handle ); 49 strncpy( store_nick, nick, MAX_NICK_LENGTH ); 50 nick_strip( store_nick ); 51 52 g_hash_table_replace( acc->nicks, store_handle, store_nick ); 53 } 54 55 char *nick_get( account_t *acc, const char *handle, const char *realname ) 29 void nick_set( irc_t *irc, const char *handle, struct prpl *proto, const char *nick ) 30 { 31 nick_t *m = NULL, *n = irc->nicks; 32 33 while( n ) 34 { 35 if( ( g_strcasecmp( n->handle, handle ) == 0 ) && n->proto == proto ) 36 { 37 g_free( n->nick ); 38 n->nick = nick_dup( nick ); 39 nick_strip( n->nick ); 40 41 return; 42 } 43 n = ( m = n )->next; // :-P 44 } 45 46 if( m ) 47 n = m->next = g_new0( nick_t, 1 ); 48 else 49 n = irc->nicks = g_new0( nick_t, 1 ); 50 51 n->handle = g_strdup( handle ); 52 n->proto = proto; 53 n->nick = nick_dup( nick ); 54 55 nick_strip( n->nick ); 56 } 57 58 char *nick_get( irc_t *irc, const char *handle, struct prpl *proto, const char *realname ) 56 59 { 57 60 static char nick[MAX_NICK_LENGTH+1]; 58 char *store_handle, *found_nick;61 nick_t *n = irc->nicks; 59 62 int inf_protection = 256; 60 63 61 64 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 62 65 63 store_handle = clean_handle( handle ); 64 /* Find out if we stored a nick for this person already. If not, try 65 to generate a sane nick automatically. */ 66 if( ( found_nick = g_hash_table_lookup( acc->nicks, store_handle ) ) ) 67 { 68 strncpy( nick, found_nick, MAX_NICK_LENGTH ); 69 } 70 else 66 while( n && !*nick ) 67 if( ( n->proto == proto ) && ( g_strcasecmp( n->handle, handle ) == 0 ) ) 68 strcpy( nick, n->nick ); 69 else 70 n = n->next; 71 72 if( !n ) 71 73 { 72 74 char *s; … … 84 86 85 87 nick_strip( nick ); 86 if ( set_getbool( &acc->irc->set, "lcnicks" ) )88 if (set_getint(irc, "lcnicks")) 87 89 nick_lc( nick ); 88 90 } 89 g_free( store_handle ); 90 91 /* Now, find out if the nick is already in use at the moment, and make 92 subtle changes to make it unique. */ 93 while( !nick_ok( nick ) || user_find( acc->irc, nick ) ) 91 92 while( !nick_ok( nick ) || user_find( irc, nick ) ) 94 93 { 95 94 if( strlen( nick ) < ( MAX_NICK_LENGTH - 1 ) ) … … 107 106 int i; 108 107 109 irc_usermsg( acc->irc, "WARNING: Almost had an infinite loop in nick_get()! "110 111 112 113 114 115 irc_usermsg( acc->irc, "Trying to get a sane nick for handle %s", handle );108 irc_usermsg( irc, "WARNING: Almost had an infinite loop in nick_get()! " 109 "This used to be a fatal BitlBee bug, but we tried to fix it. " 110 "This message should *never* appear anymore. " 111 "If it does, please *do* send us a bug report! " 112 "Please send all the following lines in your report:" ); 113 114 irc_usermsg( irc, "Trying to get a sane nick for handle %s", handle ); 116 115 for( i = 0; i < MAX_NICK_LENGTH; i ++ ) 117 irc_usermsg( acc->irc, "Char %d: %c/%d", i, nick[i], nick[i] );118 119 irc_usermsg( acc->irc, "FAILED. Returning an insane nick now. Things might break. "120 121 116 irc_usermsg( irc, "Char %d: %c/%d", i, nick[i], nick[i] ); 117 118 irc_usermsg( irc, "FAILED. Returning an insane nick now. Things might break. " 119 "Good luck, and please don't forget to paste the lines up here " 120 "in #bitlbee on OFTC or in a mail to wilmer@gaast.net" ); 122 121 123 122 g_snprintf( nick, MAX_NICK_LENGTH + 1, "xx%x", rand() ); … … 127 126 } 128 127 129 return nick; 130 } 131 132 void nick_del( account_t *acc, const char *handle ) 133 { 134 g_hash_table_remove( acc->nicks, handle ); 128 return( nick ); 129 } 130 131 void nick_del( irc_t *irc, const char *nick ) 132 { 133 nick_t *l = NULL, *n = irc->nicks; 134 135 while( n ) 136 { 137 if( g_strcasecmp( n->nick, nick ) == 0 ) 138 { 139 if( l ) 140 l->next = n->next; 141 else 142 irc->nicks = n->next; 143 144 g_free( n->handle ); 145 g_free( n->nick ); 146 g_free( n ); 147 148 break; 149 } 150 n = (l=n)->next; 151 } 135 152 } 136 153 -
nick.h
reda0270 r6398094 24 24 */ 25 25 26 void nick_set( account_t *acc, const char *handle, const char *nick ); 27 char *nick_get( account_t *acc, const char *handle, const char *realname ); 28 void nick_del( account_t *acc, const char *handle ); 26 typedef struct __NICK 27 { 28 char *handle; 29 struct prpl *proto; 30 char *nick; 31 struct __NICK *next; 32 } nick_t; 33 34 void nick_set( irc_t *irc, const char *handle, struct prpl *proto, const char *nick ); 35 char *nick_get( irc_t *irc, const char *handle, struct prpl *proto, const char *realname ); 36 void nick_del( irc_t *irc, const char *nick ); 29 37 void nick_strip( char *nick ); 30 38 -
protocols/Makefile
reda0270 r6398094 10 10 11 11 # [SH] Program variables 12 objects = nogaim.o12 objects = $(EVENT_HANDLER) http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT) 13 13 14 14 # [SH] The next two lines should contain the directory name (in $(subdirs)) -
protocols/jabber/jabber.c
reda0270 r6398094 561 561 static void gjab_start(gjconn gjc) 562 562 { 563 account_t *acc;563 struct aim_user *user; 564 564 int port = -1, ssl = 0; 565 char *server = NULL ;565 char *server = NULL, *s; 566 566 567 567 if (!gjc || gjc->state != JCONN_STATE_OFF) 568 568 return; 569 569 570 acc = GJ_GC(gjc)->acc; 571 server = acc->server; 572 port = set_getint(&acc->set, "port"); 573 ssl = set_getbool(&acc->set, "ssl"); 570 user = GJ_GC(gjc)->user; 571 if (*user->proto_opt[0]) { 572 /* If there's a dot, assume there's a hostname in the beginning */ 573 if (strchr(user->proto_opt[0], '.')) { 574 server = g_strdup(user->proto_opt[0]); 575 if ((s = strchr(server, ':'))) 576 *s = 0; 577 } 578 579 /* After the hostname, there can be a port number */ 580 s = strchr(user->proto_opt[0], ':'); 581 if (s && isdigit(s[1])) 582 sscanf(s + 1, "%d", &port); 583 584 /* And if there's the string ssl, the user wants an SSL-connection */ 585 if (strstr(user->proto_opt[0], ":ssl") || g_strcasecmp(user->proto_opt[0], "ssl") == 0) 586 ssl = 1; 587 } 574 588 575 if (port < JABBER_PORT_MIN || port > JABBER_PORT_MAX) { 589 if (port == -1 && !ssl) 590 port = DEFAULT_PORT; 591 else if (port == -1 && ssl) 592 port = DEFAULT_PORT_SSL; 593 else if (port < JABBER_PORT_MIN || port > JABBER_PORT_MAX) { 576 594 serv_got_crap(GJ_GC(gjc), "For security reasons, the Jabber port number must be in the %d-%d range.", JABBER_PORT_MIN, JABBER_PORT_MAX); 577 595 STATE_EVT(JCONN_STATE_OFF) … … 596 614 } 597 615 598 if (!acc->gc || (gjc->fd < 0)) { 616 g_free(server); 617 618 if (!user->gc || (gjc->fd < 0)) { 599 619 STATE_EVT(JCONN_STATE_OFF) 600 620 return; … … 1496 1516 } 1497 1517 1498 static void jabber_acc_init(account_t *acc) 1499 { 1500 set_t *s; 1501 1502 s = set_add( &acc->set, "port", "5222", set_eval_int, acc ); 1503 s->flags |= ACC_SET_OFFLINE_ONLY; 1504 1505 s = set_add( &acc->set, "resource", "BitlBee", NULL, acc ); 1506 s->flags |= ACC_SET_OFFLINE_ONLY; 1507 1508 s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); 1509 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 1510 1511 s = set_add( &acc->set, "ssl", "false", set_eval_bool, acc ); 1512 s->flags |= ACC_SET_OFFLINE_ONLY; 1513 } 1514 1515 static void jabber_login(account_t *acc) 1516 { 1517 struct gaim_connection *gc; 1518 struct jabber_data *jd; 1519 char *resource, *loginname; 1520 1521 /* Time to move some data/things from the old syntax to the new one: */ 1522 if (acc->server) { 1523 char *s, *tmp_server; 1524 int port; 1525 1526 if (g_strcasecmp(acc->server, "ssl") == 0) { 1527 set_setstr(&acc->set, "server", ""); 1528 set_setint(&acc->set, "port", DEFAULT_PORT_SSL); 1529 set_setstr(&acc->set, "ssl", "true"); 1530 1531 g_free(acc->server); 1532 acc->server = NULL; 1533 } else if ((s = strchr(acc->server, ':'))) { 1534 if (strstr(acc->server, ":ssl")) { 1535 set_setint(&acc->set, "port", DEFAULT_PORT_SSL); 1536 set_setstr(&acc->set, "ssl", "true"); 1537 } 1538 if (isdigit(s[1])) { 1539 if (sscanf(s + 1, "%d", &port) == 1) 1540 set_setint(&acc->set, "port", port); 1541 } 1542 tmp_server = g_strndup(acc->server, s - acc->server); 1543 set_setstr(&acc->set, "server", tmp_server); 1544 g_free(tmp_server); 1545 } 1546 } 1547 1548 gc = new_gaim_conn(acc); 1549 jd = gc->proto_data = g_new0(struct jabber_data, 1); 1550 1551 if( strchr( acc->user, '@' ) == NULL ) 1552 { 1553 hide_login_progress( gc, "Invalid account name" ); 1554 signoff( gc ); 1555 return; 1556 } 1557 1558 resource = set_getstr(&acc->set, "resource"); 1559 loginname = create_valid_jid(acc->user, DEFAULT_SERVER, resource); 1560 1518 static void jabber_login(struct aim_user *user) 1519 { 1520 struct gaim_connection *gc = new_gaim_conn(user); 1521 struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1); 1522 char *loginname = create_valid_jid(user->username, DEFAULT_SERVER, "BitlBee"); 1523 1561 1524 jd->hash = g_hash_table_new(g_str_hash, g_str_equal); 1562 1525 jd->chats = NULL; /* we have no chats yet */ … … 1564 1527 set_login_progress(gc, 1, _("Connecting")); 1565 1528 1566 if (!(jd->gjc = gjab_new(loginname, acc->pass, gc))) {1529 if (!(jd->gjc = gjab_new(loginname, user->password, gc))) { 1567 1530 g_free(loginname); 1568 1531 hide_login_progress(gc, _("Unable to connect")); … … 2374 2337 ret->name = "jabber"; 2375 2338 ret->away_states = jabber_away_states; 2376 ret->acc_init = jabber_acc_init;2377 2339 ret->login = jabber_login; 2378 2340 ret->close = jabber_close; … … 2387 2349 ret->alias_buddy = jabber_roster_update; 2388 2350 ret->group_buddy = jabber_group_change; 2389 ret-> handle_cmp= g_strcasecmp;2351 ret->cmp_buddynames = g_strcasecmp; 2390 2352 2391 2353 register_protocol (ret); -
protocols/msn/msn.c
reda0270 r6398094 27 27 #include "msn.h" 28 28 29 static char *msn_set_display_name( set_t *set, char *value ); 30 31 static void msn_acc_init( account_t *acc ) 32 { 33 set_t *s; 34 35 s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); 36 s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; 37 } 38 39 static void msn_login( account_t *acc ) 40 { 41 struct gaim_connection *gc = new_gaim_conn( acc ); 29 static void msn_login( struct aim_user *acct ) 30 { 31 struct gaim_connection *gc = new_gaim_conn( acct ); 42 32 struct msn_data *md = g_new0( struct msn_data, 1 ); 43 33 … … 47 37 md->fd = -1; 48 38 49 if( strchr( acc ->user, '@' ) == NULL )39 if( strchr( acct->username, '@' ) == NULL ) 50 40 { 51 41 hide_login_progress( gc, "Invalid account name" ); … … 222 212 static void msn_set_info( struct gaim_connection *gc, char *info ) 223 213 { 224 msn_set_display_name( set_find( &gc->acc->set, "display_name" ), info ); 214 int i; 215 char buf[1024], *fn, *s; 216 struct msn_data *md = gc->proto_data; 217 218 if( strlen( info ) > 129 ) 219 { 220 do_error_dialog( gc, "Maximum name length exceeded", "MSN" ); 221 return; 222 } 223 224 /* Of course we could use http_encode() here, but when we encode 225 every character, the server is less likely to complain about the 226 chosen name. However, the MSN server doesn't seem to like escaped 227 non-ASCII chars, so we keep those unescaped. */ 228 s = fn = g_new0( char, strlen( info ) * 3 + 1 ); 229 for( i = 0; info[i]; i ++ ) 230 if( info[i] & 128 ) 231 { 232 *s = info[i]; 233 s ++; 234 } 235 else 236 { 237 g_snprintf( s, 4, "%%%02X", info[i] ); 238 s += 3; 239 } 240 241 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn ); 242 msn_write( gc, buf, strlen( buf ) ); 243 g_free( fn ); 225 244 } 226 245 … … 361 380 } 362 381 363 static char *msn_set_display_name( set_t *set, char *value )364 {365 account_t *acc = set->data;366 struct gaim_connection *gc = acc->gc;367 struct msn_data *md;368 char buf[1024], *fn, *s;369 int i;370 371 /* Double-check. */372 if( gc == NULL )373 return NULL;374 375 md = gc->proto_data;376 377 if( strlen( value ) > 129 )378 {379 serv_got_crap( gc, "Maximum name length exceeded" );380 return NULL;381 }382 383 /* Of course we could use http_encode() here, but when we encode384 every character, the server is less likely to complain about the385 chosen name. However, the MSN server doesn't seem to like escaped386 non-ASCII chars, so we keep those unescaped. */387 s = fn = g_new0( char, strlen( value ) * 3 + 1 );388 for( i = 0; value[i]; i ++ )389 if( value[i] & 128 )390 {391 *s = value[i];392 s ++;393 }394 else395 {396 g_snprintf( s, 4, "%%%02X", value[i] );397 s += 3;398 }399 400 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );401 msn_write( gc, buf, strlen( buf ) );402 g_free( fn );403 404 /* Returning NULL would be better, because the server still has to405 confirm the name change. However, it looks a bit confusing to the406 user. */407 return value;408 }409 410 382 void msn_init() 411 383 { 412 384 struct prpl *ret = g_new0(struct prpl, 1); 413 414 385 ret->name = "msn"; 415 386 ret->login = msn_login; 416 ret->acc_init = msn_acc_init;417 387 ret->close = msn_close; 418 388 ret->send_im = msn_send_im; … … 434 404 ret->rem_deny = msn_rem_deny; 435 405 ret->send_typing = msn_send_typing; 436 ret-> handle_cmp= g_strcasecmp;406 ret->cmp_buddynames = g_strcasecmp; 437 407 438 408 register_protocol(ret); -
protocols/msn/ns.c
reda0270 r6398094 223 223 else if( num_parts == 7 && strcmp( cmd[2], "OK" ) == 0 ) 224 224 { 225 set_t *s;226 227 225 http_decode( cmd[4] ); 228 226 229 227 strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) ); 230 228 gc->displayname[sizeof(gc->displayname)-1] = 0; 231 232 if( ( s = set_find( &gc->acc->set, "display_name" ) ) )233 {234 g_free( s->value );235 s->value = g_strdup( cmd[4] );236 }237 229 238 230 set_login_progress( gc, 1, "Authenticated, getting buddy list" ); … … 525 517 if( g_strcasecmp( cmd[3], gc->username ) == 0 ) 526 518 { 527 set_t *s;528 529 519 http_decode( cmd[4] ); 530 520 strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) ); 531 521 gc->displayname[sizeof(gc->displayname)-1] = 0; 532 533 if( ( s = set_find( &gc->acc->set, "display_name" ) ) )534 {535 g_free( s->value );536 s->value = g_strdup( cmd[4] );537 }538 522 } 539 523 else -
protocols/nogaim.c
reda0270 r6398094 145 145 /* multi.c */ 146 146 147 struct gaim_connection *new_gaim_conn( account_t *acc)147 struct gaim_connection *new_gaim_conn( struct aim_user *user ) 148 148 { 149 149 struct gaim_connection *gc; 150 account_t *a; 150 151 151 152 gc = g_new0( struct gaim_connection, 1 ); 152 153 153 /* Maybe we should get rid of this memory waste later. ;-) */154 g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user);155 g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass);156 157 gc->irc = acc->irc;158 gc->acc = acc;159 acc->gc = gc;154 gc->prpl = user->prpl; 155 g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username ); 156 g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password ); 157 /* [MD] BUGFIX: don't set gc->irc to the global IRC, but use the one from the struct aim_user. 158 * This fixes daemon mode breakage where IRC doesn't point to the currently active connection. 159 */ 160 gc->irc = user->irc; 160 161 161 162 connections = g_slist_append( connections, gc ); 163 164 user->gc = gc; 165 gc->user = user; 166 167 // Find the account_t so we can set its gc pointer 168 for( a = gc->irc->accounts; a; a = a->next ) 169 if( ( struct aim_user * ) a->gc == user ) 170 { 171 a->gc = gc; 172 break; 173 } 162 174 163 175 return( gc ); … … 177 189 178 190 connections = g_slist_remove( connections, gc ); 191 g_free( gc->user ); 179 192 g_free( gc ); 180 193 } … … 207 220 va_end( params ); 208 221 209 if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||210 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) )222 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || 223 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 211 224 strip_html( text ); 212 225 213 226 /* Try to find a different connection on the same protocol. */ 214 227 for( a = gc->irc->accounts; a; a = a->next ) 215 if( a->prpl == gc-> acc->prpl && a->gc != gc )228 if( a->prpl == gc->prpl && a->gc != gc ) 216 229 break; 217 230 218 231 /* If we found one, include the screenname in the message. */ 219 232 if( a ) 220 irc_usermsg( gc->irc, "%s(%s) - %s", gc-> acc->prpl->name, gc->username, text );233 irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, text ); 221 234 else 222 irc_usermsg( gc->irc, "%s - %s", gc-> acc->prpl->name, text );235 irc_usermsg( gc->irc, "%s - %s", gc->prpl->name, text ); 223 236 224 237 g_free( text ); … … 229 242 struct gaim_connection *gc = d; 230 243 231 if( gc-> acc->prpl->keepalive )232 gc-> acc->prpl->keepalive( gc );244 if( gc->prpl && gc->prpl->keepalive ) 245 gc->prpl->keepalive( gc ); 233 246 234 247 return TRUE; … … 284 297 b_event_remove( gc->keepalive ); 285 298 gc->flags |= OPT_LOGGING_OUT; 286 287 299 gc->keepalive = 0; 288 gc-> acc->prpl->close( gc );300 gc->prpl->close( gc ); 289 301 b_event_remove( gc->inpa ); 290 302 … … 311 323 /* Uhm... This is very sick. */ 312 324 } 313 else if( !gc->wants_to_die && set_getint( &irc->set, "auto_reconnect" ) )314 { 315 int delay = set_getint( &irc->set, "auto_reconnect_delay" );325 else if( !gc->wants_to_die && set_getint( irc, "auto_reconnect" ) ) 326 { 327 int delay = set_getint( irc, "auto_reconnect_delay" ); 316 328 317 329 serv_got_crap( gc, "Reconnecting in %d seconds..", delay ); … … 352 364 irc_t *irc = gc->irc; 353 365 354 if( set_getint( &irc->set, "debug" ) && 0 ) /* This message is too useless */366 if( set_getint( irc, "debug" ) && 0 ) /* This message is too useless */ 355 367 serv_got_crap( gc, "Receiving user add from handle: %s", handle ); 356 368 357 369 if( user_findhandle( gc, handle ) ) 358 370 { 359 if( set_getint( &irc->set, "debug" ) )371 if( set_getint( irc, "debug" ) ) 360 372 serv_got_crap( gc, "User already exists, ignoring add request: %s", handle ); 361 373 … … 366 378 367 379 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 368 strcpy( nick, nick_get( gc-> acc, handle, realname ) );380 strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) ); 369 381 370 382 u = user_add( gc->irc, nick ); … … 378 390 u->user = g_strndup( handle, s - handle ); 379 391 } 380 else if( gc-> acc->server)392 else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] ) 381 393 { 382 394 char *colon; 383 395 384 if( ( colon = strchr( gc-> acc->server, ':' ) ) )385 u->host = g_strndup( gc-> acc->server,386 colon - gc-> acc->server);396 if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) ) 397 u->host = g_strndup( gc->user->proto_opt[0], 398 colon - gc->user->proto_opt[0] ); 387 399 else 388 u->host = g_strdup( gc-> acc->server);400 u->host = g_strdup( gc->user->proto_opt[0] ); 389 401 390 402 u->user = g_strdup( handle ); … … 397 409 else 398 410 { 399 u->host = g_strdup( gc-> acc->prpl->name );411 u->host = g_strdup( gc->user->prpl->name ); 400 412 u->user = g_strdup( handle ); 401 413 } … … 445 457 u->realname = g_strdup( realname ); 446 458 447 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( &gc->irc->set, "display_namechanges" ) )459 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( gc->irc, "display_namechanges" ) ) 448 460 serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname ); 449 461 } … … 467 479 void show_got_added_yes( gpointer w, struct show_got_added_data *data ) 468 480 { 469 data->gc-> acc->prpl->add_buddy( data->gc, data->handle );481 data->gc->prpl->add_buddy( data->gc, data->handle ); 470 482 add_buddy( data->gc, NULL, data->handle, data->handle ); 471 483 … … 501 513 if( !u ) 502 514 { 503 if( g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "add" ) == 0 )515 if( g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "add" ) == 0 ) 504 516 { 505 517 add_buddy( gc, NULL, handle, NULL ); … … 508 520 else 509 521 { 510 if( set_getint( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 )522 if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 ) 511 523 { 512 524 serv_got_crap( gc, "serv_got_update() for handle %s:", handle ); … … 546 558 } 547 559 548 if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0) )560 if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) ) 549 561 { 550 562 u->away = g_strdup( "Away" ); 551 563 } 552 else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0) )564 else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) ) 553 565 { 554 566 if( type & UC_DND ) … … 559 571 u->away = g_strdup( "Away" ); 560 572 } 561 else if( ( type & UC_UNAVAILABLE ) && gc-> acc->prpl->get_status_string )562 { 563 u->away = g_strdup( gc-> acc->prpl->get_status_string( gc, type ) );573 else if( ( type & UC_UNAVAILABLE ) && gc->prpl->get_status_string ) 574 { 575 u->away = g_strdup( gc->prpl->get_status_string( gc, type ) ); 564 576 } 565 577 else … … 567 579 568 580 /* LISPy... */ 569 if( ( set_getint( &gc->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */581 if( ( set_getint( gc->irc, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 570 582 ( u->online ) && /* Don't touch offline people */ 571 583 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ … … 586 598 if( !u ) 587 599 { 588 char *h = set_getstr( &irc->set, "handle_unknown" );600 char *h = set_getstr( irc, "handle_unknown" ); 589 601 590 602 if( g_strcasecmp( h, "ignore" ) == 0 ) 591 603 { 592 if( set_getint( &irc->set, "debug" ) )604 if( set_getint( irc, "debug" ) ) 593 605 serv_got_crap( gc, "Ignoring message from unknown handle %s", handle ); 594 606 … … 597 609 else if( g_strncasecmp( h, "add", 3 ) == 0 ) 598 610 { 599 int private = set_getint( &irc->set, "private" );611 int private = set_getint( irc, "private" ); 600 612 601 613 if( h[3] ) … … 618 630 } 619 631 620 if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||621 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) )632 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || 633 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 622 634 strip_html( msg ); 623 635 … … 659 671 user_t *u; 660 672 661 if( !set_getint( &gc->irc->set, "typing_notice" ) )673 if( !set_getint( gc->irc, "typing_notice" ) ) 662 674 return; 663 675 … … 681 693 GList *ir; 682 694 683 if( set_getint( &gc->irc->set, "debug" ) )695 if( set_getint( gc->irc, "debug" ) ) 684 696 serv_got_crap( gc, "You were removed from conversation %d", (int) id ); 685 697 … … 720 732 721 733 /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ 722 if( g_strcasecmp( who, gc->user name ) == 0 )734 if( g_strcasecmp( who, gc->user->username ) == 0 ) 723 735 return; 724 736 … … 726 738 for( c = gc->conversations; c && c->id != id; c = c->next ); 727 739 728 if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||729 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) )740 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || 741 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 730 742 strip_html( msg ); 731 743 … … 760 772 g_free( s ); 761 773 762 if( set_getint( &gc->irc->set, "debug" ) )774 if( set_getint( gc->irc, "debug" ) ) 763 775 serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle ); 764 776 … … 774 786 int me = 0; 775 787 776 if( set_getint( &b->gc->irc->set, "debug" ) )788 if( set_getint( b->gc->irc, "debug" ) ) 777 789 serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id ); 778 790 779 791 /* It might be yourself! */ 780 if( b->gc-> acc->prpl->handle_cmp( handle, b->gc->username ) == 0 )792 if( b->gc->prpl->cmp_buddynames( handle, b->gc->user->username ) == 0 ) 781 793 { 782 794 u = user_find( b->gc->irc, b->gc->irc->nick ); … … 808 820 int me = 0; 809 821 810 if( set_getint( &b->gc->irc->set, "debug" ) )822 if( set_getint( b->gc->irc, "debug" ) ) 811 823 serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" ); 812 824 813 825 /* It might be yourself! */ 814 if( g_strcasecmp( handle, b->gc->user name ) == 0 )826 if( g_strcasecmp( handle, b->gc->user->username ) == 0 ) 815 827 { 816 828 u = user_find( b->gc->irc, b->gc->irc->nick ); … … 870 882 } 871 883 872 char *set_eval_away_devoice( set_t *set, char *value ) 873 { 874 irc_t *irc = set->data; 884 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ) 885 { 875 886 int st; 876 887 … … 886 897 /* Horror.... */ 887 898 888 if( st != set_getint( &irc->set, "away_devoice" ) )899 if( st != set_getint( irc, "away_devoice" ) ) 889 900 { 890 901 char list[80] = ""; … … 926 937 } 927 938 928 return( set_eval_bool( set, value ) );939 return( set_eval_bool( irc, set, value ) ); 929 940 } 930 941 … … 946 957 } 947 958 948 st = gc-> acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );959 st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); 949 960 g_free( buf ); 950 961 … … 963 974 } 964 975 965 st = gc-> acc->prpl->chat_send( gc, id, msg );976 st = gc->prpl->chat_send( gc, id, msg ); 966 977 g_free( buf ); 967 978 … … 977 988 978 989 if( !away ) away = ""; 979 ms = m = gc-> acc->prpl->away_states( gc );990 ms = m = gc->prpl->away_states( gc ); 980 991 981 992 while( m ) … … 998 1009 if( m ) 999 1010 { 1000 gc-> acc->prpl->set_away( gc, m->data, *away ? away : NULL );1011 gc->prpl->set_away( gc, m->data, *away ? away : NULL ); 1001 1012 } 1002 1013 else … … 1005 1016 if( s ) 1006 1017 { 1007 gc-> acc->prpl->set_away( gc, s, away );1008 if( set_getint( &gc->irc->set, "debug" ) )1018 gc->prpl->set_away( gc, s, away ); 1019 if( set_getint( gc->irc, "debug" ) ) 1009 1020 serv_got_crap( gc, "Setting away state to %s", s ); 1010 1021 } 1011 1022 else 1012 gc-> acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );1023 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); 1013 1024 } 1014 1025 … … 1062 1073 void bim_add_allow( struct gaim_connection *gc, char *handle ) 1063 1074 { 1064 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc-> acc->prpl->handle_cmp) == NULL )1075 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1065 1076 { 1066 1077 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); 1067 1078 } 1068 1079 1069 gc-> acc->prpl->add_permit( gc, handle );1080 gc->prpl->add_permit( gc, handle ); 1070 1081 } 1071 1082 … … 1074 1085 GSList *l; 1075 1086 1076 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc-> acc->prpl->handle_cmp) ) )1087 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1077 1088 { 1078 1089 g_free( l->data ); … … 1080 1091 } 1081 1092 1082 gc-> acc->prpl->rem_permit( gc, handle );1093 gc->prpl->rem_permit( gc, handle ); 1083 1094 } 1084 1095 1085 1096 void bim_add_block( struct gaim_connection *gc, char *handle ) 1086 1097 { 1087 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc-> acc->prpl->handle_cmp) == NULL )1098 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1088 1099 { 1089 1100 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); 1090 1101 } 1091 1102 1092 gc-> acc->prpl->add_deny( gc, handle );1103 gc->prpl->add_deny( gc, handle ); 1093 1104 } 1094 1105 … … 1097 1108 GSList *l; 1098 1109 1099 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc-> acc->prpl->handle_cmp) ) )1110 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1100 1111 { 1101 1112 g_free( l->data ); … … 1103 1114 } 1104 1115 1105 gc-> acc->prpl->rem_deny( gc, handle );1106 } 1116 gc->prpl->rem_deny( gc, handle ); 1117 } -
protocols/nogaim.h
reda0270 r6398094 39 39 40 40 #include "bitlbee.h" 41 #include "account.h"42 41 #include "proxy.h" 43 42 #include "md5.h" … … 64 63 struct gaim_connection 65 64 { 66 account_t *acc;65 struct prpl *prpl; 67 66 guint32 flags; 68 67 … … 79 78 GSList *deny; 80 79 int permdeny; 80 81 struct aim_user *user; 81 82 82 83 char username[64]; … … 125 126 }; 126 127 128 struct aim_user { 129 char username[64]; 130 char alias[SELF_ALIAS_LEN]; 131 char password[32]; 132 char user_info[2048]; 133 int options; 134 struct prpl *prpl; 135 /* prpls can use this to save information about the user, 136 * like which server to connect to, etc */ 137 char proto_opt[7][256]; 138 139 struct gaim_connection *gc; 140 irc_t *irc; 141 }; 142 127 143 struct prpl { 128 144 int options; 129 145 const char *name; 130 146 131 void (* acc_init) (account_t *); 132 void (* login) (account_t *); 147 void (* login) (struct aim_user *); 133 148 void (* keepalive) (struct gaim_connection *); 134 149 void (* close) (struct gaim_connection *); … … 165 180 166 181 /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */ 167 int (* handle_cmp) (const char *who1, const char *who2);182 int (* cmp_buddynames) (const char *who1, const char *who2); 168 183 }; 169 184 … … 191 206 192 207 void nogaim_init(); 193 char *set_eval_away_devoice( set_t *set, char *value );208 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ); 194 209 195 210 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); … … 197 212 198 213 /* multi.c */ 199 G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( account_t *acc);214 G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( struct aim_user *user ); 200 215 G_MODULE_EXPORT void destroy_gaim_conn( struct gaim_connection *gc ); 201 216 G_MODULE_EXPORT void set_login_progress( struct gaim_connection *gc, int step, char *msg ); -
protocols/oscar/oscar.c
reda0270 r6398094 356 356 } 357 357 358 static void oscar_acc_init(account_t *acc) 359 { 360 set_t *s; 361 362 s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); 363 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 364 } 365 366 static void oscar_login(account_t *acc) { 358 static void oscar_login(struct aim_user *user) { 367 359 aim_session_t *sess; 368 360 aim_conn_t *conn; 369 361 char buf[256]; 370 struct gaim_connection *gc = new_gaim_conn( acc);362 struct gaim_connection *gc = new_gaim_conn(user); 371 363 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); 372 364 373 if (isdigit( acc->user[0])) {365 if (isdigit(*user->username)) { 374 366 odata->icq = TRUE; 375 367 /* This is odd but it's necessary for a proper do_import and do_export. 376 368 We don't do those anymore, but let's stick with it, just in case 377 it accidentally fixes something else too... </bitlbee>*/369 it accidentally fixes something else too... */ 378 370 gc->password[8] = 0; 379 371 } else { … … 398 390 } 399 391 400 if (acc->server == NULL) { 401 hide_login_progress(gc, "No servername specified"); 402 signoff(gc); 403 return; 404 } 405 406 if (g_strcasecmp(acc->server, "login.icq.com") != 0 && 407 g_strcasecmp(acc->server, "login.oscar.aol.com") != 0) { 408 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",acc->server); 392 if (g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.icq.com") != 0 && 393 g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.oscar.aol.com") != 0) { 394 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",user->proto_opt[USEROPT_AUTH]); 409 395 } 410 396 … … 416 402 417 403 conn->status |= AIM_CONN_STATUS_INPROGRESS; 418 conn->fd = proxy_connect(acc->server, AIM_LOGIN_PORT, oscar_login_connect, gc); 404 conn->fd = proxy_connect(user->proto_opt[USEROPT_AUTH][0] ? 405 user->proto_opt[USEROPT_AUTH] : AIM_DEFAULT_LOGIN_SERVER, 406 user->proto_opt[USEROPT_AUTHPORT][0] ? 407 atoi(user->proto_opt[USEROPT_AUTHPORT]) : AIM_LOGIN_PORT, 408 oscar_login_connect, gc); 419 409 if (conn->fd < 0) { 420 410 hide_login_progress(gc, _("Couldn't connect to host")); … … 495 485 struct aim_authresp_info *info; 496 486 int i; char *host; int port; 487 struct aim_user *user; 497 488 aim_conn_t *bosconn; 498 489 499 490 struct gaim_connection *gc = sess->aux_data; 500 491 struct oscar_data *od = gc->proto_data; 501 port = AIM_LOGIN_PORT; 492 user = gc->user; 493 port = user->proto_opt[USEROPT_AUTHPORT][0] ? 494 atoi(user->proto_opt[USEROPT_AUTHPORT]) : AIM_LOGIN_PORT, 502 495 503 496 va_start(ap, fr); … … 878 871 struct aim_redirect_data *redir; 879 872 struct gaim_connection *gc = sess->aux_data; 873 struct aim_user *user = gc->user; 880 874 aim_conn_t *tstconn; 881 875 int i; … … 883 877 int port; 884 878 879 port = user->proto_opt[USEROPT_AUTHPORT][0] ? 880 atoi(user->proto_opt[USEROPT_AUTHPORT]) : AIM_LOGIN_PORT, 881 885 882 va_start(ap, fr); 886 883 redir = va_arg(ap, struct aim_redirect_data *); 887 884 va_end(ap); 888 885 889 port = AIM_LOGIN_PORT;890 886 for (i = 0; i < (int)strlen(redir->ip); i++) { 891 887 if (redir->ip[i] == ':') { … … 1727 1723 odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint)maxsiglen; 1728 1724 1729 /* FIXME: It seems we're not really using this, and it broke now that1730 struct aim_user is dead.1731 1725 aim_bos_setprofile(sess, fr->conn, gc->user->user_info, NULL, gaim_caps); 1732 */ 1733 1726 1734 1727 return 1; 1735 1728 } … … 2663 2656 ret->away_states = oscar_away_states; 2664 2657 ret->login = oscar_login; 2665 ret->acc_init = oscar_acc_init;2666 2658 ret->close = oscar_close; 2667 2659 ret->send_im = oscar_send_im; … … 2681 2673 ret->set_permit_deny = oscar_set_permit_deny; 2682 2674 ret->keepalive = oscar_keepalive; 2675 ret->cmp_buddynames = aim_sncmp; 2683 2676 ret->get_status_string = oscar_get_status_string; 2684 2677 ret->send_typing = oscar_send_typing; 2685 2686 ret->handle_cmp = aim_sncmp;2687 2678 2688 2679 register_protocol(ret); -
protocols/yahoo/libyahoo2.c
reda0270 r6398094 89 89 #define vsnprintf _vsnprintf 90 90 #endif 91 92 #include "base64.h"93 91 94 92 #ifdef USE_STRUCT_CALLBACKS … … 697 695 } 698 696 697 static char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 698 "abcdefghijklmnopqrstuvwxyz" 699 "0123456789._"; 700 static void to_y64(unsigned char *out, const unsigned char *in, int inlen) 699 701 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ 700 static void to_y64(unsigned char *out, const unsigned char *in, int inlen) 701 { 702 base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"); 702 { 703 for (; inlen >= 3; inlen -= 3) 704 { 705 *out++ = base64digits[in[0] >> 2]; 706 *out++ = base64digits[((in[0]<<4) & 0x30) | (in[1]>>4)]; 707 *out++ = base64digits[((in[1]<<2) & 0x3c) | (in[2]>>6)]; 708 *out++ = base64digits[in[2] & 0x3f]; 709 in += 3; 710 } 711 if (inlen > 0) 712 { 713 unsigned char fragment; 714 715 *out++ = base64digits[in[0] >> 2]; 716 fragment = (in[0] << 4) & 0x30; 717 if (inlen > 1) 718 fragment |= in[1] >> 4; 719 *out++ = base64digits[fragment]; 720 *out++ = (inlen < 2) ? '-' 721 : base64digits[(in[1] << 2) & 0x3c]; 722 *out++ = '-'; 723 } 724 *out = '\0'; 703 725 } 704 726 -
protocols/yahoo/yahoo.c
reda0270 r6398094 121 121 } 122 122 123 static void byahoo_login( account_t *acc)124 { 125 struct gaim_connection *gc = new_gaim_conn( acc);123 static void byahoo_login( struct aim_user *user ) 124 { 125 struct gaim_connection *gc = new_gaim_conn( user ); 126 126 struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 ); 127 127 … … 130 130 131 131 set_login_progress( gc, 1, "Connecting" ); 132 yd->y2_id = yahoo_init( acc->user, acc->pass);132 yd->y2_id = yahoo_init( user->username, user->password ); 133 133 yahoo_login( yd->y2_id, yd->current_status ); 134 134 } … … 409 409 ret->chat_leave = byahoo_chat_leave; 410 410 ret->chat_open = byahoo_chat_open; 411 412 ret->handle_cmp = g_strcasecmp; 411 ret->cmp_buddynames = g_strcasecmp; 413 412 414 413 register_protocol(ret); … … 426 425 yd = gc->proto_data; 427 426 428 if( strcmp( gc->acc->prpl->name, "yahoo" ) == 0&& yd->y2_id == id )427 if( !strcmp(gc->prpl->name, "yahoo") && yd->y2_id == id ) 429 428 return( gc ); 430 429 } -
query.c
reda0270 r6398094 63 63 } 64 64 65 if( g_strcasecmp( set_getstr( &irc->set, "query_order" ), "lifo" ) == 0 || irc->queries == q )65 if( g_strcasecmp( set_getstr( irc, "query_order" ), "lifo" ) == 0 || irc->queries == q ) 66 66 query_display( irc, q ); 67 67 … … 172 172 query_t *q; 173 173 174 if( g_strcasecmp( set_getstr( &irc->set, "query_order" ), "fifo" ) == 0 )174 if( g_strcasecmp( set_getstr( irc, "query_order" ), "fifo" ) == 0 ) 175 175 q = irc->queries; 176 176 else -
root_commands.c
reda0270 r6398094 127 127 } 128 128 129 static void cmd_account( irc_t *irc, char **cmd );130 131 129 static void cmd_identify( irc_t *irc, char **cmd ) 132 130 { 133 131 storage_status_t status = storage_load( irc->nick, cmd[1], irc ); 134 char *account_on[] = { "account", "on", NULL };135 132 136 133 switch (status) { … … 142 139 break; 143 140 case STORAGE_OK: 144 irc_usermsg( irc, "Password accepted , settings and accounts loaded" );141 irc_usermsg( irc, "Password accepted" ); 145 142 irc_umode_set( irc, "+R", 1 ); 146 if( set_getint( &irc->set, "auto_connect" ) )147 cmd_account( irc, account_on );148 143 break; 149 case STORAGE_OTHER_ERROR:150 144 default: 151 irc_usermsg( irc, " Unknown error while loading configuration" );145 irc_usermsg( irc, "Something very weird happened" ); 152 146 break; 153 147 } … … 232 226 233 227 a = account_add( irc, prpl, cmd[3], cmd[4] ); 228 234 229 if( cmd[5] ) 235 set_setstr( &a->set, "server",cmd[5] );230 a->server = g_strdup( cmd[5] ); 236 231 237 232 irc_usermsg( irc, "Account successfully added" ); … … 311 306 312 307 for( a = irc->accounts; a; a = a->next ) 313 if( !a->gc && a->auto_connect)308 if( !a->gc ) 314 309 account_on( irc, a ); 315 310 } … … 357 352 } 358 353 } 359 else if( g_strcasecmp( cmd[1], "set" ) == 0 )360 {361 char *acc_handle, *set_name = NULL, *tmp;362 363 if( !cmd[2] )364 {365 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 );366 return;367 }368 369 acc_handle = g_strdup( cmd[2] );370 if( ( tmp = strchr( acc_handle, '/' ) ) )371 {372 *tmp = 0;373 set_name = tmp + 1;374 }375 a = account_get( irc, acc_handle );376 377 if( a == NULL )378 {379 g_free( acc_handle );380 irc_usermsg( irc, "Invalid account" );381 return;382 }383 384 if( cmd[3] )385 {386 set_t *s = set_find( &a->set, set_name );387 388 if( a->gc && s && s->flags & ACC_SET_OFFLINE_ONLY )389 {390 g_free( acc_handle );391 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "off" );392 return;393 }394 else if( !a->gc && s && s->flags & ACC_SET_ONLINE_ONLY )395 {396 g_free( acc_handle );397 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "on" );398 return;399 }400 401 set_setstr( &a->set, set_name, cmd[3] );402 403 if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] )404 irc_usermsg( irc, "Warning: Correct syntax: \002account set <variable> <value>\002 (without =)" );405 }406 if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */407 {408 char *s = set_getstr( &a->set, set_name );409 if( s )410 irc_usermsg( irc, "%s = `%s'", set_name, s );411 else412 irc_usermsg( irc, "%s is empty", set_name );413 }414 else415 {416 set_t *s = a->set;417 while( s )418 {419 if( s->value || s->def )420 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def );421 else422 irc_usermsg( irc, "%s is empty", s->key );423 s = s->next;424 }425 }426 427 g_free( acc_handle );428 }429 354 else 430 355 { … … 469 394 else 470 395 { 471 nick_set( a, cmd[2], cmd[3] );396 nick_set( irc, cmd[2], a->gc->prpl, cmd[3] ); 472 397 } 473 398 } … … 476 401 add them to your *real* (server-side) contact list. */ 477 402 if( add_for_real ) 478 a->gc-> acc->prpl->add_buddy( a->gc, cmd[2] );403 a->gc->prpl->add_buddy( a->gc, cmd[2] ); 479 404 480 405 add_buddy( a->gc, NULL, cmd[2], cmd[2] ); … … 510 435 } 511 436 512 if( !gc-> acc->prpl->get_info )437 if( !gc->prpl->get_info ) 513 438 { 514 439 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 516 441 else 517 442 { 518 gc-> acc->prpl->get_info( gc, cmd[2] );443 gc->prpl->get_info( gc, cmd[2] ); 519 444 } 520 445 } … … 551 476 else if( u->send_handler == buddy_send_handler ) 552 477 { 553 nick_set( u->gc->acc, u->handle, cmd[2] );478 nick_set( irc, u->handle, u->gc->prpl, cmd[2] ); 554 479 } 555 480 … … 570 495 s = g_strdup( u->handle ); 571 496 572 u->gc-> acc->prpl->remove_buddy( u->gc, u->handle, NULL );497 u->gc->prpl->remove_buddy( u->gc, u->handle, NULL ); 573 498 user_del( irc, cmd[1] ); 574 nick_del( u->gc->acc, u->handle);499 nick_del( irc, cmd[1] ); 575 500 576 501 irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); … … 627 552 } 628 553 629 if( !gc-> acc->prpl->add_deny || !gc->acc->prpl->rem_permit )554 if( !gc->prpl->add_deny || !gc->prpl->rem_permit ) 630 555 { 631 556 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 686 611 } 687 612 688 if( !gc-> acc->prpl->rem_deny || !gc->acc->prpl->add_permit )613 if( !gc->prpl->rem_deny || !gc->prpl->add_permit ) 689 614 { 690 615 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 741 666 if( cmd[1] && cmd[2] ) 742 667 { 743 set_setstr( &irc->set, cmd[1], cmd[2] );668 set_setstr( irc, cmd[1], cmd[2] ); 744 669 745 670 if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) … … 748 673 if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ 749 674 { 750 char *s = set_getstr( &irc->set, cmd[1] );675 char *s = set_getstr( irc, cmd[1] ); 751 676 if( s ) 752 677 irc_usermsg( irc, "%s = `%s'", cmd[1], s ); 753 else754 irc_usermsg( irc, "%s is empty", cmd[1] );755 678 } 756 679 else … … 761 684 if( s->value || s->def ) 762 685 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 763 else764 irc_usermsg( irc, "%s is empty", s->key );765 686 s = s->next; 766 687 } … … 806 727 if( online == 1 ) 807 728 { 808 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> acc->prpl->name );729 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 809 730 irc_usermsg( irc, format, u->nick, s, "Online" ); 810 731 } … … 817 738 if( away == 1 ) 818 739 { 819 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> acc->prpl->name );740 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 820 741 irc_usermsg( irc, format, u->nick, s, u->away ); 821 742 } … … 827 748 if( offline == 1 ) 828 749 { 829 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> acc->prpl->name );750 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 830 751 irc_usermsg( irc, format, u->nick, s, "Offline" ); 831 752 } … … 852 773 irc_usermsg( irc, "Your name is `%s'" , a->gc->displayname ? a->gc->displayname : "NULL" ); 853 774 } 854 else if ( !a-> prpl->set_info )775 else if ( !a->gc->prpl->set_info ) 855 776 { 856 777 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 860 781 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 861 782 862 a-> prpl->set_info( a->gc, cmd[2] );783 a->gc->prpl->set_info( a->gc, cmd[2] ); 863 784 } 864 785 } … … 879 800 for( num = 0; q; q = q->next, num ++ ) 880 801 if( q->gc ) /* Not necessary yet, but it might come later */ 881 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc-> acc->prpl->name, q->gc->username, q->question );802 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc->prpl->name, q->gc->username, q->question ); 882 803 else 883 804 irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); 805 } 806 807 static void cmd_import_buddies( irc_t *irc, char **cmd ) 808 { 809 struct gaim_connection *gc; 810 account_t *a; 811 nick_t *n; 812 813 if( !( a = account_get( irc, cmd[1] ) ) ) 814 { 815 irc_usermsg( irc, "Invalid account" ); 816 return; 817 } 818 else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) ) 819 { 820 irc_usermsg( irc, "That account is not on-line" ); 821 return; 822 } 823 824 if( cmd[2] ) 825 { 826 if( g_strcasecmp( cmd[2], "clear" ) == 0 ) 827 { 828 user_t *u; 829 830 for( u = irc->users; u; u = u->next ) 831 if( u->gc == gc ) 832 { 833 u->gc->prpl->remove_buddy( u->gc, u->handle, NULL ); 834 user_del( irc, u->nick ); 835 } 836 837 irc_usermsg( irc, "Old buddy list cleared." ); 838 } 839 else 840 { 841 irc_usermsg( irc, "Invalid argument: %s", cmd[2] ); 842 return; 843 } 844 } 845 846 for( n = gc->irc->nicks; n; n = n->next ) 847 { 848 if( n->proto == gc->prpl && !user_findhandle( gc, n->handle ) ) 849 { 850 gc->prpl->add_buddy( gc, n->handle ); 851 add_buddy( gc, NULL, n->handle, NULL ); 852 } 853 } 854 855 irc_usermsg( irc, "Sent all add requests. Please wait for a while, the server needs some time to handle all the adds." ); 884 856 } 885 857 … … 902 874 { "blist", 0, cmd_blist, 0 }, 903 875 { "nick", 1, cmd_nick, 0 }, 876 { "import_buddies", 1, cmd_import_buddies, 0 }, 904 877 { "qlist", 0, cmd_qlist, 0 }, 905 878 { NULL } -
set.c
reda0270 r6398094 26 26 #include "bitlbee.h" 27 27 28 set_t *set_add( set_t **head, char *key, char *def, void *eval, void *data ) 29 { 30 set_t *s = set_find( head, key ); 31 32 /* Possibly the setting already exists. If it doesn't exist yet, 33 we create it. If it does, we'll just change the default. */ 28 set_t *set_add( irc_t *irc, char *key, char *def, void *eval ) 29 { 30 set_t *s = set_find( irc, key ); 31 34 32 if( !s ) 35 33 { 36 if( ( s = *head) )34 if( ( s = irc->set ) ) 37 35 { 38 36 while( s->next ) s = s->next; 39 s->next = g_new 0( set_t, 1 );37 s->next = g_new ( set_t, 1 ); 40 38 s = s->next; 41 39 } 42 40 else 43 41 { 44 s = *head = g_new0( set_t, 1 );42 s = irc->set = g_new( set_t, 1 ); 45 43 } 44 memset( s, 0, sizeof( set_t ) ); 46 45 s->key = g_strdup( key ); 47 46 } … … 54 53 if( def ) s->def = g_strdup( def ); 55 54 56 s->eval = eval; 57 s->data = data; 58 59 return s; 60 } 61 62 set_t *set_find( set_t **head, char *key ) 63 { 64 set_t *s = *head; 55 if( s->eval ) 56 { 57 g_free( s->eval ); 58 s->eval = NULL; 59 } 60 if( eval ) s->eval = eval; 61 62 return( s ); 63 } 64 65 set_t *set_find( irc_t *irc, char *key ) 66 { 67 set_t *s = irc->set; 65 68 66 69 while( s ) … … 71 74 } 72 75 73 return s;74 } 75 76 char *set_getstr( set_t **head, char *key )77 { 78 set_t *s = set_find( head, key );76 return( s ); 77 } 78 79 char *set_getstr( irc_t *irc, char *key ) 80 { 81 set_t *s = set_find( irc, key ); 79 82 80 83 if( !s || ( !s->value && !s->def ) ) 81 return NULL;82 83 return s->value ? s->value : s->def;84 } 85 86 int set_getint( set_t **head, char *key )87 { 88 char *s = set_getstr( head, key );84 return( NULL ); 85 86 return( s->value?s->value:s->def ); 87 } 88 89 int set_getint( irc_t *irc, char *key ) 90 { 91 char *s = set_getstr( irc, key ); 89 92 int i = 0; 90 93 91 94 if( !s ) 92 return 0;95 return( 0 ); 93 96 94 97 if( ( g_strcasecmp( s, "true" ) == 0 ) || ( g_strcasecmp( s, "yes" ) == 0 ) || ( g_strcasecmp( s, "on" ) == 0 ) ) 95 return 1;98 return( 1 ); 96 99 97 100 if( sscanf( s, "%d", &i ) != 1 ) 98 return 0; 99 100 return i; 101 } 102 103 int set_getbool( set_t **head, char *key ) 104 { 105 char *s = set_getstr( head, key ); 101 return( 0 ); 102 103 return( i ); 104 } 105 106 int set_setstr( irc_t *irc, char *key, char *value ) 107 { 108 set_t *s = set_find( irc, key ); 109 char *nv = value; 106 110 107 111 if( !s ) 108 return 0; 109 110 return bool2int( s ); 111 } 112 113 int set_setstr( set_t **head, char *key, char *value ) 114 { 115 set_t *s = set_find( head, key ); 116 char *nv = value; 117 118 if( !s ) 119 s = set_add( head, key, NULL, NULL, NULL ); 120 121 if( s->eval && !( nv = s->eval( s, value ) ) ) 122 return 0; 112 s = set_add( irc, key, NULL, NULL ); 113 114 if( s->eval && !( nv = s->eval( irc, s, value ) ) ) 115 return( 0 ); 123 116 124 117 if( s->value ) … … 128 121 } 129 122 130 /* If there's a default setting and it's equal to what we're trying to131 set, stick with s->value = NULL. Otherwise, remember the setting. */132 123 if( !s->def || ( strcmp( nv, s->def ) != 0 ) ) 133 124 s->value = g_strdup( nv ); … … 136 127 g_free( nv ); 137 128 138 return 1;139 } 140 141 int set_setint( set_t **head, char *key, int value )129 return( 1 ); 130 } 131 132 int set_setint( irc_t *irc, char *key, int value ) 142 133 { 143 134 char s[24]; /* Not quite 128-bit clean eh? ;-) */ 144 135 145 g_snprintf( s, sizeof( s ), "%d", value );146 return set_setstr( head, key, s);147 } 148 149 void set_del( set_t **head, char *key )150 { 151 set_t *s = *head, *t = NULL;136 sprintf( s, "%d", value ); 137 return( set_setstr( irc, key, s ) ); 138 } 139 140 void set_del( irc_t *irc, char *key ) 141 { 142 set_t *s = irc->set, *t = NULL; 152 143 153 144 while( s ) … … 162 153 t->next = s->next; 163 154 else 164 *head= s->next;155 irc->set = s->next; 165 156 166 157 g_free( s->key ); … … 171 162 } 172 163 173 char *set_eval_int( set_t *set, char *value ) 174 { 175 char *s; 176 177 for( s = value; *s; s ++ ) 178 if( !isdigit( *s ) ) 179 return NULL; 180 181 return value; 182 } 183 184 char *set_eval_bool( set_t *set, char *value ) 185 { 186 return is_bool( value ) ? value : NULL; 187 } 188 189 char *set_eval_to_char( set_t *set, char *value ) 164 char *set_eval_int( irc_t *irc, set_t *set, char *value ) 165 { 166 char *s = value; 167 168 for( ; *s; s ++ ) 169 if( *s < '0' || *s > '9' ) 170 return( NULL ); 171 172 return( value ); 173 } 174 175 char *set_eval_bool( irc_t *irc, set_t *set, char *value ) 176 { 177 if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) ) 178 return( value ); 179 if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) ) 180 return( value ); 181 return( set_eval_int( irc, set, value ) ); 182 } 183 184 char *set_eval_to_char( irc_t *irc, set_t *set, char *value ) 190 185 { 191 186 char *s = g_new( char, 3 ); … … 196 191 sprintf( s, "%c ", *value ); 197 192 198 return s; 199 } 200 201 char *set_eval_ops( set_t *set, char *value ) 202 { 203 irc_t *irc = set->data; 204 193 return( s ); 194 } 195 196 char *set_eval_ops( irc_t *irc, set_t *set, char *value ) 197 { 205 198 if( g_strcasecmp( value, "user" ) == 0 ) 199 { 206 200 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 207 201 irc->channel, "+o-o", irc->nick, irc->mynick ); 202 return( value ); 203 } 208 204 else if( g_strcasecmp( value, "root" ) == 0 ) 205 { 209 206 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 210 207 irc->channel, "-o+o", irc->nick, irc->mynick ); 208 return( value ); 209 } 211 210 else if( g_strcasecmp( value, "both" ) == 0 ) 211 { 212 212 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 213 213 irc->channel, "+oo", irc->nick, irc->mynick ); 214 return( value ); 215 } 214 216 else if( g_strcasecmp( value, "none" ) == 0 ) 217 { 215 218 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 216 219 irc->channel, "-oo", irc->nick, irc->mynick ); 217 else 218 return NULL; 219 220 return value; 221 } 222 223 char *set_eval_charset( set_t *set, char *value ) 224 { 225 GIConv cd; 226 227 if ( g_strncasecmp( value, "none", 4 ) == 0 ) 228 return value; 229 230 cd = g_iconv_open( "UTF-8", value ); 231 if( cd == (GIConv) -1 ) 232 return NULL; 233 234 g_iconv_close( cd ); 235 return value; 236 } 220 return( value ); 221 } 222 223 return( NULL ); 224 } 225 -
set.h
reda0270 r6398094 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-200 6Wilmer van der Gaast and others *4 * Copyright 2002-2004 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 26 26 typedef struct set 27 27 { 28 void *data;29 30 28 char *key; 31 29 char *value; 32 30 char *def; /* Default */ 33 31 34 int flags; 35 36 /* Eval: Returns NULL if the value is incorrect or exactly the 37 passed value variable. When returning a corrected value, 38 set_setstr() should be able to free() the returned string! */ 39 char *(*eval) ( struct set *set, char *value ); 32 /* Eval: Returns NULL if the value is incorrect. Can return a 33 corrected value. set_setstr() should be able to free() the 34 returned string! */ 35 char *(*eval) ( irc_t *irc, struct set *set, char *value ); 40 36 struct set *next; 41 37 } set_t; 42 38 43 set_t *set_add( set_t **head, char *key, char *def, void *eval, void *data ); 44 set_t *set_find( set_t **head, char *key ); 45 G_MODULE_EXPORT char *set_getstr( set_t **head, char *key ); 46 G_MODULE_EXPORT int set_getint( set_t **head, char *key ); 47 G_MODULE_EXPORT int set_getbool( set_t **head, char *key ); 48 int set_setstr( set_t **head, char *key, char *value ); 49 int set_setint( set_t **head, char *key, int value ); 50 void set_del( set_t **head, char *key ); 39 set_t *set_add( irc_t *irc, char *key, char *def, void *eval ); 40 G_MODULE_EXPORT set_t *set_find( irc_t *irc, char *key ); 41 G_MODULE_EXPORT char *set_getstr( irc_t *irc, char *key ); 42 G_MODULE_EXPORT int set_getint( irc_t *irc, char *key ); 43 int set_setstr( irc_t *irc, char *key, char *value ); 44 int set_setint( irc_t *irc, char *key, int value ); 45 void set_del( irc_t *irc, char *key ); 51 46 52 char *set_eval_int( set_t *set, char *value ); 53 char *set_eval_bool( set_t *set, char *value ); 47 char *set_eval_int( irc_t *irc, set_t *set, char *value ); 48 char *set_eval_bool( irc_t *irc, set_t *set, char *value ); 49 char *set_eval_to_char( irc_t *irc, set_t *set, char *value ); 50 char *set_eval_ops( irc_t *irc, set_t *set, char *value ); 54 51 55 char *set_eval_to_char( set_t *set, char *value ); 56 char *set_eval_ops( set_t *set, char *value ); 57 char *set_eval_charset( set_t *set, char *value ); 52 -
storage.c
reda0270 r6398094 6 6 7 7 /* Support for multiple storage backends */ 8 9 /* Copyright (C) 2005 Jelmer Vernooij <jelmer@samba.org> */10 8 11 9 /* … … 31 29 32 30 extern storage_t storage_text; 33 extern storage_t storage_xml;34 31 35 static GList *storage_backends = NULL; 32 static GList text_entry = { &storage_text, NULL, NULL }; 33 static GList *storage_backends = &text_entry; 36 34 37 35 void register_storage_backend(storage_t *backend) … … 43 41 { 44 42 GList *gl; 45 storage_t *st = NULL;43 storage_t *st; 46 44 47 45 for (gl = storage_backends; gl; gl = gl->next) { … … 65 63 int i; 66 64 storage_t *storage; 67 68 register_storage_backend(&storage_text); 69 register_storage_backend(&storage_xml); 70 65 71 66 storage = storage_init_single(primary); 72 if (storage == NULL && storage->save == NULL)67 if (storage == NULL) 73 68 return NULL; 74 69 -
storage.h
reda0270 r6398094 33 33 STORAGE_ALREADY_EXISTS, 34 34 STORAGE_OTHER_ERROR /* Error that isn't caused by user input, such as 35 36 35 a database that is unreachable. log() will be 36 used for the exact error message */ 37 37 } storage_status_t; 38 38 -
storage_text.c
reda0270 r6398094 27 27 #include "bitlbee.h" 28 28 #include "crypting.h" 29 30 /* DO NOT USE THIS FUNCTION IN NEW CODE. This 31 * function is here merely because the save/load code still uses 32 * ids rather than names */ 33 static struct prpl *find_protocol_by_id(int id) 34 { 35 switch (id) { 36 case 0: case 1: case 3: return find_protocol("oscar"); 37 case 4: return find_protocol("msn"); 38 case 2: return find_protocol("yahoo"); 39 case 8: return find_protocol("jabber"); 40 default: break; 41 } 42 return NULL; 43 } 44 45 static int find_protocol_id(const char *name) 46 { 47 if (!strcmp(name, "oscar")) return 1; 48 if (!strcmp(name, "msn")) return 4; 49 if (!strcmp(name, "yahoo")) return 2; 50 if (!strcmp(name, "jabber")) return 8; 51 52 return -1; 53 } 54 29 55 30 56 static void text_init (void) … … 44 70 FILE *fp; 45 71 user_t *ru = user_find( irc, ROOT_NICK ); 46 account_t *acc, *acc_lookup[9];47 72 48 73 if( irc->status & USTATUS_IDENTIFIED ) … … 55 80 fscanf( fp, "%32[^\n]s", s ); 56 81 57 if ( checkpass( password, s ) != 0 )82 if (checkpass (password, s) != 0) 58 83 { 59 84 fclose( fp ); … … 75 100 fclose( fp ); 76 101 77 /* Build a list with the first listed account of every protocol78 number. So if the user had nicks defined for a second account on79 the same IM network, those nicks will be added to the wrong80 account, and the user should rename those buddies again. But at81 least from now on things will be saved properly. */82 memset( acc_lookup, 0, sizeof( acc_lookup ) );83 for( acc = irc->accounts; acc; acc = acc->next )84 {85 if( acc_lookup[0] == NULL && strcmp( acc->prpl->name, "oscar" ) == 0 )86 acc_lookup[0] = acc_lookup[1] = acc_lookup[3] = acc;87 else if( acc_lookup[2] == NULL && strcmp( acc->prpl->name, "yahoo" ) == 0 )88 acc_lookup[2] = acc;89 else if( acc_lookup[4] == NULL && strcmp( acc->prpl->name, "msn" ) == 0 )90 acc_lookup[4] = acc;91 else if( acc_lookup[8] == NULL && strcmp( acc->prpl->name, "jabber" ) == 0 )92 acc_lookup[8] = acc;93 }94 95 102 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, my_nick, ".nicks" ); 96 103 fp = fopen( s, "r" ); … … 98 105 while( fscanf( fp, "%s %d %s", s, &proto, nick ) > 0 ) 99 106 { 100 if( ( acc = acc_lookup[proto] ) == NULL ) 107 struct prpl *prpl; 108 109 prpl = find_protocol_by_id(proto); 110 111 if (!prpl) 101 112 continue; 113 114 http_decode( s ); 115 nick_set( irc, s, prpl, nick ); 116 } 117 fclose( fp ); 118 119 if( set_getint( irc, "auto_connect" ) ) 120 { 121 strcpy( s, "account on" ); /* Can't do this directly because r_c_s alters the string */ 122 root_command_string( irc, ru, s, 0 ); 123 } 124 125 return STORAGE_OK; 126 } 127 128 static storage_status_t text_save( irc_t *irc, int overwrite ) 129 { 130 char s[512]; 131 char path[512], new_path[512]; 132 char *line; 133 nick_t *n; 134 set_t *set; 135 mode_t ou = umask( 0077 ); 136 account_t *a; 137 FILE *fp; 138 char *hash; 139 140 if (!overwrite) { 141 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" ); 142 if (access( path, F_OK ) != -1) 143 return STORAGE_ALREADY_EXISTS; 144 145 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" ); 146 if (access( path, F_OK ) != -1) 147 return STORAGE_ALREADY_EXISTS; 148 } 149 150 /*\ 151 * [SH] Nothing should be saved if no password is set, because the 152 * password is not set if it was wrong, or if one is not identified 153 * yet. This means that a malicious user could easily overwrite 154 * files owned by someone else: 155 * a Bad Thing, methinks 156 \*/ 157 158 /* [WVG] No? Really? */ 159 160 /*\ 161 * [SH] Okay, okay, it wasn't really Wilmer who said that, it was 162 * me. I just thought it was funny. 163 \*/ 164 165 hash = hashpass( irc->password ); 166 if( hash == NULL ) 167 { 168 irc_usermsg( irc, "Please register yourself if you want to save your settings." ); 169 return STORAGE_OTHER_ERROR; 170 } 171 172 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks~" ); 173 fp = fopen( path, "w" ); 174 if( !fp ) return STORAGE_OTHER_ERROR; 175 for( n = irc->nicks; n; n = n->next ) 176 { 177 strcpy( s, n->handle ); 178 s[169] = 0; /* Prevent any overflow (169 ~ 512 / 3) */ 179 http_encode( s ); 180 g_snprintf( s + strlen( s ), 510 - strlen( s ), " %d %s", find_protocol_id(n->proto->name), n->nick ); 181 if( fprintf( fp, "%s\n", s ) != strlen( s ) + 1 ) 182 { 183 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 184 fclose( fp ); 185 return STORAGE_OTHER_ERROR; 186 } 187 } 188 if( fclose( fp ) != 0 ) 189 { 190 irc_usermsg( irc, "fclose() reported an error. Disk full?" ); 191 return STORAGE_OTHER_ERROR; 192 } 193 194 g_snprintf( new_path, 512, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" ); 195 if( unlink( new_path ) != 0 ) 196 { 197 if( errno != ENOENT ) 198 { 199 irc_usermsg( irc, "Error while removing old .nicks file" ); 200 return STORAGE_OTHER_ERROR; 201 } 202 } 203 if( rename( path, new_path ) != 0 ) 204 { 205 irc_usermsg( irc, "Error while renaming new .nicks file" ); 206 return STORAGE_OTHER_ERROR; 207 } 208 209 g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts~" ); 210 fp = fopen( path, "w" ); 211 if( !fp ) return STORAGE_OTHER_ERROR; 212 if( fprintf( fp, "%s", hash ) != strlen( hash ) ) 213 { 214 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 215 fclose( fp ); 216 return STORAGE_OTHER_ERROR; 217 } 218 g_free( hash ); 219 220 for( a = irc->accounts; a; a = a->next ) 221 { 222 if( !strcmp(a->prpl->name, "oscar") ) 223 g_snprintf( s, sizeof( s ), "account add oscar \"%s\" \"%s\" %s", a->user, a->pass, a->server ); 224 else 225 g_snprintf( s, sizeof( s ), "account add %s \"%s\" \"%s\" \"%s\"", 226 a->prpl->name, a->user, a->pass, a->server ? a->server : "" ); 102 227 103 http_decode( s ); 104 nick_set( acc, s, nick ); 105 } 106 fclose( fp ); 228 line = obfucrypt( s, irc->password ); 229 if( *line ) 230 { 231 if( fprintf( fp, "%s\n", line ) != strlen( line ) + 1 ) 232 { 233 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 234 fclose( fp ); 235 return STORAGE_OTHER_ERROR; 236 } 237 } 238 g_free( line ); 239 } 240 241 for( set = irc->set; set; set = set->next ) 242 { 243 if( set->value && set->def ) 244 { 245 g_snprintf( s, sizeof( s ), "set %s \"%s\"", set->key, set->value ); 246 line = obfucrypt( s, irc->password ); 247 if( *line ) 248 { 249 if( fprintf( fp, "%s\n", line ) != strlen( line ) + 1 ) 250 { 251 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 252 fclose( fp ); 253 return STORAGE_OTHER_ERROR; 254 } 255 } 256 g_free( line ); 257 } 258 } 259 260 if( strcmp( irc->mynick, ROOT_NICK ) != 0 ) 261 { 262 g_snprintf( s, sizeof( s ), "rename %s %s", ROOT_NICK, irc->mynick ); 263 line = obfucrypt( s, irc->password ); 264 if( *line ) 265 { 266 if( fprintf( fp, "%s\n", line ) != strlen( line ) + 1 ) 267 { 268 irc_usermsg( irc, "fprintf() wrote too little. Disk full?" ); 269 fclose( fp ); 270 return STORAGE_OTHER_ERROR; 271 } 272 } 273 g_free( line ); 274 } 275 if( fclose( fp ) != 0 ) 276 { 277 irc_usermsg( irc, "fclose() reported an error. Disk full?" ); 278 return STORAGE_OTHER_ERROR; 279 } 280 281 g_snprintf( new_path, 512, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" ); 282 if( unlink( new_path ) != 0 ) 283 { 284 if( errno != ENOENT ) 285 { 286 irc_usermsg( irc, "Error while removing old .accounts file" ); 287 return STORAGE_OTHER_ERROR; 288 } 289 } 290 if( rename( path, new_path ) != 0 ) 291 { 292 irc_usermsg( irc, "Error while renaming new .accounts file" ); 293 return STORAGE_OTHER_ERROR; 294 } 295 296 umask( ou ); 107 297 108 298 return STORAGE_OK; … … 153 343 .check_pass = text_check_pass, 154 344 .remove = text_remove, 155 .load = text_load 345 .load = text_load, 346 .save = text_save 156 347 }; -
unix.c
reda0270 r6398094 48 48 49 49 b_main_init(); 50 50 51 log_init(); 52 51 53 nogaim_init(); 52 53 srand( time( NULL ) ^ getpid() ); 54 54 55 55 CONF_FILE = g_strdup( CONF_FILE_DEF ); 56 56 57 global.helpfile = g_strdup( HELP_FILE ); 57 58 58 59 global.conf = conf_load( argc, argv ); 59 60 if( global.conf == NULL ) 60 61 return( 1 ); 61 62 63 62 64 if( global.conf->runmode == RUNMODE_INETD ) 63 65 { … … 87 89 if( i != 0 ) 88 90 return( i ); 89 91 90 92 global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage ); 91 93 if ( global.storage == NULL) { -
user.c
reda0270 r6398094 67 67 68 68 u->user = u->realname = u->host = u->nick = g_strdup( nick ); 69 u->is_private = set_getint( &irc->set, "private" );69 u->is_private = set_getint( irc, "private" ); 70 70 71 71 key = g_strdup( nick ); … … 143 143 user_t *user_findhandle( struct gaim_connection *gc, char *handle ) 144 144 { 145 user_t *u; 146 char *nick; 147 148 /* First, let's try a hash lookup. If it works, it's probably faster. */ 149 if( ( nick = g_hash_table_lookup( gc->acc->nicks, handle ) ) && 150 ( u = user_find( gc->irc, nick ) ) && 151 ( gc->acc->prpl->handle_cmp( handle, u->handle ) == 0 ) ) 152 return u; 153 154 /* However, it doesn't always work, so in that case we'll have to dig 155 through the whole userlist. :-( */ 156 for( u = gc->irc->users; u; u = u->next ) 157 if( u->gc == gc && u->handle && gc->acc->prpl->handle_cmp( u->handle, handle ) == 0 ) 158 return u; 159 160 return NULL; 145 user_t *u = gc->irc->users; 146 147 while( u ) 148 { 149 if( u->gc == gc && u->handle && gc->prpl->cmp_buddynames ( u->handle, handle ) == 0 ) 150 break; 151 u = u->next; 152 } 153 154 return( u ); 161 155 } 162 156
Note: See TracChangeset
for help on using the changeset viewer.