Changeset fa29d093 for protocols


Ignore:
Timestamp:
2007-03-28T05:53:11Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
0da65d5
Parents:
723e611
Message:

Preparing for Jabber conference room support.

Location:
protocols
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    r723e611 rfa29d093  
    241241}
    242242
    243 static int msn_chat_send( struct gaim_connection *gc, int id, char *message )
    244 {
    245         struct msn_switchboard *sb = msn_sb_by_id( gc, id );
     243static int msn_chat_send( struct conversation *c, char *message )
     244{
     245        struct msn_switchboard *sb = msn_sb_by_chat( c );
    246246       
    247247        if( sb )
     
    251251}
    252252
    253 static void msn_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who )
    254 {
    255         struct msn_switchboard *sb = msn_sb_by_id( gc, id );
     253static void msn_chat_invite( struct conversation *c, char *msg, char *who )
     254{
     255        struct msn_switchboard *sb = msn_sb_by_chat( c );
    256256        char buf[1024];
    257257       
     
    263263}
    264264
    265 static void msn_chat_leave( struct gaim_connection *gc, int id )
    266 {
    267         struct msn_switchboard *sb = msn_sb_by_id( gc, id );
     265static void msn_chat_leave( struct conversation *c )
     266{
     267        struct msn_switchboard *sb = msn_sb_by_chat( c );
    268268       
    269269        if( sb )
     
    271271}
    272272
    273 static int msn_chat_open( struct gaim_connection *gc, char *who )
     273static struct conversation *msn_chat_open( struct gaim_connection *gc, char *who )
    274274{
    275275        struct msn_switchboard *sb;
     
    280280        {
    281281                debug( "Converting existing switchboard to %s to a groupchat", who );
    282                 msn_sb_to_chat( sb );
    283                 return( 1 );
     282                return msn_sb_to_chat( sb );
    284283        }
    285284        else
     
    292291                        g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who );
    293292                        if( msn_sb_write( sb, buf, strlen( buf ) ) )
    294                         {
    295                                 msn_sb_to_chat( sb );
    296                                 return( 1 );
    297                         }
     293                                return msn_sb_to_chat( sb );
    298294                }
    299295               
     
    314310                md->msgq = g_slist_append( md->msgq, m );
    315311               
    316                 return( 1 );
    317         }
    318        
    319         return( 0 );
     312                /* FIXME: Can I try to return something here already? */
     313                return NULL;
     314        }
     315       
     316        return NULL;
    320317}
    321318
  • protocols/msn/msn.h

    r723e611 rfa29d093  
    169169struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, int port, char *key, int session );
    170170struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *handle );
    171 struct msn_switchboard *msn_sb_by_id( struct gaim_connection *gc, int id );
     171struct msn_switchboard *msn_sb_by_chat( struct conversation *c );
    172172struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc );
    173173int msn_sb_sendmessage( struct msn_switchboard *sb, char *text );
    174 void msn_sb_to_chat( struct msn_switchboard *sb );
     174struct conversation *msn_sb_to_chat( struct msn_switchboard *sb );
    175175void msn_sb_destroy( struct msn_switchboard *sb );
    176176gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond );
  • protocols/msn/sb.c

    r723e611 rfa29d093  
    8686}
    8787
    88 struct msn_switchboard *msn_sb_by_id( struct gaim_connection *gc, int id )
    89 {
    90         struct msn_data *md = gc->proto_data;
     88struct msn_switchboard *msn_sb_by_chat( struct conversation *c )
     89{
     90        struct msn_data *md = c->gc->proto_data;
    9191        struct msn_switchboard *sb;
    9292        GSList *l;
     
    9595        {
    9696                sb = l->data;
    97                 if( sb->chat && sb->chat->id == id )
     97                if( sb->chat == c )
    9898                        return( sb );
    9999        }
     
    177177}
    178178
    179 void msn_sb_to_chat( struct msn_switchboard *sb )
     179struct conversation *msn_sb_to_chat( struct msn_switchboard *sb )
    180180{
    181181        struct gaim_connection *gc = sb->gc;
     
    184184        /* Create the groupchat structure. */
    185185        g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session );
    186         sb->chat = serv_got_joined_chat( gc, ++msn_chat_id, buf );
     186        sb->chat = serv_got_joined_chat( gc, buf );
    187187       
    188188        /* Populate the channel. */
     
    196196                sb->who = NULL;
    197197        }
     198       
     199        return sb->chat;
    198200}
    199201
     
    230232        if( sb->chat )
    231233        {
    232                 serv_got_chat_left( gc, sb->chat->id );
     234                serv_got_chat_left( sb->chat );
    233235        }
    234236       
     
    372374                        {
    373375                                g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session );
    374                                 sb->chat = serv_got_joined_chat( gc, ++msn_chat_id, buf );
     376                                sb->chat = serv_got_joined_chat( gc, buf );
    375377                               
    376378                                g_free( sb->who );
     
    610612                        else if( sb->chat )
    611613                        {
    612                                 serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, body, 0 );
     614                                serv_got_chat_in( sb->chat, cmd[1], 0, body, 0 );
    613615                        }
    614616                        else
     
    669671                        else if( sb->chat )
    670672                        {
    671                                 serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, buf, 0 );
     673                                serv_got_chat_in( sb->chat, cmd[1], 0, buf, 0 );
    672674                        }
    673675                        else
  • protocols/nogaim.c

    r723e611 rfa29d093  
    682682}
    683683
    684 void serv_got_chat_left( struct gaim_connection *gc, int id )
    685 {
    686         struct conversation *c, *l = NULL;
     684void serv_got_chat_left( struct conversation *c )
     685{
     686        struct gaim_connection *gc = c->gc;
     687        struct conversation *l = NULL;
    687688        GList *ir;
    688689       
    689690        if( set_getbool( &gc->irc->set, "debug" ) )
    690                 serv_got_crap( gc, "You were removed from conversation %d", (int) id );
    691        
    692         for( c = gc->conversations; c && c->id != id; c = (l=c)->next );
     691                serv_got_crap( gc, "You were removed from conversation 0x%x", (int) c );
    693692       
    694693        if( c )
     
    720719}
    721720
    722 void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime )
    723 {
    724         struct conversation *c;
     721void serv_got_chat_in( struct conversation *c, char *who, int whisper, char *msg, time_t mtime )
     722{
     723        struct gaim_connection *gc = c->gc;
    725724        user_t *u;
    726725       
     
    730729       
    731730        u = user_findhandle( gc, who );
    732         for( c = gc->conversations; c && c->id != id; c = c->next );
    733731       
    734732        if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
     
    739737                irc_privmsg( gc->irc, u, "PRIVMSG", c->channel, "", msg );
    740738        else
    741                 serv_got_crap( gc, "Message from/to conversation %s@%d (unknown conv/user): %s", who, id, msg );
    742 }
    743 
    744 struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle )
     739                serv_got_crap( gc, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );
     740}
     741
     742struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle )
    745743{
    746744        struct conversation *c;
    747         char *s;
    748745       
    749746        /* This one just creates the conversation structure, user won't see anything yet */
     
    755752        }
    756753        else
    757                 gc->conversations = c = g_new0( struct conversation, 1);
    758        
    759         c->id = id;
     754                gc->conversations = c = g_new0( struct conversation, 1 );
     755       
    760756        c->gc = gc;
    761757        c->title = g_strdup( handle );
    762        
    763         s = g_new( char, 16 );
    764         sprintf( s, "&chat_%03d", gc->irc->c_id++ );
    765         c->channel = g_strdup( s );
    766         g_free( s );
     758        c->channel = g_strdup_printf( "&chat_%03d", gc->irc->c_id++ );
    767759       
    768760        if( set_getbool( &gc->irc->set, "debug" ) )
    769                 serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle );
    770        
    771         return( c );
     761                serv_got_crap( gc, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );
     762       
     763        return c;
    772764}
    773765
     
    781773       
    782774        if( set_getbool( &b->gc->irc->set, "debug" ) )
    783                 serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id );
     775                serv_got_crap( b->gc, "User %s added to conversation 0x%x", handle, (int) b );
    784776       
    785777        /* It might be yourself! */
     
    815807       
    816808        if( set_getbool( &b->gc->irc->set, "debug" ) )
    817                 serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" );
     809                serv_got_crap( b->gc, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" );
    818810       
    819811        /* It might be yourself! */
     
    858850/* Misc. BitlBee stuff which shouldn't really be here */
    859851
    860 struct conversation *conv_findchannel( char *channel )
     852struct conversation *chat_by_channel( char *channel )
    861853{
    862854        struct gaim_connection *gc;
     
    870862                for( c = gc->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next );
    871863                if( c )
    872                         return( c );
    873         }
    874        
    875         return( NULL );
     864                        return c;
     865        }
     866       
     867        return NULL;
    876868}
    877869
     
    958950}
    959951
    960 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg )
     952int bim_chat_msg( struct conversation *c, char *msg )
    961953{
    962954        char *buf = NULL;
    963955        int st;
    964956       
    965         if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
     957        if( ( c->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
    966958        {
    967959                buf = escape_html( msg );
     
    969961        }
    970962       
    971         st = gc->acc->prpl->chat_send( gc, id, msg );
     963        st = c->gc->acc->prpl->chat_send( c, msg );
    972964        g_free( buf );
    973965       
  • protocols/nogaim.h

    r723e611 rfa29d093  
    100100
    101101        /* stuff used just for chat */
    102         GList *in_room;
    103         GList *ignored;
    104         int id;
    105        
    106         /* BitlBee */
    107         struct conversation *next;
    108         char *channel;
    109         char *title;
    110         char joined;
    111         void *data;
     102        GList *in_room;
     103        GList *ignored;
     104       
     105        /* BitlBee */
     106        struct conversation *next;
     107        char *channel;
     108        char *title;
     109        char joined;
     110        void *data;
    112111};
    113112
     
    115114        char name[80];
    116115        char show[BUDDY_ALIAS_MAXLEN];
    117         int present;
     116        int present;
    118117        int evil;
    119118        time_t signon;
    120119        time_t idle;
    121         int uc;
     120        int uc;
    122121        guint caps; /* woohoo! */
    123122        void *proto_data; /* what a hack */
     
    153152       
    154153        /* Group chat stuff. */
    155         void (* join_chat)      (struct gaim_connection *, GList *data);
    156         void (* chat_invite)    (struct gaim_connection *, int id, char *who, char *message);
    157         void (* chat_leave)     (struct gaim_connection *, int id);
    158         int  (* chat_send)      (struct gaim_connection *, int id, char *message);
    159         int  (* chat_open)      (struct gaim_connection *, char *who);
     154        void (* chat_invite)    (struct conversation *, char *who, char *message);
     155        void (* chat_leave)     (struct conversation *);
     156        int  (* chat_send)      (struct conversation *, char *message);
     157        struct conversation *
     158             (* chat_open)      (struct gaim_connection *, char *who);
     159        struct conversation *
     160             (* chat_join)      (struct gaim_connection *, char *chat, char *nick, char *password);
    160161       
    161162        /* DIE! */
     
    183184int bim_set_away( struct gaim_connection *gc, char *away );
    184185int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags );
    185 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg );
     186int bim_chat_msg( struct conversation *c, char *msg );
    186187
    187188void bim_add_allow( struct gaim_connection *gc, char *handle );
     
    224225G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *handle, const char *realname );
    225226
    226 /* server.c */                   
     227/* server.c */
    227228G_MODULE_EXPORT void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps );
    228229G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len );
    229230G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type );
    230231G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data );
    231 G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle );
    232 G_MODULE_EXPORT void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime );
    233 G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id );
    234 
    235 struct conversation *conv_findchannel( char *channel );
     232G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle );
     233G_MODULE_EXPORT void serv_got_chat_in( struct conversation *c, char *who, int whisper, char *msg, time_t mtime );
     234G_MODULE_EXPORT void serv_got_chat_left( struct conversation *c );
     235
     236struct conversation *chat_by_channel( char *channel );
     237struct conversation *chat_by_id( int id );
    236238
    237239#endif
  • protocols/oscar/oscar.c

    r723e611 rfa29d093  
    157157        return tmp;
    158158}
    159 
    160 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) {
    161         GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats;
    162         struct chat_connection *c = NULL;
    163 
    164         while (g) {
    165                 c = (struct chat_connection *)g->data;
    166                 if (c->id == id)
    167                         break;
    168                 g = g->next;
    169                 c = NULL;
    170         }
    171 
    172         return c;
    173 }
    174 
    175159
    176160static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc,
     
    769753        chatcon = find_oscar_chat_by_conn(gc, fr->conn);
    770754        chatcon->id = id;
    771         chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show);
     755        chatcon->cnv = serv_got_joined_chat(gc, chatcon->show);
     756        chatcon->cnv->data = chatcon;
    772757
    773758        return 1;
     
    15801565        tmp = g_malloc(BUF_LONG);
    15811566        g_snprintf(tmp, BUF_LONG, "%s", msg);
    1582         serv_got_chat_in(gc, ccon->id, info->sn, 0, tmp, time((time_t)NULL));
     1567        serv_got_chat_in(ccon->cnv, info->sn, 0, tmp, time((time_t)NULL));
    15831568        g_free(tmp);
    15841569
     
    25212506}
    25222507
    2523 int oscar_chat_send(struct gaim_connection * gc, int id, char *message)
    2524 {
     2508int oscar_chat_send(struct conversation *c, char *message)
     2509{
     2510        struct gaim_connection *gc = c->gc;
    25252511        struct oscar_data * od = (struct oscar_data*)gc->proto_data;
    25262512        struct chat_connection * ccon;
     
    25302516        char *s;
    25312517       
    2532         if(!(ccon = find_oscar_chat(gc, id)))
    2533                 return -1;
     2518        ccon = c->data;
    25342519               
    25352520        for (s = message; *s; s++)
     
    25682553}
    25692554
    2570 void oscar_chat_invite(struct gaim_connection * gc, int id, char *message, char *who)
    2571 {
     2555void oscar_chat_invite(struct conversation *c, char *message, char *who)
     2556{
     2557        struct gaim_connection *gc = c->gc;
    25722558        struct oscar_data * od = (struct oscar_data *)gc->proto_data;
    2573         struct chat_connection *ccon = find_oscar_chat(gc, id);
    2574        
    2575         if (ccon == NULL)
    2576                 return;
     2559        struct chat_connection *ccon = c->data;
    25772560       
    25782561        aim_chat_invite(od->sess, od->conn, who, message ? message : "",
     
    25852568
    25862569        /* Notify the conversation window that we've left the chat */
    2587         serv_got_chat_left(gc, cc->id);
     2570        serv_got_chat_left(cc->cnv);
    25882571
    25892572        /* Destroy the chat_connection */
     
    25972580}
    25982581
    2599 void oscar_chat_leave(struct gaim_connection * gc, int id)
    2600 {
    2601         struct chat_connection * ccon = find_oscar_chat(gc, id);
    2602 
    2603         if(ccon == NULL)
    2604                 return;
    2605 
    2606         oscar_chat_kill(gc, ccon);
     2582void oscar_chat_leave(struct conversation *c)
     2583{
     2584        oscar_chat_kill(c->gc, c->data);
    26072585}
    26082586
    26092587int oscar_chat_join(struct gaim_connection * gc, char * name)
    26102588{
    2611     struct oscar_data * od = (struct oscar_data *)gc->proto_data;
     2589        struct oscar_data * od = (struct oscar_data *)gc->proto_data;
    26122590       
    26132591        aim_conn_t * cur;
     
    26272605}
    26282606
    2629 int oscar_chat_open(struct gaim_connection * gc, char *who)
     2607struct conversation *oscar_chat_open(struct gaim_connection * gc, char *who)
    26302608{
    26312609        struct oscar_data * od = (struct oscar_data *)gc->proto_data;
     
    26422620        g_free(chatname);
    26432621       
    2644         return ret;
     2622        return NULL;
    26452623}
    26462624
  • protocols/yahoo/yahoo.c

    r723e611 rfa29d093  
    140140       
    141141        while( gc->conversations )
    142                 serv_got_chat_left( gc, gc->conversations->id );
     142                serv_got_chat_left( gc->conversations );
    143143       
    144144        for( l = yd->buddygroups; l; l = l->next )
     
    332332}
    333333
    334 static int byahoo_chat_send( struct gaim_connection *gc, int id, char *message )
    335 {
    336         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    337         struct conversation *c;
    338        
    339         for( c = gc->conversations; c && c->id != id; c = c->next );
    340 
     334static int byahoo_chat_send( struct conversation *c, char *message )
     335{
     336        struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data;
     337       
    341338        yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 );
    342339       
     
    344341}
    345342
    346 static void byahoo_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who )
    347 {
    348         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    349         struct conversation *c;
    350        
    351         for( c = gc->conversations; c && c->id != id; c = c->next );
     343static void byahoo_chat_invite( struct conversation *c, char *msg, char *who )
     344{
     345        struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data;
    352346       
    353347        yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg );
    354348}
    355349
    356 static void byahoo_chat_leave( struct gaim_connection *gc, int id )
    357 {
    358         struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
    359         struct conversation *c;
    360        
    361         for( c = gc->conversations; c && c->id != id; c = c->next );
     350static void byahoo_chat_leave( struct conversation *c )
     351{
     352        struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data;
    362353       
    363354        yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title );
    364         serv_got_chat_left( gc, c->id );
    365 }
    366 
    367 static int byahoo_chat_open( struct gaim_connection *gc, char *who )
     355        serv_got_chat_left( c );
     356}
     357
     358static struct conversation *byahoo_chat_open( struct gaim_connection *gc, char *who )
    368359{
    369360        struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;
     
    375366        g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id );
    376367       
    377         c = serv_got_joined_chat( gc, ++byahoo_chat_id, roomname );
     368        c = serv_got_joined_chat( gc, roomname );
    378369        add_chat_buddy( c, gc->username );
    379370       
     
    387378        g_free( roomname );
    388379       
    389         return( 1 );
     380        return c;
    390381}
    391382
     
    805796{
    806797        yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" );
    807         serv_got_chat_left( inv->gc, inv->c->id );
     798        serv_got_chat_left( inv->c );
    808799        g_free( inv->name );
    809800        g_free( inv );
     
    820811        memset( inv, 0, sizeof( struct byahoo_conf_invitation ) );
    821812        inv->name = g_strdup( room );
    822         inv->c = serv_got_joined_chat( gc, ++byahoo_chat_id, room );
     813        inv->c = serv_got_joined_chat( gc, room );
    823814        inv->c->data = members;
    824815        inv->yid = id;
     
    872863        for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );
    873864       
    874         serv_got_chat_in( gc, c ? c->id : 0, who, 0, m, 0 );
     865        if( c )
     866                serv_got_chat_in( c, who, 0, m, 0 );
    875867        g_free( m );
    876868}
Note: See TracChangeset for help on using the changeset viewer.