Skip to content

Commit 94ca32c

Browse files
committed
Prepare for test release
1 parent 25678c5 commit 94ca32c

File tree

7 files changed

+63
-12
lines changed

7 files changed

+63
-12
lines changed

v2rock/app-entry/v2rock.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Desktop Entry]
22
Type=Application
3-
Name=V2rock
3+
Name=V2Rock
44
Comment=GUI for v2ray
55
Exec=/usr/bin/v2rock
66
Icon=/usr/share/pixmaps/v2rock.png

v2rock/config.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef CONFIG_H
2+
#define CONFIG_H
3+
4+
namespace v2rock_config
5+
{
6+
static const char __attribute__ ((unused)) *name = "V2Rock";
7+
static const char __attribute__ ((unused)) *version = "0.1.0";
8+
static const char __attribute__ ((unused)) *main_config = "v2rock.conf";
9+
static const char __attribute__ ((unused)) *v2ray_config = "config.json";
10+
}
11+
12+
#endif // CONFIG_H

v2rock/debian/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
v2rock (0.1.0-1) precise; urgency=low
2+
3+
* Initial ubuntu test release
4+
5+
-- IOsetting <[email protected]> Tue, 19 May 2020 17:32:21 +0800

v2rock/main.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,47 @@
1-
#include "maindialog.h"
21
#include <QApplication>
32

3+
#include "config.h"
4+
#include "maindialog.h"
5+
6+
7+
bool isRunningAlready()
8+
{
9+
QStringList arguments;
10+
arguments << "-A";
11+
12+
QProcess *ch = new QProcess();
13+
ch->start("ps", arguments);
14+
ch->waitForFinished(5000);
15+
ch->waitForReadyRead(5000);
16+
QString line;
17+
int count = 0;
18+
while(!ch->atEnd())
19+
{
20+
line = QString::fromLatin1(ch->readLine());
21+
if(line.contains(QFileInfo(QCoreApplication::applicationFilePath()).fileName()))
22+
count++;
23+
}
24+
delete ch;
25+
26+
return (count > 1) ? true : false;
27+
}
28+
429
int main(int argc, char *argv[])
530
{
631
QApplication a(argc, argv);
32+
QApplication::setApplicationName(v2rock_config::name);
33+
QApplication::setApplicationVersion(v2rock_config::version);
34+
a.setQuitOnLastWindowClosed(false);
35+
36+
if(isRunningAlready()) {
37+
QMessageBox::critical(
38+
NULL,
39+
"Error",
40+
"V2rock is already running.",
41+
QMessageBox::Ok);
42+
exit(0);
43+
}
44+
745
MainDialog w;
846
w.show();
947

v2rock/v2rock.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SOURCES += \
3030
$$PWD/v2rayconfigoutbound.cpp
3131

3232
HEADERS += \
33+
$$PWD/config.h \
3334
$$PWD/maindialog.h \
3435
$$PWD/settingsdialog.h \
3536
$$PWD/generaltab.h \

v2rock/v2rockconfig.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "v2rockconfig.h"
2+
#include "config.h"
23

34
V2RockConfig::V2RockConfig(QObject *parent) : QObject(parent), empty(true)
45
{
@@ -23,9 +24,6 @@ V2RockConfig::~V2RockConfig()
2324
nodes.clear();
2425
}
2526

26-
const char *V2RockConfig::CONFIG_FILE_NAME = "v2rock.conf";
27-
const char *V2RockConfig::V2RAY_FILE_NAME = "config.json";
28-
2927
bool V2RockConfig::isEmpty() const
3028
{
3129
return empty;
@@ -140,7 +138,7 @@ void V2RockConfig::init()
140138

141139
void V2RockConfig::read()
142140
{
143-
QFile file(workDir + "/" + CONFIG_FILE_NAME);
141+
QFile file(workDir + "/" + v2rock_config::main_config);
144142
if (!file.exists()) {
145143
return;
146144
}
@@ -167,9 +165,9 @@ void V2RockConfig::write()
167165
QJsonObject jsonObj;
168166
toJson(jsonObj);
169167
QJsonDocument doc(jsonObj);
170-
QFile file(workDir + "/" + CONFIG_FILE_NAME);
168+
QFile file(workDir + "/" + v2rock_config::main_config);
171169
if (!file.open(QFile::WriteOnly | QFile::Text | QFile::Truncate)) {
172-
emit logReceived("Error: file is not writable: " + workDir + "/" + CONFIG_FILE_NAME);
170+
emit logReceived("Error: file is not writable: " + workDir + "/" + v2rock_config::main_config);
173171
}
174172
file.write(doc.toJson());
175173
file.close();
@@ -435,7 +433,7 @@ QString *V2RockConfig::toV2RayJson(QJsonObject &json)
435433

436434
v2rayConfig.toJson(json);
437435
QJsonDocument doc(json);
438-
QString *configFilePath = new QString(workDir + "/" + V2RAY_FILE_NAME);
436+
QString *configFilePath = new QString(workDir + "/" + v2rock_config::v2ray_config);
439437
QFile file(*configFilePath);
440438
if (!file.open(QFile::WriteOnly | QFile::Text | QFile::Truncate)) {
441439
emit logReceived("Error: file not writable: " + *configFilePath);

v2rock/v2rockconfig.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ class V2RockConfig : public QObject
2222
explicit V2RockConfig(QObject *parent = nullptr);
2323
~V2RockConfig();
2424

25-
static const char *CONFIG_FILE_NAME;
26-
static const char *V2RAY_FILE_NAME;
27-
2825
bool isEmpty() const;
2926

3027
QString getWorkDir() const;

0 commit comments

Comments
 (0)