Changeset 6197702
- Timestamp:
- 2010-10-09T18:41:19Z (14 years ago)
- Branches:
- master
- Children:
- d150a9d
- Parents:
- 23b29c6 (diff), 27b407f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 2 added
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r23b29c6 r6197702 10 10 11 11 # Program variables 12 objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS)12 objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o $(OTR_BI) query.o root_commands.o set.o storage.o $(STORAGE_OBJS) 13 13 headers = bitlbee.h commands.h conf.h config.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h lib/events.h lib/ftutil.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/account.h protocols/bee.h protocols/ft.h protocols/nogaim.h 14 14 subdirs = lib protocols … … 27 27 subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o) 28 28 29 all: $(OUTFILE) 29 all: $(OUTFILE) $(OTR_PI) 30 30 $(MAKE) -C doc 31 31 … … 33 33 @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n' 34 34 35 install: install-bin install-doc 35 install: install-bin install-doc install-plugins 36 36 @if ! [ -d $(DESTDIR)$(CONFIG) ]; then echo -e '\nThe configuration directory $(DESTDIR)$(CONFIG) does not exist yet, don'\''t forget to create it!'; fi 37 37 @if ! [ -e $(DESTDIR)$(ETCDIR)/bitlbee.conf ]; then echo -e '\nNo files are installed in '$(DESTDIR)$(ETCDIR)' by make install. Run make install-etc to do that.'; fi 38 38 @echo 39 39 40 .PHONY: install install-bin install-etc install-doc \40 .PHONY: install install-bin install-etc install-doc install-plugins \ 41 41 uninstall uninstall-bin uninstall-etc uninstall-doc \ 42 42 all clean distclean tar $(subdirs) … … 104 104 -rmdir $(DESTDIR)$(ETCDIR) 105 105 106 install-plugins: 107 ifdef OTR_PI 108 mkdir -p $(DESTDIR)$(PLUGINDIR) 109 install -m 0755 otr.so $(DESTDIR)$(PLUGINDIR) 110 endif 111 106 112 tar: 107 113 fakeroot debian/rules clean || make distclean … … 112 118 $(subdirs): 113 119 @$(MAKE) -C $@ $(MAKECMDGOALS) 120 121 $(OTR_PI): %.so: $(SRCDIR)%.c 122 @echo '*' Building plugin $@ 123 @$(CC) $(CFLAGS) $(OTRFLAGS) -fPIC -shared $< -o $@ 114 124 115 125 $(objects): %.o: $(SRCDIR)%.c -
bitlbee.h
r23b29c6 r6197702 162 162 void root_command_string( irc_t *irc, char *command ); 163 163 void root_command( irc_t *irc, char *command[] ); 164 gboolean root_command_add( const char *command, int params, void (*func)(irc_t *, char **args), int flags ); 164 165 gboolean cmd_identify_finish( gpointer data, gint fd, b_input_condition cond ); 165 166 gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond ); -
commands.h
r23b29c6 r6197702 37 37 } command_t; 38 38 39 extern co nst command_tcommands[];39 extern command_t root_commands[]; 40 40 41 41 #define IRC_CMD_PRE_LOGIN 1 -
configure
r23b29c6 r6197702 34 34 gcov=0 35 35 plugins=1 36 otr=0 36 37 37 38 events=glib … … 72 73 73 74 --purple=0/1 Disable/enable libpurple support $purple 75 (automatically disables other protocol modules) 74 76 75 77 --debug=0/1 Disable/enable debugging $debug … … 77 79 --gcov=0/1 Disable/enable test coverage reporting $gcov 78 80 --plugins=0/1 Disable/enable plugins support $plugins 81 --otr=0/1/auto/plugin 82 Disable/enable OTR encryption support $otr 79 83 80 84 --events=... Event handler (glib, libevent) $events … … 489 493 fi 490 494 495 otrprefix="" 496 for i in / /usr /usr/local; do 497 if [ -f ${i}/lib/libotr.a ]; then 498 otrprefix=${i} 499 break 500 fi 501 done 502 if [ "$otr" = "auto" ]; then 503 if [ -n "$otrprefix" ]; then 504 otr=1 505 else 506 otr=0 507 fi 508 fi 509 if [ "$otr" = 1 ]; then 510 # BI == built-in 511 echo '#define OTR_BI' >> config.h 512 echo "EFLAGS+=-L${otrprefix}/lib -lotr" >> Makefile.settings 513 echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings 514 echo 'OTR_BI=otr.o' >> Makefile.settings 515 elif [ "$otr" = "plugin" ]; then 516 echo '#define OTR_PI' >> config.h 517 echo "OTRFLAGS=-L${otrprefix}/lib -lotr" >> Makefile.settings 518 echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings 519 echo 'OTR_PI=otr.so' >> Makefile.settings 520 fi 521 491 522 if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then 492 523 echo … … 683 714 fi 684 715 716 if [ "$otr" = "1" ]; then 717 echo ' Off-the-Record (OTR) Messaging enabled.' 718 elif [ "$otr" = "plugin" ]; then 719 echo ' Off-the-Record (OTR) Messaging enabled (as a plugin).' 720 else 721 echo ' Off-the-Record (OTR) Messaging disabled.' 722 fi 723 685 724 echo ' Using event handler: '$events 686 725 echo ' Using SSL library: '$ssl -
debian/control
r23b29c6 r6197702 5 5 Uploaders: Jelmer Vernooij <jelmer@samba.org> 6 6 Standards-Version: 3.8.4 7 Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), po-debconf, libpurple-dev, debhelper (>= 6)7 Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), po-debconf, libpurple-dev, libotr2-dev, debhelper (>= 6) 8 8 Homepage: http://www.bitlbee.org/ 9 9 Vcs-Bzr: http://code.bitlbee.org/bitlbee/ … … 59 59 . 60 60 This package holds development stuff for compiling plug-ins. 61 62 Package: bitlbee-plugin-otr 63 Architecture: any 64 Depends: ${misc:Depends}, ${shlibs:Depends}, bitlbee (= ${bee:Version}) | bitlbee-libpurple (= ${bee:Version}) 65 Description: An IRC to other chat networks gateway (default version) 66 This program can be used as an IRC server which forwards everything you 67 say to people on other chat networks: Jabber (which includes Google Talk 68 and Facebook Chat), ICQ, AIM, MSN, Yahoo! and Twitter/Identica/Status.net. 69 . 70 This package contains a plugin that adds support for Off-The-Record 71 encryption of instant messages. -
debian/rules
r23b29c6 r6197702 8 8 # 9 9 10 # Include the bitlbee-libpurple variant by default10 # Include the bitlbee-libpurple variant and OTR plugin by default 11 11 BITLBEE_LIBPURPLE ?= 1 12 BITLBEE_OTR ?= plugin 12 13 BITLBEE_CONFIGURE_FLAGS ?= 13 14 DEBUG ?= 0 … … 22 23 endif 23 24 25 ifneq ($(BITLBEE_OTR),plugin) 26 DH_OPTIONS += -Nbitlbee-plugin-otr 27 endif 28 24 29 build: build-stamp 25 30 build-stamp: … … 27 32 28 33 mkdir -p debian/build-native 29 ROOT=$$PWD; cd debian/build-native; $(BITLBEE_CONFIGURE_VERSION) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent $(BITLBEE_CONFIGURE_FLAGS)34 ROOT=$$PWD; cd debian/build-native; $(BITLBEE_CONFIGURE_VERSION) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent --otr=$(BITLBEE_OTR) $(BITLBEE_CONFIGURE_FLAGS) 30 35 $(MAKE) -C debian/build-native 31 36 … … 56 61 dh_installdirs 57 62 58 $(MAKE) -C debian/build-native install DESTDIR=`pwd`/debian/bitlbee59 $(MAKE) -C debian/build-native install-etc DESTDIR=`pwd`/debian/bitlbee-common63 $(MAKE) -C debian/build-native install-bin DESTDIR=`pwd`/debian/bitlbee 64 $(MAKE) -C debian/build-native install-etc install-doc DESTDIR=`pwd`/debian/bitlbee-common 60 65 $(MAKE) -C debian/build-native install-dev DESTDIR=`pwd`/debian/bitlbee-dev 61 patch debian/bitlbee-common/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff66 $(MAKE) -C debian/build-native install-plugins DESTDIR=`pwd`/debian/bitlbee-plugin-otr 62 67 63 68 ifeq ($(BITLBEE_LIBPURPLE),1) 64 $(MAKE) -C debian/build-libpurple install DESTDIR=`pwd`/debian/bitlbee-libpurple69 $(MAKE) -C debian/build-libpurple install-bin DESTDIR=`pwd`/debian/bitlbee-libpurple 65 70 ln -sf debian/bitlbee.prerm debian/bitlbee-libpurple.prerm 66 71 endif 67 72 68 mkdir -p debian/bitlbee-common/usr 69 mv debian/bitlbee/usr/share debian/bitlbee-common/usr 70 rm -rf debian/bitlbee-libpurple/usr/share 73 patch debian/bitlbee-common/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff 74 chmod 640 debian/bitlbee-common/etc/bitlbee/bitlbee.conf 71 75 72 76 binary-common: … … 79 83 # TODO: Restore --link-doc up here and remove the hack below once 80 84 # Hardy and Lenny are deprecated. 81 for p in bitlbee bitlbee-libpurple bitlbee-dev ; do rm -r debian/$$p/usr/share/doc/$$p && ln -s bitlbee-common debian/$$p/usr/share/doc/$$p; done85 for p in bitlbee bitlbee-libpurple bitlbee-dev bitlbee-plugin-otr; do rm -r debian/$$p/usr/share/doc/$$p && ln -s bitlbee-common debian/$$p/usr/share/doc/$$p || true; done 82 86 dh_installdebconf 83 87 dh_installinit --init-script=bitlbee -
doc/README
r23b29c6 r6197702 66 66 BitlBee's only real dependency is GLib. This is available on virtually every 67 67 platform. Any recent version of GLib (2.4 or higher) will work. 68 69 Off-the-Record encryption support can be included if libotr is available on 70 your machine. Pass --otr=1 to configure to build it into BitlBee, or 71 --otr=plugin to build it as a separate loadable plugin (mostly meant for 72 distro packages). 68 73 69 74 These days, many IM protocols use SSL/TLS connections (for authentication … … 145 150 146 151 147 A NOTE ON ENCRYPTION148 ==================== 152 A NOTE ON PASSWORD ENCRYPTION 153 ============================= 149 154 150 155 There used to be a note here about the simple obfuscation method used to -
doc/user-guide/commands.xml
r23b29c6 r6197702 367 367 </description> 368 368 </bitlbee-command> 369 370 <bitlbee-command name="otr"> 371 <short-description>Off-the-Record encryption control</short-description> 372 <syntax>otr <subcommand> [<arguments>]</syntax> 373 374 <description> 375 376 <para> 377 Available subcommands: connect, disconnect, smp, smpq, trust, info, keygen, and forget. See <emphasis>help otr <subcommand></emphasis> for more information. 378 </para> 379 380 </description> 381 382 <bitlbee-command name="connect"> 383 <syntax>otr connect <nick></syntax> 384 385 <description> 386 387 <para> 388 Attempts to establish an encrypted connection with the specified user by sending a magic string. 389 </para> 390 391 </description> 392 393 </bitlbee-command> 394 395 <bitlbee-command name="disconnect"> 396 <syntax>otr disconnect <nick></syntax> 397 398 <description> 399 400 <para> 401 Resets the connection with the specified user to cleartext. 402 </para> 403 404 </description> 405 406 </bitlbee-command> 407 408 <bitlbee-command name="smp"> 409 <syntax>otr smp <nick> <secret></syntax> 410 411 <description> 412 413 <para> 414 Attempts to authenticate the given user's active fingerprint via the Socialist Millionaires' Protocol. 415 </para> 416 417 <para> 418 If an SMP challenge has been received from the given user, responds with the specified secret/answer. Otherwise, sends a challenge for the given secret. 419 </para> 420 421 <para> 422 Note that there are two flavors of SMP challenges: "shared-secret" and "question & answer". This command is used to respond to both of them, or to initiate a shared-secret style exchange. Use the <emphasis>otr smpq</emphasis> command to initiate a "Q&A" session. 423 </para> 424 425 <para> 426 When responding to a "Q&A" challenge, the local trust value is not altered. Only the <emphasis>asking party</emphasis> sets trust in the case of success. Use <emphasis>otr smpq</emphasis> to pose your challenge. In a shared-secret exchange, both parties set their trust according to the outcome. 427 </para> 428 429 </description> 430 431 </bitlbee-command> 432 433 <bitlbee-command name="smpq"> 434 <syntax>otr smpq <nick> <question> <answer></syntax> 435 436 <description> 437 438 <para> 439 Attempts to authenticate the given user's active fingerprint via the Socialist Millionaires' Protocol, Q&A style. 440 </para> 441 442 <para> 443 Initiates an SMP session in "question & answer" style. The question is transmitted with the initial SMP packet and used to prompt the other party. You must be confident that only they know the answer. If the protocol succeeds (i.e. they answer correctly), the fingerprint will be trusted. Note that the answer must be entered exactly, case and punctuation count! 444 </para> 445 446 <para> 447 Note that this style of SMP only affects the trust setting on your side. Expect your opponent to send you their own challenge. Alternatively, if you and the other party have a shared secret, use the <emphasis>otr smp</emphasis> command. 448 </para> 449 450 </description> 451 452 </bitlbee-command> 453 454 <bitlbee-command name="trust"> 455 <syntax>otr trust <nick> <fp1> <fp2> <fp3> <fp4> <fp5></syntax> 456 457 <description> 458 459 <para> 460 Manually affirms trust in the specified fingerprint, given as five blocks of precisely eight (hexadecimal) digits each. 461 </para> 462 463 </description> 464 465 </bitlbee-command> 466 467 <bitlbee-command name="info"> 468 <syntax>otr info</syntax> 469 <syntax>otr info <nick></syntax> 470 471 <description> 472 473 <para> 474 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. 475 </para> 476 477 </description> 478 479 </bitlbee-command> 480 481 <bitlbee-command name="keygen"> 482 <syntax>otr keygen <account-no></syntax> 483 484 <description> 485 486 <para> 487 Generates a new OTR private key for the given account. 488 </para> 489 490 </description> 491 492 </bitlbee-command> 493 494 <bitlbee-command name="forget"> 495 <syntax>otr forget <thing> <arguments></syntax> 496 497 <description> 498 499 <para> 500 Forgets some part of our OTR userstate. Available things: fingerprint, context, and key. See <emphasis>help otr forget <thing></emphasis> for more information. 501 </para> 502 503 </description> 504 505 <bitlbee-command name="fingerprint"> 506 <syntax>otr forget fingerprint <nick> <fingerprint></syntax> 507 508 <description> 509 510 <para> 511 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. 512 </para> 513 514 </description> 515 516 </bitlbee-command> 517 518 <bitlbee-command name="context"> 519 <syntax>otr forget context <nick></syntax> 520 521 <description> 522 523 <para> 524 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. 525 </para> 526 527 </description> 528 529 </bitlbee-command> 530 531 <bitlbee-command name="key"> 532 <syntax>otr forget key <fingerprint></syntax> 533 534 <description> 535 536 <para> 537 Forgets an OTR private key matching the specified fingerprint. It is allowed to specify only a (unique) prefix of the fingerprint. 538 </para> 539 540 </description> 541 542 </bitlbee-command> 543 544 </bitlbee-command> 545 546 </bitlbee-command> 369 547 370 548 <bitlbee-command name="set"> … … 589 767 </description> 590 768 769 </bitlbee-setting> 770 771 <bitlbee-setting name="color_encrypted" type="boolean" scope="global"> 772 <default>true</default> 773 774 <description> 775 <para> 776 If set to true, BitlBee will color incoming encrypted messages according to their fingerprint trust level: untrusted=red, trusted=green. 777 </para> 778 </description> 591 779 </bitlbee-setting> 592 780 … … 931 1119 </bitlbee-setting> 932 1120 1121 <bitlbee-setting name="otr_policy" type="string" scope="global"> 1122 <default>opportunistic</default> 1123 <possible-values>never, opportunistic, manual, always</possible-values> 1124 1125 <description> 1126 <para> 1127 This setting controls the policy for establishing Off-the-Record connections. 1128 </para> 1129 <para> 1130 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. 1131 </para> 1132 </description> 1133 </bitlbee-setting> 1134 933 1135 <bitlbee-setting name="password" type="string" scope="both"> 934 1136 <description> -
irc.c
r23b29c6 r6197702 29 29 30 30 GSList *irc_connection_list; 31 GSList *irc_plugins; 31 32 32 33 static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond ); … … 42 43 char *host = NULL, *myhost = NULL; 43 44 irc_user_t *iu; 45 GSList *l; 44 46 set_t *s; 45 47 bee_t *b; … … 165 167 nogaim_init(); 166 168 169 for( l = irc_plugins; l; l = l->next ) 170 { 171 irc_plugin_t *p = l->data; 172 if( p->irc_new ) 173 p->irc_new( irc ); 174 } 175 167 176 return irc; 168 177 } … … 208 217 void irc_free( irc_t * irc ) 209 218 { 219 GSList *l; 220 210 221 irc->status |= USTATUS_SHUTDOWN; 211 222 … … 215 226 if( storage_save( irc, NULL, TRUE ) != STORAGE_OK ) 216 227 log_message( LOGLVL_WARNING, "Error while saving settings for user %s", irc->user->nick ); 228 229 for( l = irc_plugins; l; l = l->next ) 230 { 231 irc_plugin_t *p = l->data; 232 if( p->irc_free ) 233 p->irc_free( irc ); 234 } 217 235 218 236 irc_connection_list = g_slist_remove( irc_connection_list, irc ); … … 933 951 return SET_INVALID; 934 952 } 953 954 void register_irc_plugin( const struct irc_plugin *p ) 955 { 956 irc_plugins = g_slist_prepend( irc_plugins, (gpointer) p ); 957 } -
irc.h
r23b29c6 r6197702 28 28 29 29 #define IRC_MAX_LINE 512 30 #define IRC_MAX_ARGS 830 #define IRC_MAX_ARGS 16 31 31 32 32 #define IRC_LOGIN_TIMEOUT 60 … … 86 86 gint login_source_id; /* To slightly delay some events at login time. */ 87 87 88 struct otr *otr; /* OTR state and book keeping, used by the OTR plugin. 89 TODO: Some mechanism for plugindata. */ 90 88 91 struct bee *b; 89 92 } irc_t; … … 93 96 /* Replaced with iu->last_channel IRC_USER_PRIVATE = 1, */ 94 97 IRC_USER_AWAY = 2, 98 99 IRC_USER_OTR_ENCRYPTED = 0x10000, 100 IRC_USER_OTR_TRUSTED = 0x20000, 95 101 } irc_user_flags_t; 96 102 … … 214 220 } irc_channel_del_user_type_t; 215 221 222 /* These are a glued a little bit to the core/bee layer and a little bit to 223 IRC. The first user is OTR, and I guess at some point we'll get to shape 224 this a little bit more as other uses come up. */ 225 typedef struct irc_plugin 226 { 227 /* Called at the end of irc_new(). Can be used to add settings, etc. */ 228 gboolean (*irc_new)( irc_t *irc ); 229 /* At the end of irc_free(). */ 230 void (*irc_free)( irc_t *irc ); 231 232 /* Problem with the following two functions is ordering if multiple 233 plugins are handling them. Let's keep fixing that problem for 234 whenever it becomes important. */ 235 236 /* Called by bee_irc_user_privmsg_cb(). Return NULL if you want to 237 abort sending the msg. */ 238 char* (*filter_msg_out)( irc_user_t *iu, char *msg, int flags ); 239 /* Called by bee_irc_user_msg(). Return NULL if you swallowed the 240 message and don't want anything to go to the user. */ 241 char* (*filter_msg_in)( irc_user_t *iu, char *msg, int flags ); 242 243 /* From storage.c functions. Ideally these should not be used 244 and instead data should be stored in settings which will get 245 saved automatically. Consider these deprecated! */ 246 void (*storage_load)( irc_t *irc ); 247 void (*storage_save)( irc_t *irc ); 248 void (*storage_remove)( const char *nick ); 249 } irc_plugin_t; 250 251 extern GSList *irc_plugins; /* struct irc_plugin */ 252 216 253 /* irc.c */ 217 254 extern GSList *irc_connection_list; … … 238 275 239 276 void irc_umode_set( irc_t *irc, const char *s, gboolean allow_priv ); 277 278 void register_irc_plugin( const struct irc_plugin *p ); 240 279 241 280 /* irc_channel.c */ -
irc_commands.c
r23b29c6 r6197702 635 635 irc_send_msg_raw( irc->root, "NOTICE", irc->user->nick, "COMPLETIONS OK" ); 636 636 637 for( i = 0; commands[i].command; i ++ )638 irc_send_msg_f( irc->root, "NOTICE", irc->user->nick, "COMPLETIONS %s", commands[i].command );637 for( i = 0; root_commands[i].command; i ++ ) 638 irc_send_msg_f( irc->root, "NOTICE", irc->user->nick, "COMPLETIONS %s", root_commands[i].command ); 639 639 640 640 for( h = global.help; h; h = h->next ) -
irc_im.c
r23b29c6 r6197702 192 192 } 193 193 194 static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg , time_t sent_at )194 static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg_, time_t sent_at ) 195 195 { 196 196 irc_t *irc = bee->ui_data; … … 199 199 char *wrapped, *ts = NULL; 200 200 irc_channel_t *ic = NULL; 201 char *msg = g_strdup( msg_ ); 202 GSList *l; 201 203 202 204 if( sent_at > 0 && set_getbool( &irc->b->set, "display_timestamps" ) ) … … 224 226 } 225 227 228 for( l = irc_plugins; l; l = l->next ) 229 { 230 irc_plugin_t *p = l->data; 231 if( p->filter_msg_in ) 232 { 233 char *s = p->filter_msg_in( iu, msg, 0 ); 234 if( s ) 235 { 236 if( s != msg ) 237 g_free( msg ); 238 msg = s; 239 } 240 else 241 { 242 /* Modules can swallow messages. */ 243 return TRUE; 244 } 245 } 246 } 247 248 if( ( g_strcasecmp( set_getstr( &bee->set, "strip_html" ), "always" ) == 0 ) || 249 ( ( bu->ic->flags & OPT_DOES_HTML ) && set_getbool( &bee->set, "strip_html" ) ) ) 250 { 251 char *s = g_strdup( msg ); 252 strip_html( s ); 253 g_free( msg ); 254 msg = s; 255 } 256 226 257 wrapped = word_wrap( msg, 425 ); 227 258 irc_send_msg( iu, "PRIVMSG", dst, wrapped, prefix ); … … 229 260 g_free( wrapped ); 230 261 g_free( prefix ); 262 g_free( msg ); 231 263 g_free( ts ); 232 264 … … 349 381 } 350 382 383 if( iu->pastebuf == NULL ) 384 iu->pastebuf = g_string_new( msg ); 385 else 386 { 387 b_event_remove( iu->pastebuf_timer ); 388 g_string_append_printf( iu->pastebuf, "\n%s", msg ); 389 } 390 351 391 if( set_getbool( &iu->irc->b->set, "paste_buffer" ) ) 352 392 { 353 393 int delay; 354 355 if( iu->pastebuf == NULL )356 iu->pastebuf = g_string_new( msg );357 else358 {359 b_event_remove( iu->pastebuf_timer );360 g_string_append_printf( iu->pastebuf, "\n%s", msg );361 }362 394 363 395 if( ( delay = set_getint( &iu->irc->b->set, "paste_buffer_delay" ) ) <= 5 ) … … 369 401 } 370 402 else 371 return bee_user_msg( iu->irc->b, iu->bu, msg, 0 ); 403 { 404 bee_irc_user_privmsg_cb( iu, 0, 0 ); 405 406 return TRUE; 407 } 372 408 } 373 409 … … 375 411 { 376 412 irc_user_t *iu = data; 377 378 bee_user_msg( iu->irc->b, iu->bu, iu->pastebuf->str, 0 ); 379 380 g_string_free( iu->pastebuf, TRUE ); 381 iu->pastebuf = 0; 413 char *msg = g_string_free( iu->pastebuf, FALSE ); 414 GSList *l; 415 416 for( l = irc_plugins; l; l = l->next ) 417 { 418 irc_plugin_t *p = l->data; 419 if( p->filter_msg_out ) 420 { 421 char *s = p->filter_msg_out( iu, msg, 0 ); 422 if( s ) 423 { 424 if( s != msg ) 425 g_free( msg ); 426 msg = s; 427 } 428 else 429 { 430 /* Modules can swallow messages. */ 431 iu->pastebuf = NULL; 432 g_free( msg ); 433 return FALSE; 434 } 435 } 436 } 437 438 bee_user_msg( iu->irc->b, iu->bu, msg, 0 ); 439 440 g_free( msg ); 441 iu->pastebuf = NULL; 382 442 iu->pastebuf_timer = 0; 383 443 -
lib/events.h
r23b29c6 r6197702 81 81 G_MODULE_EXPORT void b_event_remove(gint id); 82 82 83 /* For now, closesocket() is only a function when using libevent. With GLib 84 it's a preprocessor macro. */ 85 #ifdef EVENTS_LIBEVENT 83 /* With libevent, this one also cleans up event handlers if that wasn't already 84 done (the caller is expected to do so but may miss it sometimes). */ 86 85 G_MODULE_EXPORT void closesocket(int fd); 87 #endif88 86 89 87 #endif /* _EVENTS_H_ */ -
lib/events_glib.c
r23b29c6 r6197702 147 147 g_source_remove(tag); 148 148 } 149 150 void closesocket( int fd ) 151 { 152 close( fd ); 153 } -
lib/misc.c
r23b29c6 r6197702 157 157 char *s = out, *cs; 158 158 int i, matched; 159 int taglen; 159 160 160 161 memset( out, 0, sizeof( out ) ); … … 173 174 in ++; 174 175 176 taglen = in - cs - 1; /* not <0 because the above loop runs at least once */ 175 177 if( *in ) 176 178 { 177 if( g_strncasecmp( cs+1, "br", 2) == 0 ) 179 if( g_strncasecmp( cs+1, "b", taglen) == 0 ) 180 *(s++) = '\x02'; 181 else if( g_strncasecmp( cs+1, "/b", taglen) == 0 ) 182 *(s++) = '\x02'; 183 else if( g_strncasecmp( cs+1, "i", taglen) == 0 ) 184 *(s++) = '\x1f'; 185 else if( g_strncasecmp( cs+1, "/i", taglen) == 0 ) 186 *(s++) = '\x1f'; 187 else if( g_strncasecmp( cs+1, "br", taglen) == 0 ) 178 188 *(s++) = '\n'; 179 189 in ++; -
lib/ssl_bogus.c
r23b29c6 r6197702 27 27 28 28 int ssl_errno; 29 30 void ssl_init( void ) 31 { 32 } 29 33 30 34 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) … … 66 70 return 0; 67 71 } 72 73 int ssl_pending( void *conn ) 74 { 75 return 0; 76 } -
lib/ssl_client.h
r23b29c6 r6197702 47 47 48 48 49 /* Perform any global initialization the SSL library might need. */ 50 G_MODULE_EXPORT void ssl_init( void ); 51 49 52 /* Connect to host:port, call the given function when the connection is 50 53 ready to be used for SSL traffic. This is all done asynchronously, no -
lib/ssl_gnutls.c
r23b29c6 r6197702 60 60 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); 61 61 62 63 void ssl_init( void ) 64 { 65 gnutls_global_init(); 66 initialized = TRUE; 67 atexit( gnutls_global_deinit ); 68 } 62 69 63 70 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) … … 122 129 if( !initialized ) 123 130 { 124 gnutls_global_init(); 125 initialized = TRUE; 126 atexit( gnutls_global_deinit ); 131 ssl_init(); 127 132 } 128 133 -
lib/ssl_nss.c
r23b29c6 r6197702 91 91 92 92 93 void ssl_init( void ) 94 { 95 PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); 96 NSS_NoDB_Init(NULL); 97 NSS_SetDomesticPolicy(); 98 initialized = TRUE; 99 } 100 93 101 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) 94 102 { … … 107 115 if( !initialized ) 108 116 { 109 PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); 110 NSS_NoDB_Init(NULL); 111 NSS_SetDomesticPolicy(); 117 ssl_init(); 112 118 } 113 119 -
lib/ssl_openssl.c
r23b29c6 r6197702 56 56 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); 57 57 58 59 void ssl_init( void ) 60 { 61 initialized = TRUE; 62 SSL_library_init(); 63 // SSLeay_add_ssl_algorithms(); 64 } 58 65 59 66 void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) … … 115 122 if( !initialized ) 116 123 { 117 initialized = TRUE; 118 SSL_library_init(); 119 //SSLeay_add_ssl_algorithms(); 120 //OpenSSL_add_all_algorithms(); 124 ssl_init(); 121 125 } 122 126 -
log.c
r23b29c6 r6197702 30 30 static log_t logoutput; 31 31 32 static void log_null(int level, c har *logmessage);33 static void log_irc(int level, c har *logmessage);34 static void log_syslog(int level, c har *logmessage);35 static void log_console(int level, c har *logmessage);32 static void log_null(int level, const char *logmessage); 33 static void log_irc(int level, const char *logmessage); 34 static void log_syslog(int level, const char *logmessage); 35 static void log_console(int level, const char *logmessage); 36 36 37 37 void log_init(void) { … … 97 97 } 98 98 99 void log_message(int level, c har *message, ... ) {99 void log_message(int level, const char *message, ... ) { 100 100 101 101 va_list ap; … … 122 122 } 123 123 124 void log_error(c har *functionname) {124 void log_error(const 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 har *message) {130 static void log_null(int level, const char *message) { 131 131 return; 132 132 } 133 133 134 static void log_irc(int level, c har *message) {134 static void log_irc(int level, const 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 har *message) {149 static void log_syslog(int level, const 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 har *message) {163 static void log_console(int level, const char *message) { 164 164 if(level == LOGLVL_ERROR) 165 165 fprintf(stderr, "Error: %s\n", message); -
log.h
r23b29c6 r6197702 44 44 45 45 typedef struct log_t { 46 void (*error)(int level, c har *logmessage);47 void (*warning)(int level, c har *logmessage);48 void (*informational)(int level, c har *logmessage);46 void (*error)(int level, const char *logmessage); 47 void (*warning)(int level, const char *logmessage); 48 void (*informational)(int level, const char *logmessage); 49 49 #ifdef DEBUG 50 void (*debug)(int level, c har *logmessage);50 void (*debug)(int level, const 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 har *message, ...) G_GNUC_PRINTF( 2, 3 );57 void log_error(c har *functionname);56 void log_message(int level, const char *message, ...) G_GNUC_PRINTF( 2, 3 ); 57 void log_error(const char *functionname); 58 58 59 59 #endif -
nick.c
r23b29c6 r6197702 196 196 LC_CTYPE being set to something other than C/POSIX. */ 197 197 if( part ) 198 part = asc = g_convert ( part, -1, "ASCII//TRANSLIT//IGNORE",199 "UTF-8", NULL, NULL, NULL );198 part = asc = g_convert_with_fallback( part, -1, "ASCII//TRANSLIT", 199 "UTF-8", "", NULL, NULL, NULL ); 200 200 201 201 if( ret->len == 0 && part && isdigit( *part ) ) -
protocols/bee_user.c
r23b29c6 r6197702 265 265 } 266 266 267 if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||268 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )269 strip_html( msg );270 271 267 if( bee->ui->user_msg && bu ) 272 268 bee->ui->user_msg( bee, bu, msg, sent_at ); -
protocols/jabber/jabber.c
r23b29c6 r6197702 557 557 558 558 ret->name = "jabber"; 559 ret->mms = 0; /* no limit */ 559 560 ret->login = jabber_login; 560 561 ret->init = jabber_init; -
protocols/msn/msn.c
r23b29c6 r6197702 359 359 360 360 ret->name = "msn"; 361 ret->mms = 1409; /* this guess taken from libotr UPGRADING file */ 361 362 ret->login = msn_login; 362 363 ret->init = msn_init; -
protocols/nogaim.h
r23b29c6 r6197702 68 68 #define OPT_TYPING 0x00000100 /* Some pieces of code make assumptions */ 69 69 #define OPT_THINKING 0x00000200 /* about these values... Stupid me! */ 70 #define OPT_NOOTR 0x00001000 /* protocol not suitable for OTR */ 70 71 71 72 /* ok. now the fun begins. first we create a connection structure */ … … 142 143 const char *name; 143 144 void *data; 145 /* Maximum Message Size of this protocol. 146 * - Introduced for OTR, in order to fragment large protocol messages. 147 * - 0 means "unlimited". */ 148 unsigned int mms; 144 149 145 150 /* Added this one to be able to add per-account settings, don't think -
protocols/oscar/oscar.c
r23b29c6 r6197702 2612 2612 struct prpl *ret = g_new0(struct prpl, 1); 2613 2613 ret->name = "oscar"; 2614 ret->mms = 2343; /* this guess taken from libotr UPGRADING file */ 2614 2615 ret->away_states = oscar_away_states; 2615 2616 ret->init = oscar_init; -
protocols/twitter/twitter.c
r23b29c6 r6197702 534 534 struct prpl *ret = g_new0(struct prpl, 1); 535 535 536 ret->options = OPT_NOOTR; 536 537 ret->name = "twitter"; 537 538 ret->login = twitter_login; -
protocols/yahoo/yahoo.c
r23b29c6 r6197702 379 379 struct prpl *ret = g_new0(struct prpl, 1); 380 380 ret->name = "yahoo"; 381 ret->mms = 832; /* this guess taken from libotr UPGRADING file */ 381 382 ret->init = byahoo_init; 382 383 -
query.c
r23b29c6 r6197702 106 106 int count = 0; 107 107 108 if( !ic ) 109 return; 110 108 111 q = irc->queries; 109 112 def = query_default( irc ); … … 148 151 else 149 152 irc_usermsg( irc, "Accepted: %s", q->question ); 150 q->yes( q->data ); 153 if( q->yes ) 154 q->yes( q->data ); 151 155 } 152 156 else … … 156 160 else 157 161 irc_usermsg( irc, "Rejected: %s", q->question ); 158 q->no( q->data ); 162 if( q->no ) 163 q->no( q->data ); 159 164 } 160 165 q->data = NULL; -
root_commands.c
r23b29c6 r6197702 55 55 56 56 len = strlen( cmd[0] ); 57 for( i = 0; commands[i].command; i++ )58 if( g_strncasecmp( commands[i].command, cmd[0], len ) == 0 )59 { 60 if( commands[i+1].command &&61 g_strncasecmp( commands[i+1].command, cmd[0], len ) == 0 )57 for( i = 0; root_commands[i].command; i++ ) 58 if( g_strncasecmp( root_commands[i].command, cmd[0], len ) == 0 ) 59 { 60 if( root_commands[i+1].command && 61 g_strncasecmp( root_commands[i+1].command, cmd[0], len ) == 0 ) 62 62 /* Only match on the first letters if the match is unique. */ 63 63 break; 64 64 65 MIN_ARGS( commands[i].required_parameters );65 MIN_ARGS( root_commands[i].required_parameters ); 66 66 67 commands[i].execute( irc, cmd );67 root_commands[i].execute( irc, cmd ); 68 68 return; 69 69 } … … 1313 1313 1314 1314 /* IMPORTANT: Keep this list sorted! The short command logic needs that. */ 1315 co nst command_tcommands[] = {1315 command_t root_commands[] = { 1316 1316 { "account", 1, cmd_account, 0 }, 1317 1317 { "add", 2, cmd_add, 0 }, … … 1337 1337 { "transfer", 0, cmd_transfer, 0 }, 1338 1338 { "yes", 0, cmd_yesno, 0 }, 1339 { NULL } 1339 /* Not expecting too many plugins adding root commands so just make a 1340 dumb array with some empty entried at the end. */ 1341 { NULL }, 1342 { NULL }, 1343 { NULL }, 1344 { NULL }, 1345 { NULL }, 1346 { NULL }, 1347 { NULL }, 1348 { NULL }, 1349 { NULL }, 1340 1350 }; 1351 static const int num_root_commands = sizeof( root_commands ) / sizeof( command_t ); 1352 1353 gboolean root_command_add( const char *command, int params, void (*func)(irc_t *, char **args), int flags ) 1354 { 1355 int i; 1356 1357 if( root_commands[num_root_commands-2].command ) 1358 /* Planning fail! List is full. */ 1359 return FALSE; 1360 1361 for( i = 0; root_commands[i].command; i++ ) 1362 { 1363 if( g_strcasecmp( root_commands[i].command, command ) == 0 ) 1364 return FALSE; 1365 else if( g_strcasecmp( root_commands[i].command, command ) > 0 ) 1366 break; 1367 } 1368 memmove( root_commands + i + 1, root_commands + i, 1369 sizeof( command_t ) * ( num_root_commands - i - 1 ) ); 1370 1371 root_commands[i].command = g_strdup( command ); 1372 root_commands[i].required_parameters = params; 1373 root_commands[i].execute = func; 1374 root_commands[i].flags = flags; 1375 1376 return TRUE; 1377 } -
sock.h
r23b29c6 r6197702 11 11 #define sock_make_blocking(fd) fcntl(fd, F_SETFL, 0) 12 12 #define sockerr_again() (errno == EINPROGRESS || errno == EINTR) 13 #ifndef EVENTS_LIBEVENT14 #define closesocket(a) close(a)15 #else16 13 void closesocket( int fd ); 17 #endif18 14 #else 19 15 # include <winsock2.h> -
storage.c
r23b29c6 r6197702 115 115 status = st->load(irc, password); 116 116 if (status == STORAGE_OK) 117 { 118 GSList *l; 119 for( l = irc_plugins; l; l = l->next ) 120 { 121 irc_plugin_t *p = l->data; 122 if( p->storage_load ) 123 p->storage_load( irc ); 124 } 117 125 return status; 126 } 118 127 119 128 if (status != STORAGE_NO_SUCH_USER) … … 127 136 { 128 137 storage_status_t st; 138 GSList *l; 129 139 130 140 if (password != NULL) { … … 140 150 st = ((storage_t *)global.storage->data)->save(irc, overwrite); 141 151 152 for( l = irc_plugins; l; l = l->next ) 153 { 154 irc_plugin_t *p = l->data; 155 if( p->storage_save ) 156 p->storage_save( irc ); 157 } 158 142 159 if (password != NULL) { 143 160 irc_setpass(irc, NULL); … … 151 168 GList *gl; 152 169 storage_status_t ret = STORAGE_OK; 170 gboolean ok = FALSE; 171 GSList *l; 153 172 154 173 /* Remove this account from all storage backends. If this isn't … … 160 179 161 180 status = st->remove(nick, password); 181 ok |= status == STORAGE_OK; 162 182 if (status != STORAGE_NO_SUCH_USER && status != STORAGE_OK) 163 183 ret = status; 164 184 } 185 186 /* If at least one succeeded, remove plugin data. */ 187 if( ok ) 188 for( l = irc_plugins; l; l = l->next ) 189 { 190 irc_plugin_t *p = l->data; 191 if( p->storage_remove ) 192 p->storage_remove( nick ); 193 } 165 194 166 195 return ret; -
unix.c
r23b29c6 r6197702 29 29 #include "base64.h" 30 30 #include "commands.h" 31 #include "otr.h" 31 32 #include "protocols/nogaim.h" 32 33 #include "help.h" 33 34 #include "ipc.h" 35 #include "lib/ssl_client.h" 34 36 #include "md5.h" 35 37 #include "misc.h" … … 68 70 69 71 b_main_init(); 72 73 /* Ugly Note: libotr and gnutls both use libgcrypt. libgcrypt 74 has a process-global config state whose initialization happpens 75 twice if libotr and gnutls are used together. libotr installs custom 76 memory management functions for libgcrypt while our gnutls module 77 uses the defaults. Therefore we initialize OTR after SSL. *sigh* */ 78 ssl_init(); 79 #ifdef OTR_BI 80 otr_init(); 81 #endif 82 /* And in case OTR is loaded as a plugin, it'll also get loaded after 83 this point. */ 70 84 71 85 srand( time( NULL ) ^ getpid() );
Note: See TracChangeset
for help on using the changeset viewer.