Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
2953c6ba
Commit
2953c6ba
authored
Jun 24, 2014
by
Fabio Bas
Browse files
Ported servatrice
parent
80f68306
Changes
2
Hide whitespace changes
Inline
Side-by-side
servatrice/src/main.cpp
View file @
2953c6ba
...
...
@@ -93,6 +93,17 @@ void myMessageOutput2(QtMsgType /*type*/, const char *msg)
std
::
cerr
<<
msg
<<
std
::
endl
;
}
void
myMessageOutputQt5
(
QtMsgType
/*type*/
,
const
QMessageLogContext
&
,
const
QString
&
msg
)
{
logger
->
logMessage
(
msg
);
}
void
myMessageOutput2Qt5
(
QtMsgType
/*type*/
,
const
QMessageLogContext
&
,
const
QString
&
msg
)
{
logger
->
logMessage
(
msg
);
std
::
cerr
<<
msg
.
toStdString
()
<<
std
::
endl
;
}
#ifdef Q_OS_UNIX
void
sigSegvHandler
(
int
sig
)
{
...
...
@@ -121,9 +132,12 @@ int main(int argc, char *argv[])
bool
logToConsole
=
args
.
contains
(
"--log-to-console"
);
qRegisterMetaType
<
QList
<
int
>
>
(
"QList<int>"
);
#if QT_VERSION < 0x050000
// gone in Qt5, all source files _MUST_ be utf8-encoded
QTextCodec
::
setCodecForCStrings
(
QTextCodec
::
codecForName
(
"UTF-8"
));
#endif
QSettings
*
settings
=
new
QSettings
(
"servatrice.ini"
,
QSettings
::
IniFormat
);
loggerThread
=
new
QThread
;
...
...
@@ -133,11 +147,19 @@ int main(int argc, char *argv[])
loggerThread
->
start
();
QMetaObject
::
invokeMethod
(
logger
,
"startLog"
,
Qt
::
BlockingQueuedConnection
,
Q_ARG
(
QString
,
settings
->
value
(
"server/logfile"
).
toString
()));
#if QT_VERSION < 0x050000
if
(
logToConsole
)
qInstallMsgHandler
(
myMessageOutput
);
else
qInstallMsgHandler
(
myMessageOutput2
);
#else
if
(
logToConsole
)
qInstallMessageHandler
(
myMessageOutputQt5
);
else
qInstallMessageHandler
(
myMessageOutput2Qt5
);
#endif
#ifdef Q_OS_UNIX
struct
sigaction
hup
;
hup
.
sa_handler
=
ServerLogger
::
hupSignalHandler
;
...
...
@@ -173,8 +195,12 @@ int main(int argc, char *argv[])
if
(
server
->
initServer
())
{
std
::
cerr
<<
"-------------------------"
<<
std
::
endl
;
std
::
cerr
<<
"Server initialized."
<<
std
::
endl
;
#if QT_VERSION < 0x050000
qInstallMsgHandler
(
myMessageOutput
);
#else
qInstallMessageHandler
(
myMessageOutputQt5
);
#endif
retval
=
app
.
exec
();
std
::
cerr
<<
"Server quit."
<<
std
::
endl
;
...
...
servatrice/src/servatrice.cpp
View file @
2953c6ba
...
...
@@ -234,8 +234,16 @@ bool Servatrice::initServer()
if
(
!
certFile
.
open
(
QIODevice
::
ReadOnly
))
throw
QString
(
"Error opening certificate file: %1"
).
arg
(
certFileName
);
QSslCertificate
cert
(
&
certFile
);
#if QT_VERSION < 0x050000
if
(
!
cert
.
isValid
())
throw
(
QString
(
"Invalid certificate."
));
#else
const
QDateTime
currentTime
=
QDateTime
::
currentDateTime
();
if
(
currentTime
<
cert
.
effectiveDate
()
||
currentTime
>
cert
.
expiryDate
()
||
cert
.
isBlacklisted
())
throw
(
QString
(
"Invalid certificate."
));
#endif
qDebug
()
<<
"Loading private key..."
;
QFile
keyFile
(
keyFileName
);
if
(
!
keyFile
.
open
(
QIODevice
::
ReadOnly
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment