summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/opie/resourceopie.cpp9
-rw-r--r--kaddressbook/xxport/opie/opie_xxport.cpp12
2 files changed, 16 insertions, 5 deletions
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index f992301..a4f8d8a 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -37,24 +37,25 @@ $Id$
37 37
38#include <kapplication.h> 38#include <kapplication.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kdebug.h> 40#include <kdebug.h>
41#include <klocale.h> 41#include <klocale.h>
42//US #include <ksavefile.h> 42//US #include <ksavefile.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44 44
45//US #include "formatfactory.h" 45//US #include "formatfactory.h"
46//US #include <qpe/qpeapplication.h> 46//US #include <qpe/qpeapplication.h>
47 47
48#include <opie/ocontactaccess.h> 48#include <opie/ocontactaccess.h>
49#include <opie/ocontactaccessbackend_xml.h>
49 50
50#include "resource.h" 51#include "resource.h"
51#include "resourceopieconfig.h" 52#include "resourceopieconfig.h"
52#include "stdaddressbook.h" 53#include "stdaddressbook.h"
53 54
54#include "opieconverter.h" 55#include "opieconverter.h"
55 56
56#include "resourceopie.h" 57#include "resourceopie.h"
57 58
58using namespace KABC; 59using namespace KABC;
59extern "C" 60extern "C"
60{ 61{
@@ -170,26 +171,29 @@ bool ResourceOpie::doOpen()
170 return true; 171 return true;
171} 172}
172 173
173void ResourceOpie::doClose() 174void ResourceOpie::doClose()
174{ 175{
175// qDebug("ResourceOpie::doClose() %s", mFileName.latin1()); 176// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
176} 177}
177 178
178bool ResourceOpie::load() 179bool ResourceOpie::load()
179{ 180{
180// qDebug("ResourceOpie::load() %s", mFileName.latin1()); 181// qDebug("ResourceOpie::load() %s", mFileName.latin1());
181 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; 182 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
182 183
183 OContactAccess* access = new OContactAccess("KDEPim/Pi", mFileName, 0l, false); 184 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
185
186 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
187 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
184 188
185 if ( !access ) { 189 if ( !access ) {
186 qDebug("Unable to load file() %s", mFileName.latin1()); 190 qDebug("Unable to load file() %s", mFileName.latin1());
187 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) ); 191 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
188 return false; 192 return false;
189 } 193 }
190 194
191 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available 195 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
192 196
193 if (mConverter == 0) 197 if (mConverter == 0)
194 mConverter = new OpieConverter(); 198 mConverter = new OpieConverter();
195 199
@@ -206,24 +210,25 @@ bool ResourceOpie::load()
206 res = mConverter->opieToAddressee( c, addressee ); 210 res = mConverter->opieToAddressee( c, addressee );
207 211
208 if ( !addressee.isEmpty() && res ) 212 if ( !addressee.isEmpty() && res )
209 { 213 {
210 addressee.setResource( this ); 214 addressee.setResource( this );
211 addressBook()->insertAddressee( addressee ); 215 addressBook()->insertAddressee( addressee );
212 } 216 }
213 217
214// qDebug("found %s", c.fullName().latin1()); 218// qDebug("found %s", c.fullName().latin1());
215 } 219 }
216 220
217 delete access; 221 delete access;
222 delete backend;
218 223
219 return true; 224 return true;
220} 225}
221 226
222bool ResourceOpie::save( Ticket *ticket ) 227bool ResourceOpie::save( Ticket *ticket )
223{ 228{
224 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1()); 229 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1());
225/*US 230/*US
226 231
227 qDebug("ResourceOpie::save %s", mFileName.latin1()); 232 qDebug("ResourceOpie::save %s", mFileName.latin1());
228 kdDebug(5700) << "ResourceOpie::save()" << endl; 233 kdDebug(5700) << "ResourceOpie::save()" << endl;
229 234
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp
index 90d05cd..f30a205 100644
--- a/kaddressbook/xxport/opie/opie_xxport.cpp
+++ b/kaddressbook/xxport/opie/opie_xxport.cpp
@@ -25,24 +25,26 @@
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qdir.h> 31#include <qdir.h>
32 32
33#include <kfiledialog.h> 33#include <kfiledialog.h>
34#include <kmessagebox.h> 34#include <kmessagebox.h>
35 35
36#include <opie/ocontactaccess.h> 36#include <opie/ocontactaccess.h>
37#include <opie/ocontactaccessbackend_xml.h>
38
37#include "stdaddressbook.h" 39#include "stdaddressbook.h"
38 40
39/*US 41/*US
40#include <qfile.h> 42#include <qfile.h>
41#include <qtextstream.h> 43#include <qtextstream.h>
42 44
43#include <kabc/vcardconverter.h> 45#include <kabc/vcardconverter.h>
44#ifndef KAB_EMBEDDED 46#ifndef KAB_EMBEDDED
45#include <kio/netaccess.h> 47#include <kio/netaccess.h>
46#endif //KAB_EMBEDDED 48#endif //KAB_EMBEDDED
47 49
48#include <klocale.h> 50#include <klocale.h>
@@ -87,25 +89,26 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString
87{ 89{
88 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 90 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
89 91
90#ifndef KAB_EMBEDDED 92#ifndef KAB_EMBEDDED
91 QString fileName = KFileDialog::getSaveFileName( name ); 93 QString fileName = KFileDialog::getSaveFileName( name );
92#else //KAB_EMBEDDED 94#else //KAB_EMBEDDED
93 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); 95 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() );
94#endif //KAB_EMBEDDED 96#endif //KAB_EMBEDDED
95 97
96 if ( fileName.isEmpty() ) 98 if ( fileName.isEmpty() )
97 return true; 99 return true;
98 100
99 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false); 101 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName );
102 OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false);
100 103
101 if ( !access ) { 104 if ( !access ) {
102 qDebug("Unable to access file() %s", fileName.latin1()); 105 qDebug("Unable to access file() %s", fileName.latin1());
103 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); 106 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) );
104 return false; 107 return false;
105 } 108 }
106 109
107 //Now check if the file has already entries, and ask the user if he wants to delete them first. 110 //Now check if the file has already entries, and ask the user if he wants to delete them first.
108 OContactAccess::List contactList = access->allRecords(); 111 OContactAccess::List contactList = access->allRecords();
109 if (contactList.count() > 0) 112 if (contactList.count() > 0)
110 { 113 {
111 QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); 114 QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) );
@@ -130,44 +133,46 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString
130 if (res == false) 133 if (res == false)
131 qDebug("Unable to append Contact %s", c.fullName().latin1()); 134 qDebug("Unable to append Contact %s", c.fullName().latin1());
132 } 135 }
133 else 136 else
134 { 137 {
135 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); 138 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
136 } 139 }
137 } 140 }
138 141
139 access->save(); 142 access->save();
140 143
141 delete access; 144 delete access;
142 145 delete backend;
146
143 return true; 147 return true;
144} 148}
145 149
146KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const 150KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const
147{ 151{
148 KABC::AddresseeList adrlst; 152 KABC::AddresseeList adrlst;
149 153
150 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 154 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
151 155
152#ifndef KAB_EMBEDDED 156#ifndef KAB_EMBEDDED
153 QString fileName = KFileDialog::getOpenFileName( name ); 157 QString fileName = KFileDialog::getOpenFileName( name );
154#else //KAB_EMBEDDED 158#else //KAB_EMBEDDED
155 QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); 159 QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() );
156#endif //KAB_EMBEDDED 160#endif //KAB_EMBEDDED
157 161
158 if ( fileName.isEmpty() ) 162 if ( fileName.isEmpty() )
159 return KABC::AddresseeList(); 163 return KABC::AddresseeList();
160 164
161 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false); 165 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName );
166 OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false);
162 167
163 if ( !access ) { 168 if ( !access ) {
164 qDebug("Unable to access file() %s", fileName.latin1()); 169 qDebug("Unable to access file() %s", fileName.latin1());
165 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); 170 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) );
166 return KABC::AddresseeList(); 171 return KABC::AddresseeList();
167 } 172 }
168 173
169 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available 174 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
170 175
171 KABC::OpieConverter mConverter; 176 KABC::OpieConverter mConverter;
172 bool res = false; 177 bool res = false;
173 178
@@ -181,16 +186,17 @@ KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const
181 KABC::Addressee addressee; 186 KABC::Addressee addressee;
182 187
183 res = mConverter.opieToAddressee( c, addressee ); 188 res = mConverter.opieToAddressee( c, addressee );
184 189
185 if ( !addressee.isEmpty() && res ) { 190 if ( !addressee.isEmpty() && res ) {
186 adrlst.append( addressee ); 191 adrlst.append( addressee );
187 } 192 }
188 193
189// qDebug("found %s", c.fullName().latin1()); 194// qDebug("found %s", c.fullName().latin1());
190 } 195 }
191 196
192 delete access; 197 delete access;
198 delete backend;
193 199
194 return adrlst; 200 return adrlst;
195 201
196} 202}