⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blade_if.h

📁 wi-fi手机原代码
💻 H
字号:
/*! \defgroup Blade */

/*! \ingroup    Blade
*   \file       blade_if.h
*   \brief      This file contains API/Data Structure IF definition for Blade and application layer.
*   \author     Wu Enping
*   \version    1.0
*
*   \warning    This file is OS independent.
*   \date       2006-01-11
*/

#ifndef _BLADE_IF_H
#define _BLADE_IF_H


#ifdef __cplusplus
extern "C"{
#endif

/*! maximum length of host name */
#define MAX_HOST_NAME_LEN 64

/*! macro definition of the maximum length of a JID */
#define MAX_JID_LEN  52     /*must be the multpile of sizeof(int)*/

/*! macro definition of the maximum length of a password */
#define MAX_PSWD_LEN    12  /*must be the multpile of sizeof(int)*/

/*! macro definition of the maximum length of a group name */
#define MAX_GROUP_LEN    10   /*must be the multpile of sizeof(int), the item size is sizeof(unsigned short)*/

/*! macro definition of the maximum length of a contact nick */
#define MAX_NICK_LEN    10  /*must be the multpile of sizeof(int), the item size is sizeof(unsigned short)*/

/*! macro definition of the maximum length of the text in the <show> element in presence */
#define MAX_STATUS_TEXT_LEN    20  /*must be the multpile of sizeof(int), the item size is sizeof(unsigned short)*/

/*! macro definition of the maximum length of an instant message */
#define MAX_IM_LEN    128

/*! macro definition of the maximum item numbers in one roster update message sent to Application layer */
#define MAX_ROSTER_ITEM    10

/*
 ****************************************************
 *** Below are Application --> Protocol Interface ***
 ****************************************************
 */
 
/*! \brief  enumeration for the message types */
typedef enum
{
    APP_JAB_LOGIN_REQ =0,	
    APP_JAB_LOGOUT_REQ,
    APP_JAB_IM_REQ,
    APP_JAB_CHG_STAT_REQ,
    APP_JAB_ADD_CONTACT_REQ,
    APP_JAB_SUB_REQ,
    APP_JAB_REMOVE_CONTACT_REQ,
    APP_JAB_UNSUB_REQ,
    APP_JAB_MOVE_CONTACT_REQ,
    APP_JAB_RENAME_CONTACT_REQ,
    APP_JAB_BLOCK_REQ,
    APP_JAB_INC_SUB_APPROVE_REQ,
    APP_JAB_SET_DEF_RULE_REQ,
    APP_JAB_SET_INVISIBLE_REQ,
    /* below is are private messages used inside Jabber stack only */
    JAB_BROADCAST_PRES_REQ,
    APP_JAB_MAX_MSG                                        /*end of the enum*/
} app_jab_msg_type_e;


/*! typedef  INIT message body structure */
typedef struct
{	
    char 	my_jid_s[MAX_JID_LEN];
    char 	passwd_s[MAX_PSWD_LEN];
    char    jab_server_s[MAX_HOST_NAME_LEN];
    unsigned int pres_broadcast_interv;
    unsigned int invisible_login_b;
    unsigned int new_account_b;
    unsigned int use_tls_b;         
} app_jab_login_t; 

/*! typedef  UN-INIT message body structure */
typedef struct
{
    void* reserved_p;
} app_jab_logout_t;


/*! typedef  IM message body structure */
typedef struct
{
    char 	dest_jid_s[MAX_JID_LEN];
    unsigned short 	msg_body_s[MAX_IM_LEN];  /*must be the unicode*/
} app_jab_im_t;


/*! \brief  enumeration for main presence states */
typedef enum
{	
    J_AVAILABLE,
    J_UNAVAILABLE
} jab_pres_main_stat_e;


/*! \brief  enumeration for sub presence states */
typedef enum
{
    J_NONE,
    J_AWAY,
    J_CHAT,
    J_DND,
    J_XA
} jab_pres_sub_stat_e;


/*! typedef  presence state structure */
typedef struct
{	
    jab_pres_main_stat_e     main_stat;
    jab_pres_sub_stat_e	      sub_stat;
    unsigned short                status_txt_s[MAX_STATUS_TEXT_LEN];    /*must be unicode*/
    char                               stat_priority;
}jab_pres_stat_t;


/*! typedef  CHG_STAT message body structure */
typedef struct
{
    jab_pres_stat_t			state;
} app_jab_my_stat_t;


/*! \brief  enumeration for the subscription status */
typedef enum
{
    N_A,
    NONE_TO_FROM,
    NONE_P_OUT,
    NONE_P_IN,
    NONE_P_OUT_IN,
    TO,
    TO_P_IN,
    FROM,
    FROM_P_OUT,
    BOTH,
    REMOVE
} jab_sub_status_e;


/*! typedef  ADD_CONTACT message body structure */
typedef struct
{	
    char 	                dest_jid_s[MAX_JID_LEN];   
    unsigned short	  group_s[MAX_GROUP_LEN];                  /*must be unicode*/
     unsigned short 	  dest_nick_name_s[MAX_NICK_LEN];   /*must be unicode*/
    jab_sub_status_e sub_state;
} app_jab_add_contact_t;


/*! typedef  SUBSCRIBE_CONTACT message body structure */
typedef struct
{	
    char 	dest_jid_s[MAX_JID_LEN];
} app_jab_sub_t;


/*! typedef  REMOVE_CONTACT message body structure */
typedef struct
{
    char 	dest_jid_s[MAX_JID_LEN];
} app_jab_remove_contact_t;


/*! typedef  UNSUBSCRIBE_CONTACT message body structure */
typedef struct
{
    char 	dest_jid_s[MAX_JID_LEN];
} app_jab_unsub_t;


/*! typedef  MOVE_CONTACT message body structure */
typedef struct
{
    char 	              dest_jid_s[MAX_JID_LEN];
    unsigned short	dest_nick_s[MAX_NICK_LEN];                     /*must be unicode*/
    unsigned short 	dest_group_name_s[MAX_GROUP_LEN];     /*must be unicode*/
    jab_sub_status_e sub_state;
} app_jab_move_contact_t;


/*! typedef  RENAME_CONTACT message body structure */
typedef struct
{
    char 	              dest_jid_s[MAX_JID_LEN];
    unsigned short 	dest_nick_name_s[MAX_NICK_LEN];            /*must be unicode*/
    unsigned short	dest_group_name_s[MAX_GROUP_LEN];       /*must be unicode*/
    jab_sub_status_e sub_state;
} app_jab_rename_contact_t;


/*! typedef  BLOCK_CONTACT message body structure */
typedef struct
{
    char                     dest_jid_s[MAX_JID_LEN];
    unsigned short      dest_nick_name_s[MAX_NICK_LEN];    /*must be unicode*/
    jab_sub_status_e  sub_state;
} app_jab_block_t;


/*! typedef  INCOMING_SUBSCRIPTION_APPROVE message body structure */
typedef struct
{
    char 	dest_jid_s[MAX_JID_LEN];
    int 	approve_b;	
} app_jab_inc_sub_approve_t;


/*! typedef  SET_DEFAULT_PRIVACY_RULE message body structure */
typedef struct
{
    int 				approve_b;
} app_jab_set_def_rule_t;


/*! typedef  SET_DEFAULT_PRIVACY_RULE message body structure */
typedef struct
{
    int                 invisible_b;
} app_jab_set_invisible_t;

/*! typedef  message bodies' union */
typedef union
{	
    app_jab_login_t				login;
    app_jab_logout_t			logout;
    app_jab_im_t				im;
    app_jab_my_stat_t			pres_status;
    app_jab_add_contact_t		add_contact;
    app_jab_sub_t				subscribe;
    app_jab_remove_contact_t	remov_contact;
    app_jab_unsub_t			    unsubscribe;
    app_jab_move_contact_t		mov_usr;
    app_jab_rename_contact_t	ren_usr;
    app_jab_block_t			    block;
    app_jab_inc_sub_approve_t	inc_sub;
    app_jab_set_def_rule_t		def_rule;
    app_jab_set_invisible_t     set_invisible;
} app_jab_msg_body_t;


/*! typedef  application --> protocol message structure */
typedef struct
{	
    app_jab_msg_type_e			    msg_type;	
    app_jab_msg_body_t			    msg_body;
} app_jab_msg_t;


/* The message sending API provided for Application layer */
extern int app_jab_send_msg(app_jab_msg_t *);


/*
 ****************************************************
 *** Below are Protocol --> Application Interface ***
 ****************************************************
 */
 
/*! \brief  enumeration for the message types */
typedef enum
{	
    JAB_APP_LOGIN_RSP=0,
    JAB_APP_LOGOUT_RSP,
    JAB_APP_SEND_IM_RSP,
    JAB_APP_CHG_STAT_RSP,
    JAB_APP_ADD_CONTACT_RSP,
    JAB_APP_SUB_RSP,
    JAB_APP_REMOVE_CONTACT_RSP,
    JAB_APP_UNSUB_RSP,
    JAB_APP_MOVE_CONTACT_RSP,
    JAB_APP_RENAME_CONTACT_RSP,
    JAB_APP_BLOCK_CONTACT_RSP = 10,
    JAB_APP_APPROVE_SUB_RSP,
    JAB_APP_SET_DEF_RULE_RSP,
    JAB_APP_SET_INVISIBLE_RULE_RSP,
    JAB_APP_INC_SUB_IND,
    JAB_APP_INC_UNSUB_IND = 15,
    JAB_APP_INC_IM_IND,
    JAB_APP_INC_REM_PRES_IND,
    JAB_APP_OUT_SUB_RESULT_IND,
    JAB_APP_ROSTER_UPD_IND,
    JAB_APP_MAX_MSG                  /*end of the enum*/
    
} jab_app_msg_type_e;


/*! typedef  login_RSP message body structure */
typedef struct
{
    int					result;
} jab_app_login_rsp_t;


/*! typedef  logout_RSP message body structure */
typedef struct
{
    int					result;
} jab_app_logout_rsp_t;


/*! typedef  CHG_STAT_RSP message body structure */
typedef struct
{
    int					result;
} jab_app_chg_stat_rsp_t;


/*! typedef  SEND_IM_RSP message body structure */
typedef struct
{
    int					result;
} jab_app_send_im_rsp_t;


/*! typedef  ADD_CONTACT_RSP message body structure */
typedef struct
{
    char                rem_jid[MAX_JID_LEN];
    int					result;
} jab_app_add_contact_rsp_t;


/*! typedef  SUBSCRIBE_CONTACT_RSP message body structure */
typedef struct
{
    char                rem_jid[MAX_JID_LEN];
    int					result;
} jab_app_sub_rsp_t;


/*! typedef  REMOVE_CONTACT_RSP message body structure */
typedef struct
{
    char                rem_jid[MAX_JID_LEN];
    int					result;
} jab_app_remove_contact_rsp_t;


/*! typedef  UNSUBSCRIBE_CONTACT_RSP message body structure */
typedef struct
{
    char                rem_jid[MAX_JID_LEN];
    int					result;
} jab_app_unsub_rsp_t;


/*! typedef  MOVE_CONTACT_RSP message body structure */
typedef struct
{
    char                rem_jid[MAX_JID_LEN];
    int					result;
} jab_app_move_contact_rsp_t;


/*! typedef  RENAME_CONTACT_RSP message body structure */
typedef struct
{
    char                rem_jid[MAX_JID_LEN];
    int					result;
} jab_app_rename_contact_rsp_t;


/*! typedef  BLOCK_CONTACT_RSP message body structure */
typedef struct
{
    char                rem_jid[MAX_JID_LEN];
    int					result;
} jab_app_block_contact_rsp_t;


/*! typedef  BLOCK_CONTACT_RSP message body structure */
typedef struct
{
    char                rem_jid[MAX_JID_LEN];
    int					result;
} jab_app_approve_sub_rsp_t;


/*! typedef  SET_DEFAULT_RULE_RSP message body structure */
typedef struct
{
    int					result;
} jab_app_set_def_rule_rsp_t;


/*! typedef  SET_INVISIBLE_RULE_RSP message body structure */
typedef struct
{
    int					result;
} jab_app_set_invisibe_rule_rsp_t;

/*! typedef  INC_SUBSCRIPTION_IND message body structure */
typedef struct
{
    char rem_jid[MAX_JID_LEN];
} jab_app_inc_sub_ind_t;


/*! typedef  INC_UNSUBSCRIPTION_IND message body structure */
typedef struct
{
    char rem_jid[MAX_JID_LEN];
} jab_app_inc_unsub_ind_t;


/*! \brief  enumeration for Jabber language  */
typedef enum
{
    ENGLISH,
    CHINESE
} jab_lan_type_e;


/*! typedef  INC_IM_IND message body structure */
typedef struct
{
    char                    rem_jid[MAX_JID_LEN];
    jab_lan_type_e	  lan_type;
    unsigned short     msg_body[MAX_IM_LEN];      /*must be unicode*/
} jab_app_inc_im_ind_t;
 

/*! typedef  INC_REM_PRES_IND message body structure */
typedef struct
{
    char                        rem_jid[MAX_JID_LEN];
    jab_pres_stat_t 			rem_pres;
} jab_app_inc_rem_pres_ind_t;


/*! typedef  OUT_SUB_RESULT_IND message body structure */
typedef struct
{
    char    rem_jid[MAX_JID_LEN];
    int     result;
} jab_app_out_sub_result_ind_t;


/*! typedef  roster item structure */
typedef struct
{
    jab_sub_status_e sub_state;
    char                    jid_s[MAX_JID_LEN];
    unsigned short     name_s[MAX_NICK_LEN];          /*must be unicode*/
    unsigned short     group_s[MAX_GROUP_LEN];       /*must be unicode*/
} jab_roster_item_t;


/*! typedef  ROSTER_UPDATE_IND message body structure */
typedef struct
{
    int num;
    jab_roster_item_t  roster[MAX_ROSTER_ITEM];
} jab_app_roster_update_ind_t;


/*! typedef  message bodies' union */
typedef union
{
    jab_app_login_rsp_t			    login_rsp;
    jab_app_logout_rsp_t			logout_rsp;
    jab_app_send_im_rsp_t           snd_im_rsp;
    jab_app_chg_stat_rsp_t          chg_stat_rsp;
    jab_app_add_contact_rsp_t		add_rsp;
    jab_app_sub_rsp_t			    sub_rsp;
    jab_app_remove_contact_rsp_t	remove_rsp;
    jab_app_unsub_rsp_t			    unsub_rsp;
    jab_app_move_contact_rsp_t		move_rsp;
    jab_app_rename_contact_rsp_t	rename_rsp;
    jab_app_block_contact_rsp_t		block_rsp;
    jab_app_approve_sub_rsp_t       approve_rsp;
    jab_app_set_def_rule_rsp_t		set_rule_rsp;
    jab_app_set_invisibe_rule_rsp_t	set_invisible_rsp;
    jab_app_inc_sub_ind_t		    sub_ind;
    jab_app_inc_unsub_ind_t		    unsub_ind;
    jab_app_inc_im_ind_t			im_ind;
    jab_app_inc_rem_pres_ind_t		rem_pres_ind;
    jab_app_out_sub_result_ind_t	sub_res_ind;
    jab_app_roster_update_ind_t		roster_ind;
}jab_app_msg_body_t;


/*! typedef  protocol --> application message structure */
typedef struct
{
    jab_app_msg_type_e		    msg_type;
    jab_app_msg_body_t		    msg_body;
} jab_app_msg_t;


typedef int (*jabber_callback)(jab_app_msg_t *);
extern int blade_ua_init(jabber_callback);

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -