// ================================================================================
// FUNCTION		: CopyAddrBookToBackupDb
// DESCRIPTION	: Copy all contacts in addrressbook to backup database.
// ================================================================================
bool CDbHandler::CopyAddrBookToBackupDb()
{
	IDatabase *pBkpDatabase;
	IAddrBook * pIAddrBook=NULL;
	IAddrRec* rec=NULL;
	CContactInfo *pContact;

	//delete previous backup database.
	//this should change to: create a tempory backup database. after successfully creating this.
	//rename current bakup to old backup and temp backup to backup and delete old backup
	if ( !DeleteDatabase( SM_BACKUPDB )) return false;

	pContact = new CContactInfo();
	if ( NULL==pContact ) return false;

	if ( !OpenBackupDb(&pBkpDatabase))
	{
		delete pContact;
		return false;
	}

	//enumerate addressbook
	if ( SUCCESS != ISHELL_CreateInstance(m_pIShell, AEECLSID_ADDRBOOK, (void **)&pIAddrBook))
	{
		delete pContact;
		IDATABASE_Release(pBkpDatabase);
		return false;
	}

	if( AEE_SUCCESS == IADDRBOOK_EnumRecInit(pIAddrBook,AEE_ADDR_CAT_NONE, AEE_ADDRFIELD_NONE,NULL,0) )
	{
		while( NULL != (rec=IADDRBOOK_EnumNextRec(pIAddrBook)) )
		{

			pContact->SetContactInfo(rec);
			//Add contact to backup database
			AddToBackupDb( pBkpDatabase, pContact);

			IADDRREC_Release(rec);
		
		}
	}

	delete pContact;
	//release address book
	IADDRBOOK_Release(pIAddrBook);
	IDATABASE_Release(pBkpDatabase);

	return true;
}
예제 #2
0
/*=============================================================================
FUNCTION c_SampleCameraApp_Start

DESCRIPTION
  This is function is creates an ICamera object, sets up some parameters and 
    initializes the application into a known state.

PROTOTYPE:
  static void c_SampleCameraApp_Start(c_samplecamera* pMe )

PARAMETERS:
   pMe: Pointer to the applet data stucture
  
   e: adf.

DEPENDENCIES
   none

RETURN VALUE
   TRUE: If 
   FALSE: If 

SIDE EFFECTS
   none
=============================================================================*/
static void c_SampleCameraApp_Start(c_samplecamera* pMe )
{
   int nErr = AEE_EFAILED;

   // Create each of the controls used by the application.
   nErr = ISHELL_CreateInstance(pMe->Applet.m_pIShell, AEECLSID_CAMERA,
                                (void**)( &pMe->pICamera));
   if (nErr != AEE_SUCCESS)
   {
      DBGPRINTF("Creating ICamera Failed %d", nErr);
      if (nErr == AEE_EPRIVLEVEL)
      {
         DBGPRINTF("Check if MIF has permissions to create AEECLSID_CAMERA");
      }
      
	  if (nErr == AEE_EFAILED)
      {
		  // If a camera is not attached, on the simulator, close the app,
		  // attach a camera to the computer, and then on the simuator, use the app manager to 
		  // run the app. You don't have to stop and restart the debugging session.
         DBGPRINTF("Attach a camera to the PC and restart the sample application.");
      }
      return;
   }

   nErr = ICAMERA_GetParm(pMe->pICamera, CAM_PARM_IS_SUPPORT, 
                          (int32 *)CAM_PARM_ZOOM, (int32 *)&pMe->bSupportZoom);
   if (pMe->bSupportZoom != TRUE)
   {
      DBGPRINTF("Zoom is not supported on this build");
   }

   //Register for Notify Callback
   ICAMERA_RegisterNotify(pMe->pICamera, 
                          (PFNCAMERANOTIFY) c_SampleCameraApp_CameraCBFunc, 
                          (void *)pMe);

   //Set the size of the image to be recorded by the camera.
   nErr = ICAMERA_SetSize(pMe->pICamera, &pMe->ImageSize);

   //Set the size of the image to be displayed to the screen.
   nErr = ICAMERA_SetDisplaySize(pMe->pICamera, &pMe->ImageSize);

   //Initialize the application into the preview snapshot mode
   c_SampleCameraApp_SetMediaDataParameters(pMe, CAM_PREVIEW_SNAPSHOT);

   //Call helper function to print messages to the screen.
   c_SampleCameraApp_PrintStatus(pMe);
} // end of static void c_SampleCameraApp_Start(SampleCameraApp* pMe )
예제 #3
0
int IMainUI_New(IGlobalVariable* glbVar, AEECLSID clsID, void ** iMainUI){
	IMainUI * mainUI = (IMainUI *)MALLOC(sizeof(IMainUI));
	mainUI->pvt = (VTBL(IMainUI) * )MALLOC(sizeof(VTBL(IMainUI)));
	mainUI->clsID = clsID;
	mainUI->pvt->pFNShow = IMainUI_Show;
	mainUI->pvt->pFNShowPosUI = IMainUI_ShowPosUI;
	mainUI->pvt->pFNClosePosUI = IMainUI_ClosePosUI;
	mainUI->pvt->pFNHandleEvent = IMainUI_HandleEvent;
	mainUI->pvt->pFNHandleEVKDOWNEvent = IMainUI_HandleEVKDOWNEvent;
	mainUI->pvt->pFNHandleEVKUPEvent = IMainUI_HandleEVKUPEvent;
	mainUI->pvt->pFNHandleSELECTUPEvent = IMainUI_HandleSELECTEvent;
	mainUI->pvt->pFNRelease = IMainUI_Release;
	
	 mainUI->glbVar = glbVar;
	
	 ISHELL_CreateInstance(glbVar->pIShell, AEECLSID_MENUCTL, (void**)(&mainUI->pMenu));
	 ISHELL_CreateInstance(glbVar->pIShell, AEECLSID_SOFTKEYCTL, (void**)(&mainUI->pSK));
	 
	 
	*iMainUI = mainUI;
	
	return AEE_SUCCESS;

}
예제 #4
0
파일: File.cpp 프로젝트: bonly/Template
/**
 * 初始化动态库接口
 * @return 0:成功
 */
