Changes in / [4eb4c0f:ca60550]
- Files:
-
- 3 deleted
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r4eb4c0f rca60550 10 10 11 11 # Program variables 12 objects = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o otr.oquery.o root_commands.o set.o storage.o $(STORAGE_OBJS) unix.o user.o13 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ipc.h irc.h log.h nick.h otr.hquery.h set.h sock.h storage.h user.h lib/events.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/nogaim.h12 objects = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) unix.o user.o 13 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h user.h lib/events.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/nogaim.h 14 14 subdirs = lib protocols 15 15 … … 84 84 mkdir -p $(DESTDIR)$(ETCDIR) 85 85 install -m 0644 motd.txt $(DESTDIR)$(ETCDIR)/motd.txt 86 install -m 0644 welcome.txt $(DESTDIR)$(ETCDIR)/welcome.txt87 86 install -m 0644 bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf 88 87 89 88 uninstall-etc: 90 89 rm -f $(DESTDIR)$(ETCDIR)/motd.txt 91 rm -f $(DESTDIR)$(ETCDIR)/welcome.txt92 90 rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf 93 91 -rmdir $(DESTDIR)$(ETCDIR) -
bitlbee.c
r4eb4c0f rca60550 143 143 log_link( LOGLVL_ERROR, LOGOUTPUT_IRC ); 144 144 log_link( LOGLVL_WARNING, LOGOUTPUT_IRC ); 145 /* TODO: Remove debugging log_link's */146 log_link( LOGLVL_INFO, LOGOUTPUT_IRC );147 log_link( LOGLVL_DEBUG, LOGOUTPUT_IRC );148 145 149 146 return( 0 ); -
bitlbee.conf
r4eb4c0f rca60550 73 73 # MotdFile = /etc/bitlbee/motd.txt 74 74 75 ## WelcomeFile76 ##77 ## Specify an alternative file for the welcome message displayed when joining the78 ## control channel. Default value depends on the --etcdir argument to configure.79 ##80 # WelcomeFile = /etc/bitlbee/welcome.txt81 82 75 ## ConfigDir 83 76 ## -
bitlbee.h
r4eb4c0f rca60550 137 137 #include "misc.h" 138 138 #include "proxy.h" 139 #include "otr.h"140 139 141 140 typedef struct global { … … 149 148 char *helpfile; 150 149 int restart; 151 OtrlMessageAppOps otr_ops; /* collects interface functions required by OTR */152 150 } global_t; 153 151 -
conf.c
r4eb4c0f rca60550 59 59 conf->pidfile = g_strdup( PIDFILE ); 60 60 conf->motdfile = g_strdup( ETCDIR "/motd.txt" ); 61 conf->welcomefile = g_strdup( ETCDIR "/welcome.txt" );62 61 conf->ping_interval = 180; 63 62 conf->ping_timeout = 300; … … 244 243 g_free( conf->motdfile ); 245 244 conf->motdfile = g_strdup( ini->value ); 246 }247 else if( g_strcasecmp( ini->key, "welcomefile" ) == 0 )248 {249 g_free( conf->welcomefile );250 conf->welcomefile = g_strdup( ini->value );251 245 } 252 246 else if( g_strcasecmp( ini->key, "account_storage" ) == 0 ) -
conf.h
r4eb4c0f rca60550 45 45 char *pidfile; 46 46 char *motdfile; 47 char *welcomefile;48 47 char *primary_storage; 49 48 char **migrate_storage; -
configure
r4eb4c0f rca60550 30 30 gcov=0 31 31 plugins=1 32 otr=auto33 32 34 33 events=glib … … 71 70 --gcov=0/1 Disable/enable test coverage reporting $gcov 72 71 --plugins=0/1 Disable/enable plugins support $plugins 73 --otr=0/1/auto Disable/enable OTR encryption support $otr74 72 75 73 --events=... Event handler (glib, libevent) $events … … 176 174 if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then 177 175 cat<<EOF>>Makefile.settings 178 EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0 gthread-2.0`179 CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0 gthread-2.0`176 EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0` 177 CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0` 180 178 EOF 181 179 else … … 387 385 fi 388 386 389 if [ "$otr" = "auto" ]; then390 for i in /lib /usr/lib /usr/local/lib; do391 if [ -f $i/libotr.a ]; then392 otr=1393 break394 fi395 done396 fi397 if [ "$otr" = 0 ]; then398 echo '#undef WITH_OTR' >> config.h399 else400 echo '#define WITH_OTR' >> config.h401 echo "EFLAGS+=-lotr" >> Makefile.settings402 fi403 404 387 echo 405 388 if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then … … 521 504 fi 522 505 523 if [ "$otr" = "1" ]; then524 echo ' Off-the-Record (OTR) Messaging enabled.'525 else526 echo ' Off-the-Record (OTR) Messaging disabled.'527 fi528 529 506 echo ' Using event handler: '$events 530 507 echo ' Using SSL library: '$ssl -
doc/README
r4eb4c0f rca60550 48 48 BitlBee's only real dependency is GLib. This is available on virtually every 49 49 platform. Any recent version of GLib (2.4 or higher) will work. 50 51 Off-the-Record encryption support will be included by default if the52 configure script finds libotr in one of the usual places. You can pass53 --otr=1 or --otr=0 to force it on or off, respectively.54 50 55 51 These days, MSN Messenger clients have to connect to the MS Passport servers … … 156 152 157 153 158 A NOTE ON PASSWORDENCRYPTION159 ==================== =========154 A NOTE ON ENCRYPTION 155 ==================== 160 156 161 157 There used to be a note here about the simple obfuscation method used to -
doc/user-guide/commands.xml
r4eb4c0f rca60550 244 244 </description> 245 245 </bitlbee-command> 246 247 <bitlbee-command name="otr">248 <short-description>Off-the-Record encryption control</short-description>249 <syntax>otr <subcommand> [<arguments>]</syntax>250 251 <description>252 253 <para>254 Available subcommands: connect, disconnect, smp, trust, info, keygen, and forget. See <emphasis>help otr <subcommand></emphasis> for more information.255 </para>256 257 </description>258 259 <bitlbee-command name="connect">260 <syntax>otr connect <nick></syntax>261 262 <description>263 264 <para>265 Attempts to establish an encrypted connection with the specified user by sending a magic string.266 </para>267 268 </description>269 270 </bitlbee-command>271 272 <bitlbee-command name="disconnect">273 <syntax>otr disconnect <nick></syntax>274 275 <description>276 277 <para>278 Resets the connection with the specified user to cleartext.279 </para>280 281 </description>282 283 </bitlbee-command>284 285 <bitlbee-command name="smp">286 <syntax>otr smp <nick> <secret></syntax>287 288 <description>289 290 <para>291 Attempts to authenticate the given user's active fingerprint via the Socialist Millionaires' Protocol.292 </para>293 294 <para>295 If an SMP challenge has already been received from the given user, responds with the specified secret. Otherwise, a challenge for the secret will be sent. If the protocol succeeds (i.e. both parties gave the same secret), the fingerprint will be trusted.296 </para>297 298 </description>299 300 </bitlbee-command>301 302 <bitlbee-command name="trust">303 <syntax>otr trust <nick> <fp1> <fp2> <fp3> <fp4> <fp5></syntax>304 305 <description>306 307 <para>308 Manually affirms trust in the specified fingerprint, given as five blocks of precisely eight (hexadecimal) digits each.309 </para>310 311 </description>312 313 </bitlbee-command>314 315 <bitlbee-command name="info">316 <syntax>otr info</syntax>317 <syntax>otr info <nick></syntax>318 319 <description>320 321 <para>322 Shows information about the OTR state. The first form lists our private keys and current OTR contexts. The second form displays information about the connection with a given user, including the list of their known fingerprints.323 </para>324 325 </description>326 327 </bitlbee-command>328 329 <bitlbee-command name="keygen">330 <syntax>otr keygen <account-no></syntax>331 332 <description>333 334 <para>335 Generates a new OTR private key for the given account.336 </para>337 338 </description>339 340 </bitlbee-command>341 342 <bitlbee-command name="forget">343 <syntax>otr forget <thing> <arguments></syntax>344 345 <description>346 347 <para>348 Forgets some part of our OTR userstate. Available things: fingerprint and context. See <emphasis>help otr forget <thing></emphasis> for more information.349 </para>350 351 </description>352 353 <bitlbee-command name="fingerprint">354 <syntax>otr forget fingerprint <nick> <fingerprint></syntax>355 356 <description>357 358 <para>359 Drops the specified fingerprint from the given user's OTR connection context. It is allowed to specify only a (unique) prefix of the desired fingerprint.360 </para>361 362 </description>363 364 </bitlbee-command>365 366 <bitlbee-command name="context">367 <syntax>otr forget context <nick></syntax>368 369 <description>370 371 <para>372 Forgets the entire OTR context associated with the given user. This includes current message and protocol states, as well as any fingerprints for that user.373 </para>374 375 </description>376 377 </bitlbee-command>378 379 </bitlbee-command>380 381 </bitlbee-command>382 246 383 247 <bitlbee-command name="set"> … … 534 398 </bitlbee-setting> 535 399 536 <bitlbee-setting name="color_encrypted" type="boolean" scope="global">537 <default>true</default>538 539 <description>540 <para>541 If set to true, BitlBee will color incoming encrypted messages according to their fingerprint trust level: untrusted=red, trusted=green.542 </para>543 </description>544 545 </bitlbee-setting>546 547 400 <bitlbee-setting name="debug" type="boolean" scope="global"> 548 401 <default>false</default> … … 611 464 </bitlbee-setting> 612 465 613 <bitlbee-setting name="halfop_buddies" type="string" scope="global">614 <default>encrypted</default>615 <possible-values>encrypted, trusted, notaway, false</possible-values>616 617 <description>618 <para>619 Specifies under which circumstances BitlBee should give the "halfop" mode flag (+h) to buddies.620 </para>621 622 <para>623 If "false", the flag is never set. On "notaway", the flag is removed for users marked as "away" and set for all others. On "encrypted", the flag is set for users with whom we have an encrypted connection. On "trusted", it is set only for encrypted connections using a trusted key.624 </para>625 </description>626 627 </bitlbee-setting>628 629 466 <bitlbee-setting name="lcnicks" type="boolean" scope="global"> 630 467 <default>true</default> … … 649 486 </bitlbee-setting> 650 487 651 <bitlbee-setting name="op_buddies" type="string" scope="global"> 652 <default>trusted</default> 653 <possible-values>encrypted, trusted, notaway, false</possible-values> 654 655 <description> 656 <para> 657 Specifies under which circumstances BitlBee should give the "op" mode flag (+o) to buddies. 658 </para> 659 660 <para> 661 If "false", the flag is never set. On "notaway", the flag is removed for users marked as "away" and set for all others. On "encrypted", the flag is set for users with whom we have an encrypted connection. On "trusted", it is set only for encrypted connections using a trusted key. 662 </para> 663 </description> 664 665 </bitlbee-setting> 666 667 <bitlbee-setting name="op_root" type="bool" scope="global"> 668 <default>true</default> 669 670 <description> 671 <para> 672 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can set the desired state for root using this setting. 673 </para> 674 </description> 675 </bitlbee-setting> 676 677 <bitlbee-setting name="op_user" type="bool" scope="global"> 678 <default>true</default> 679 680 <description> 681 <para> 682 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can set the desired state for yourself using this setting. 683 </para> 684 </description> 685 </bitlbee-setting> 686 687 <bitlbee-setting name="otr_policy" type="string" scope="global"> 688 <default>opportunistic</default> 689 <possible-values>never, opportunistic, manual, always</possible-values> 690 691 <description> 692 <para> 693 This setting controls the policy for establishing Off-the-Record connections. 694 </para> 695 <para> 696 A value of "never" effectively disables the OTR subsystem. In "opportunistic" mode, a magic whitespace pattern will be appended to the first message sent to any user. If the peer is also running opportunistic OTR, an encrypted connection will be set up automatically. On "manual", on the other hand, OTR connections must be established explicitly using <emphasis>otr connect</emphasis>. Finally, the setting "always" enforces encrypted communication by causing BitlBee to refuse to send any cleartext messages at all. 488 <bitlbee-setting name="ops" type="string" scope="global"> 489 <default>both</default> 490 <possible-values>both, root, user, none</possible-values> 491 492 <description> 493 <para> 494 Some people prefer themself and root to have operator status in &bitlbee, other people don't. You can change these states using this setting. 495 </para> 496 497 <para> 498 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. 697 499 </para> 698 500 </description> … … 878 680 </para> 879 681 </description> 880 </bitlbee-setting>881 882 <bitlbee-setting name="voice_buddies" type="string" scope="global">883 <default>trusted</default>884 <possible-values>encrypted, trusted, notaway, false</possible-values>885 886 <description>887 <para>888 Specifies under which circumstances BitlBee should give the "voice" mode flag (+v) to buddies.889 </para>890 891 <para>892 If "false", the flag is never set. On "notaway", the flag is removed for users marked as "away" and set for all others. On "encrypted", the flag is set for users with whom we have an encrypted connection. On "trusted", it is set only for encrypted connections using a trusted key.893 </para>894 </description>895 896 682 </bitlbee-setting> 897 683 -
irc.c
r4eb4c0f rca60550 28 28 #include "crypting.h" 29 29 #include "ipc.h" 30 #include <sys/types.h>31 #include <sys/wait.h>32 30 33 31 static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond ); 34 static void irc_welcome( irc_t *irc );35 32 36 33 GSList *irc_connection_list = NULL; … … 105 102 106 103 irc_connection_list = g_slist_append( irc_connection_list, irc ); 107 104 105 set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc ); 108 106 set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); 109 107 set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc ); … … 112 110 set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 113 111 set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc ); 114 set_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc );115 112 set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 116 113 set_add( &irc->set, "default_target", "root", NULL, irc ); 117 114 set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 118 115 set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 119 set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc );120 116 set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); 121 set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc ); 122 set_add( &irc->set, "op_root", "true", set_eval_op_root, irc ); 123 set_add( &irc->set, "op_user", "true", set_eval_op_user, irc ); 124 set_add( &irc->set, "otr_policy", "opportunistic", set_eval_otr_policy, irc ); 117 set_add( &irc->set, "ops", "both", set_eval_ops, irc ); 125 118 set_add( &irc->set, "password", NULL, passchange, irc ); 126 119 set_add( &irc->set, "private", "true", set_eval_bool, irc ); … … 131 124 set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 132 125 set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); 133 set_add( &irc->set, "voice_buddies", "notaway", set_eval_voice_buddies, irc );134 126 135 127 conf_loaddefaults( irc ); 136 137 irc->otr = otr_new();138 128 139 129 return( irc ); … … 274 264 g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL); 275 265 g_hash_table_destroy(irc->watches); 276 277 otr_free(irc->otr);278 266 279 267 g_free(irc); … … 632 620 } 633 621 634 const char *user_mode_prefix( irc_t *irc, user_t *u )635 {636 static char op[] = "@";637 static char halfop[] = "%";638 static char voice[] = "+";639 static char none[] = "";640 641 int or = set_getbool(&irc->set, "op_root");642 int ou = set_getbool(&irc->set, "op_user");643 char *ob = set_getstr(&irc->set, "op_buddies");644 char *hb = set_getstr(&irc->set, "halfop_buddies");645 char *vb = set_getstr(&irc->set, "voice_buddies");646 647 if( (!strcmp(u->nick, irc->mynick) && or) ||648 (!strcmp(u->nick, irc->nick) && ou) ||649 (!u->away && !strcmp(ob, "notaway")) ||650 (u->encrypted && !strcmp(ob, "encrypted")) ||651 (u->encrypted>1 && !strcmp(ob, "trusted"))652 )653 return op;654 else if( (!u->away && !strcmp(hb, "notaway")) ||655 (u->encrypted && !strcmp(hb, "encrypted")) ||656 (u->encrypted>1 && !strcmp(hb, "trusted"))657 )658 return halfop;659 else if( (!u->away && !strcmp(vb, "notaway")) ||660 (u->encrypted && !strcmp(vb, "encrypted")) ||661 (u->encrypted>1 && !strcmp(vb, "trusted"))662 )663 return voice;664 else665 return none;666 }667 668 622 void irc_names( irc_t *irc, char *channel ) 669 623 { … … 671 625 char namelist[385] = ""; 672 626 struct groupchat *c = NULL; 627 char *ops = set_getstr( &irc->set, "ops" ); 673 628 674 629 /* RFCs say there is no error reply allowed on NAMES, so when the … … 685 640 } 686 641 687 strcat( namelist, user_mode_prefix(irc, u) ); 642 if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) ) 643 strcat( namelist, "+" ); 644 else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) || 645 ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ) 646 strcat( namelist, "@" ); 647 688 648 strcat( namelist, u->nick ); 689 649 strcat( namelist, " " ); … … 696 656 /* root and the user aren't in the channel userlist but should 697 657 show up in /NAMES, so list them first: */ 698 sprintf( namelist, "%s%s %s%s ", s et_getbool(&irc->set, "op_root") ? "@" : "", irc->mynick,699 s et_getbool(&irc->set, "op_user") ? "@" : "", irc->nick );658 sprintf( namelist, "%s%s %s%s ", strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->mynick, 659 strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->nick ); 700 660 701 661 for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->ic, l->data ) ) ) … … 707 667 } 708 668 709 strcat( namelist, user_mode_prefix(irc, u) );710 669 strcat( namelist, u->nick ); 711 670 strcat( namelist, " " ); … … 749 708 irc_reply( irc, 3, ":%s", IRCD_INFO ); 750 709 irc_reply( irc, 4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES ); 751 irc_reply( irc, 5, "PREFIX=(o hv)@%%+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 );710 irc_reply( irc, 5, "PREFIX=(ov)@+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 ); 752 711 irc_motd( irc ); 753 712 irc->umode[0] = '\0'; … … 776 735 irc_spawn( irc, u ); 777 736 778 irc_ welcome( irc);737 irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQs are answered there." ); 779 738 780 739 if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) … … 782 741 783 742 irc->status |= USTATUS_LOGGED_IN; 784 }785 786 static void irc_welcome( irc_t *irc )787 {788 FILE *f;789 790 f = fopen( global.conf->welcomefile, "r" );791 if( !f )792 {793 irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQs are answered there.\n\nOTR users please note: Private key files are owned by the user BitlBee is running as." );794 }795 else796 {797 char linebuf[380];798 799 while( fgets( linebuf, 380, f ) )800 {801 irc_usermsg( irc, linebuf );802 }803 804 fclose( f );805 }806 743 } 807 744 -
irc.h
r4eb4c0f rca60550 27 27 #define _IRC_H 28 28 29 #include "otr.h"30 31 29 #define IRC_MAX_LINE 512 32 #define IRC_MAX_ARGS 1630 #define IRC_MAX_ARGS 8 33 31 34 32 #define IRC_LOGIN_TIMEOUT 60 … … 96 94 gint w_watch_source_id; 97 95 gint ping_source_id; 98 99 otr_t *otr; /* OTR state and book keeping */100 96 } irc_t; 101 97 -
lib/misc.c
r4eb4c0f rca60550 112 112 { "gt", ">" }, 113 113 { "amp", "&" }, 114 { "apos", "'" },115 114 { "quot", "\"" }, 116 115 { "aacute", "á" }, … … 144 143 char *s = out, *cs; 145 144 int i, matched; 146 int taglen;147 145 148 146 memset( out, 0, strlen( in ) + 1 ); … … 161 159 in ++; 162 160 163 taglen = in-cs-1; /* not <0 because the above loop runs at least once */164 161 if( *in ) 165 162 { 166 if( g_strncasecmp( cs+1, "b", taglen) == 0 ) 167 *(s++) = '\x02'; 168 else if( g_strncasecmp( cs+1, "/b", taglen) == 0 ) 169 *(s++) = '\x02'; 170 else if( g_strncasecmp( cs+1, "i", taglen) == 0 ) 171 *(s++) = '\x1f'; 172 else if( g_strncasecmp( cs+1, "/i", taglen) == 0 ) 173 *(s++) = '\x1f'; 174 else if( g_strncasecmp( cs+1, "br", 2) == 0 ) 163 if( g_strncasecmp( cs+1, "br", 2) == 0 ) 175 164 *(s++) = '\n'; 176 165 in ++; -
log.c
r4eb4c0f rca60550 30 30 static log_t logoutput; 31 31 32 static void log_null(int level, c onst char *logmessage);33 static void log_irc(int level, c onst char *logmessage);34 static void log_syslog(int level, c onst char *logmessage);35 static void log_console(int level, c onst char *logmessage);32 static void log_null(int level, char *logmessage); 33 static void log_irc(int level, char *logmessage); 34 static void log_syslog(int level, char *logmessage); 35 static void log_console(int level, char *logmessage); 36 36 37 37 void log_init(void) { … … 97 97 } 98 98 99 void log_message(int level, c onst char *message, ... ) {99 void log_message(int level, char *message, ... ) { 100 100 101 101 va_list ap; … … 122 122 } 123 123 124 void log_error(c onst char *functionname) {124 void log_error(char *functionname) { 125 125 log_message(LOGLVL_ERROR, "%s: %s", functionname, strerror(errno)); 126 126 … … 128 128 } 129 129 130 static void log_null(int level, c onst char *message) {130 static void log_null(int level, char *message) { 131 131 return; 132 132 } 133 133 134 static void log_irc(int level, c onst char *message) {134 static void log_irc(int level, char *message) { 135 135 if(level == LOGLVL_ERROR) 136 136 irc_write_all(1, "ERROR :Error: %s", message); … … 147 147 } 148 148 149 static void log_syslog(int level, c onst char *message) {149 static void log_syslog(int level, char *message) { 150 150 if(level == LOGLVL_ERROR) 151 151 syslog(LOG_ERR, "%s", message); … … 161 161 } 162 162 163 static void log_console(int level, c onst char *message) {163 static void log_console(int level, char *message) { 164 164 if(level == LOGLVL_ERROR) 165 165 fprintf(stderr, "Error: %s\n", message); -
log.h
r4eb4c0f rca60550 44 44 45 45 typedef struct log_t { 46 void (*error)(int level, c onst char *logmessage);47 void (*warning)(int level, c onst char *logmessage);48 void (*informational)(int level, c onst char *logmessage);46 void (*error)(int level, char *logmessage); 47 void (*warning)(int level, char *logmessage); 48 void (*informational)(int level, char *logmessage); 49 49 #ifdef DEBUG 50 void (*debug)(int level, c onst char *logmessage);50 void (*debug)(int level, char *logmessage); 51 51 #endif 52 52 } log_t; … … 54 54 void log_init(void); 55 55 void log_link(int level, int output); 56 void log_message(int level, c onst char *message, ...) G_GNUC_PRINTF( 2, 3 );57 void log_error(c onst char *functionname);56 void log_message(int level, char *message, ...) G_GNUC_PRINTF( 2, 3 ); 57 void log_error(char *functionname); 58 58 59 59 #endif -
protocols/jabber/jabber.c
r4eb4c0f rca60550 511 511 512 512 ret->name = "jabber"; 513 ret->mms = 0; /* no limit */514 513 ret->login = jabber_login; 515 514 ret->init = jabber_init; -
protocols/msn/msn.c
r4eb4c0f rca60550 372 372 373 373 ret->name = "msn"; 374 ret->mms = 1409; /* this guess taken from libotr UPGRADING file */375 374 ret->login = msn_login; 376 375 ret->init = msn_init; -
protocols/nogaim.c
r4eb4c0f rca60550 603 603 604 604 /* LISPy... */ 605 if( ( u->online ) && /* Don't touch offline people */ 606 ( ( ( u->online != oo ) && !u->away ) || /* Do joining people */ 607 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* Do people changing state */ 605 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 606 ( u->online ) && /* Don't touch offline people */ 607 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 608 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 608 609 { 609 610 char *from; … … 618 619 ic->irc->myhost ); 619 620 } 620 if(!strcmp(set_getstr(&ic->irc->set, "voice_buddies"), "notaway")) { 621 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 622 u->away?'-':'+', u->nick ); 623 } 624 if(!strcmp(set_getstr(&ic->irc->set, "halfop_buddies"), "notaway")) { 625 irc_write( ic->irc, ":%s MODE %s %ch %s", from, ic->irc->channel, 626 u->away?'-':'+', u->nick ); 627 } 628 if(!strcmp(set_getstr(&ic->irc->set, "op_buddies"), "notaway")) { 629 irc_write( ic->irc, ":%s MODE %s %co %s", from, ic->irc->channel, 630 u->away?'-':'+', u->nick ); 631 } 621 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 622 u->away?'-':'+', u->nick ); 632 623 g_free( from ); 633 624 } … … 639 630 char *wrapped; 640 631 user_t *u; 641 642 /* pass the message through OTR */ 643 msg = otr_handle_message(ic, handle, msg); 644 if(!msg) { 645 /* this was an internal OTR protocol message */ 646 return; 647 } 648 632 649 633 u = user_findhandle( ic, handle ); 634 650 635 if( !u ) 651 636 { … … 657 642 imcb_log( ic, "Ignoring message from unknown handle %s", handle ); 658 643 659 g_free(msg);660 644 return; 661 645 } … … 690 674 irc_msgfrom( irc, u->nick, wrapped ); 691 675 g_free( wrapped ); 692 g_free( msg );693 676 } 694 677 … … 931 914 932 915 916 /* Misc. BitlBee stuff which shouldn't really be here */ 917 918 char *set_eval_away_devoice( set_t *set, char *value ) 919 { 920 irc_t *irc = set->data; 921 int st; 922 923 if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) ) 924 st = 1; 925 else if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) ) 926 st = 0; 927 else if( sscanf( value, "%d", &st ) != 1 ) 928 return( NULL ); 929 930 st = st != 0; 931 932 /* Horror.... */ 933 934 if( st != set_getbool( &irc->set, "away_devoice" ) ) 935 { 936 char list[80] = ""; 937 user_t *u = irc->users; 938 int i = 0, count = 0; 939 char pm; 940 char v[80]; 941 942 if( st ) 943 pm = '+'; 944 else 945 pm = '-'; 946 947 while( u ) 948 { 949 if( u->ic && u->online && !u->away ) 950 { 951 if( ( strlen( list ) + strlen( u->nick ) ) >= 79 ) 952 { 953 for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0; 954 irc_write( irc, ":%s MODE %s %c%s%s", 955 irc->myhost, 956 irc->channel, pm, v, list ); 957 958 *list = 0; 959 count = 0; 960 } 961 962 sprintf( list + strlen( list ), " %s", u->nick ); 963 count ++; 964 } 965 u = u->next; 966 } 967 968 /* $v = 'v' x $i */ 969 for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0; 970 irc_write( irc, ":%s MODE %s %c%s%s", irc->myhost, 971 irc->channel, pm, v, list ); 972 } 973 974 return( set_eval_bool( set, value ) ); 975 } 976 977 978 979 933 980 /* The plan is to not allow straight calls to prpl functions anymore, but do 934 981 them all from some wrappers. We'll start to define some down here: */ … … 944 991 msg = buf; 945 992 } 946 947 /* if compiled without otr support, this just calls the prpl buddy_msg */ 948 st = otr_send_message(ic, handle, msg, flags); 949 950 g_free(buf); 993 994 st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags ); 995 g_free( buf ); 996 951 997 return st; 952 998 } -
protocols/nogaim.h
r4eb4c0f rca60550 136 136 * - The user sees this name ie. when imcb_log() is used. */ 137 137 const char *name; 138 /* Maximum Message Size of this protocol.139 * - Introduced for OTR, in order to fragment large protocol messages.140 * - 0 means "unlimited". */141 unsigned int mms;142 138 143 139 /* Added this one to be able to add per-account settings, don't think … … 321 317 322 318 /* Misc. stuff */ 319 char *set_eval_away_devoice( set_t *set, char *value ); 323 320 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); 324 321 void cancel_auto_reconnect( struct account *a ); -
protocols/oscar/oscar.c
r4eb4c0f rca60550 2605 2605 struct prpl *ret = g_new0(struct prpl, 1); 2606 2606 ret->name = "oscar"; 2607 ret->mms = 2343; /* this guess taken from libotr UPGRADING file */2608 2607 ret->away_states = oscar_away_states; 2609 2608 ret->init = oscar_init; -
protocols/yahoo/yahoo.c
r4eb4c0f rca60550 354 354 struct prpl *ret = g_new0(struct prpl, 1); 355 355 ret->name = "yahoo"; 356 ret->mms = 832; /* this guess taken from libotr UPGRADING file */357 356 ret->init = byahoo_init; 358 357 -
query.c
r4eb4c0f rca60550 102 102 int count = 0; 103 103 104 if(!ic)105 return;106 107 104 q = irc->queries; 108 105 def = query_default( irc ); … … 143 140 if( ans ) 144 141 { 145 if(q->ic) 146 imcb_log( q->ic, "Accepted: %s", q->question ); 147 else 148 irc_usermsg( irc, "Accepted: %s", q->question ); 149 if(q->yes) 150 q->yes( q->ic ? (gpointer)q->ic : (gpointer)irc, q->data ); 142 imcb_log( q->ic, "Accepted: %s", q->question ); 143 q->yes( NULL, q->data ); 151 144 } 152 145 else 153 146 { 154 if(q->ic) 155 imcb_log( q->ic, "Rejected: %s", q->question ); 156 else 157 irc_usermsg( irc, "Rejected: %s", q->question ); 158 if(q->no) 159 q->no( q->ic ? (gpointer)q->ic : (gpointer)irc, q->data ); 147 imcb_log( q->ic, "Rejected: %s", q->question ); 148 q->no( NULL, q->data ); 160 149 } 161 150 q->data = NULL; -
root_commands.c
r4eb4c0f rca60550 29 29 #include "bitlbee.h" 30 30 #include "help.h" 31 #include "otr.h"32 31 33 32 #include <string.h> … … 242 241 243 242 irc_usermsg( irc, "Account successfully added" ); 244 245 if(otr_check_for_key(a)) {246 irc_usermsg(irc, "otr: you will be notified when it completes");247 }248 243 } 249 244 else if( g_strcasecmp( cmd[1], "del" ) == 0 ) … … 997 992 { "qlist", 0, cmd_qlist, 0 }, 998 993 { "join_chat", 2, cmd_join_chat, 0 }, 999 { "otr", 1, cmd_otr, 0 },1000 994 { NULL } 1001 995 }; -
set.c
r4eb4c0f rca60550 209 209 } 210 210 211 char *set_eval_op _root( set_t *set, char *value )211 char *set_eval_ops( set_t *set, char *value ) 212 212 { 213 213 irc_t *irc = set->data; 214 char *ret = set_eval_bool(set, value); 215 int b = bool2int(ret); 216 217 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 218 irc->channel, b?"+o":"-o", irc->mynick ); 219 return ret; 220 } 221 222 char *set_eval_op_user( set_t *set, char *value ) 223 { 224 irc_t *irc = set->data; 225 char *ret = set_eval_bool(set, value); 226 int b = bool2int(ret); 227 228 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 229 irc->channel, b?"+o":"-o", irc->nick ); 230 return ret; 231 } 232 233 /* generalized version of set_eval_op/voice_buddies */ 234 char *set_eval_mode_buddies( set_t *set, char *value, char modeflag ) 235 { 236 irc_t *irc = set->data; 237 char op[64], deop[64]; 238 int nop=0, ndeop=0; 239 user_t *u; 240 int mode; 241 242 if(!strcmp(value, "false")) 243 mode=0; 244 else if(!strcmp(value, "encrypted")) 245 mode=1; 246 else if(!strcmp(value, "trusted")) 247 mode=2; 248 else if(!strcmp(value, "notaway")) 249 mode=3; 214 215 if( g_strcasecmp( value, "user" ) == 0 ) 216 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 217 irc->channel, "+o-o", irc->nick, irc->mynick ); 218 else if( g_strcasecmp( value, "root" ) == 0 ) 219 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 220 irc->channel, "-o+o", irc->nick, irc->mynick ); 221 else if( g_strcasecmp( value, "both" ) == 0 ) 222 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 223 irc->channel, "+oo", irc->nick, irc->mynick ); 224 else if( g_strcasecmp( value, "none" ) == 0 ) 225 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 226 irc->channel, "-oo", irc->nick, irc->mynick ); 250 227 else 251 228 return NULL; 252 229 253 /* sorry for calling them op/deop - too lazy for search+replace :P */254 op[0]='\0';255 deop[0]='\0';256 for(u=irc->users; u; u=u->next) {257 /* we're only concerned with online buddies */258 if(!u->ic || !u->online)259 continue;260 261 /* just in case... */262 if(strlen(u->nick) >= 64)263 continue;264 265 /* dump out ops/deops when the corresponding name list fills up */266 if(strlen(op)+strlen(u->nick)+2 > 64) {267 char *flags = g_strnfill(nop, modeflag);268 irc_write( irc, ":%s!%s@%s MODE %s +%s%s", irc->mynick, irc->mynick, irc->myhost,269 irc->channel, flags, op );270 op[0]='\0';271 nop=0;272 g_free(flags);273 }274 if(strlen(deop)+strlen(u->nick)+2 > 64) {275 char *flags = g_strnfill(ndeop, modeflag);276 irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost,277 irc->channel, flags, deop );278 deop[0]='\0';279 ndeop=0;280 g_free(flags);281 }282 283 switch(mode) {284 /* "false" */285 case 0:286 g_strlcat(deop, " ", 64);287 g_strlcat(deop, u->nick, 64);288 ndeop++;289 break;290 /* "encrypted" */291 case 1:292 if(u->encrypted) {293 g_strlcat(op, " ", 64);294 g_strlcat(op, u->nick, 64);295 nop++;296 } else {297 g_strlcat(deop, " ", 64);298 g_strlcat(deop, u->nick, 64);299 ndeop++;300 }301 break;302 /* "trusted" */303 case 2:304 if(u->encrypted > 1) {305 g_strlcat(op, " ", 64);306 g_strlcat(op, u->nick, 64);307 nop++;308 } else {309 g_strlcat(deop, " ", 64);310 g_strlcat(deop, u->nick, 64);311 ndeop++;312 }313 break;314 /* "notaway" */315 case 3:316 if(u->away) {317 g_strlcat(deop, " ", 64);318 g_strlcat(deop, u->nick, 64);319 ndeop++;320 } else {321 g_strlcat(op, " ", 64);322 g_strlcat(op, u->nick, 64);323 nop++;324 }325 }326 }327 /* dump anything left in op/deop lists */328 if(*op) {329 char *flags = g_strnfill(nop, modeflag);330 irc_write( irc, ":%s!%s@%s MODE %s +%s%s", irc->mynick, irc->mynick, irc->myhost,331 irc->channel, flags, op );332 g_free(flags);333 }334 if(*deop) {335 char *flags = g_strnfill(ndeop, modeflag);336 irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost,337 irc->channel, flags, deop );338 g_free(flags);339 }340 341 230 return value; 342 }343 344 char *set_eval_op_buddies( set_t *set, char *value )345 {346 return set_eval_mode_buddies(set, value, 'o');347 }348 349 char *set_eval_halfop_buddies( set_t *set, char *value )350 {351 return set_eval_mode_buddies(set, value, 'h');352 }353 354 char *set_eval_voice_buddies( set_t *set, char *value )355 {356 return set_eval_mode_buddies(set, value, 'v');357 231 } 358 232 … … 371 245 return value; 372 246 } 373 374 /* possible values: never, opportunistic, manual, always */375 char *set_eval_otr_policy( set_t *set, char *value )376 {377 if ( !strcmp(value, "never") )378 return value;379 if ( !strcmp(value, "opportunistic") )380 return value;381 if ( !strcmp(value, "manual") )382 return value;383 if ( !strcmp(value, "always") )384 return value;385 return NULL;386 } -
set.h
r4eb4c0f rca60550 96 96 /* Some not very generic evaluators that really shouldn't be here... */ 97 97 char *set_eval_to_char( set_t *set, char *value ); 98 char *set_eval_op_root( set_t *set, char *value ); 99 char *set_eval_op_user( set_t *set, char *value ); 100 char *set_eval_op_buddies( set_t *set, char *value ); 101 char *set_eval_halfop_buddies( set_t *set, char *value ); 102 char *set_eval_voice_buddies( set_t *set, char *value ); 98 char *set_eval_ops( set_t *set, char *value ); 103 99 char *set_eval_charset( set_t *set, char *value ); 104 char *set_eval_otr_policy( set_t *set, char *value );105 100 106 101 #endif /* __SET_H__ */ -
storage.c
r4eb4c0f rca60550 29 29 #include "bitlbee.h" 30 30 #include "crypting.h" 31 #include "otr.h"32 31 33 32 extern storage_t storage_text; … … 116 115 if (status == STORAGE_OK) { 117 116 irc_setpass(irc, password); 118 otr_load(irc); /* load our OTR userstate */119 117 return status; 120 118 } 121 119 122 if (status != STORAGE_NO_SUCH_USER) {120 if (status != STORAGE_NO_SUCH_USER) 123 121 return status; 124 }125 122 } 126 123 … … 130 127 storage_status_t storage_save (irc_t *irc, int overwrite) 131 128 { 132 storage_status_t st; 133 134 otr_save(irc); 135 st = ((storage_t *)global.storage->data)->save(irc, overwrite); 136 return st; 129 return ((storage_t *)global.storage->data)->save(irc, overwrite); 137 130 } 138 131 … … 154 147 ret = status; 155 148 } 156 if (ret == STORAGE_OK) {157 otr_remove(nick);158 }159 149 160 150 return ret; … … 167 157 storage_t *primary_storage = gl->data; 168 158 irc_t *irc; 169 159 170 160 /* First, try to rename in the current write backend, assuming onick 171 161 * is stored there */ 172 162 status = primary_storage->rename(onick, nnick, password); 173 if (status != STORAGE_NO_SUCH_USER) { 174 otr_rename(onick, nnick); 163 if (status != STORAGE_NO_SUCH_USER) 175 164 return status; 176 }177 165 178 166 /* Try to load from a migration backend and save to the current backend. … … 198 186 199 187 storage_remove(onick, password); 200 otr_rename(onick, nnick);201 188 202 189 return STORAGE_OK; -
unix.c
r4eb4c0f rca60550 27 27 #include "commands.h" 28 28 #include "crypting.h" 29 #include "otr.h"30 29 #include "protocols/nogaim.h" 31 30 #include "help.h" … … 55 54 b_main_init(); 56 55 nogaim_init(); 57 otr_init();58 56 59 57 srand( time( NULL ) ^ getpid() ); -
user.c
r4eb4c0f rca60550 141 141 } 142 142 143 user_t *user_findhandle( struct im_connection *ic, c onst char *handle )143 user_t *user_findhandle( struct im_connection *ic, char *handle ) 144 144 { 145 145 user_t *u; -
user.h
r4eb4c0f rca60550 37 37 char is_private; 38 38 char online; 39 char encrypted;40 39 41 40 char *handle; … … 57 56 int user_del( irc_t *irc, char *nick ); 58 57 G_MODULE_EXPORT user_t *user_find( irc_t *irc, char *nick ); 59 G_MODULE_EXPORT user_t *user_findhandle( struct im_connection *ic, c onst char *handle );58 G_MODULE_EXPORT user_t *user_findhandle( struct im_connection *ic, char *handle ); 60 59 void user_rename( irc_t *irc, char *oldnick, char *newnick ); 61 60
Note: See TracChangeset
for help on using the changeset viewer.