📄 pop3.h
字号:
/******************************************************************************
Copyright (C) 2005 UTStarcom (Hangzhou) Telecom Co., Ltd.
All rights reserved.
Contains confidential proprietary information of UTStarcom, Inc.
Reverse engineering is prohibited.
The copyright notice does not imply publication.
Project Name:
Project No. :
File Name : Pop3.h
Module : Email
Description :
************** REVISION HISTORY *******************************************
Date Author Reference
=========== ========== ==========================
2005-06-10 TangJun Initial version
******************************************************************************/
#ifndef _POP3_HEADER_
#define _POP3_HEADER_
#include "email.h"
#define POP3_TASK_PRIORITY 100
#define POP3_STACK_SIZE 4096
#define POP3_PORT 110
#define POP3LOG printf
/* Different states in POP3 FSM */
typedef enum
{
POP3_INIT = 0,
/* Defined for initial state */
POP3_CONNECTING,
/* Waiting for TCP connection response state */
POP3_AUTHORIZATION,
/* Send User-Name and Password to POP3 server for authorization */
POP3_TRANSACTION,
/* Receive email(s) from server, read or delete it */
POP3_UPDATE,
/* Wait for server release any resources acquired during the transaction state and disconnect with client */
POP3_MAX_STATUS
/* Max Status of Pop3, not used */
} Pop3StatusType;
/* Different commands to POP3 */
typedef enum
{
POP3_CONNECTION_CMD = 0x00,
/* Pseudo command indicates to open TCP connection */
POP3_USER_CMD,
/* Validate User Name command */
POP3_PASSWORD_CMD,
/* Validate Password command */
POP3_STAT_CMD,
/* Query the Number and total size of emails */
POP3_LIST_CMD,
/* List the size of one or all emails */
POP3_TOP_CMD,
/* Get the header and part content of email */
POP3_RETR_CMD,
/* Get the header and content all of a email */
POP3_QUIT_CMD,
/* Quit of operation */
POP3_DELETE_CMD,
/* Delete email from server, not used yet */
POP3_RSET_CMD,
/* Cancel deleting email from server, not used yet */
POP3_NOOP_CMD,
/* Insignificance command, only sent at transation state */
POP3_APOP_CMD,
/* Another Authorization command, not used yet */
POP3_UIDL_CMD,
/* Get the unique ID of the message */
POP3_MAX_CMD
/* Max command to Pop3 */
} Pop3Cmd;
/* Different commands from PM to POP3 */
typedef enum
{
POP3_RECEIVE_EMAIL = 0,
/* Command to receive email from Pop3 server */
POP3_CANCEL_RECEIVE,
/* Command to cancel the receiving of email */
POP3_MAX_PM_CMD
/* Max Pm command to Pop3 */
} Pop3PmCmdType;
/* Message structure PM ->POP3 */
typedef struct
{
Pop3PmCmdType Pop3Cmd;
U8 bbuf[4];
} MsgPop3;
/* the structure of Pop3 control */
typedef struct
{
Pop3StatusType status; /* the task status */
Pop3PmCmdType pmCmd; /* Pm command received */
Pop3Cmd lastCmd; /* last command sent to server */
Pop3Cmd nextCmd; /* next command sent to server */
int sock; /* the sock number */
int numberEmail; /* total number of emails on server */
int currentEmail; /* the sequence number of email current receiving */
int TotalSize; /* total size of all emails on server */
int currentSize; /* size of the current email on server */
char serverIndex; /* the index of domain */
char *pmMsgId; /* the msg id which PM indicates */
EMAIL_SAVE_RESULT (*cb)( EMAIL_POP3_ENTITY *pop_mail, EMAIL_ERROR_TYPE *err);
/* the callback function to inform error or save the email content */
} Pop3Type;
#ifdef __cplusplus
extern "C" {
#endif
/* the control variable of pop3 module */
Pop3Type pop3;
/* the structure of POP3 data(Protocol ==> MMI) */
EMAIL_POP3_ENTITY pop3_mail;
/* the structure of the status receiving the mail (Protocol ==> MMI) */
EMAIL_ERROR_TYPE pop3_err;
/******************************************************************************************* Function Name: Pop3TaskInit* Description : Initialize the pop3 task, include creating the message queue and the task.* Note : should be called when system initialization.* * Parameter : None.* Return values : None.* * Author : Tang Jun 2005-07-25* ******************************************************************************************/VOID Pop3TaskInit( VOID );
/******************************************************************************************* Function Name: Pop3ReceiveMail
* Description : Receive the email from pop3 server.* Note : Should be called when MMI or test module prapare to receive email from pop3 server.* * Parameter : pop_info -> the information of the email, include domain,username,password etc* pCallBackFunc -> the callback function called when email received or error occured* Return values : None.* * Author : Tang Jun 2005-07-25* ******************************************************************************************/VOID Pop3ReceiveMail(
EMAIL_POP3_INFO *pop_info, EMAIL_SAVE_RESULT (*pCallBackFunc) ( EMAIL_POP3_ENTITY *pop_mail, EMAIL_ERROR_TYPE *err));
/******************************************************************************************* Function Name: Pop3CancelMail
* Description : Cancel the receiving email from pop3 server.* Note : Could be called if MMI or test module want to cancel the receiving email.* * Parameter : None.* * Return values : None.* * Author : Tang Jun 2005-07-25* ******************************************************************************************/VOID Pop3CancelMail( VOID );
/******************************************************************************************* Function Name: Pop3CreateTask* Description : Create the pop3 task* Note : * * Parameter : taskId -> name of the task* taskProc -> the entry function of the task* MsgQueue -> the message queue of the task* priority -> the priority of the task* stackSize -> the stack size of the task* Return values : the task ID.* * Author : Tang Jun 2005-07-25* ******************************************************************************************/int Pop3CreateTask(char *taskId, FUNCPTR taskProc, int MsgQueue,int priority, int stackSize);
/******************************************************************************************* Function Name: tPop3Main* Description : the main function of the pop3 task.* Note : None.* * Parameter : None.* * Return values : None.* * Author : Tang Jun 2005-07-25* ******************************************************************************************/void tPop3Main (void);
/******************************************************************************************
* Function Name: Pop3PmResultReport
* Description : Report the result of the email receiving to MMI.
* Note : None.* * Parameter : None.
* * Return values : the result of the email saving on flash.
* * Author : Tang Jun 2005-07-25* ******************************************************************************************/EMAIL_SAVE_RESULT Pop3PmResultReport(void);
#ifdef __cplusplus
}
#endif
#endif //_POP3_HEADER_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -