| 46 | static const char ack[] = "ack"; |
| 47 | |
| 48 | QString QtLocalPeer::appSessionId(const QString &appId) |
| 49 | { |
| 50 | QByteArray idc = appId.toUtf8(); |
| 51 | quint16 idNum = qChecksum(idc.constData(), idc.size()); |
| 52 | //### could do: two 16bit checksums over separate halves of id, for a 32bit result - improved uniqeness probability. Every-other-char split would be best. |
| 53 | |
| 54 | QString res = QLatin1String("qtsingleapplication-") |
| 55 | + QString::number(idNum, 16); |
| 56 | #if defined(Q_OS_WIN) |
| 57 | if (!pProcessIdToSessionId) { |
| 58 | QLibrary lib(QLatin1String("kernel32")); |
| 59 | pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); |
| 60 | } |
| 61 | if (pProcessIdToSessionId) { |
| 62 | DWORD sessionId = 0; |
| 63 | pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); |
| 64 | res += QLatin1Char('-') + QString::number(sessionId, 16); |
| 65 | } |
| 66 | #else |
| 67 | res += QLatin1Char('-') + QString::number(::getuid(), 16); |
| 68 | #endif |
| 69 | return res; |
| 70 | } |
| 71 | |
| 72 | QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId) |
| 73 | : QObject(parent), id(appId) |