-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (61 loc) · 1.91 KB
/
main.cpp
File metadata and controls
77 lines (61 loc) · 1.91 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
#include <QApplication>
#include <mysignalhandler.h>
#include <sys/socket.h>
#include <sys/signal.h>
#include <unistd.h>
#include <QSocketNotifier>
#include <QSettings>
//
// Configurar los manejadores de señal
//
int setupUnixSignalHandlers()
{
struct ::sigaction hup, term, INT;
hup.sa_handler = &MySignalHandler::hupSignalHandler;
::sigemptyset(&hup.sa_mask);
hup.sa_flags = SA_RESTART;
// Establecer manejador de la señal SIGHUP
if (::sigaction(SIGHUP, &hup, 0) > 0)
return 1;
term.sa_handler = &MySignalHandler::termSignalHandler;
::sigemptyset(&term.sa_mask);
term.sa_flags = SA_RESTART;
// Establecer manejador de la señal SIGTERM
if (::sigaction(SIGTERM, &term, 0) > 0)
return 2;
INT.sa_handler = &MySignalHandler::INTSignalHandler;
::sigemptyset(&INT.sa_mask);
INT.sa_flags = SA_RESTART;
// Establecer manejador de la señal SIGTERM
if (::sigaction(SIGINT, &INT, 0) > 0)
return 3;
return 0;
}
int main(int argc, char *argv[])
{
QCoreApplication::setOrganizationName("VVG-1314-g03");
QCoreApplication::setApplicationName("Cliente");
QApplication app(argc, argv,true);
QSettings settings;
QStringList args = app.arguments();
for(int i = 0; i< args.size();i++){
if(args[i] == "-i")
settings.setValue("hostAdress", args[i+1]);
else
settings.setValue("hostAdress", "127.0.0.1");
if(args[i] == "-p")
settings.setValue("port", args[i+1]);
else
settings.setValue("port", "5000");
if(args[i] == "-f")
settings.setValue("mode", true);
else
settings.setValue("mode", false);
}
MySignalHandler MSHC(&app);
setupUnixSignalHandlers();
QObject::connect(&MSHC, SIGNAL(Exito()), &app,
SLOT(quit()));
return app.exec();
//app.exit();
}