This repository was archived by the owner on Sep 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (70 loc) · 3 KB
/
main.cpp
File metadata and controls
84 lines (70 loc) · 3 KB
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
/****************************************************************************
**
** Copyright (C) 2011 Jan M. Binder
** Contact: jan.binder@sfz-bw.de
**
** $QT_BEGIN_LICENSE:GPL$
** GNU General Public License Usage
** This file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QApplication>
#include <QCommandLineParser>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
unsigned int sig = 123456;
unsigned int port = 54545;
QString addressString = "255.255.255.255";
QHostAddress qHa = QHostAddress(addressString);
bool noconfig = false;
QApplication a(argc, argv);
QApplication::setApplicationName("iyptclock");
QApplication::setApplicationVersion("1.0");
QCommandLineParser parser;
parser.setApplicationDescription("Test helper");
QCommandLineOption portOption(QStringList() << "p" << "port",
QCoreApplication::translate("main", "Port to listen on"),
QCoreApplication::translate("main", "port"));
QCommandLineOption signatureOption(QStringList() << "s" << "signature",
QCoreApplication::translate("main", "Signature to use"),
QCoreApplication::translate("main", "signature"));
QCommandLineOption broadcastOption(QStringList() << "b" << "broadcast",
QCoreApplication::translate("main", "Broadcast address to send packets to"),
QCoreApplication::translate("main", "broadcast address"));
QCommandLineOption noconfigOption(QStringList() << "n" << "noconfig",
QCoreApplication::translate("main", "disable configuration file"));
parser.addHelpOption();
parser.addVersionOption();
parser.addOption(portOption);
parser.addOption(signatureOption);
parser.addOption(broadcastOption);
parser.addOption(noconfigOption);
parser.process(a);
if (parser.isSet(broadcastOption)) {
QString tmpAddressString = parser.value(broadcastOption);
qHa = QHostAddress(tmpAddressString);
}
if (parser.isSet(portOption)) {
unsigned int tmpPort = parser.value(portOption).toUInt();
if (tmpPort > 0 && tmpPort < 65536){
port = tmpPort;
}
}
if (parser.isSet(signatureOption)) {
unsigned int tmpSig = parser.value(signatureOption).toUInt();
if (tmpSig > 0) {
sig = tmpSig;
}
}
noconfig = parser.isSet(noconfigOption);
MainWindow w(nullptr, qHa, port, sig, noconfig);
w.show();
return a.exec();
}