int File::init()
{
    _app = GETAPPGLOBAL()->m_pMe;
    if (_app && FileMgr == 0)
    {
      if (ISHELL_CreateInstance(_app->m_pIShell, AEECLSID_FILEMGR,(void**)&FileMgr)
                  != SUCCESS)
      {
          return ENOMEMORY;
      }
      _FileMgr = FileMgr;
      ++count;
    }
    return SUCCESS;
}
예제 #5
0
파일: Location.c 프로젝트: TopSoup/BasicLoc
/*======================================================================= 
Function: Loc_InitGPSSettings()

Description: 
   Initializes the GPS configuration to the default values.
=======================================================================*/
uint32 Loc_InitGPSSettings(IShell *pIShell, AEEGPSConfig *gpsConfig)
{
   IFileMgr   *pIFileMgr = NULL;
   IFile      *pIConfigFile = NULL;
   uint32      nResult = 0;
   
   if (pIShell == NULL || gpsConfig == NULL)
      return EFAILED;

   // Create the instance of IFileMgr
   nResult = ISHELL_CreateInstance( pIShell, AEECLSID_FILEMGR, (void**)&pIFileMgr );
   if ( SUCCESS != nResult ) {
      return nResult;
   }

   // If the config file exists, open it and read the settings.  Otherwise, we need to
   // create a new config file.
   nResult = IFILEMGR_Test( pIFileMgr, LOC_CONFIG_FILE );
   if ( SUCCESS == nResult ) {
      pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, LOC_CONFIG_FILE, _OFM_READ );
      if ( !pIConfigFile ) {
         nResult = EFAILED;
      }
      else {
         nResult = Loc_ReadGPSSettings( pIConfigFile, gpsConfig );
      }
   }
   else {
      pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, LOC_CONFIG_FILE, _OFM_CREATE );
      if ( !pIConfigFile ) {
         nResult = EFAILED;
      }
      else {
         // Setup the default GPS settings
         gpsConfig->optim  = AEEGPS_OPT_DEFAULT;
         gpsConfig->qos    = LOC_QOS_DEFAULT;
         gpsConfig->server.svrType = AEEGPS_SERVER_DEFAULT;
         nResult = Loc_WriteGPSSettings( pIConfigFile , gpsConfig);
      }
   }

   // Free the IFileMgr and IFile instances
   IFILE_Release( pIConfigFile );
   IFILEMGR_Release( pIFileMgr );

   return nResult;
}
예제 #6
0
/*===========================================================================

FUNCTION: ARB_GetTotalRecNum

DESCRIPTION:
  This function get all record count in address book

PARAMETERS:
  pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains 
    information specific to this applet. 

DEPENDENCIES:
   None

RETURN VALUE:
  records count in address book

SIDE EFFECTS:
   None
===========================================================================*/
uint32 ARB_GetTotalRecNum( CAddrBookRuim * pMe, AEECLSID ContactCLS )
{
    IAddrBook *pb;
    int nCount=0;
    
    if(pMe==NULL||pMe->pIShell==NULL)
    {
        return 0;
    }
    DBGPRINTF("contact cls id=0x%x",ContactCLS);
    if(!ISHELL_CreateInstance(pMe->pIShell, ContactCLS, (void **)&pb))
    {
        nCount = IADDRBOOK_GetNumRecs(pb);    
        IADDRBOOK_Release(pb);
    }

    return nCount;
}
예제 #7
0
/*======================================================================= 
Function: SamplePosDet_InitGPSSettings()

Description: 
   Initializes the GPS configuration to the default values.

Prototype:

   uint32 SamplePosDet_InitGPSSettings( CSamplePosDet *pMe );

Parameters:
   pMe: [in]. CSamplePosDet instance.

Return Value:

   SUCCESS - If the settings were initialized successfully.
   Returns error code otherwise.
 
Comments:  
   None

Side Effects: 
   None

See Also:
   None
=======================================================================*/
uint32 SamplePosDet_InitGPSSettings(CSamplePosDet *pMe)
{
   IFileMgr   *pIFileMgr = NULL;
   IFile      *pIConfigFile = NULL;
   uint32      nResult = 0;

   // Create the instance of IFileMgr
   nResult = ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_FILEMGR, (void**)&pIFileMgr );
   if ( SUCCESS != nResult ) {
      return nResult;
   }

   // If the config file exists, open it and read the settings.  Otherwise, we need to
   // create a new config file.
   nResult = IFILEMGR_Test( pIFileMgr, SPD_CONFIG_FILE );
   if ( SUCCESS == nResult ) {
      pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, SPD_CONFIG_FILE, _OFM_READ );
      if ( !pIConfigFile ) {
         nResult = EFAILED;
      }
      else {
         nResult = SamplePosDet_ReadGPSSettings( pMe, pIConfigFile );
      }
   }
   else {
      pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, SPD_CONFIG_FILE, _OFM_CREATE );
      if ( !pIConfigFile ) {
         nResult = EFAILED;
      }
      else {
         // Setup the default GPS settings
         pMe->gpsSettings.optim  = AEEGPS_OPT_DEFAULT;
         pMe->gpsSettings.qos    = SPD_QOS_DEFAULT;
         pMe->gpsSettings.server.svrType = AEEGPS_SERVER_DEFAULT;
         nResult = SamplePosDet_WriteGPSSettings( pMe, pIConfigFile );
      }
   }

   // Free the IFileMgr and IFile instances
   IFILE_Release( pIConfigFile );
   IFILEMGR_Release( pIFileMgr );

   return nResult;
}
예제 #8
0
/*===========================================================================
   This function draws the splash screen and brings up the main window
   after the splash timer runs out.
===========================================================================*/
void  TS_DrawSplash(CTopSoupApp * pme,AECHAR* prompt,int msTimeout,PFNNOTIFY on_splashOver,void* pUser)
{
	if( NULL == prompt )
		return;
	
	if (pme->m_pWin)
		CTopSoupApp_DisableWin(pme);
   
   {
      IImage * pi = ISHELL_LoadResImage(pme->a.m_pIShell, NAVIGATE_RES_FILE, IDP_OBJECT_PROMPT);
	  IStatic * pInfoStatic = NULL;

      if (pi)
      {
         AEERect  rect;
		 AEEImageInfo      info;
		 int16 x,y;

		 IIMAGE_GetInfo(pi,&info);
		 x = ( pme->m_rectWin.dx - info.cx ) / 2;
		 y = pme->m_rectWin.y + ( pme->m_rectWin.dy - info.cy ) / 2;
         SETAEERECT(&rect,x,y,info.cx,info.cy);
         TS_DrawImage(pi, &rect, TRUE);


		 ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_STATIC, (void **)&pInfoStatic);
		 ISTATIC_SetRect(pInfoStatic, &rect);
		 ISTATIC_SetProperties(pInfoStatic,  ST_MIDDLETEXT | ST_CENTERTEXT | ST_NOSCROLL);
         TS_FitStaticText(pme->a.m_pIDisplay, pInfoStatic, AEE_FONT_LARGE, prompt);

         TS_RELEASEIF(pi);
		 TS_RELEASEIF(pInfoStatic);
      }

      // start the timer.
	  if ( on_splashOver )
		  ISHELL_SetTimer(pme->a.m_pIShell, msTimeout, (PFNNOTIFY)on_splashOver, pUser);  
	  else
		  ISHELL_SetTimer(pme->a.m_pIShell, msTimeout, (PFNNOTIFY)CTopSoupApp_onSplashDrawOver, pme);
   }
}
예제 #9
0
/*======================================================================= 
Function: SamplePosDet_SaveGPSSettings()

Description: 
   Opens the configuration file and saves the settings.

Prototype:

   uint32 SamplePosDet_SaveGPSSettings(CSamplePosDet *pMe);

Parameters:
   pMe: [in]. CSamplePosDet instance.

Return Value:

  SUCCESS - If the settings were written successfully.
  Error code otherwise.
 
Comments:  
   None

Side Effects: 
   None

See Also:
   None
=======================================================================*/
uint32 SamplePosDet_SaveGPSSettings( CSamplePosDet *pMe )
{
   IFileMgr   *pIFileMgr = NULL;
   IFile      *pIConfigFile = NULL;
   uint32      nResult = 0;

   // Create the instance of IFileMgr
   nResult = ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_FILEMGR, (void**)&pIFileMgr );
   if ( SUCCESS != nResult ) {
      return nResult;
   }

   // If the config file exists, open it and read the settings.  Otherwise, we need to
   // create a new config file.
   nResult = IFILEMGR_Test( pIFileMgr, SPD_CONFIG_FILE );
   if ( SUCCESS == nResult ) {
      pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, SPD_CONFIG_FILE, _OFM_READWRITE );
      if ( !pIConfigFile ) {
         nResult = EFAILED;
      }
      else {
         nResult = SamplePosDet_WriteGPSSettings( pMe, pIConfigFile );
      }
   }
   else {
      pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, SPD_CONFIG_FILE, _OFM_CREATE );
      if ( !pIConfigFile ) {
         nResult = EFAILED;
      }
      else {
         nResult = SamplePosDet_WriteGPSSettings( pMe, pIConfigFile );
      }
   }

   // Free the IFileMgr and IFile instances
   IFILE_Release( pIConfigFile );
   IFILEMGR_Release( pIFileMgr );

   return nResult;
}
예제 #10
0
SkFILE* sk_fopen(const char path[], SkFILE_Flags flags)
{
    int err;
    OpenFileMode mode;
    IFileMgr* fileMgr;
    IFile* file;
    IShell* shell;

    shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell;
    err = ISHELL_CreateInstance(shell, AEECLSID_FILEMGR, (void**)&fileMgr);
    if (err!= SUCCESS)
        return NULL;

    if (flags & kWrite_SkFILE_Flag)
        mode = _OFM_READWRITE;
    else /* kRead_SkFILE_Flag */
        mode = _OFM_READ;

    file = IFILEMGR_OpenFile(fileMgr, path, mode);
    IFILEMGR_Release(fileMgr);

    return (SkFILE*)file;
}
예제 #11
0
// ================================================================================
// FUNCTION		: OpenDatabase
// DESCRIPTION	: Open a given database in BREW.
// ================================================================================
bool CDbHandler::OpenDatabase(IDatabase **pDb, const char *pszFile, boolean bCreate)
{
	IDBMgr * pDBMgr;
	
	// Create the IDBMgr object
	if(ISHELL_CreateInstance(m_pIShell, AEECLSID_DBMGR, (void**)(&pDBMgr)) != SUCCESS)
	{
		DBGPRINTF("CDbHandler::OpenDatabase >> ISHELL_CreateInstance AEECLSID_DBMGR failed.");
		return false;
	}

	//Open database
	if((*pDb = IDBMGR_OpenDatabase(pDBMgr, pszFile, bCreate)) == NULL) 
	{
		DBGPRINTF("CDbHandler::OpenDatabase >> IDBMGR_OpenDatabase %s failed.", pszFile);
		IDBMGR_Release(pDBMgr);
		return false;
	}
	else
	{
		IDBMGR_Release(pDBMgr);
		return true;
	}
}
예제 #12
0
// ================================================================================
// FUNCTION		: DeleteDatabase
// DESCRIPTION	: Delete a given database in BREW.
// ================================================================================
bool CDbHandler::DeleteDatabase(const char *pszDbName)
{
	IDBMgr * pDBMgr;
	
	// Create the IDBMgr object
	if(ISHELL_CreateInstance(m_pIShell, AEECLSID_DBMGR, (void**)(&pDBMgr)) != SUCCESS)
	{
		DBGPRINTF("CDbHandler::DeleteDatabase >> ISHELL_CreateInstance %s failed.", pszDbName);
		return false;
	}

	if ( SUCCESS==IDBMGR_Remove(pDBMgr, pszDbName) )
	{
		IDBMGR_Release(pDBMgr);
		return true;
	}
	else
	{
		DBGPRINTF("CDbHandler::DeleteDatabase >> IDBMGR_Release failed.");
		IDBMGR_Release(pDBMgr);
		return false;
	}
	
}
예제 #13
0
파일: isms.c 프로젝트: virqin/brew_code
static boolean ISmsApp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
    ISmsApp * pMe = (ISmsApp*)pi;

    switch (eCode)
    {

    case EVT_APP_START:
        // When this applet is started, try to create the main menu
        // that allows the user to select a usage example to execute.
        // If we cannot create an instance of the menu class, exit and
        // indicate that we have handled the event by returning TRUE
        if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MENUCTL,
                                 (void **)&pMe->m_pIMenu) != SUCCESS)
            return TRUE;

        // Succeeded in obtaining a menu instance pointer, so
        // construct the menu and display it on the screen
        BuildMainMenu(pMe);
        return(TRUE);

    case EVT_APP_STOP:
    {
        int nErr;
        AEECLSID clsNotifier= AEECLSID_TAPI; // event sender
        AEECLSID clsNotify = AEECLSID_ISMS; // event listener
        uint32 dwMask = 0; // for deregister NMASK_TAPI_SMS_TEXT;

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

        clsNotifier= AEECLSID_SMSNOTIFIER; // event sender
        clsNotify = AEECLSID_ISMS; // event listener
        dwMask = 0; // for deregister event;

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

    case EVT_KEY:
        // 控制上下键选择菜单
        if (pMe->m_pIMenu)
        {
            if ((IMENUCTL_IsActive(pMe->m_pIMenu) == FALSE) &&
                    ((wParam == AVK_UP) || (wParam == AVK_DOWN)))
            {
                IMENUCTL_SetActive(pMe->m_pIMenu, TRUE);
                IMENUCTL_Redraw(pMe->m_pIMenu);
            }

            return IMENUCTL_HandleEvent(pMe->m_pIMenu, EVT_KEY, wParam, 0);
        }
        else
            return FALSE;


    case EVT_NOTIFY:
    {
        uint32 uMsgId;
        ISMSMsg *pRxMsg=NULL;
        AEENotify* pNotify = (AEENotify*) dwParam;

        // 使用原TAPI接口接收短信
        if (pNotify && (pNotify->cls == AEECLSID_TAPI)) // event sender
        {
            DBGPRINTF("AEECLSID_TAPI sender");

            if ((pNotify->dwMask & NMASK_TAPI_SMS_TEXT) == NMASK_TAPI_SMS_TEXT)
            {
                AEESMSTextMsg *pMsg;
                DBGPRINTF("Notify mask ok");
                pMsg = (AEESMSTextMsg *)pNotify->pData;

                // 此处假定短信为ASCII,如果UNICODE需要首先检测,再输出UNICODE字串
                WriteLine(pMe,  pMsg->szText, NULL, FALSE);
            }
        }

        // 使用新的SMSNotifier 接口接收短信,此接口BREW 3.1.x 以上版本支持
        if (pNotify && (pNotify->cls == AEECLSID_SMSNOTIFIER)) // event sender
        {
            uint32  MyNMask;

            DBGPRINTF("AEECLSID_SMSNOTIFIER sender");
            // 普通短信的EVENT MASK
            MyNMask = ((AEESMS_TYPE_TEXT << 16) | NMASK_SMS_TYPE);
            if ((pNotify->dwMask & MyNMask) == MyNMask)
            {
                DBGPRINTF("Notify mask ok");

                uMsgId = (uint32 )pNotify->pData;
                if(ISMS_ReceiveMsg(pMe->m_pISMS, uMsgId, &pRxMsg)==AEE_SUCCESS)
                {
                    SMSMsgOpt TmpOpt;
                    DBGPRINTF("ISMS_ReceiveMsg ret ok");

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

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

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

                    // MSGOPT_PAYLOAD_BINARY - UTF-8的短信内容
                    if(ISMSMSG_GetOpt(pRxMsg, MSGOPT_PAYLOAD_BINARY, &TmpOpt)==AEE_SUCCESS)
                    {
                        unsigned char *ucBuf;
                        AECHAR  UnicodeBuf[100];
                        DBGPRINTF("PAYLOAD_BINARY(len: %d):", WEBOPT_GETVARBUFFERLENGTH(TmpOpt.pVal));
                        ucBuf = WEBOPT_GETVARBUFFERDATA(TmpOpt.pVal);
                        UTF8TOWSTR(ucBuf, WEBOPT_GETVARBUFFERLENGTH(TmpOpt.pVal), UnicodeBuf, sizeof(UnicodeBuf));

                        DBGPRINTF("0x%2x, %2x, %2x, %2x", UnicodeBuf[0], UnicodeBuf[1], UnicodeBuf[2], UnicodeBuf[3] );
                        DBGPRINTF("0x%2x, %2x, %2x, %2x", UnicodeBuf[4], UnicodeBuf[5], UnicodeBuf[6], UnicodeBuf[7] );
                        DBGPRINTF("0x%2x, %2x, %2x, %2x", UnicodeBuf[8], UnicodeBuf[9], UnicodeBuf[10], UnicodeBuf[11] );
                        DBGPRINTF("0x%2x, %2x, %2x, %2x", UnicodeBuf[12], UnicodeBuf[13], UnicodeBuf[14], UnicodeBuf[15] );
                        WriteLine(pMe,  NULL, (AECHAR *)UnicodeBuf, TRUE);
                    }

                    // 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,  buf, NULL, FALSE);
                    }
                }

            }
        }
    }


    return TRUE;

    case EVT_COMMAND:
        switch(wParam)
        {
        // The following commands are generated by user selections
        // from the main usage app menu.
        case USAGE_SMS_TX_ASCII:
        case USAGE_SMS_TX_UNICODE:
        case USAGE_SMS_TX_UTF8:
        case USAGE_SMS_RX_TAPI_METHOD:
        case USAGE_SMS_RX_ISMS_METHOD:
        case USAGE_SMS_STORE_STATUS:
        case USAGE_SMS_STORE_ENUM_READ:
            // Deactivate main menu to turn off horizontal scrolling of long menu items
            IMENUCTL_SetActive(pMe->m_pIMenu, FALSE);

            // Execute the usage example the user has selected
            ISmsAppUsage (pMe, wParam);
            return TRUE;

        default:
            return FALSE;
        }
    default:
        break;
    }
    return FALSE;
}
예제 #14
0
int AEEStaticMod_New(int16 nSize, IShell *pIShell, void *ph, IModule **ppMod,PFNMODCREATEINST pfnMC,PFNFREEMODDATA pfnMF)
{
	IFileMgr      *pFileMgr      = NULL;
	IFile         *pFile         = NULL;
	byte          *pData         = NULL;
	FileInfo      fileinfo             ;
	RunLoadMod    pFun           = NULL;
	int           nResult        = 0;
	char          name[128];
	char          path[128];
	DBGPRINTF( "+++++++++++++++++++++++++++++++++++++++++");
	MEMSET(name,0,128*sizeof(char));
	MEMSET(path,0,128*sizeof(char));
	if(!(SUCCESS == ISHELL_CreateInstance( pIShell , AEECLSID_FILEMGR, (void **) &pFileMgr)) )
		goto TagFailModLoader;

	/*
	pFile = IFILEMGR_OpenFile( pFileMgr , AEEFS_SHARED_DIR"run.app" ,_OFM_READWRITE);
		if ( NULL == pFile ){
			DBGPRINTF( "Open run.app EFAILED");
			IFILEMGR_Release( pFileMgr );
			goto TagFailModLoader;}
		else{
			DBGPRINTF( "Open run.app OK");
		}
		IFILE_Read(pFile, name, 128);
		IFILE_Release(pFile);
		STRCPY(path,AEEFS_SHARED_DIR);
		STRCAT(path,name);
	
		DBGPRINTF("Load Mod Path:%s",path);
		DBGPRINTF("Load Mod Name:%s",name);*/
	
	//pFile = IFILEMGR_OpenFile( pFileMgr , "helloworld.bin" ,_OFM_READWRITE);//打开读 和写。
	pFile = IFILEMGR_OpenFile( pFileMgr , "flyvideo.mod" ,_OFM_READWRITE);//打开读 和写。
	if ( NULL == pFile ){
		DBGPRINTF( "Open Mod File EFAILED");
		IFILEMGR_Release( pFileMgr );
		goto TagFailModLoader;}
	else{
		DBGPRINTF( "Open Mod File OK");
	}
	IFILE_GetInfo(pFile, &fileinfo);
	pData = (byte *)MALLOC( 4 * fileinfo.dwSize + 5);//pData不用释放,由AEE环境释放
	MEMSET( pData , 0x00 ,  4 * fileinfo.dwSize + 5);
	MEMCPY( pData , &ph , 4 );
	DBGPRINTF( "Open File OK:%d" , fileinfo.dwSize );
	IFILE_Read( pFile , pData + 4 , fileinfo.dwSize );
	DBGPRINTF( "Read File OK" );

	IFILE_Release( pFile );
	IFILEMGR_Release( pFileMgr );

	DBGPRINTF("Before RunLoadMod");
	pFun = (RunLoadMod)(pData + 4);
	nResult =  pFun(pIShell,ph,ppMod);
	(*ppMod)->pvt->FreeResources = AEEMod_FreeResources;
	DBGPRINTF("After RunLoadMod");
	DBGPRINTF( "+++++++++++++++++++++++++++++++++++++++++");
	return nResult;
TagFailModLoader:
	DBGPRINTF("AEEMod_Load EFAILED");
	DBGPRINTF( "+++++++++++++++++++++++++++++++++++++++++");
	return EFAILED;
}
예제 #15
0
파일: ExRSA.c 프로젝트: virqin/brew_code
/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent
===========================================================================*/
static boolean ExRSA_HandleEvent(ExRSA* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{  

	switch (eCode) 
	{
		// App is told it is starting up
	case EVT_APP_START:       
		{
			/*
			AECHAR *pBuffer;
			uint32 resSize;
			int fontHeight;
			int pageLine;
			int i;
			int fitNumber;
			int count;
			ISHELL_GetResSize(pMe->pIShell,EXRSA_RES_FILE,IDS_DEMO,RESTYPE_STRING,&resSize);
			pBuffer = (AECHAR*)MALLOC(resSize);
			ISHELL_LoadResString(pMe->pIShell,EXRSA_RES_FILE,IDS_DEMO,pBuffer,resSize);
			IDISPLAY_SetColor(pMe->pIDisplay,CLR_USER_TEXT,MAKE_RGB(0,0,0));
			IDISPLAY_SetColor(pMe->pIDisplay,CLR_USER_BACKGROUND,MAKE_RGB(255,255,255));
			fontHeight = IDISPLAY_GetFontMetrics(pMe->pIDisplay,AEE_FONT_NORMAL,NULL,NULL);
			pageLine = pMe->DeviceInfo.cyScreen/fontHeight;
			count = 0;
			for(i = 0;i<pageLine;i++)
			{
				IDISPLAY_MeasureTextEx(pMe->pIDisplay,AEE_FONT_NORMAL,pBuffer+count,-1,pMe->DeviceInfo.cxScreen,&fitNumber);
				if(fitNumber!=-1)
				{
					IDISPLAY_DrawText(pMe->pIDisplay,AEE_FONT_NORMAL,
						pBuffer+count,fitNumber,0,i*fontHeight,
						NULL,IDF_TEXT_TRANSPARENT);
					count += fitNumber;
				}
				else
				{
					IDISPLAY_DrawText(pMe->pIDisplay,AEE_FONT_NORMAL,pBuffer+count,-1,0,i*fontHeight,NULL,IDF_TEXT_TRANSPARENT);
				}
			}
			IDISPLAY_Update(pMe->pIDisplay);
			FREE(pBuffer);*/
			IGraphics *pIGra;
			AEEPoint point;
			AEECircle circle;
			AEEEllipse ellipise;
			point.x = 10;
			point.y = 10;
			circle.cx = 100;
			circle.cy = 100;
			circle.r = 10;
			ellipise.cx = 50;
			ellipise.cy = 50;
			ellipise.wx = 10;
			ellipise.wy = 20;


			ISHELL_CreateInstance(pMe->pIShell,AEECLSID_GRAPHICS,(void**)&pIGra);
			//IGRAPHICS_SetBackground(pIGra,0,0,0);
			IGRAPHICS_ClearViewport(pIGra);
			IGRAPHICS_DrawPoint(pIGra,&point);
			IGRAPHICS_SetFillColor(pIGra,255,0,0,0);
			IGRAPHICS_SetColor(pIGra,0,255,0,0);
			IGRAPHICS_SetFillMode(pIGra,TRUE);
			IGRAPHICS_DrawCircle(pIGra,&circle);
			//STROKE_DOTTED
				IGRAPHICS_SetStrokeStyle(pIGra,STROKE_DOTTED);
			//IGRAPHICS_SetStokeStyle(pIGra,STROKE_SOLID);
							IGRAPHICS_SetFillColor(pIGra,255,255,0,0);
			IGRAPHICS_SetColor(pIGra,0,255,255,0);
				IGRAPHICS_DrawEllipse(pIGra,&ellipise);
			IGRAPHICS_Update(pIGra);
			IGRAPHICS_Release(pIGra);



		}

		return(TRUE);


		// App is told it is exiting
	case EVT_APP_STOP:
		// Add your code here...

		return(TRUE);


		// App is being suspended 
	case EVT_APP_SUSPEND:
		// Add your code here...

		return(TRUE);


		// App is being resumed
	case EVT_APP_RESUME:
		// Add your code here...

		return(TRUE);


		// 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...

		return(TRUE);

		// 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...

		return(TRUE);


		// If nothing fits up to this point then we'll just break out
	default:
		break;
	}

	return FALSE;
}
예제 #16
0
/*===========================================================================

FUNCTION: ABR_GetContactFieldByItemID

DESCRIPTION:
  This function get all fields of record whose id is wID

PARAMETERS:
  pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains 
    information specific to this applet. 
  wID[in] - record id to be query
  pTextName[out] - name field 
  pTextNum[out] - number field

DEPENDENCIES:
   None

RETURN VALUE:
  AEE_SUCCESS -  IADDRREC_UpdateAllFields operate successfully
  other - fail

SIDE EFFECTS:
   None
===========================================================================*/
int32  ABR_GetContactFieldByItemID(CAddrBookRuim *pMe, AEECLSID ContactCLS, uint16 wID, AECHAR *pTextName, AECHAR *pTextNum)
{
    int nRet = 0;
    IAddrBook *pb;
    IAddrRec *pR;
    boolean bFlgNameGet;
    boolean bFlgNumGet;
    
    if(pMe==NULL || pMe->pIShell==NULL || pTextName==NULL || pTextNum==NULL)
    {
        return (-1);
    }

    if(!ISHELL_CreateInstance(pMe->pIShell, ContactCLS, (void **)&pb))
    {
        pR =IADDRBOOK_GetRecByID(pb, wID);
        if(pR)
        {
            AEEAddrField *ptr = NULL;
            int i;
            int nFields;

            bFlgNameGet = FALSE;
            bFlgNumGet = FALSE;
            nFields= IADDRREC_GetFieldCount(pR);
            for(i = 0; i < nFields; i++)
            {
               ptr = IADDRREC_GetField(pR,i);
               // find name field and save it;
               if (   ptr->fID == AEE_ADDRFIELD_NAME  
                   ||ptr->fID == AEE_ADDRFIELD_FIRSTNAME
                   ||ptr->fID == AEE_ADDRFIELD_LASTNAME
                   ||ptr->fID == AEE_ADDRFIELD_NICKNAME)
               { 
                  if(bFlgNameGet==FALSE)
                   {
                      bFlgNameGet = TRUE;
                      WSTRCPY(pTextName, ptr->pBuffer);
                   }
               }

               // find number field and save it;
               if (    ptr->fID >= AEE_ADDRFIELD_PHONE_WORK  
                  && ptr->fID <= AEE_ADDRFIELD_PHONE_OTHER)
               { 
                  if(bFlgNumGet==FALSE)
                   {
                      bFlgNumGet = TRUE;
                      WSTRCPY(pTextNum, ptr->pBuffer);
                   }
               }

            }

            if(bFlgNameGet && bFlgNumGet) 
            {
                nRet=0;
            }
            else
            {
                nRet=3;
            }
        }
        else
        {
            nRet=2;  // IADDRBOOK_GetRecByID fail
        }

        IADDRBOOK_Release(pb);
    }
    else
    {
        nRet = 1; // fail ISHELL_CreateInstance
    }

    return nRet;
}
예제 #17
0
파일: isms.c 프로젝트: virqin/brew_code
/*===========================================================================

FUNCTION: IFileUsage

DESCRIPTION
    This function executes the usage example selected from the main menu by the
  user.  It takes as input the app data pointer and the ID of the example the
  user selected.  After clearing the screen, the selected example is executed.
  Each example is a self-contained code block that contains any local variables
  needed to execute the example.  Each code block also creates and releases any
  BREW interfaces that are required, and will exit if any errors are detected.
  Once the example has been executed, this function prints a heading at the top
  of the screen to indicate which example was selected,
  and a message at the bottom of the screen instructing the user how to return to
  the main menu to execute another example.

PROTOTYPE:
   static void IFileUsage(ISmsApp * pMe, uint16 wParam)

PARAMETERS:
   pMe:   [in]: Contains a pointer to the usage app data structure.
   wParam: [in]: Identifier of the selected example (example IDs are specified when the
                 main usage app menu is created).

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None

===========================================================================*/
static void ISmsAppUsage (ISmsApp * pMe, uint16 wParam)
{


    // Make sure the pointers we'll be using are valid
    if (pMe == NULL || pMe->a.m_pIShell == NULL || pMe->a.m_pIDisplay == NULL)
        return;

    // Erase screen first for display output purposes.
    DisplayEvent (pMe, USAGE_ERASE_SCREEN);
    IMENUCTL_SetProperties(pMe->m_pIMenu, MP_NO_REDRAW);
    IMENUCTL_SetActive(pMe->m_pIMenu, FALSE);

    // Initialize line number where we will start the output
    // of each test
    pMe->m_cLineNum = 1;

    switch (wParam)
    {
    case USAGE_SMS_TX_ASCII:
    {
        int nErr;
        WebOpt awo[6]; /* ***IMPORTANT**** grow this if you add more
                             WebOpts here, or shrink it and call AddOpt() multiple times */
        int    i = 0;
        uint32 nReturn=0;


        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++;

        /* ascii text to be send */
        awo[i].nId  = MSGOPT_PAYLOAD_SZ ;
        awo[i].pVal = (void *)MO_TEXT_ASCII;
        i++;

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

        awo[i].nId  = MSGOPT_MOSMS_ENCODING;
        awo[i].pVal = (void *)AEESMS_ENC_ASCII;
        i++;
#if 0
        /* user ack */
        awo[i].nId  = MSGOPT_USER_ACK;
        awo[i].pVal = (void *)TRUE;
        i++;
#endif
        /* this is absolutely necessary, do not remove, marks the end of the
           array of WebOpts */
        awo[i].nId  = WEBOPT_END;

        /* add 'em */
        nErr =ISMSMSG_AddOpt(pMe->m_pISMSMsg, awo);
        DBGPRINTF("ISMSMSG_AddOpt ret %d", nErr);

        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;

    case USAGE_SMS_TX_UNICODE:
    {
        int nErr;
        WebOpt awo[6]; /* ***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, ISMS_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++;

#if 0
        /* user ack */
        awo[i].nId  = MSGOPT_READ_ACK;
        awo[i].pVal = (void *)TRUE;
        i++;
#endif

        /* 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);

        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;

    case USAGE_SMS_TX_UTF8:
    {
        int nErr;
        WebOpt awo[6]; /* ***IMPORTANT**** grow this if you add more
                             WebOpts here, or shrink it and call AddOpt() multiple times */
        int    i = 0;
        uint32 nReturn=0;
        char utf8_Buf_Sending[302];
        uint16 count;
        // in utf-8 "数组19英文English混合" with heading of two bytes for length -0x0010
        // The length is little-endian, low byte first.
        char cTextUTF8[142]= {0xFF, 0xFE,
                              0x70, 0x65,0x57, 0x5B, 0x31, 0x0, 0x39, 0x0, 0xF1, 0x82, 0x87, 0x65, 0x45, 0x0,
                              0x6E, 0x0,  0x67, 0x0, 0x6c, 0x0, 0x69, 0x0, 0x73, 0x0, 0x68, 0x0, 0xF7, 0x6D, 0x08, 0x54, 0x0, 0x0
                             };
        //char cTextUTF8[142]={0x1e, 0x0,
        //                                    0xEF, 0xBB, 0xBF, 0xE6,0x95, 0xB0, 0xE7, 0xBB, 0x84, 0x31, 0x39, 0xE8, 0x8B, 0x8B, 0xB1, 0xE6, 0x96,
        //                                     0x87, 0x45,  0x6E, 0x67, 0x6c, 0x69, 0x73, 0x68, 0xE6, 0xB7, 0xB7, 0xE5, 0x90, 0x88 };

        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_BINARY;
        MEMSET(utf8_Buf_Sending, 0, sizeof(utf8_Buf_Sending));
        WSTRTOUTF8((AECHAR *)cTextUTF8, WSTRLEN((AECHAR *)cTextUTF8), (byte *)&(utf8_Buf_Sending[2]), 300);
        count = STRLEN(&(utf8_Buf_Sending[2]));
        DBGPRINTF("WLen(%d)===> count=%d", WSTRLEN((AECHAR *)cTextUTF8),count);
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[0], utf8_Buf_Sending[1], utf8_Buf_Sending[2], utf8_Buf_Sending[3] );
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[4], utf8_Buf_Sending[5], utf8_Buf_Sending[6], utf8_Buf_Sending[7] );
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[8], utf8_Buf_Sending[9], utf8_Buf_Sending[10], utf8_Buf_Sending[11] );
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[12], utf8_Buf_Sending[13], utf8_Buf_Sending[14], utf8_Buf_Sending[15] );
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[16], utf8_Buf_Sending[17], utf8_Buf_Sending[18], utf8_Buf_Sending[19] );
        utf8_Buf_Sending[0]=count & 0xff;
        utf8_Buf_Sending[1]=(count>>8) & 0xff;
        awo[i].pVal = (void *)utf8_Buf_Sending;
        i++;

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

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

