Beispiel #1
0
/* Start here! */
UInt32
PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
    UInt16 err;

    // Called as a subroutine
    if (cmd == boogerPlugLaunchCmdBlowNose) {
        if ((err = StartApplication()))
            return (err);

        if (!(err = PickBooger((KleenexPtr)cmdPBP)))
            err = BlowNose((KleenexPtr)cmdPBP);

        StopApplication();
        return (err);
    }

    // Running as an application
    if (cmd == boogerPlugLaunchCmdSneeze) {
        if ((err = StartApplication()))
            return (err);

        if (!(err = PickBooger((KleenexPtr)cmdPBP)))
            err = Sneeze((KleenexPtr)cmdPBP);

        StopApplication();
        return (err);
    }

    return (sysErrParamErr);
}
DWord
PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
    if (cmd == sysAppLaunchCmdNormalLaunch)
    {
        StartApplication ();
        FrmGotoForm (mainForm);
        EventLoop ();
        StopApplication ();
    }
    return (0);
}
Beispiel #3
0
UInt32 PilotMain(UInt16 launchCode, MemPtr cmdPBP, UInt16 launchFlags)
{

    Err err;
    if (launchCode == sysAppLaunchCmdNormalLaunch) {
        if ((err = StartApplication()) == 0) {
            EventLoop();
            StopApplication();
        }
    }
    return 0;
}
Beispiel #4
0
ULong PilotMain( UInt launchCode, Ptr cmdPBP, UInt launchFlags )
{
	Err err=0;

	if( launchCode == sysAppLaunchCmdNormalLaunch ) {
		if( (err=StartApplication()) == 0 ) {
			EventLoop();
			StopApplication();
		}
	}

	return err;
}
Beispiel #5
0
DWord
PilotMain (Word cmd, Ptr cmdPBP, Word launchFlags)
{
    int error;

    if (cmd == sysAppLaunchCmdNormalLaunch) {
	error = StartApplication();
	if (error) return error;
	EventLoop();
	StopApplication();
    }

    return 0;
}
Beispiel #6
0
/* Main entry point; it is unlikely you will need to change this except to
   handle other launch command codes */
UInt32 PilotMain(UInt16 cmd, void *cmdPBP, UInt16 launchFlags)
{
    UInt16 err;

    if (cmd == sysAppLaunchCmdNormalLaunch) {

	err = StartApplication();
	if (err) return err;

	EventLoop();
	StopApplication();

    } else {
	return sysErrParamErr;
    }

    return 0;
}
Beispiel #7
0
/* Main entry point; it is unlikely you will need to change this except to
   handle other launch command codes */
UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
        UInt16 err;

        if (cmd == sysAppLaunchCmdNormalLaunch) {

                err = StartApplication();
                if (err) {
                        FrmCloseAllForms();
                        return err;
                }
	
                EventLoop();
                StopApplication();
	
        } else {
                return sysErrParamErr;
        }

        return 0;
}
Beispiel #8
0
/* Main entry point; it is unlikely you will need to change this except to
   handle other launch command codes */
DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
  if (cmd == sysAppLaunchCmdNormalLaunch) {
    Word err;


    err = StartApplication();
    if (err) {
      FrmCloseAllForms();
      return err;
    }
	
    EventLoop();
    StopApplication();
	
  } else {
    return sysErrParamErr;
  }

  return 0;
}
Beispiel #9
0
/* This is the main entry point for the cleaner application */
UInt32 PilotMain
    (
    UInt16 cmd,         /* SysAppLaunch Command */
    MemPtr cmdPBP,      /* pointer to command parameter block */
    UInt16 launchFlags  /* launch flag ( see SystemMgr.h for details ) */
    )
{
    Err err;

    err = errNone;
    if ( cmd == sysAppLaunchCmdNormalLaunch ) {
        err = StartApplication( NULL );
        if ( err != errNone )
            return err;

        EventLoop();
        StopApplication();
    }

    return err;
}
Beispiel #10
0
/* Main entry point; it is unlikely you will need to change this except to
   handle other launch command codes */
UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
	UInt16 err;

	if (cmd != sysAppLaunchCmdNormalLaunch)
		return sysErrParamErr;

	if (!(buffer = WinCreateOffscreenWindow (160, 160, screenFormat, &err)))
		return err;

	if ((err = StartApplication()) != 0)
		return err;

	ticks = SysTicksPerSecond() / FRAME_RATE;

	run_game ();
	/* EventLoop(); */
	StopApplication();

	WinDeleteWindow (buffer, false);

	return 0;
}
Beispiel #11
0
/**********************************************************************************
 * Function: PilotMain
 * Description: this is the function that is acctually called by the PalmOS when
 * application start and other events occur. we handle those system launch events
 * here
 * *******************************************************************************/ 
UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) 
{
	Err err = 0;
	
		// request to start application normally
		if (cmd == sysAppLaunchCmdNormalLaunch)
		
	{
#if ((defined DEBUG) && (defined HAVE_GDBHOOK))	
	_gdb_hook();
#endif 
			// call StartApplication to initialize things, 
			// go to the opening form and enter the event loop,
			// until end.
			if ((err = StartApplication ()) == 0)
			
		{
			FrmGotoForm (PasswordForm);
			EventLoop ();
			StopApplication ();
		}
	}
	return cmd;
}
Beispiel #12
0
/***********************************************************************
 * main function
 ***********************************************************************/
