Пример #1
0
/* Save preferences, close forms, close app database */
static void StopApplication(void)
{
    PrefSetAppPreferences('StWt', 0, stopWatchPrefVersionNum,
            &stopWatchPrefs, sizeof(stopWatchPreferenceType), true);
    FrmSaveAllForms();
    FrmCloseAllForms();
}
Пример #2
0
void TestPrefsDataReadOld( void )
{
    OldPreferences  oldPref;
    Int16           version;
    UInt16          prefSize;

    /* Add known old preference structure */
    MemSet( &oldPref, sizeof( OldPreferences ), 0 );
    oldPref.rotate          = true;
    oldPref.controlMode     = MODE2;
    oldPref.useDateTime     = true;
    PrefSetAppPreferences( (UInt32) ViewerAppID, (UInt16) ViewerOldPrefID,
        (Int16) ViewerVersion, &oldPref, sizeof( OldPreferences ), true );

    /* When the old preference structure is found it should be converted
       to the new format and then the old structure should be removed */
    ReadPrefs();
    ASSERT( Prefs()->rotate );
    ASSERT( Prefs()->controlMode == MODE2 );
    ASSERT( Prefs()->useDateTime );

    /* Check that the old preference structure is removed */
    prefSize    = 0;
    version     = PrefGetAppPreferences( (UInt32) ViewerAppID,
                    (UInt16) ViewerOldPrefID, NULL, &prefSize, true);

    ASSERT( version == noPreferenceFound );
}
Пример #3
0
/* Store search patterns */
static void WriteSearchPatterns( void )
{
    if ( patterns != NULL ) {
        PrefSetAppPreferences( (UInt32) ViewerAppID,
            (UInt16) ViewerPrefSearchStringID, (Int16) ViewerVersion, patterns,
            patternsSize, true );

        SafeMemPtrFree( patterns );
        patterns = NULL;
    }
}
Пример #4
0
int PrefsDataSuiteTearDown( void )
{
    /* Restore original preference structure */
    if ( hasStoredPrefs )
    {
        PrefSetAppPreferences( (UInt32) ViewerAppID, (UInt16) ViewerPrefID,
            (Int16) ViewerVersion, &originalPref, sizeof( Preferences ), true );
    }
    MemSet( &originalPref, sizeof( Preferences ), 0 );

    return 0;
}
/***********************************************************************
 *
 * FUNCTION:    AppStop
 *
 * DESCRIPTION: Save the current state of the application.
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static void AppStop(void)
{
	StarterPreferenceType prefs;

	// Write the saved preferences / saved-state information.  This data 
	// will saved during a HotSync backup.
	PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, 
		&prefs, sizeof (prefs), true);
		
	// Close all the open forms.
	FrmCloseAllForms ();
}
Пример #6
0
void
ReleaseAlarmInternals (
	PendingAlarmQueueType *	inAlarmInternalsP,
	Boolean						inModified )
{
//#pragma unused (inInterrupt)
//	MemPtrUnlock (inAlarmInternalsP);
	if (inModified)
    {
		PrefSetAppPreferences (sysFileCDatebook, datebookUnsavedPrefID,
                               datebookUnsavedPrefsVersionNum, inAlarmInternalsP,
                               sizeof (PendingAlarmQueueType), false);
    }
}
Пример #7
0
void TestPrefsDataRead( void )
{
    Preferences testPref;

    /* Add known preference structure */
    MemSet( &testPref, sizeof( Preferences ), 0 );
    testPref.controlMode = MODE2;
    PrefSetAppPreferences( (UInt32) ViewerAppID, (UInt16) ViewerPrefID,
        (Int16) ViewerVersion, &testPref, sizeof( Preferences ), true );

    /* Read it back and check that the item has the correct value */
    ReadPrefs();
    ASSERT( Prefs()->controlMode == MODE2 );
}
Пример #8
0
}void
save_preferences(void)
{int size=prefs_size(),n;char*p=MemPtrNew(size),*_=p;const char*l;
 const char*dbn;struct database_handle**dbl;char aux_flags;
 if(!p){if(lookup)MemPtrFree(lookup);lookup=0;return;}
 l=get_lookup();dbl=get_database_list(&n);dbn=db_name;
 if(dbl)dbn=dbl[get_current_db_idx()]->name;
 MemMove(_,dbn,db_name_size);_+=db_name_size;
 if(l){StrCopy(_,l);_+=StrLen(l);if(lookup)MemPtrFree(lookup);lookup=0;}
 *_++=0;aux_flags=0;if(get_list_mode())aux_flags|=1<<list_mode_bit;
 *_=aux_flags;
 PrefSetAppPreferences(CREATOR,prefs_id,prefs_version,p,size,0);
 MemPtrFree(p);
}/*Copyright (C) 2008, 2009 Ineiev<*****@*****.**>, super V 93
Пример #9
0
/***********************************************************************
 *
 * FUNCTION:    ReserveAlarmInternals
 *
 * DESCRIPTION: Returns the internal struct which stores pending alarms,
 *					 etc. for use by AlarmTrigger and DBDisplayAlarm, et al.
 *					 THIS MAY BE CALLED AT INTERRUPT LEVEL (inInterrupt == true)!
 *					 IF SO, DONT USE GLOBALS!!
 *
 * PARAMETERS:  inInterrupt		If true, use FeatureMgr to retrieve
 *											application globals.
 *
 * RETURNED:    Pointer to the internal struct
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			rbb	4/29/99	Initial Revision
 *
 ***********************************************************************/