#if 0
        /* user ack */
        awo[i].nId  = MSGOPT_READ_ACK;
        awo[i].pVal = (void *)TRUE;
        i++;
#endif

        /* 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);

        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;

    case USAGE_SMS_RX_TAPI_METHOD:
    {
        // 使用TAPI的notify机制接收短信
        AEECLSID clsNotifier= AEECLSID_TAPI; // Event sender
        AEECLSID clsNotify = AEECLSID_ISMS;  // Event listener
        // Set the notify event to be NOTIFY_MASK_EVENT. This event is used
        // as an example.
        uint32 dwMask = NMASK_TAPI_SMS_TEXT;
        int nErr;

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

    break;

    case USAGE_SMS_RX_ISMS_METHOD:
    {
        // 使用新的AEECLSID_SMSNOTIFIER 的notify机制接收短信
        AEECLSID clsNotifier= AEECLSID_SMSNOTIFIER; // Event sender
        AEECLSID clsNotify = AEECLSID_ISMS; // 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);
    }
    break;

    case USAGE_SMS_STORE_STATUS:
    {
        CALLBACK_Cancel(&pMe->m_cb);
        CALLBACK_Init(&pMe->m_cb, OATSMS_StoreReadMsgStorageStatusCb, (void*)pMe);

        ISMSSTORAGE_GetStorageStatus(pMe->m_pISMSStorage,
                                     pMe->m_mt,
                                     pMe->m_tag,
                                     &pMe->m_cb,
                                     &pMe->m_ss,
                                     &pMe->m_dwStatus);
    }
    break;

    case USAGE_SMS_STORE_ENUM_READ:
    {
        CALLBACK_Cancel(&pMe->EnumMsgInitCb);
        CALLBACK_Init(&pMe->EnumMsgInitCb, OATSMS_EnumMsgInitCb, (void*)pMe);
        ISMSSTORAGE_EnumMsgInit(pMe->m_pISMSStorage,
                                pMe->m_mt,
                                pMe->m_tag,
                                &pMe->EnumMsgInitCb,
                                &pMe->m_dwStatus);
    }
    break;

    default:
        return;
    }

    // Display above event.
    DisplayEvent (pMe, wParam);

    return;
}
예제 #18
0
/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent

DESCRIPTION
	This is the EventHandler for this app. All events to this app are handled in this
	function. All APPs must supply an Event Handler.

PROTOTYPE:
	boolean SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)

PARAMETERS:
	pi: Pointer to the AEEApplet structure. This structure contains information specific
	to this applet. It was initialized during the AEEClsCreateInstance() function.

	ecode: Specifies the Event sent to this applet

   wParam, dwParam: Event specific data.

DEPENDENCIES
  none

RETURN VALUE
  TRUE: If the app has processed the event
  FALSE: If the app did not process the event

SIDE EFFECTS
  none
===========================================================================*/
static boolean MemChecker_HandleEvent(MemChecker* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
#if 1
    // for debugging
    if (EVT_POINTER_DOWN == eCode)
    {
        AEERect rc;
        int x, y;
        AEE_POINTER_GET_XY((char *)dwParam, &x, &y);
        SETAEERECT(&rc, x, y, 2, 2);
        IDisplay_FillRect(pMe->a.m_pIDisplay, &rc, RGB_BLACK);
        IDisplay_Update(pMe->a.m_pIDisplay);
    }
#endif

    if (pMe->m_pIDesktopWindow 
        && IDesktopWindow_HandleEvent(pMe->m_pIDesktopWindow, eCode, wParam, dwParam))
    {
        return TRUE;
    }

    switch (eCode) 
    {
        // App is told it is starting up
    case EVT_APP_START:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_START ##############");

        if (pMe->m_bBackground)
        {
            pMe->m_bBackground = FALSE;
            IContainer_Invalidate((IContainer *)pMe->m_pIDesktopWindow, NULL, NULL);
            return TRUE;
        }

        ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_APPLETCTL, (void **)&pMe->m_pIAppletCtl);
        IniFileParser_LoadFile(pMe->a.m_pIShell, MemChecker_ParseLineCB, pMe);

        // ClassFactory & DestopWindow
        pMe->m_pIClassFactory = XClassFactory_New();
        IClassFactory_CreateInstance(pMe->m_pIClassFactory, XCLSID_DesktopWindow, (void **)&pMe->m_pIDesktopWindow);
        IWidget_SetName((IWidget*)pMe->m_pIDesktopWindow, "DesktopWindow");
        IDesktopWindow_SetDisplay(pMe->m_pIDesktopWindow, pMe->a.m_pIDisplay);
        IWidget_SetRectEx((IWidget*)pMe->m_pIDesktopWindow, 0, 0, pMe->DeviceInfo.cxScreen, pMe->DeviceInfo.cyScreen);

        MemChecker_CreateMainMenu(pMe);

        return(TRUE);


    // App is told it is exiting
    case EVT_APP_STOP:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_STOP ###################");

        if (pMe->m_bBackground)
        {
            *(boolean *)dwParam = FALSE;
            return TRUE;
        }

        CALLBACK_Cancel(&pMe->m_cbModUnload);
        CALLBACK_Cancel(&pMe->m_cbWaitForAppStartup);

        MemHook_Uninstall();

        RELEASEIF(pMe->m_pIClassFactory);
        RELEASEIF(pMe->m_pIDesktopWindow);

        RELEASEIF(pMe->m_pIAppletCtl);

        return(TRUE);


        // App is being suspended 
    case EVT_APP_SUSPEND:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_SUSPEND ################");

        return(TRUE);


        // App is being resumed
    case EVT_APP_RESUME:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_RESUME #################");
        IContainer_Invalidate((IContainer *)pMe->m_pIDesktopWindow, NULL, NULL);

        return(TRUE);


        // 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...

        return(TRUE);


        // If nothing fits up to this point then we'll just break out
    default:
        break;
    }

    return FALSE;
}
예제 #19
0
파일: calldemo.c 프로젝트: virqin/brew_code
static boolean CallDemoApp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{  
    CallDemoApp * pMe = (CallDemoApp*)pi;

    switch (eCode) 
    {
        case EVT_APP_START:
            // When this applet is started, try to create the main menu
            // that allows the user to select a usage example to execute.
            // If we cannot create an instance of the menu class, exit and
            // indicate that we have handled the event by returning TRUE
            if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MENUCTL, 
                                                (void **)&pMe->m_pIMenu) != SUCCESS)
                return TRUE;

            // Succeeded in obtaining a menu instance pointer, so
            // construct the menu and display it on the screen
            BuildMainMenu(pMe);
            return(TRUE);

        case EVT_APP_STOP:
            return(TRUE);

        case EVT_KEY: 
            if(pMe->m_isDTMFItem)
            {
                if (wParam == AVK_2)
                {
                    AECHAR szwStr[32];
                    char szNumber[32];
                    int nRet;

                    // get telephone number (main) from resource file
                    ISHELL_LoadResString(pMe->a.m_pIShell, CALLDEMO_RES_FILE, IDS_STRING_TELEPHONE_NUMBER_SUB, szwStr, sizeof(szwStr));
                    WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));

                    nRet = ICALL_BurstDTMF(pMe->m_pOutgoingCall,  AEET_DTMF_ON_95,AEET_DTMF_OFF_60,szNumber);
                    DBGPRINTF("ICALL_BurstDTMF ret %d", nRet);
                    WriteLine(pMe, "ICALL_BurstDTMF -->", NULL, FALSE);    
                }
            }


            if (pMe->m_isParty3Item)
            {
                if (wParam == AVK_3)
                {
                   AECHAR szwStr[32];
                   char szNumber[32];
                   boolean Result;

                   // get telephone number (main) from resource file
                   ISHELL_LoadResString(pMe->a.m_pIShell, CALLDEMO_RES_FILE, IDS_STRING_TELEPHONE_NUMBER_B, szwStr, sizeof(szwStr));
                   WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));

                          
                  LISTENER_Init(&pMe->callListenerB, (PFNLISTENER) OriginateListener, pMe);
                  Result = ICALLMGR_Originate(pMe->m_pCallMgr, AEET_CALL_TYPE_VOICE, szNumber, NULL, &pMe->m_pOutgoingCallB, &pMe->callListenerB);
                  if (Result != SUCCESS)
                  {
                     DBGPRINTF("ICALLMGR_Originate failed with res=%d", Result);
                     break;
                  }
                  WriteLine(pMe, "Call Originate B-->", NULL, FALSE);  
                  WriteLine(pMe, "Press 1 to unhold A", NULL, FALSE);  
                  return TRUE;
                }

                if (wParam == AVK_1)
                {
                  int nRet;
                  if(pMe->m_pOutgoingCall)
                  {
                    nRet = ICALL_SwitchTo( pMe->m_pOutgoingCall );
                    DBGPRINTF("ICALL_SwitchTo A ret:%d", nRet);
                  }
#if 0
                  if(pMe->m_pOutgoingCallB)
                  {
                    nRet = ICALL_Hold( pMe->m_pOutgoingCallB );
                    DBGPRINTF("ICALL_Hold B ret:%d", nRet);
                  }
#endif                  
                  WriteLine(pMe, "switch issued", NULL, FALSE);  
                  return TRUE;
                }

