author | zecke <zecke> | 2002-09-06 21:35:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-06 21:35:13 (UTC) |
commit | e95e14f056ce6be658a4fd0d4737168431e92d88 (patch) (unidiff) | |
tree | 732f0a69b2063dc6c54444486223fd99879da72c /core/launcher/transferserver.cpp | |
parent | 5536f65e60b3c662d2da3636e617faaad02522db (diff) | |
download | opie-e95e14f056ce6be658a4fd0d4737168431e92d88.zip opie-e95e14f056ce6be658a4fd0d4737168431e92d88.tar.gz opie-e95e14f056ce6be658a4fd0d4737168431e92d88.tar.bz2 |
Remove the libuuid dependency for Linux targets...
Diffstat (limited to 'core/launcher/transferserver.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/launcher/transferserver.cpp | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 9d18b7b..a20df2f 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -25,11 +25,15 @@ | |||
25 | #include <time.h> | 25 | #include <time.h> |
26 | #include <shadow.h> | 26 | #include <shadow.h> |
27 | 27 | ||
28 | #ifndef _OS_LINUX_ | ||
29 | |||
28 | extern "C" { | 30 | extern "C" { |
29 | #include <uuid/uuid.h> | 31 | #include <uuid/uuid.h> |
30 | #define UUID_H_INCLUDED | 32 | #define UUID_H_INCLUDED |
31 | } | 33 | } |
32 | 34 | ||
35 | #endif // not defined linux | ||
36 | |||
33 | #if defined(_OS_LINUX_) | 37 | #if defined(_OS_LINUX_) |
34 | #include <shadow.h> | 38 | #include <shadow.h> |
35 | #endif | 39 | #endif |
@@ -76,15 +80,46 @@ void TransferServer::newConnection( int socket ) | |||
76 | (void) new ServerPI( socket, this ); | 80 | (void) new ServerPI( socket, this ); |
77 | } | 81 | } |
78 | 82 | ||
83 | /* | ||
84 | * small class in anonymous namespace | ||
85 | * to generate a QUUid for us | ||
86 | */ | ||
87 | namespace { | ||
88 | struct UidGen { | ||
89 | QString uuid(); | ||
90 | }; | ||
91 | #if defined(_OS_LINUX_) | ||
92 | /* | ||
93 | * linux got a /proc/sys/kernel/random/uuid file | ||
94 | * it'll generate the uuids for us | ||
95 | */ | ||
96 | QString UidGen::uuid() { | ||
97 | QFile file( "/proc/sys/kernel/random/uuid" ); | ||
98 | if (!file.open(IO_ReadOnly ) ) | ||
99 | return QString::null; | ||
100 | |||
101 | QTextStream stream(&file); | ||
102 | |||
103 | return "{" + stream.read().stripWhiteSpace() + "}"; | ||
104 | } | ||
105 | #else | ||
106 | QString UidGen::uuid() { | ||
107 | uuid_t uuid; | ||
108 | uuid_generate( uuid ); | ||
109 | return QUUid( uuid ).toString(); | ||
110 | } | ||
111 | #endif | ||
112 | } | ||
113 | |||
79 | QString SyncAuthentication::serverId() | 114 | QString SyncAuthentication::serverId() |
80 | { | 115 | { |
81 | Config cfg("Security"); | 116 | Config cfg("Security"); |
82 | cfg.setGroup("Sync"); | 117 | cfg.setGroup("Sync"); |
83 | QString r=cfg.readEntry("serverid"); | 118 | QString r=cfg.readEntry("serverid"); |
84 | if ( r.isEmpty() ) { | 119 | if ( r.isEmpty() ) { |
85 | uuid_t uuid; | 120 | UidGen gen; |
86 | uuid_generate( uuid ); | 121 | r = gen.uuid(); |
87 | cfg.writeEntry("serverid",(r = QUuid( uuid ).toString())); | 122 | cfg.writeEntry("serverid", r ); |
88 | } | 123 | } |
89 | return r; | 124 | return r; |
90 | } | 125 | } |