Esempio n. 1
0
bool CFileZillaApp::OnInit()
{
	AddStartupProfileRecord(_T("CFileZillaApp::OnInit()"));

	fz::set_translators(translator, translator_pf);

#ifdef __WXMSW__
	if (!InitWinsock()) {
		return false;
	}

	SetAppId();
#endif

	//wxSystemOptions is slow, if a value is not set, it keeps querying the environment
	//each and every time...
	wxSystemOptions::SetOption(_T("filesys.no-mimetypesmanager"), 0);
	wxSystemOptions::SetOption(_T("window-default-variant"), _T(""));
#ifdef __WXMSW__
	wxSystemOptions::SetOption(_T("no-maskblt"), 0);
	wxSystemOptions::SetOption(_T("msw.window.no-clip-children"), 0);
	wxSystemOptions::SetOption(_T("msw.font.no-proof-quality"), 0);
	wxSystemOptions::SetOption(_T("msw.remap"), 0);
	wxSystemOptions::SetOption(_T("msw.staticbox.optimized-paint"), 0);
#endif
#ifdef __WXMAC__
	wxSystemOptions::SetOption(_T("mac.listctrl.always_use_generic"), 1);
	wxSystemOptions::SetOption(_T("mac.textcontrol-use-spell-checker"), 0);
#endif

	int cmdline_result = ProcessCommandLine();
	if (!cmdline_result)
		return false;

	LoadLocales();

	if (cmdline_result < 0) {
		if (m_pCommandLine) {
			m_pCommandLine->DisplayUsage();
		}
		return false;
	}

	InitDefaultsDir();

	COptions::Init();

	InitLocale();

#ifndef _DEBUG
	const wxString& buildType = CBuildInfo::GetBuildType();
	if (buildType == _T("nightly")) {
		wxMessageBoxEx(_T("You are using a nightly development version of FileZilla 3, do not expect anything to work.\r\nPlease use the official releases instead.\r\n\r\n\
Unless explicitly instructed otherwise,\r\n\
DO NOT post bugreports,\r\n\
DO NOT use it in production environments,\r\n\
DO NOT distribute the binaries,\r\n\
DO NOT complain about it\r\n\
USE AT OWN RISK"), _T("Important Information"));
	}
Esempio n. 2
0
/*** MAIN LOOP ***/
int main(int argc, char *argv[])
{
#if	DEBUG
	bmem = AvailMem( MEMF_PUBLIC );
#endif

	ParseArgs(&args, argc, argv);

	/* Look first if Jano isn't already running */
	if( find_janoed( &args ) ) cleanup(0, RETURN_OK);

	/* Some global initialization */
	init_searchtable();

	/* Optionnal libraries */
	AslBase      = (struct Library *)    OpenLibrary("asl.library",     36);
	LocaleBase   = (struct LocaleBase *) OpenLibrary("locale.library",  38);
	DiskfontBase = (struct Library *)    OpenLibrary("diskfont.library", 0);
	IFFParseBase = (struct Library *)    OpenLibrary("iffparse.library",36);

	if(LocaleBase) InitLocale();    /* Localize the prog */

	/* Open the required ROM libraries */
	if( (IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 36)) &&
	    (GfxBase       = (struct GfxBase *)       OpenLibrary("graphics.library",  36)) &&
	    (GadToolsBase  = (struct Library *)       OpenLibrary("gadtools.library",  36)) &&
	    (KeymapBase    = (struct Library *)       OpenLibrary("keymap.library",    36)) &&
		 (UtilityBase   = (struct UtilityBase *)   OpenLibrary("utility.library",   36)) )
	{
		init_macros();
		set_default_prefs(&prefs, IntuitionBase->ActiveScreen);
		
		load_prefs(&prefs, NULL);     /* See if it exists a config file */
		sigport = create_port();

		/* Create whether an empty project or an existing one */
		if( ( edit = create_projects(NULL, args.sa_ArgLst, args.sa_NbArgs) ) )
		{
			/* Open the main interface */
			if(setup() == 0)
			{
				/* Makes edit project visible */
				reshape_panel(edit);
				active_project(edit,TRUE);
				clear_brcorner();

				dispatch_events();

			} else cleanup(ErrMsg(ERR_NOGUI), RETURN_FAIL);
		}
	} else cleanup(ErrMsg(ERR_BADOS), RETURN_FAIL);

	/* Hope that all were well... */
	cleanup(0, RETURN_OK);
	
	return 0;
}
Esempio n. 3
0
wxString CaMuleExternalConnector::SetLocale(const wxString& language)
{
	if (!language.IsEmpty()) {
		m_language = language;
		if (m_locale) {
			delete m_locale;
		}
		m_locale = new wxLocale;
		InitLocale(*m_locale, StrLang2wx(language));
	}

	return m_locale == NULL ? wxString() : m_locale->GetCanonicalName();
}
Esempio n. 4
0
int main(void)
{
    InitLocale("System/Prefs/IControl.catalog", 1);
    InitMenus();
    OpenLibs();
    GetArguments();
    InitPrefs((STRPTR)args[ARG_FROM], (args[ARG_USE] ? TRUE : FALSE), (args[ARG_SAVE] ? TRUE : FALSE));

    MakeGUI();
    HandleAll();
    Cleanup(NULL);
    
    return 0;
}
Esempio n. 5
0
BOOL CTeapotApp::InitInstance()
{
    CWinApp::InitInstance();

    // 如果装配文件 (manifest) 中指定使用 Windows 通用控件 ComCtl32.dll 6.0+ 版本, 则在 Windows XP 下需要调用 InitCommonControlsEx(), 否则窗口创建将失败
    // 设置程序中能够使用的通用控件类, ICC_WIN95_CLASSES 表示所有 Win95 通用控件
    INITCOMMONCONTROLSEX initCtrls;
    initCtrls.dwSize = sizeof(initCtrls);
    initCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&initCtrls);

    InitLocale();

    // 计算主模块全路径, 设置工作目录
    InitModulePath(MAX_PATH);
    InitWorkDir(GetModuleDir());

    // NOTE:
    // 保存应用设置选项的注册表键, 通常命名为开发公司, 组织, 团队的名字
    // 该函数设定 m_pszRegistryKey, 并影响 GetProfileInt 等函数
    // 保存应用设置的注册表键:
    // HKCU\Software\<company name>\<application name>\<section name>\<value name>
    // 当不使用注册表而使用 ini 文件时, 请去掉 SetRegistryKey
    SetRegistryKey(_T(MODULE_NAME));

    try {
        CMainFrame* pFrmWnd = new CMainFrame();

        // 由共享资源 IDR_MAINFRAME 创建主框架窗口, IDR_MAINFRAME 可同时标识: 菜单(必需), 快捷键, 主图标, 标题栏字符串
        pFrmWnd->LoadFrame(IDR_MAINFRAME);

        // NOTE: 在 Run 中显示窗口
        pFrmWnd->ShowWindow(SW_HIDE);

        m_pMainWnd = pFrmWnd;
    }
    catch (std::exception& e) {
        ERR_TRACEA("std::exception: what: %s, type: %s", e.what(), typeid(e).name());
        return FALSE;
    }
    catch (...) {
        ERR_TRACE("unknown exception");
        return FALSE;
    }

    return TRUE;
}
Esempio n. 6
0
BeHappy::BeHappy()
	: BApplication("application/x.vnd-STertois.BeHappy")
{
	addOnsSearched = false;
	
// récupération du dossier de préférences
	BPath prefsPath;
	find_directory(B_USER_SETTINGS_DIRECTORY,&prefsPath);
#ifdef _DEBUG
	prefsPath.Append("BeHappy_");
#else
	prefsPath.Append("BeHappy");
#endif //_DEBUG
	BEntry prefsDirEntry(prefsPath.Path());
	prefsDir = new BDirectory(prefsPath.Path());
	
	// si ce nom est celui d'un fichier et pas celui d'un dossier, il faut
	// effacer le fichier
	if ((prefsDirEntry.InitCheck() == B_OK) &&
		(prefsDir->InitCheck() != B_OK))
		prefsDirEntry.Remove();
	
	// si le dossier n'existe pas, on le crée
	if (prefsDir->InitCheck() != B_OK)
	{
		create_directory(prefsPath.Path(),0777);
		prefsDir->SetTo(prefsPath.Path());
	}
	prefsPath.Append("Preferences");
			
	prefs = new Preferences(prefsPath.Path());
	InitLocale();
	SearchAddOns();
	
	eraser = new Eraser;
	
	bookOpened = false;
	
	// création du monitor
	m_Monitor = new WindowMonitor;
}
Esempio n. 7
0
INT CommandChcp (LPTSTR param)
{
	LPTSTR *arg;
	INT    args;
	UINT uNewCodePage;

	/* print help */
	if (!_tcsncmp (param, _T("/?"), 2))
	{
		ConOutResPaging(TRUE,STRING_CHCP_HELP);
		return 0;
	}

	nErrorLevel = 0;

	/* get parameters */
	arg = split (param, &args, FALSE);

	if (args == 0)
	{
		/* display active code page number */
		ConErrResPrintf(STRING_CHCP_ERROR1, InputCodePage);
		freep (arg);
		return 0;
	}

	if (args >= 2)
	{
		/* too many parameters */
		ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT, param);
		nErrorLevel = 1;
		freep (arg);
		return 1;
	}

	uNewCodePage = (UINT)_ttoi(arg[0]);

	if (uNewCodePage == 0)
	{
		ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT, arg[0]);
		freep (arg);
		nErrorLevel = 1;
		return 1;
	}

	if (!SetConsoleCP(uNewCodePage))
	{
		ConErrResPuts(STRING_CHCP_ERROR4);
	}
	else
	{

		SetConsoleOutputCP (uNewCodePage);
		InitLocale ();
		InputCodePage= GetConsoleCP();
	}

	freep (arg);

	return 0;
}
Esempio n. 8
0
/**
 * @brief Initializes the application.
 */