#if 0
                if (wParam == AVK_2)
                {
                  int nRet;
                  if(pMe->m_pOutgoingCallB)
                  {
                    nRet = ICALL_SwitchTo( pMe->m_pOutgoingCallB );
                     DBGPRINTF("ICALL_SwitchTo B ret:%d", nRet);
                  }
                  
                  if(pMe->m_pOutgoingCall)
                  {
                    nRet = ICALL_Hold( pMe->m_pOutgoingCall );
                    DBGPRINTF("ICALL_Hold A ret:%d", nRet);
                  }
                  WriteLine(pMe, "switch issued", NULL, FALSE);  
                  return TRUE;
                }
#endif                  
            }

            // ¿ØÖÆÉÏϼüÑ¡Ôñ²Ëµ¥
            if (pMe->m_pIMenu)
            {
                if ((IMENUCTL_IsActive(pMe->m_pIMenu) == FALSE) &&
                   ((wParam == AVK_UP) || (wParam == AVK_DOWN)))
                {
                    IMENUCTL_SetActive(pMe->m_pIMenu, TRUE);
                    IMENUCTL_Redraw(pMe->m_pIMenu);
                }

                return IMENUCTL_HandleEvent(pMe->m_pIMenu, EVT_KEY, wParam, 0);
            }
            else
                return FALSE;


        case EVT_NOTIFY:
            break;
            
        case EVT_COMMAND:
            switch(wParam)
            {
                // The following commands are generated by user selections
                // from the main usage app menu.
                
                case USAGE_CALL_ORIG:
                case USAGE_CALL_OUTGOING_END:
                case USAGE_CALL_INCOMING_END:
                case USAGE_CALL_DTMF:
                case USAGE_CALL_PARTY3:
                case USAGE_CALL_ANSWER:
                case USAGE_CALL_REDIRECT:
                    // Deactivate main menu to turn off horizontal scrolling of long menu items
                    IMENUCTL_SetActive(pMe->m_pIMenu, FALSE);

                    // Execute the usage example the user has selected
                    CallDemoAppUsage (pMe, wParam);
                    return TRUE;
             
                default:
                    return FALSE;
            } // switch(wPara)

        case EVT_MY_ANSWER:
        DBGPRINTF("handler of call incoming by answer");
        if (pMe->m_pIncomingCall)
        { 
            int nError;
            nError = ICALL_Answer(pMe->m_pIncomingCall);
            if (SUCCESS != nError)
            {
                DBGPRINTF("ICALL_Answer failed ret=%d", nError);
            }
            else
            {
                DBGPRINTF("ICALL_Answer -->");
                WriteLine(pMe, "ICALL_Answer -->", NULL, FALSE);          
            }
        }
                    return TRUE;

        case EVT_MY_REDIRECT:
        DBGPRINTF("handler of call incoming by redirect");
        if (pMe->m_pIncomingCall)
        { 
            int nError;
            AECHAR szwStr[32];
            char szNumber[32];

            // get redirect number
            ISHELL_LoadResString(pMe->a.m_pIShell, CALLDEMO_RES_FILE, IDS_STRING_TELEPHONE_NUMBER_REDIRECT, szwStr, sizeof(szwStr));
            WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));

            nError = ICALL_Redirect(pMe->m_pIncomingCall, szNumber);
            if (SUCCESS != nError)
            {
                DBGPRINTF("ICALL_Redirect failed ret=%d", nError);
            }
            else
            {
                DBGPRINTF("ICALL_Redirect -->%s", szNumber);
                WriteLine(pMe, "ICALL_Redirect -->", NULL, FALSE);          
            }
        }
        return TRUE;

        default:
            break;
   } //  switch (eCode) 

