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

📄 myitapi.step2

📁 BREW程序:在手机上通过TAPI拨打电话的程序
💻 STEP2
📖 第 1 页 / 共 3 页
字号:
                        if ((pNotify->dwMask & MyNMask) == MyNMask) 
                        {
                            uMsgId = (uint32 )pNotify->pData;
                            if(ISMS_ReceiveMsg(pMe->m_pISMS, uMsgId, &pRxMsg)==AEE_SUCCESS)
                            {
                                SMSMsgOpt TmpOpt;
                                DBGPRINTF("ISMS_ReceiveMsg ret ok");
								
                                // for print to screen
                                if(pMe->m_pIMenu)
                                {
                                    IMENUCTL_Release(pMe->m_pIMenu);
                                    pMe->m_pIMenu = NULL;
                                }
                                pMe->m_cLineNum = 0;
                                IDISPLAY_ClearScreen(pMe->pIDisplay);

                                // MSGOPT_FROM_DEVICE_SZ - 发送方号码
                                if(ISMSMSG_GetOpt(pRxMsg, MSGOPT_FROM_DEVICE_SZ, &TmpOpt)==AEE_SUCCESS)
                                {
                                    DBGPRINTF("get MSGOPT_FROM_DEVICE_SZ");
                                    WriteLine(pMe,  (char *)"From:");
                                    WriteLine(pMe,  (char *)TmpOpt.pVal);
                                }

                                // MSGOPT_PAYLOAD_SZ - ASCII的短信内容
                                if(ISMSMSG_GetOpt(pRxMsg, MSGOPT_PAYLOAD_SZ, &TmpOpt)==AEE_SUCCESS)
                                {
                                    DBGPRINTF("get MSGOPT_PAYLOAD_SZ");
                                    WriteLine(pMe,  (char *)"SMS (ASCII):");
                                    WriteLine(pMe,  (char *)TmpOpt.pVal);
                                }

                                // MSGOPT_PAYLOAD_WSZ - UNICODE的短信内容
                                if(ISMSMSG_GetOpt(pRxMsg, MSGOPT_PAYLOAD_WSZ, &TmpOpt)==AEE_SUCCESS)
                                {
                                    DBGPRINTF("get MSGOPT_PAYLOAD_WSZ");
                                    WriteLine(pMe,  (char *)"SMS (UNICODE):");
                                    WriteLineUnicode(pMe,  (AECHAR *)TmpOpt.pVal);
                                }

                                // MSGOPT_TIMESTAMP - 短信时间标签
                                if(ISMSMSG_GetOpt(pRxMsg, MSGOPT_TIMESTAMP, &TmpOpt)==AEE_SUCCESS)
                                {
                                    JulianType *pMyJulian;
                                    char buf[80];
                                    DBGPRINTF("get MSGOPT_TIMESTAMP");

                                    pMyJulian = (JulianType *)TmpOpt.pVal;
                                    SPRINTF(buf, "%d/%d/%d %d:%d:%d, weekday:%d", pMyJulian->wMonth, pMyJulian->wDay, pMyJulian->wYear, 
                                                                                              pMyJulian->wHour, pMyJulian->wMinute, pMyJulian->wSecond, pMyJulian->wWeekDay);
                                    WriteLine(pMe,  (char *)"Time Stamp::");
                                    WriteLine(pMe,  buf);
                                }

                                // 释放ISMSMsg 资源
                                ISMSMSG_Release(pRxMsg);
                                
                                IDISPLAY_Update(pMe->pIDisplay);
                                
                            }

                        }
                    }
                }
            return TRUE;
#endif

#ifdef MY_DEFINE_STEP_4_BREW_SMS
        // An SMS message has arrived for this app. Message is in the dwParam above as (char *)
        // sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
        case EVT_APP_MESSAGE:
            // Add your code here...
            DBGPRINTF("EVT_APP_MESSAGE before ISHELL_StartApplet");
            STRCPY(pMe->charbuffer, (char*)dwParam);
            pMe->m_bBrewSMSStart =TRUE;
            ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_MYITAPI);
            DBGPRINTF("EVT_APP_MESSAGE after ISHELL_StartApplet");
            return(TRUE);
