📄 myitapi.final
字号:
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_DATA_0, szData, sizeof(szData));
tpst.bDigital ?
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_DIGITAL_1, szDigital, sizeof(szDigital)):
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_DIGITAL_0, szDigital, sizeof(szDigital));
tpst.bRoaming ?
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_ROAM_1, szRoaming, sizeof(szRoaming)):
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_ROAM_0, szRoaming, sizeof(szRoaming));
tpst.bCallEnded ?
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_CALLEND_1, szCallended, sizeof(szCallended)):
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_CALLEND_0, szCallended, sizeof(szCallended));
tpst.bE911CallbackMode ?
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_911_1, sz911, sizeof(sz911)):
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_911_0, sz911, sizeof(sz911));
tpst.bRegistered ?
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_REG_1, szRegistered, sizeof(szRegistered)):
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_REG_0, szRegistered, sizeof(szRegistered));
tpst.bDormancy ?
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_DOR_1, szDormancy, sizeof(szDormancy)):
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_DOR_0, szDormancy, sizeof(szDormancy));
WSTRCPY(szText,szData);
WSTRCAT(szText,szDigital);
WSTRCAT(szText,szRoaming);
WSTRCAT(szText,szCallended);
WSTRCAT(szText,sz911);
WSTRCAT(szText,szRegistered);
WSTRCAT(szText,szDormancy);
}
IMENUCTL_Release(pMe->m_pIMenu);
pMe->m_pIMenu = NULL;
IDISPLAY_ClearScreen(pMe->pIDisplay);
myitapi_DisplayInfo(pMe,szText);
// end of lab 1
return TRUE;
case IDS_MSPHONE :
// lab 2
if (ITAPI_GetStatus(pMe->m_pITapi, &tpst) != SUCCESS)
{
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_UNKNOWN, szText, sizeof(szText));
}else{
switch (tpst.state)
{
case PS_OFFLINE:
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_PH_OFFLINE, szText, sizeof(szText));
break;
case PS_IDLE:
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_PH_IDLE, szText, sizeof(szText));
break;
case PS_INCOMING:
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_PH_INCOMING, szText, sizeof(szText));
break;
case PS_ORIG:
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_PH_ORIG, szText, sizeof(szText));
break;
case PS_CONVERSATION:
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_PH_CALL, szText, sizeof(szText));
break;
}
}
IMENUCTL_Release(pMe->m_pIMenu);
pMe->m_pIMenu = NULL;
IDISPLAY_ClearScreen(pMe->pIDisplay);
myitapi_DisplayInfo(pMe,szText);
// end of lab 2
return TRUE;
break;
case IDS_SENDSMS:
// lab 3
{
char sPhoneNum[16];
int16 iRet = 0;
IMENUCTL_Release(pMe->m_pIMenu);
pMe->m_pIMenu = NULL;
SPRINTF(sPhoneNum,"%s","13301330133");
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_SEND_CH, szText, sizeof(szText));
iRet = ITAPI_SendSMS(pMe->m_pITapi, (const char *)sPhoneNum, (const char *)szText,
0, (PFNSMSSTATUS)MySmsNotify, pMe);
if(iRet == SUCCESS)
{
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_SMS_SEND_YES, szText, sizeof(szText));
}else{
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_SMS_SEND_NO, szText, sizeof(szText));
}
IDISPLAY_ClearScreen(pMe->pIDisplay);
myitapi_DisplayInfo(pMe,szText);
return TRUE;
}
// end of lab 3
break;
case IDS_BREWSMS:
// lab 4
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_BREWSMS_TEXT, szText, sizeof(szText));
if(pMe->m_pIMenu)
{
IMENUCTL_Release(pMe->m_pIMenu);
pMe->m_pIMenu = NULL;
}
IDISPLAY_ClearScreen(pMe->pIDisplay);
myitapi_DisplayInfo(pMe,szText);
// end of lab 4
return TRUE;
case IDS_MAKECALL :
// lab 5
ITAPI_MakeVoiceCall(pMe->m_pITapi, "13301330133", AEECLSID_MYITAPI);
// end of lab 5
return TRUE;
break;
default:
break;
}
}
case EVT_USER:
// lab
if(wParam == SUCCESS)
{
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_SEND_OK, szText, 20);
}
else
{
ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_SEND_FAIL, szText, 20);
}
if(pMe->m_pIMenu)
{
IMENUCTL_Release(pMe->m_pIMenu);
pMe->m_pIMenu = NULL;
}
IDISPLAY_ClearScreen(pMe->pIDisplay);
myitapi_DisplayInfo(pMe,szText);
return TRUE;
// end of lab 3
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;
}
// this function is called when your application is starting up
boolean myitapi_InitAppData(myitapi* pMe)
{
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// The display and shell interfaces are always created by
// default, so we'll asign them so that you can access
// them via the standard "pMe->" without the "a."
pMe->pIDisplay = pMe->a.m_pIDisplay;
pMe->pIShell = pMe->a.m_pIShell;
// Insert your code here for initializing or allocating resources...
if( ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MENUCTL, (void **)&pMe->m_pIMenu) !=SUCCESS)
{
IMENUCTL_Release( pMe->m_pIMenu );
return EFAILED;
}
// lab 1
if( ISHELL_CreateInstance(pMe->pIShell, AEECLSID_TAPI, (void **)(&pMe->m_pITapi))!=SUCCESS )
return EFAILED;
if( ISHELL_CreateInstance(pMe->pIShell, AEECLSID_STATIC, (void **)&pMe->m_pIStatic) !=SUCCESS)
{
ISTATIC_Release( pMe->m_pIStatic );
return EFAILED;
}
// end of lab 1
// lab 4
pMe->m_bBrewSMSStart = FALSE;
// end of lab 4
// if there have been no failures up to this point then return success
return TRUE;
}
// this function is called when your application is exiting
void myitapi_FreeAppData(myitapi* pMe)
{
// insert your code here for freeing any resources you have allocated...
if( pMe->m_pIMenu )
{
IMENUCTL_Release(pMe->m_pIMenu);
pMe->m_pIMenu = NULL;
}
//lab 1
if( pMe->m_pITapi )
{
ITAPI_Release(pMe->m_pITapi);
pMe->m_pITapi = NULL;
}
if(pMe->m_pIStatic)
{
ISTATIC_Release(pMe->m_pIStatic);
pMe->m_pIStatic = NULL;
}
// end of lab1
}
static void myitapi_ShowMenu(myitapi* pMe)
{
CtlAddItem ai;
if (! pMe->m_pIMenu)
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MENUCTL, (void **)&pMe->m_pIMenu) ;
ai.pText = NULL;
ai.pImage = NULL;
ai.pszResImage = MYITAPI_RES_FILE;
ai.pszResText = MYITAPI_RES_FILE;
ai.wFont = AEE_FONT_NORMAL;
ai.dwData = NULL;
ai.wText = IDS_MSUSER;
ai.wImage = IDB_MENU;
ai.wItemID = IDS_MSUSER;
// Add the item to the menu control
if(IMENUCTL_AddItemEx(pMe->m_pIMenu, &ai )==FALSE)
{
IMENUCTL_Release(pMe->m_pIMenu);
return;
}
ai.wText = IDS_MSPHONE;
ai.wItemID = IDS_MSPHONE;
// Add the item to the menu control
IMENUCTL_AddItemEx( pMe->m_pIMenu, &ai );
ai.wText = IDS_SENDSMS;
ai.wItemID = IDS_SENDSMS;
// Add the item to the menu control
IMENUCTL_AddItemEx( pMe->m_pIMenu, &ai );
ai.wText = IDS_BREWSMS;
ai.wItemID = IDS_BREWSMS;
// Add the item to the menu control
IMENUCTL_AddItemEx( pMe->m_pIMenu, &ai );
ai.wText = IDS_MAKECALL;
ai.wItemID = IDS_MAKECALL;
// Add the item to the menu control
IMENUCTL_AddItemEx( pMe->m_pIMenu, &ai );
IMENUCTL_SetActive(pMe->m_pIMenu,TRUE);
}
// lab 1
static void myitapi_DisplayInfo(myitapi* pMe,AECHAR* pInfo)
{
AEERect rct;
if(!pMe->m_pIStatic)
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_STATIC, (void **)&pMe->m_pIStatic);
SETAEERECT(&rct, 16, 16, pMe->DeviceInfo.cxScreen-32, pMe->DeviceInfo.cyScreen-32);
ISTATIC_SetRect(pMe->m_pIStatic, &rct);
ISTATIC_SetText(pMe->m_pIStatic, NULL,pInfo, AEE_FONT_BOLD, AEE_FONT_NORMAL);
ISTATIC_Redraw(pMe->m_pIStatic);
}
// end of lab 1
// lab 3
static void MySmsNotify(myitapi * pMe, int16 status)
{
ISHELL_PostEvent (pMe->a.m_pIShell, AEECLSID_MYITAPI,
EVT_USER, status, 0);
DBGPRINTF("Message send notify(%d)!",status);
}
// end of lab 3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -