-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
146 lines (123 loc) · 4.71 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* This file is part of StarBackup
* StarBackup is a Free Real-Time Backup and Archiving Software
*
* Copyright (C) 2011 Clément Nardi
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "profilecreator.h"
#include <stdio.h>
#include "backupsettings.h"
#include "trace.h"
#include <QDateTime>
#include <QSettings>
#include <QSystemSemaphore>
#include <QSharedMemory>
#include <QMessageBox>
#include "instancemanager.h"
#include <QTranslator>
#include <languagechooser.h>
#include "filesystemtools.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
/*
QDir d("K:/backup/source test/toto");
d.setFilter(QDir::System | QDir::AllEntries);
FTRACE(qDebug()<<QDir(d.entryInfoList().at(3).absoluteFilePath()).exists());
//FTRACE(qDebug()<<d.rmdir(d.entryInfoList().at(3).absoluteFilePath()));
//FTRACE(qDebug()<<QFile(d.entryInfoList().at(3).absoluteFilePath()).remove());
FTRACE(qDebug()<<QDir(d.entryInfoList().at(3).absoluteFilePath()).count());
FTRACE(qDebug()<<QDir(d.entryInfoList().at(3).absoluteFilePath()).entryList().at(0));
FTRACE(qDebug()<<d.count());
FTRACE(qDebug()<<d.entryList().at(0));
FTRACE(qDebug()<<d.entryList().at(1));
FTRACE(qDebug()<<d.entryList().at(2));
FTRACE(qDebug()<<d.entryList().at(3));
FTRACE(qDebug()<<d.entryInfoList().at(3).isSymLink());
FTRACE(qDebug()<<d.entryInfoList().at(3).isDir());
return 15;
*/
/*
QSystemSemaphore sem("StarBackup", 1, QSystemSemaphore::Open);
int ret = sem.error();
FTRACE(qDebug()<<ret);
if (ret == QSystemSemaphore::AlreadyExists) {
QMessageBox msgBox;
msgBox.setText(QString("StarBackup is already running!"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
exit(0);
}
*/
QSharedMemory sm ("StarBackupInstance");
if (!sm.create(1)) {
/*
QMessageBox msgBox;
msgBox.setText(QString("StarBackup is already running!"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
*/
QSystemSemaphore sem("StarBackupSemaphore", 0, QSystemSemaphore::Open);
sem.release(1);
exit(0);
}
QCoreApplication::setOrganizationName("StarBackup");
QCoreApplication::setApplicationName("StarBackup");
QCoreApplication::setApplicationVersion("0.1");
QCoreApplication::setOrganizationDomain("StarBackup.net");
QSettings settings(QSettings::IniFormat,
QSettings::UserScope,
QCoreApplication::organizationName(),
QCoreApplication::applicationName());
QDir dir = QDir(QFileInfo(settings.fileName()).absolutePath());
TRACE(qDebug()<<dir);
TRACE(qDebug()<<QDir::current());
if (!dir.exists()) {
dir.mkpath(dir.absolutePath());
}
LanguageChooser * lc = new LanguageChooser(QDir::current().absolutePath(),&a,&settings);
TRACE(qDebug()<<QDir::current());
if (QDir::setCurrent(dir.absolutePath())) {
TRACE(qDebug()<<QDir::current());
} else {
TRACE(qDebug()<<"boo");
}
ProfileCreator *pc = new ProfileCreator();
MainWindow *w = new MainWindow(pc,lc);
InstanceManager im(w);
im.start();
if (!(argc > 1 && QString::compare(argv[1],"-hide")==0)) {
w->show();
}
if (w->backupListModel->backupList.size() == 0) {
QMessageBox msgBox;
msgBox.setText(QString(a.tr("No settings found!")));
msgBox.setInformativeText(QString(a.tr("Would you like to configure a backup now?")));
msgBox.setIcon(QMessageBox::Information);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes) {
w->addProfile_clicked();
}
}
return a.exec();
}