UInt32
PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
  UInt16 error = RomVersionCompatible (MINVERSION, launchFlags);
  if (error) return (error);

  /***
  * NORMAL STARTUP
  ****/
  if ( cmd == sysAppLaunchCmdNormalLaunch ) {
    error = StartApplication ();
    if (error) {
      // PalmOS before 3.5 will continuously relaunch this app unless we switch to
      // another safe one.
      if (error != dmErrCorruptDatabase) {
        FrmCustomAlert(ALERT_debug, "Please reports this bug! Give your Palm device and PalmOS version, this BadBug(TM) should not happen.", "", "");
      }
      StopApplication();
      AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
      return error;
    }

    FrmGotoForm(FORM_main);

    AppEventLoop ();
    StopApplication ();

    /***
     * FIND
     ****/
    /*
      } else if (cmd == sysAppLaunchCmdSaveData) {
      FrmSaveAllForms();
      } else if (cmd == sysAppLaunchCmdFind) {
      PalmGlobalFind((FindParamsPtr)cmdPBP);
    */

    /***
     * GoTo
     ****/
    /*
      } else if (cmd == sysAppLaunchCmdGoTo) {
      Boolean launched = launchFlags & sysAppLaunchFlagNewGlobals;
	
      if (launched) {
      error = StartApplication();
      if (! error) {
      GoToItem((GoToParamsPtr)cmdPBP, launched);
      AppEventLoop();
      StopApplication();
      }
      } else {
      GoToItem((GoToParamsPtr)cmdPBP, launched);
      }
    */

    /***
     * BEAMING
     ****/
  } else if (cmd == sysAppLaunchCmdSyncNotify) {
    // Register with the Exchange Manager
    ExgRegisterData(APP_CREATOR, exgRegExtensionID, "umx");
  } else if (cmd == sysAppLaunchCmdExgAskUser) {
    // Always assume "Yes" as answer to the accept dialog since we display our
    // own on which the user can cancel the data
    ExgAskParamType *exgAskParam = (ExgAskParamType *)cmdPBP;
    exgAskParam->result=exgAskOk;
  } else if (cmd == sysAppLaunchCmdExgReceiveData) {
    DmOpenRef cats=NULL, dogs=NULL;
    // Is app active?
    if (launchFlags & sysAppLaunchFlagSubCall) {
      // Quit Forms
      FrmSaveAllForms();

      cats = DatabaseGetRefN(DB_MAIN);
      dogs = DatabaseGetRefN(DB_DATA);
      error = BeamReceive(cats, dogs, (ExgSocketPtr) cmdPBP);
      CacheReset();
      FrmGotoForm(FORM_main);

    } else {
      // Another app was running when we were called
      cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite);
      dogs = DmOpenDatabaseByTypeCreator(DATABASE_DATA_TYPE, APP_CREATOR, dmModeReadWrite);
      if (! (cats && dogs)) {
        FrmAlert(ALERT_beamdbfail);
      } else {
        error=BeamReceive(cats, dogs, (ExgSocketPtr)cmdPBP);
      }
      if (cats)  DmCloseDatabase(cats);
      if (dogs)  DmCloseDatabase(dogs);
    }

    /***
     * ALARM
     ****/
  } else if (cmd == sysAppLaunchCmdAlarmTriggered) {
    // Is app active?
    if (launchFlags & sysAppLaunchFlagSubCall) {
      AlarmTriggered(DatabaseGetRefN(DB_MAIN), (SysAlarmTriggeredParamType *)cmdPBP);
    } else {
      DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite);
      AlarmTriggered(cats, (SysAlarmTriggeredParamType *)cmdPBP);
      DmCloseDatabase(cats);
    }

    /***
     * ATTENTION
     ****/
  } else if (cmd == sysAppLaunchCmdAttention) {
    // Is app active?
    if (launchFlags & sysAppLaunchFlagSubCall) {
      AttentionBottleNeckProc(DatabaseGetRefN(DB_MAIN), (AttnLaunchCodeArgsType *)cmdPBP);
    } else {
      // Another app was running when we were called
      DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite);
      AttentionBottleNeckProc(cats, (AttnLaunchCodeArgsType *)cmdPBP);
      DmCloseDatabase(cats);
    }

    /***
     * ATTENTION GOTO
     ****/
  } else if (cmd == appLaunchCmdAlarmEventGoto) {
    error = StartApplication ();
    if (error) {
      // PalmOS before 3.5 will continuously relaunch this app unless we switch to
      // another safe one.
      if (error != dmErrCorruptDatabase) {
        FrmCustomAlert(ALERT_debug, "Please reports this bug! Give your Palm device and PalmOS version, this BadBug(TM) should not happen.", "", "");
      }
      StopApplication();
      AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
      return error;
    }

    ExamSetGoto(*(UInt32 *)cmdPBP);
    FrmGotoForm(FORM_exams);

    AppEventLoop ();
    StopApplication ();


  /***
  * TIME CHANGE
  ****/
  // Launch code sent when the system time is changed.
  } else if (cmd == sysAppLaunchCmdTimeChange) {
    // reset the trigger for the next alarm to fire
    if (launchFlags & sysAppLaunchFlagSubCall) {
      AlarmReset(DatabaseGetRefN(DB_MAIN));
      // Remove any "future" alarms from the attention manager queue
      // (ie alarms that will trigger after the new time setting)
      //AlarmUpdatePosted(DeviceTimeChanged);
    } else {
      // Another app was running when we were called
      DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite);
      if (cats != 0) {
        AlarmReset(cats);
        //AlarmUpdatePosted(DeviceTimeChanged);
        DmCloseDatabase(cats);
      }
    }
    
  
  /***
  * RESET
  ****/
  // This action code is sent after the system is reset.
  } else if (cmd == sysAppLaunchCmdSystemReset) {
    if (! ((SysAppLaunchCmdSystemResetType*)cmdPBP)->hardReset) {
      if (launchFlags & sysAppLaunchFlagSubCall) {
        AlarmReset(DatabaseGetRefN(DB_MAIN));
      } else {
        // Another app was running when we were called
        DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite);
        if (cats != 0) {
          AlarmReset(cats);
          DmCloseDatabase(cats);
        }
      }
    }

  }

  return 0;
}
Beispiel #13
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 ();
}