#ifdef EVENT_AUTO_GET
   if(eCode == pMe->m_UserAnswerEvent)
   {
        DBGPRINTF("handler of call incoming by answer");
        if (pMe->m_pIncomingCall)
        { 
            int nError;
            nError = ICALL_Answer(pMe->m_pIncomingCall);
            if (SUCCESS != nError)
            {
                DBGPRINTF("ICALL_Answer failed ret=%d", nError);
            }
            else
            {
                DBGPRINTF("ICALL_Answer -->");
                WriteLine(pMe, "ICALL_Answer -->", NULL, FALSE);          
            }
        }
   }
   
   if(eCode == pMe->m_UserRedirectEvent)
   {
        DBGPRINTF("handler of call incoming by redirect");
        if (pMe->m_pIncomingCall)
        { 
            int nError;
            AECHAR szwStr[32];
            char szNumber[32];

            // get redirect number
            ISHELL_LoadResString(pMe->a.m_pIShell, CALLDEMO_RES_FILE, IDS_STRING_TELEPHONE_NUMBER_REDIRECT, szwStr, sizeof(szwStr));
            WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));

            nError = ICALL_Redirect(pMe->m_pIncomingCall, szNumber);
            if (SUCCESS != nError)
            {
                DBGPRINTF("ICALL_Redirect failed ret=%d", nError);
            }
            else
            {
                DBGPRINTF("ICALL_Redirect -->%s", szNumber);
                WriteLine(pMe, "ICALL_Redirect -->", NULL, FALSE);          
            }
        }
   }