void
ReserveAlarmInternals (
	PendingAlarmQueueType*		outAlarmInternalsP )
{
	UInt16 prefsSize = sizeof (PendingAlarmQueueType);
	Int16 prefsVersion;

	prefsVersion = PrefGetAppPreferences
        (sysFileCDatebook, datebookUnsavedPrefID,
         outAlarmInternalsP, &prefsSize, false);
	
	if (prefsVersion == noPreferenceFound)
    {
		MemSet (outAlarmInternalsP, sizeof (PendingAlarmQueueType), 0);
		outAlarmInternalsP->snoozeAnchorTime = apptNoAlarm;
		
		PrefSetAppPreferences (sysFileCDatebook, datebookUnsavedPrefID,
                               datebookUnsavedPrefsVersionNum,
                               outAlarmInternalsP,
                               sizeof (PendingAlarmQueueType), false);
    }
}
Пример #10
0
void SaveCubes() {
  PrefSetAppPreferences( CREATOR, 0, 1, &stor, sizeof(stor), true );
}
Пример #11
0
/***************************************************************************
 * Function: cryptSwitch
 * Description: handles changing the system password based upon the 
 * password change screen. Basically checks that current password is correct,
 * checks that the new password was entered correctly, then re-encrypts the
 * databases based upon the new password.
 * ************************************************************************/ 
