|
|
@ -21,9 +21,37 @@ |
|
|
|
#include <QCoreApplication> |
|
|
|
#include <QCoreApplication> |
|
|
|
#include <QDebug> |
|
|
|
#include <QDebug> |
|
|
|
#include <QThread> |
|
|
|
#include <QThread> |
|
|
|
|
|
|
|
|
|
|
|
#include <ctime> |
|
|
|
#include <ctime> |
|
|
|
#include <random> |
|
|
|
#include <random> |
|
|
|
#include <unistd.h> |
|
|
|
#include <unistd.h> |
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef Q_OS_WIN |
|
|
|
|
|
|
|
const char* getCurUsername() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return getenv("USERNAME"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
const char* getCurUsername() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return getenv("USER"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString getIpcKey() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto* user = getCurUsername(); |
|
|
|
|
|
|
|
if (!user) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
qWarning() << "Failed to get current username. Will use a global IPC."; |
|
|
|
|
|
|
|
user = ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return QString("qtox-" IPC_PROTOCOL_VERSION "-") + user; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @var time_t IPC::lastEvent |
|
|
|
* @var time_t IPC::lastEvent |
|
|
@ -40,7 +68,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
IPC::IPC(uint32_t profileId) |
|
|
|
IPC::IPC(uint32_t profileId) |
|
|
|
: profileId{profileId} |
|
|
|
: profileId{profileId} |
|
|
|
, globalMemory{"qtox-" IPC_PROTOCOL_VERSION} |
|
|
|
, globalMemory{getIpcKey()} |
|
|
|
{ |
|
|
|
{ |
|
|
|
qRegisterMetaType<IPCEventHandler>("IPCEventHandler"); |
|
|
|
qRegisterMetaType<IPCEventHandler>("IPCEventHandler"); |
|
|
|
|
|
|
|
|
|
|
|