#endif    
   return FALSE;
}
예제 #20
0
/*======================================================================= 
Function: SamplePosDet_OptimSettings_HandleEvent()

Description: 
   Event handler function for the optimization mode settings menu.

Prototype:

   boolean SamplePosDet_OptimSettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)

Parameters:
   pMe: [in]. CSamplePosDet instance.
   eCode: [in]. Event code.
   wParam: [in]. Event wParam.
   dwParam: [in]. Event dwParam.

Return Value:

   TRUE - If the event was handled by this menu.
   FALSE - If the event was not handled.
 
Comments:  
   None

Side Effects: 
   None

See Also:
   None
=======================================================================*/
boolean SamplePosDet_OptimSettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)
{
   boolean bHandled = FALSE;
   IMenuCtl *pMenuCtl = SamplePosDet_GetScreenData( pMe );

   switch( eCode ) {
   case EVT_SCREEN:
      if( wParam == SCREEN_PARAM_INIT ) {
         if( pMenuCtl ) {  /* This is not expected to happen */
            SamplePosDet_DrawScreen( pMe, 0 );
            bHandled = TRUE;
         }
         else {
            if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_MENUCTL, 
               (void **)&pMenuCtl ) == SUCCESS ) {

               //IMENUCTL_AddItem( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_OPT_NONE,
               //   AEEGPS_OPT_NONE, NULL, (uint32)pMenuCtl );

               IMENUCTL_AddItem( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_OPT_SPEED,
                  AEEGPS_OPT_SPEED, NULL, (uint32)pMenuCtl );

               IMENUCTL_AddItem( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_OPT_ACCURACY,
                  AEEGPS_OPT_ACCURACY, NULL, (uint32)pMenuCtl );

               //IMENUCTL_AddItem( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_OPT_PAYLOAD,
               //   AEEGPS_OPT_PAYLOAD, NULL, (uint32)pMenuCtl );

               IMENUCTL_AddItem( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_OPT_DEFAULT,
                  AEEGPS_OPT_DEFAULT, NULL, (uint32)pMenuCtl );

               IMENUCTL_SetTitle( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_OPT_SETTINGS_TITLE, NULL );
               SamplePosDet_SetScreenData( pMe, (void *)pMenuCtl );
               SamplePosDet_DrawScreen( pMe, 0 );
               bHandled = TRUE;
            }
         }
      }
      else if( wParam == SCREEN_PARAM_CLOSE ) {
         IMENUCTL_Release( pMenuCtl );
         SamplePosDet_SetScreenData( pMe, 0 );
         pMe->currentHandler = 0;
         bHandled = TRUE;
      }
      else if( wParam == SCREEN_PARAM_PAINT ) {
         if( IMENUCTL_IsActive( pMenuCtl ) ) {
            IMENUCTL_Redraw( pMenuCtl );
         }
         else {
            IMENUCTL_SetActive( pMenuCtl, TRUE );  /* Also causes a menu draw */
         }
      }
      break;

   case EVT_KEY:
      if( wParam == AVK_CLR ) {
         SamplePosDet_GotoScreen( pMe, SCREENID_CONFIG, 0 );
         bHandled = TRUE;
         break;
      }
   case EVT_KEY_PRESS:
   case EVT_KEY_RELEASE:
      bHandled = IMENUCTL_HandleEvent( pMenuCtl, eCode, wParam, dwParam );
      break;

   case EVT_COMMAND:
      if( dwParam == (uint32)pMenuCtl ) {
         switch( wParam ) {
         case AEEGPS_OPT_SPEED:
         case AEEGPS_OPT_ACCURACY:
            // Set the optimization mode and save the settings
            pMe->gpsSettings.optim = (AEEGPSOpt)wParam;
            SamplePosDet_SaveGPSSettings(pMe);
            SamplePosDet_GotoScreen( pMe, SCREENID_CONFIG, 0 );
            bHandled = TRUE;
            break;
         default:
            break;
         }
      }
      break;
   }
   return bHandled;
}
예제 #21
0
/*======================================================================= 
Function: SamplePosDet_QosSettings_HandleEvent()

Description: 
   Event handler function for the QoS settings menu.

Prototype:

   boolean SamplePosDet_QosSettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)

Parameters:
   pMe: [in]. CSamplePosDet instance.
   eCode: [in]. Event code.
   wParam: [in]. Event wParam.
   dwParam: [in]. Event dwParam.

Return Value:

   TRUE - If the event was handled by this menu.
   FALSE - If the event was not handled.
 
Comments:  
   None

Side Effects: 
   None

See Also:
   None
=======================================================================*/
boolean SamplePosDet_QosSettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)
{
   boolean bHandled = FALSE;
   CTextCtlData *ptcd = SamplePosDet_GetScreenData( pMe );
   ITextCtl *pTextCtl = NULL;
   IMenuCtl *pSoftKeyMenu = NULL;
   char * pszStr;
   AECHAR * pQos;
   uint32 nResult;

   if (ptcd) {
      pSoftKeyMenu = ptcd->pSoftKey;
      pTextCtl = ptcd->pTextCtl;
   }

   switch( eCode ) {
   case EVT_SCREEN:
      if( wParam == SCREEN_PARAM_INIT ) {
         if( pTextCtl ) {  /* This is not expected to happen */
            SamplePosDet_DrawScreen( pMe, 0 );
            bHandled = TRUE;
         }
         else {
            if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_TEXTCTL, 
               (void **)&pTextCtl ) == SUCCESS ) {
               if (ISHELL_CreateInstance(pMe->theApp.m_pIShell, AEECLSID_SOFTKEYCTL,
                  (void **)&pSoftKeyMenu) == SUCCESS) {

                  IMENUCTL_AddItem( pSoftKeyMenu, SAMPLEPOSDET_RES_FILE, IDS_SOFTKEY_SAVE,
                     IDS_SOFTKEY_SAVE, NULL, (uint32)pSoftKeyMenu );

                  ITEXTCTL_SetSoftKeyMenu( pTextCtl, pSoftKeyMenu );
                  ITEXTCTL_SetTitle( pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_QOS_SETTINGS_TITLE, NULL );
                  ITEXTCTL_SetInputMode( pTextCtl, AEE_TM_NUMBERS );

                  // Load the current QoS value, if it exists
                  pszStr = MALLOC(50);
                  pQos = MALLOC(100);
                  SPRINTF(pszStr, "%d", pMe->gpsSettings.qos);
                  STRTOWSTR(pszStr, pQos, 100);
                  ITEXTCTL_SetText(pTextCtl, pQos, -1);
                  FREE(pszStr);
                  FREE(pQos);

                  ptcd = MALLOC( sizeof(CTextCtlData) );

                  ptcd->pSoftKey = pSoftKeyMenu;
                  ptcd->pTextCtl = pTextCtl;
                  SamplePosDet_SetScreenData( pMe, (void *)ptcd );
                  SamplePosDet_DrawScreen( pMe, 0 );
                  bHandled = TRUE;
               }
            }
         }
      }
      else if( wParam == SCREEN_PARAM_CLOSE ) {
         ITEXTCTL_Release( pTextCtl );
         IMENUCTL_Release( pSoftKeyMenu );
         FREE( ptcd );
         SamplePosDet_SetScreenData( pMe, 0 );
         pMe->currentHandler = 0;
         bHandled = TRUE;
      }
      else if( wParam == SCREEN_PARAM_PAINT ) {
         if( ITEXTCTL_IsActive( pTextCtl ) ) {
            ITEXTCTL_Redraw( pTextCtl );
         }
         else {
            ITEXTCTL_SetActive( pTextCtl, TRUE );  /* Also causes a menu draw */
         }
      }
      break;

   case EVT_KEY:
   case EVT_KEY_PRESS:
   case EVT_KEY_RELEASE:
      bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam );
      if (!bHandled) {
         bHandled = IMENUCTL_HandleEvent( pSoftKeyMenu, eCode, wParam, dwParam );
         
         if(!bHandled && wParam == AVK_CLR && eCode == EVT_KEY) {
            SamplePosDet_GotoScreen( pMe, SCREENID_CONFIG, 0 );
            bHandled = TRUE;
         }
      }
      break;
   case EVT_COMMAND:
      bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam );
      if (!bHandled) {
         if (IDS_SOFTKEY_SAVE == wParam) {
            // Need to validate and save the Port settings here
            pQos = ITEXTCTL_GetTextPtr(pTextCtl);
            pszStr = MALLOC(50);
            WSTRTOSTR(pQos, pszStr, 50);
            nResult = STRTOUL(pszStr, NULL, 10);
            if (nResult >= 0 && nResult <= 255) {
               pMe->gpsSettings.qos = (AEEGPSQos)nResult;
               SamplePosDet_SaveGPSSettings(pMe);
               SamplePosDet_GotoScreen(pMe, SCREENID_CONFIG, 0);
            }
            else {
               ITEXTCTL_SetTitle(pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_QOS_SETTINGS_INVALID, NULL);
               ITEXTCTL_Redraw(pTextCtl);
            }
            FREE(pszStr);
            bHandled = TRUE;
         }
      }
      break;
   }
   return bHandled;
}
예제 #22
0
/*======================================================================= 
Function: SamplePosDet_ConfigMenu_HandleEvent()

Description: 
   Event handler function for the configuration menu.

Prototype:

   boolean SamplePosDet_ConfigMenu_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)

Parameters:
   pMe: [in]. CSamplePosDet instance.
   eCode: [in]. Event code.
   wParam: [in]. Event wParam.
   dwParam: [in]. Event dwParam.

Return Value:

   TRUE - If the event was handled by this menu.
   FALSE - If the event was not handled.
 
Comments:  
   None

Side Effects: 
   None

See Also:
   None
=======================================================================*/
boolean SamplePosDet_ConfigMenu_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)
{
   boolean bHandled = FALSE;
   IMenuCtl *pMenuCtl = SamplePosDet_GetScreenData( pMe );

   switch( eCode ) {
   case EVT_SCREEN:
      if( wParam == SCREEN_PARAM_INIT ) {
         if( pMenuCtl ) {  /* This is not expected to happen */
            SamplePosDet_DrawScreen( pMe, 0 );
            bHandled = TRUE;
         }
         else {
            if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_MENUCTL, 
               (void **)&pMenuCtl ) == SUCCESS ) {

               IMENUCTL_AddItem( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_CONFIG_SERVER,
                  IDS_CONFIG_SERVER, NULL, (uint32)pMenuCtl );

               IMENUCTL_AddItem( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_CONFIG_QOS,
                  IDS_CONFIG_QOS, NULL, (uint32)pMenuCtl );

               IMENUCTL_AddItem( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_CONFIG_OPT,
                  IDS_CONFIG_OPT, NULL, (uint32)pMenuCtl );

               IMENUCTL_SetTitle( pMenuCtl, SAMPLEPOSDET_RES_FILE, IDS_CONFIG_TITLE, NULL );
               SamplePosDet_SetScreenData( pMe, (void *)pMenuCtl );
               SamplePosDet_DrawScreen( pMe, 0 );
               bHandled = TRUE;
            }
         }
      }
      else if( wParam == SCREEN_PARAM_CLOSE ) {
         IMENUCTL_Release( pMenuCtl );
         SamplePosDet_SetScreenData( pMe, 0 );
         pMe->currentHandler = 0;
         bHandled = TRUE;
      }
      else if( wParam == SCREEN_PARAM_PAINT ) {
         if( IMENUCTL_IsActive( pMenuCtl ) ) {
            IMENUCTL_Redraw( pMenuCtl );
         }
         else {
            IMENUCTL_SetActive( pMenuCtl, TRUE );  /* Also causes a menu draw */
         }
      }
      break;

   case EVT_KEY:
      if( wParam == AVK_CLR ) {
         SamplePosDet_GotoScreen( pMe, SCREENID_MAINMENU, 0 );
         bHandled = TRUE;
         break;
      }
   case EVT_KEY_PRESS:
   case EVT_KEY_RELEASE:
      bHandled = IMENUCTL_HandleEvent( pMenuCtl, eCode, wParam, dwParam );
      break;

   case EVT_COMMAND:
      if( dwParam == (uint32)pMenuCtl ) {
         switch( wParam ) {
         case IDS_CONFIG_SERVER:
            SamplePosDet_GotoScreen( pMe, SCREENID_SERVER_SETTINGS, 0 );
            bHandled = TRUE;
            break;
         case IDS_CONFIG_QOS:
            SamplePosDet_GotoScreen( pMe, SCREENID_QOS_SETTINGS, 0 );
            bHandled = TRUE;
            break;
         case IDS_CONFIG_OPT:
            SamplePosDet_GotoScreen( pMe, SCREENID_OPTIM_SETTINGS, 0 );
         default:
            break;
         }
      }
      break;
   }
   return bHandled;
}
예제 #23
0
/*======================================================================= 
Function: SamplePosDet_PDESettings_HandleEvent()

Description: 
   Event handler function for the PDE settings menu.

Prototype:

   boolean SamplePosDet_PDESettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)

Parameters:
   pMe: [in]. CSamplePosDet instance.
   eCode: [in]. Event code.
   wParam: [in]. Event wParam.
   dwParam: [in]. Event dwParam.

Return Value:

   TRUE - If the event was handled by this menu.
   FALSE - If the event was not handled.
 
Comments:  
   None

Side Effects: 
   None

See Also:
   None
=======================================================================*/
boolean SamplePosDet_PDESettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)
{
   AECHAR * pServer;
   uint32 nResult;
   boolean bHandled = FALSE;
   CTextCtlData *ptcd = SamplePosDet_GetScreenData( pMe );
   ITextCtl *pTextCtl = NULL;
   IMenuCtl *pSoftKeyMenu = NULL;
   char * pszStr;

   if (ptcd) {
      pSoftKeyMenu = ptcd->pSoftKey;
      pTextCtl = ptcd->pTextCtl;
   }

   switch( eCode ) {
   case EVT_SCREEN:
      if( wParam == SCREEN_PARAM_INIT ) {
         if( pTextCtl ) {  /* This is not expected to happen */
            SamplePosDet_DrawScreen( pMe, 0 );
            bHandled = TRUE;
         }
         else {
            if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_TEXTCTL, 
               (void **)&pTextCtl ) == SUCCESS ) {
               if (ISHELL_CreateInstance(pMe->theApp.m_pIShell, AEECLSID_SOFTKEYCTL,
                  (void **)&pSoftKeyMenu) == SUCCESS) {

                  IMENUCTL_AddItem( pSoftKeyMenu, SAMPLEPOSDET_RES_FILE, IDS_SOFTKEY_SAVE,
                     IDS_SOFTKEY_SAVE, NULL, (uint32)pSoftKeyMenu );

                  ITEXTCTL_SetSoftKeyMenu( pTextCtl, pSoftKeyMenu );
                  ITEXTCTL_SetTitle( pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_PDE_SETTINGS_TITLE, NULL );
                  ITEXTCTL_SetInputMode( pTextCtl, AEE_TM_NUMBERS );

                  // Load the current IP address, if it exists
                  if (AEEGPS_SERVER_IP == pMe->gpsSettings.server.svrType) {
                     pszStr = MALLOC(50);
                     INET_NTOA(pMe->gpsSettings.server.svr.ipsvr.addr, pszStr, 50);
                     pServer = MALLOC(100);
                     STRTOWSTR(pszStr, pServer, 100);
                     ITEXTCTL_SetText(pTextCtl, pServer, -1);
                     FREE(pszStr);
                     FREE(pServer);
                  }

                  ptcd = MALLOC( sizeof(CTextCtlData) );
                  
                  ptcd->pSoftKey = pSoftKeyMenu;
                  ptcd->pTextCtl = pTextCtl;
                  SamplePosDet_SetScreenData( pMe, (void *)ptcd );
                  SamplePosDet_DrawScreen( pMe, 0 );
                  bHandled = TRUE;
               }
            }
         }
      }
      else if( wParam == SCREEN_PARAM_CLOSE ) {
         ITEXTCTL_Release( pTextCtl );
         IMENUCTL_Release( pSoftKeyMenu );
         FREE( ptcd );
         SamplePosDet_SetScreenData( pMe, 0 );
         pMe->currentHandler = 0;
         bHandled = TRUE;
      }
      else if( wParam == SCREEN_PARAM_PAINT ) {
         if( ITEXTCTL_IsActive( pTextCtl ) ) {
            ITEXTCTL_Redraw( pTextCtl );
         }
         else {
            ITEXTCTL_SetActive( pTextCtl, TRUE );  /* Also causes a menu draw */
         }
      }
      break;

   case EVT_KEY:
   case EVT_KEY_PRESS:
   case EVT_KEY_RELEASE:
      bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam );
      if (!bHandled) {
         bHandled = IMENUCTL_HandleEvent( pSoftKeyMenu, eCode, wParam, dwParam );
         
         if(!bHandled && wParam == AVK_CLR && eCode == EVT_KEY) {
            SamplePosDet_GotoScreen( pMe, SCREENID_SERVER_SETTINGS, 0 );
            bHandled = TRUE;
         }
      }
      break;

   case EVT_COMMAND:
      bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam );
      if (!bHandled) {
         if (IDS_SOFTKEY_SAVE == wParam) {   // Save the new IP address
            pServer = ITEXTCTL_GetTextPtr(pTextCtl);
            pszStr = MALLOC(50);
            WSTRTOSTR(pServer, pszStr, 50);
            if (INET_ATON(pszStr, &nResult)) {
               pMe->gpsSettings.server.svrType = AEEGPS_SERVER_IP;
               pMe->gpsSettings.server.svr.ipsvr.addr = nResult;
               SamplePosDet_SaveGPSSettings(pMe);
               SamplePosDet_GotoScreen(pMe, SCREENID_PORT_SETTINGS, 0);
            }
            else {
               ITEXTCTL_SetTitle(pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_PDE_SETTINGS_INVALID, NULL);
               ITEXTCTL_Redraw(pTextCtl);
            }
            FREE(pszStr);
            // add code to save the new PDE IP address
            bHandled = TRUE;
         }
      }
      break;
   }
   return bHandled;
}
예제 #24
0
int CSettings_PopulateMainContainer(CSettings* pMe) 
{
	int result = 0;
	ImageStaticWidget* imageWidget = NULL;
	IMenuModel * iMenuModal = NULL;
	IWidget* wItemList;
	IWidget* containerWidget = NULL;
	IWidget* pScrollBar = NULL;
	WExtent we;
	WidgetProp wp;
	IFont *piFont = 0;
	
	result = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_IMAGESTATICWIDGET, (void**)&imageWidget);
	result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MENUMODEL, (void**)&iMenuModal);
  	result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_LISTWIDGET, (void**)&wItemList);
	result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_SCROLLBARWIDGET, (void**)&pScrollBar);
	result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FONTSYSBOLD, (void**)&piFont);
	ISHELL_GetDeviceInfo(pMe->pIShell, &pMe->DeviceInfo);
	
	//load the strings
	pMe->str1 = (AECHAR*) MALLOC(20);
	pMe->str2 = (AECHAR*) MALLOC(20);

	result += ISHELL_LoadResString(pMe->pIShell, RIPPLEVAULT_RES_FILE, IDS_RANGE, pMe->str1, 20);
	result += ISHELL_LoadResString(pMe->pIShell, RIPPLEVAULT_RES_FILE, IDS_SHEDULER, pMe->str2, 20);
	
	//load the images
	pMe->imageInfo1.pwText = (AECHAR*)pMe->str1;
	pMe->imageInfo2.pwText = (AECHAR*)pMe->str2;

	IMENUMODEL_Add(iMenuModal,&pMe->imageInfo1,1,MMF_ENABLED);
	IMENUMODEL_Add(iMenuModal,&pMe->imageInfo2,2,MMF_ENABLED);

	//set the vidget to act as a menu modal vidget
	IWIDGET_SetModel(wItemList, IMENUMODEL_TO_IMODEL(iMenuModal));

	//set the picklist widget properties
	IWIDGET_SetBorderWidth(wItemList, 0);
	IWIDGET_SetItemHeight(wItemList, 30);
	IWIDGET_SetItemWidth(wItemList, pMe->DeviceInfo.cxScreen);
	IWIDGET_SetHintCols(wItemList, 5);
	IWIDGET_GetPreferredExtent(wItemList, &we);
	IWIDGET_SetExtent(wItemList, &we);

	IWIDGET_SetFont((IWidget *)imageWidget, piFont);
	IWIDGET_SetSelectedShadowOffset((IWidget *)imageWidget,2);
	IWIDGET_SetShadowColor((IWidget *)imageWidget,MAKE_RGB(122,122,122));
	IWIDGET_SetSelectedActiveBGColor((IWidget*)imageWidget, MAKE_RGB(128,128,255));
	IWIDGET_SetProperty(pScrollBar, PROP_ACTIVE_SCROLLCOLOR, MAKE_RGB(128,128,255));
	IDECORATOR_SetWidget((IDecorator*)pScrollBar, (IWidget *)wItemList);
	IDECORATOR_SetWidget((IDecorator*)wItemList, (IWidget *)imageWidget);

	// get the view model of the wItemList and register a listener 
	// in order to to pick up operator selection
	{
		IModel* pickListViewModel = NULL;
		IWIDGET_GetViewModel(wItemList, &pickListViewModel);
		IMODEL_AddListenerEx(pickListViewModel, &pMe->menuListener, (PFNLISTENER)MenuModal_EventHandler, pMe);
		IMODEL_Release(pickListViewModel);
	}
	wp.bVisible = TRUE;
	wp.prop = 1;
	IPROPCONTAINER_Insert(pMe->mainContainer, pScrollBar, WIDGET_ZNORMAL, &wp);

	//set WID_FORM to the container
	result = IPROPCONTAINER_QueryInterface(pMe->mainContainer, AEEIID_WIDGET, (void**)&pMe->containerWidget);
	
	HANDLERDESC_Init(&pMe->settingsMenuHandler, CSettings_HandleEvent, pMe, CSettings_Delete);
	IFORM_SetHandler((IForm*)pMe->csettings, &pMe->settingsMenuHandler);	
	if(result ==0) 
	{
		IFORM_SetWidget((IForm*)pMe->csettings, WID_FORM, pMe->containerWidget);
		IWIDGET_MoveFocus(pMe->containerWidget, wItemList);
	}

	IWIDGET_Release((IWidget*)imageWidget);
	IMENUMODEL_Release(iMenuModal);
	IWIDGET_Release(wItemList);
	IWIDGET_Release(pScrollBar);
	if (pMe->containerWidget)
		IWIDGET_Release(pMe->containerWidget);
	
	RELEASEIF(piFont);
		
	if(result != 0)
		return EFAILED;
	
	return result;
}
예제 #25
0
/*===========================================================================
===========================================================================*/
boolean SamplePosDet_GetGPSInfo_HandleEvent( CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam )
{
   boolean bHandled = FALSE;
   struct _GetGPSInfo *pGetGPSInfo = SamplePosDet_GetScreenData( pMe );

   switch( eCode ) {

   case EVT_SCREEN:
      if( wParam == SCREEN_PARAM_INIT ) {
         if( pGetGPSInfo == 0 ) {

            pGetGPSInfo = MALLOC( sizeof( struct _GetGPSInfo ) );

            if( pGetGPSInfo ) {
               int nErr = SUCCESS;
               ZEROAT( pGetGPSInfo );

               pGetGPSInfo->theInfo.server = pMe->gpsSettings.server;
               pGetGPSInfo->theInfo.qos = pMe->gpsSettings.qos;
               pGetGPSInfo->theInfo.optim = pMe->gpsSettings.optim;

               pGetGPSInfo->wMainMenuEntry = (uint16)dwParam;
               SamplePosDet_SetScreenData( pMe, (void *)pGetGPSInfo );

               if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_POSDET,
                  (void **)&pGetGPSInfo->pPosDet ) == SUCCESS ) {

                  CALLBACK_Init( &pGetGPSInfo->cbPosDet, SamplePosDet_GetGPSInfo_Callback, pMe );
                  CALLBACK_Init( &pGetGPSInfo->cbProgressTimer, SamplePosDet_GetGPSInfo_SecondTicker, pMe );

                  nErr = Track_Init( pMe->theApp.m_pIShell, pGetGPSInfo->pPosDet, 
                                        &pGetGPSInfo->cbPosDet, &pGetGPSInfo->pts );
                  if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_ONE_SHOT ) {
                     nErr = Track_Start( pGetGPSInfo->pts, TRACK_NETWORK, 1, 0, &pGetGPSInfo->theInfo );
                  }
                  else if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_TRACK_LOCAL ) {
                     nErr = Track_Start( pGetGPSInfo->pts, TRACK_LOCAL, 0, 0, &pGetGPSInfo->theInfo );
                  }
                  else if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_TRACK_NETWORK ) {
                     nErr = Track_Start( pGetGPSInfo->pts, TRACK_NETWORK, 0, 0, &pGetGPSInfo->theInfo );
                  }
                  else if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_TRACK_AUTO ) {
                     nErr = Track_Start( pGetGPSInfo->pts, TRACK_AUTO, 0, 0, &pGetGPSInfo->theInfo );
                  }
                  else {
                     nErr = EFAILED;
                  }
 
                  SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_ALL );
                  if( nErr != SUCCESS ) {
                     pGetGPSInfo->theInfo.nErr = nErr;
                     SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_ERROR );
                  }
                  else {
                     ISHELL_SetTimerEx( pMe->theApp.m_pIShell, 1000, &pGetGPSInfo->cbProgressTimer );
                  }

                  bHandled = TRUE;
               }
            }
         }
         if( !bHandled ) {
            SamplePosDet_GotoScreen( pMe, SCREENID_MAINMENU, 0 );
            bHandled = TRUE;
         }
      }
      else if( wParam == SCREEN_PARAM_CLOSE ) {
         if( pGetGPSInfo ) {
            if( pGetGPSInfo->pPosDet ) {
               CALLBACK_Cancel( &pGetGPSInfo->cbProgressTimer );
               CALLBACK_Cancel( &pGetGPSInfo->cbPosDet );
               IPOSDET_Release( pGetGPSInfo->pPosDet );
            }
            FREE( pGetGPSInfo );
         }
         SamplePosDet_SetScreenData( pMe, 0 );
         pMe->currentHandler = 0;
         bHandled = TRUE;
      }
      else if( wParam == SCREEN_PARAM_PAINT ) {
         if( !pGetGPSInfo->bPaused ) {
            SamplePosDet_GetGPSInfo_Paint( pMe, (GetGPSInfo_PaintRegions)dwParam );
         }
         bHandled = TRUE;
      }
      break;

   case EVT_KEY:
      if( wParam == AVK_CLR || wParam == AVK_SOFT2) {

		 Track_Stop(pGetGPSInfo->pts);

		if (pGetGPSInfo) {
			if (pGetGPSInfo->pPosDet) {
				CALLBACK_Cancel(&pGetGPSInfo->cbProgressTimer);
				CALLBACK_Cancel(&pGetGPSInfo->cbPosDet);
				IPOSDET_Release(pGetGPSInfo->pPosDet);
			}
			FREE(pGetGPSInfo);
		}

         SamplePosDet_GotoScreen( pMe, SCREENID_MAINMENU, 0 );

         bHandled = TRUE;
      }
      break;

   case EVT_DIALOG_START:
      pGetGPSInfo->bPaused = TRUE;
      bHandled = TRUE;
      break;

   case EVT_DIALOG_END:
      pGetGPSInfo->bPaused = FALSE;
      SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_ALL );
      bHandled = TRUE;
      break;

   case EVT_COMMAND:
      break;
   }

   return bHandled;
}
예제 #26
0
/*===========================================================================

FUNCTION: ABR_GetContactRec

DESCRIPTION:
  This function get all record from address book and show every record as a manu item

PARAMETERS:
  pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains 
    information specific to this applet. 
  pMenu[out] - menu show all address book menu  
  pnTotal[out] - all records count of address book

DEPENDENCIES:
   None

RETURN VALUE:
  AEE_SUCCESS -  successfully enumate all record in address book
  other - fail


SIDE EFFECTS:
   None
===========================================================================*/
int32 ABR_GetContactRec( CAddrBookRuim * pMe, AEECLSID ContactCLS, IMenuCtl* pMenu, uint32* pnTotal)
{
    IAddrBook *pb;
    IAddrRec *pR;
    int nRet = 0;
    uint32 nTempTotal;
    boolean bFlgNameGet;
    boolean bFlgNumGet;

    AECHAR *aszNum, *aszName;


    if(pMe==NULL || pMe->pIShell==NULL || pMenu==NULL || pnTotal==NULL)
    {
        return (-1);
    }

    aszNum = (AECHAR *)MALLOC(MAX_CONTACT_NUM_SIZE*sizeof(AECHAR));
    aszName = (AECHAR *)MALLOC(MAX_CONTACT_NAME_SIZE*sizeof(AECHAR));

    
    if(aszNum==NULL ||  aszName==NULL)
    {
        return (-2);
    }

    // Clear any items from the IMenuCtl
    IMENUCTL_Reset( pMenu );
    IMENUCTL_SetRect( pMenu, &pMe->m_rScreenRect );
    IMENUCTL_SetTitle( pMenu, ADDRBOOKRUIM_RES_FILE, IDS_VIEW_MENU, NULL);

    nTempTotal = 0;

    if(!ISHELL_CreateInstance(pMe->pIShell, ContactCLS, (void **)&pb))
    {
        nRet = IADDRBOOK_EnumRecInit(pb,  AEE_ADDR_CAT_NONE, AEE_ADDRFIELD_NONE, NULL, 0);
        if(nRet == AEE_SUCCESS)
        {
            while((pR = IADDRBOOK_EnumNextRec(pb)) != NULL)
            {
                AEEAddrField *ptr = NULL;
                int i;
                int nFields;

                bFlgNameGet = FALSE;
                bFlgNumGet = FALSE;
                MEMSET( aszName, 0, MAX_CONTACT_NAME_SIZE*sizeof(AECHAR));
                MEMSET( aszNum,  0, MAX_CONTACT_NUM_SIZE*sizeof(AECHAR));
                nFields= IADDRREC_GetFieldCount(pR);
                for(i = 0; i < nFields; i++)
                {
                    ptr = IADDRREC_GetField(pR,i);
                    DBGPRINTF("lintao fID   =%d", ptr->fID);
                    // find name field and save it;
                    if (   ptr->fID == AEE_ADDRFIELD_NAME  
                       ||ptr->fID == AEE_ADDRFIELD_FIRSTNAME
                       ||ptr->fID == AEE_ADDRFIELD_LASTNAME
                       ||ptr->fID == AEE_ADDRFIELD_NICKNAME)
                    { 
                        if(bFlgNameGet==FALSE)
                        {
                            bFlgNameGet = TRUE;
                            WSTRCPY(aszName, ptr->pBuffer);
                        }
                    }

                    // find number field and save it;
                    if (    ptr->fID >= AEE_ADDRFIELD_PHONE_WORK
                        && ptr->fID <= AEE_ADDRFIELD_PHONE_OTHER)
                    { 
                        if(bFlgNumGet==FALSE)
                        {
                            bFlgNumGet = TRUE;
                            WSTRCPY(aszNum, ptr->pBuffer);
                        }
                    }

                }

                if(bFlgNameGet && bFlgNumGet) 
                {
                    nTempTotal++;
                    IMENUCTL_AddItem(pMenu, 
                                     NULL, 
                                     0,  
                                     ABR_REC_LIST_ID + IADDRREC_GetRecID(pR), 
                                     aszName, 
                                     NULL);
                }
            }                  
        }

        IADDRBOOK_Release(pb);
    }
    else
    {
        nRet=1; // error : ISHELL_CreateInstance fail
    }

    *pnTotal = nTempTotal;
    IMENUCTL_SetActive( pMenu, TRUE );

    FREEIF(aszNum);
    FREEIF(aszName);
    return nRet;
}
예제 #27
0
파일: calldemo.c 프로젝트: virqin/brew_code
/*===========================================================================

FUNCTION CallDemoApp_InitAppData

DESCRIPTION
   This function initializes app specific data.

PROTOTYPE:
  static boolean CallDemoApp_InitAppData(IApplet* pi);

PARAMETERS:
  pi [in]: Pointer to the IApplet structure.

DEPENDENCIES
    None.

RETURN VALUE
    TRUE: If the app has app data is allocated and initialized successfully
    FALSE: Either app data could not be allocated or initialized

SIDE EFFECTS
    None.
===========================================================================*/
static boolean CallDemoApp_InitAppData(IApplet* pi)
{
   CallDemoApp * pMe = (CallDemoApp*)pi;
   int charHeight, pnAscent, pnDescent;
   AEEDeviceInfo di;
   int nErr;

   // Make sure the pointers we'll be using are valid
   if (pMe == NULL || pMe->a.m_pIShell == NULL)
     return FALSE;

   pMe->m_pIMenu = NULL;

   // Determine the amount of available screen space
   ZEROAT(&di);
   di.wStructSize = sizeof(di);
   ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&di);

   pMe->m_rc.dx = di.cxScreen;
   pMe->m_rc.dy = di.cyScreen;
   // Determine the height of a line of text
   charHeight = IDISPLAY_GetFontMetrics (pMe->a.m_pIDisplay, AEE_FONT_NORMAL,
      &pnAscent, &pnDescent);

   // Number of available lines equals the available screen
   // space divided by the height of a line, minus 3 for the
   // lines we always print at the top and bottom of the screen
   pMe->m_cMaxLine = (di.cyScreen / charHeight) - 3;

   pMe->m_pCallMgr = NULL;
   pMe->m_pOutgoingCall = NULL;
   pMe->m_pIncomingCall = NULL;
   nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_CALLMGR, (void**) &pMe->m_pCallMgr);
   DBGPRINTF("CreateInst AEECLSID_CALLMGR ret %d", nErr);
   if(nErr != AEE_SUCCESS)
   {
       return FALSE;
   }

   if(SUCCESS != ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_TELEPHONE, (void **) &pMe->m_pTelephone)) 
   {
       return FALSE;
   }

   if(SUCCESS != ITELEPHONE_QueryInterface(pMe->m_pTelephone, AEEIID_MODEL, (void **) &pMe->m_pModel)) 
   {
       return FALSE;
   }

   LISTENER_Init((ModelListener *)&pMe->m_lisPhone, MyPhoneListener, (void *) pMe);
   IMODEL_AddListener(pMe->m_pModel, (ModelListener *) &pMe->m_lisPhone);

