Changeset 860ba6a


Ignore:
Timestamp:
2009-10-05T23:32:34Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
7da726b
Parents:
796da03
Message:

Moved some stuff around, got something that logs in and reports status now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/purple/purple.c

    r796da03 r860ba6a  
    4747} PurpleGLibIOClosure;
    4848
     49static struct im_connection *purple_ic_by_gc( PurpleConnection *gc )
     50{
     51        PurpleAccount *pa = purple_connection_get_account( gc );
     52        GSList *i;
     53       
     54        for( i = purple_connections; i; i = i->next )
     55                if( ((struct im_connection *)i->data)->proto_data == pa )
     56                        return i->data;
     57       
     58        return NULL;
     59}
     60
    4961static void purple_glib_io_destroy(gpointer data)
    5062{
     
    110122};
    111123
     124static void purple_init( account_t *acc )
     125{
     126        /* TODO: Figure out variables to export via set. */
     127}
     128
     129static void purple_login( account_t *acc )
     130{
     131        struct im_connection *ic = imcb_new( acc );
     132        PurpleAccount *pa;
     133        PurpleSavedStatus *ps;
     134       
     135        /* For now this is needed in the _connected() handlers if using
     136           GLib event handling, to make sure we're not handling events
     137           on dead connections. */
     138        purple_connections = g_slist_prepend( purple_connections, ic );
     139       
     140        pa = purple_account_new( acc->user, acc->prpl->name );
     141        purple_account_set_password( pa, acc->pass );
     142       
     143        ic->proto_data = pa;
     144       
     145        purple_account_set_enabled( pa, "BitlBee", TRUE );
     146       
     147        //ps = purple_savedstatus_new( NULL, PURPLE_STATUS_AVAILABLE );
     148        //purple_savedstatus_activate_for_account( ps, pa );
     149}
     150
     151static void purple_logout( struct im_connection *ic )
     152{
     153        purple_connections = g_slist_remove( purple_connections, ic );
     154}
     155
     156static int purple_buddy_msg( struct im_connection *ic, char *who, char *message, int flags )
     157{
     158}
     159
     160static GList *purple_away_states( struct im_connection *ic )
     161{
     162        return NULL;
     163}
     164
     165static void purple_set_away( struct im_connection *ic, char *state_txt, char *message )
     166{
     167}
     168
     169static void purple_add_buddy( struct im_connection *ic, char *who, char *group )
     170{
     171}
     172
     173static void purple_remove_buddy( struct im_connection *ic, char *who, char *group )
     174{
     175}
     176
     177static void purple_keepalive( struct im_connection *ic )
     178{
     179}
     180
     181static int purple_send_typing( struct im_connection *ic, char *who, int typing )
     182{
     183}
     184
     185static void purple_ui_init();
     186
    112187static PurpleCoreUiOps bee_core_uiops =
    113188{
    114189        NULL,
    115190        NULL,
    116         NULL, //null_ui_init,
     191        purple_ui_init,
    117192        NULL,
    118193
     
    122197        NULL,
    123198        NULL
     199};
     200
     201static void prplcb_conn_progress( PurpleConnection *gc, const char *text, size_t step, size_t step_count )
     202{
     203        imcb_log( purple_ic_by_gc( gc ), "%s", text );
     204}
     205
     206static void prplcb_conn_connected( PurpleConnection *gc )
     207{
     208        imcb_connected( purple_ic_by_gc( gc ) );
     209}
     210
     211static void prplcb_conn_disconnected( PurpleConnection *gc )
     212{
     213        imc_logout( purple_ic_by_gc( gc ), TRUE );
     214}
     215
     216static void prplcb_conn_notice( PurpleConnection *gc, const char *text )
     217{
     218        imcb_log( purple_ic_by_gc( gc ), "%s", text );
     219}
     220
     221static void prplcb_conn_report_disconnect_reason( PurpleConnection *gc, PurpleConnectionError reason, const char *text )
     222{
     223        /* PURPLE_CONNECTION_ERROR_NAME_IN_USE means concurrent login,
     224           should probably handle that. */
     225        imcb_error( purple_ic_by_gc( gc ), "%s", text );
     226}
     227
     228static PurpleConnectionUiOps bee_conn_uiops =
     229{
     230        prplcb_conn_progress,
     231        prplcb_conn_connected,
     232        prplcb_conn_disconnected,
     233        prplcb_conn_notice,
     234        NULL,
     235        NULL,
     236        NULL,
     237        prplcb_conn_report_disconnect_reason,
    124238};
    125239
     
    147261};
    148262
    149 static void purple_init( account_t *acc )
    150 {
    151         set_t *s;
    152         char str[16];
    153        
    154 }
    155 
    156 static void purple_login( account_t *acc )
    157 {
    158         struct im_connection *ic = imcb_new( acc );
    159         struct ns_srv_reply *srv = NULL;
    160         char *connect_to, *s;
    161         int i;
    162        
    163         /* For now this is needed in the _connected() handlers if using
    164            GLib event handling, to make sure we're not handling events
    165            on dead connections. */
    166         purple_connections = g_slist_prepend( purple_connections, ic );
    167        
    168 }
    169 
    170 static void purple_logout( struct im_connection *ic )
    171 {
    172         purple_connections = g_slist_remove( purple_connections, ic );
    173 }
    174 
    175 static int purple_buddy_msg( struct im_connection *ic, char *who, char *message, int flags )
    176 {
    177 }
    178 
    179 static GList *purple_away_states( struct im_connection *ic )
    180 {
    181 }
    182 
    183 static void purple_set_away( struct im_connection *ic, char *state_txt, char *message )
    184 {
    185 }
    186 
    187 static void purple_add_buddy( struct im_connection *ic, char *who, char *group )
    188 {
    189 }
    190 
    191 static void purple_remove_buddy( struct im_connection *ic, char *who, char *group )
    192 {
    193 }
    194 
    195 static void purple_keepalive( struct im_connection *ic )
    196 {
    197 }
    198 
    199 static int purple_send_typing( struct im_connection *ic, char *who, int typing )
    200 {
     263static void purple_ui_init()
     264{
     265        purple_connections_set_ui_ops( &bee_conn_uiops );
     266        purple_conversations_set_ui_ops( &bee_conv_uiops );
    201267}
    202268
Note: See TracChangeset for help on using the changeset viewer.