static void _elim_chat_add_users ( PurpleConversation *conv , GList *cbuddies , gboolean new_arrivals ) { char *ID = new_elim_id(); xmlnode *args = xnode_new( "alist" ); xmlnode *list = xnode_new( "list" ); xmlnode *mcall = func_call( "elim-chat-add-users", ID, args ); g_free( ID ); fprintf( stderr, "(_elim_chat_add_users)\n" ); _elim_conv_args( args, conv ); AL_BOOL( args, "new-arrivals" , new_arrivals ); AL_NODE( args, "participants" , list ); fprintf( stderr, "(_elim_chat_add_users)\n" ); for( ; cbuddies; cbuddies = cbuddies->next ) { xmlnode *cbuddy = xnode_new( "alist" ); PurpleConvChatBuddy *pccb = cbuddies->data; AL_STR ( cbuddy, "name" , pccb->name ? pccb->name : "" ); AL_STR ( cbuddy, "alias" , pccb->alias ? pccb->alias : "" ); AL_STR ( cbuddy, "alias-key", pccb->alias_key ? pccb->alias_key : "" ); AL_ENUM( cbuddy, "flags" , pccb->flags , ":conv-chat-buddy-flags" ); AL_BOOL( cbuddy, "on-blist" , pccb->buddy ); xnode_insert_child( list, cbuddy ); } add_outbound_sexp( mcall ); fprintf( stderr, "(_elim_chat_add_users:DONE)\n" ); }
static void _elim_report_disconnect_reason( PurpleConnection *conn , PurpleConnectionError reason , const char *text ) { PurpleAccount *acct = purple_connection_get_account( conn ); if( acct ) { char *ID = new_elim_id(); xmlnode *alist = xnode_new( "alist" ); fprintf( stderr, "(_elim_report_disconnect_reason)\n" ); xmlnode *mcall = func_call( "elim-disconnect-reason", ID, alist ); const char *aname = purple_account_get_username ( acct ); const char *proto = purple_account_get_protocol_id( acct ); int state = purple_connection_get_state ( conn ); g_free( ID ); AL_PTR ( alist, "account-uid" , acct ); AL_STR ( alist, "account-name", aname ); AL_STR ( alist, "im-protocol" , proto ); AL_STR ( alist, "message" , text ); AL_ENUM( alist, "reason-code" , reason, ":connection-error" ); AL_ENUM( alist, "state" , state , ":connection-state" ); add_outbound_sexp( mcall ); } }
static void _elim_write_conv ( PurpleConversation *conv , const char *name , const char *alias , const char *message , PurpleMessageFlags flags , time_t mtime ) { char *msg = NULL; char *ID = new_elim_id(); xmlnode *args = xnode_new( "alist" ); xmlnode *mcall = func_call( "elim-conv-write-sys", ID, args ); g_free( ID ); fprintf( stderr, "(_elim_write_conv)\n" ); if( _elim_strippable( conv, flags ) ) msg = purple_markup_strip_html( message ); _elim_conv_args( args, conv ); AL_STR ( args, "who" , (name ? name : (alias ? alias : "")) ); AL_STR ( args, "alias", (alias ? alias : (name ? name : "")) ); AL_STR ( args, "text" , msg ? msg : message ); AL_ENUM( args, "flags", flags , ":message-flags" ); AL_INT ( args, "time" , mtime ); if( msg ) g_free( msg ); fprintf( stderr, "(elim-debug _elim_write_conv:DONE)\n" ); add_outbound_sexp( mcall ); }
static void _elim_connect_progress ( PurpleConnection *gc , const char *text , size_t step , size_t step_count ) { PurpleAccount *acct = purple_connection_get_account( gc ); fprintf( stderr, "(_elim_connect_progress)\n" ); if( acct ) { char *ID = new_elim_id(); xmlnode *alist = xnode_new( "alist" ); xmlnode *mcall = func_call( "elim-connection-progress", ID, alist ); const char *aname = purple_account_get_username ( acct ); const char *proto = purple_account_get_protocol_id( acct ); int state = purple_connection_get_state ( gc ); g_free( ID ); AL_PTR ( alist, "account-uid" , acct ); AL_STR ( alist, "account-name", aname ); AL_STR ( alist, "im-protocol" , proto ); AL_INT ( alist, "step" , step ); AL_INT ( alist, "step-count" , step_count ); AL_STR ( alist, "message" , text ); AL_ENUM( alist, "state" , state , ":connection-state" ); add_outbound_sexp( mcall ); } }
static void *_elim_request_authorise ( PurpleAccount *account , const char *remote_user , const char *id , const char *alias , const char *message , gboolean on_list , PARA_CB authorize_cb , PARA_CB deny_cb , void *user_data ) { CB_HANDLER *cbh = g_new0( CB_HANDLER, 1 ); AUI_RESP *resp = g_new0( AUI_RESP , 1 ); xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); fprintf( stderr, "(_elim_request_authorise)\n" ); AL_STR ( alist, "user" , remote_user ); AL_STR ( alist, "id" , id ); AL_STR ( alist, "alias" , alias ); AL_BOOL( alist, "on-list" , on_list ); AL_STR ( alist, "message" , message ); AL_PTR ( alist, "account-uid" , account ); AL_STR ( alist, "account-name", purple_account_get_username ( account ) ); AL_STR ( alist, "im-protocol" , purple_account_get_protocol_id( account ) ); resp->ok = authorize_cb; resp->nok = deny_cb; resp->id = ID; resp->data = user_data; cbh ->func = _elim_request_authorise_cb; cbh ->data = resp; store_cb_data( ID, cbh ); xmlnode *mcall = func_call( "elim-account-request-auth", ID, alist ); add_outbound_sexp( mcall ); return cbh; }
static void _elim_network ( const char *call ) { char *ID = new_elim_id(); xmlnode *mcall = func_call( call , ID, NULL ); fprintf( stderr, "(_elim_network)\n" ); g_free( ID ); add_outbound_sexp( mcall ); }
static void _elim_destroy_conversation ( PurpleConversation *conv ) { char *ID = new_elim_id(); xmlnode *args = xnode_new( "alist" ); xmlnode *mcall = func_call( "elim-conv-destroy", ID, args ); g_free( ID ); fprintf( stderr, "(_elim_destroy_conversation)\n" ); _elim_conv_args( args, conv ); add_outbound_sexp( mcall ); }
static void _elim_roomlist_add ( PurpleRoomlist *list , PurpleRoomlistRoom *room ) { g_return_if_fail( list && room ); xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); __roomlist_insert_account( list->account, alist ); AL_PTR ( alist , "roomlist-id" , list ); AL_STR ( alist , "room-name" , room->name ); AL_ENUM( alist , "room-type" , room->type , ":roomlist-room-type" ); AL_PTR ( alist , "room-parent" , room->parent ); AL_BOOL( alist , "room-expanded-once", room->expanded_once ); xmlnode *fields = xnode_new_child( alist, "alist" ); xnode_set_attrib( fields, "name", "fields" ); GList *listf = g_list_first( list->fields ); GList *roomf = g_list_first( room->fields ); #define NNEXTT( a, b ) a = g_list_next( a ), b = g_list_next( b ) #define PTR_TO_BOOL(_p) (_p != NULL) for( ; listf && roomf ; NNEXTT( listf, roomf ) ) { PurpleRoomlistField *f = (PurpleRoomlistField*) listf->data; switch( f->type ) { case PURPLE_ROOMLIST_FIELD_BOOL: AL_BOOL( fields, f->name, PTR_TO_BOOL( roomf->data ) ); break; case PURPLE_ROOMLIST_FIELD_INT: AL_INT ( fields, f->name, roomf->data ); break; case PURPLE_ROOMLIST_FIELD_STRING: AL_STR ( fields, f->name, roomf->data ); break; default: fprintf( stderr, "unsupported room list field type.\n" ); break; } } xmlnode *mcall = func_call( "elim-roomlist-add", ID, alist ); g_free( ID ); add_outbound_sexp( mcall ); }
static void _elim_roomlist_destroy ( PurpleRoomlist *list ) { g_return_if_fail( list ); xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); __roomlist_insert_account( list->account, alist ); AL_PTR ( alist , "roomlist-id", list ); xmlnode *mcall = func_call( "elim-roomlist-destroy", ID, alist ); g_free( ID ); add_outbound_sexp( mcall ); }
static void _elim_roomlist_in_progress ( PurpleRoomlist *list , gboolean flag ) { g_return_if_fail( list ); xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); __roomlist_insert_account( list->account, alist ); AL_PTR ( alist , "roomlist-id", list ); AL_BOOL( alist , "in-progress", flag ); xmlnode *mcall = func_call( "elim-roomlist-in-progress", ID, alist ); g_free( ID ); add_outbound_sexp( mcall ); }
static void _elim_roomlist_create ( PurpleRoomlist *list ) { g_return_if_fail( list ); xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); __roomlist_insert_account( list->account, alist ); AL_PTR ( alist, "roomlist-id", list ); xmlnode *flist = xnode_new_child( alist, "alist" ); xnode_set_attrib( flist, "name", "fields" ); g_list_foreach( list->fields, __roomlist_add_list_field, flist ); xmlnode *mcall = func_call( "elim-roomlist-create", ID, alist ); g_free( ID ); add_outbound_sexp( mcall ); }
static void _elim_chat_rename_user ( PurpleConversation *conv , const char *old_name , const char *new_name , const char *new_alias ) { char *ID = new_elim_id(); xmlnode *args = xnode_new( "alist" ); xmlnode *mcall = func_call( "elim-chat-rename-user", ID, args ); g_free( ID ); fprintf( stderr, "(_elim_chat_rename_user)\n" ); _elim_conv_args( args, conv ); AL_STR( args, "old-name" , old_name ); AL_STR( args, "new-name" , new_name ); AL_STR( args, "new-alias", new_alias ); add_outbound_sexp( mcall ); }
static void _elim_notify_added ( PurpleAccount *account , const char *remote_user, const char *id , const char *alias , const char *message ) { xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); fprintf( stderr, "(_elim_notify_added)\n" ); AL_STR( alist, "user" , remote_user ); AL_STR( alist, "alias" , alias ); AL_STR( alist, "message" , message ); AL_PTR( alist, "account-uid" , account ); AL_STR( alist, "account-name" , purple_account_get_username ( account ) ); AL_STR( alist, "im-protocol" , purple_account_get_protocol_id( account ) ); xmlnode *mcall = func_call( "elim-account-notify-added", ID, alist ); g_free( ID ); add_outbound_sexp( mcall ); }
static void _elim_chat_remove_users ( PurpleConversation *conv , GList *users ) { char *ID = new_elim_id(); xmlnode *args = xnode_new( "alist" ); xmlnode *mcall = func_call( "elim-chat-remove-users", ID, args ); xmlnode *list = xnode_new( "list" ); g_free( ID ); fprintf( stderr, "(_elim_chat_remove_users)\n" ); _elim_conv_args( args, conv ); for( ; users; users = users->next ) { xmlnode *user = xnode_new_child( list, "string" ); xnode_insert_data( user, users->data ? users->data : "", -1 ); } AL_NODE( args, "participants", list ); fprintf( stderr, "(_elim_chat_remove_users:DONE)\n" ); add_outbound_sexp( mcall ); }
static void _elim_notice ( PurpleConnection *conn, const char *msg ) { PurpleAccount *acct = purple_connection_get_account( conn ); if( acct ) { char *ID = new_elim_id(); xmlnode *alist = xnode_new( "alist" ); xmlnode *mcall = func_call( "elim-connection-state", ID, alist ); const char *aname = purple_account_get_username ( acct ); const char *proto = purple_account_get_protocol_id( acct ); int state = purple_connection_get_state ( conn ); g_free( ID ); AL_PTR ( alist, "account-uid" , acct ); AL_STR ( alist, "account-name", aname ); AL_STR ( alist, "im-protocol" , proto ); AL_STR ( alist, "message" , msg ); AL_ENUM( alist, "state" , state , ":connection-state" ); add_outbound_sexp( mcall ); } }
static void _elim_status_changed ( PurpleAccount *account , PurpleStatus *status ) { xmlnode *alist = xnode_new( "alist" ); char *ID = new_elim_id(); fprintf( stderr, "(_elim_status_changed)\n" ); PurpleStatusType *type = purple_status_get_type( status ); PurpleStatusPrimitive statp = purple_status_type_get_primitive( type ); AL_PTR ( alist, "account-uid" , account ); AL_STR ( alist, "account-name", purple_account_get_username ( account ) ); AL_STR ( alist, "im-protocol" , purple_account_get_protocol_id( account ) ); AL_STR ( alist, "status-name" , purple_status_get_name ( status ) ); AL_ENUM( alist, "status-type" , statp, ":status-primitive" ); AL_BOOL( alist, "connected" , purple_account_is_connected ( account ) ); xmlnode *mcall = func_call( "elim-account-status-changed", ID, alist ); g_free( ID ); add_outbound_sexp( mcall ); }