summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/qws/transferserver.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/qws/transferserver.cpp b/core/qws/transferserver.cpp
index 7bf6719..42ac917 100644
--- a/core/qws/transferserver.cpp
+++ b/core/qws/transferserver.cpp
@@ -1,158 +1,159 @@
1/********************************************************************** 1/**********************************************************************
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 20
21/* OPIE */ 21/* OPIE */
22#include <opie2/odebug.h> 22#include <opie2/odebug.h>
23 23
24/* STD */ 24/* STD */
25#define _XOPEN_SOURCE 25#define _XOPEN_SOURCE
26#include <pwd.h> 26#include <pwd.h>
27#include <sys/types.h> 27#include <sys/types.h>
28#include <unistd.h> 28#include <unistd.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#include <time.h> 30#include <time.h>
31#include <crypt.h>
31 32
32#ifndef Q_OS_MACX 33#ifndef Q_OS_MACX
33#include <shadow.h> 34#include <shadow.h>
34#endif /* Q_OS_MACX */ 35#endif /* Q_OS_MACX */
35 36
36/* we need the _OS_LINUX stuff first ! */ 37/* we need the _OS_LINUX stuff first ! */
37 38
38#ifndef _OS_LINUX_ 39#ifndef _OS_LINUX_
39// Is anybody able to review this ? The include "uuid/uuid.h" couldn't be found 40// Is anybody able to review this ? The include "uuid/uuid.h" couldn't be found
40// anywhere ? Therfore I removed it completely.. 41// anywhere ? Therfore I removed it completely..
41// I think it should be made permanentyl !? (eilers) 42// I think it should be made permanentyl !? (eilers)
42#warning "Where should uuid/uuid.h be found ? Removed this part .. (eilers)" 43#warning "Where should uuid/uuid.h be found ? Removed this part .. (eilers)"
43#if 0 44#if 0
44 45
45extern "C" 46extern "C"
46{ 47{
47#include <uuid/uuid.h> 48#include <uuid/uuid.h>
48#define UUID_H_INCLUDED 49#define UUID_H_INCLUDED
49} 50}
50 51
51#endif 52#endif
52 53
53#endif // not defined linux 54#endif // not defined linux
54 55
55#if defined(_OS_LINUX_) 56#if defined(_OS_LINUX_)
56#include <shadow.h> 57#include <shadow.h>
57#elif defined(Q_OS_MACX) 58#elif defined(Q_OS_MACX)
58#include <stdlib.h> 59#include <stdlib.h>
59#endif 60#endif
60 61
61#include <qtextstream.h> 62#include <qtextstream.h>
62#include <qmessagebox.h> 63#include <qmessagebox.h>
63//#include <qpe/qcopchannel_qws.h> 64//#include <qpe/qcopchannel_qws.h>
64#include <qpe/process.h> 65#include <qpe/process.h>
65#include <qpe/global.h> 66#include <qpe/global.h>
66#include <qpe/config.h> 67#include <qpe/config.h>
67#include <qpe/contact.h> 68#include <qpe/contact.h>
68#include <qpe/version.h> 69#include <qpe/version.h>
69#include <qpe/qcopenvelope_qws.h> 70#include <qpe/qcopenvelope_qws.h>
70 71
71#include "transferserver.h" 72#include "transferserver.h"
72#include <opie2/oprocess.h> 73#include <opie2/oprocess.h>
73using namespace Opie::Core; 74using namespace Opie::Core;
74 75
75const int block_size = 51200; 76const int block_size = 51200;
76 77
77TransferServer::TransferServer( Q_UINT16 port, QObject *parent , 78TransferServer::TransferServer( Q_UINT16 port, QObject *parent ,
78 const char* name ) 79 const char* name )
79 : QServerSocket( port, 1, parent, name ) 80 : QServerSocket( port, 1, parent, name )
80{ 81{
81 if ( !ok() ) 82 if ( !ok() )
82 owarn << "Failed to bind to port " << port << "" << oendl; 83 owarn << "Failed to bind to port " << port << "" << oendl;
83} 84}
84 85
85TransferServer::~TransferServer() 86TransferServer::~TransferServer()
86{ 87{
87} 88}
88 89
89void TransferServer::newConnection( int socket ) 90void TransferServer::newConnection( int socket )
90{ 91{
91 (void) new ServerPI( socket, this ); 92 (void) new ServerPI( socket, this );
92} 93}
93 94
94/* 95/*
95 * small class in anonymous namespace 96 * small class in anonymous namespace
96 * to generate a QUUid for us 97 * to generate a QUUid for us
97 */ 98 */
98namespace 99namespace
99{ 100{
100struct UidGen 101struct UidGen
101{ 102{
102 QString uuid(); 103 QString uuid();
103}; 104};
104#if defined(Q_OS_MACX) 105#if defined(Q_OS_MACX)
105QString UidGen::uuid() 106QString UidGen::uuid()
106{ 107{
107 srandom( random() ); 108 srandom( random() );
108 QString numStr = QString::number( random() ); 109 QString numStr = QString::number( random() );
109 110
110 return "{" + numStr + "}"; 111 return "{" + numStr + "}";
111} 112}
112#elif defined(_OS_LINUX_) 113#elif defined(_OS_LINUX_)
113/* 114/*
114* linux got a /proc/sys/kernel/random/uuid file 115* linux got a /proc/sys/kernel/random/uuid file
115* it'll generate the uuids for us 116* it'll generate the uuids for us
116*/ 117*/
117QString UidGen::uuid() 118QString UidGen::uuid()
118{ 119{
119 QFile file( "/proc/sys/kernel/random/uuid" ); 120 QFile file( "/proc/sys/kernel/random/uuid" );
120 if (!file.open(IO_ReadOnly ) ) 121 if (!file.open(IO_ReadOnly ) )
121 return QString::null; 122 return QString::null;
122 123
123 QTextStream stream(&file); 124 QTextStream stream(&file);
124 125
125 return "{" + stream.read().stripWhiteSpace() + "}"; 126 return "{" + stream.read().stripWhiteSpace() + "}";
126} 127}
127#else 128#else
128QString UidGen::uuid() 129QString UidGen::uuid()
129{ 130{
130 uuid_t uuid; 131 uuid_t uuid;
131 ::uuid_generate( uuid ); 132 ::uuid_generate( uuid );
132 return QUUid( uuid ).toString(); 133 return QUUid( uuid ).toString();
133} 134}
134#endif 135#endif
135} 136}
136 137
137QString SyncAuthentication::serverId() 138QString SyncAuthentication::serverId()
138{ 139{
139 Config cfg("Security"); 140 Config cfg("Security");
140 cfg.setGroup("Sync"); 141 cfg.setGroup("Sync");
141 QString r = cfg.readEntry("serverid"); 142 QString r = cfg.readEntry("serverid");
142 if ( r.isEmpty() ) { 143 if ( r.isEmpty() ) {
143 UidGen gen; 144 UidGen gen;
144 r = gen.uuid(); 145 r = gen.uuid();
145 cfg.writeEntry("serverid", r ); 146 cfg.writeEntry("serverid", r );
146 } 147 }
147 return r; 148 return r;
148} 149}
149 150
150QString SyncAuthentication::ownerName() 151QString SyncAuthentication::ownerName()
151{ 152{
152 QString vfilename = Global::applicationFileName("addressbook", 153 QString vfilename = Global::applicationFileName("addressbook",
153 "businesscard.vcf"); 154 "businesscard.vcf");
154 if (QFile::exists(vfilename)) { 155 if (QFile::exists(vfilename)) {
155 Contact c; 156 Contact c;
156 c = Contact::readVCard( vfilename )[0]; 157 c = Contact::readVCard( vfilename )[0];
157 return c.fullName(); 158 return c.fullName();
158 } 159 }