| 129 | } |
| 130 | |
| 131 | void SingleApplicationPrivate::genBlockServerName() |
| 132 | { |
| 133 | QCryptographicHash appData( QCryptographicHash::Sha256 ); |
| 134 | appData.addData( "SingleApplication", 17 ); |
| 135 | appData.addData( SingleApplication::app_t::applicationName().toUtf8() ); |
| 136 | appData.addData( SingleApplication::app_t::organizationName().toUtf8() ); |
| 137 | appData.addData( SingleApplication::app_t::organizationDomain().toUtf8() ); |
| 138 | |
| 139 | if ( ! appDataList.isEmpty() ) |
| 140 | appData.addData( appDataList.join( "" ).toUtf8() ); |
| 141 | |
| 142 | if( ! (options & SingleApplication::Mode::ExcludeAppVersion) ){ |
| 143 | appData.addData( SingleApplication::app_t::applicationVersion().toUtf8() ); |
| 144 | } |
| 145 | |
| 146 | if( ! (options & SingleApplication::Mode::ExcludeAppPath) ){ |
| 147 | #if defined(Q_OS_WIN) |
| 148 | appData.addData( SingleApplication::app_t::applicationFilePath().toLower().toUtf8() ); |
| 149 | #elif defined(Q_OS_LINUX) |
| 150 | // If the application is running as an AppImage then the APPIMAGE env var should be used |
| 151 | // instead of applicationPath() as each instance is launched with its own executable path |
| 152 | const QByteArray appImagePath = qgetenv( "APPIMAGE" ); |
| 153 | if( appImagePath.isEmpty() ){ // Not running as AppImage: use path to executable file |
| 154 | appData.addData( SingleApplication::app_t::applicationFilePath().toUtf8() ); |
| 155 | } else { // Running as AppImage: Use absolute path to AppImage file |
| 156 | appData.addData( appImagePath ); |
| 157 | }; |
| 158 | #else |
| 159 | appData.addData( SingleApplication::app_t::applicationFilePath().toUtf8() ); |
| 160 | #endif |
| 161 | } |
| 162 | |
| 163 | // User level block requires a user specific data in the hash |
| 164 | if( options & SingleApplication::Mode::User ){ |
| 165 | appData.addData( getUsername().toUtf8() ); |
| 166 | } |
| 167 | |
| 168 | // Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with |
| 169 | // server naming requirements. |
| 170 | blockServerName = appData.result().toBase64().replace("/", "_"); |
| 171 | } |
| 172 | |
| 173 | void SingleApplicationPrivate::initializeMemoryBlock() const |
| 174 | { |
no test coverage detected