示例#1
0
static void MemChecker_Button_Listener(MemChecker *pMe, XEvent *pEvent)
{
    if (XEVT_COMMAND == pEvent->nCode)
    {
        switch(pEvent->dwParam)
        {
        case IDS_BEGIN_WATCH:
        case IDS_RUN_AND_WATCH:
            {
                int nErr = SUCCESS;
                MemHookInitParam sParam = {0};
                AEEAppInfo ai = {0};

                if (ISHELL_QueryClass(pMe->a.m_pIShell, pMe->m_clsCheckedApp, &ai)) {
                    sParam.pIShell = pMe->a.m_pIShell;
                    sParam.clsApp = pMe->m_clsCheckedApp;
                    sParam.eOutputMode = pMe->m_eOutputMode;
                    MemHook_Install(&sParam);

                    if (IDS_RUN_AND_WATCH == pEvent->dwParam) {
                        nErr = ISHELL_StartApplet(pMe->a.m_pIShell, pMe->m_clsCheckedApp);
                    }
                } else {
                    nErr = ECLASSNOTSUPPORT;
                }

                if (SUCCESS == nErr)
                {
                    pMe->m_bBackground = TRUE; // Go background
                    ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE);
                    MemChecker_WaitForAppStartup(pMe);
                }
                else // Failed
                {
                    MemHook_Uninstall();

                    if (IDS_BEGIN_WATCH == pEvent->dwParam) {
                        XMessageBox(
                            L"Please set a valid applet class id in \"config.ini\".", 
                            L"Error");
                    } else {
                        XMessageBox(
                            L"Can not start the applet. "
                            L"Please set a valid applet class id in \"config.ini\".", 
                            L"Error");
                    }
                }
            }

            break;
        case IDS_ABOUT:
            XMessageBox(
                L"BREW Memory Leak Checker\n\n"
                L"Version: 1.0.1\n\n"
                L"Copyright 2010-2012 by DXJ. All Rights Reserved.\n\n"
                L"Email: [email protected]", 
                L"About me");
            break;

        default:
            break;
        }
    }
}
示例#2
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 lizard_HandleEvent(lizard* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
	int legal = 0;
	 
    switch (eCode) 
	{
	    
        // App is told it is starting up
        case EVT_APP_START:
			legal = lizard_CheckDateLegal(pMe->a.m_pIShell); 
			if(legal > 0){
				DBGPRINTF("this time is legal ");
				 
				if( pMe->startType == STARTWITHSYSTEM){
					 pMe->startType = 0;
					
					pMe->glbVar->appState = BACKGROUND;
					IPOSITIONTHREAD_Start(pMe->pPosThread);
				} 
				IMAINUI_Show(pMe->pMainUI); 
			}else{
				DBGPRINTF("this time is illegal "); 
				return ISHELL_MessageBoxText(pMe->a.m_pIShell, L"illegal", L"current time is illegal");
			}
			DBGPRINTF("EVT_APP_START.................................");
            return(TRUE);

		
        // App is told it is exiting
        case EVT_APP_STOP:
           DBGPRINTF("......................EVT_APP_STOP...........");
			pMe->glbVar->appState = BACKGROUND;
			*(boolean *)dwParam = FALSE; 
      		return(TRUE);
			

        // App is being suspended 
        case EVT_APP_SUSPEND:
		    // Add your code here...
			DBGPRINTF("......................EVT_APP_SUSPEND...........");
			
      		return(TRUE);


        // App is being resumed
        case EVT_APP_RESUME:
			 
			switch (pMe->glbVar->appState)
			{ 
			case APP_STATE_POSUI:
			 
				IMAINUI_ShowPosUI(pMe->pMainUI);
				break;
			default :
				IMAINUI_Show(pMe->pMainUI);
				break;
			}
      		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:
		    DBGPRINTF("============receive event: EVT_KEY");
			switch (pMe->glbVar->appState)
			{
			case APP_STATE_POSUI:
			case APP_STATE_MAINUI:
				if(IMAINUI_HandleEvent(pMe->pMainUI, eCode, wParam, dwParam)){
					return TRUE;
				}
			}
      		return(TRUE);

		case EVT_COMMAND:
			DBGPRINTF("===================EVT_COMMAND==============================");
			switch (wParam)
			{
				case EVT_COMMAND_SHOWMAINUI:
					
					IMAINUI_Show(pMe->pMainUI);
					break;
				case EVT_COMMAND_LOCATE:
				 
					if(dwParam == IDS_POSUI_ACTION_STOP){//用户点击了停止定位按钮
						
						IPOSITIONTHREAD_Stop(pMe->pPosThread);
					 
					}else{//用户点击了开始定位按钮
						IPOSITIONTHREAD_Start(pMe->pPosThread);
					}
					break;
				case EVT_COMMAND_LOCATE_RESTART: //重启定位线程
					{
						int status = 0 ; 
						status =  IPOSITIONTHREAD_Stop(pMe->pPosThread); 
						if(status != SUCCESS){//等待MIN_POSDET_INTERVAL时间之后再重启 
							ISHELL_SetTimer( pMe->glbVar->pIShell, MIN_POSDET_INTERVAL * 1000, (PFNNOTIFY)lizard_RestartPosThread, pMe);
						}else{
							ISHELL_SetTimer( pMe->glbVar->pIShell, MIN_POSDET_INTERVAL * 1000, (PFNNOTIFY)lizard_RestartPosThread, pMe);
						}
					}
					break;
				default:
					break;
			}
			return(TRUE);
	  // Flip event. Look at the wParam above to know flip state.
        case EVT_FLIP:
			// wParam = FALSE, when flip is closed.
			if(wParam == FALSE)
			{
				// Add your code here...				
			}			
			else 
			{				
				// Add your code here...	
			}
		
			return(TRUE);

	   // Key-guard event. Look at the wParam above to know key-guard state.
        case EVT_KEYGUARD:

			// wParam = TRUE, when key-guard is enabled.
			if(wParam == TRUE)
			{
				// Add your code here...	
			}			
			else
			{				
				// Add your code here...	
			}	
				
      		return(TRUE);	
		case EVT_DIALOG_INIT:
			DBGPRINTF("=====================EVT_DIALOG_INIT");
			return TRUE;
		case EVT_DIALOG_START:
			DBGPRINTF("=====================EVT_DIALOG_START");
			return TRUE;
		case EVT_DIALOG_END:
			DBGPRINTF("=====================EVT_DIALOG_END");
			return TRUE;
		case EVT_NOTIFY:{
			AEENotify* pNotify = (AEENotify*) dwParam;
			if (pNotify && (pNotify->cls == AEECLSID_SHELL))  // event sender
			{
				if ((pNotify->dwMask & NMASK_SHELL_INIT) == NMASK_SHELL_INIT) 
				{
					// AEECLSID_SHELLINIT 为本应用
					pMe->startType = STARTWITHSYSTEM;
					ISHELL_StartApplet(pMe->a.m_pIShell, pMe->a.clsID);
					
				}
			}
			return TRUE;
		}
        // If nothing fits up to this point then we'll just break out
        default:
            break;
   }

   return FALSE;
}