#endif

        // A key was pressed. Look at the wParam above to see which key was pressed. The key
        // codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
        case EVT_KEY:
            // Add your code here...            
            if( pMe->m_pIMenu )
            {
                if( IMENUCTL_HandleEvent(pMe->m_pIMenu, EVT_KEY, wParam, dwParam) )
                    return TRUE;
                else      return FALSE; 
            }
            else if(wParam ==AVK_CLR)
            {
                if(pMe->m_pIStatic)
                {
                    ISTATIC_Release(pMe->m_pIStatic);
                    pMe->m_pIStatic = NULL;
                }
                myitapi_ShowMenu(pMe);
            }
            return TRUE;
        
    case EVT_COMMAND:
        if( pMe->m_pIMenu )
        {
            switch(IMENUCTL_GetSel(pMe->m_pIMenu))
            {

#ifdef MY_DEFINE_STEP_1_PHONE_INFO
            TAPIStatus tpst;
            AECHAR szText[141];

            case IDS_MSUSER:
                if (ITAPI_GetStatus(pMe->m_pITapi, &tpst) != SUCCESS)
                {
                    ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_UNKNOWN, szText, sizeof(szText));
                }
                else
                {
                    AECHAR szData[16];
                    AECHAR szDigital[16];
                    AECHAR szRoaming[16];
                    AECHAR szCallended[16];
                    AECHAR sz911[16];
                    AECHAR szRegistered[16];
                    AECHAR szDormancy[16];
                
                    tpst.bData ? 
                        ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_USER_DATA_1, szData, sizeof(szData)):
                        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);
                return TRUE;
                
            case IDS_MSPHONE    :
                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);
                return TRUE;
                break;
#endif // MY_DEFINE_STEP_1_PHONE_INFO

#ifdef MY_DEFINE_STEP_2_VOICE_CALL
            case IDS_MAKECALL   :
                ITAPI_MakeVoiceCall(pMe->m_pITapi, "13301330133", AEECLSID_MYITAPI);
                return TRUE;
                break;
#endif

#ifdef MY_DEFINE_STEP_3_SMS_TX_RX
            case IDS_SENDSMS:
                /**************************************************************/
                /*                           receive SMS register                                                */
                /**************************************************************/
                {
                    // 使用新的AEECLSID_SMSNOTIFIER 的notify机制接收短信
                    AEECLSID clsNotifier= AEECLSID_SMSNOTIFIER; // Event sender
                    AEECLSID clsNotify = AEECLSID_MYITAPI; // Event listener
                    // Set the notify event to be NOTIFY_MASK_EVENT. This event is used
                    // as an example.
                    uint32 dwMask = ((AEESMS_TYPE_TEXT << 16) | NMASK_SMS_TYPE); 
                    int nErr;

                    // Register a notification 
                    nErr = ISHELL_RegisterNotify (pMe->a.m_pIShell, clsNotify, clsNotifier, dwMask);
                    DBGPRINTF("ISHELL_RegisterNotify ret %d", nErr);
                }

                
                /**************************************************************/
                /*                           sending SMS                                                           */
                /**************************************************************/
                {
                    int nErr;
                    WebOpt awo[7]; /* ***IMPORTANT**** grow this if you add more 
                                     WebOpts here, or shrink it and call AddOpt() multiple times */
                    int    i = 0;
                    uint32 nReturn=0;                                 
                    AECHAR pszBuf[100];

                    nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMSMSG, (void **)&pMe->m_pISMSMsg);
                    DBGPRINTF("CreateInstance of AEECLSID_SMSMSG ret %d", nErr);
                    if(nErr != AEE_SUCCESS)
                    {
                        break;
                    }

                    /* NULL terminated string providing destination device number. 
                        '+' as first character signifies international number.  */
                    awo[i].nId  = MSGOPT_TO_DEVICE_SZ ;
                    awo[i].pVal = (void *)DESTINATION_NUMBER;
                    i++;

                    /* unicode text to be send */
                    awo[i].nId  = MSGOPT_PAYLOAD_WSZ ;
                    ISHELL_LoadResString(pMe->a.m_pIShell, MYITAPI_RES_FILE, IDS_MO_TEXT_UNICODE, pszBuf, sizeof(pszBuf));
                    awo[i].pVal = (void *)pszBuf;
                    i++;

                    /* encoding */
                    awo[i].nId  = MSGOPT_PAYLOAD_ENCODING;
                    awo[i].pVal = (void *)AEE_ENC_UNICODE ;
                    i++;

                    awo[i].nId  = MSGOPT_MOSMS_ENCODING;
                    awo[i].pVal = (void *)AEESMS_ENC_UNICODE;
                    i++;

                    /* this is absolutely necessary, do not remove, marks the end of the 
                       array of WebOpts */
                    awo[i].nId  = MSGOPT_END;
                  
                    /* add 'em */
                    nErr =ISMSMSG_AddOpt(pMe->m_pISMSMsg, awo);
                    DBGPRINTF("ISMSMSG_AddOpt ret %d", nErr);

⌨️ 快捷键说明

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