Ejemplo n.º 1
0
static NTSTATUS SilentUpdateCheckThreadStart(
    __in PVOID Parameter
    )
{
    if (ConnectionAvailable())
    {
        if (QueryXmlData())
        {
            ULONG majorVersion = 0;
            ULONG minorVersion = 0;

            // Get the current Process Hacker version
            PhGetPhVersionNumbers(&majorVersion, &minorVersion, NULL, NULL);

            // Compare the current version against the latest available version
            if (CompareVersions(UpdateData.MajorVersion, UpdateData.MinorVersion, majorVersion, minorVersion) > 0)
            {
                // Don't spam the user the second they open PH, delay dialog creation for 3 seconds.
                Sleep(3 * 1000);

                // Show the dialog asynchronously on a new thread.
                ShowUpdateDialog();
            }
        }

        FreeXmlData();
    }

    return STATUS_SUCCESS;
}
Ejemplo n.º 2
0
NTSTATUS UpdateCheckSilentThread(
    _In_ PVOID Parameter
    )
{
    PPH_UPDATER_CONTEXT context = NULL;
    ULONGLONG currentVersion = 0;
    ULONGLONG latestVersion = 0;

    context = CreateUpdateContext(TRUE);

#ifndef FORCE_UPDATE_CHECK
    if (!LastUpdateCheckExpired())
        goto CleanupExit;
#endif

    Sleep(5 * 1000);

    // Clear the application cache directory.
    PhClearCacheDirectory();

    // Query latest update information from the server.
    if (!QueryUpdateData(context))
        goto CleanupExit;

    currentVersion = ParseVersionString(context->CurrentVersionString);

#ifdef FORCE_UPDATE_CHECK
    latestVersion = MAKE_VERSION_ULONGLONG(
        9999,
        9999,
        9999,
        0
        );
#else
    latestVersion = ParseVersionString(context->Version);
#endif

    // Compare the current version against the latest available version
    if (currentVersion < latestVersion)
    {
        // Check if the user hasn't already opened the dialog.
        if (!UpdateDialogHandle)
        {
            // We have data we're going to cache and pass into the dialog
            context->HaveData = TRUE;

            // Show the dialog asynchronously on a new thread.
            ShowUpdateDialog(context);
        }
    }

CleanupExit:

    if (!context->HaveData)
        FreeUpdateContext(context);

    return STATUS_SUCCESS;
}
Ejemplo n.º 3
0
static VOID NTAPI MenuItemCallback(
    _In_opt_ PVOID Parameter,
    _In_opt_ PVOID Context
    )
{
    PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter;

    if (menuItem != NULL && menuItem->Id == UPDATE_MENUITEM)
    {
        ShowUpdateDialog(NULL);
    }
}
Ejemplo n.º 4
0
static VOID NTAPI MenuItemCallback(
    __in_opt PVOID Parameter,
    __in_opt PVOID Context
    )
{
    PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter;

    if (menuItem != NULL)
    {
        switch (menuItem->Id)
        {
        case UPDATE_MENUITEM:
            {
                ShowUpdateDialog();
            }
            break;
        }
    }
}
Ejemplo n.º 5
0
void MainWindow::CreateNavigationBar()
{
  QToolBar * pToolBar = new QToolBar(tr("Navigation Bar"), this);
  pToolBar->setOrientation(Qt::Vertical);
  pToolBar->setIconSize(QSize(32, 32));

  {
    // Add navigation hot keys.
    hotkey_t const arr[] = {
      { Qt::Key_Equal, SLOT(ScalePlus()) },
      { Qt::Key_Minus, SLOT(ScaleMinus()) },
      { Qt::ALT + Qt::Key_Equal, SLOT(ScalePlusLight()) },
      { Qt::ALT + Qt::Key_Minus, SLOT(ScaleMinusLight()) },
      { Qt::Key_A, SLOT(ShowAll()) },
      // Use CMD+n (New Item hotkey) to activate Create Feature mode.
      { Qt::Key_Escape, SLOT(ChoosePositionModeDisable()) }
    };

    for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
    {
      QAction * pAct = new QAction(this);
      pAct->setShortcut(QKeySequence(arr[i].key));
      connect(pAct, SIGNAL(triggered()), m_pDrawWidget, arr[i].slot);
      addAction(pAct);
    }
  }

  {
    // TODO(AlexZ): Replace icon.
    m_pCreateFeatureAction = pToolBar->addAction(QIcon(":/navig64/select.png"),
                                           tr("Create Feature"),
                                           this,
                                           SLOT(OnCreateFeatureClicked()));
    m_pCreateFeatureAction->setCheckable(true);
    m_pCreateFeatureAction->setToolTip(tr("Please select position on a map."));
    m_pCreateFeatureAction->setShortcut(QKeySequence::New);

    pToolBar->addSeparator();

    // Add search button with "checked" behavior.
    m_pSearchAction = pToolBar->addAction(QIcon(":/navig64/search.png"),
                                           tr("Search"),
                                           this,
                                           SLOT(OnSearchButtonClicked()));
    m_pSearchAction->setCheckable(true);
    m_pSearchAction->setToolTip(tr("Offline Search"));
    m_pSearchAction->setShortcut(QKeySequence::Find);

    pToolBar->addSeparator();

// #ifndef OMIM_OS_LINUX
    // add my position button with "checked" behavior

    m_pMyPositionAction = pToolBar->addAction(QIcon(":/navig64/location.png"),
                                           tr("My Position"),
                                           this,
                                           SLOT(OnMyPosition()));
    m_pMyPositionAction->setCheckable(true);
    m_pMyPositionAction->setToolTip(tr("My Position"));
// #endif

    // add view actions 1
    button_t arr[] = {
      { QString(), 0, 0 },
      //{ tr("Show all"), ":/navig64/world.png", SLOT(ShowAll()) },
      { tr("Scale +"), ":/navig64/plus.png", SLOT(ScalePlus()) }
    };
    add_buttons(pToolBar, arr, ARRAY_SIZE(arr), m_pDrawWidget);
  }

  // add scale slider
  QScaleSlider * pScale = new QScaleSlider(Qt::Vertical, this, 20);
  pScale->SetRange(2, scales::GetUpperScale());
  pScale->setTickPosition(QSlider::TicksRight);

  pToolBar->addWidget(pScale);
  m_pDrawWidget->SetScaleControl(pScale);

  {
    // add view actions 2
    button_t arr[] = {
      { tr("Scale -"), ":/navig64/minus.png", SLOT(ScaleMinus()) }
    };
    add_buttons(pToolBar, arr, ARRAY_SIZE(arr), m_pDrawWidget);
  }

#ifndef NO_DOWNLOADER
  {
    // add mainframe actions
    button_t arr[] = {
      { QString(), 0, 0 },
      { tr("Download Maps"), ":/navig64/download.png", SLOT(ShowUpdateDialog()) }
    };
    add_buttons(pToolBar, arr, ARRAY_SIZE(arr), this);
  }
#endif // NO_DOWNLOADER

  addToolBar(Qt::RightToolBarArea, pToolBar);
}
Ejemplo n.º 6
0
void Updater::CheckTriggerUpdateDialog()
{
//    TSLogging::Print(QString("Stable: %1").arg(m_VersionStable));
//    TSLogging::Print(QString("Beta: %1").arg(m_VersionBeta));
//    TSLogging::Print(QString("Local: %1").arg(ts3plugin_version()));

    if (!m_isBetaChannel)
    {
        if (m_VersionStable != ts3plugin_version())
            ShowUpdateDialog(m_VersionStable);
        else
            TSLogging::Log(QString("%1 version %2 is up to date.").arg(ts3plugin_name()).arg(ts3plugin_version()));
    }
    else
    {
        // Is Stable newer than beta?
        bool isStableNewer = false;
        if (m_VersionStable.isEmpty() && m_VersionBeta.isEmpty())
        {
            TSLogging::Log(QString("(Updater) Could not check for updates."));
        }
        else if (m_VersionStable.isEmpty()) // TS site is down
        {
            TSLogging::Log("(Updater) Could not get stable version info. Aborting.");
        }
        else if (m_VersionBeta.isEmpty()) // Beta site is down
        {
            TSLogging::Log("(Updater) Could not get beta version info.");
            isStableNewer = true;
        }
        else if (m_VersionBeta == m_VersionStable)
            isStableNewer = true;
        else
        {
            QStringList stable = m_VersionStable.split(".",QString::SkipEmptyParts);
            QStringList beta = m_VersionBeta.split(".",QString::SkipEmptyParts);
            bool isOk;
            for (int i = 0; i< stable.length(); ++i)
            {
                int stableInt = stable[i].toInt(&isOk,10);
                if (!isOk)
                    break;

                int betaInt = beta[i].toInt(&isOk,10);
                if (!isOk)
                    break;

                if (stableInt > betaInt)
                {
                    isStableNewer = true;
                    break;
                }
            }
            if (!isOk)
            {
                TSLogging::Log("(Updater) Problem with version comparison.");
                isStableNewer = true;
            }
//            TSLogging::Print(QString("(Updater) Remote Stable is %1 than beta.").arg((isStableNewer)?"newer":"older"));
        }

        if (isStableNewer && (m_VersionStable != ts3plugin_version()))
            ShowUpdateDialog(m_VersionStable);
        else if (!isStableNewer && (m_VersionBeta != ts3plugin_version()))
            ShowUpdateDialog(m_VersionBeta);
        else
            TSLogging::Log(QString("%1 version %2 is up to date.").arg(ts3plugin_name()).arg(ts3plugin_version()));
    }
}
Ejemplo n.º 7
0
MainWindow::MainWindow() : m_locationService(CreateDesktopLocationService(*this))
{
#ifndef USE_DRAPE
  m_pDrawWidget = new DrawWidget(this);
  setCentralWidget(m_pDrawWidget);
#else
  m_pDrawWidget = new DrapeSurface();
  QSurfaceFormat format = m_pDrawWidget->requestedFormat();
  format.setDepthBufferSize(16);
  m_pDrawWidget->setFormat(format);
  QWidget * w = QWidget::createWindowContainer(m_pDrawWidget, this);
  w->setMouseTracking(true);
  setCentralWidget(w);
#endif // USE_DRAPE

  shared_ptr<location::State> locState = m_pDrawWidget->GetFramework().GetLocationState();
  locState->AddStateModeListener([this] (location::State::Mode mode)
                                 {
                                    LocationStateModeChanged(mode);
                                 });

  CreateNavigationBar();
  CreateSearchBarAndPanel();

  setWindowTitle(tr("MAPS.ME"));
  setWindowIcon(QIcon(":/ui/logo.png"));

#ifndef OMIM_OS_WINDOWS
  QMenu * helpMenu = new QMenu(tr("Help"), this);
  menuBar()->addMenu(helpMenu);
  helpMenu->addAction(tr("About"), this, SLOT(OnAbout()));
  helpMenu->addAction(tr("Preferences"), this, SLOT(OnPreferences()));
#else
  {
    // create items in the system menu
    HMENU menu = ::GetSystemMenu((HWND)winId(), FALSE);
    MENUITEMINFOA item;
    item.cbSize = sizeof(MENUITEMINFOA);
    item.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING;
    item.fType = MFT_STRING;
    item.wID = IDM_PREFERENCES_DIALOG;
    QByteArray const prefsStr = tr("Preferences...").toLocal8Bit();
    item.dwTypeData = const_cast<char *>(prefsStr.data());
    item.cch = prefsStr.size();
    ::InsertMenuItemA(menu, ::GetMenuItemCount(menu) - 1, TRUE, &item);
    item.wID = IDM_ABOUT_DIALOG;
    QByteArray const aboutStr = tr("About MAPS.ME...").toLocal8Bit();
    item.dwTypeData = const_cast<char *>(aboutStr.data());
    item.cch = aboutStr.size();
    ::InsertMenuItemA(menu, ::GetMenuItemCount(menu) - 1, TRUE, &item);
    item.fType = MFT_SEPARATOR;
    ::InsertMenuItemA(menu, ::GetMenuItemCount(menu) - 1, TRUE, &item);
  }
#endif

  LoadState();

#ifndef NO_DOWNLOADER
  // Show intro dialog if necessary
  bool bShow = true;
  (void)Settings::Get("ShowWelcome", bShow);

  if (bShow)
  {
    bool bShowUpdateDialog = true;

    string text;
    try
    {
      ReaderPtr<Reader> reader = GetPlatform().GetReader("welcome.html");
      reader.ReadAsString(text);
    }
    catch (...)
    {}

    if (!text.empty())
    {
      InfoDialog welcomeDlg(tr("Welcome to MAPS.ME!"), text.c_str(),
                            this, QStringList(tr("Download Maps")));
      if (welcomeDlg.exec() == QDialog::Rejected)
        bShowUpdateDialog = false;
    }
    Settings::Set("ShowWelcome", false);

    if (bShowUpdateDialog)
      ShowUpdateDialog();
  }
#endif // NO_DOWNLOADER

#ifndef USE_DRAPE
  m_pDrawWidget->UpdateAfterSettingsChanged();
#endif // USE_DRAPE
  locState->InvalidatePosition();
}
Ejemplo n.º 8
0
void MainWindow::CreateNavigationBar()
{
  QToolBar * pToolBar = new QToolBar(tr("Navigation Bar"), this);
  pToolBar->setOrientation(Qt::Vertical);
  pToolBar->setIconSize(QSize(32, 32));

#ifndef USE_DRAPE
  {
    // add navigation hot keys
    hotkey_t arr[] = {
      { Qt::Key_Left, SLOT(MoveLeft()) },
      { Qt::Key_Right, SLOT(MoveRight()) },
      { Qt::Key_Up, SLOT(MoveUp()) },
      { Qt::Key_Down, SLOT(MoveDown()) },
      { Qt::Key_Equal, SLOT(ScalePlus()) },
      { Qt::Key_Minus, SLOT(ScaleMinus()) },
      { Qt::ALT + Qt::Key_Equal, SLOT(ScalePlusLight()) },
      { Qt::ALT + Qt::Key_Minus, SLOT(ScaleMinusLight()) },
      { Qt::Key_A, SLOT(ShowAll()) },
      { Qt::Key_S, SLOT(QueryMaxScaleMode()) }
    };

    for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
    {
      QAction * pAct = new QAction(this);
      pAct->setShortcut(QKeySequence(arr[i].key));
      connect(pAct, SIGNAL(triggered()), m_pDrawWidget, arr[i].slot);
      addAction(pAct);
    }
  }
#endif // USE_DRAPE

  {
    // add search button with "checked" behavior
    m_pSearchAction = pToolBar->addAction(QIcon(":/navig64/search.png"),
                                           tr("Search"),
                                           this,
                                           SLOT(OnSearchButtonClicked()));
    m_pSearchAction->setCheckable(true);
    m_pSearchAction->setToolTip(tr("Offline Search"));
    m_pSearchAction->setShortcut(QKeySequence::Find);

    pToolBar->addSeparator();

// #ifndef OMIM_OS_LINUX
    // add my position button with "checked" behavior

    m_pMyPositionAction = pToolBar->addAction(QIcon(":/navig64/location.png"),
                                           tr("My Position"),
                                           this,
                                           SLOT(OnMyPosition()));
    m_pMyPositionAction->setCheckable(true);
    m_pMyPositionAction->setToolTip(tr("My Position"));
// #endif

#ifndef USE_DRAPE
    // add view actions 1
    button_t arr[] = {
      { QString(), 0, 0 },
      //{ tr("Show all"), ":/navig64/world.png", SLOT(ShowAll()) },
      { tr("Scale +"), ":/navig64/plus.png", SLOT(ScalePlus()) }
    };
    add_buttons(pToolBar, arr, ARRAY_SIZE(arr), m_pDrawWidget);
#endif // USE_DRAPE
  }

#ifndef USE_DRAPE
  // add scale slider
  QScaleSlider * pScale = new QScaleSlider(Qt::Vertical, this, 20);
  pScale->SetRange(2, scales::GetUpperScale());
  pScale->setTickPosition(QSlider::TicksRight);

  pToolBar->addWidget(pScale);
  m_pDrawWidget->SetScaleControl(pScale);

  {
    // add view actions 2
    button_t arr[] = {
      { tr("Scale -"), ":/navig64/minus.png", SLOT(ScaleMinus()) }
    };
    add_buttons(pToolBar, arr, ARRAY_SIZE(arr), m_pDrawWidget);
  }
#endif // USE_DRAPE

#ifndef NO_DOWNLOADER
  {
    // add mainframe actions
    button_t arr[] = {
      { QString(), 0, 0 },
      { tr("Download Maps"), ":/navig64/download.png", SLOT(ShowUpdateDialog()) }
    };
    add_buttons(pToolBar, arr, ARRAY_SIZE(arr), this);
  }
#endif // NO_DOWNLOADER

  addToolBar(Qt::RightToolBarArea, pToolBar);
}