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

📄 smstext.cpp

📁 联通手机的宝典画面.用brew 平台编辑而成.
💻 CPP
字号:
// SmsText.cpp: implementation of the CSmsText class.
//
//////////////////////////////////////////////////////////////////////

#include "SmsText.h"
#include "wk_BaseFunc.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSmsText::CSmsText()
{

}

CSmsText::~CSmsText()
{

}

void CSmsText::Init(AECHAR * szName, long nID, XFRAMEINFO * pInfo)
{
	m_nID	= nID;
	if (szName)
	{
		long nLen = sizeof(AECHAR) * (WSTRLEN(szName) + 1);
		m_szName = (AECHAR *)MALLOC(nLen);
		if (m_szName)
			MEMCPY(m_szName, szName, nLen);
	}
	else
		m_szName = NULL;

	m_pApplet		= pInfo->pApplet;
	m_pDevice		= pInfo->pDevice;
	m_pNetWork		= (CNetWork *)pInfo->pNetWork;
    m_szMobile		= pInfo->szMobile;
    m_szMobileType	= pInfo->szMobileType;

	m_rcScreen.x	= 0;
	m_rcScreen.y	= 0; 
    m_rcScreen.dx	= m_pDevice->cxScreen;
    m_rcScreen.dy	= m_pDevice->cyScreen; 

	m_szReceiveData = NULL;
	m_szPostData	= NULL;
	m_nBufferLength	= 0;
	
    m_pIStatic		= NULL;
	m_pObject		= NULL;

	m_nType	= TYPE_SMSTEXT;

	m_bRelease	= TRUE;
}

void CSmsText::Release()
{
	ClearScreen();

    if (m_szName) FREEIF(m_szName);
    if (m_szReceiveData) FREEIF(m_szReceiveData);
    if (m_szPostData) FREEIF(m_szPostData);

	if (m_pObject)
	{
		m_pObject->Release();
		delete m_pObject;
		m_pObject = NULL;
	}

	m_bRelease	= TRUE;
}

void CSmsText::Suspend()
{
	if (m_pObject)
	{
		m_pObject->Suspend();
	}
	else
	{
		if(m_pIStatic)
			ISTATIC_SetActive(m_pIStatic,FALSE);
	//	ClearScreen();
	}
}

void CSmsText::Resume()
{
	if (m_pObject)
	{
		m_pObject->Resume();
	}
	else
	{
		if(m_pIStatic)
		{
			ISTATIC_SetActive(m_pIStatic,TRUE);
			ISTATIC_Redraw(m_pIStatic);

		}
	//	ClearScreen();
	//	Display();
	}
}

void CSmsText::Create()
{
	// 传送项目列表信息
	long	  nLength, nBufferLength;
	long	  nIndex;
	long	  nValue;
	long	  nTotal, nChunk1, nChunk2;
    char	  szPrefix[] = {'W', 'X', 'F', 'Z', '\0'};

	m_bRelease	= FALSE;
	// APPID + VERSION + SZMOBILE + SZMOBILETYPE + REQUESTTYPE

	// 计算发送请求的总长度
	nBufferLength = 0;
	nLength = STRLEN(szPrefix);	// prifix
	nBufferLength += sizeof(char) * (nLength);
	nBufferLength += 4;	// APPID
	nBufferLength += 4;	// VERSION
	nBufferLength += 4;	// TotalSize
	nBufferLength += 4;	// Number of Chunks

	nBufferLength += 4;	// REQUESTTYPE
	nBufferLength += 4;	// Size
	nChunk1 = nBufferLength;
	nLength = WSTRLEN(m_szMobile) + 1;	// SZMOBILE
	nBufferLength += sizeof(AECHAR) * (nLength);
	nLength = WSTRLEN(m_szMobileType) + 1;	// SZMOBILETYPE
	nBufferLength += sizeof(AECHAR) * (nLength);
	nBufferLength += 4;
	nChunk1 = nBufferLength - nChunk1;

	nBufferLength += 4;	// REQUESTTYPE
	nBufferLength += 4;	// Size
	nChunk2 = nBufferLength;
	nBufferLength += 4;	// CategoryID
	nChunk2 = nBufferLength - nChunk2;

	nTotal = nBufferLength;

	if (m_szPostData)
		FREEIF(m_szPostData);
	m_szPostData = (char *) MALLOC(nBufferLength);
	if (m_szPostData == NULL) 
	{
		ClearScreen();
//		ShowResString(m_pApplet->m_pIShell, &m_pIStatic, &m_rcScreen, m_szName, IDS_CONTENT_NONE);
		return;
	}

	nIndex = 0;
	// Prefix
	nLength =  sizeof(char) * (STRLEN(szPrefix));
	MEMCPY(m_szPostData + nIndex, szPrefix, nLength);
	// APPID
	nIndex += nLength;
	nLength = 4;
	nValue = APPID;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);
	// VERSION
	nIndex += nLength;
	nLength = 4;
	nValue = VERSION;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);
	// Total size
	nIndex += nLength;
	nLength = sizeof(long);
	nLength = 4;
	nValue = nTotal;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);
	// number of chunks
	nIndex += nLength;
	nLength = 4;
	nValue = 2;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);

	// Chunk type
	nIndex += nLength;
	nLength = 4;
	nValue = REQUEST_ACCOUNT;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);
	// Chunk size
	nIndex += nLength;
	nLength = 4;
	nValue = nChunk1;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);
	// MOBILE
	nIndex += nLength;
	nLength =  sizeof(AECHAR) * (WSTRLEN(m_szMobile) + 1);
	MEMCPY(m_szPostData + nIndex, m_szMobile, nLength);
	// MOBILETYPE
	nIndex += nLength;
	nLength =  sizeof(AECHAR) * (WSTRLEN(m_szMobileType) + 1);
	MEMCPY(m_szPostData + nIndex, m_szMobileType, nLength);
	//login
	nIndex += nLength;
	nLength =  4;
	if(m_pNetWork->m_bFirst)
		nValue=1;
	else 
		nValue=0;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);

	// Chunk type
	nIndex += nLength;
	nLength = 4;
	nValue = REQUEST_CONTENT;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);
	// Chunk size
	nIndex += nLength;
	nLength = 4;
	nValue = nChunk2;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);
	// contentid
	nIndex += nLength;
	nLength = 4;
	nValue = m_nID;
	MEMCPY(m_szPostData + nIndex, &nValue, nLength);

	// 发送请求信息
	m_pNetWork->PostData(m_szPostData, nBufferLength, (CObject *)this);
}