#ifdef EVENT_AUTO_GET
   pMe->m_UserAnswerEvent = ISHELL_RegisterEvent(pMe->a.m_pIShell, "user anwser event", NULL );
   pMe->m_UserRedirectEvent = ISHELL_RegisterEvent(pMe->a.m_pIShell, "user redirect event", NULL );
#endif

   pMe->m_isDTMFItem = FALSE;
   pMe->m_isParty3Item= FALSE;
   pMe->m_isRedirectItem = FALSE;

   return TRUE;
}
예제 #28
0
/*===========================================================================

FUNCTION: ABR_UpdateContactRec

DESCRIPTION:
  This function update record whose id is wID

PARAMETERS:
  pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains 
    information specific to this applet. 
  wID[in] - record id which is want to be update
  pTextName[in] - name field which record will change to
  pTextNum[in] - number field which record will change to

DEPENDENCIES:
   None

RETURN VALUE:
  AEE_SUCCESS -  IADDRREC_UpdateAllFields operate successfully
  other - fail


SIDE EFFECTS:
   None
===========================================================================*/
int32 ABR_UpdateContactRec( CAddrBookRuim *pMe, AEECLSID ContactCLS, uint16 wID, AECHAR *pTextName, AECHAR *pTextNum)
{
    int nRet = 0;
    IAddrBook *pb;
    IAddrRec *pR;
    AEEAddrField field;
    boolean bFlgNameGet;
    boolean bFlgNumGet;
    
    if(pMe==NULL || pMe->pIShell==NULL || pTextName==NULL || pTextNum==NULL)
    {
        return (-1);
    }

    if(!ISHELL_CreateInstance(pMe->pIShell, ContactCLS, (void **)&pb))
    {
        pR =IADDRBOOK_GetRecByID(pb, wID);
        if(pR)
        {
                int nFields;
                int i;
                AEEAddrField *ptr = NULL;
                bFlgNameGet = FALSE;
                bFlgNumGet = FALSE;
                nFields= IADDRREC_GetFieldCount(pR);
                for(i = 0; i < nFields; i++)
                {
                    ptr = IADDRREC_GetField(pR,i);
                    DBGPRINTF("lintao fID   =%d", ptr->fID);
                    DBGPRINTF("lintao fType=%d", ptr->fType);

                    // find name field and save it;
                    if (   ptr->fID == AEE_ADDRFIELD_NAME  
                       ||ptr->fID == AEE_ADDRFIELD_FIRSTNAME
                       ||ptr->fID == AEE_ADDRFIELD_LASTNAME
                       ||ptr->fID == AEE_ADDRFIELD_NICKNAME)
                    { 
                        if(bFlgNameGet==FALSE)
                        {
                            bFlgNameGet = TRUE;
                            field.fID = ptr->fID;
                            field.fType = ptr->fType;
                            field.pBuffer = pTextName;
                            field.wDataLen = (WSTRLEN(pTextName)+1)*sizeof(AECHAR);
                            IADDRREC_UpdateField(pR, i, &field);
                        }
                    }

                    // find number field and save it;
                    if (    ptr->fID >= AEE_ADDRFIELD_PHONE_WORK  
                        && ptr->fID <= AEE_ADDRFIELD_PHONE_OTHER)
                    { 
                        if(bFlgNumGet==FALSE)
                        {
                            bFlgNumGet = TRUE;
                            field.fID = ptr->fID;
                            field.fType = ptr->fType;
                            field.pBuffer = pTextNum;
                            field.wDataLen = (WSTRLEN(pTextNum)+1)*sizeof(AECHAR);
                            IADDRREC_UpdateField(pR, i, &field);
                        }
                    }
                }

                // ÐÕÃûºÍºÅÂë¾ùÓÐ
                if(bFlgNameGet && bFlgNumGet) 
                {
                    nRet=0;
                }
                else
                {
                    nRet=4;
                }
        }
        else
        {
            nRet=2;  // IADDRBOOK_GetRecByID fail
        }

        IADDRBOOK_Release(pb);
    }
    else
    {
        nRet = 3;
    }
    DBGPRINTF("nRet=%d", nRet);
    return nRet;
}
예제 #29
0
// ================================================================================
// FUNCTION		: GetContactList
// DESCRIPTION	: Get the addressbook contacts 
// ================================================================================
int CDbHandler::GetContactList(AECHAR **pszContactList)
{
	
	//create address book
	IAddrBook * pIAddrBook=NULL;
	if ( SUCCESS != ISHELL_CreateInstance(m_pIShell, AEECLSID_ADDRBOOK, (void **)&pIAddrBook))
	{
		return 0;
	}

	//get the number of records in addressbook and create a buffer to hold the names
	int nSize = IADDRBOOK_GetNumRecs(pIAddrBook);
	*pszContactList = (AECHAR*)MALLOC(nSize*100*sizeof(AECHAR));//assume approximate name length + mobile number is 100
	if ( NULL==*pszContactList ) goto error;

	if( AEE_SUCCESS == IADDRBOOK_EnumRecInit(pIAddrBook,AEE_ADDR_CAT_NONE, AEE_ADDRFIELD_NONE,NULL,0) )
	{
		IAddrRec* rec=NULL;

		while( NULL != (rec=IADDRBOOK_EnumNextRec(pIAddrBook)) )
		{
			AEEAddrField* pField;

			int noOfFilelds = IADDRREC_GetFieldCount(rec);

			for ( int i=0; i<noOfFilelds; i++)
			{
				pField = IADDRREC_GetField(rec, i);
				//append first name and last name to the buffer
				if ( SM_ADDRFIELD_FIRSTNAME==pField->fID )
				{
					WSTRCAT(*pszContactList, (AECHAR*)pField->pBuffer);
					WSTRCAT(*pszContactList, L" ");
				}

				//append the last name to the buffer
				if ( SM_ADDRFIELD_LASTNAME==pField->fID )
				{
					WSTRCAT(*pszContactList, (AECHAR*)pField->pBuffer);
					
				}

				//append the mobile number
				if ( SM_ADDRFIELD_MOBILE==pField->fID )
				{
					WSTRCAT(*pszContactList, L":");
					WSTRCAT(*pszContactList, (AECHAR*)pField->pBuffer);
					
				}
			}

			WSTRCAT(*pszContactList, L";");

			IADDRREC_Release(rec);
		
		}

	}

error:
	IADDRBOOK_Release(pIAddrBook);

	return nSize;
	
}
예제 #30
0
파일: isms.c 프로젝트: virqin/brew_code
/*===========================================================================

FUNCTION ISmsApp_InitAppData

DESCRIPTION
   This function initializes app specific data.

PROTOTYPE:
  static boolean ISmsApp_InitAppData(IApplet* pi);

PARAMETERS:
  pi [in]: Pointer to the IApplet structure.

DEPENDENCIES
    None.

RETURN VALUE
    TRUE: If the app has app data is allocated and initialized successfully
    FALSE: Either app data could not be allocated or initialized

SIDE EFFECTS
    None.
===========================================================================*/
static boolean ISmsApp_InitAppData(IApplet* pi)
{
    ISmsApp * pMe = (ISmsApp*)pi;
    int charHeight, pnAscent, pnDescent;
    AEEDeviceInfo di;
    int nErr;
    int i;
    AECHAR szwStr[32];
    char szNumber[32];

#define MAX_ENC 32
    uint32 *EncodingMoSms;
    uint32 nSize;

    IModel * pIModel = NULL;
    // Make sure the pointers we'll be using are valid
    if (pMe == NULL || pMe->a.m_pIShell == NULL)
        return FALSE;

    pMe->m_pIMenu = NULL;
    pMe->m_pISMSMsg = NULL;
    pMe->m_pISMS      = NULL;
    pMe->m_pISMSStorage = NULL;



    // Determine the amount of available screen space
    ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&di);

    // Determine the height of a line of text
    charHeight = IDISPLAY_GetFontMetrics (pMe->a.m_pIDisplay, AEE_FONT_NORMAL,
                                          &pnAscent, &pnDescent);

    // Number of available lines equals the available screen
    // space divided by the height of a line, minus 3 for the
    // lines we always print at the top and bottom of the screen
    pMe->m_cMaxLine = (di.cyScreen / charHeight) - 3;

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

    if ((ISMS_GetEncodingsAvailableForMOSMS(pMe->m_pISMS, NULL, (uint32*)&nSize) == SUCCESS) &&
            ((EncodingMoSms = (uint32*)MALLOC(nSize)) != NULL) &&
            (ISMS_GetEncodingsAvailableForMOSMS(pMe->m_pISMS, EncodingMoSms, (uint32*)&nSize) == SUCCESS))
    {
        nSize = nSize/sizeof(uint32);
        DBGPRINTF("ISMS_GetEncodingsAvailableForMOSMS");
        DBGPRINTF("size Encode ret:%d", nSize);
        for(i=0; i<nSize; i++)
        {
            DBGPRINTF("en[%d]=%x", i, EncodingMoSms[i]);
        }
    }

    if ((nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMSSTORAGE, (void**)&pMe->m_pISMSStorage)) != SUCCESS)
    {
        DBGPRINTF("CreateInstance SMSSTORAGE ret %d", nErr);
        return FALSE;
    }

    if (pMe->m_pISMSStorage &&
            (SUCCESS == ISMSSTORAGE_QueryInterface(pMe->m_pISMSStorage, AEEIID_MODEL, (void**)&pIModel)))
    {
        IMODEL_AddListenerEx(pIModel, &pMe->m_SMSStorageModelListener, (PFNLISTENER)OATSMSStorage_ModelListener, pMe);
        IMODEL_Release(pIModel);
        pIModel = NULL;
    }

    ISHELL_LoadResString(pMe->a.m_pIShell, ISMS_RES_FILE, IDS_SMS_TAG, szwStr, sizeof(szwStr));
    WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));
    pMe->m_tag = STRTOUL(szNumber, NULL, 10);

    ISHELL_LoadResString(pMe->a.m_pIShell, ISMS_RES_FILE, IDS_SMS_MT, szwStr, sizeof(szwStr));
    WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));
    pMe->m_mt = STRTOUL(szNumber, NULL, 10);

    return TRUE;
}