OK, I have sort-of implemented an illustrative application for handling this 
problem and it sort-of works. From the user point of view, the experience still 
isn't identical to that of the Launcher; I'll explain what the differences are 
in a moment. First, the answers of the questions that I have discovered.

> Or do I have to do stupid tricks like setting the owner of that
> memory to zero?

Yes, I do have to use stupid tricks like that, sigh.

> But I'll be launching start.prc from an alarm. I won't be in an
> event loop at this point. Does that mean that I should use
> SysAppLaunch?

No. Even though I run start.prc from an alarm, there is still an application 
running at that time - the Launcher or something else. So, it is SysUIAppSwitch 
that has to be used - it will tell that application to terminate.

> But I seem to remember having read somewhere that one shouldn't
> use SysAppLaunch with the sysAppLaunchCmdNormalLaunch launch code
> - is that correct or am I imagining things?

I'm not imagining things. Apparently, SysAppLaunch doesn't set the global 
variables, for instance. You can't launch normally any random application with 
it. It should be used only to pass special launch codes to applications.

> What should I pass as the cmdPBP argument? NULL?

Yep, NULL works fine.

> For instance, the application might still be running. So, I guess
> if the deletion fails, I should set an alarm to try deleting it
> later.

That's what I ended up doing - although it's not elegant, to put it mildly.

Dave's suggestion to listen to the sysNotifyAppQuittingEvent notification isn't 
good enough. According to the documentation,

"This notification is declared in the Palm OS 4.0 SDK Update 1. Versions 4.1 
and earlier of Palm OS don't broadcast this notification. Palm OS Garnet 
releases do broadcast it. Later versions may or may not broadcast this 
notification."

That's unacceptable. My program has to work correctly on every OS that supports 
memory cards - including 4.0 and 6.x. Still, I might use this notification if 
the OS version is greater than 4.1 and less than 6.0; I'll think about it.

> How do I *find* the start.prc in the main memory anyway?

I did it using type and creatorID and it works. I like Dave's suggestion to use 
the database name only; I'll do it that way. I also noticed that if the main 
memory already contains some version of that application, it is what will be 
run - *not* the version on the card. (Makes sense, really, but was not 
immediately obvious that this is what would happen.) So, I have to make a 
similar check and avoid overwriting an already existing version with what's on 
the card. The Launcher also displays an error if the application in the main 
memory is already running when a card containing a similar application as 
start.prc is inserted - I'll have to implement that too.

Now the problems.

1) When the Launcher copies start.prc to the main memory, it usually goes to 
the Unfiled category (unless it has a resource telling the Launcher to put it 
in another category, that is). So, after you switch to the Launcher (after 
start.prc was run) and go to the Unfiled category, you see there the temporary 
copy of the application. If, at this moment, you remove the card, the Launcher 
deletes it. But it also knows that you've been looking at the category where 
the temporary copy resided, so it refresses the screen and you see the icon of 
the application disappear.

I don't see how I can do that from my application. The Launcher has no way of 
knowing that I have copied start.prc to the main memory and am about to delete 
it on volume unmount - so it doesn't know that it has to refresh the screen. 
So, I end up with a phantom icon if the user was looking at the wrong category 
when the card was removed. As I said, I don't think that there is a solution to 
this - although I'm open to ideas. I don't suppose that there is an 
undocumented launch code for the Launcher, telling it to refresh the screen? :-)

2) If the copied application was running when the card was removed, I can't 
delete it. So, I set an alarm and keep trying every second. I evetually 
succeed, when the user switches to the Launcher. Problem is, the Launcher seem 
to "lose" the current category view. That is, it switches to the "All" category 
- not to the category that was current when the card was inserted. I don't know 
why this happens, and I don't know how to fix it - but I suspect that it 
similarly cannot be fixed.

Comments, suggestions, ideas, anyone?

Regards,
Vesselin
-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to