Ejemplo n.º 1
0
bool CGUIDialogFirstTimeUseLang::OnMessage(CGUIMessage& message)
{
    switch (message.GetMessage())
    {
    case GUI_MSG_CLICKED:
    {
        int iControl = message.GetSenderId();

        CLog::Log(LOGDEBUG,"%s::OnMessage - GUI_MSG_CLICKED - [iControl=%d] (initbox)",m_name.c_str(),iControl);

        switch (iControl)
        {
        case LIST_CTRL:
        {
            // set the selected lang
            if (!CGUIDialogFirstTimeUseWithList::OnMessage(message))
            {
                CLog::Log(LOGERROR,"CGUIDialogFirstTimeUseLang::OnMessage - LIST_CTRL - Call to CGUIDialogFirstTimeUseWithList::OnMessage returned FALSE (initbox)");
                return true;
            }

            if (UpdateLanguage())
            {
                m_actionChoseEnum = CActionChose::NEXT;
                Close();
            }
        }
        break;
        }
    }
    break;
    }

    return CGUIDialogFirstTimeUseWithList::OnMessage(message);
}
Ejemplo n.º 2
0
void Applet::ShowConfig()
{
  Config config(mainInst, mainWnd, appletName, pSettings);
  if (config.Show() == IDOK)
  {
    displayLang = 0;
    UpdateLanguage();
    UpdateGUI();
  }
}
Ejemplo n.º 3
0
LRESULT Applet::DoTimer(UINT_PTR timerID)
{
  if (timerID == MOUSE_TIMER)
  {
    return BaseApplet::DoTimer(timerID);
  }
  else
  {
    UpdateLanguage();
  }

  return 1;
}
Ejemplo n.º 4
0
PluginManager::PluginManager(char *plug_dir)
{
  //FIXME: Show message here
  ItemsNumber=0;
  TypesList.ItemsNumber=0;
  TypesList.Items=NULL;
  TypesListItems=NULL;
  Language=NULL;
  UpdateLanguage();
  PluginsData=NULL;
  PluginsCount=0;
  FSF.FarRecursiveSearch(plug_dir,"*.ahp",(FRSUSERFUNC)FindPlugin,FRS_RECUR,this);
  LoadPluginsData();
}
Ejemplo n.º 5
0
void PluginManager::ShowConfigMenu(void)
{
  if(UpdateLanguage()) LoadPluginsData();
  int ItemCount=0;
  unsigned long flag=AHMSG_CONFIG;
  for(int i=0;i<PluginsCount;i++)
    if(PluginsData[i].Flags&flag)
      ItemCount++;
  if(ItemCount)
  {
    int *ids=new int[ItemCount];
    FarMenuItem *PlugList=new FarMenuItem[ItemCount];
    for(int i=0,j=0;(i<PluginsCount)&&(j<ItemCount);i++)
    {
      if(PluginsData[i].Flags&flag)
      {
        lstrcpy(PlugList[j].Text,PluginsData[i].ConfigString);
        ids[j]=i;
        j++;
      }
    }
    for(int i=0;i<ItemCount;i++)
    {
      PlugList[i].Selected=0;
      PlugList[i].Checked=0;
      PlugList[i].Separator=0;
    }
    int select=0,selected=0;
    while (select>=0)
    {
      PlugList[selected].Selected=0;
      PlugList[select].Selected=1;
      selected=select;
      int MenuCode=Info.Menu(Info.ModuleNumber,-1,-1,0,FMENU_AUTOHIGHLIGHT|FMENU_WRAPMODE,GetMsg(MPluginConfig),NULL,NULL,NULL,NULL,PlugList,ItemCount);
      if(MenuCode>=0)
        SendMessage(ids[MenuCode],flag,NULL,NULL);
      select=MenuCode;
    }
    delete [] PlugList;
    delete [] ids;
  }
}
Ejemplo n.º 6
0
bool CGUIDialogFirstTimeUseLang::HandleClickNext()
{
    return UpdateLanguage();
}
Ejemplo n.º 7
0
 const char *GetMsg(int MsgId) {
     UpdateLanguage();
     if (MsgId>=0 && MsgId<MessagesCount) return Messages[MsgId];
     else return "";
 }
