# # # add_file "src/GuitoneCore.cpp" # content [57ade5ff937fd43b41271f3dab4d772fad2479b6] # # add_file "src/GuitoneCore.h" # content [286c2f55e77fb3947a6ec3b10689793f6179913d] # # add_file "src/GuitoneDriver.cpp" # content [02ee4e0942c688ab35015d80b4701737cb75cae7] # # add_file "src/GuitoneDriver.h" # content [6df86d7464f8c7c9cfd971b4e7bcefc34b41d27f] # ============================================================ --- src/GuitoneCore.cpp 57ade5ff937fd43b41271f3dab4d772fad2479b6 +++ src/GuitoneCore.cpp 57ade5ff937fd43b41271f3dab4d772fad2479b6 @@ -0,0 +1,135 @@ +/*************************************************************************** + * Copyright (C) 2008 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "GuitoneCore.h" +#include "Preferences.h" +#include "Settings.h" + +#ifdef Q_WS_MACX +#include "CocoaUtil.h" +#endif + +#include +#include + +GuitoneCore::GuitoneCore(int & argc, char** argv, QApplication::Type type) + : QApplication(argc, argv, type), monotoneManager(0) +{ +#ifndef Q_WS_MACX + updateDialog = 0; +#else +// CocoaUtil::initialize(); +#endif + + // check for updates immediatly on launch + if (Settings::getBool("CheckForUpdates", true)) + { + checkForApplicationUpdates(true); + } + + monotoneManager = new MonotoneManager(); + + QTimer::singleShot(0, this, SLOT(setMonotoneBinaryPath())); +} + +GuitoneCore::~GuitoneCore() +{ + delete monotoneManager; +#ifndef Q_WS_MACX + if (updateDialog) delete updateDialog; +#endif +} + +void GuitoneCore::setMonotoneBinaryPath() +{ + if (monotoneManager->monotoneBinaryPathSet()) + { + W("monotone binary path already set"); + } + + QString installedVersion; + if (!monotoneManager->setMonotoneBinaryPath( + Settings::getMtnBinaryPath(), + Settings::getBool("RelaxedVersionCheck", false), + installedVersion)) + { + QMessageBox::critical( + NULL, + tr("Error"), + tr("The path to the monotone binary is either invalid " + "or points to a version of monotone with which guitone can't " + "work with. Guitone requires monotone with an interface version " + "between '%1' and '%2'. Your installation has the interface " + "version '%3'.") + .arg(MonotoneManager::MinInterfaceVersion) + .arg(MonotoneManager::MaxInterfaceVersion) + .arg(installedVersion), + QMessageBox::Ok, 0, 0 + ); + + // note: the pref dialog tries to set the mtn binary path on its + // own again and can only be accepted successfully, if the user + // enters/selects a valid monotone binary path + Preferences dialog(NULL); + + // the user has rejected the dialog, i.e. made no new settings + if (dialog.exec() == QDialog::Rejected) + { + return; + } + } + D("binary path was set"); + emit monotoneBinaryPathSet(); +} + +void GuitoneCore::quit() +{ + Settings::sync(); + QApplication::quit(); +} + +void GuitoneCore::checkForApplicationUpdates(bool silent) +{ +#ifdef Q_WS_MACX + //CocoaUtil::checkForUpdates(silent); +#else + if (!updateDialog) + { + updateDialog = new ApplicationUpdate(NULL); + } + + if (!updateDialog->updateAvailable()) + { + if (!silent) + { + QMessageBox::information( + NULL, + tr("No updates available"), + tr("Your version of guitone (%1) is already up-to-date.") + .arg(GUITONE_VERSION), + QMessageBox::Ok + ); + } + return; + } + updateDialog->show(); +#endif +} + ============================================================ --- src/GuitoneCore.h 286c2f55e77fb3947a6ec3b10689793f6179913d +++ src/GuitoneCore.h 286c2f55e77fb3947a6ec3b10689793f6179913d @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2008 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef GUITONE_CORE_H +#define GUITONE_CORE_H + +#include "MonotoneManager.h" +#ifndef Q_WS_MACX +#include "ApplicationUpdate.h" +#endif + +#include + +class GuitoneCore : public QApplication +{ + Q_OBJECT +public: + GuitoneCore(int &, char**, QApplication::Type); + ~GuitoneCore(); + inline MonotoneManager * manager() { return monotoneManager; } + +signals: + void monotoneBinaryPathSet(); + +public slots: + void checkForApplicationUpdates(bool silent = false); + virtual void quit(); + +private slots: + void setMonotoneBinaryPath(); + +private: + MonotoneManager * monotoneManager; +#ifndef Q_WS_MACX + ApplicationUpdate * updateDialog; +#endif +}; + +#endif + ============================================================ --- src/GuitoneDriver.cpp 02ee4e0942c688ab35015d80b4701737cb75cae7 +++ src/GuitoneDriver.cpp 02ee4e0942c688ab35015d80b4701737cb75cae7 @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (C) 2008 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "GuitoneDriver.h" + +GuitoneDriver::GuitoneDriver(int & argc, char** argv) + : GuitoneCore(argc, argv, QApplication::Tty) +{} + +GuitoneDriver::~GuitoneDriver() +{} + ============================================================ --- src/GuitoneDriver.h 6df86d7464f8c7c9cfd971b4e7bcefc34b41d27f +++ src/GuitoneDriver.h 6df86d7464f8c7c9cfd971b4e7bcefc34b41d27f @@ -0,0 +1,35 @@ +/*************************************************************************** + * Copyright (C) 2008 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef GUITONE_DRIVER_H +#define GUITONE_DRIVER_H + +#include "GuitoneCore.h" + +class GuitoneDriver : public GuitoneCore +{ + Q_OBJECT +public: + GuitoneDriver(int &, char**); + ~GuitoneDriver(); +}; + +#endif +