Thanks for the answer.
> You can also do this manually using RsrcEdit or some other
> prefs editor.
Explain it to the user... I know about the cases when the users spent days
in removing this bug and tried everything possible (incl writing to Palm)
and we exchanged many emails until they stopped communicating. And we stil
did not know what they are talking about. (At that time I did not know yet
about the public Palm OS sources.)
Below is the code that we intend to use. However, it does not solve the
problem of the opened prefs database.
It will be a feature of our file manager. I am quite interested in your
tool. It would be good if we use similar UI in order not to confuse the
user. (Or maybe we could just refere to your tool.) We intend to publish it
as a menu option 'Repair Exchg Manager Preferences".
With best regards,
Jan Slodicka
int ExchangeMgr_ReapairPreferences()
{
DmOpenRef dbRef = PrefOpenPreferenceDB(false) ;
int numRec = DmNumRecords(dbRef) ;
int err = 0 ;
int i ;
int removed = 0 ;
for( i=0; i<numRec; i++ )
{
UInt32 creator ;
UInt16 id ;
DmResourceInfo( dbRef, i, &creator, &id, NULL ) ;
if( creator!=NULL )
{
DmSearchStateType state ;
UInt16 cardNo ;
LocalID dbId ;
Boolean bStart = true ;
if( id!=exgRegCreatorID &&
id!=exgRegSchemeID &&
id!=exgRegExtensionID &&
id!=exgRegTypeID )
continue ;
// These are allowed not to exists on the simulator||emulator
if( onPOSE() )
{
if( creator==sysFileCIrLib || creator==sysFileCLocalLib )
continue ;
}
// Go through types allowed...
while( (err = DmGetNextDatabaseByTypeCreator(bStart, &state, 0, creator,
true, &cardNo, &dbId ))==0 )
{
UInt32 typeID ;
GetDbInfo( dbId, DbInfo_Type, &typeID ) ;
// These types are allowed...
if( typeID == sysFileTApplication ||
typeID == sysFileTExgLib ||
typeID == sysFileTPanel )
break ;
bStart = false ;
}
// The corresponding db was not found.. delete the offending resource...
if( err )
{
err = DmRemoveResource( dbRef, i ) ;
if( err==0 )
{
i-- ;
removed++ ;
numRec-- ;
}
if( err )
break ;
}
}
}
if( err==0 && removed > 0 )
SayText( "%d bogus entries removed", removed ) ;
DmCloseDatabase(dbRef) ;
return err ;
}
----- Original Message -----
From: "Ben Combee" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Sunday, June 20, 2004 5:59 PM
Subject: Re: exgErrNoTargetApp and inconsistent prefs
> At 04:17 AM 6/20/2004, Jan Slodicka wrote:
> >Probable explanation is this:
> >The user deleted a registered application incorrectly so that its
> >registration was not removed. At least this follows from the published
Palm
> >OS sources (they seem to have a bug leaving the prefs database opened).
> >Additionally, we managed to "construct" such a situation in the described
> >way.
>
> Your analysis is correct. I can add a little more information to this:
>
> The problem is that there's code in Palm OS that isn't cleaning up
properly
> after an error. Specifically, the exchange manager uses entries in the
> "Unsaved Preferences" database to store information about what kinds of
> objects your application has registered for. On Palm OS 5 and earlier,
> these entries have IDs 0xFFFB (-5) through 0xFFFE (-2) -- here's the text
> from ExgMgr.h that identifies these registries:
>
> #define exgRegCreatorID 0xfffb // creator ID registry
> #define exgRegSchemeID 0xfffc // URL scheme registry
> #define exgRegExtensionID 0xfffd // filename extension registry
> #define exgRegTypeID 0xfffe // MIME type registry
>
> Well, if a user runs an application that registers itself from an
expansion
> card, these entries don't get deleted when the application ends, since the
> general rule is to allow unassociated prefs entries for card-based apps.
>
> OK, so Exchange Manager is looking for an entry, and it iterates through
> all of these records. When it hits one that doesn't actually have an
> on-device application, it returns an error. However, some of the calls
> that do this don't clean up the data structure associated with the search,
> and that leaves the Prefs DB open; on the next call to a function that
uses
> the prefs DB, the system crashes with the "pref DB open error".
>
> I'm working on a little fix program that will clear out all of the ExgMgr
> unsaved prefs entries for apps that aren't on the device; this won't
> prevent it from reoccurring, but it can fix a device where this is already
> happening. You can also do this manually using RsrcEdit or some other
> prefs editor.
>
>
> -- Ben Combee, DTS technical lead, PalmSource, Inc.
> Read "Combee on Palm OS" at http://palmos.combee.net/
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/