Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

The description says:"If the applet is not currently running, it is loaded and the event is sent directly to it."QUESTION 1: Can you define what "loading" an applet means. Does it involve calling the applet's AEEClsCreateInstance() function (to establish the event handler)?QUESTION 2: If ISHELL_PostEvent() calls AEEClsCreateInstance(), what mechanism releases the resources that are allocated in this case? Must this be done manually by the caller of ISHELL_PostEvent() and how should the caller do it? How does the caller know whether to release these resources?The description continues:"Under these conditions, the applet is started in the background (EVT_APP_START and EVT_APP_STOP events are not sent to the applet)."QUESTION 3: Is it true that, in fact, the applet receives no events at all other than the event specified in the ISHELL_PostEvent() function? What about EVT_APP_START_BACKGROUND? Anything else?The description also specifies the return value of the function to be:"TRUE: if the event was processed. FALSE: if the event was not processed."QUESTION 4: Is this return value in fact always equal to the return value from the applet's event handler?

Please read my answers inline:-The description of ISHELL_SendEvent() reads:"If the applet is not currently running, it is loaded and the event is sent directly to it."QUESTION 1: Can you define what "loading" an applet means. Does it involve calling the applet's AEEClsCreateInstance() function (to establish the event handler)?---------------------------------Ans:- Yes, loading the applet means starting the applet and it will call AEEClsCreateInstance() to instantiate the applet.Let's say you want to send event EVT_USER from applet A(running) to Applet B(not running) using IShell_SendEvent(), Now as applet B is not running so first its AEEClsCreateInstance() will be called and then initappdata(), This is what the loading of applet B.I also questioned about the implicit creation of background processes. How does the application know that it has just been "loaded" by SendEvent()?Ans: You can put breakoints to the AEEClsCreateInstance() of applet B and run in debug mode, now send event from applet A using IShell_SendEvent(), AEEClsCreateInstance() of applet B will be called.QUESTION 3: Is it true that, in fact, the applet receives no events at all other than the event specified in the ISHELL_SendEvent() function? What about EVT_APP_START_BACKGROUND? Anything else?Ans: Using Ishell_sendevent() you can send user defined events to do specific actions. but EVT_APP_START_BACKGROUND will be recieved by applet only when you make a call to ISHELL_StartBackgroundApplet() API, upon recieving EVT_APP_START_BACKGROUND, you have to call InitAppData() of that application, calling ISHELL_StartBackgroundApplet() will send application to background.---------------------------------In your answer for question 4 you said:"Q4:- No, return va,ue of ISHELL_PostEvent and ISHELL_SendEvent is boolean which denotes whether events was sent/posted successfully or not."Just to be clear, if I do a SendEvent() to an application, and the event handler of that application returns FALSE, the return value of SendEvent() could still be TRUE?If so, what could cause the return value from SendEvent() to be FALSE?Ans: SendEvent() is used only for sending the event and returns true/false whether success/failed, return value of sendevent() does not effected by what you return from target app's event handler, so if sendevent() return TRUE from sending app and you return false form recieving app then still sendevent() eturn value will be true. Return value of SendEvent() may be flase if event was not sent to target application. "The only difference between ISHELL_PostEvent() and ISHELL_SendEvent() is that first one posts events asyncronously and later one sends immediately i.e. synchronous"QUESTION 5: Does this mean that ISHELL_PostEvent() will also start the applet in the background if it isn't started yet? Just like ISHELL_SendEvent()?Ans: Both will do the same work but let me clear you the diffrenece first. For every OS there is event queue where all the generated events gets stored to be processed later. Now if you call postevent() then all the pending events in the event queue will be processed first then the event sent using postevent() will be processed. But if you call sendevent() then it will immediately send the event without caring pending events in the queue. That is why it is synchronous.QUESTION 6: Does sending an event "immediately" mean that the target application's event handler is called directly? On the callers stack?Ans: Yes, this call will ignore pending events in the event queue to be processed, and directly send the event to the target app without caring other events waiting in the event queue to be proceesed. I would suggest to get some idea on processing the events in event queue (asynchronously and synchronously).Hope it helps.

