summaryrefslogtreecommitdiff
path: root/core/qws/transferserver.cpp
Unidiff
Diffstat (limited to 'core/qws/transferserver.cpp') (more/less context) (ignore 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
@@ -2,65 +2,77 @@
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
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>
55#include <qpe/global.h> 67#include <qpe/global.h>
56#include <qpe/config.h> 68#include <qpe/config.h>
57#include <qpe/contact.h> 69#include <qpe/contact.h>
58#include <qpe/quuid.h> 70#include <qpe/quuid.h>
59#include <qpe/version.h> 71#include <qpe/version.h>
60#include <qpe/qcopenvelope_qws.h> 72#include <qpe/qcopenvelope_qws.h>
61 73
62#include "transferserver.h" 74#include "transferserver.h"
63#include <opie/oprocess.h> 75#include <opie/oprocess.h>
64 76
65const int block_size = 51200; 77const int block_size = 51200;
66 78
@@ -70,71 +82,78 @@ TransferServer::TransferServer( Q_UINT16 port, QObject *parent ,
70{ 82{
71 if ( !ok() ) 83 if ( !ok() )
72 qWarning( "Failed to bind to port %d", port ); 84 qWarning( "Failed to bind to port %d", port );
73} 85}
74 86
75TransferServer::~TransferServer() 87TransferServer::~TransferServer()
76{ 88{
77} 89}
78 90
79void TransferServer::newConnection( int socket ) 91void TransferServer::newConnection( int socket )
80{ 92{
81 (void) new ServerPI( socket, this ); 93 (void) new ServerPI( socket, this );
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 );
129 } 148 }
130 return r; 149 return r;
131} 150}
132 151
133QString SyncAuthentication::ownerName() 152QString SyncAuthentication::ownerName()
134{ 153{
135 QString vfilename = Global::applicationFileName("addressbook", 154 QString vfilename = Global::applicationFileName("addressbook",
136 "businesscard.vcf"); 155 "businesscard.vcf");
137 if (QFile::exists(vfilename)) { 156 if (QFile::exists(vfilename)) {
138 Contact c; 157 Contact c;
139 c = Contact::readVCard( vfilename )[0]; 158 c = Contact::readVCard( vfilename )[0];
140 return c.fullName(); 159 return c.fullName();