bool WebAppManager::validateApplication(const ApplicationDescription& desc) { if (desc.id().length() == 0) return false; if (desc.entryPoint().isLocalFile() && !QFile::exists(desc.entryPoint().toLocalFile())) return false; return true; }
std::string ProcessManager::launchBootTimeApp(const std::string& appDescString) { std::string processId = processIdFactory(); ApplicationDescription* desc = ApplicationDescription::fromJsonString(appDescString.c_str()); WebAppManager::instance()->onLaunchUrl(desc->entryPoint().c_str(), Window::Type_None, appDescString.c_str(), processId.c_str(), "{\"launchedAtBoot\":true}", "", ""); delete desc; return processId; }
/** * Launch an application (webApps only, not native). * * @param appId The application ID to launch. * @param params The call parameters. * @param the ID of the application performing the launch (can be NULL). * @param launchingProcId (can be NULL). * @param errMsg The error message (will be empty if this call was successful). * * @todo: this should now be moved private and be protected...leaving it for now as to not break stuff and make things * slightly faster for intra-sysmgr mainloop launches * * @return The process ID of the newly launched application. Empty upon error. If empty lool at errMsg. */ std::string ProcessManager::launchModal(const std::string& appDescString, const std::string& params, const std::string& launchingAppId, const std::string& launchingProcId, std::string& errMsg, int& errorCode, bool isHeadless, bool isParentPdk) { std::string processId = ""; errMsg.erase(); Window::Type winType = Window::Type_ModalChildWindowCard; if(false == isParentPdk && 0 >= launchingProcId.size()) { errorCode = SystemUiController::MissingProcessId; errMsg = "Invalid processId of the calling process"; return processId; } ApplicationDescription* desc = ApplicationDescription::fromJsonString(appDescString.c_str()); if(!desc) { errorCode = SystemUiController::InternalError; errMsg = "Error getting ApplicationDescription for the app to be launched"; return processId; } errorCode = SystemUiController::NoErr; // always create a new card if the system wants a modal card to be created, no relaunching. std::string url = desc->entryPoint(); processId = processIdFactory(); // if we want to create a headless app, the type is Window::Type_None else it Window::Type_ModalChildWindowCard if(true == isHeadless) winType = Window::Type_None; // launch the app WebAppManager::instance()->onLaunchUrlChild(url.c_str(), winType, appDescString.c_str(), processId.c_str(), params.c_str(), launchingAppId.c_str(), launchingProcId.c_str(), errorCode, isHeadless); g_debug("Launched Id %s", processId.c_str() ); delete desc; return processId; }
/** * Launch an application (webApps only, not native). * * @param appId The application ID to launch. * @param params The call parameters. * @param the ID of the application performing the launch (can be NULL). * @param launchingProcId (can be NULL). * @param errMsg The error message (will be empty if this call was successful). * * @todo: this should now be moved private and be protected...leaving it for now as to not break stuff and make things * slightly faster for intra-sysmgr mainloop launches * * @return The process ID of the newly launched application. Empty upon error. If empty lool at errMsg. */ std::string ProcessManager::launch(const std::string& appDescString, const std::string& params, const std::string& launchingAppId, const std::string& launchingProcId, std::string& errMsg) { std::string processId = ""; ApplicationDescription* desc = ApplicationDescription::fromJsonString(appDescString.c_str()); errMsg.erase(); // This now will only launch Web Apps. Native Apps are now launched by the WebAppMgrProxy. // Find out what type of window we need to create Window::Type winType = Window::Type_Card; std::string winTypeStr; if (extractFromJson(params, "windowType", winTypeStr)) { if (winTypeStr == "dashboard") winType = Window::Type_Dashboard; else if (winTypeStr == "popupalert") winType = Window::Type_PopupAlert; else if (winTypeStr == "emergency") winType = Window::Type_Emergency; else if (winTypeStr == "dockModeWindow") // $$$ FIX THIS, it is just a patch to test Dock mode apps for now winType = Window::Type_DockModeWindow; else { winType = Window::Type_Emulated_Card; if (desc->uiRevision() == 2) { winType = Window::Type_Card; } } } if (winType == Window::Type_Card) { if (desc->uiRevision() != 2) { winType = Window::Type_Emulated_Card; } } // Get a list of all apps typedef std::list<const ProcessBase*> ProcessList; ProcessList runningApps = WebAppManager::instance()->runningApps(); const ProcessBase* app = 0; for (ProcessList::const_iterator it = runningApps.begin(); it != runningApps.end(); ++it) { if ((*it)->appId() == desc->id()) { app = (*it); processId = app->processId(); break; } } if (!app) { // App not running? Launch it std::string url = desc->entryPoint(); if (desc->isHeadLess()) winType = Window::Type_None; processId = processIdFactory(); WebAppManager::instance()->onLaunchUrl(url.c_str(), winType, appDescString.c_str(), processId.c_str(), params.c_str(), launchingAppId.c_str(), launchingProcId.c_str()); g_debug("Launched Id %s", processId.c_str() ); } else { WebAppManager::instance()->onRelaunchApp(processId.c_str(), params.c_str(), launchingAppId.c_str(), launchingProcId.c_str()); } delete desc; return processId; }