Use Qt dedicated 'runtime' standard location for sockets.
This fix an issue on macos where temporary directories are so long
that a user having a long nick would bypass the socket file path length
Good idea, this generally opens a new range of possibilities to simplify the code a bit, since the socket will now exist in user-specific directory (unlike until now it existed in /tmp on Linux, which could possibly clash with other users if it were called only "akonadi", hence the username and random string) so the name can be deterministic without random strings.
Since on Linux you are now creating the directory in /var/run/user/<uid>/, I'd very much prefer to keep akonadi in the name...
Actually, since you cannot have two same instances of Akonadi running at the same time, it should be perfectly fine to call the folder akonadi for the default instance and akonadi-<instancename> when Akonadi::Instance::hasIdentifier() is true, no more random strings.
This would make the directory deterministic for each instance, simplifying the code.
Once you change to the deterministic format, mkdtemp can be switched to QDir::mkpath()
createSocketDirectory is calling saveDir("runtime"), which already append "akonadi" tho the runtime path, ie "/path/to/runtime/akonadi", which result to path like "path/tp/runtime/akonadi/TMPL".
I could then just use fixed (no) template name like 'default' and 'identifier Name' in this folder then ?
should be >=, you need room for the trailing NUL character as well.
Let's hope that one does fit in the length limit :-)
Don't use QDir::separator(). That's '\' on Windows, while all this code uses '/' everywhere.
Just make it "/socket..." (the existing code is the result of automated conversion)
%1/%2, no need for QDir::separator, this uses Qt APIs, not native APIs.