2011-11-09 08:43:23 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* Copyright 2011 Juan Carlos Cornejo jc2@paintblack.com
|
|
|
|
*
|
|
|
|
* This file is part of owncloud_sync.
|
|
|
|
*
|
|
|
|
* owncloud_sync 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2011-11-09 08:55:05 +04:00
|
|
|
* owncloud_sync is distributed in the hope that it will be useful,
|
2011-11-09 08:43:23 +04:00
|
|
|
* 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 owncloud_sync. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
2011-11-03 22:04:35 +04:00
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include "SyncWindow.h"
|
2011-11-04 23:01:42 +04:00
|
|
|
#include <QSharedMemory>
|
2011-11-09 19:27:54 +04:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
int quitOtherInstanceRunning()
|
|
|
|
{
|
|
|
|
QMessageBox box;
|
|
|
|
box.setText(QMessageBox::tr("Another instance is already running. "
|
|
|
|
"Please quit that instance before trying again."));
|
|
|
|
box.setDefaultButton(QMessageBox::Ok);
|
|
|
|
box.exec();
|
|
|
|
return -1;
|
|
|
|
}
|
2011-11-03 22:04:35 +04:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2011-11-09 19:27:54 +04:00
|
|
|
QApplication a(argc, argv);
|
2011-11-04 23:01:42 +04:00
|
|
|
// Technique for having only one application running at the same time per
|
|
|
|
// computer.
|
|
|
|
QSharedMemory sharedMemory;
|
|
|
|
sharedMemory.setKey("8SyGEyz2kcI0UNrqxc7wcuKLjD1pSL8GezlBM1W0QckgpjMon0");
|
|
|
|
if(sharedMemory.attach()) {
|
2011-11-09 19:27:54 +04:00
|
|
|
return quitOtherInstanceRunning();
|
2011-11-04 23:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!sharedMemory.create(1)) {
|
2011-11-09 19:27:54 +04:00
|
|
|
return quitOtherInstanceRunning();
|
2011-11-04 23:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Great. No other instance is running, so we can run the program.
|
2011-11-03 22:04:35 +04:00
|
|
|
SyncWindow w;
|
2011-11-05 01:07:39 +04:00
|
|
|
//w.show();
|
2011-11-03 22:04:35 +04:00
|
|
|
|
|
|
|
return a.exec();
|
|
|
|
}
|