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

📄 myitapi.step2

📁 BREW程序:在手机上通过TAPI拨打电话的程序
💻 STEP2
📖 第 1 页 / 共 3 页
字号:

                    CALLBACK_Init(&pMe->m_cb, SMSCallBack_Send, pMe);
                    ISMS_SendMsg(pMe->m_pISMS, pMe->m_pISMSMsg, &pMe->m_cb, &nReturn);

                    // Higher 16 bits specify error type specified as AEESMS_ERRORTYPE_XXX 
                    // lower  16 bits specify error specified as AEESMS_ERROR_XXX
                    DBGPRINTF("ISMS_SendMsg ret 0x%x", nReturn);
                }
                break;
#endif // MY_DEFINE_STEP_3_SMS_TX_RX

#ifdef MY_DEFINE_STEP_4_BREW_SMS
            case IDS_BREWSMS:
                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);
                return TRUE;
#endif

            default:
                break;
            }
        }


    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;

    if( ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MENUCTL, (void **)&pMe->m_pIMenu) !=SUCCESS)
    {
        return FALSE;
    }

    if( ISHELL_CreateInstance(pMe->pIShell, AEECLSID_STATIC, (void **)&pMe->m_pIStatic) !=SUCCESS)
    {
        return FALSE;
    }

 #ifdef MY_DEFINE_STEP_1_PHONE_INFO
    // Insert your code here for initializing or allocating resources...
    if( ISHELL_CreateInstance(pMe->pIShell, AEECLSID_TAPI, (void **)(&pMe->m_pITapi))!=SUCCESS )
    {
        return FALSE;
    }
#endif
   
#ifdef MY_DEFINE_STEP_3_SMS_TX_RX
    if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMS, (void **)&pMe->m_pISMS) !=SUCCESS)
    {
        return FALSE;
    }
#endif

#ifdef MY_DEFINE_STEP_4_BREW_SMS
    pMe->m_bBrewSMSStart = FALSE;
#endif

    DBGPRINTF("myitapi_InitAppData");

    // 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...
    DBGPRINTF("myitapi_FreeAppData");
    
    if( pMe->m_pIMenu )
    {
        IMENUCTL_Release(pMe->m_pIMenu);
        pMe->m_pIMenu = NULL;
    }

    if(pMe->m_pIStatic)
    {
        ISTATIC_Release(pMe->m_pIStatic);
        pMe->m_pIStatic = NULL;
    }

#ifdef MY_DEFINE_STEP_1_PHONE_INFO
    if( pMe->m_pITapi )
    {
        ITAPI_Release(pMe->m_pITapi);
        pMe->m_pITapi = NULL;
    }
#endif

#ifdef MY_DEFINE_STEP_3_SMS_TX_RX
    if(pMe->m_pISMS)
    {
        ISMS_Release(pMe->m_pISMS);
        pMe->m_pISMS = NULL;
    }
#endif    
}

static void  myitapi_ShowMenu(myitapi* pMe)
{   
#ifdef MY_DEFINE_STEP_1_PHONE_INFO
    CtlAddItem  ai;
#endif

    if (! pMe->m_pIMenu)
        ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MENUCTL, (void **)&pMe->m_pIMenu) ;
    
    IMENUCTL_Reset(pMe->m_pIMenu);

#ifdef MY_DEFINE_STEP_1_PHONE_INFO
    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 );
#endif

#ifdef MY_DEFINE_STEP_2_VOICE_CALL
    ai.wText = IDS_MAKECALL;
    ai.wItemID = IDS_MAKECALL;
    // Add the item to the menu control
    IMENUCTL_AddItemEx( pMe->m_pIMenu, &ai );
#endif

#ifdef MY_DEFINE_STEP_3_SMS_TX_RX
    ai.wText = IDS_SENDSMS;
    ai.wItemID = IDS_SENDSMS;
    // Add the item to the menu control
    IMENUCTL_AddItemEx( pMe->m_pIMenu, &ai );
#endif

#ifdef  MY_DEFINE_STEP_4_BREW_SMS
    ai.wText = IDS_BREWSMS;
    ai.wItemID = IDS_BREWSMS;
    // Add the item to the menu control
    IMENUCTL_AddItemEx( pMe->m_pIMenu, &ai );
#endif

    IMENUCTL_SetActive(pMe->m_pIMenu,TRUE);
}
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);
}

#ifdef MY_DEFINE_STEP_3_SMS_TX_RX
static void SMSCallBack_Send(void *p)
{
   myitapi *pMe = (myitapi *)p;
   DBGPRINTF("SMSCallBack_Send called");

   // 短信发送完毕后,释放ISMSMsg,否则它将保留在其中,对下一条短信产生影响
   if(pMe->m_pISMSMsg != NULL)
   {
       ISMSMSG_Release(pMe->m_pISMSMsg);
       pMe->m_pISMSMsg = NULL;
   }
}
#endif


static void WriteLine(myitapi * pMe, char *pszStr)
{

   int charHeight = 0;      // Stores the char height in pixels for given font
   int pnAscent = 0;        // Stores the ascent in number of pixels
   int pnDescent = 0;       // Stores the descent in number of pixels
   AECHAR * szBuf;     // a buffer that supports 200 char string

   // Make sure the pointers we'll be using are valid
   if (pMe==NULL || pMe->pIDisplay == NULL || pszStr == NULL)
       return;

   if ((szBuf = (AECHAR *) MALLOC(TEXT_BUFFER_SIZE)) == NULL)
     return;

   // Get the font metrics info
   charHeight = IDISPLAY_GetFontMetrics (pMe->pIDisplay, AEE_FONT_BOLD, &pnAscent, &pnDescent);

   // Convert to wide string (unicode)
   STR_TO_WSTR ((char *)pszStr, szBuf, TEXT_BUFFER_SIZE);

   IDISPLAY_DrawText(pMe->pIDisplay,    // Display instance
                       AEE_FONT_BOLD,       // Use BOLD font
                       szBuf,        // Text - Normally comes from resource
                       -1,                  // -1 = Use full string length
                       0,                   // Ignored - IDF_ALIGN_CENTER
                       charHeight*pMe->m_cLineNum,                   // Ignored - IDF_ALIGN_MIDDLE
                       NULL,                // No clipping
                       0);

  pMe->m_cLineNum ++;
  FREE(szBuf);
  return;

} // End of WriteLine 

static void WriteLineUnicode(myitapi * pMe, AECHAR *pszStr)
{

   int charHeight = 0;      // Stores the char height in pixels for given font
   int pnAscent = 0;        // Stores the ascent in number of pixels
   int pnDescent = 0;       // Stores the descent in number of pixels

   // Make sure the pointers we'll be using are valid
   if (pMe==NULL || pMe->pIDisplay == NULL || pszStr == NULL)
       return;

   // Get the font metrics info
   charHeight = IDISPLAY_GetFontMetrics (pMe->pIDisplay, AEE_FONT_BOLD, &pnAscent, &pnDescent);

   IDISPLAY_DrawText(pMe->pIDisplay,    // Display instance
                       AEE_FONT_BOLD,       // Use BOLD font
                       pszStr,        // Text - Normally comes from resource
                       -1,                  // -1 = Use full string length
                       0,                   // Ignored - IDF_ALIGN_CENTER
                       charHeight*pMe->m_cLineNum,                   // Ignored - IDF_ALIGN_MIDDLE
                       NULL,                // No clipping
                       0);

  pMe->m_cLineNum ++;
  return;

} // End of WriteLine 


⌨️ 快捷键说明

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