Err sbuReceiveResponse( SyncBmrResponse_t **respP ) { UInt cardNo; LocalID dbID; DWord result; Err error; SyncBmrData_t *dataP; sbuFindSyncBmr( &cardNo, &dbID ); // find SyncBmr // Allocate memory for SyncBmr comm block dataP = (SyncBmrData_t *)MEM_ALLOC( sizeof( SyncBmrData_t ) ); ErrFatalDisplayIf( !dataP, "memory allocation" ); MemPtrSetOwner( dataP, 0 ); // set owner of storage to system dataP->waitForResponse = true; // indicate a response is expected dataP->requestP = NULL; // indicate no document to send dataP->responseP = NULL; // indicate no document received yet // Cause SyncBmr to be programmatically launched error = SysAppLaunch( cardNo, dbID, sysAppLaunchFlagNewGlobals, sysAppLaunchSyncBmrReceive, (void *)dataP, &result ); *respP = (SyncBmrResponse_t *)dataP->responseP; // return received document MEM_FREE( dataP ); // free SyncBmr comm block return 0; } // sbuSendResponse()
static Err ModImport(UInt16 volRefNum, UInt8 engine, Boolean *armP) { #ifndef _DEBUG_ENGINE char filename[256]; UInt16 cardNo; LocalID dbID; UInt32 result; FileRef file; #endif char msg[256]; FormPtr ofmP, frmP; Err e = errNone; ofmP = FrmGetActiveForm(); frmP = FrmInitForm(ImportForm); FrmSetActiveForm(frmP); FrmDrawForm(frmP); // In debug mode, the engine files are directly uploaded to the simulator #ifndef _DEBUG_ENGINE // engine file ? BUILD_FILE(engines[engine].fileP, ".engine"); CHECK_FILE("ScummVM engine file was not found !"); IMPRT_FILE("Cannot import engine file !"); // need more files ? dbID = DmFindDatabase(0, "ScummVM-Engine"); // be sure to have the correct dbID e = SysAppLaunch(cardNo, dbID, 0, sysAppLaunchCustomEngineGetInfo, 0, &result); *armP = ((result & GET_MODEARM) == GET_MODEARM); // common file ? if (!e && (result & GET_DATACOMMON)) { BUILD_FILE("common", ".data"); CHECK_FILE("Common data file was not found !"); IMPRT_FILE("Cannot import common data file !"); } // data file ? if (!e && (result & GET_DATAENGINE)) { BUILD_FILE(engines[engine].fileP, ".data"); CHECK_FILE("Engine data file was not found !"); IMPRT_FILE("Cannot import engine data file !"); } #endif // if error, cleanup if (e) ModDelete(); onError: FrmEraseForm(frmP); FrmDeleteForm(frmP); if (e) { if (ofmP) FrmSetActiveForm(ofmP); FrmCustomAlert(FrmErrorAlert, msg, 0, 0); } return e; }
/* ** Add the Linker link to the plugin text. The calling ** function must free the returned pointer. */ static Char* GetLink(Char* orig_text) { UInt16 length = 0; Char* linked_text = NULL; LinkerCPB command_block; UInt32 result; /* Bail if there is no text */ if (!orig_text) return 0; length = StrLen(orig_text) + 1; if (p.flags & PFLAGS_XFER_BACKLINK && d.linker_available) length += 5; linked_text = MemPtrNew(length); ASSERT(linked_text); StrCopy(linked_text, orig_text); if (!(p.flags & PFLAGS_XFER_BACKLINK && d.linker_available)) return linked_text; MemSet(&command_block, sizeof(LinkerCPB), 0); command_block.creator = 'Linx'; /* maybe this is overkill, but .... */ command_block.message = LinkerNewLinkMessage; /* command_block.linkTag is empty and to be filled by Linker */ command_block.gotoTargetAppCreator = AppType; /* DiddleBug is the target */ DmOpenDatabaseInfo(d.dbR, &(command_block.gotoLinkParams.dbID), NULL, NULL, &(command_block.gotoLinkParams.dbCardNo), NULL); command_block.gotoLinkParams.recordNum = p.dbI; /* Signal Linker */ SysAppLaunch(d.cardNo, d.dbID, 0, linkerAppLaunchCmdSignalLinker, &command_block, &result); /* Add the link text */ command_block.linkTag[5] = 0x00; /* just to be sure */ StrCat(linked_text, command_block.linkTag); return linked_text; }
/* Finds and opens database, * calls plugin specific code to create new item, * then fills in GoTo parameters. */ static UInt16 PickBooger(KleenexPtr kleenexP) { DmOpenRef dbR; DmSearchStateType searchstate; UInt32 creatorID, dbtype; UInt16 cardNo; LocalID dbID; Boolean closedb = false; UInt16 err, index; UInt32 result; /* Check for the correct version */ if (!((kleenexP->version) & IBVERSION_ORIG)) return (boogerErrorVersionMismatch); /* Open the database */ if (DmGetNextDatabaseByTypeCreator(true, &searchstate, DB_TYPE, DB_CREATOR, true, &cardNo, &dbID)) return (1); if ((dbR = DmOpenDatabase(cardNo, dbID, dmModeReadWrite))) { closedb = true; } else if (DmGetLastErr() == dmErrAlreadyOpenForWrites) { dbR = NULL; while ((dbR = DmNextOpenDatabase(dbR))) { DmOpenDatabaseInfo(dbR, &dbID, NULL, NULL, &cardNo, NULL); DmDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &dbtype, &creatorID); if ((dbtype == DB_TYPE) && (creatorID == DB_CREATOR)) break; } if (!dbR) return (1); } /* Call plugin specific routine to create item in database */ err = DoTheBoogie(kleenexP, dbR, &index); /* Close the database */ if (closedb) DmCloseDatabase(dbR); /* Did it work? */ if (err) return (1); /* Load the GoTo parameters */ if (!(kleenexP->booger.cmdPBP = MemPtrNew(sizeof(GoToParamsType)))) return (1); MemSet(kleenexP->booger.cmdPBP, sizeof(GoToParamsType), 0); ((GoToParamsType *)(kleenexP->booger.cmdPBP))->dbCardNo = cardNo; ((GoToParamsType *)(kleenexP->booger.cmdPBP))->dbID = dbID; ((GoToParamsType *)(kleenexP->booger.cmdPBP))->recordNum = index; MemPtrSetOwner(kleenexP->booger.cmdPBP, 0); /* Send signal to set the alarm */ if (kleenexP->alarm_secs) { if (DmGetNextDatabaseByTypeCreator(true, &searchstate, sysFileTApplication, GOTO_ID, true, &cardNo, &dbID)) { FrmAlert(alertID_noDateBk4); MemPtrFree(kleenexP->booger.cmdPBP); return (1); } if (SysAppLaunch(cardNo, dbID, 0, sysAppLaunchCmdSyncNotify, NULL, &result)) FrmAlert(alertID_noAlarmSet); } return (errNone); }
/* ** FinishXferMode */ void FinishXferMode(void) { KleenexType kleenex; DtbkRepeatInfoType repeat; FormType* frm = FrmGetActiveForm(); SysDBListItemType* pluglistP = NULL; Int16 current_plug = -1; UInt32 result; Boolean is_goto = false; Err err = errNone; Char cat_name[dmCategoryLength]; Char* note = NULL; UInt16 attr; /* Zero the kleenex */ MemSet(&kleenex, sizeof(KleenexType), 0); /* Bail if no plugins installed */ if (!d.xfer.pluglistH) { FrmAlert(NoPluginInstalled); return; } /* Lock the plugin list */ pluglistP = MemHandleLock(d.xfer.pluglistH); current_plug = GetCurrentXferAppListIndex(); if (current_plug == -1) { FrmAlert(NoPluginSelected); MemHandleUnlock(d.xfer.pluglistH); return; } /* Set the version */ if (pluglistP[current_plug].version & IBVERSION_PICTURE) kleenex.version = IBVERSION_PICTURE; else if (pluglistP[current_plug].version & IBVERSION_ORIG) kleenex.version = IBVERSION_ORIG; else abort(); /* Add flag notifier */ kleenex.version |= IBVERSION_FLAGS; /* Set flags */ if (d.hires) kleenex.flags = IBFLAG_HIRES; /* Set the current record index */ kleenex.sketchRecordNum = p.dbI; /* Set the pick text */ kleenex.text = GetLink(FldGetTextPtr(GetObjectPointer(frm, XferField))); if (!kleenex.text) { FlashWaitMessage(XferNoTextString); MemHandleUnlock(d.xfer.pluglistH); return; } /* Set the title text */ kleenex.title = MemHandleLock(d.record_name); /* Set the category text */ DmRecordInfo(d.dbR, p.dbI, &attr, NULL, NULL); CategoryGetName(d.dbR, attr & dmRecAttrCategoryMask, cat_name); kleenex.category = cat_name; /* Set the note */ note = MemHandleLock(d.record_note); if (StrLen(note)) kleenex.note = note; /* Set the seconds for the alarm */ if (recordIsAlarmSet) kleenex.alarm_secs = d.record.alarmSecs; /* Set the repeat information */ kleenex.repeat = &repeat; switch (d.record.repeatInfo.repeatType) { case repeatDaily: case repeatWeekly: case repeatMonthlyByDay: case repeatMonthlyByDate: case repeatYearly: repeat.repeatType = d.record.repeatInfo.repeatType - 1; /* fix offset caused by repeatHourly */ repeat.repeatFrequency = d.record.repeatInfo.repeatFrequency; repeat.repeatEndDate = d.record.repeatInfo.repeatEndDate; repeat.repeatOn = d.record.repeatInfo.repeatOn; repeat.repeatStartOfWeek = d.record.repeatInfo.repeatStartOfWeek; break; case repeatNone: case repeatHourly: default: kleenex.repeat = NULL; } /* Set the priority */ kleenex.priority = d.record.priority + 1; /* DiddleBug priority is zero-based */ /* Set the completion flag */ if ((d.xfer.complete || (xferCompleteIsAlways)) && !(xferCompleteIsNever)) kleenex.is_complete = 1; else kleenex.is_complete = 0; /* Load the sketch data */ if (kleenex.version & IBVERSION_PICTURE) { if (!d.sonyClie || !d.hires) { kleenex.data = BmpGetBits(WinGetBitmap(d.winbufM)); kleenex.data_size = BmpBitsSize(WinGetBitmap(d.winbufM)); } else { kleenex.data = BmpGetBits(WinGetBitmap(d.winbufM)); kleenex.data_size = HRBmpBitsSize(d.sonyHRRefNum, WinGetBitmap(d.winbufM)); } } /* Call the plugin */ err = SysAppLaunch(pluglistP[current_plug].cardNo, pluglistP[current_plug].dbID, 0, boogerPlugLaunchCmdBlowNose, (MemPtr)&kleenex, &result); /* Clean up some stuff */ MemHandleUnlock(d.xfer.pluglistH); MemPtrFree(kleenex.text); if (err || result) { FrmAlert(PluginError); return; } /* Just to save some typing */ is_goto = (((p.flags&PFLAGS_XFER_GOTO) || (xferGotoIsAlways)) && !(xferGotoIsNever)); if (!is_goto) FlashWaitMessage(XferSavingString); /* Clean up some more */ MemHandleUnlock(d.record_name); MemHandleUnlock(d.record_note); /* Delete the sketch if selected */ if (p.flags&PFLAGS_XFER_DELETE) DoCmdRemove(); /* Goto the new sketch if required */ if (is_goto) { /* Clean up */ MemHandleFree(d.xfer.pluglistH); d.xfer.pluglistH = NULL; /* Switch to other application */ err = SysUIAppSwitch(kleenex.booger.cardNo, kleenex.booger.dbID, kleenex.booger.cmd, kleenex.booger.cmdPBP); /* Clean up on error */ if (err && kleenex.booger.cmdPBP) MemPtrFree(kleenex.booger.cmdPBP); } else { if (kleenex.booger.cmdPBP) MemPtrFree(kleenex.booger.cmdPBP); } CancelXferMode(); }