boolean	CSmsText::KeyHandle(AEEEvent evt, uint16 wParam, uint32 dwParam)
{
    boolean status = FALSE;

	switch(evt)
	{
		//Key handler
		case EVT_KEY:
		//case EVT_KEY_PRESS:	
			if (wParam == AVK_CLR)
			{
				Release();
				status = TRUE;
			}
			else if (m_pIStatic)
			{
				if (ISTATIC_HandleEvent(m_pIStatic, evt, wParam, dwParam))
					status = TRUE;
			}
			break;
		case EVT_COMMAND:
			break;
	}

	return status;
}

void CSmsText::Construct(char * szBuffer, long nBufferLength)
{
	long	nIndex;
	long	cstLong;
	long	nPostType, nValue;

    IDISPLAY_ClearScreen(m_pApplet->m_pIDisplay);

	if ((nBufferLength <= 0) || (szBuffer == NULL))
		return;


	// read head info
	nIndex	= 0;
	cstLong = 4;

	// prifix
	nIndex = 4;

	// total size
	MEMCPY(&nValue, szBuffer + nIndex, 4);
	nIndex += 4;

	// post type
	MEMCPY(&nPostType, szBuffer + nIndex, 4);
	nIndex += 4;

	// number of Chunks
	MEMCPY(&nValue, szBuffer + nIndex, 4);
	nIndex += 4;

	// chunkID
	MEMCPY(&nValue, szBuffer + nIndex, 4);
	nIndex += 4;

	// chunkSize
	MEMCPY(&nValue, szBuffer + nIndex, 4);
	nIndex += 4;

	// read text from buffer and add menu item
	if (nPostType == REQUEST_CONTENT)
	{// 短信文本
		// read nContentID
		MEMCPY(&nValue, szBuffer + nIndex, cstLong);
		nIndex += cstLong;

		// read nSize
		MEMCPY(&nValue, szBuffer + nIndex, cstLong);
		nIndex += cstLong;
		if (nValue > nBufferLength - nIndex)
			nValue = nBufferLength - nIndex;

		// 显示短信文本
		if (m_szReceiveData)	FREEIF(m_szReceiveData);

		m_nBufferLength = nValue + sizeof(AECHAR);
		m_szReceiveData = (char *) MALLOC(m_nBufferLength);
		if (m_szReceiveData == NULL)
		{
			ClearScreen();
			ShowResString(m_pApplet->m_pIShell, &m_pIStatic, &m_rcScreen, m_szName, IDS_CONTENT_NONE);
			return;
		}

		MEMCPY(m_szReceiveData, szBuffer + nIndex, nValue);
		MEMSET(m_szReceiveData + nValue, 0, sizeof(AECHAR));

		Display();
	}

    return;
}

void CSmsText::Display()
{
	AEERect rect;
//	if(m_szReceiveData) return;
	if (m_pIStatic)
		ReleaseObj((void * *)&m_pIStatic);

    ISHELL_CreateInstance(m_pApplet->m_pIShell, AEECLSID_STATIC, (void * *)&m_pIStatic);
	// 设置文本信息
    if (m_pIStatic) 
	{
		rect.x	= 0;
		rect.y	= 0; 
		rect.dx	= m_pDevice->cxScreen;
		rect.dy	= m_pDevice->cyScreen; 
		ISTATIC_SetRect(m_pIStatic, &rect);
        ISTATIC_SetProperties(m_pIStatic, ST_NOSCROLL ); //ST_ASCII |

		PrintString2(m_pIStatic, m_szName, (AECHAR *)m_szReceiveData, FALSE);
   }
}

void CSmsText::ClearScreen()
{
	if(m_pIStatic)
		ReleaseObj((void * *)&m_pIStatic);
	m_pIStatic=NULL;
}

⌨️ 快捷键说明

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