static void 
cryptSwitch (int v) 
{
	
		// total number of records to re-write
	UInt16 totalAItems = DmNumRecordsInCategory (AccountDB, dmAllCategories);
	UInt16 totalSItems = DmNumRecordsInCategory (SystemDB, dmAllCategories);
	MemPtr pac = NULL, scratch = NULL, scratch2 = NULL;
	UInt16 i = 0, senc = 0, aenc = 0;
	MemHandle rH;
	char s[5], a[5];
	StripPrefType prefs;	
	UInt16 prefsSize, prefsVersion;

	FormType *preF = FrmGetActiveForm ();
	FormType *f = FrmInitForm (pleaseWait);
	FrmDrawForm (f);
	
		// re-encrypt the password 
	if ((rH = DmGetRecord (PasswordDB, 0)))	
	{
		if ((scratch = MemPtrNew (getSCSize(sizeof(md_hash)))))			
		{
			PackPassword (scratch, &NewSysPass);			
			writeRecord (scratch, rH);
			MemPtrFree (scratch);
		}
		DmReleaseRecord (PasswordDB, 0, true);
	}
	
		// loop through the systems and re-encrypt
	for (i = 0; i < totalSItems; i++)
	{
		System_old sys;
		if ((rH = DmGetRecord (SystemDB, i)))	
		{
			pac = MemHandleLock (rH);
			if ((scratch = MemPtrNew (MemPtrSize (pac))))	
			{	
					// decrypt the system with old password
				switch (v)	
				{
					case 0:
						UnpackSystem_old (&sys, pac, scratch, SysPass,
										MemHandleSize (rH), true, 1);
										
						scratch2 = MemPtrNew (getSystemSize((System *)&sys, true));
						break;
					case 1:
						UnpackSystem_old (&sys, pac, scratch, SysPass,
										MemHandleSize (rH), true, 2);
						scratch2 = MemPtrNew (getSystemSize ((System *)&sys,true) );
						break;
					case 2:
						UnpackSystem_old (&sys, pac, scratch, SysPass,
										MemHandleSize (rH), true, 0);
						scratch2 = MemPtrNew (getSystemSize ((System *)&sys, true ));
						break;
				}
				if (scratch2)				
				{			
					PackSystem(scratch2, *((System *) &sys), &NewSysPass, true);
					MemHandleUnlock (rH);
					writeRecord (scratch2, rH);
					senc++;
					MemPtrFree (scratch2);
				}
				MemPtrFree (scratch);
			}
			DmReleaseRecord (SystemDB, i, true);
		}
	}
	
		// loop through the accounts and re-encrypt
	for (i = 0; i < totalAItems; i++)	
	{
		Account_old ac;
		Account ac_new;
		if ((rH = DmGetRecord (AccountDB, i)))
			
		{
			pac = MemHandleLock (rH);
			if ((scratch = MemPtrNew (MemPtrSize (pac))))
				
			{
				
					// decrypt the system with old password
				switch (v)	
				{
					case 0:
						UnpackAccount_old(&ac, pac, scratch, SysPass,
										 MemHandleSize (rH), true, true, 1);
						ChangeAccountFormat(i, &ac, &ac_new);
						scratch2 = MemPtrNew (getAccountSize(&ac_new, true));
						break; 
					case 1:
						UnpackAccount_old (&ac, pac, scratch, SysPass,
										 MemHandleSize (rH), true, true, 2);
						ChangeAccountFormat(i, &ac, &ac_new);
						scratch2 = MemPtrNew (getAccountSize(&ac_new, true));
						break; 
					case 2:
						UnpackAccount_old(&ac, pac, scratch, SysPass,
										 MemHandleSize (rH), true, true, 0);
						ChangeAccountFormat(i, &ac, &ac_new);
						scratch2 = MemPtrNew (getAccountSize(&ac_new,true));
						break; 
				}

				if (scratch2)
				{
					PackAccount(scratch2, ac_new, &NewSysPass, true);
					MemHandleUnlock (rH);
					writeRecord (scratch2, rH);
					aenc++;
					MemPtrFree (scratch2);
				}
				MemPtrFree (scratch);
			}
			DmReleaseRecord (AccountDB, i, true);
		}
	}
	FrmEraseForm (f);
	FrmDeleteForm (f);
	FrmSetActiveForm (preF);
		// close databases.
	DmCloseDatabase (SystemDB);
	DmCloseDatabase (AccountDB);
	DmCloseDatabase (PasswordDB);

	{
		UInt16 cardNo;
		UInt32 type;
		LocalID dbID;
		DmSearchStateType search;

		type = systemDBType;
		DmGetNextDatabaseByTypeCreator(true, &search, systemDBTypeOld, 
			StripCreator, true, &cardNo, &dbID);
		DmSetDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL,
			NULL, NULL, NULL, NULL, &type, NULL);
	
		type = accountDBType;
		DmGetNextDatabaseByTypeCreator(true, &search, accountDBTypeOld, 
			StripCreator, true, &cardNo, &dbID);
		DmSetDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL,
			NULL, NULL, NULL, NULL, &type, NULL);

		type = passwordDBType;
		DmGetNextDatabaseByTypeCreator(true, &search, passwordDBTypeOld, 
			StripCreator, true, &cardNo, &dbID);
		DmSetDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL,
			NULL, NULL, NULL, NULL,  &type, NULL);

	}

	prefsSize = sizeof (StripPrefType);
	prefsVersion = PrefGetAppPreferences (StripCreator, StripPrefID, &prefs, &prefsSize, true);
    if  (prefsVersion != StripVersionNumber) {
        prefs.smart_beaming = false;
        PrefSetAppPreferences (StripCreator, StripPrefID, StripVersionNumber,
            &prefs, sizeof (StripPrefType), true);
        prefsVersion = PrefGetAppPreferences (StripCreator, StripPrefID,
            &prefs, &prefsSize, true);
	} 

	StrIToA (s, senc);
	StrIToA (a, aenc);
	FrmCustomAlert (infoDialog, s, a, NULL);

	StopApplication ();
	SysReset ();
}
Пример #12
0
void FlickrSavePrefs(const FlickrPrefs& prefs)
{
    PrefSetAppPreferences(FlickrCreatorID, flickrPrefsResourceID, flickrPrefsVersion, &prefs, sizeof(FlickrPrefs), true);
}
Пример #13
0
/* Store preferences in the Preferences database */
void WritePrefs( void )
{
    PrefSetAppPreferences( (UInt32) ViewerAppID, (UInt16) ViewerPrefID,
        (Int16) ViewerVersion, &pref, sizeof( Preferences ), true );
}