Err DIA_Free(DIA_Settings* diaSettings) { UInt16 cardNo; LocalID localId; Err error=errNone; Err tmpErr; Assert(diaSettings); if (DIA_TestFlag(diaSettings, diaRegisteredDisplayResizeNotify) || DIA_TestFlag(diaSettings, diaRegisteredDisplayChangeNotify)) { error=SysCurAppDatabase(&cardNo, &localId); if (error) goto OnErrorFreeLib; if (DIA_TestFlag(diaSettings, diaRegisteredDisplayResizeNotify)) { error=SysNotifyUnregister(cardNo, localId, sysNotifyDisplayResizedEvent, sysNotifyNormalPriority); if (!error) DIA_ResetFlag(diaSettings, diaRegisteredDisplayResizeNotify); else goto OnErrorFreeLib; } if (DIA_TestFlag(diaSettings, diaRegisteredDisplayChangeNotify)) { error=SysNotifyUnregister(cardNo, localId, sysNotifyDisplayChangeEvent, sysNotifyNormalPriority); if (!error) DIA_ResetFlag(diaSettings, diaRegisteredDisplayChangeNotify); else goto OnErrorFreeLib; } } OnErrorFreeLib: if (DIA_HasSonySilkLib(diaSettings)) { tmpErr=SonySilkLibFree(diaSettings); if (tmpErr) error=tmpErr; } OnError: return error; }
static void UnregisterNotification( void ) { if ( haveNotification ) { SysNotifyUnregister( card, db, displayChangeNotification, sysNotifyNormalPriority ); haveNotification = false; } }
/*********************************************************************** * * FUNCTION: AppStop * * DESCRIPTION: Save the current state of the application. * * PARAMETERS: nothing * * RETURNED: nothing * * REVISION HISTORY: * * ***********************************************************************/ static Err AppStopCheckNotify() { UInt32 romVersion; Err err; err = FtrGet(sysFtrCreator, sysFtrNumNotifyMgrVersion, &romVersion); if (!err) { UInt16 cardNo; LocalID dbID; err = SysCurAppDatabase(&cardNo, &dbID); if (!err) { SysNotifyUnregister(cardNo, dbID, sysNotifyVolumeUnmountedEvent, sysNotifyNormalPriority); SysNotifyUnregister(cardNo, dbID, sysNotifyVolumeMountedEvent, sysNotifyNormalPriority); // sonySysNotifyMsaEnforceOpenEvent SysNotifyUnregister(cardNo, dbID, sysNotifyDisplayResizedEvent, sysNotifyNormalPriority); } } return err; }
void unhookHoldSwitch(void) { Err err; UInt32 val; err = FtrGet(sysFtrCreator, sysFtrNumNotifyMgrVersion, &val); if (!err && val) { UInt16 CardNo; LocalID dbID; DmSearchStateType state; DmGetNextDatabaseByTypeCreator(true, &state, 'appl', GetCreatorID(), true, &CardNo, &dbID); SysNotifyUnregister(CardNo, dbID, sonySysNotifyHoldStatusChangeEvent, sysNotifyNormalPriority); holdCB = NULL; } }
void SonyEndSilk(void) { UInt16 cardNo; LocalID dbID; if (silk_ref <= 0) return; WriteLog("Will Close\n"); if (silk_ver == 0) { // SilkLibResizeDispWin(silk_ref, silkResizeNormal); // SilkLibDisableResize(silk_ref); SilkLibClose(silk_ref); } else { // VskSetState(silk_ref, vskStateResize, vskResizeMin); // VskSetState(silk_ref, vskStateEnable, 0); VskClose(silk_ref); } silk_ref = -1; SysCurAppDatabase(&cardNo, &dbID); SysNotifyUnregister(cardNo, dbID, sysNotifyDisplayChangeEvent, sysNotifyNormalPriority); }
/*********************************************************************** * handling for form and control actions * menu actions are forwarded to MainFormDoCommand ***********************************************************************/ static Boolean MainFormHandleEvent (EventPtr event) { FormType *frm; Boolean handled = false; Boolean categoryEdited, reDraw=false; UInt16 category, numRecords; ControlType *ctl; UInt32 *recordList; if (event->eType == ctlSelectEvent) { // button handling handled = true; switch (event->data.ctlSelect.controlID) { // the ok button - this leaves the application case LIST_cat_trigger: frm = FrmGetActiveForm(); category=DatabaseGetCat(); numRecords=DmNumRecordsInCategory(DatabaseGetRef(), DELETE_CATEGORY); recordList=(UInt32 *)MemPtrNew(numRecords * sizeof(UInt32)); CatPreEdit(numRecords, recordList); categoryEdited = CategorySelect(DatabaseGetRef(), frm, LIST_cat_trigger, LIST_cat, false, &category, gCategoryName, 0, STRING_cat_edit); // categoryDefaultEditCategoryString if (categoryEdited || (category != DatabaseGetCat())) { reDraw=true; DatabaseSetCat(category); ctl = GetObjectPtr(LIST_cat_trigger); CategoryGetName(DatabaseGetRef(), DatabaseGetCat(), gCategoryName); CategorySetTriggerLabel(ctl, gCategoryName); } CatPostEdit(numRecords, recordList); if (reDraw) { GadgetSetNeedsCompleteRedraw(true); FrmDrawForm(frm); } if (recordList != NULL) MemPtrFree((MemPtr)recordList); break; case BUTTON_beam: BeamCourse(GadgetGetHintCourseIndex()); break; case BUTTON_edit: gMenuCurrentForm=FORM_main; EditTime(); break; case BUTTON_next: GadgetDrawHintNext(); break; default: break; } } else if (event->eType == keyDownEvent) { // We have a hard button assigned and it was pressed if (TxtCharIsHardKey(event->data.keyDown.modifiers, event->data.keyDown.chr)) { if (! (event->data.keyDown.modifiers & poweredOnKeyMask)) { GadgetDrawHintNext(); handled = true; } } else if (EvtKeydownIsVirtual(event)) { // Up or down keys pressed switch (event->data.keyDown.chr) { case vchrPageUp: if (event->data.keyDown.modifiers & autoRepeatKeyMask) { if (! gMainRepeat) { GadgetSwitchScreen(); gMainRepeat = true; } } else { GadgetDrawStep(winUp); gMainRepeat = false; } handled=true; break; case vchrPageDown: if (event->data.keyDown.modifiers & autoRepeatKeyMask) { if (! gMainRepeat) { GadgetSwitchScreen(); gMainRepeat = true; } } else { GadgetDrawStep(winDown); gMainRepeat = false; } handled=true; break; case vchrSendData: BeamCourse(GadgetGetHintCourseIndex()); handled=true; break; default: break; } } } else if (event->eType == menuEvent) { // forwarding of menu events return HandleMenuEvent(event->data.menu.itemID); } else if (event->eType == menuOpenEvent) { return HandleMenuOpenEvent(event); } else if (event->eType == frmUpdateEvent) { // redraws the form if needed frm = FrmGetActiveForm(); FrmDrawForm(frm); // GadgetDrawHintNext(); handled = true; } else if (event->eType == frmOpenEvent) { ControlType *ctl; LocalID dbID; UInt16 cardNo; Boolean newKeyP4=false; UInt16 newKeyP2=0xFFFF; // initializes and draws the form at program launch frm = FrmGetActiveForm(); GadgetSet(frm, GADGET_main, GADGET_hint); FrmSetGadgetHandler(frm, FrmGetObjectIndex(frm, GADGET_main), GadgetHandler); FrmSetGadgetHandler(frm, FrmGetObjectIndex(frm, GADGET_hint), GadgetHintHandler); FrmDrawForm(frm); GadgetDrawHintNext(); ctl = GetObjectPtr(LIST_cat_trigger); CategoryGetName (DatabaseGetRef(), DatabaseGetCat(), gCategoryName); CategorySetTriggerLabel (ctl, gCategoryName); DmOpenDatabaseInfo(DatabaseGetRefN(DB_MAIN), &dbID, NULL, NULL, &cardNo, NULL); SysNotifyRegister(cardNo, dbID, sysNotifyLateWakeupEvent, HandleNotification, sysNotifyNormalPriority, NULL); KeyRates(false,&gKeyP1, &gKeyP2, &gKeyP3, &gKeyP4); KeyRates(true, &gKeyP1, &newKeyP2, &gKeyP3, &newKeyP4); handled = true; } else if (event->eType == frmCloseEvent) { // this is done if program is closed LocalID dbID; UInt16 cardNo; DmOpenDatabaseInfo(DatabaseGetRefN(DB_MAIN), &dbID, NULL, NULL, &cardNo, NULL); SysNotifyUnregister(cardNo, dbID, sysNotifyLateWakeupEvent, sysNotifyNormalPriority); // Restore original key rates KeyRates(true, &gKeyP1, &gKeyP2, &gKeyP3, &gKeyP4); } return (handled); }