// Read/Write versions.
//*****************************************************************************
// Init the Stgdb and its subcomponents.
//*****************************************************************************
HRESULT CLiteWeightStgdbRW::InitNew()
{ 
    InitializeLogging();
    LOG((LF_METADATA, LL_INFO10, "Metadata logging enabled\n"));

    return m_MiniMd.InitNew();
}
Пример #2
0
MainWindow::MainWindow(std::unique_ptr<Application> app):
    app_(std::move(app)),
    ui(new Ui::MainWindow),
    current_search_(nullptr),
    search_count_(0),
    auto_online_(app_->data_manager(), app_->sensitive_data_manager())
{
#ifdef Q_OS_WIN32
    createWinId();
    taskbar_button_ = new QWinTaskbarButton(this);
    taskbar_button_->setWindow(this->windowHandle());
#endif
    image_cache_ = new ImageCache(Filesystem::UserDir() + "/cache");

    InitializeUi();
    InitializeLogging();
    InitializeSearchForm();
    NewSearch();

    image_network_manager_ = new QNetworkAccessManager;
    connect(image_network_manager_, SIGNAL(finished(QNetworkReply*)),
            this, SLOT(OnImageFetched(QNetworkReply*)));

    connect(&app_->items_manager(), SIGNAL(ItemsRefreshed(Items, std::vector<std::string>)),
        this, SLOT(OnItemsRefreshed()));
    connect(&app_->items_manager(), SIGNAL(StatusUpdate(ItemsFetchStatus)), this, SLOT(OnItemsManagerStatusUpdate(ItemsFetchStatus)));
    connect(&update_checker_, &UpdateChecker::UpdateAvailable, this, &MainWindow::OnUpdateAvailable);
    connect(&auto_online_, &AutoOnline::Update, this, &MainWindow::OnOnlineUpdate);
}
Пример #3
0
GTEST_API_ int main(int argc,
                    char **argv) {
   InitializeLogging();
   log4cplus::Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("main"));
   LOG4CPLUS_INFO(logger, "Running main()");
   testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
}
Пример #4
0
// Read/Write versions.
//*****************************************************************************
// Init the Stgdb and its subcomponents.
//*****************************************************************************
__checkReturn 
HRESULT CLiteWeightStgdbRW::InitNew()
{ 
    InitializeLogging();
    LOG((LF_METADATA, LL_INFO10, "Metadata logging enabled\n"));

    //<TODO>@FUTURE: should probably init the pools here instead of in the MiniMd.</TODO>
    return m_MiniMd.InitNew();
}
Пример #5
0
int	initialize_global_cs(void)
{
	static	int	init = 1;

	if (!init)
		return 0;
	init = 0;
	InitializeLogging();
	memset(&globals, 0, sizeof(globals));

	return 0;
}
Пример #6
0
int main(int argc, char* argv[])
{
#ifdef M_TRIM_THRESHOLD
// Prevent fragmentation of the heap by malloc (glibc).
//
// The default threshold is 128*1024, which can result in a large memory usage
// due to fragmentation since we use a lot of small objects. On the other hand
// if the threshold is too low, free() starts to permanently ask the kernel
// about shrinking the heap.
#ifdef HAVE_UNISTD_H
    int pagesize = sysconf(_SC_PAGESIZE);
#else
    int pagesize = 4*1024;
#endif
    mallopt(M_TRIM_THRESHOLD, 5*pagesize);
#endif
    Interface::SanityCheck(VERSION_GEMRB);
    InitializeLogging();

    core = new Interface( argc, argv );
    if (core->Init() == GEM_ERROR) {
        delete( core );
        print("Press enter to continue...");
        textcolor(DEFAULT);
        getc(stdin);
        ShutdownLogging();
        return -1;
    }
#ifdef ANDROID
#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(1,3,0)
    SDL_ANDROID_SetApplicationPutToBackgroundCallback(&appPutToBackground, &appPutToForeground);
#endif
#endif
    core->Main();
    delete( core );
    textcolor(DEFAULT);
    ShutdownLogging();
    return 0;
}
Пример #7
0
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPTSTR lpstrCmdLine, int nCmdShow) {
    g_hInstance = hInstance;
    json_value* appSettings = GetApplicationSettings();
    if (GetApplicationSettingsError().length()) {
        std::string error = GetApplicationSettingsError();
        error.append("\nApplication will terminate immediately. ");
        FatalError(NULL, error);
    }

    // Debugging options.
    bool show_console = (*appSettings)["debugging"]["show_console"];
    bool subprocess_show_console = (*appSettings)["debugging"]["subprocess_show_console"];
    std::string log_level = (*appSettings)["debugging"]["log_level"];
    std::string log_file = (*appSettings)["debugging"]["log_file"];
    log_file = GetAbsolutePath(log_file);
    
    // Initialize logging.
    if (std::wstring(lpstrCmdLine).find(L"--type=") != std::string::npos) {
        // This is a subprocess.
        InitializeLogging(subprocess_show_console, log_level, log_file);
    } else {
        // Main browser process.
        InitializeLogging(show_console, log_level, log_file);
    }

    // Command line arguments
    LPWSTR *argv;
    int argc;
    argv = CommandLineToArgvW(GetCommandLineW(), &argc);
    if (argv) {
        for (int i = 0; i < argc; i++) {
            std::string argument = WideToUtf8(std::wstring(argv[i]));
            size_t pos = argument.find("=");
            if (pos != std::string::npos) {
                std::string name = argument.substr(0, pos);
                std::string value = argument.substr(pos+1, std::string::npos);
                if (name == "--cgi-environment" && value.length()) {
                    g_cgiEnvironmentFromArgv.assign(value);
                }
            }
        }
    } else {
        LOG_WARNING << "CommandLineToArgvW() failed";
    }

    // CEF subprocesses.
    CefMainArgs main_args(hInstance);
    CefRefPtr<App> app(new App);
    int exit_code = CefExecuteProcess(main_args, app.get(), NULL);
    if (exit_code >= 0) {
        ShutdownLogging();
        return exit_code;
    }

    LOG_INFO << "--------------------------------------------------------";
    LOG_INFO << "Started application";

    if (log_file.length())
        LOG_INFO << "Logging to: " << log_file;
    else
        LOG_INFO << "No logging file set";
    LOG_INFO << "Log level = "
             << FILELog::ToString(FILELog::ReportingLevel());

    // Main window title option.
    std::string main_window_title = (*appSettings)["main_window"]["title"];
    if (main_window_title.empty())
        main_window_title = GetExecutableName();

    // Single instance guid option.
    const char* single_instance_guid =
            (*appSettings)["application"]["single_instance_guid"];
    if (single_instance_guid && single_instance_guid[0] != 0) {
        int guidSize = strlen(single_instance_guid) + 1;
        g_singleInstanceApplicationGuid = new wchar_t[guidSize];
        Utf8ToWide(single_instance_guid, g_singleInstanceApplicationGuid,
                   guidSize);
    }
    if (g_singleInstanceApplicationGuid
            && g_singleInstanceApplicationGuid[0] != 0) {
        g_singleInstanceApplication.Initialize(
                g_singleInstanceApplicationGuid);
	    if (g_singleInstanceApplication.IsRunning()) {
            HWND hwnd = FindWindow(g_singleInstanceApplicationGuid, NULL);
            if (hwnd) {
                if (IsIconic(hwnd))
                    ShowWindow(hwnd, SW_RESTORE);
                SetForegroundWindow(hwnd);
                return 0;
            }
        }
    }

    // Window class name.
    if (g_singleInstanceApplicationGuid) {
        swprintf_s(g_windowClassName, _countof(g_windowClassName), L"%s",
                   g_singleInstanceApplicationGuid);
    } else {
        swprintf_s(g_windowClassName, _countof(g_windowClassName), L"%s",
                   Utf8ToWide(GetExecutableName()).c_str());
    }

    if (!StartWebServer()) {
        FatalError(NULL, "Error while starting an internal local server.\n"
                   "Application will terminate immediately.");
    }

    CefSettings cef_settings;

    // log_file
    std::string chrome_log_file = (*appSettings)["chrome"]["log_file"];
    chrome_log_file = GetAbsolutePath(chrome_log_file);
    CefString(&cef_settings.log_file) = chrome_log_file;

    // log_severity
    std::string chrome_log_severity = (*appSettings)["chrome"]["log_severity"];
    cef_log_severity_t log_severity = LOGSEVERITY_DEFAULT;
    if (chrome_log_severity == "verbose") {
        log_severity = LOGSEVERITY_VERBOSE;
    } else if (chrome_log_severity == "info") {
        log_severity = LOGSEVERITY_INFO;
    } else if (chrome_log_severity == "warning") {
        log_severity = LOGSEVERITY_WARNING;
    } else if (chrome_log_severity == "error") {
        log_severity = LOGSEVERITY_ERROR;
    } else if (chrome_log_severity == "error-report") {
        log_severity = LOGSEVERITY_ERROR_REPORT;
    } else if (chrome_log_severity == "disable") {
        log_severity = LOGSEVERITY_DISABLE;
    }
    cef_settings.log_severity = log_severity;

    // cache_path
    std::string cache_path = (*appSettings)["chrome"]["cache_path"];
    cache_path = GetAbsolutePath(cache_path);
    CefString(&cef_settings.cache_path) = cache_path;

    // remote_debugging_port
    // A value of -1 will disable remote debugging.
    int remote_debugging_port = static_cast<long>(
            (*appSettings)["chrome"]["remote_debugging_port"]);
    if (remote_debugging_port == 0) {
        remote_debugging_port = random(49152, 65535+1);
        int i = 100;
        while (((i--) > 0) && remote_debugging_port == GetWebServerPort()) {
            remote_debugging_port = random(49152, 65535+1);
        }
    }
    if (remote_debugging_port > 0) {
        LOG_INFO << "remote_debugging_port = " << remote_debugging_port;
        cef_settings.remote_debugging_port = remote_debugging_port;
    }

    // Sandbox support
    cef_settings.no_sandbox = true;

    CefInitialize(main_args, cef_settings, app.get(), NULL);
    CreateMainWindow(hInstance, nCmdShow, main_window_title);
    CefRunMessageLoop();
    CefShutdown();

    LOG_INFO << "Ended application";
    LOG_INFO << "--------------------------------------------------------";

    ShutdownLogging();

    return 0;
}
//--------------------------------------------------------------------------//
//                                                                          //
//--------------------------------------------------------------------------//
BOOL StartHttpService(int argc, char *argv[])
{
    HANDLE hEventLog = NULL;
    BOOL bReturn = FALSE;
    char szReconfigEvent[MAX_PATH];
    char szDoneEvent[MAX_PATH];
    PRStatus webserver_run_status = PR_SUCCESS;

    // Process the argv and extract config_root into unique_name. 
    // Use this to name events.

    int c;
    char *serverconfig = NULL;
    while ((c = getopt(argc, argv, "s:n:d:r:f:cvi")) != -1) {
        switch(c) {
        case 'd':
            serverconfig = optarg;
            break;
        default:
            break;
        }
    }
    if (!serverconfig || !serverconfig[0])
        goto cleanup;

    // canonicalize the server config dir path in case it is a relative
    // path and use it to generate a unique id that is used for all server
    // to watchdog communication
    serverconfig = file_canonicalize_path(serverconfig);
    unique_name = set_uniquename(serverconfig);
    FREE(serverconfig);

    hEventLog = InitializeLogging(unique_name);

    wsprintf(szDoneEvent, "NS_%s", unique_name);

    phEvents[WS_SHUTDOWN] = OpenEvent(EVENT_ALL_ACCESS, FALSE, szDoneEvent);
    if (phEvents[WS_SHUTDOWN] != NULL)
    {
        // should not exist
        goto cleanup;
    }

    phEvents[WS_SHUTDOWN] = CreateEvent(NULL, TRUE, FALSE, szDoneEvent);
    if (phEvents[WS_SHUTDOWN] == NULL)
	goto cleanup;

    wsprintf(szReconfigEvent, "NR_%s", unique_name);

    phEvents[WS_RECONFIG] = OpenEvent(EVENT_ALL_ACCESS, FALSE, szReconfigEvent);
    if (phEvents[WS_RECONFIG] != NULL)
    {
        // should not exist
        goto cleanup;
    }

    phEvents[WS_RECONFIG] = CreateEvent(NULL, TRUE, FALSE, szReconfigEvent);
    if (phEvents[WS_RECONFIG] == NULL)
	goto cleanup;

    if (WebServer::Init(argc, argv) == PR_FAILURE)
        goto cleanup;

    MainThread = PR_CreateThread(PR_USER_THREAD,
				 webserver_run,
				 &webserver_run_status,
				 PR_PRIORITY_NORMAL,
				 PR_GLOBAL_THREAD,
				 PR_UNJOINABLE_THREAD,
				 65536);
    if (MainThread == NULL)
	goto cleanup;

    PRThread *thread;
			
    /* In NSPR20, the first thread becomes a user thread.
     * You can't go to sleep on a blocking call like WaitForSingleObject
     * or you'll kill the whole process.
     * So send it off to a native thread before Wait()ing.
     */
    thread = PR_CreateThread(PR_USER_THREAD,
				_WaitSignalThread,
				NULL,
				PR_PRIORITY_NORMAL,
				PR_GLOBAL_THREAD,
				PR_JOINABLE_THREAD,
				0);
			
    if (thread == NULL)
	goto cleanup;

    // the MainThread runs the server at this point, while we wait for
    // the WaitSignalThread to end

    PR_JoinThread(thread);

    if (webserver_run_status == PR_SUCCESS) {
        SuspendHttpdService();
        bReturn = TRUE;
    }
	
cleanup:
    if(!bReturn)
        LogErrorEvent(NULL, EVENTLOG_ERROR_TYPE, 0, MSG_BAD_STARTUP, "Initialization Failed", "");

    WebServer::Cleanup();

    TerminateLogging(hEventLog);

    if (phEvents[WS_SHUTDOWN])
        CLOSEHANDLE(phEvents[WS_SHUTDOWN]);

    if (phEvents[WS_RECONFIG])
        CLOSEHANDLE(phEvents[WS_RECONFIG]);

    return bReturn;
}
Пример #9
0
	virtual void StartupModule() override
	{
		// load required libraries
		IMediaModule* MediaModule = FModuleManager::LoadModulePtr<IMediaModule>("Media");

		if (MediaModule == nullptr)
		{
			UE_LOG(LogVlcMedia, Warning, TEXT("Failed to load Media module"));

			return;
		}

		// initialize LibVLC
		if (!FVlc::Initialize())
		{
			UE_LOG(LogVlcMedia, Warning, TEXT("Failed to initialize libvlc"));

			return;
		}

		// register settings
		ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");

		if (SettingsModule != nullptr)
		{
			ISettingsSectionPtr SettingsSection = SettingsModule->RegisterSettings("Project", "Plugins", "VlcMedia",
				LOCTEXT("VlcMediaSettingsName", "VLC Media"),
				LOCTEXT("VlcMediaSettingsDescription", "Configure the VLC Media plug-in."),
				GetMutableDefault<UVlcMediaSettings>()
			);

			if (SettingsSection.IsValid())
			{
				SettingsSection->OnModified().BindRaw(this, &FVlcMediaModule::HandleSettingsSaved);
			}
		}

		// create LibVLC instance
		const ANSICHAR* Args[] =
		{
			TCHAR_TO_ANSI(*(FString(TEXT("--plugin-path=")) + FVlc::GetPluginDir())),
			"--aout", "amem",
			"--intf", "dummy",
			"--no-disable-screensaver",
//			"--no-osd",
			"--no-snapshot-preview",
			"--no-stats",
			"--no-video-title-show",
			"--no-xlib",
//			"--text-renderer", "dummy",
			"--vout", "vmem",
			"--vmem-chroma", "RV32"
		};

		int Argc = sizeof(Args) / sizeof(*Args);
		VlcInstance = FVlc::New(Argc, Args);

		if (VlcInstance == nullptr)
		{
			UE_LOG(LogVlcMedia, Warning, TEXT("Failed to create VLC instance (%s)"), ANSI_TO_TCHAR(FVlc::Errmsg()));
			FVlc::Shutdown();

			return;
		}

		// register logging callback
		InitializeLogging();	

		// initialize supported media formats
		SupportedFileTypes.Add(TEXT("3gp"), LOCTEXT("Format3gp", "3GP Video Stream"));
		SupportedFileTypes.Add(TEXT("a52"), LOCTEXT("FormatA52", "Dolby Digital AC-3 Audio"));
		SupportedFileTypes.Add(TEXT("aac"), LOCTEXT("FormatAac", "MPEG-2 Advanced Audio Coding File"));
		SupportedFileTypes.Add(TEXT("asf"), LOCTEXT("FormatAsf", "ASF Media File"));
		SupportedFileTypes.Add(TEXT("au"), LOCTEXT("FormatAu", "Sun Microsystems Audio"));
		SupportedFileTypes.Add(TEXT("avi"), LOCTEXT("FormatAvi", "Audio Video Interleave File"));
		SupportedFileTypes.Add(TEXT("dts"), LOCTEXT("FormatDts", "Digital Theater System File"));
		SupportedFileTypes.Add(TEXT("dv"), LOCTEXT("FormatDv", "Digital Video File"));
		SupportedFileTypes.Add(TEXT("flac"), LOCTEXT("FormatFlac", "Free Lossless Audio Codec"));
		SupportedFileTypes.Add(TEXT("flv"), LOCTEXT("FormatFlv", "Adobe Flash Video"));
		SupportedFileTypes.Add(TEXT("mkv"), LOCTEXT("FormatMkv", "Matroska Video"));
		SupportedFileTypes.Add(TEXT("mka"), LOCTEXT("FormatMka", "Matroska Audio"));
		SupportedFileTypes.Add(TEXT("mov"), LOCTEXT("FormatMov", "Apple QuickTime Movie"));
		SupportedFileTypes.Add(TEXT("mp2"), LOCTEXT("FormatMp2", "MPEG-1 Audio"));
		SupportedFileTypes.Add(TEXT("mp3"), LOCTEXT("FormatMp3", "MPEG-2 Audio"));
		SupportedFileTypes.Add(TEXT("mp4"), LOCTEXT("FormatMp4", "MPEG-4 Movie"));
		SupportedFileTypes.Add(TEXT("mpg"), LOCTEXT("FormatMpg", "MPEG-2 Movie"));
		SupportedFileTypes.Add(TEXT("nsc"), LOCTEXT("FormatNsc", "Windows Media Station"));
		SupportedFileTypes.Add(TEXT("nsv"), LOCTEXT("FormatNsv", "Nullsoft Streaming Video"));
		SupportedFileTypes.Add(TEXT("nut"), LOCTEXT("FormatNut", "NUT Multimedia Container"));
		SupportedFileTypes.Add(TEXT("ogm"), LOCTEXT("FormatMp4", "Ogg Multimedia"));
		SupportedFileTypes.Add(TEXT("ogg"), LOCTEXT("FormatOgg", "Ogg Multimedia"));
		SupportedFileTypes.Add(TEXT("ra"), LOCTEXT("FormatRa", "Real Audio"));
		SupportedFileTypes.Add(TEXT("ram"), LOCTEXT("FormatRam", "Real Audio Metadata"));
		SupportedFileTypes.Add(TEXT("rm"), LOCTEXT("FormatRm", "Real Media"));
		SupportedFileTypes.Add(TEXT("rmvb"), LOCTEXT("FormatRmvb", "Real Media VBR"));
		SupportedFileTypes.Add(TEXT("rv"), LOCTEXT("FormatRv", "Real Video"));
		SupportedFileTypes.Add(TEXT("ts"), LOCTEXT("FormatTs", "MPEG-2 Transport Stream"));
		SupportedFileTypes.Add(TEXT("tac"), LOCTEXT("FormatTac", "True Audio Codec File"));
		SupportedFileTypes.Add(TEXT("tta"), LOCTEXT("FormatTta", "True Audio Codec File"));
		SupportedFileTypes.Add(TEXT("ty"), LOCTEXT("FormatTy", "Tivo Container"));
		SupportedFileTypes.Add(TEXT("vid"), LOCTEXT("FormatVid", "Generic Video File"));
		SupportedFileTypes.Add(TEXT("wav"), LOCTEXT("FormatWav", "Wave Audio File"));
		SupportedFileTypes.Add(TEXT("wmv"), LOCTEXT("FormatWmv", "Windows Media Video"));
		SupportedFileTypes.Add(TEXT("xa"), LOCTEXT("FormatXa", "PlayStation Audio File"));

		// initialize supported URI schemes
		SupportedUriSchemes.Add(TEXT("cdda://"));
		SupportedUriSchemes.Add(TEXT("file://"));
		SupportedUriSchemes.Add(TEXT("dvd://"));
		SupportedUriSchemes.Add(TEXT("ftp://"));
		SupportedUriSchemes.Add(TEXT("http://"));
		SupportedUriSchemes.Add(TEXT("https://"));
		SupportedUriSchemes.Add(TEXT("mms://"));
		SupportedUriSchemes.Add(TEXT("rtp://"));
		SupportedUriSchemes.Add(TEXT("rtsp://"));
		SupportedUriSchemes.Add(TEXT("sap://"));
		SupportedUriSchemes.Add(TEXT("screen://"));
		SupportedUriSchemes.Add(TEXT("vcd://"));

		// register factory
		MediaModule->RegisterPlayerFactory(*this);

		Initialized = true;
	}
Пример #10
0
	/** Callback for when the settings were saved. */
	bool HandleSettingsSaved()
	{
		InitializeLogging();

		return true;
	}