summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/olaccess/olaccess.pro1
-rw-r--r--kabc/plugins/olaccess/resourceolaccess.cpp5
2 files changed, 4 insertions, 2 deletions
diff --git a/kabc/plugins/olaccess/olaccess.pro b/kabc/plugins/olaccess/olaccess.pro
index 4416d0c..9b95015 100644
--- a/kabc/plugins/olaccess/olaccess.pro
+++ b/kabc/plugins/olaccess/olaccess.pro
@@ -1,34 +1,35 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3TARGET = microkabc_olaccess 3TARGET = microkabc_olaccess
4 4
5include( ../../../variables.pri ) 5include( ../../../variables.pri )
6 6
7INCLUDEPATH += ../../.. ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat 7INCLUDEPATH += ../../.. ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
8 8
9INTERFACES = \ 9INTERFACES = \
10 10
11DESTDIR = ../../../bin
11HEADERS = \ 12HEADERS = \
12 resourceolaccess.h \ 13 resourceolaccess.h \
13 resourceolaccessconfig.h \ 14 resourceolaccessconfig.h \
14 olaccessconverter.h 15 olaccessconverter.h
15 16
16SOURCES = \ 17SOURCES = \
17 resourceolaccess.cpp \ 18 resourceolaccess.cpp \
18 resourceolaccessconfig.cpp \ 19 resourceolaccessconfig.cpp \
19 olaccessconverter.cpp 20 olaccessconverter.cpp
20 21
21unix : { 22unix : {
22OBJECTS_DIR = obj/unix 23OBJECTS_DIR = obj/unix
23MOC_DIR = moc/unix 24MOC_DIR = moc/unix
24} 25}
25win32: { 26win32: {
26CONFIG += dll 27CONFIG += dll
27DEFINES += _WIN32_ 28DEFINES += _WIN32_
28OBJECTS_DIR = obj/win 29OBJECTS_DIR = obj/win
29MOC_DIR = moc/win 30MOC_DIR = moc/win
30LIBS += ../../../bin/microkdepim.lib 31LIBS += ../../../bin/microkdepim.lib
31LIBS += ../../../bin/microkcal.lib 32LIBS += ../../../bin/microkcal.lib
32LIBS += ../../../bin/microkde.lib 33LIBS += ../../../bin/microkde.lib
33LIBS += ../../../bin/microkabc.lib 34LIBS += ../../../bin/microkabc.lib
34} 35}
diff --git a/kabc/plugins/olaccess/resourceolaccess.cpp b/kabc/plugins/olaccess/resourceolaccess.cpp
index 7113e0e..c7c9874 100644
--- a/kabc/plugins/olaccess/resourceolaccess.cpp
+++ b/kabc/plugins/olaccess/resourceolaccess.cpp
@@ -1,254 +1,255 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <sys/types.h> 28#include <sys/types.h>
29#include <sys/stat.h> 29#include <sys/stat.h>
30 30
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34#include <qregexp.h> 34#include <qregexp.h>
35//US #include <qtimer.h> 35//US #include <qtimer.h>
36 36
37#include <kapplication.h> 37#include <kapplication.h>
38#include <kconfig.h> 38#include <kconfig.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41//US #include <ksavefile.h> 41//US #include <ksavefile.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44 44
45 45
46#include <libkdepim/ksyncprofile.h> 46#include <libkdepim/ksyncprofile.h>
47 47
48#include "resourceolaccessconfig.h" 48#include "resourceolaccessconfig.h"
49#include "resourceolaccess.h" 49#include "resourceolaccess.h"
50 50
51#include "stdaddressbook.h" 51#include "stdaddressbook.h"
52 52
53#include "olaccessconverter.h" 53#include "olaccessconverter.h"
54//#define ALLOW_LOCKING 54//#define ALLOW_LOCKING
55using namespace KABC; 55using namespace KABC;
56extern "C" 56extern "C"
57{ 57__declspec(dllexport)
58
58 void *init_microkabc_olaccess() 59 void *init_microkabc_olaccess()
59 { 60 {
60 return new KRES::PluginFactory<Resourceolaccess,ResourceolaccessConfig>(); 61 return new KRES::PluginFactory<Resourceolaccess,ResourceolaccessConfig>();
61 } 62 }
62} 63
63 64
64Resourceolaccess::Resourceolaccess( const KConfig *config ) 65Resourceolaccess::Resourceolaccess( const KConfig *config )
65 : Resource( config ), mConverter (0) 66 : Resource( config ), mConverter (0)
66{ 67{
67 // we can not choose the filename. Therefore use the default to display 68 // we can not choose the filename. Therefore use the default to display
68 //mAccess = 0; 69 //mAccess = 0;
69 QString fileName;// = SlZDataBase::addressbookFileName(); 70 QString fileName;// = SlZDataBase::addressbookFileName();
70 init( fileName ); 71 init( fileName );
71} 72}
72 73
73Resourceolaccess::Resourceolaccess( const QString &fileName ) 74Resourceolaccess::Resourceolaccess( const QString &fileName )
74 : Resource( 0 ) 75 : Resource( 0 )
75{ 76{
76 //mAccess = 0; 77 //mAccess = 0;
77 init( fileName ); 78 init( fileName );
78} 79}
79 80
80void Resourceolaccess::init( const QString &fileName ) 81void Resourceolaccess::init( const QString &fileName )
81{ 82{
82 if (mConverter == 0) { 83 if (mConverter == 0) {
83 mConverter = new OlaccessConverter(); 84 mConverter = new OlaccessConverter();
84 bool res = mConverter->init(); 85 bool res = mConverter->init();
85 if ( !res ) 86 if ( !res )
86 { 87 {
87 QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); 88 QString msg("Unable to initialize sharp converter. Most likely a problem with the category file");
88 qDebug(msg); 89 qDebug(msg);
89 return; 90 return;
90 } 91 }
91 } 92 }
92 setFileName( fileName ); 93 setFileName( fileName );
93} 94}
94 95
95Resourceolaccess::~Resourceolaccess() 96Resourceolaccess::~Resourceolaccess()
96{ 97{
97 if (mConverter != 0) 98 if (mConverter != 0)
98 delete mConverter; 99 delete mConverter;
99 100
100 //if(mAccess != 0) 101 //if(mAccess != 0)
101 //delete mAccess; 102 //delete mAccess;
102} 103}
103 104
104void Resourceolaccess::writeConfig( KConfig *config ) 105void Resourceolaccess::writeConfig( KConfig *config )
105{ 106{
106 Resource::writeConfig( config ); 107 Resource::writeConfig( config );
107} 108}
108 109
109Ticket *Resourceolaccess::requestSaveTicket() 110Ticket *Resourceolaccess::requestSaveTicket()
110{ 111{
111 112
112 qDebug("Resourceolaccess::requestSaveTicket: %s", fileName().latin1()); 113 qDebug("Resourceolaccess::requestSaveTicket: %s", fileName().latin1());
113 114
114 if ( !addressBook() ) return 0; 115 if ( !addressBook() ) return 0;
115 return createTicket( this ); 116 return createTicket( this );
116} 117}
117 118
118 119
119bool Resourceolaccess::doOpen() 120bool Resourceolaccess::doOpen()
120{ 121{
121 if (!mConverter) 122 if (!mConverter)
122 return false; 123 return false;
123 return true; 124 return true;
124} 125}
125 126
126void Resourceolaccess::doClose() 127void Resourceolaccess::doClose()
127{ 128{
128 return; 129 return;
129} 130}
130 131
131bool Resourceolaccess::load() 132bool Resourceolaccess::load()
132{ 133{
133 if (!mConverter) 134 if (!mConverter)
134 return false; 135 return false;
135 QString fileN ;//= SlZDataBase::addressbookFileName(); 136 QString fileN ;//= SlZDataBase::addressbookFileName();
136#if 0 137#if 0
137 if ( ! mAccess ) { 138 if ( ! mAccess ) {
138 mAccess = new SlZDataBase(fileN, 139 mAccess = new SlZDataBase(fileN,
139 SlZDataBase::addressbookItems(), 140 SlZDataBase::addressbookItems(),
140 0, true); 141 0, true);
141 } 142 }
142 if(mAccess == 0) 143 if(mAccess == 0)
143 return false; 144 return false;
144 145
145 qDebug("Resourceolaccess:: %x load: %s",this, fileName().latin1()); 146 qDebug("Resourceolaccess:: %x load: %s",this, fileName().latin1());
146 bool res = false; 147 bool res = false;
147 CardId id; 148 CardId id;
148 for (bool res=mAccess->first(); res == true; res=mAccess->next()) 149 for (bool res=mAccess->first(); res == true; res=mAccess->next())
149 { 150 {
150 id = mAccess->cardId(); 151 id = mAccess->cardId();
151 KABC::Addressee addressee; 152 KABC::Addressee addressee;
152 res = mConverter->sharpToAddressee( id, mAccess, addressee ); 153 res = mConverter->sharpToAddressee( id, mAccess, addressee );
153 if ( !addressee.isEmpty() && res ) 154 if ( !addressee.isEmpty() && res )
154 { 155 {
155 addressee.setResource( this ); 156 addressee.setResource( this );
156 addressBook()->insertAddressee( addressee ); 157 addressBook()->insertAddressee( addressee );
157 } 158 }
158 } 159 }
159 if(mAccess != 0) 160 if(mAccess != 0)
160 delete mAccess; 161 delete mAccess;
161 mAccess = 0; 162 mAccess = 0;
162#endif 163#endif
163 return true; 164 return true;
164} 165}
165 166
166bool Resourceolaccess::save( Ticket *ticket ) 167bool Resourceolaccess::save( Ticket *ticket )
167{ 168{
168#if 0 169#if 0
169 if (!mConverter) 170 if (!mConverter)
170 return false; 171 return false;
171 QString fileN = SlZDataBase::addressbookFileName(); 172 QString fileN = SlZDataBase::addressbookFileName();
172 if ( ! mAccess ) { 173 if ( ! mAccess ) {
173 mAccess = new SlZDataBase(fileN, 174 mAccess = new SlZDataBase(fileN,
174 SlZDataBase::addressbookItems(), 175 SlZDataBase::addressbookItems(),
175 0, false); 176 0, false);
176 } 177 }
177 if(mAccess == 0) 178 if(mAccess == 0)
178 return false; 179 return false;
179 qDebug("Resourceolaccess::save: %s", fileName().latin1()); 180 qDebug("Resourceolaccess::save: %s", fileName().latin1());
180 KABC::AddressBook::Iterator it; 181 KABC::AddressBook::Iterator it;
181 bool res; 182 bool res;
182 KABC::Addressee::List changedAddressees; 183 KABC::Addressee::List changedAddressees;
183 typedef QMap<int,QString> AddresseeMap; 184 typedef QMap<int,QString> AddresseeMap;
184 AddresseeMap map; 185 AddresseeMap map;
185 CardId id ; 186 CardId id ;
186 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 187 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
187 188
188 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 189 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
189 QString uid = (*it).originalExternalUID(); 190 QString uid = (*it).originalExternalUID();
190 bool res; 191 bool res;
191 if ( uid.isEmpty() ) 192 if ( uid.isEmpty() )
192 id = 0; 193 id = 0;
193 else 194 else
194 id = uid.toUInt(); 195 id = uid.toUInt();
195 KABC::Addressee addressee = (*it); 196 KABC::Addressee addressee = (*it);
196 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { 197 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
197 res = mAccess->startEditCard(id); 198 res = mAccess->startEditCard(id);
198 if (res == true) 199 if (res == true)
199 { 200 {
200 res = mConverter->addresseeToSharp( (*it), mAccess, id ); 201 res = mConverter->addresseeToSharp( (*it), mAccess, id );
201 if (res == true) 202 if (res == true)
202 { 203 {
203 res = mAccess->finishEditCard(&id);; 204 res = mAccess->finishEditCard(&id);;
204 mConverter->setCategories( (*it), mAccess, id ); 205 mConverter->setCategories( (*it), mAccess, id );
205 map.insert(id,(*it).uid()); 206 map.insert(id,(*it).uid());
206 if (res == false) 207 if (res == false)
207 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); 208 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
208 209
209 } 210 }
210 else 211 else
211 { 212 {
212 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); 213 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1());
213 mAccess->cancelEditCard(); 214 mAccess->cancelEditCard();
214 } 215 }
215 } 216 }
216 217
217 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 218 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
218 res = mAccess->deleteCard(&id); 219 res = mAccess->deleteCard(&id);
219 if ( !res ) 220 if ( !res )
220 qDebug("delete error "); 221 qDebug("delete error ");
221 222
222 223
223 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 224 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
224 //changed 225 //changed
225 res = mAccess->startEditCard(id); 226 res = mAccess->startEditCard(id);
226 if (res == true) 227 if (res == true)
227 { 228 {
228 res = mConverter->addresseeToSharp( (*it), mAccess, id ); 229 res = mConverter->addresseeToSharp( (*it), mAccess, id );
229 if (res == true) 230 if (res == true)
230 { 231 {
231 res = mAccess->finishEditCard(&id); 232 res = mAccess->finishEditCard(&id);
232 mConverter->setCategories( (*it), mAccess, id ); 233 mConverter->setCategories( (*it), mAccess, id );
233 map.insert(id,(*it).uid()); 234 map.insert(id,(*it).uid());
234 if (res == false) 235 if (res == false)
235 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); 236 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
236 } 237 }
237 else 238 else
238 { 239 {
239 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); 240 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1());
240 mAccess->cancelEditCard(); 241 mAccess->cancelEditCard();
241 } 242 }
242 } 243 }
243 } 244 }
244 } 245 }
245 246
246 } 247 }
247 AddresseeMap::Iterator itam; 248 AddresseeMap::Iterator itam;
248 for ( res=mAccess->first(); res == true; res=mAccess->next()) 249 for ( res=mAccess->first(); res == true; res=mAccess->next())
249 { 250 {
250 id = mAccess->cardId(); 251 id = mAccess->cardId();
251 int idint = id; 252 int idint = id;
252 itam = map.find( idint ); 253 itam = map.find( idint );
253 if ( itam != map.end() ) { 254 if ( itam != map.end() ) {
254 KABC::Addressee addressee; 255 KABC::Addressee addressee;