Ejemplo n.º 8
0
CModule::CModule(const char *filename)
{
    loaded=false;

    hModule = LoadLibraryEx(filename,NULL,DONT_RESOLVE_DLL_REFERENCES);
    //DONT_RESOLVE_DLL_REFERENCES это чтобы не напрягать длл-ки которые
    //не плагины, если решаем что экспортит достаточно чтоб быть плагином
    //тогда выгружаем и загружаем по нормальному.
    if (!hModule)
        return;

    GetPluginInfo       = (GetPluginInfo_t *)       GetProcAddress(hModule, "GetPluginInfo");
    SetStartupInfo      = (SetStartupInfo_t *)      GetProcAddress(hModule, "SetStartupInfo");
    if (!SetStartupInfo || !GetPluginInfo)
        return;

    FreeLibrary(hModule);

    hModule = LoadLibraryEx(filename,NULL,0);
    if (!hModule)
        return;

    ClosePlugin         = (ClosePlugin_t *)         GetProcAddress(hModule, "ClosePlugin");
    Compare             = (Compare_t *)             GetProcAddress(hModule, "Compare");
    Configure           = (Configure_t *)           GetProcAddress(hModule, "Configure");
    DeleteFiles         = (DeleteFiles_t *)         GetProcAddress(hModule, "DeleteFiles");
    ExitFAR             = (ExitFAR_t *)             GetProcAddress(hModule, "ExitFAR");
    FreeFindData        = (FreeFindData_t *)        GetProcAddress(hModule, "FreeFindData");
    FreeVirtualFindData = (FreeVirtualFindData_t *) GetProcAddress(hModule, "FreeVirtualFindData");
    GetFiles            = (GetFiles_t *)            GetProcAddress(hModule, "GetFiles");
    GetFindData         = (GetFindData_t *)         GetProcAddress(hModule, "GetFindData");
    GetMinFarVersion    = (GetMinFarVersion_t *)    GetProcAddress(hModule, "GetMinFarVersion");
    GetOpenPluginInfo   = (GetOpenPluginInfo_t *)   GetProcAddress(hModule, "GetOpenPluginInfo");
    GetPluginInfo       = (GetPluginInfo_t *)       GetProcAddress(hModule, "GetPluginInfo");
    GetVirtualFindData  = (GetVirtualFindData_t *)  GetProcAddress(hModule, "GetVirtualFindData");
    MakeDirectory       = (MakeDirectory_t *)       GetProcAddress(hModule, "MakeDirectory");
    OpenFilePlugin      = (OpenFilePlugin_t *)      GetProcAddress(hModule, "OpenFilePlugin");
    OpenPlugin          = (OpenPlugin_t *)          GetProcAddress(hModule, "OpenPlugin");
    ProcessEditorEvent  = (ProcessEditorEvent_t *)  GetProcAddress(hModule, "ProcessEditorEvent");
    ProcessEditorInput  = (ProcessEditorInput_t *)  GetProcAddress(hModule, "ProcessEditorInput");
    ProcessEvent        = (ProcessEvent_t *)        GetProcAddress(hModule, "ProcessEvent");
    ProcessHostFile     = (ProcessHostFile_t *)     GetProcAddress(hModule, "ProcessHostFile");
    ProcessKey          = (ProcessKey_t *)          GetProcAddress(hModule, "ProcessKey");
    ProcessViewerEvent  = (ProcessViewerEvent_t *)  GetProcAddress(hModule, "ProcessViewerEvent");
    PutFiles            = (PutFiles_t *)            GetProcAddress(hModule, "PutFiles");
    SetDirectory        = (SetDirectory_t *)        GetProcAddress(hModule, "SetDirectory");
    SetFindList         = (SetFindList_t *)         GetProcAddress(hModule, "SetFindList");
    SetStartupInfo      = (SetStartupInfo_t *)      GetProcAddress(hModule, "SetStartupInfo");

    if (!SetStartupInfo || !GetPluginInfo)
        return;

    lstrcpy(ModulePath,filename);
    *Language = 0;
    Messages = NULL;
    MessagesCount = 0;

    UpdateLanguage();

    if (GetMinFarVersion)
        MinFarVersion = GetMinFarVersion();
    else
        MinFarVersion = 0;

    loaded=true;
}
Ejemplo n.º 9
0
int main(int argc, char *argv[])
{
	//Initialization of system functions
	InitSystem();

	//configure debug output
	qInstallMessageHandler(myMessageOutput);

	//class for interface windows
	gMainInterface = new cInterface;

	WriteLog("Prepare QApplication", 2);
	QCoreApplication *gCoreApplication = new QCoreApplication(argc, argv);
	gCoreApplication->setOrganizationName("Mandelbulber");
	gCoreApplication->setApplicationName("Mandelbulber");
	gCoreApplication->setApplicationVersion(MANDELBULBER_VERSION_STRING);

	UpdateLanguage(gCoreApplication);

	cCommandLineInterface commandLineInterface(gApplication);

	if (commandLineInterface.isNoGUI())
	{
		gApplication = qobject_cast<QApplication *>(gCoreApplication);
	}
	else
	{
		delete gCoreApplication;
		gApplication = new QApplication(argc, argv);
		gApplication->setOrganizationName("Mandelbulber");
		gApplication->setApplicationName("Mandelbulber");
		gApplication->setApplicationVersion(MANDELBULBER_VERSION_STRING);
	}

	//registering types for queued connections
	qRegisterMetaType<cStatistics>("cStatistics");
	qRegisterMetaType<QList<QByteArray> >("QList<QByteArray>");
	qRegisterMetaType<QList<int> >("QList<int>");
	qRegisterMetaType<cParameterContainer>("cParameterContainer");
	qRegisterMetaType<cFractalContainer>("cFractalContainer");
	qRegisterMetaType<sTextures>("sTextures");
	qRegisterMetaType<cProgressText::enumProgressType>("cProgressText::enumProgressType");
	qRegisterMetaType<QVector<int> >("QVector<int>");
	qRegisterMetaType<CVector2<double> >("CVector2<double>");
	qRegisterMetaType<QMessageBox::StandardButtons>("QMessageBox::StandardButtons");
	qRegisterMetaType<QMessageBox::StandardButtons*>("QMessageBox::StandardButtons*");
	qRegisterMetaType<cErrorMessage::enumMessageType>("cErrorMessage::enumMessageType");

	gErrorMessage = new cErrorMessage;

	//create default directories and copy all needed files
	WriteLog("CreateDefaultFolders()", 2);
	if (!CreateDefaultFolders())
	{
		qCritical() << "Files/directories initialization failed" << endl;
		return 73;
	}

	//create internal database with parameters
	gPar = new cParameterContainer;
	gParFractal = new cFractalContainer;

	//Allocate container for animation frames
	gAnimFrames = new cAnimationFrames;

	//Allocate container for key frames
	gKeyframes = new cKeyframes;

	gPar->SetContainerName("main");
	InitParams(gPar);
	for (int i = 0; i < NUMBER_OF_FRACTALS; i++)
	{
		gParFractal->at(i).SetContainerName(QString("fractal") + QString::number(i));
		InitFractalParams(&gParFractal->at(i));
	}

	/****************** TEMPORARY CODE FOR MATERIALS *******************/

	//InitMaterialParams(1, gPar);
	//InitMaterialParams(2, gPar);
	//InitMaterialParams(3, gPar);

	/*******************************************************************/

	//Define list of fractal formulas
	DefineFractalList(&fractalList);

	//Netrender
	gNetRender = new CNetRender(systemData.numberOfThreads);

	//loading AppSettings
	if (QFile(systemData.dataDirectory + "mandelbulber.ini").exists())
	{
		cSettings parSettings(cSettings::formatAppSettings);
		parSettings.LoadFromFile(systemData.dataDirectory + "mandelbulber.ini");
		parSettings.Decode(gPar, gParFractal);
	}

	systemData.loggingVerbosity = gPar->Get<int>("logging_verbosity");

	UpdateDefaultPaths();
	if (!commandLineInterface.isNoGUI())
	{
		UpdateUIStyle();
		UpdateUISkin();
	}
	UpdateLanguage(gApplication);

	commandLineInterface.ReadCLI();

	if (!commandLineInterface.isNoGUI())
	{
		gMainInterface->ShowUi();
		gFlightAnimation = new cFlightAnimation(gMainInterface,
																						gAnimFrames,
																						gMainInterface->mainImage,
																						gMainInterface->renderedImage,
																						gPar,
																						gParFractal,
																						gMainInterface->mainWindow);
		gKeyframeAnimation = new cKeyframeAnimation(gMainInterface,
																								gKeyframes,
																								gMainInterface->mainImage,
																								gMainInterface->renderedImage,
																								gPar,
																								gParFractal,
																								gMainInterface->mainWindow);

		QObject::connect(gFlightAnimation,
										 SIGNAL(updateProgressAndStatus(const QString&, const QString&, double, cProgressText::enumProgressType)),
										 gMainInterface->mainWindow,
										 SLOT(slotUpdateProgressAndStatus(const QString&, const QString&, double, cProgressText::enumProgressType)));
		QObject::connect(gFlightAnimation,
										 SIGNAL(updateProgressHide(cProgressText::enumProgressType)),
										 gMainInterface->mainWindow,
										 SLOT(slotUpdateProgressHide(cProgressText::enumProgressType)));
		QObject::connect(gFlightAnimation,
										 SIGNAL(updateStatistics(cStatistics)),
										 gMainInterface->mainWindow,
										 SLOT(slotUpdateStatistics(cStatistics)));
		QObject::connect(gKeyframeAnimation,
										 SIGNAL(updateProgressAndStatus(const QString&, const QString&, double, cProgressText::enumProgressType)),
										 gMainInterface->mainWindow,
										 SLOT(slotUpdateProgressAndStatus(const QString&, const QString&, double, cProgressText::enumProgressType)));
		QObject::connect(gKeyframeAnimation,
										 SIGNAL(updateProgressHide(cProgressText::enumProgressType)),
										 gMainInterface->mainWindow,
										 SLOT(slotUpdateProgressHide(cProgressText::enumProgressType)));
		QObject::connect(gKeyframeAnimation,
										 SIGNAL(updateStatistics(cStatistics)),
										 gMainInterface->mainWindow,
										 SLOT(slotUpdateStatistics(cStatistics)));

		try
		{
			gQueue = new cQueue(gMainInterface,
													systemData.dataDirectory + "queue.fractlist",
													systemData.dataDirectory + "queue",
													gMainInterface->mainWindow);
		} catch (QString &ex)
		{
			cErrorMessage::showMessage(QObject::tr("Cannot init queue: ") + ex,
																 cErrorMessage::errorMessage);
			return -1;
		}
	}
Ejemplo n.º 10
0
// Entry point
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, char *szCmdLine, int iCmdShow) {
    g_hinst = hInst;
    IsWow64Process(GetCurrentProcess(), &x64);

    // Get ini path
    GetModuleFileName(NULL, inipath, ARRAY_SIZE(inipath));
    PathRemoveFileSpec(inipath);
    wcscat(inipath, L"\\"APP_NAME".ini");
    wchar_t txt[10];

    // Convert szCmdLine to argv and argc (max 10 arguments)
    char *argv[10];
    int argc = 1;
    argv[0] = szCmdLine;
    while ((argv[argc]=strchr(argv[argc-1],' ')) != NULL) {
        *argv[argc] = '\0';
        if (argc == ARRAY_SIZE(argv)) break;
        argv[argc++]++;
    }

    // Check arguments
    int i;
    int elevate=0, quiet=0, config=-1, multi=0;
    for (i=0; i < argc; i++) {
        if (!strcmp(argv[i],"-hide") || !strcmp(argv[i],"-h")) {
            // -hide = do not add tray icon, hide it if already running
            hide = 1;
        }
        else if (!strcmp(argv[i],"-quiet") || !strcmp(argv[i],"-q")) {
            // -quiet = do nothing if already running
            quiet = 1;
        }
        else if (!strcmp(argv[i],"-elevate") || !strcmp(argv[i],"-e")) {
            // -elevate = create a new instance with administrator privileges
            elevate = 1;
        }
        else if (!strcmp(argv[i],"-config") || !strcmp(argv[i],"-c")) {
            // -config = open config (with requested page)
            config = (i+1 < argc)?atoi(argv[i+1]):0;
        }
        else if (!strcmp(argv[i],"-multi")) {
            // -multi = allow multiple instances, used internally when elevating via config window
            multi = 1;
        }
    }

    // Check if elevated if in >= Vista
    OSVERSIONINFO vi = { sizeof(OSVERSIONINFO) };
    GetVersionEx(&vi);
    vista = (vi.dwMajorVersion >= 6);
    if (vista) {
        HANDLE token;
        TOKEN_ELEVATION elevation;
        DWORD len;
        if (OpenProcessToken(GetCurrentProcess(),TOKEN_READ,&token) && GetTokenInformation(token,TokenElevation,&elevation,sizeof(elevation),&len)) {
            elevated = elevation.TokenIsElevated;
        }
    }

    // Register some messages
    WM_UPDATESETTINGS = RegisterWindowMessage(L"UpdateSettings");
    WM_OPENCONFIG = RegisterWindowMessage(L"OpenConfig");
    WM_CLOSECONFIG = RegisterWindowMessage(L"CloseConfig");
    WM_ADDTRAY = RegisterWindowMessage(L"AddTray");
    WM_HIDETRAY = RegisterWindowMessage(L"HideTray");

    // Look for previous instance
    GetPrivateProfileString(L"Advanced", L"MultipleInstances", L"0", txt, ARRAY_SIZE(txt), inipath);
    if (!_wtoi(txt) && !multi) {
        HWND previnst = FindWindow(APP_NAME, NULL);
        if (previnst != NULL) {
            if (quiet) {
                return 0;
            }
            PostMessage(previnst, WM_UPDATESETTINGS, 0, 0);
            PostMessage(previnst, (hide && !config?WM_CLOSECONFIG:WM_OPENCONFIG), config, 0);
            PostMessage(previnst, (hide?WM_HIDETRAY:WM_ADDTRAY), 0, 0);
            return 0;
        }
    }

    // Check AlwaysElevate
    if (!elevated) {
        GetPrivateProfileString(L"Advanced", L"AlwaysElevate", L"0", txt, ARRAY_SIZE(txt), inipath);
        if (_wtoi(txt)) {
            elevate = 1;
        }

        // Handle request to elevate to administrator privileges
        if (elevate) {
            wchar_t path[MAX_PATH];
            GetModuleFileName(NULL, path, ARRAY_SIZE(path));
            int ret = (INT_PTR) ShellExecute(NULL, L"runas", path, (hide?L"-hide":NULL), NULL, SW_SHOWNORMAL);
            if (ret > 32) {
                return 0;
            }
        }
    }

    // Language
    memset(&l10n_ini, 0, sizeof(l10n_ini));
    UpdateLanguage();

    // Create window
    WNDCLASSEX wnd = { sizeof(WNDCLASSEX), 0, WindowProc, 0, 0, hInst, NULL, NULL, (HBRUSH)(COLOR_WINDOW+1), NULL, APP_NAME, NULL };
    RegisterClassEx(&wnd);
    g_hwnd = CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST|WS_EX_LAYERED, wnd.lpszClassName, NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, hInst, NULL);
    SetLayeredWindowAttributes(g_hwnd, 0, 1, LWA_ALPHA); // Almost transparent

    // Tray icon
    InitTray();
    UpdateTray();

    // Hook system
    HookSystem();

    // Add tray if hook failed, even though -hide was supplied
    if (hide && !keyhook) {
        hide = 0;
        UpdateTray();
    }

    // Check for update
    GetPrivateProfileString(L"Update", L"CheckOnStartup", L"0", txt, ARRAY_SIZE(txt), inipath);
    if (_wtoi(txt)) {
        CheckForUpdate(0);
    }

    // Open config if -config was supplied
    if (config != -1) {
        PostMessage(g_hwnd, WM_OPENCONFIG, config, 0);
    }

    // Message loop
    MSG msg;
    while (GetMessage(&msg,NULL,0,0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}
Ejemplo n.º 11
0
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    if (msg == WM_TRAY) {
        if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) {
            ToggleState();
            if (lParam == WM_LBUTTONDBLCLK && !(GetAsyncKeyState(VK_SHIFT)&0x8000)) {
                SendMessage(hwnd, WM_OPENCONFIG, 0, 0);
            }
        }
        else if (lParam == WM_MBUTTONDOWN) {
            ShellExecute(NULL, L"open", inipath, NULL, NULL, SW_SHOWNORMAL);
        }
        else if (lParam == WM_RBUTTONDOWN) {
            ShowContextMenu(hwnd);
        }
        else if (lParam == NIN_BALLOONUSERCLICK) {
            hide = 0;
            SendMessage(hwnd, WM_COMMAND, SWM_UPDATE, 0);
        }
        else if (lParam == NIN_BALLOONTIMEOUT) {
            if (hide) {
                RemoveTray();
            }
        }
    }
    else if (msg == WM_UPDATESETTINGS) {
        UpdateLanguage();
        // Reload hooks
        if (ENABLED()) {
            UnhookSystem();
            HookSystem();
        }
        // Reload config language
        if (!wParam && IsWindow(g_cfgwnd)) {
            SendMessage(g_cfgwnd, WM_UPDATESETTINGS, 0, 0);
        }
    }
    else if (msg == WM_ADDTRAY) {
        hide = 0;
        UpdateTray();
    }
    else if (msg == WM_HIDETRAY) {
        hide = 1;
        RemoveTray();
    }
    else if (msg == WM_OPENCONFIG && (lParam || !hide)) {
        OpenConfig(wParam);
    }
    else if (msg == WM_CLOSECONFIG) {
        CloseConfig();
    }
    else if (msg == WM_TASKBARCREATED) {
        tray_added = 0;
        UpdateTray();
    }
    else if (msg == WM_COMMAND) {
        int wmId=LOWORD(wParam), wmEvent=HIWORD(wParam);
        if (wmId == SWM_TOGGLE) {
            ToggleState();
        }
        else if (wmId == SWM_HIDE) {
            hide = 1;
            RemoveTray();
        }
        else if (wmId == SWM_UPDATE) {
            if (MessageBox(NULL,l10n->update_dialog,APP_NAME,MB_ICONINFORMATION|MB_YESNO|MB_TOPMOST|MB_SETFOREGROUND) == IDYES) {
                OpenUrl(APP_URL);
            }
        }
        else if (wmId == SWM_CONFIG) {
            SendMessage(hwnd, WM_OPENCONFIG, 0, 0);
        }
        else if (wmId == SWM_ABOUT) {
            SendMessage(hwnd, WM_OPENCONFIG, 4, 0);
        }
        else if (wmId == SWM_EXIT) {
            DestroyWindow(hwnd);
        }
    }
    else if (msg == WM_QUERYENDSESSION && msghook) {
        showerror = 0;
        UnhookSystem();
    }
    else if (msg == WM_DESTROY) {
        showerror = 0;
        UnhookSystem();
        RemoveTray();
        PostQuitMessage(0);
    }
    else if (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
        // Hide cursorwnd if clicked on, this might happen if it wasn't hidden by hooks.c for some reason
        ShowWindow(hwnd, SW_HIDE);
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}