bool App::OnInit()
{
    // initialize wxWidgets
    SetAppName(wxT("UltraDefrag"));
    wxInitAllImageHandlers();
    if(!wxApp::OnInit())
        return false;

    // initialize udefrag library
    if(::udefrag_init_library() < 0){
        wxLogError(wxT("Initialization failed!"));
        return false;
    }

    // set out of memory handler
#if !defined(__GNUC__)
    winx_set_killer(out_of_memory_handler);
    _set_new_handler(out_of_memory_handler);
    _set_new_mode(1);
#endif

    // initialize debug log
    wxFileName logpath(wxT(".\\logs\\ultradefrag.log"));
    logpath.Normalize();
    wxSetEnv(wxT("UD_LOG_FILE_PATH"),logpath.GetFullPath());
    ::udefrag_set_log_file_path();

    // initialize logging
    m_log = new Log();

    // use global config object for internal settings
    wxFileConfig *cfg = new wxFileConfig(wxT(""),wxT(""),
        wxT("gui.ini"),wxT(""),wxCONFIG_USE_RELATIVE_PATH);
    wxConfigBase::Set(cfg);

    // enable i18n support
    InitLocale();

    // save report translation on setup
    wxString cmdLine(GetCommandLine());
    if(cmdLine.Find(wxT("--setup")) != wxNOT_FOUND){
        SaveReportTranslation();
        ::winx_flush_dbg_log(0);
        delete m_log;
        return false;
    }

    // start web statistics
    m_statThread = new StatThread();

    // check for administrative rights
    if(!Utils::CheckAdminRights()){
        wxMessageDialog dlg(NULL,
            wxT("Administrative rights are needed to run the program!"),
            wxT("UltraDefrag"),wxOK | wxICON_ERROR
        );
        dlg.ShowModal(); Cleanup();
        return false;
    }

    // create synchronization event
    g_synchEvent = ::CreateEvent(NULL,TRUE,FALSE,NULL);
    if(!g_synchEvent){
        letrace("cannot create synchronization event");
        wxMessageDialog dlg(NULL,
            wxT("Cannot create synchronization event!"),
            wxT("UltraDefrag"),wxOK | wxICON_ERROR
        );
        dlg.ShowModal(); Cleanup();
        return false;
    }

    // keep things DPI-aware
    HDC hdc = ::GetDC(NULL);
    if(hdc){
        g_scaleFactor = (double)::GetDeviceCaps(hdc,LOGPIXELSX) / 96.0f;
        ::ReleaseDC(NULL,hdc);
    }
    g_iconSize = wxSystemSettings::GetMetric(wxSYS_SMALLICON_X);
    if(g_iconSize < 20) g_iconSize = 16;
    else if(g_iconSize < 24) g_iconSize = 20;
    else if(g_iconSize < 32) g_iconSize = 24;
    else g_iconSize = 32;

    // support taskbar icon overlay setup on shell restart
    g_TaskbarIconMsg = ::RegisterWindowMessage(wxT("TaskbarButtonCreated"));
    if(!g_TaskbarIconMsg) letrace("cannot register TaskbarButtonCreated message");

    // create main window
    g_mainFrame = new MainFrame();
    g_mainFrame->Show(true);
    SetTopWindow(g_mainFrame);
    return true;
}
Esempio n. 9
0
int main( int argc, char** argv )
#endif
{
	try
	{
#ifdef _WIN32
		SetHighDPIAware();
		//disable system critical messageboxes (for example: no floppy disk :) )
		SetErrorMode( SEM_FAILCRITICALERRORS );

		Win32HInstance = hInstance;
		Win32HIconId = IDI_WCM;

		WSADATA wsaData;

		if ( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) ) { throw_syserr( 0, "WSAStartup failed" ); }

		std::string StartupDir;
#else
		setlocale( LC_ALL, "" );
		signal( SIGPIPE, SIG_IGN );

		std::string StartupDir = GetStartupDir( argv[0] );
#endif

		try
		{
			InitConfigPath();
			g_WcmConfig.Load( nullptr, StartupDir );

			const char* langId = g_WcmConfig.systemLang.data() ? g_WcmConfig.systemLang.data() : "+";
#ifdef _WIN32
			if ( !InitLocale( L"install-files/share/wcm/lang", langId ) )
			{
				InitLocale( carray_cat<sys_char_t>( GetAppPath().data(), utf8_to_sys( "lang" ).data() ).data(), langId );
			}
#else

			if ( !InitLocale( "install-files/share/wcm/lang", langId ) )
			{
				InitLocale( UNIX_CONFIG_DIR_PATH "/lang", langId );
			}

#endif


//			SetEditorColorStyle(g_WcmConfig.editColorMode);
//			SetViewerColorStyle(g_WcmConfig.viewColorMode);
		}
		catch ( cexception* ex )
		{
			fprintf( stderr, "%s\n", ex->message() );
			ex->destroy();
		}

		InitSSH();

		AppInit();

		SetColorStyle( g_WcmConfig.styleColorTheme);

		OldSysGetFont = SysGetFont;
		SysGetFont = MSysGetFont;

//		cfont* defaultFont = SysGetFont( 0, 0 );
		defaultGC = new wal::GC( ( Win* )0 );

#ifndef _WIN32
#include "icons/wcm.xpm"
		Win::SetIcon( wcm_xpm );
#endif

		InitFonts();
		InitOperCharsets();

		SetCmdIcons();

		NCWin ncWin;

		g_MainWin = &ncWin;

		// reload config with a valid NCWin
		g_WcmConfig.Load( &ncWin, StartupDir );

		ncWin.Enable();
		ncWin.Show();

		InitExtensionApp();

#if !defined( _WIN32 )

		// don't bother with this on Windows
		if ( !ParseCommandLine( argc, argv, &ncWin ) ) { return 0; }

#endif

		for ( auto i = g_Applets.begin(); i != g_Applets.end(); i++ )
		{
			if ( !( *i )->Run() ) { return 0; }
		}

		g_Applets.clear();

		AppRun();

		// clean up
		RemoveAllWcmTempDirs();

		dbg_printf( "App Quit!!!\n" );

	}
	catch ( cexception* ex )
	{
#ifdef _WIN32
		MessageBoxA( 0, ex->message(), "", MB_OK );
#else
		printf( "Error: %s\n", ex->message() );
#endif
	}


	return 0;
}
Esempio n. 10
0
bool CodeBlocksApp::OnInit()
{
#ifdef __WXMSW__
    InitCommonControls();
#endif

    wxLog::EnableLogging(true);

    SetAppName(_T("codeblocks"));

    s_Loading              = true;
    m_pBatchBuildDialog    = nullptr;
    m_BatchExitCode        = 0;
    m_Batch                = false;
    m_BatchNotify          = false;
    m_Build                = false;
    m_ReBuild              = false;
    m_Clean                = false;
    m_HasProject           = false;
    m_HasWorkSpace         = false;
    m_SafeMode             = false;
    m_BatchWindowAutoClose = true;

    wxTheClipboard->Flush();

    wxCmdLineParser& parser = *Manager::GetCmdLineParser();
    parser.SetDesc(cmdLineDesc);

    // NOTE: crash handler explicitly disabled because it causes problems
    //       with plugins loading/unloading...
    //
    // static CrashHandler crash_handler(!m_CrashHandler);

    // we'll do this once and for all at startup
    wxFileSystem::AddHandler(new wxZipFSHandler);
    wxFileSystem::AddHandler(new wxMemoryFSHandler);
    wxXmlResource::Get()->InsertHandler(new wxToolBarAddOnXmlHandler);
    wxXmlResource::Get()->InsertHandler(new wxScrollingDialogXmlHandler);
    wxInitAllImageHandlers();
    wxXmlResource::Get()->InitAllHandlers();

    Manager::Get()->GetLogManager()->Log(F(wxT("Starting ") + appglobals::AppName + wxT(" ") +
                                           appglobals::AppActualVersionVerb + wxT(" ") +
                                           appglobals::AppBuildTimestamp));

    try
    {
    #if (wxUSE_ON_FATAL_EXCEPTION == 1)
        wxHandleFatalExceptions(true);
    #endif

        InitExceptionHandler();

        delete wxMessageOutput::Set(new cbMessageOutputNull); // No output. (suppress warnings about unknown options from plugins)
        if (ParseCmdLine(nullptr) == -1) // only abort if '--help' was passed in the command line
        {
            delete wxMessageOutput::Set(new wxMessageOutputMessageBox);
            parser.Usage();
            return false;
        }

        if ( !LoadConfig() )
            return false;

        // set safe-mode appropriately
        PluginManager::SetSafeMode(m_SafeMode);

        // If not in batch mode, and no startup-script defined, initialise XRC
        if(!m_Batch && m_Script.IsEmpty() && !InitXRCStuff())
            return false;

        InitLocale();

        if (m_DDE && !m_Batch && Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/use_ipc"), true))
        {
            // Create a new client
            DDEClient *client = new DDEClient;
            DDEConnection* connection = nullptr;
            wxLogNull ln; // own error checking implemented -> avoid debug warnings
            connection = (DDEConnection *)client->MakeConnection(_T("localhost"), F(DDE_SERVICE, wxGetUserId().wx_str()), DDE_TOPIC);

            if (connection)
            {
                // don't eval here just forward the whole command line to the other instance
                wxString cmdLine;
                for (int i = 1 ; i < argc; ++i)
                    cmdLine += wxString(argv[i]) + _T(' ');

                if ( !cmdLine.IsEmpty() )
                {
                    // escape openings and closings so it is easily possible to find the end on the rx side
                    cmdLine.Replace(_T("("), _T("\\("));
                    cmdLine.Replace(_T(")"), _T("\\)"));
                    connection->Execute(_T("[CmdLine({") + cmdLine + _T("})]"));
                }

                // On Linux, C::B has to be raised explicitly if it's wanted
                if (Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/raise_via_ipc"), true))
                    connection->Execute(_T("[Raise]"));
                connection->Disconnect();
                delete connection;
                delete client;

                // return false to end the application
                return false;
            }
            // free memory DDE-/IPC-clients, if we are here connection could not be established and there is no need to free it
            delete client;
        }
        // Now we can start the DDE-/IPC-Server, if we did it earlier we would connect to ourselves
        if (m_DDE && !m_Batch)
        {
            g_DDEServer = new DDEServer(nullptr);
            g_DDEServer->Create(F(DDE_SERVICE, wxGetUserId().wx_str()));
        }

        m_pSingleInstance = nullptr;
        if (   Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/single_instance"), true)
            && !parser.Found(_T("multiple-instance")) )
        {
            const wxString name = wxString::Format(_T("Code::Blocks-%s"), wxGetUserId().wx_str());

            m_pSingleInstance = new wxSingleInstanceChecker(name, ConfigManager::GetTempFolder());
            if (m_pSingleInstance->IsAnotherRunning())
            {
                /* NOTE: Due to a recent change in logging code, this visual warning got disabled.
                   So the wxLogError() has been changed to a cbMessageBox(). */
                cbMessageBox(_("Another program instance is already running.\nCode::Blocks is currently configured to only allow one running instance.\n\nYou can access this Setting under the menu item 'Environment'."),
                            _T("Code::Blocks"), wxOK | wxICON_ERROR);
                return false;
            }
        }
        // Splash screen moved to this place, otherwise it would be short visible, even if we only pass filenames via DDE/IPC
        // we also don't need it, if only a single instance is allowed
        Splash splash(!m_Batch && m_Script.IsEmpty() && m_Splash &&
                      Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/show_splash"), true));
        InitDebugConsole();

        Manager::SetBatchBuild(m_Batch || !m_Script.IsEmpty());
        Manager::Get()->GetScriptingManager();
        MainFrame* frame = nullptr;
        frame = InitFrame();
        m_Frame = frame;

        // plugins loaded -> check command line arguments again
        delete wxMessageOutput::Set(new wxMessageOutputBest); // warn about unknown options
        if ( ParseCmdLine(m_Frame) == 0 )
        {
            if (Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/blank_workspace"), true) == false)
                Manager::Get()->GetProjectManager()->LoadWorkspace();
        }

        if (m_SafeMode) wxLog::EnableLogging(true); // re-enable logging in safe-mode

        if (m_Batch)
        {
            Manager::SetAppStartedUp(true);

            // the compiler plugin might be waiting for this
            CodeBlocksEvent event(cbEVT_APP_STARTUP_DONE);
            Manager::Get()->ProcessEvent(event);

            Manager::Get()->RegisterEventSink(cbEVT_COMPILER_FINISHED, new cbEventFunctor<CodeBlocksApp, CodeBlocksEvent>(this, &CodeBlocksApp::OnBatchBuildDone));
            s_Loading = false;
            LoadDelayedFiles(frame);

            BatchJob();
            frame->Close();
            return true;
        }

        if (!m_Script.IsEmpty())
        {
            s_Loading = false;
            LoaderBase* loader = Manager::Get()->GetFileManager()->Load(m_Script);

            if (loader->GetData())
                Manager::Get()->GetScriptingManager()->LoadBuffer(cbC2U(loader->GetData()));

            delete loader;
            frame->Close();
            return true;
        }

        CheckVersion();

        // run startup script
        try
        {
            wxString startup = ConfigManager::LocateDataFile(_T("startup.script"), sdScriptsUser | sdScriptsGlobal);
            if (!startup.IsEmpty())
                Manager::Get()->GetScriptingManager()->LoadScript(startup);
        }
        catch (SquirrelError& exception)
        {
            Manager::Get()->GetScriptingManager()->DisplayErrors(&exception);
        }
        Manager::ProcessPendingEvents();

        // finally, show the app
        splash.Hide();
        SetTopWindow(frame);
        frame->Show();

        frame->StartupDone();

        frame->ShowTips(); // this func checks if the user wants tips, so no need to check here

        if (platform::windows)
            InitAssociations();

        s_Loading = false;

        LoadDelayedFiles(frame);
        AttachDebugger();
        Manager::Get()->GetProjectManager()->WorkspaceChanged();

        // all done
        Manager::SetAppStartedUp(true);

        CodeBlocksEvent event(cbEVT_APP_STARTUP_DONE);
        Manager::Get()->ProcessEvent(event);

        return true;
    }
    catch (cbException& exception)
    {
        exception.ShowErrorMessage();
    }
    catch (SquirrelError& exception)
    {
        Manager::Get()->GetScriptingManager()->DisplayErrors(&exception);
    }
    catch (const char* message)
    {
        wxSafeShowMessage(_T("Exception"), cbC2U(message));
    }
    catch (...)
    {
        wxSafeShowMessage(_T("Exception"), _T("Unknown exception was raised. The application will terminate immediately..."));
    }
    // if we reached here, return error
    return false;
}
Esempio n. 11
0
int main( int argc, char** argv )
#endif
{
	try
	{

#ifndef _WIN32

		for ( int i = 1; i < argc; i++ )
		{
			if ( argv[i][0] == '-' && argv[i][1] == '-' && !strcmp( argv[i] + 2, "dlg" ) )
			{
				createDialogAsChild = false;
			}
		}

#endif

#ifdef _WIN32
		//disable system critical messageboxes (for example: no floppy disk :) )
		SetErrorMode( SEM_FAILCRITICALERRORS );
#endif

#ifdef _WIN32
		Win32HInstance = hInstance;
		Win32HIconId = IDI_WCM;
#endif


#ifdef _WIN32
		WSADATA wsaData;

		if ( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) ) { throw_syserr( 0, "WSAStartup failed" ); }

#else
		setlocale( LC_ALL, "" );
		signal( SIGPIPE, SIG_IGN );
#endif

		try
		{
			InitConfigPath();
			g_WcmConfig.Load( NULL );

			const char* langId = g_WcmConfig.systemLang.data() ? g_WcmConfig.systemLang.data() : "+";
#ifdef _WIN32
			InitLocale( carray_cat<sys_char_t>( GetAppPath().data(), utf8_to_sys( "lang" ).data() ).data(), langId );
#else

			if ( !InitLocale( "install-files/share/wcm/lang", langId ) )
			{
				InitLocale( UNIX_CONFIG_DIR_PATH "/lang", langId );
			}

#endif


//			SetEditorColorStyle(g_WcmConfig.editColorMode);
//			SetViewerColorStyle(g_WcmConfig.viewColorMode);
		}
		catch ( cexception* ex )
		{
			fprintf( stderr, "%s\n", ex->message() );
			ex->destroy();
		}

		InitSSH();

		AppInit();

		SetColorStyle( g_WcmConfig.styleColorMode );

		OldSysGetFont = SysGetFont;
		SysGetFont = MSysGetFont;

//		cfont* defaultFont = SysGetFont( 0, 0 );
		defaultGC = new wal::GC( ( Win* )0 );

#ifndef _WIN32
#include "icons/wcm.xpm"
		Win::SetIcon( wcm_xpm );
#endif

		InitFonts();
		InitOperCharsets();

		SetCmdIcons();

		NCWin ncWin;

		// reload config with a valid NCWin
		g_WcmConfig.Load( &ncWin );

		ncWin.Enable();
		ncWin.Show();

		InitExtensionApp();

		AppRun();

		dbg_printf( "App Quit!!!" );

	}
	catch ( cexception* ex )
	{
#ifdef _WIN32
		MessageBoxA( 0, ex->message(), "", MB_OK );
#else
		printf( "Error: %s\n", ex->message() );
#endif
	}


	return 0;
}
Esempio n. 12
0
VOID __stdargs
__main( char *argstring )
{
    static struct Args     args;
    LONG    rev;

    /* Get arguments if started from CLI */
    if( !_WBenchMsg )
    {
        if( !( RDArgs = ReadArgs( TEMPLATE, ( IPTR * ) &args, NULL ) ) )
        {
            PrintFault( IoErr(), GetString( MSG_ERROR_ARGS ) );
            __exit( 0 );
        }
    }

    IntuiHook.h_Entry = ( HOOKFUNC ) IntuiMsgFunc;

//    DefaultPrefs.Flags = 0;
    DefaultPrefs.ReqDefaults[ RTPREF_OTHERREQ      ].ReqPos = REQPOS_POINTER;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].Size = 75;
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].Size =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].Size =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].Size = 65;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].ReqPos =
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].ReqPos =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].ReqPos =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].ReqPos =
    DefaultPrefs.ReqDefaults[ RTPREF_PALETTEREQ    ].ReqPos = REQPOS_TOPLEFTSCR;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_PALETTEREQ    ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_OTHERREQ      ].LeftOffset = 25;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_PALETTEREQ    ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_OTHERREQ      ].TopOffset = 18;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].MinEntries = 10;
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].MinEntries =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].MinEntries =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].MinEntries = 6;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].MaxEntries = 50;
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].MaxEntries =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].MaxEntries =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].MaxEntries = 10;

    if( !( IntuitionBase = ( struct IntuitionBase * ) OpenLibrary( "intuition.library", 37 ) ) )
    {
        BPTR    con;

        if( ( con = Open( "CON:40/20/320/40/ReqTools 2.8", MODE_NEWFILE ) ) )
        {
            Write( con, "\nNeed OS 2.04 or better!\n", 25 );
            Delay( 120L );
            Close( con );
        }

        FreeExit( 0 );
    }

    InitLocale();
    GfxBase      = OpenLib( "graphics.library", 37 );
    UtilityBase  = OpenLib( "utility.library", 36 );
    IconBase     = OpenLib( "icon.library", 0 );
    GadToolsBase = OpenLib( "gadtools.library", 37 );
    ReqToolsBase = OpenLib( "reqtools.library", 38 );

    rev = ReqToolsBase->LibNode.lib_Revision;

    if( ( rev >= 693 && rev <= 811 ) || ( rev >= 347 && rev <= 363 ) )
    {
        LocEZReq( MSG_WRONG_REQTOOLS_VERSION, MSG_ABORT );
        FreeExit( RETURN_FAIL );
    }

    if( rtLockPrefs()->PrefsSize != PREFSLEN )
    {
        LocEZReq( MSG_ALL_PREFS_NOT_SUPPORTED, MSG_OK );
    }

    rtUnlockPrefs();

    if( _WBenchMsg )
    {
        struct WBArg    *wbarg;
        BPTR    oldcd;

        CreateIcons = TRUE;
        wbarg = &_WBenchMsg->sm_ArgList[ 0 ];
        oldcd = CurrentDir( wbarg->wa_Lock );

        if( ( DiskObject = GetDiskObject( wbarg->wa_Name ) ) )
        {
            STRPTR    str;

            if( ( str = FindToolType( (UBYTE **)DiskObject->do_ToolTypes, "CREATEICONS" ) ) )
            {
                CreateIcons = Stricmp( str, "NO" );
            }

            if( ( str = FindToolType( (UBYTE **)DiskObject->do_ToolTypes, "SCREENFONT" ) ) )
            {
                UseScreenFont = Stricmp( str, "NO" );
            }

            if( ( str = FindToolType( (UBYTE **)DiskObject->do_ToolTypes, "PUBSCREEN" ) ) )
            {
                args.PubScreen = str;
            }
        }

        CurrentDir( oldcd );
    }
    else
    {
        if( args.ScreenFont )
        {
            UseScreenFont = Stricmp( args.ScreenFont, "NO" );
        }
    }

    if( !( FileReq = rtAllocRequestA( RT_FILEREQ, NULL ) ) )
    {
        FreeExit( RETURN_FAIL );
    }

        {
        struct TagItem tags[] =
        {
            {RTFI_Dir    , (IPTR)"Presets"    },
            {TAG_DONE                }
        };
        
        rtChangeReqAttrA( FileReq, tags );
    }
    
    /* Get current prefs from ReqTools */
    CopyMem( rtLockPrefs(), &RTPrefs, sizeof( struct ReqToolsPrefs ) );
    rtUnlockPrefs();

    /* If FROM was used load prefs from disk */
    if( args.From )
    {
        if( !LoadConfig( args.From ) )
        {
            FreeExit( RETURN_ERROR );
        }
    }

    WheelType = GetWheelType( RTPrefs.Flags );

    if( !( Screen = LockPubScreen( args.PubScreen ) ) )
    {
        LocEZReq( MSG_COULDNT_LOCK_PUBSCREEN, MSG_ABORT );
        FreeExit( RETURN_ERROR );
    }

    if( !( DrawInfo = GetScreenDrawInfo( Screen ) ) )
    {
        LocEZReq( MSG_ERROR_GETSCREENDRAWINFO, MSG_ABORT );
        FreeExit( RETURN_ERROR );
    }

    if( !( VisualInfo = GetVisualInfoA( Screen, NULL ) ) )
    {
        LocEZReq( MSG_ERROR_GETVISUALINFO, MSG_ABORT );
        FreeExit( RETURN_FAIL );
    }

    if( IntuitionBase->LibNode.lib_Version >= 39 )
    {
        Zoom[ 0 ] = Zoom[ 1 ] = 65535;
    }
    else
    {
        Zoom[ 1 ] = Screen->BarHeight + 1;
    }

    Zoom[ 2 ] = 250;
    Zoom[ 3 ] = Screen->WBorTop + Screen->Font->ta_YSize + 1;
    LocalizeMenus( NewMenu );

    if( !( Menus = CreateMenusA( NewMenu, NULL ) ) )
    {
        LocEZReq( MSG_ERROR_MENUS, MSG_ABORT );
        FreeExit( RETURN_FAIL );
    }

    LayoutMenus( Menus, VisualInfo,
        GTMN_NewLookMenus,    TRUE,
    TAG_END );

    if( !OpenGUI() )
    {
        LocEZReq( MSG_COULDNT_OPEN_WINDOW, MSG_ABORT );
        FreeExit( RETURN_FAIL );
    }


    {
        struct MenuItem    *iconItem;

        iconItem = ItemAddress( Menus, FULLMENUNUM( OPTIONS_MENU, SAVEICONS_ITEM, NOSUB ) );

        if( !CreateIcons )
        {
            iconItem->Flags &= ~CHECKED;
        }
    }

    CurrentReq = RTPREF_FILEREQ;
    ReqDefs = &RTPrefs.ReqDefaults[ CurrentReq ];
    LoopGUI();
    FreeExit( 0 );
}