Changeset 10a96f4


Ignore:
Timestamp:
2010-03-29T12:25:01Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
81e04e1
Parents:
38ee021
Message:

Start restoring IM-related bits, added bee_user.c with basic functions
and UI callbacks.

Location:
protocols
Files:
1 added
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/Makefile

    r38ee021 r10a96f4  
    1111# [SH] Program variables
    1212#objects = account.o nogaim.o user.o
    13 objects = bee.o
     13objects = bee.o bee_user.o nogaim.o
    1414
    1515
  • protocols/bee.h

    r38ee021 r10a96f4  
    1 typedef struct bee_ui
    2 {
    3         void *data;
    4 } bee_ui_t;
     1  /********************************************************************\
     2  * BitlBee -- An IRC to other IM-networks gateway                     *
     3  *                                                                    *
     4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
     5  \********************************************************************/
     6
     7/* Stuff to handle, save and search buddies                             */
     8
     9/*
     10  This program is free software; you can redistribute it and/or modify
     11  it under the terms of the GNU General Public License as published by
     12  the Free Software Foundation; either version 2 of the License, or
     13  (at your option) any later version.
     14
     15  This program is distributed in the hope that it will be useful,
     16  but WITHOUT ANY WARRANTY; without even the implied warranty of
     17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18  GNU General Public License for more details.
     19
     20  You should have received a copy of the GNU General Public License with
     21  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
     22  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
     23  Suite 330, Boston, MA  02111-1307  USA
     24*/
     25
     26#ifndef __BEE_H__
     27#define __BEE_H__
     28
     29struct bee_ui_funcs;
    530
    631typedef struct bee
     
    1136        GSList *accounts;
    1237       
    13         //const bee_ui_funcs_t *ui;
     38        const struct bee_ui_funcs *ui;
    1439        void *ui_data;
    1540} bee_t;
     
    1742bee_t *bee_new();
    1843void bee_free( bee_t *b );
     44
     45typedef enum
     46{
     47        BEE_USER_ONLINE = 1,
     48        BEE_USER_AWAY = 2,
     49} bee_user_flags_t;
     50
     51typedef struct bee_user
     52{
     53        struct im_connection *ic;
     54        char *handle;
     55        char *fullname;
     56        char *group;
     57
     58        char *away;
     59        char *status_msg;
     60       
     61        bee_t *bee;
     62        void *ui_data;
     63} bee_user_t;
     64
     65typedef struct bee_ui_funcs
     66{
     67        gboolean (*user_new)( bee_t *bee, struct bee_user *bu );
     68        gboolean (*user_free)( bee_t *bee, struct bee_user *bu );
     69} bee_ui_funcs_t;
     70
     71
     72/* bee.c */
     73bee_t *bee_new();
     74void bee_free( bee_t *b );
     75
     76/* bee_user.c */
     77bee_user_t *bee_user_new( bee_t *bee, struct im_connection *ic, const char *handle );
     78int bee_user_free( bee_t *bee, struct im_connection *ic, const char *handle );
     79bee_user_t *bee_user_by_handle( bee_t *bee, struct im_connection *ic, const char *handle );
     80
     81#endif /* __BEE_H__ */
  • protocols/nogaim.c

    r38ee021 r10a96f4  
    199199        va_end( params );
    200200
    201         if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
    202             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
     201        if( ( g_strcasecmp( set_getstr( &ic->irc->b->set, "strip_html" ), "always" ) == 0 ) ||
     202            ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->b->set, "strip_html" ) ) )
    203203                strip_html( text );
    204204       
     
    265265        irc_t *irc = ic->irc;
    266266        struct chat *c;
    267         user_t *u;
    268267       
    269268        /* MSN servers sometimes redirect you to a different server and do
     
    273272                return;
    274273       
    275         u = user_find( ic->irc, ic->irc->nick );
    276        
    277274        imcb_log( ic, "Logged in" );
    278275       
     
    287284        ic->acc->auto_reconnect_delay = 0;
    288285       
     286        /*
    289287        for( c = irc->chatrooms; c; c = c->next )
    290288        {
     
    295293                        chat_join( irc, c, NULL );
    296294        }
     295        */
    297296}
    298297
     
    360359                /* Uhm... This is very sick. */
    361360        }
    362         else if( allow_reconnect && set_getbool( &irc->set, "auto_reconnect" ) &&
     361        else if( allow_reconnect && set_getbool( &irc->b->set, "auto_reconnect" ) &&
    363362                 set_getbool( &a->set, "auto_reconnect" ) &&
    364363                 ( delay = account_reconnect_delay( a ) ) > 0 )
     
    391390        if( user_findhandle( ic, handle ) )
    392391        {
    393                 if( set_getbool( &irc->set, "debug" ) )
     392                if( set_getbool( &irc->b->set, "debug" ) )
    394393                        imcb_log( ic, "User already exists, ignoring add request: %s", handle );
    395394               
     
    470469                u->realname = g_strdup( realname );
    471470               
    472                 if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) )
     471                if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->b->set, "display_namechanges" ) )
    473472                        imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
    474473        }
     
    518517                /* Some processing to make sure this string is a valid IRC nickname. */
    519518                nick_strip( newnick );
    520                 if( set_getbool( &ic->irc->set, "lcnicks" ) )
     519                if( set_getbool( &ic->irc->b->set, "lcnicks" ) )
    521520                        nick_lc( newnick );
    522521               
     
    626625        if( !u )
    627626        {
    628                 if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 )
     627                if( g_strcasecmp( set_getstr( &ic->irc->b->set, "handle_unknown" ), "add" ) == 0 )
    629628                {
    630629                        imcb_add_buddy( ic, (char*) handle, NULL );
     
    633632                else
    634633                {
    635                         if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 )
     634                        if( set_getbool( &ic->irc->b->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->b->set, "handle_unknown" ), "ignore" ) != 0 )
    636635                        {
    637636                                imcb_log( ic, "imcb_buddy_status() for unknown handle %s:", handle );
     
    693692       
    694693        /* LISPy... */
    695         if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
     694        if( ( set_getbool( &ic->irc->b->set, "away_devoice" ) ) &&              /* Don't do a thing when user doesn't want it */
    696695            ( u->online ) &&                                            /* Don't touch offline people */
    697696            ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
     
    700699                char *from;
    701700               
    702                 if( set_getbool( &ic->irc->set, "simulate_netsplit" ) )
     701                if( set_getbool( &ic->irc->b->set, "simulate_netsplit" ) )
    703702                {
    704703                        from = g_strdup( ic->irc->myhost );
     
    725724        if( !u )
    726725        {
    727                 char *h = set_getstr( &irc->set, "handle_unknown" );
     726                char *h = set_getstr( &irc->b->set, "handle_unknown" );
    728727               
    729728                if( g_strcasecmp( h, "ignore" ) == 0 )
    730729                {
    731                         if( set_getbool( &irc->set, "debug" ) )
     730                        if( set_getbool( &irc->b->set, "debug" ) )
    732731                                imcb_log( ic, "Ignoring message from unknown handle %s", handle );
    733732                       
     
    736735                else if( g_strncasecmp( h, "add", 3 ) == 0 )
    737736                {
    738                         int private = set_getbool( &irc->set, "private" );
     737                        int private = set_getbool( &irc->b->set, "private" );
    739738                       
    740739                        if( h[3] )
     
    757756        }
    758757       
    759         if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
    760             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
     758        if( ( g_strcasecmp( set_getstr( &ic->irc->b->set, "strip_html" ), "always" ) == 0 ) ||
     759            ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->b->set, "strip_html" ) ) )
    761760                strip_html( msg );
    762761
     
    770769        user_t *u;
    771770       
    772         if( !set_getbool( &ic->irc->set, "typing_notice" ) )
     771        if( !set_getbool( &ic->irc->b->set, "typing_notice" ) )
    773772                return;
    774773       
     
    801800        c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title );
    802801       
    803         if( set_getbool( &ic->irc->set, "debug" ) )
     802        if( set_getbool( &ic->irc->b->set, "debug" ) )
    804803                imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );
    805804       
     
    813812        GList *ir;
    814813       
    815         if( set_getbool( &ic->irc->set, "debug" ) )
     814        if( set_getbool( &ic->irc->b->set, "debug" ) )
    816815                imcb_log( ic, "You were removed from conversation %p", c );
    817816       
     
    860859        u = user_findhandle( ic, who );
    861860       
    862         if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
    863             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
     861        if( ( g_strcasecmp( set_getstr( &ic->irc->b->set, "strip_html" ), "always" ) == 0 ) ||
     862            ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->b->set, "strip_html" ) ) )
    864863                strip_html( msg );
    865864       
     
    906905                u = user_findhandle( ic, who );
    907906       
    908         if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
    909             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
     907        if( ( g_strcasecmp( set_getstr( &ic->irc->b->set, "strip_html" ), "always" ) == 0 ) ||
     908            ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->b->set, "strip_html" ) ) )
    910909                strip_html( topic );
    911910       
     
    925924        int me = 0;
    926925       
    927         if( set_getbool( &b->ic->irc->set, "debug" ) )
     926        if( set_getbool( &b->ic->irc->b->set, "debug" ) )
    928927                imcb_log( b->ic, "User %s added to conversation %p", handle, b );
    929928       
     
    960959        int me = 0;
    961960       
    962         if( set_getbool( &b->ic->irc->set, "debug" ) )
     961        if( set_getbool( &b->ic->irc->b->set, "debug" ) )
    963962                imcb_log( b->ic, "User %s removed from conversation %p (%s)", handle, b, reason ? reason : "" );
    964963       
     
    10181017        /* Horror.... */
    10191018       
    1020         if( st != set_getbool( &irc->set, "away_devoice" ) )
     1019        if( st != set_getbool( &irc->b->set, "away_devoice" ) )
    10211020        {
    10221021                char list[80] = "";
     
    11071106       
    11081107        away = set_getstr( &ic->acc->set, "away" ) ?
    1109              : set_getstr( &ic->irc->set, "away" );
     1108             : set_getstr( &ic->irc->b->set, "away" );
    11101109        if( away && *away )
    11111110        {
     
    11181117                away = NULL;
    11191118                msg = set_getstr( &ic->acc->set, "status" ) ?
    1120                     : set_getstr( &ic->irc->set, "status" );
     1119                    : set_getstr( &ic->irc->b->set, "status" );
    11211120        }
    11221121       
Note: See TracChangeset for help on using the changeset viewer.