int PackageModel::setPackage(const QString &path) { if (!m_structure) { kDebug() << "Must set the package type FIRST!"; return 0; } m_structure->setPath(path); delete m_package; m_package = new Plasma::Package(path, m_structure); delete m_directory; m_directory = new KDirWatch(this); m_directory->addDir(path, KDirWatch::WatchSubDirs | KDirWatch::WatchFiles); if (!loadPackage()) { delete m_directory; m_directory = 0; delete m_package; m_package = 0; return 0; } connect(m_directory, SIGNAL(created(QString)), this, SLOT(fileAddedOnDisk(QString))); connect(m_directory, SIGNAL(created(QString)), this, SLOT(loadPackage())); connect(m_directory, SIGNAL(deleted(QString)), this, SLOT(fileDeletedOnDisk(QString))); return 1; }
void mainLoop (void) { unsigned int getCurVoltageSample(); CtnrBlock *insertBlock; ListItem *list; int inactivityCheckCounter = 0; while(1) { // check if need to load in a new package if (context.queuedPackageType > PKG_NONE) { if (context.queuedPackageNameIndex != -1) loadPackage(context.queuedPackageType, pkgSystem.strHeapStack + context.queuedPackageNameIndex); else loadPackage(context.queuedPackageType, NULL); } // check for start or end event // todo: do we have to check SACM_Status() to see if stopped or can that be moved into the start/end event processing? if (SACM_Status() && !context.isPaused && compressTime(Snd_A1800_GetCurrentTime(),context.package->timePrecision) >= context.timeNextTimeframe) endOfTimeframe(context.idxTimeframe, FALSE); else if (!context.isStopped && !SACM_Status()) { // just stopped playing // this assume that stopped means end of audio file // todo: this should be checking end action for CtnrFile (doesn't exist yet) context.isStopped = TRUE; turnAmpOff(); markEndPlay(getRTCinSeconds()); flushLog(); if (GREEN_LED_WHEN_PLAYING) { setLED(LED_GREEN,FALSE); setLED(LED_RED,FALSE); } if (context.idxActiveList == -1) endOfTimeframe(context.idxTimeframe, TRUE); else { //process any end of play sound-insert //TODO: work this into other code; it's a bit of a one-off right now list = &context.package->lists[context.idxActiveList]; insertBlock = getEndInsert(list->actionStartEnd, list->idxFirstAction); if (insertBlock) insertSound(getFileFromBlock(insertBlock),insertBlock,FALSE); } if (context.package->pkg_type == PKG_MSG) { insertSound(&pkgSystem.files[POST_PLAY_FILE_IDX],NULL,FALSE); } } if (++inactivityCheckCounter > 10) { checkInactivity(!context.isStopped && !context.isPaused); inactivityCheckCounter = 0; if(vCur_1 < V_MIN_RUN_VOLTAGE) { refuse_lowvoltage(1); // not reached } } keyResponse(); } // end of while(1) loop }
void AccountFactory::setAccountId(const QString &accountId) { mAccountId = accountId; Sink::Store::fetchOne<Sink::ApplicationDomain::SinkAccount>(Sink::Query().filter(accountId.toUtf8())) .then([this](const Sink::ApplicationDomain::SinkAccount &account) { mAccountType = account.getProperty("type").toByteArray(); loadPackage(); }).exec(); }
/** * Perform the initial loading of a package. The loading * process involves resolving the external library and * attempting to resolve a Rexx package exporter routine * in the library. If the library loads, but does not have * the package exporter function, this is a classic library. * * If we do find a package exporter, then we can load all of * the routines immediately. Method loads are deferred until * the first request. * * @param manager The package manager we're attached to. * * @return True if we were able to load this as proper ooRexx package * file, false if either step failed. We do not throw * exceptions here, since these are usually loaded in the * context of operations that return an error result instead * of an exception. */ bool LibraryPackage::load() { // try to load the package table. package = getPackageTable(); // if this is NULL, return false to the manager if (package == NULL) { return false; } // call the loader to get the package tables and set them up. loadPackage(); return true; }
void bootstrap(char * entry, char * bootPkg, char * version) { char errorMsg[MAX_MSG_LEN]; defineExitProg(); defineDieProg(); // defineTrapProg(); // defineObjectProg(kmain); defineResumeProgs(); /* define the resume entry points */ ptrI mainThread = newThread(); processPo root = rootProcess(mainThread, bootPkg); // We create the root with a early death code - updated later switch (loadPackage(bootPkg, version, errorMsg, NumberOf(errorMsg), NULL)) { default: logMsg(logFile, "corrupt or no boot package found in %s:%s", bootPkg, errorMsg); lo_exit(EXIT_FAIL); return; case Eof: logMsg(logFile, "short boot package %s", bootPkg); lo_exit(EXIT_FAIL); return; case Ok: { ptrI prog = newProgramLbl(entry, 0); if (!IsProgram(prog)) { logMsg(logFile, "%U entry point not found", entry); lo_exit(EXIT_FAIL); } else { root->proc.PROG = ProgramOf(prog); /* this is where we establish the program */ root->proc.PC = FirstInstruction(root->proc.PROG); root->proc.thread = kmainThread; runGo(root); } } } }
void startUp(void) { char buffer[200]; char strCounts[20]; int key; SetSystemClockRate(MAX_CLOCK_SPEED); // to speed up initial startup -- set CLOCK_RATE later setDefaults(); setLED(LED_RED,FALSE); // red light can be left on after reprog restart setLED(LED_GREEN,TRUE); // red light can be left on after reprog restart //to stop user from wondering if power is on and possibly cycling too quickly, playDing(); // it is important to play a sound immediately key = keyCheck(1); // long keycheck // voltage checks in SystemIntoUSB.c if (key == KEY_STAR || key == KEY_MINUS) { // allows USB device mode no matter what is on memory card Snd_Stop(); SystemIntoUDisk(1); loadConfigFile(); processInbox(); resetSystem(); } else if (key == KEY_PLUS) { // outbox mode: copy outbox files to connecting device loadConfigFile(); copyOutbox(); resetSystem(); } // check for new firmware first, but don't flash if voltage is low if(V_MIN_SDWRITE_VOLTAGE <= vCur_1) { check_new_sd_flash(); } if (loadConfigFile() == -1) // config.txt file not found testPCB(); if (!SNexists()) logException(32,(const char *)"no serial number",SHUT_DOWN); SysDisableWaitMode(WAITMODE_CHANNEL_A); adjustVolume(NORMAL_VOLUME,FALSE,FALSE); adjustSpeed(NORMAL_SPEED,FALSE); loadDefaultPackage(); if (MACRO_FILE) loadMacro(); loadSystemCounts(); systemCounts.powerUpNumber++; if (systemCounts.powerUpNumber - systemCounts.lastLogErase > MAX_PWR_CYCLES_IN_LOG) { systemCounts.lastLogErase = systemCounts.powerUpNumber; clearStaleLog(); } #ifndef TB_CAN_WAKE resetRTC(); // reset before saving anything to disk and running macros #endif saveSystemCounts(); strcpy(buffer,"\x0d\x0a" "---------------------------------------------------\x0d\x0a"); strcat(buffer,getDeviceSN(1)); strcpy(strCounts,(char *)" counts:S"); longToDecimalString(systemCounts.powerUpNumber, strCounts+9, 4); strcat(strCounts,(char *)"P"); longToDecimalString(systemCounts.packageNumber, strCounts+14, 4); strcat(strCounts,(char *)"R"); longToDecimalString(systemCounts.revdPkgNumber, strCounts+19, 4); strcat(buffer,strCounts); strcat(buffer,"\x0d\x0a" "CYCLE "); //cycle number longToDecimalString(systemCounts.powerUpNumber,(char *)(buffer+strlen(buffer)),4); strcat(buffer,(const char *)" - version " VERSION); logString(buffer,BUFFER); #ifdef TB_CAN_WAKE logRTC(); #endif loadPackage(PKG_SYS,BOOT_PACKAGE); SetSystemClockRate(CLOCK_RATE); // either set in config file or the default 48 MHz set at beginning of startUp() mainLoop(); }
void PlasmoidHandler::createRequiredFiles(const QString &serviceType, const QString &pluginName, const QString &userName, const QString &userEmail, const QString &fileExtension) { // a package may require a file like ui/main.qml // but the ui dir may not be required, so lets check for them for (const auto &it : package().requiredFiles()) { if (m_directoryDefinitions.values().contains(it)) { const QString dirName(m_directoryDefinitions.key(it)); QDir dir(packagePath() + contentsPrefix()); dir.mkpath(dirName); dir.cd(dirName); QFile f; const QString filePath = dir.path() + QLatin1Char('/') + m_fileDefinitions[it]; QString templateFilePath; if (it == QLatin1String("mainscript")) { if (serviceType == "Plasma/Applet") { templateFilePath.append("mainPlasmoid"); } else if (serviceType == "KWin/WindowSwitcher") { templateFilePath.append("mainTabbox"); } else if (serviceType == "KWin/Script") { templateFilePath.append("mainKWinScript"); } else if (serviceType == "KWin/Effect") { templateFilePath.append("mainKWinEffect"); } f.setFileName(QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("templates/") + templateFilePath + fileExtension)); const bool ok = f.copy(filePath); if (!ok) { emit error(QStringLiteral("The mainscript file hasn't been created")); } f.setFileName(filePath); f.open(QIODevice::ReadWrite); // Now open these files, and substitute the main class, author, email and date fields QByteArray tmpPluginName(pluginName.toLocal8Bit()); QByteArray tmpAuthor(userName.toLocal8Bit()); QByteArray tmpEmail(userEmail.toLocal8Bit()); QByteArray rawData = f.readAll(); f.close(); f.open(QIODevice::WriteOnly); QByteArray replacedString("$PLASMOID_NAME"); if (rawData.contains(replacedString)) { rawData.replace(replacedString, tmpPluginName); } replacedString.clear(); replacedString.append("$AUTHOR"); if (rawData.contains(replacedString)) { rawData.replace(replacedString, tmpAuthor); } replacedString.clear(); replacedString.append("$EMAIL"); if (rawData.contains(replacedString)) { rawData.replace(replacedString, tmpEmail); } replacedString.clear(); replacedString.append("$DATE"); QDate date = QDate::currentDate(); QByteArray datetime(date.toString().toUtf8()); QTime time = QTime::currentTime(); datetime.append(", " + time.toString().toUtf8()); if (rawData.contains(replacedString)) { rawData.replace(replacedString, datetime); } f.write(rawData); f.close(); } } } loadPackage(); }
bool ClientEngine::initialize() { // Setup Window m_Window.setName("void"); // Connect to server ENetAddress address; if(enet_address_set_host(&address, "localhost") != 0) return false; address.port = 1234; if(!m_Client.connect(&address)) return false; // Setup Resource Manager m_ResourceManager.registerResourceType<Texture2dFile>(RES_TEXTURE2D); // Setup OpenGL glClearDepth(1); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); // Setup camera m_Camera.setNear(0.1); m_Camera.setFar(100); m_Camera.setRotation(Quaternion(vec3f(1,0,0), -tools4k::Pi*0.5)); m_Camera.setScreen(m_Window.size()); m_Camera.setFov(90); // Setup shader if(!m_Shader.load("Shader.vert", "Shader.frag")) return false; m_Shader.setUniform("DiffuseMap", 0); // Setup map { int myTileMap = m_ClientMap.createTileMap(); TileMap* tm = m_ClientMap.getTileMap(myTileMap); tm->diffuse = (Texture2dFile*)m_ResourceManager.loadResource(RES_TEXTURE2D, "tileset.png"); tm->tileSize = 32; tm->width = 128; int id = m_ClientMap.createVoxelType("Rock"); VoxelType* vt = m_ClientMap.getVoxelType(id); vt->collisionShape = VCSHAPE_CUBE; ClientVoxelType* cvt = m_ClientMap.getClientVoxelType(id); cvt->mesh = VCSHAPE_CUBE; cvt->renderMode = VRENDER_SOLID; cvt->tileMap = myTileMap; memset(cvt->faces, 0, sizeof(cvt->faces)); cvt->faces[VFACE_BACK] = 1; cvt->faces[VFACE_TOP] = 4; Voxel voxel; voxel.typeId = id; m_ClientMap.setVoxel(vec3i(0,0,0), voxel); m_ClientMap.setVoxel(vec3i(1,1,1), voxel); m_ClientMap.updateModel(aabb3i(vec3i(0,0,0), vec3i(10,10,10))); } if(!loadPackage("Base")) return false; return true; }
void AccountFactory::setAccountType(const QString &type) { mAccountType = type.toLatin1(); loadPackage(); }