bool Myth::ProfileSubmit() { bool bResult = false; HardwareProfile profile; LOG(VB_GENERAL, LOG_NOTICE, "Profile Submission..."); profile.GenerateUUIDs(); bResult = profile.SubmitProfile(); if (bResult) LOG(VB_GENERAL, LOG_NOTICE, "Profile Submitted."); return bResult; }
bool Myth::ProfileSubmit() { bool bResult = false; HardwareProfile *profile = new HardwareProfile(); if (profile) { LOG(VB_GENERAL, LOG_NOTICE, "Profile Submission..."); profile->GenerateUUIDs(); bResult = profile->SubmitProfile(); if (bResult) LOG(VB_GENERAL, LOG_NOTICE, "Profile Submitted."); } delete profile; return bResult; }
bool HardwareProfileTask::DoRun(void) { HardwareProfile hp; return hp.SubmitProfile(false); }
int main(int argc, char **argv) { bool bPromptForBackend = false; bool bBypassAutoDiscovery = false; bool upgradeAllowed = false; bool cmdline_err; MythCommandLineParser cmdline( kCLPOverrideSettingsFile | kCLPOverrideSettings | kCLPWindowed | kCLPNoWindowed | kCLPGetSettings | kCLPQueryVersion | kCLPVerbose | kCLPNoUPnP | #ifdef USING_X11 kCLPDisplay | #endif // USING_X11 kCLPExtra | kCLPGeometry); // Handle --help before QApplication is created, so that // we can print help even if X11 is absent. for (int argpos = 1; argpos < argc; ++argpos) { QString arg(argv[argpos]); if (arg == "-h" || arg == "--help" || arg == "--usage") { ShowUsage(cmdline); return GENERIC_EXIT_OK; } } for (int argpos = 1; argpos < argc; ++argpos) { if (cmdline.PreParse(argc, argv, argpos, cmdline_err)) { if (cmdline_err) return GENERIC_EXIT_INVALID_CMDLINE; if (cmdline.WantsToExit()) return GENERIC_EXIT_OK; } } #ifdef Q_WS_MACX // Without this, we can't set focus to any of the CheckBoxSetting, and most // of the MythPushButton widgets, and they don't use the themed background. QApplication::setDesktopSettingsAware(false); #endif QApplication a(argc, argv); QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHFRONTEND); QString pluginname; QFileInfo finfo(a.argv()[0]); QString binname = finfo.baseName(); VERBOSE(VB_IMPORTANT, QString("%1 version: %2 [%3] www.mythtv.org") .arg(MYTH_APPNAME_MYTHFRONTEND) .arg(MYTH_SOURCE_PATH) .arg(MYTH_SOURCE_VERSION)); bool ResetSettings = false; if (binname.toLower() != "mythfrontend") pluginname = binname; for (int argpos = 1; argpos < a.argc(); ++argpos) { if (!strcmp(a.argv()[argpos],"--prompt") || !strcmp(a.argv()[argpos],"-p" )) { bPromptForBackend = true; } else if (!strcmp(a.argv()[argpos],"--disable-autodiscovery") || !strcmp(a.argv()[argpos],"-d" )) { bBypassAutoDiscovery = true; } else if (!strcmp(a.argv()[argpos],"-l") || !strcmp(a.argv()[argpos],"--logfile")) { if (a.argc()-1 > argpos) { logfile = a.argv()[argpos+1]; if (logfile.startsWith('-')) { cerr << "Invalid or missing argument" " to -l/--logfile option\n"; return GENERIC_EXIT_INVALID_CMDLINE; } else { ++argpos; } } else { cerr << "Missing argument to -l/--logfile option\n"; return GENERIC_EXIT_INVALID_CMDLINE; } } else if (cmdline.Parse(a.argc(), a.argv(), argpos, cmdline_err)) { if (cmdline_err) return GENERIC_EXIT_INVALID_CMDLINE; if (cmdline.WantsToExit()) return GENERIC_EXIT_OK; } } QMap<QString,QString> settingsOverride = cmdline.GetSettingsOverride(); if (logfile.size()) { if (log_rotate(1) < 0) cerr << "cannot open logfile; using stdout/stderr" << endl; else { VERBOSE(VB_IMPORTANT, QString("%1 version: %2 [%3] www.mythtv.org") .arg(MYTH_APPNAME_MYTHFRONTEND) .arg(MYTH_SOURCE_PATH) .arg(MYTH_SOURCE_VERSION)); signal(SIGHUP, &log_rotate_handler); } } if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) cerr << "Unable to ignore SIGPIPE\n"; if (!cmdline.GetDisplay().isEmpty()) { MythUIHelper::SetX11Display(cmdline.GetDisplay()); } if (!cmdline.GetGeometry().isEmpty()) { MythUIHelper::ParseGeometryOverride(cmdline.GetGeometry()); } CleanupGuard callCleanup(cleanup); gContext = new MythContext(MYTH_BINARY_VERSION); if (cmdline.IsUPnPEnabled()) { g_pUPnp = new MediaRenderer(); if (!g_pUPnp->initialized()) { delete g_pUPnp; g_pUPnp = NULL; } } // Override settings as early as possible to cover bootstrapped screens // such as the language prompt settingsOverride = cmdline.GetSettingsOverride(); if (settingsOverride.size()) { QMap<QString, QString>::iterator it; for (it = settingsOverride.begin(); it != settingsOverride.end(); ++it) { VERBOSE(VB_IMPORTANT, QString("Setting '%1' being forced to '%2'") .arg(it.key()).arg(*it)); gCoreContext->OverrideSettingForSession(it.key(), *it); } } if (!gContext->Init(true, bPromptForBackend, bBypassAutoDiscovery)) { VERBOSE(VB_IMPORTANT, "Failed to init MythContext, exiting."); return GENERIC_EXIT_NO_MYTHCONTEXT; } if (!GetMythDB()->HaveSchema()) { if (!InitializeMythSchema()) return GENERIC_EXIT_DB_ERROR; } for(int argpos = 1; argpos < a.argc(); ++argpos) { if (!strcmp(a.argv()[argpos],"-l") || !strcmp(a.argv()[argpos],"--logfile")) { // Arg processing for logfile already done (before MythContext) ++argpos; } else if (!strcmp(a.argv()[argpos],"-v") || !strcmp(a.argv()[argpos],"--verbose")) { // Arg processing for verbose already done (before MythContext) ++argpos; } else if (!strcmp(a.argv()[argpos],"-r") || !strcmp(a.argv()[argpos],"--reset")) { ResetSettings = true; } else if (!strcmp(a.argv()[argpos],"--prompt") || !strcmp(a.argv()[argpos],"-p" )) { } else if (!strcmp(a.argv()[argpos],"--disable-autodiscovery") || !strcmp(a.argv()[argpos],"-d" )) { } else if (!strcmp(a.argv()[argpos],"--upgrade-schema") || !strcmp(a.argv()[argpos],"-u" )) { upgradeAllowed = true; } else if (cmdline.Parse(a.argc(), a.argv(), argpos, cmdline_err)) { if (cmdline_err) { return GENERIC_EXIT_INVALID_CMDLINE; } if (cmdline.WantsToExit()) { return GENERIC_EXIT_OK; } } else if ((argpos + 1 == a.argc()) && (!QString(a.argv()[argpos]).startsWith('-'))) { pluginname = a.argv()[argpos]; } else { cerr << "Invalid argument: " << a.argv()[argpos] << endl; ShowUsage(cmdline); return GENERIC_EXIT_INVALID_CMDLINE; } } QStringList settingsQuery = cmdline.GetSettingsQuery(); if (!settingsQuery.empty()) { QStringList::const_iterator it = settingsQuery.begin(); for (; it != settingsQuery.end(); ++it) { QString value = gCoreContext->GetSetting(*it); QString out = QString("\tSettings Value : %1 = %2") .arg(*it).arg(value); cout << out.toLocal8Bit().constData() << endl; } return GENERIC_EXIT_OK; } QString fileprefix = GetConfDir(); QDir dir(fileprefix); if (!dir.exists()) dir.mkdir(fileprefix); if (ResetSettings) { AppearanceSettings as; as.Save(); gCoreContext->SaveSetting("Theme", DEFAULT_UI_THEME); gCoreContext->SaveSetting("Language", ""); gCoreContext->SaveSetting("Country", ""); return GENERIC_EXIT_OK; } setuid(getuid()); VERBOSE(VB_IMPORTANT, QString("Enabled verbose msgs: %1").arg(verboseString)); LCD::SetupLCD(); if (LCD *lcd = LCD::Get()) lcd->setupLEDs(RemoteGetRecordingMask); MythTranslation::load("mythfrontend"); QString themename = gCoreContext->GetSetting("Theme", DEFAULT_UI_THEME); QString themedir = GetMythUI()->FindThemeDir(themename); if (themedir.isEmpty()) { VERBOSE(VB_IMPORTANT, QString("Couldn't find theme '%1'") .arg(themename)); return GENERIC_EXIT_NO_THEME; } GetMythUI()->LoadQtConfig(); themename = gCoreContext->GetSetting("Theme", DEFAULT_UI_THEME); themedir = GetMythUI()->FindThemeDir(themename); if (themedir.isEmpty()) { VERBOSE(VB_IMPORTANT, QString("Couldn't find theme '%1'") .arg(themename)); return GENERIC_EXIT_NO_THEME; } MythMainWindow *mainWindow = GetMythMainWindow(); mainWindow->Init(); mainWindow->setWindowTitle(QObject::tr("MythTV Frontend")); // We must reload the translation after a language change and this // also means clearing the cached/loaded theme strings, so reload the // theme which also triggers a translation reload if (LanguageSelection::prompt()) { if (!reloadTheme()) return GENERIC_EXIT_NO_THEME; } if (!UpgradeTVDatabaseSchema(upgradeAllowed)) { VERBOSE(VB_IMPORTANT, "Couldn't upgrade database to new schema, exiting."); return GENERIC_EXIT_DB_OUTOFDATE; } WriteDefaults(); // Refresh Global/Main Menu keys after DB update in case there was no DB // when they were written originally mainWindow->ResetKeys(); InitJumpPoints(); internal_media_init(); CleanupMyOldInUsePrograms(); pmanager = new MythPluginManager(); gContext->SetPluginManager(pmanager); if (pluginname.size()) { if (pmanager->run_plugin(pluginname) || pmanager->run_plugin("myth" + pluginname)) { qApp->exec(); return GENERIC_EXIT_OK; } else return GENERIC_EXIT_INVALID_CMDLINE; } MediaMonitor *mon = MediaMonitor::GetMediaMonitor(); if (mon) { mon->StartMonitoring(); mainWindow->installEventFilter(mon); } NetworkControl *networkControl = NULL; if (gCoreContext->GetNumSetting("NetworkControlEnabled", 0)) { int networkPort = gCoreContext->GetNumSetting("NetworkControlPort", 6545); networkControl = new NetworkControl(); if (!networkControl->listen(QHostAddress::Any,networkPort)) VERBOSE(VB_IMPORTANT, QString("NetworkControl failed to bind to port %1.") .arg(networkPort)); } #ifdef __linux__ #ifdef CONFIG_BINDINGS_PYTHON HardwareProfile *profile = new HardwareProfile(); if (profile && profile->NeedsUpdate()) profile->SubmitProfile(); delete profile; #endif #endif if (!RunMenu(themedir, themename) && !resetTheme(themedir, themename)) { return GENERIC_EXIT_NO_THEME; } #ifndef _MSC_VER // Setup handler for USR1 signals to reload theme signal(SIGUSR1, &signal_USR1_handler); // Setup handler for USR2 signals to restart LIRC signal(SIGUSR2, &signal_USR2_handler); #endif ThemeUpdateChecker *themeUpdateChecker = NULL; if (gCoreContext->GetNumSetting("ThemeUpdateNofications", 1)) themeUpdateChecker = new ThemeUpdateChecker(); MythSystemEventHandler *sysEventHandler = new MythSystemEventHandler(); GetMythMainWindow()->RegisterSystemEventHandler(sysEventHandler); BackendConnectionManager bcm; PreviewGeneratorQueue::CreatePreviewGeneratorQueue( PreviewGenerator::kRemote, 50, 60); int ret = qApp->exec(); PreviewGeneratorQueue::TeardownPreviewGeneratorQueue(); if (themeUpdateChecker) delete themeUpdateChecker; delete sysEventHandler; pmanager->DestroyAllPlugins(); if (mon) mon->deleteLater(); delete networkControl; DestroyMythMainWindow(); return ret; }