Please read my answers inline:-The description of ISHELL_SendEvent() reads:"If the applet is not currently running, it is loaded and the event is sent directly to it."QUESTION 1: Can you define what "loading" an applet means. Does it involve calling the applet's AEEClsCreateInstance() function (to establish the event handler)?---------------------------------Ans:- Yes, loading the applet means starting the applet and it will call AEEClsCreateInstance() to instantiate the applet.Let's say you want to send event EVT_USER from applet A(running) to Applet B(not running) using IShell_SendEvent(), Now as applet B is not running so first its AEEClsCreateInstance() will be called and then initappdata(), This is what the loading of applet B.I also questioned about the implicit creation of background processes. How does the application know that it has just been "loaded" by SendEvent()?Ans: You can put breakoints to the AEEClsCreateInstance() of applet B and run in debug mode, now send event from applet A using IShell_SendEvent(), AEEClsCreateInstance() of applet B will be called.QUESTION 3: Is it true that, in fact, the applet receives no events at all other than the event specified in the ISHELL_SendEvent() function? What about EVT_APP_START_BACKGROUND? Anything else?Ans: Using Ishell_sendevent() you can send user defined events to do specific actions. but EVT_APP_START_BACKGROUND will be recieved by applet only when you make a call to ISHELL_StartBackgroundApplet() API, upon recieving EVT_APP_START_BACKGROUND, you have to call InitAppData() of that application, calling ISHELL_StartBackgroundApplet() will send application to background.---------------------------------In your answer for question 4 you said:"Q4:- No, return va,ue of ISHELL_PostEvent and ISHELL_SendEvent is boolean which denotes whether events was sent/posted successfully or not."Just to be clear, if I do a SendEvent() to an application, and the event handler of that application returns FALSE, the return value of SendEvent() could still be TRUE?If so, what could cause the return value from SendEvent() to be FALSE?Ans: SendEvent() is used only for sending the event and returns true/false whether success/failed, return value of sendevent() does not effected by what you return from target app's event handler, so if sendevent() return TRUE from sending app and you return false form recieving app then still sendevent() eturn value will be true. Return value of SendEvent() may be flase if event was not sent to target application. "The only difference between ISHELL_PostEvent() and ISHELL_SendEvent() is that first one posts events asyncronously and later one sends immediately i.e. synchronous"QUESTION 5: Does this mean that ISHELL_PostEvent() will also start the applet in the background if it isn't started yet? Just like ISHELL_SendEvent()?Ans: Both will do the same work but let me clear you the diffrenece first. For every OS there is event queue where all the generated events gets stored to be processed later. Now if you call postevent() then all the pending events in the event queue will be processed first then the event sent using postevent() will be processed. But if you call sendevent() then it will immediately send the event without caring pending events in the queue. That is why it is synchronous.QUESTION 6: Does sending an event "immediately" mean that the target application's event handler is called directly? On the callers stack?Ans: Yes, this call will ignore pending events in the event queue to be processed, and directly send the event to the target app without caring other events waiting in the event queue to be proceesed. I would suggest to get some idea on processing the events in event queue (asynchronously and synchronously).Hope it helps.

(The info in that response seems useful, but the unfortunate formatting makes it difficult to distinguish question from answer.)
If I do SendEvent (or similarly, if the system sends EVT_ALARM) to an app that's not running, that app must be loaded - meaning AEEClsCreateInstance gets called for the target clsid. Typical app implementation for createInstance:

invokes AEEApplet_New(), specifying, among other things, the applet event handler and freeAppData functions,
invokes an initAppData function to initialize any needed context

If that createInstance succeeds, the indicated event is then passed to the applet's event handler. 
Sometime thereafter, I assume some accounting happens on the target applet and if reference counts indicate the applet is no longer needed (handling the event didn't queue up a startApp or some other message for the target) then the applet gets dumped, meaning its freeAppData function gets called and the Applet is Released.
 
Do I have this right?
 
thx
-steve

(The info in that response seems useful, but the unfortunate formatting makes it difficult to distinguish question from answer.)
If I do SendEvent (or similarly, if the system sends EVT_ALARM) to an app that's not running, that app must be loaded - meaning AEEClsCreateInstance gets called for the target clsid. Typical app implementation for createInstance:

invokes AEEApplet_New(), specifying, among other things, the applet event handler and freeAppData functions,
invokes an initAppData function to initialize any needed context

If that createInstance succeeds, the indicated event is then passed to the applet's event handler. 
Sometime thereafter, I assume some accounting happens on the target applet and if reference counts indicate the applet is no longer needed (handling the event didn't queue up a startApp or some other message for the target) then the applet gets dumped, meaning its freeAppData function gets called and the Applet is Released.
 
Do I have this right?
 
thx
-steve

yes, but applet willbe dumped when you call Ishell_CloseApplet() or press the END key, This will send EVT_APP_STOP event to current running application and its freeappdata() function will gets called up which essentially releases applet resources before stopping.

yes, but applet willbe dumped when you call Ishell_CloseApplet() or press the END key, This will send EVT_APP_STOP event to current running application and its freeappdata() function will gets called up which essentially releases applet resources before stopping.

On top of that you can also send user defined events to backgroud running application to close and needs to handle this user defined event in background application and call Ishell_closeapplet().

On top of that you can also send user defined events to backgroud running application to close and needs to handle this user defined event in background application and call Ishell_closeapplet().