📄 cms_wapmain.c
字号:
/******************************************************************************
C M O D U L E F I L E
(c) Copyright MobileSoft Technology (NanJing) Co., LTD. 2001-2002
ALL RIGHTS RESERVED
*******************************************************************************
Project Name: WAP STACK Ver1.20
Written By : MobileSoft Technology
File Name : mms_Malloc.c
Last Modify : 06/22/2002
******************************************************************************/
#include "stdio.h"
#include "Cms_WAPMain.h"
#include "Cms_WTP.h"
/* 全局WAP状态回调函数入口点 */
wapproc statproc=0;
/* WTP WSP全局状态机 */
extern WTPMachine * WTPGlobalMachine;
extern WSPMachine * WSPGlobalMachine;
/* ??? */
#ifdef CMS_WHOLE_WAP_DEBUG
InterfaceEvent *g_interevent = NULL;
static void ProcessEvent(InterfaceEvent *event);
#endif
extern WSPEvent * WSPCreateSConnectRequest(CMS_VOID);
extern WSPEvent *WSPCreateSMethodInvokeRequest(CMS_S32 method_type, P_CMS_U8 url, HTTPHeader *headers,
P_CMS_U8 content_type, P_CMS_U8 data, CMS_U32 dataLen);
extern CMS_VOID Cms_UDPInit(P_CMS_U8 host, CMS_U16 port);
extern CMS_VOID Cms_UDPDone(CMS_VOID);
//extern CMS_VOID Cms_UDPRecvData(P_CMS_U8*data, P_CMS_S32 len);
//extern CMS_VOID Cms_UDPSendData(P_CMS_U8 data, CMS_S32 len);
/* 打开WAP ,彩信*/
CMS_VOID Cms_WAPOpen(P_CMS_U8 host, CMS_S64 port, wapproc proc)
{
statproc=proc;
if (!host)
{
return;
}
Cms_UDPInit(host, (CMS_U16)port);
// 1 for mms
Cms_WAPInit(1);
if(WTPGlobalMachine)
{
memcpy(WTPGlobalMachine->udp_host,host,4);
WTPGlobalMachine->udp_port = port;
}
Cms_WAPConnect();
}
/* 打开WAP ,浏览器*/
CMS_VOID Cms_BRW_WAPOpen(P_CMS_U8 host, CMS_S64 port, wapproc proc)
{
WSPEvent * wsp_event = NULL;
int addr[4];
statproc = proc;
if (!host)
{
return;
}
/* set remote address */
sscanf_s((char*)host, "%d.%d.%d.%d", &addr[0], &addr[1], &addr[2], &addr[3]);
Cms_UDPInit(host, (CMS_U16)port);
/* 2 for wap browser */
Cms_WAPInit(2);
if(WTPGlobalMachine)
{
memcpy(WTPGlobalMachine->udp_host, host, 4);
WTPGlobalMachine->udp_port = port;
}
wsp_event = (WSPEvent *)WSPCreateSConnectRequest();
wsp_event->SConnectRequest.connect_type = 1; /* browser connect */
wsp_handle_event(WSPGlobalMachine, wsp_event);
}
CMS_VOID Cms_OTA_WAPOpen(P_CMS_U8 host, CMS_S64 port, P_CMS_U8 capability,CMS_S32 capability_len,
P_CMS_U8 head,CMS_S32 head_len,wapproc proc)
{
WSPEvent *wsp_event = NULL;
statproc = proc;
if (!host)
{
return;
}
Cms_WAPInit(2); // ota dowload use the browser open
if(WTPGlobalMachine)
{
memcpy(WTPGlobalMachine->udp_host, host, 4);
WTPGlobalMachine->udp_port = port;
}
wsp_event = (WSPEvent *)WSPCreateSConnectRequest();
wsp_event->SConnectRequest.connect_type = 1; //browser connect
wsp_event->SConnectRequest.capability = octstr_create_from_data(capability,capability_len);
wsp_event->SConnectRequest.head = octstr_create_from_data(head,head_len);
wsp_handle_event(WSPGlobalMachine, wsp_event);
}
CMS_VOID Cms_OTA_SetMaxRecvSize(int size)
{
if (WTPGlobalMachine)
{
WTPGlobalMachine->recv_msgsize = size;
}
return;
}
CMS_VOID Cms_WAPClose(CMS_VOID)
{
Cms_UDPDone();
Cms_WAPDone();
return;
}
CMS_VOID Cms_WAPGetURL(P_CMS_U8 url)
{
if (!url)
{
return;
}
Cms_WAPGet(url);
return;
}
CMS_VOID Cms_WAPDisconnect(CMS_VOID)
{
WSPEvent * wsp_event = NULL;
wsp_event = wsp_event_create(Disconnect);
wsp_handle_event(WSPGlobalMachine, wsp_event);
return;
}
CMS_VOID Cms_WAPPostURL(P_CMS_U8 url, P_CMS_U8 param, CMS_U32 paramLen, FILE_HANDLE file)
{
//P_CMS_U8 debug_url=(P_CMS_U8)"Http://mmsc.monternet.com/";
if (!url)
{
return;
}
Cms_WAPPost(url, param, paramLen);
return;
}
CMS_VOID Cms_BRW_WAPPostURL(P_CMS_U8 url, P_CMS_U8 param, CMS_U32 paramLen, FILE_HANDLE file)
{
WSPEvent * wsp_event = NULL;
unsigned char con[] = {0x92};
if (!url)
{
return;
}
wsp_event = (WSPEvent *)WSPCreateSMethodInvokeRequest(0x60, url, NULL, (P_CMS_U8)con,
param, paramLen);
wsp_handle_event(WSPGlobalMachine, wsp_event);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -