Changes in / [2e44b1f:3f81999]


Ignore:
Files:
3 added
39 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r2e44b1f r3f81999  
    1111# Program variables
    1212objects = account.o bitlbee.o chat.o crypting.o help.o ipc.o irc.o irc_commands.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) user.o
    13 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
     13headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ipc.h irc.h log.h nick.h otr.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
    1414subdirs = lib protocols
    1515
     
    2020OUTFILE=bitlbee.exe
    2121else
    22 objects += unix.o conf.o log.o
     22objects += unix.o conf.o log.o otr.o
    2323OUTFILE=bitlbee
    2424endif
     
    9494        mkdir -p $(DESTDIR)$(ETCDIR)
    9595        install -m 0644 motd.txt $(DESTDIR)$(ETCDIR)/motd.txt
     96        install -m 0644 welcome.txt $(DESTDIR)$(ETCDIR)/welcome.txt
    9697        install -m 0644 bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf
    9798
    9899uninstall-etc:
    99100        rm -f $(DESTDIR)$(ETCDIR)/motd.txt
     101        rm -f $(DESTDIR)$(ETCDIR)/welcome.txt
    100102        rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf
    101103        -rmdir $(DESTDIR)$(ETCDIR)
  • bitlbee.conf

    r2e44b1f r3f81999  
    8686# MotdFile = /etc/bitlbee/motd.txt
    8787
     88## WelcomeFile
     89##
     90## Specify an alternative file for the welcome message displayed when joining the
     91## control channel. Default value depends on the --etcdir argument to configure.
     92##
     93# WelcomeFile = /etc/bitlbee/welcome.txt
     94
    8895## ConfigDir
    8996##
  • bitlbee.h

    r2e44b1f r3f81999  
    2828
    2929#define _GNU_SOURCE /* Stupid GNU :-P */
     30
     31/* Depend on Windows 2000 for now since we need getaddrinfo() */
     32#define _WIN32_WINNT 0x0501
    3033
    3134/* Depend on Windows 2000 for now since we need getaddrinfo() */
     
    138141#include "misc.h"
    139142#include "proxy.h"
     143#include "otr.h"
    140144
    141145typedef struct global {
     
    149153        char *helpfile;
    150154        int restart;
     155        OtrlMessageAppOps otr_ops;   /* collects interface functions required by OTR */
    151156} global_t;
    152157
  • conf.c

    r2e44b1f r3f81999  
    6060        conf->pidfile = g_strdup( PIDFILE );
    6161        conf->motdfile = g_strdup( ETCDIR "/motd.txt" );
     62        conf->welcomefile = g_strdup( ETCDIR "/welcome.txt" );
    6263        conf->ping_interval = 180;
    6364        conf->ping_timeout = 300;
     
    248249                                g_free( conf->motdfile );
    249250                                conf->motdfile = g_strdup( ini->value );
     251                        }
     252                        else if( g_strcasecmp( ini->key, "welcomefile" ) == 0 )
     253                        {
     254                                g_free( conf->welcomefile );
     255                                conf->welcomefile = g_strdup( ini->value );
    250256                        }
    251257                        else if( g_strcasecmp( ini->key, "account_storage" ) == 0 )
  • conf.h

    r2e44b1f r3f81999  
    4545        char *pidfile;
    4646        char *motdfile;
     47        char *welcomefile;
    4748        char *primary_storage;
    4849        char **migrate_storage;
  • configure

    r2e44b1f r3f81999  
    3131gcov=0
    3232plugins=1
     33otr=auto
    3334
    3435events=glib
     
    7172--gcov=0/1      Disable/enable test coverage reporting  $gcov
    7273--plugins=0/1   Disable/enable plugins support          $plugins
     74--otr=0/1       Disable/enable OTR encryption support   $otr
    7375
    7476--events=...    Event handler (glib, libevent)          $events
     
    411413fi
    412414
     415otrprefix=""
     416for i in / /usr /usr/local; do
     417        if [ -f ${i}/lib/libotr.a ]; then
     418                otrprefix=${i}
     419                break
     420        fi
     421done
     422if [ "$otr" = "auto" ]; then
     423        if [ -n "$otrprefix" ]; then
     424                otr=1
     425        else
     426                otr=0
     427        fi
     428fi
     429if [ "$otr" = 1 ]; then
     430        echo '#define WITH_OTR' >> config.h
     431        echo "EFLAGS+=-L${otrprefix}/lib -lotr" >> Makefile.settings
     432        echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings
     433else
     434        echo '#undef WITH_OTR' >> config.h
     435fi
     436
    413437echo
    414438if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
     
    536560fi
    537561
     562if [ "$otr" = "1" ]; then
     563        echo '  Off-the-Record (OTR) Messaging enabled.'
     564else
     565        echo '  Off-the-Record (OTR) Messaging disabled.'
     566fi
     567
    538568echo '  Using event handler: '$events
    539569echo '  Using SSL library: '$ssl
  • doc/README

    r2e44b1f r3f81999  
    6767BitlBee's only real dependency is GLib. This is available on virtually every
    6868platform. Any recent version of GLib (2.4 or higher) will work.
     69
     70Off-the-Record encryption support will be included by default if the
     71configure script finds libotr in one of the usual places. You can pass
     72--otr=1 or --otr=0 to force it on or off, respectively.
    6973
    7074These days, MSN Messenger clients have to connect to the MS Passport servers
     
    143147
    144148
    145 A NOTE ON ENCRYPTION
    146 ====================
     149A NOTE ON PASSWORD ENCRYPTION
     150=============================
    147151
    148152There used to be a note here about the simple obfuscation method used to
  • doc/user-guide/commands.xml

    r2e44b1f r3f81999  
    327327                </description>
    328328        </bitlbee-command>
     329       
     330        <bitlbee-command name="otr">
     331                <short-description>Off-the-Record encryption control</short-description>
     332                <syntax>otr &lt;subcommand&gt; [&lt;arguments&gt;]</syntax>
     333
     334                <description>
     335
     336                        <para>
     337                                Available subcommands: connect, disconnect, smp, trust, info, keygen, and forget. See <emphasis>help otr &lt;subcommand&gt;</emphasis> for more information.
     338                        </para>
     339
     340                </description>
     341               
     342                <bitlbee-command name="connect">
     343                        <syntax>otr connect &lt;nick&gt;</syntax>
     344                       
     345                        <description>
     346                       
     347                                <para>
     348                                        Attempts to establish an encrypted connection with the specified user by sending a magic string.
     349                                </para>
     350                               
     351                        </description>
     352               
     353                </bitlbee-command>
     354               
     355                <bitlbee-command name="disconnect">
     356                        <syntax>otr disconnect &lt;nick&gt;</syntax>
     357                       
     358                        <description>
     359                       
     360                                <para>
     361                                        Resets the connection with the specified user to cleartext.
     362                                </para>
     363                               
     364                        </description>
     365               
     366                </bitlbee-command>
     367               
     368                <bitlbee-command name="smp">
     369                        <syntax>otr smp &lt;nick&gt; &lt;secret&gt;</syntax>
     370                       
     371                        <description>
     372                       
     373                                <para>
     374                                        Attempts to authenticate the given user's active fingerprint via the Socialist Millionaires' Protocol.
     375                                </para>
     376                               
     377                                <para>
     378                                        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.
     379                                </para>
     380                               
     381                        </description>
     382               
     383                </bitlbee-command>
     384               
     385                <bitlbee-command name="trust">
     386                        <syntax>otr trust &lt;nick&gt; &lt;fp1&gt; &lt;fp2&gt; &lt;fp3&gt; &lt;fp4&gt; &lt;fp5&gt;</syntax>
     387                       
     388                        <description>
     389                       
     390                                <para>
     391                                        Manually affirms trust in the specified fingerprint, given as five blocks of precisely eight (hexadecimal) digits each.
     392                                </para>
     393                               
     394                        </description>
     395               
     396                </bitlbee-command>
     397               
     398                <bitlbee-command name="info">
     399                        <syntax>otr info</syntax>
     400                        <syntax>otr info &lt;nick&gt;</syntax>
     401                       
     402                        <description>
     403                       
     404                                <para>
     405                                        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.
     406                                </para>
     407                               
     408                        </description>
     409               
     410                </bitlbee-command>
     411               
     412                <bitlbee-command name="keygen">
     413                        <syntax>otr keygen &lt;account-no&gt;</syntax>
     414                       
     415                        <description>
     416                       
     417                                <para>
     418                                        Generates a new OTR private key for the given account.
     419                                </para>
     420                               
     421                        </description>
     422               
     423                </bitlbee-command>
     424               
     425                <bitlbee-command name="forget">
     426                        <syntax>otr forget &lt;thing&gt; &lt;arguments&gt;</syntax>
     427                       
     428                        <description>
     429                       
     430                                <para>
     431                                        Forgets some part of our OTR userstate. Available things: fingerprint, context, and key. See <emphasis>help otr forget &lt;thing&gt;</emphasis> for more information.
     432                                </para>
     433                       
     434                        </description>
     435                       
     436                        <bitlbee-command name="fingerprint">
     437                                <syntax>otr forget fingerprint &lt;nick&gt; &lt;fingerprint&gt;</syntax>
     438                               
     439                                <description>
     440                               
     441                                        <para>
     442                                                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.
     443                                        </para>
     444                                       
     445                                </description>
     446                               
     447                        </bitlbee-command>
     448                               
     449                        <bitlbee-command name="context">
     450                                <syntax>otr forget context &lt;nick&gt;</syntax>
     451                               
     452                                <description>
     453                               
     454                                        <para>
     455                                                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.
     456                                        </para>
     457                                       
     458                                </description>
     459                               
     460                        </bitlbee-command>
     461
     462                        <bitlbee-command name="key">
     463                                <syntax>otr forget key &lt;fingerprint&gt;</syntax>
     464                               
     465                                <description>
     466                               
     467                                        <para>
     468                                                Forgets an OTR private key matching the specified fingerprint. It is allowed to specify only a (unique) prefix of the fingerprint.
     469                                        </para>
     470                                       
     471                                </description>
     472                               
     473                        </bitlbee-command>
     474               
     475                </bitlbee-command>
     476               
     477        </bitlbee-command>
    329478
    330479        <bitlbee-command name="set">
     
    495644        </bitlbee-setting>
    496645
     646        <bitlbee-setting name="color_encrypted" type="boolean" scope="global">
     647                <default>true</default>
     648
     649                <description>
     650                        <para>
     651                                If set to true, BitlBee will color incoming encrypted messages according to their fingerprint trust level: untrusted=red, trusted=green.
     652                        </para>
     653                </description>
     654
     655        </bitlbee-setting>
     656
    497657        <bitlbee-setting name="debug" type="boolean" scope="global">
    498658                <default>false</default>
     
    561721        </bitlbee-setting>
    562722
     723        <bitlbee-setting name="halfop_buddies" type="string" scope="global">
     724                <default>encrypted</default>
     725                <possible-values>encrypted, trusted, notaway, false</possible-values>
     726
     727                <description>
     728                        <para>
     729                                Specifies under which circumstances BitlBee should give the "halfop" mode flag (+h) to buddies.
     730                        </para>
     731                       
     732                        <para>
     733                                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.
     734                        </para>
     735                </description>
     736
     737        </bitlbee-setting>
     738
    563739        <bitlbee-setting name="lcnicks" type="boolean" scope="global">
    564740                <default>true</default>
     
    583759        </bitlbee-setting>
    584760
     761        <bitlbee-setting name="op_buddies" type="string" scope="global">
     762                <default>trusted</default>
     763                <possible-values>encrypted, trusted, notaway, false</possible-values>
     764
     765                <description>
     766                        <para>
     767                                Specifies under which circumstances BitlBee should give the "op" mode flag (+o) to buddies.
     768                        </para>
     769                       
     770                        <para>
     771                                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.
     772                        </para>
     773                </description>
     774
     775        </bitlbee-setting>
     776
     777        <bitlbee-setting name="op_root" type="bool" scope="global">
     778                <default>true</default>
     779
     780                <description>
     781                        <para>
     782                                Some people prefer themself and root to have operator status in &amp;bitlbee, other people don't. You can set the desired state for root using this setting.
     783                        </para>
     784                </description>
     785        </bitlbee-setting>
     786
     787        <bitlbee-setting name="op_user" type="bool" scope="global">
     788                <default>true</default>
     789
     790                <description>
     791                        <para>
     792                                Some people prefer themself and root to have operator status in &amp;bitlbee, other people don't. You can set the desired state for yourself using this setting.
     793                        </para>
     794                </description>
     795        </bitlbee-setting>
     796
     797        <bitlbee-setting name="otr_policy" type="string" scope="global">
     798                <default>opportunistic</default>
     799                <possible-values>never, opportunistic, manual, always</possible-values>
     800
     801                <description>
     802                        <para>
     803                                This setting controls the policy for establishing Off-the-Record connections.
     804                        </para>
     805                        <para>
     806                                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.
     807                        </para>
     808                </description>
     809        </bitlbee-setting>
     810
    585811        <bitlbee-setting name="nick" type="string" scope="chat">
    586812
     
    588814                        <para>
    589815                                You can use this option to set your nickname in a chatroom. You won't see this nickname yourself, but other people in the room will. By default, BitlBee will use your username as the chatroom nickname.
    590                         </para>
    591                 </description>
    592         </bitlbee-setting>
    593 
    594         <bitlbee-setting name="ops" type="string" scope="global">
    595                 <default>both</default>
    596                 <possible-values>both, root, user, none</possible-values>
    597 
    598                 <description>
    599                         <para>
    600                                 Some people prefer themself and root to have operator status in &amp;bitlbee, other people don't. You can change these states using this setting.
    601                         </para>
    602 
    603                         <para>
    604                                 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.
    605816                        </para>
    606817                </description>
     
    7961007                        </para>
    7971008                </description>
     1009        </bitlbee-setting>
     1010
     1011        <bitlbee-setting name="voice_buddies" type="string" scope="global">
     1012                <default>trusted</default>
     1013                <possible-values>encrypted, trusted, notaway, false</possible-values>
     1014
     1015                <description>
     1016                        <para>
     1017                                Specifies under which circumstances BitlBee should give the "voice" mode flag (+v) to buddies.
     1018                        </para>
     1019                       
     1020                        <para>
     1021                                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.
     1022                        </para>
     1023                </description>
     1024
    7981025        </bitlbee-setting>
    7991026
  • ipc.c

    r2e44b1f r3f81999  
    3333
    3434GSList *child_list = NULL;
     35static char *statefile = NULL;
    3536
    3637static void ipc_master_cmd_client( irc_t *data, char **cmd )
     
    6263}
    6364
    64 static void ipc_master_cmd_deaf( irc_t *data, char **cmd )
    65 {
    66         if( global.conf->runmode == RUNMODE_DAEMON )
    67         {
    68                 b_event_remove( global.listen_watch_source_id );
    69                 close( global.listen_socket );
    70                
    71                 global.listen_socket = global.listen_watch_source_id = -1;
    72        
    73                 ipc_to_children_str( "OPERMSG :Closed listening socket, waiting "
    74                                      "for all users to disconnect." );
    75         }
    76         else
    77         {
    78                 ipc_to_children_str( "OPERMSG :The DEAF command only works in "
    79                                      "normal daemon mode. Try DIE instead." );
    80         }
    81 }
    82 
    8365void ipc_master_cmd_rehash( irc_t *data, char **cmd )
    8466{
     
    11698        { "hello",      0, ipc_master_cmd_client,     0 },
    11799        { "die",        0, ipc_master_cmd_die,        0 },
    118         { "deaf",       0, ipc_master_cmd_deaf,       0 },
    119100        { "wallops",    1, NULL,                      IPC_CMD_TO_CHILDREN },
    120101        { "wall",       1, NULL,                      IPC_CMD_TO_CHILDREN },
     
    460441}
    461442
    462 #ifndef _WIN32
    463443char *ipc_master_save_state()
    464444{
     
    501481}
    502482
     483void ipc_master_set_statefile( char *fn )
     484{
     485        statefile = g_strdup( fn );
     486}
     487
    503488
    504489static gboolean new_ipc_client( gpointer data, gint serversock, b_input_condition cond )
     
    521506}
    522507
     508#ifndef _WIN32
    523509int ipc_master_listen_socket()
    524510{
     
    557543}
    558544#else
    559 int ipc_master_listen_socket()
    560 {
    561545        /* FIXME: Open named pipe \\.\BITLBEE */
    562         return 0;
    563 }
    564546#endif
    565547
    566 int ipc_master_load_state( char *statefile )
     548int ipc_master_load_state()
    567549{
    568550        struct bitlbee_child *child;
     
    572554        if( statefile == NULL )
    573555                return 0;
    574        
    575556        fp = fopen( statefile, "r" );
    576557        unlink( statefile );    /* Why do it later? :-) */
  • ipc.h

    r2e44b1f r3f81999  
    5858
    5959char *ipc_master_save_state();
    60 int ipc_master_load_state( char *statefile );
     60void ipc_master_set_statefile( char *fn );
     61int ipc_master_load_state();
    6162int ipc_master_listen_socket();
    6263
  • irc.c

    r2e44b1f r3f81999  
    2929#include "crypting.h"
    3030#include "ipc.h"
     31#include <sys/types.h>
     32#include <sys/wait.h>
    3133
    3234static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond );
     35static void irc_welcome( irc_t* irc );
    3336
    3437GSList *irc_connection_list = NULL;
     
    142145
    143146        irc_connection_list = g_slist_append( irc_connection_list, irc );
    144        
    145         s = set_add( &irc->set, "away_devoice", "true",  set_eval_away_devoice, irc );
     147
     148       
    146149        s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc );
    147150        s = set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc );
     
    150153        s = set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc );
    151154        s = set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc );
     155        s = set_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc );
    152156        s = set_add( &irc->set, "debug", "false", set_eval_bool, irc );
    153157        s = set_add( &irc->set, "default_target", "root", NULL, irc );
    154158        s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc );
    155159        s = set_add( &irc->set, "handle_unknown", "root", NULL, irc );
     160        s = set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc );
    156161        s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc );
    157         s = set_add( &irc->set, "ops", "both", set_eval_ops, irc );
     162        s = set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc );
     163        s = set_add( &irc->set, "op_root", "true", set_eval_op_root, irc );
     164        s = set_add( &irc->set, "otr_policy", "oppurtunistic", set_eval_otr_policy, irc );
    158165        s = set_add( &irc->set, "password", NULL, set_eval_password, irc );
    159166        s->flags |= SET_NULL_OK;
     
    166173        s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc );
    167174        s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc );
     175        s = set_add( &irc->set, "voice_buddies", "notaway", set_eval_voice_buddies, irc);
    168176       
    169177        conf_loaddefaults( irc );
    170        
     178
     179        irc->otr = otr_new();
     180
    171181        /* Evaluator sets the iconv/oconv structures. */
    172182        set_eval_charset( set_find( &irc->set, "charset" ), set_getstr( &irc->set, "charset" ) );
     
    320330       
    321331        g_free( irc->last_target );
     332
     333        otr_free(irc->otr);
    322334       
    323335        g_free( irc );
    324        
     336
    325337        if( global.conf->runmode == RUNMODE_INETD ||
    326338            global.conf->runmode == RUNMODE_FORKDAEMON ||
     
    691703}
    692704
     705const char *user_mode_prefix( irc_t *irc, user_t *u )
     706{
     707        static char op[] = "@";
     708        static char halfop[] = "%";
     709        static char voice[] = "+";
     710        static char none[] = "";
     711
     712        int or = set_getbool(&irc->set, "op_root");
     713        int ou = set_getbool(&irc->set, "op_user");
     714        char *ob = set_getstr(&irc->set, "op_buddies");
     715        char *hb = set_getstr(&irc->set, "halfop_buddies");
     716        char *vb = set_getstr(&irc->set, "voice_buddies");
     717
     718        if( (!strcmp(u->nick, irc->mynick) && or) ||
     719            (!strcmp(u->nick, irc->nick) && ou) ||
     720        (!u->away && !strcmp(ob, "notaway")) ||
     721        (u->encrypted && !strcmp(ob, "encrypted")) ||
     722        (u->encrypted>1 && !strcmp(ob, "trusted"))
     723      )
     724                return op;
     725        else if( (!u->away && !strcmp(hb, "notaway")) ||
     726             (u->encrypted && !strcmp(hb, "encrypted")) ||
     727             (u->encrypted>1 && !strcmp(hb, "trusted"))
     728               )
     729                return halfop;
     730        else if( (!u->away && !strcmp(vb, "notaway")) ||
     731             (u->encrypted && !strcmp(vb, "encrypted")) ||
     732             (u->encrypted>1 && !strcmp(vb, "trusted"))
     733               )
     734                return voice;
     735        else
     736                return none;
     737}
     738                       
    693739void irc_names( irc_t *irc, char *channel )
    694740{
     
    696742        char namelist[385] = "";
    697743        struct groupchat *c = NULL;
    698         char *ops = set_getstr( &irc->set, "ops" );
    699744       
    700745        /* RFCs say there is no error reply allowed on NAMES, so when the
     
    711756                        }
    712757                       
    713                         if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) )
    714                                 strcat( namelist, "+" );
    715                         else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ||
    716                                  ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) )
    717                                 strcat( namelist, "@" );
    718                        
     758                        strcat( namelist, user_mode_prefix(irc, u) );
    719759                        strcat( namelist, u->nick );
    720760                        strcat( namelist, " " );
     
    727767                /* root and the user aren't in the channel userlist but should
    728768                   show up in /NAMES, so list them first: */
    729                 sprintf( namelist, "%s%s %s%s ", strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->mynick,
    730                                                  strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->nick );
     769                sprintf( namelist, "%s%s %s%s ", set_getbool(&irc->set, "op_root") ? "@" : "", irc->mynick,
     770                                                 set_getbool(&irc->set, "op_user") ? "@" : "", irc->nick );
    731771               
    732772                for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->ic, l->data ) ) )
     
    738778                        }
    739779                       
     780                        strcat( namelist, user_mode_prefix(irc, u) );
    740781                        strcat( namelist, u->nick );
    741782                        strcat( namelist, " " );
     
    779820        irc_reply( irc,   3, ":%s", IRCD_INFO );
    780821        irc_reply( irc,   4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES );
    781         irc_reply( irc,   5, "PREFIX=(ov)@+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee "
     822        irc_reply( irc,   5, "PREFIX=(ohv)@%%+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee "
    782823                             "CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server",
    783824                             CTYPES, CMODES, MAX_NICK_LENGTH - 1 );
     
    785826        irc->umode[0] = '\0';
    786827        irc_umode_set( irc, "+" UMODE, 1 );
    787 
    788         u = user_add( irc, irc->mynick );
     828u = user_add( irc, irc->mynick );
    789829        u->host = g_strdup( irc->myhost );
    790830        u->realname = g_strdup( ROOT_FN );
     
    808848        irc_spawn( irc, u );
    809849       
    810         irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n"
    811                           "If you've never used BitlBee before, please do read the help "
    812                           "information using the \x02help\x02 command. Lots of FAQs are "
    813                           "answered there.\n"
    814                           "If you already have an account on this server, just use the "
    815                           "\x02identify\x02 command to identify yourself." );
     850        irc_welcome( irc );
    816851       
    817852        if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON )
     
    828863                root_command( irc, send_cmd );
    829864                g_free( send_cmd[1] );
     865        }
     866}
     867
     868static void irc_welcome( irc_t *irc )
     869{
     870        FILE *f;
     871       
     872        f = fopen( global.conf->welcomefile, "r" );
     873        if( !f )
     874        {
     875                irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n"
     876                                  "If you've never used BitlBee before, please do read the help "
     877                                  "information using the \x02help\x02 command. Lots of FAQs are "
     878                                  "answered there.\n"
     879                                  "OTR users please note: Private key files are owned by the user "
     880                                  "BitlBee is running as.\n"
     881                                  "If you already have an account on this server, just use the "
     882                                  "\x02identify\x02 command to identify yourself." );
     883        }
     884        else
     885        {
     886                char linebuf[380];
     887               
     888                while( fgets( linebuf, 380, f ) )
     889                {
     890                        irc_usermsg( irc, linebuf );
     891                }
     892               
     893                fclose( f );
    830894        }
    831895}
  • irc.h

    r2e44b1f r3f81999  
    2727#define _IRC_H
    2828
     29#include "otr.h"
     30
    2931#define IRC_MAX_LINE 512
    30 #define IRC_MAX_ARGS 8
     32#define IRC_MAX_ARGS 16
    3133
    3234#define IRC_LOGIN_TIMEOUT 60
     
    9496        gint w_watch_source_id;
    9597        gint ping_source_id;
     98       
     99        otr_t *otr;            /* OTR state and book keeping */
    96100} irc_t;
    97101
  • irc_commands.c

    r2e44b1f r3f81999  
    608608        { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN },
    609609        { "die",         0, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
    610         { "deaf",        0, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
    611610        { "wallops",     1, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
    612611        { "wall",        1, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
  • lib/misc.c

    r2e44b1f r3f81999  
    8888        { "gt",     ">" },
    8989        { "amp",    "&" },
     90        { "apos",   "'" },
    9091        { "quot",   "\"" },
    9192        { "aacute", "á" },
     
    119120        char *s = out, *cs;
    120121        int i, matched;
     122        int taglen;
    121123       
    122124        memset( out, 0, strlen( in ) + 1 );
     
    135137                                in ++;
    136138                       
     139                        taglen = in-cs-1;   /* not <0 because the above loop runs at least once */
    137140                        if( *in )
    138141                        {
    139                                 if( g_strncasecmp( cs+1, "br", 2) == 0 )
     142                                if( g_strncasecmp( cs+1, "b", taglen) == 0 )
     143                                        *(s++) = '\x02';
     144                                else if( g_strncasecmp( cs+1, "/b", taglen) == 0 )
     145                                        *(s++) = '\x02';
     146                                else if( g_strncasecmp( cs+1, "i", taglen) == 0 )
     147                                        *(s++) = '\x1f';
     148                                else if( g_strncasecmp( cs+1, "/i", taglen) == 0 )
     149                                        *(s++) = '\x1f';
     150                                else if( g_strncasecmp( cs+1, "br", 2) == 0 )
    140151                                        *(s++) = '\n';
    141152                                in ++;
  • lib/ssl_bogus.c

    r2e44b1f r3f81999  
    2727
    2828int ssl_errno;
     29
     30void ssl_init( void )
     31{
     32}
    2933
    3034void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
     
    6670        return 0;
    6771}
     72
     73int ssl_pending( void *conn )
     74{
     75        return 0;
     76}
  • lib/ssl_client.h

    r2e44b1f r3f81999  
    4747
    4848
     49/* Perform any global initialization the SSL library might need. */
     50G_MODULE_EXPORT void ssl_init( void );
     51
    4952/* Connect to host:port, call the given function when the connection is
    5053   ready to be used for SSL traffic. This is all done asynchronously, no
  • lib/ssl_gnutls.c

    r2e44b1f r3f81999  
    6060static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond );
    6161
     62
     63void ssl_init( void )
     64{
     65        gnutls_global_init();
     66        initialized = TRUE;
     67        atexit( gnutls_global_deinit );
     68}
    6269
    6370void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
     
    122129        if( !initialized )
    123130        {
    124                 gnutls_global_init();
    125                 initialized = TRUE;
    126                 atexit( gnutls_global_deinit );
     131                ssl_init();
    127132        }
    128133       
  • lib/ssl_nss.c

    r2e44b1f r3f81999  
    9191
    9292
     93void 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
    93101void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
    94102{
     
    107115        if( !initialized )
    108116        {
    109                 PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
    110                 NSS_NoDB_Init(NULL);
    111                 NSS_SetDomesticPolicy();
     117                ssl_init();
    112118        }
    113119
  • lib/ssl_openssl.c

    r2e44b1f r3f81999  
    5656static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond );
    5757
     58
     59void ssl_init( void )
     60{
     61        initialized = TRUE;
     62        SSLeay_add_ssl_algorithms();
     63}
    5864
    5965void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
     
    115121        if( !initialized )
    116122        {
    117                 initialized = TRUE;
    118                 SSLeay_add_ssl_algorithms();
     123                ssl_init();
    119124        }
    120125       
  • log.c

    r2e44b1f r3f81999  
    3030static log_t logoutput;
    3131
    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);
     32static void log_null(int level, const char *logmessage);
     33static void log_irc(int level, const char *logmessage);
     34static void log_syslog(int level, const char *logmessage);
     35static void log_console(int level, const char *logmessage);
    3636
    3737void log_init(void) {
     
    9797}
    9898
    99 void log_message(int level, char *message, ... ) {
     99void log_message(int level, const char *message, ... ) {
    100100
    101101        va_list ap;
     
    122122}
    123123
    124 void log_error(char *functionname) {
     124void log_error(const char *functionname) {
    125125        log_message(LOGLVL_ERROR, "%s: %s", functionname, strerror(errno));
    126126       
     
    128128}
    129129
    130 static void log_null(int level, char *message) {
     130static void log_null(int level, const char *message) {
    131131        return;
    132132}
    133133
    134 static void log_irc(int level, char *message) {
     134static void log_irc(int level, const char *message) {
    135135        if(level == LOGLVL_ERROR)
    136136                irc_write_all(1, "ERROR :Error: %s", message);
     
    147147}
    148148
    149 static void log_syslog(int level, char *message) {
     149static void log_syslog(int level, const char *message) {
    150150        if(level == LOGLVL_ERROR)
    151151                syslog(LOG_ERR, "%s", message);
     
    161161}
    162162
    163 static void log_console(int level, char *message) {
     163static void log_console(int level, const char *message) {
    164164        if(level == LOGLVL_ERROR)
    165165                fprintf(stderr, "Error: %s\n", message);
  • log.h

    r2e44b1f r3f81999  
    4444
    4545typedef struct log_t {
    46         void (*error)(int level, char *logmessage);
    47         void (*warning)(int level, char *logmessage);
    48         void (*informational)(int level, char *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);
    4949#ifdef DEBUG
    50         void (*debug)(int level, char *logmessage);
     50        void (*debug)(int level, const char *logmessage);
    5151#endif
    5252} log_t;
     
    5454void log_init(void);
    5555void log_link(int level, int output);
    56 void log_message(int level, char *message, ...) G_GNUC_PRINTF( 2, 3 );
    57 void log_error(char *functionname);
     56void log_message(int level, const char *message, ...) G_GNUC_PRINTF( 2, 3 );
     57void log_error(const char *functionname);
    5858
    5959#endif
  • protocols/jabber/jabber.c

    r2e44b1f r3f81999  
    528528       
    529529        ret->name = "jabber";
     530    ret->mms = 0;                        /* no limit */
    530531        ret->login = jabber_login;
    531532        ret->init = jabber_init;
  • protocols/msn/msn.c

    r2e44b1f r3f81999  
    317317       
    318318        ret->name = "msn";
     319    ret->mms = 1409;         /* this guess taken from libotr UPGRADING file */
    319320        ret->login = msn_login;
    320321        ret->init = msn_init;
  • protocols/msn/ns.c

    r2e44b1f r3f81999  
    278278                if( num_parts == 5 )
    279279                {
    280                         int i, groupcount;
    281                        
    282                         groupcount = atoi( cmd[4] );
    283                         if( groupcount > 0 )
    284                         {
    285                                 /* valgrind says this is leaking memory, I'm guessing
    286                                    that this happens during server redirects. */
    287                                 if( md->grouplist )
    288                                 {
    289                                         for( i = 0; i < md->groupcount; i ++ )
    290                                                 g_free( md->grouplist[i] );
    291                                         g_free( md->grouplist );
    292                                 }
    293                                
    294                                 md->groupcount = groupcount;
     280                        md->buddycount = atoi( cmd[3] );
     281                        md->groupcount = atoi( cmd[4] );
     282                        if( md->groupcount > 0 )
    295283                                md->grouplist = g_new0( char *, md->groupcount );
    296                         }
    297                        
    298                         md->buddycount = atoi( cmd[3] );
     284                       
    299285                        if( !*cmd[3] || md->buddycount == 0 )
    300286                                msn_logged_in( ic );
     
    679665                                        imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
    680666                                }
    681                                
    682                                 g_free( inbox );
    683                                 g_free( folders );
    684667                        }
    685668                        else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 )
  • protocols/nogaim.c

    r2e44b1f r3f81999  
    661661       
    662662        /* LISPy... */
    663         if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
    664             ( u->online ) &&                                            /* Don't touch offline people */
    665             ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
    666               ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* (De)voice people changing state */
     663        if( ( u->online ) &&                                            /* Don't touch offline people */
     664            ( ( ( u->online != oo ) && !u->away ) ||                    /* Do joining people */
     665              ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* Do people changing state */
    667666        {
    668667                char *from;
     
    677676                                                            ic->irc->myhost );
    678677                }
    679                 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
    680                                                           u->away?'-':'+', u->nick );
     678                if(!strcmp(set_getstr(&ic->irc->set, "voice_buddies"), "notaway")) {
     679                        irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
     680                                                                 u->away?'-':'+', u->nick );
     681                }
     682                if(!strcmp(set_getstr(&ic->irc->set, "halfop_buddies"), "notaway")) {
     683                        irc_write( ic->irc, ":%s MODE %s %ch %s", from, ic->irc->channel,
     684                                                                 u->away?'-':'+', u->nick );
     685                }
     686                if(!strcmp(set_getstr(&ic->irc->set, "op_buddies"), "notaway")) {
     687                        irc_write( ic->irc, ":%s MODE %s %co %s", from, ic->irc->channel,
     688                                                                 u->away?'-':'+', u->nick );
     689                }
    681690                g_free( from );
    682691        }
     
    688697        char *wrapped;
    689698        user_t *u;
    690        
     699
     700        /* pass the message through OTR */
     701        msg = otr_handle_message(ic, handle, msg);
     702        if(!msg) {
     703                /* this was an internal OTR protocol message */
     704                return;
     705        }
     706
    691707        u = user_findhandle( ic, handle );
    692        
    693708        if( !u )
    694709        {
     
    700715                                imcb_log( ic, "Ignoring message from unknown handle %s", handle );
    701716                       
     717                        g_free(msg);
    702718                        return;
    703719                }
     
    732748        irc_msgfrom( irc, u->nick, wrapped );
    733749        g_free( wrapped );
     750        g_free( msg );
    734751}
    735752
     
    972989
    973990
    974 /* Misc. BitlBee stuff which shouldn't really be here */
    975 
    976 char *set_eval_away_devoice( set_t *set, char *value )
    977 {
    978         irc_t *irc = set->data;
    979         int st;
    980        
    981         if( !is_bool( value ) )
    982                 return SET_INVALID;
    983        
    984         st = bool2int( value );
    985        
    986         /* Horror.... */
    987        
    988         if( st != set_getbool( &irc->set, "away_devoice" ) )
    989         {
    990                 char list[80] = "";
    991                 user_t *u = irc->users;
    992                 int i = 0, count = 0;
    993                 char pm;
    994                 char v[80];
    995                
    996                 if( st )
    997                         pm = '+';
    998                 else
    999                         pm = '-';
    1000                
    1001                 while( u )
    1002                 {
    1003                         if( u->ic && u->online && !u->away )
    1004                         {
    1005                                 if( ( strlen( list ) + strlen( u->nick ) ) >= 79 )
    1006                                 {
    1007                                         for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0;
    1008                                         irc_write( irc, ":%s MODE %s %c%s%s",
    1009                                                    irc->myhost,
    1010                                                    irc->channel, pm, v, list );
    1011                                        
    1012                                         *list = 0;
    1013                                         count = 0;
    1014                                 }
    1015                                
    1016                                 sprintf( list + strlen( list ), " %s", u->nick );
    1017                                 count ++;
    1018                         }
    1019                         u = u->next;
    1020                 }
    1021                
    1022                 /* $v = 'v' x $i */
    1023                 for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0;
    1024                 irc_write( irc, ":%s MODE %s %c%s%s", irc->myhost,
    1025                                                             irc->channel, pm, v, list );
    1026         }
    1027        
    1028         return value;
    1029 }
    1030 
    1031 
    1032 
    1033 
    1034991/* The plan is to not allow straight calls to prpl functions anymore, but do
    1035992   them all from some wrappers. We'll start to define some down here: */
     
    10451002                msg = buf;
    10461003        }
    1047        
    1048         st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags );
    1049         g_free( buf );
    1050        
     1004
     1005        /* if compiled without otr support, this just calls the prpl buddy_msg */
     1006        st = otr_send_message(ic, handle, msg, flags);
     1007       
     1008        g_free(buf);
    10511009        return st;
    10521010}
  • protocols/nogaim.h

    r2e44b1f r3f81999  
    132132         * - The user sees this name ie. when imcb_log() is used. */
    133133        const char *name;
     134    /* Maximum Message Size of this protocol.
     135     * - Introduced for OTR, in order to fragment large protocol messages.
     136     * - 0 means "unlimited". */
     137    unsigned int mms;
    134138
    135139        /* Added this one to be able to add per-account settings, don't think
     
    324328
    325329/* Misc. stuff */
    326 char *set_eval_away_devoice( set_t *set, char *value );
    327330gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond );
    328331void cancel_auto_reconnect( struct account *a );
  • protocols/oscar/oscar.c

    r2e44b1f r3f81999  
    26672667        struct prpl *ret = g_new0(struct prpl, 1);
    26682668        ret->name = "oscar";
     2669    ret->mms = 2343;       /* this guess taken from libotr UPGRADING file */
    26692670        ret->away_states = oscar_away_states;
    26702671        ret->init = oscar_init;
  • protocols/yahoo/libyahoo2.c

    r2e44b1f r3f81999  
    6969#ifdef __MINGW32__
    7070# include <winsock2.h>
     71# define write(a,b,c) send(a,b,c,0)
     72# define read(a,b,c)  recv(a,b,c,0)
    7173#endif
    7274
  • protocols/yahoo/yahoo.c

    r2e44b1f r3f81999  
    369369        struct prpl *ret = g_new0(struct prpl, 1);
    370370        ret->name = "yahoo";
     371    ret->mms = 832;           /* this guess taken from libotr UPGRADING file */
    371372        ret->init = byahoo_init;
    372373       
  • protocols/yahoo/yahoo_httplib.c

    r2e44b1f r3f81999  
    5151#ifdef __MINGW32__
    5252# include <winsock2.h>
     53# define write(a,b,c) send(a,b,c,0)
     54# define read(a,b,c)  recv(a,b,c,0)
    5355# define snprintf _snprintf
    5456#endif
  • query.c

    r2e44b1f r3f81999  
    103103        int count = 0;
    104104       
     105        if(!ic)
     106                return;
     107       
    105108        q = irc->queries;
    106109        def = query_default( irc );
     
    145148                else
    146149                        irc_usermsg( irc, "Accepted: %s", q->question );
    147                 q->yes( q->data );
     150                if( q->yes )
     151                        q->yes( q->data );
    148152        }
    149153        else
     
    153157                else
    154158                        irc_usermsg( irc, "Rejected: %s", q->question );
    155                 q->no( q->data );
     159                if( q->no )
     160                        q->no( q->data );
    156161        }
    157162        q->data = NULL;
  • root_commands.c

    r2e44b1f r3f81999  
    2929#include "bitlbee.h"
    3030#include "help.h"
     31#include "otr.h"
    3132
    3233#include <string.h>
     
    407408               
    408409                irc_usermsg( irc, "Account successfully added" );
     410               
     411                if(otr_check_for_key(a)) {
     412                        irc_usermsg(irc, "otr: you will be notified when it completes");
     413                }
    409414        }
    410415        else if( g_strcasecmp( cmd[1], "del" ) == 0 )
     
    12091214        { "qlist",          0, cmd_qlist,          0 },
    12101215        { "join_chat",      2, cmd_join_chat,      0 },
     1216        { "otr",            1, cmd_otr,            0 },
    12111217        { "chat",           1, cmd_chat,           0 },
    12121218        { NULL }
  • set.c

    r2e44b1f r3f81999  
    225225}
    226226
    227 char *set_eval_ops( set_t *set, char *value )
     227char* set_eval_op_root( set_t *set, char* value )
    228228{
    229229        irc_t *irc = set->data;
    230        
    231         if( g_strcasecmp( value, "user" ) == 0 )
    232                 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost,
    233                                                               irc->channel, "+o-o", irc->nick, irc->mynick );
    234         else if( g_strcasecmp( value, "root" ) == 0 )
    235                 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost,
    236                                                               irc->channel, "-o+o", irc->nick, irc->mynick );
    237         else if( g_strcasecmp( value, "both" ) == 0 )
    238                 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost,
    239                                                               irc->channel, "+oo", irc->nick, irc->mynick );
    240         else if( g_strcasecmp( value, "none" ) == 0 )
    241                 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost,
    242                                                               irc->channel, "-oo", irc->nick, irc->mynick );
     230        char* ret = set_eval_bool(set, value);
     231        int b = bool2int(ret);
     232
     233        irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost,
     234                                               irc->channel, b?"+o":"-o", irc->mynick);
     235
     236        return ret;
     237}
     238
     239char* set_eval_op_user( set_t *set, char* value )
     240{
     241        irc_t *irc = set->data;
     242        char* ret = set_eval_bool(set, value);
     243        int b = bool2int(ret);
     244
     245        irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost,
     246                                               irc->channel, b?"+o":"-o", irc->nick);
     247
     248        return ret;
     249}
     250
     251/* generalized version of set_eval_op/voice_buddies */
     252char *set_eval_mode_buddies( set_t *set, char *value, char modeflag )
     253{
     254        irc_t *irc = set->data;
     255        char op[64], deop[64];
     256        int nop=0, ndeop=0;
     257        user_t *u;
     258        int mode;
     259       
     260        if(!strcmp(value, "false"))
     261                mode=0;
     262        else if(!strcmp(value, "encrypted"))
     263                mode=1;
     264        else if(!strcmp(value, "trusted"))
     265                mode=2;
     266        else if(!strcmp(value, "notaway"))
     267                mode=3;
    243268        else
    244269                return SET_INVALID;
    245        
     270
     271        /* sorry for calling them op/deop - too lazy for search+replace :P */
     272        op[0]='\0';
     273        deop[0]='\0';
     274        for(u=irc->users; u; u=u->next) {
     275                /* we're only concerned with online buddies */
     276                if(!u->ic || !u->online)
     277                        continue;
     278
     279                /* just in case... */
     280                if(strlen(u->nick) >= 64)
     281                        continue;
     282               
     283                /* dump out ops/deops when the corresponding name list fills up */
     284                if(strlen(op)+strlen(u->nick)+2 > 64) {
     285                        char *flags = g_strnfill(nop, modeflag);
     286                        irc_write( irc, ":%s!%s@%s MODE %s +%s%s", irc->mynick, irc->mynick, irc->myhost,
     287                                                               irc->channel, flags, op );
     288                    op[0]='\0';
     289            nop=0;
     290                    g_free(flags);
     291                }
     292                if(strlen(deop)+strlen(u->nick)+2 > 64) {
     293                        char *flags = g_strnfill(ndeop, modeflag);
     294                        irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost,
     295                                                               irc->channel, flags, deop );
     296                    deop[0]='\0';
     297            ndeop=0;
     298                    g_free(flags);
     299                }
     300               
     301                switch(mode) {
     302                /* "false" */
     303                case 0:
     304                        g_strlcat(deop, " ", 64);
     305                        g_strlcat(deop, u->nick, 64);
     306                        ndeop++;
     307                        break;
     308                /* "encrypted" */
     309                case 1:
     310                        if(u->encrypted) {
     311                                g_strlcat(op, " ", 64);
     312                                g_strlcat(op, u->nick, 64);
     313                                nop++;
     314                        } else {
     315                                g_strlcat(deop, " ", 64);
     316                                g_strlcat(deop, u->nick, 64);
     317                                ndeop++;
     318                        }
     319                        break;
     320                /* "trusted" */
     321                case 2:
     322                        if(u->encrypted > 1) {
     323                                g_strlcat(op, " ", 64);
     324                                g_strlcat(op, u->nick, 64);
     325                                nop++;
     326                        } else {
     327                                g_strlcat(deop, " ", 64);
     328                                g_strlcat(deop, u->nick, 64);
     329                                ndeop++;
     330                        }
     331                        break;
     332                /* "notaway" */
     333                case 3:
     334                        if(u->away) {
     335                                g_strlcat(deop, " ", 64);
     336                                g_strlcat(deop, u->nick, 64);
     337                                ndeop++;
     338                        } else {
     339                                g_strlcat(op, " ", 64);
     340                                g_strlcat(op, u->nick, 64);
     341                                nop++;
     342                        }
     343                }
     344        }
     345        /* dump anything left in op/deop lists */
     346        if(*op) {
     347                char *flags = g_strnfill(nop, modeflag);
     348                irc_write( irc, ":%s!%s@%s MODE %s +%s%s", irc->mynick, irc->mynick, irc->myhost,
     349                                                               irc->channel, flags, op );
     350                g_free(flags);
     351        }
     352        if(*deop) {
     353                char *flags = g_strnfill(ndeop, modeflag);
     354                irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost,
     355                                                   irc->channel, flags, deop );
     356        g_free(flags);
     357    }
     358
    246359        return value;
    247360}
     361
     362char *set_eval_op_buddies( set_t *set, char *value )
     363{
     364        return set_eval_mode_buddies(set, value, 'o');
     365}
     366
     367char *set_eval_halfop_buddies( set_t *set, char *value )
     368{
     369        return set_eval_mode_buddies(set, value, 'h');
     370}
     371
     372char *set_eval_voice_buddies( set_t *set, char *value )
     373{
     374        return set_eval_mode_buddies(set, value, 'v');
     375}
     376
     377/* possible values: never, opportunistic, manual, always */
     378char *set_eval_otr_policy( set_t *set, char *value )
     379{
     380        if ( !strcmp(value, "never") )
     381                return value;
     382        if ( !strcmp(value, "opportunistic") )
     383                return value;
     384        if ( !strcmp(value, "manual") )
     385                return value;
     386        if ( !strcmp(value, "always") )
     387                return value;
     388        return NULL;
     389}
     390
  • set.h

    r2e44b1f r3f81999  
    100100/* Some not very generic evaluators that really shouldn't be here... */
    101101char *set_eval_to_char( set_t *set, char *value );
    102 char *set_eval_ops( set_t *set, char *value );
     102char *set_eval_op_root( set_t *set, char *value );
     103char *set_eval_op_user( set_t *set, char *value );
     104char *set_eval_op_buddies( set_t *set, char *value );
     105char *set_eval_halfop_buddies( set_t *set, char *value );
     106char *set_eval_voice_buddies( set_t *set, char *value );
     107char *set_eval_otr_policy( set_t *set, char *value );
    103108
    104109#endif /* __SET_H__ */
  • sock.h

    r2e44b1f r3f81999  
    1616#else
    1717# include <winsock2.h>
    18 # include <ws2tcpip.h>
     18# ifndef _MSC_VER
     19#  include <ws2tcpip.h>
     20# endif
    1921# if !defined(BITLBEE_CORE) && defined(_MSC_VER)
    2022#   pragma comment(lib,"bitlbee.lib")
    2123# endif
    2224# include <io.h>
     25# define read(a,b,c) recv(a,b,c,0)
     26# define write(a,b,c) send(a,b,c,0)
     27# define umask _umask
     28# define mode_t int
    2329# define sock_make_nonblocking(fd) { int non_block = 1; ioctlsocket(fd, FIONBIO, &non_block); }
    2430# define sock_make_blocking(fd) { int non_block = 0; ioctlsocket(fd, FIONBIO, &non_block); }
  • storage.c

    r2e44b1f r3f81999  
    2929#include "bitlbee.h"
    3030#include "crypting.h"
     31#include "otr.h"
    3132
    3233extern storage_t storage_text;
     
    116117
    117118                status = st->load(irc, password);
    118                 if (status == STORAGE_OK)
     119                if (status == STORAGE_OK) {
     120                        otr_load(irc);
    119121                        return status;
    120                
     122                }
    121123                if (status != STORAGE_NO_SUCH_USER)
    122124                        return status;
     
    139141                return STORAGE_NO_SUCH_USER;
    140142        }
    141        
     143
     144        otr_save(irc);
    142145        st = ((storage_t *)global.storage->data)->save(irc, overwrite);
    143146       
     
    165168                        ret = status;
    166169        }
     170        if (ret == STORAGE_OK) {
     171                otr_remove(nick);
     172        }
    167173       
    168174        return ret;
     
    178184        storage_t *primary_storage = gl->data;
    179185        irc_t *irc;
    180 
     186       
    181187        /* First, try to rename in the current write backend, assuming onick
    182188         * is stored there */
    183189        status = primary_storage->rename(onick, nnick, password);
    184         if (status != STORAGE_NO_SUCH_USER)
     190        if (status != STORAGE_NO_SUCH_USER) {
     191                otr_rename(onick, nnick);
    185192                return status;
     193        }
    186194
    187195        /* Try to load from a migration backend and save to the current backend.
     
    207215
    208216        storage_remove(onick, password);
     217        otr_rename(onick, nnick);
    209218
    210219        return STORAGE_OK;
  • storage_text.c

    r2e44b1f r3f81999  
    2727#include "bitlbee.h"
    2828#include "crypting.h"
    29 #ifdef _WIN32
    30 # define umask _umask
    31 # define mode_t int
    32 #endif
    33 
    34 #ifndef F_OK
    35 #define F_OK 0
    36 #endif
    3729
    3830static void text_init (void)
  • unix.c

    r2e44b1f r3f81999  
    2727#include "commands.h"
    2828#include "crypting.h"
     29#include "otr.h"
    2930#include "protocols/nogaim.h"
    3031#include "help.h"
    3132#include "ipc.h"
     33#include "lib/ssl_client.h"
    3234#include <signal.h>
    3335#include <unistd.h>
     
    5456        b_main_init();
    5557        nogaim_init();
     58        /* Ugly Note: libotr and gnutls both use libgcrypt. libgcrypt
     59           has a process-global config state whose initialization happpens
     60           twice if libotr and gnutls are used together. libotr installs custom
     61           memory management functions for libgcrypt while our gnutls module
     62           uses the defaults. Therefore we initialize OTR after SSL. *sigh* */
     63        ssl_init();
     64        otr_init();
    5665       
    5766        srand( time( NULL ) ^ getpid() );
     
    214223        return( (double) time->tv_sec + (double) time->tv_usec / 1000000 );
    215224}
    216 
    217 
  • user.h

    r2e44b1f r3f81999  
    3737        char is_private;
    3838        char online;
     39        char encrypted;
    3940       
    4041        char *handle;
Note: See TracChangeset for help on using the changeset viewer.