-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthentification.cpp
More file actions
49 lines (37 loc) · 1.43 KB
/
authentification.cpp
File metadata and controls
49 lines (37 loc) · 1.43 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
#include "authentification.h"
#include "utils.h"
#include "settings.h"
#include "logging.h"
#include <QDebug>
#include <QString>
#include <QProcess>
#include <QDir>
#include <QTextCodec>
namespace Pico{
namespace Auth{
QString GetUid(double sessionId){
Pico::Logging::Funcs logging;
logging.Write("GET_UID => Called for an UID generation");
QString uid = "-1";
QProcess* process = new QProcess();
QString file = QDir::currentPath() + "/" + QString::fromStdString(Pico::Settings::HC_CONFIG.UID_EXE_PATH) + " " + QString::number(sessionId, 'f', 0);
logging.Write("GET_UID => Looking for "+file);
if (!Pico::Utils::file_exists(Pico::Settings::HC_CONFIG.UID_EXE_PATH)){
logging.Write("GET_UID => UID Generator couldn't be find. Exiting.");
return uid;
}
logging.Write("GET_UID => Found it.");
QString output;
process->start(file);
while (!process->waitForFinished(3000)){
if (process->error() < 5){
logging.Write("GET_UID => Could not generate UID : "+process->errorString()+". Exiting.");
return uid;
}
}
logging.Write("GET_UID => Process finished");
uid = QTextCodec::codecForMib(106)->toUnicode(process->readAll());
return uid;
}
}
}