summaryrefslogtreecommitdiff
path: root/core/qws/transferserver.cpp
Unidiff
Diffstat (limited to 'core/qws/transferserver.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/qws/transferserver.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/core/qws/transferserver.cpp b/core/qws/transferserver.cpp
index 0337a94..239c824 100644
--- a/core/qws/transferserver.cpp
+++ b/core/qws/transferserver.cpp
@@ -14,41 +14,53 @@
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#define _XOPEN_SOURCE 20#define _XOPEN_SOURCE
21#include <pwd.h> 21#include <pwd.h>
22#include <sys/types.h> 22#include <sys/types.h>
23#include <unistd.h> 23#include <unistd.h>
24#include <stdlib.h> 24#include <stdlib.h>
25#include <time.h> 25#include <time.h>
26
27#ifndef Q_OS_MACX
26#include <shadow.h> 28#include <shadow.h>
29#endif /* Q_OS_MACX */
27 30
28/* we need the _OS_LINUX stuff first ! */ 31/* we need the _OS_LINUX stuff first ! */
29#include <qglobal.h> 32#include <qglobal.h>
30 33
31#ifndef _OS_LINUX_ 34#ifndef _OS_LINUX_
35// Is anybody able to review this ? The include "uuid/uuid.h" couldn't be found
36// anywhere ? Therfore I removed it completely..
37// I think it should be made permanentyl !? (eilers)
38#warning "Where should uuid/uuid.h be found ? Removed this part .. (eilers)"
39#if 0
32 40
33extern "C" 41extern "C"
34{ 42{
35#include <uuid/uuid.h> 43#include <uuid/uuid.h>
36#define UUID_H_INCLUDED 44#define UUID_H_INCLUDED
37} 45}
38 46
47#endif
48
39#endif // not defined linux 49#endif // not defined linux
40 50
41#if defined(_OS_LINUX_) 51#if defined(_OS_LINUX_)
42#include <shadow.h> 52#include <shadow.h>
53#elif defined(Q_OS_MACX)
54#include <stdlib.h>
43#endif 55#endif
44 56
45#include <qdir.h> 57#include <qdir.h>
46#include <qfile.h> 58#include <qfile.h>
47#include <qtextstream.h> 59#include <qtextstream.h>
48#include <qdatastream.h> 60#include <qdatastream.h>
49#include <qmessagebox.h> 61#include <qmessagebox.h>
50#include <qstringlist.h> 62#include <qstringlist.h>
51#include <qfileinfo.h> 63#include <qfileinfo.h>
52#include <qregexp.h> 64#include <qregexp.h>
53//#include <qpe/qcopchannel_qws.h> 65//#include <qpe/qcopchannel_qws.h>
54#include <qpe/process.h> 66#include <qpe/process.h>
@@ -82,47 +94,54 @@ void TransferServer::newConnection( int socket )
82} 94}
83 95
84/* 96/*
85 * small class in anonymous namespace 97 * small class in anonymous namespace
86 * to generate a QUUid for us 98 * to generate a QUUid for us
87 */ 99 */
88namespace 100namespace
89{ 101{
90struct UidGen 102struct UidGen
91{ 103{
92 QString uuid(); 104 QString uuid();
93}; 105};
94#if !defined(_OS_LINUX_) 106#if defined(Q_OS_MACX)
95
96QString UidGen::uuid() 107QString UidGen::uuid()
97{ 108{
98 uuid_t uuid; 109 srandom( random() );
99 uuid_generate( uuid ); 110 QString numStr = QString::number( random() );
100 return QUUid( uuid ).toString(); 111
112 return "{" + numStr + "}";
101} 113}
102#else 114#elif defined(_OS_LINUX_)
103/* 115/*
104* linux got a /proc/sys/kernel/random/uuid file 116* linux got a /proc/sys/kernel/random/uuid file
105* it'll generate the uuids for us 117* it'll generate the uuids for us
106*/ 118*/
107QString UidGen::uuid() 119QString UidGen::uuid()
108{ 120{
109 QFile file( "/proc/sys/kernel/random/uuid" ); 121 QFile file( "/proc/sys/kernel/random/uuid" );
110 if (!file.open(IO_ReadOnly ) ) 122 if (!file.open(IO_ReadOnly ) )
111 return QString::null; 123 return QString::null;
112 124
113 QTextStream stream(&file); 125 QTextStream stream(&file);
114 126
115 return "{" + stream.read().stripWhiteSpace() + "}"; 127 return "{" + stream.read().stripWhiteSpace() + "}";
116} 128}
129#else
130QString UidGen::uuid()
131{
132 uuid_t uuid;
133 ::uuid_generate( uuid );
134 return QUUid( uuid ).toString();
135}
117#endif 136#endif
118} 137}
119 138
120QString SyncAuthentication::serverId() 139QString SyncAuthentication::serverId()
121{ 140{
122 Config cfg("Security"); 141 Config cfg("Security");
123 cfg.setGroup("Sync"); 142 cfg.setGroup("Sync");
124 QString r = cfg.readEntry("serverid"); 143 QString r = cfg.readEntry("serverid");
125 if ( r.isEmpty() ) { 144 if ( r.isEmpty() ) {
126 UidGen gen; 145 UidGen gen;
127 r = gen.uuid(); 146 r = gen.uuid();
128 cfg.writeEntry("serverid", r ); 147 cfg.writeEntry("serverid", r );