I can't figure it out. :-((

OK, so I tried a different approach. Instead of going to the proper form and 
running the event loop when I get a notification, I decided to launch myself 
with a custom launch code:

UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
    UInt16 cardNo;
    LocalID dbID;
    UInt32 romVersion;

    switch (cmd)
    {
        case sysAppLaunchCmdNormalLaunch:
        case sysAppLaunchCmdCustomBase + 1:
            AppStart ();
            FrmGotoForm ((cmd == sysAppLaunchCmdNormalLaunch) ? kMainForm : 
kScanningMemoryCardForm);
            AppEventLoop ();
            AppStop ();
            break;
        case sysAppLaunchCmdSystemReset:
        case sysAppLaunchCmdSyncNotify:
            FtrGet (sysFtrCreator, sysFtrNumROMVersion, &romVersion);
            if (romVersion >= version40)
                SysNotifyRegister (cardNo, dbID, sysNotifyVolumeMountedEvent, 
NULL, sysNotifyNormalPriority, NULL);
            break;
        case sysAppLaunchCmdNotify:
            HandleNotification ((SysNotifyParamType *) cmdPBP);
            break;
        default:
            break;
    }
    return 0;
}

void HandleNotification (SysNotifyParamType *np)
{
    DmSearchStateType stateInfo;
    UInt16 cardNo;
    LocalID dbID;

    switch (np->notifyType)
    {
        case sysNotifyVolumeMountedEvent:
            DmGetNextDatabaseByTypeCreator (true, &stateInfo, 'appl', 
appCreatorID, true, &cardNo, &dbID);
            SysUIAppSwitch (cardNo, dbID, sysAppLaunchCmdCustomBase + 1, NULL);
            break;
        default:
            break;
    }
}

This doesn't crash. However:

1) When installed on the simulator and when the simulator is reset, my 
application is started and it scans the memory card *twice*. Why twice?! OK, 
currently I don't check which volume is being mounted and scan all the 
available volumes. So, if a device had more than one card and both were mounted 
on reset, my program would be run twice. However, the Tungsten E simulator with 
HostFS does not have two cards; it has only one! And why the previous version 
(that tried to do a FrmGotoForm) was run only once, implying that there is only 
a single volume mounting event at reset??

2) When used on a real device, it doesn't crash, either. However, the card is 
*not* scanned when it is inserted in the slot! Instead, the Launcher does its 
usual thing - plays a sound, displays the applications in /PALM/Launcher, etc. 
It's as if my application isn't getting a volume mounted event notification. 
Why?!

And, if I reset the real device with the card left in the slot, my application 
*is* launched - and scans the card. Once, not twice.

This thing is driving me nuts... :-((( Help?

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