summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/opie/opie_xxport.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp
index 616eec1..90d05cd 100644
--- a/kaddressbook/xxport/opie/opie_xxport.cpp
+++ b/kaddressbook/xxport/opie/opie_xxport.cpp
@@ -15,182 +15,182 @@
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
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 "stdaddressbook.h" 37#include "stdaddressbook.h"
38 38
39/*US 39/*US
40#include <qfile.h> 40#include <qfile.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42 42
43#include <kabc/vcardconverter.h> 43#include <kabc/vcardconverter.h>
44#ifndef KAB_EMBEDDED 44#ifndef KAB_EMBEDDED
45#include <kio/netaccess.h> 45#include <kio/netaccess.h>
46#endif //KAB_EMBEDDED 46#endif //KAB_EMBEDDED
47 47
48#include <klocale.h> 48#include <klocale.h>
49#include <kmessagebox.h> 49#include <kmessagebox.h>
50#include <ktempfile.h> 50#include <ktempfile.h>
51#include <kurl.h> 51#include <kurl.h>
52*/ 52*/
53 53
54#include "xxportmanager.h" 54#include "xxportmanager.h"
55#include "opieconverter.h" 55#include "opieconverter.h"
56 56
57#include "opie_xxport.h" 57#include "opie_xxport.h"
58 58
59 59
60class OpieXXPortFactory : public XXPortFactory 60class OpieXXPortFactory : public XXPortFactory
61{ 61{
62 public: 62 public:
63 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 63 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
64 { 64 {
65 return new OpieXXPort( ab, parent, name ); 65 return new OpieXXPort( ab, parent, name );
66 } 66 }
67}; 67};
68 68
69 69
70extern "C" 70extern "C"
71{ 71{
72 void *init_kaddrbk_opie_xxport() 72 void *init_kaddrbk_opie_xxport()
73 { 73 {
74 return ( new OpieXXPortFactory() ); 74 return ( new OpieXXPortFactory() );
75 } 75 }
76} 76}
77 77
78 78
79OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) 79OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
80 : XXPortObject( ab, parent, name ) 80 : XXPortObject( ab, parent, name )
81{ 81{
82 createImportAction( i18n( "Import Opie..." ) ); 82 createImportAction( i18n( "Import Opie..." ) );
83 createExportAction( i18n( "Export Opie..." ) ); 83 createExportAction( i18n( "Export Opie..." ) );
84} 84}
85 85
86bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) 86bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data )
87{ 87{
88 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 88 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
89 89
90#ifndef KAB_EMBEDDED 90#ifndef KAB_EMBEDDED
91 QString fileName = KFileDialog::getSaveFileName( name ); 91 QString fileName = KFileDialog::getSaveFileName( name );
92#else //KAB_EMBEDDED 92#else //KAB_EMBEDDED
93 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); 93 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() );
94#endif //KAB_EMBEDDED 94#endif //KAB_EMBEDDED
95 95
96 if ( fileName.isEmpty() ) 96 if ( fileName.isEmpty() )
97 return true; 97 return true;
98 98
99 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false); 99 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false);
100 100
101 if ( !access ) { 101 if ( !access ) {
102 qDebug("Unable to access file() %s", fileName.latin1()); 102 qDebug("Unable to access file() %s", fileName.latin1());
103 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); 103 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) );
104 return false; 104 return false;
105 } 105 }
106 106
107 //Now check if the file has already entries, and ask the user if he wants to delete them first. 107 //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(); 108 OContactAccess::List contactList = access->allRecords();
109 if (contactList.count() > 0) 109 if (contactList.count() > 0)
110 { 110 {
111 QString text( i18n( "<qt>Do you want to remove all existing entries from <b>%1</b> before exporting.?</qt>" ) ); 111 QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) );
112 if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { 112 if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) {
113 // Clean the database.. 113 // Clean the database..
114 access->clear(); 114 access->clear();
115 } 115 }
116 } 116 }
117 117
118 KABC::OpieConverter mConverter; 118 KABC::OpieConverter mConverter;
119 bool res; 119 bool res;
120 120
121 KABC::Addressee::List::ConstIterator it; 121 KABC::Addressee::List::ConstIterator it;
122 for ( it = list.begin(); it != list.end(); ++it ) { 122 for ( it = list.begin(); it != list.end(); ++it ) {
123 OContact c; 123 OContact c;
124 KABC::Addressee addressee = (*it); 124 KABC::Addressee addressee = (*it);
125 125
126 res = mConverter.addresseeToOpie( *it, c ); 126 res = mConverter.addresseeToOpie( *it, c );
127 if (res == true) 127 if (res == true)
128 { 128 {
129 res = access->add(c); 129 res = access->add(c);
130 if (res == false) 130 if (res == false)
131 qDebug("Unable to append Contact %s", c.fullName().latin1()); 131 qDebug("Unable to append Contact %s", c.fullName().latin1());
132 } 132 }
133 else 133 else
134 { 134 {
135 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); 135 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
136 } 136 }
137 } 137 }
138 138
139 access->save(); 139 access->save();
140 140
141 delete access; 141 delete access;
142 142
143 return true; 143 return true;
144} 144}
145 145
146KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const 146KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const
147{ 147{
148 KABC::AddresseeList adrlst; 148 KABC::AddresseeList adrlst;
149 149
150 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 150 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
151 151
152#ifndef KAB_EMBEDDED 152#ifndef KAB_EMBEDDED
153 QString fileName = KFileDialog::getOpenFileName( name ); 153 QString fileName = KFileDialog::getOpenFileName( name );
154#else //KAB_EMBEDDED 154#else //KAB_EMBEDDED
155 QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); 155 QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() );
156#endif //KAB_EMBEDDED 156#endif //KAB_EMBEDDED
157 157
158 if ( fileName.isEmpty() ) 158 if ( fileName.isEmpty() )
159 return KABC::AddresseeList(); 159 return KABC::AddresseeList();
160 160
161 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false); 161 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false);
162 162
163 if ( !access ) { 163 if ( !access ) {
164 qDebug("Unable to access file() %s", fileName.latin1()); 164 qDebug("Unable to access file() %s", fileName.latin1());
165 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); 165 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) );
166 return KABC::AddresseeList(); 166 return KABC::AddresseeList();
167 } 167 }
168 168
169 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available 169 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
170 170
171 KABC::OpieConverter mConverter; 171 KABC::OpieConverter mConverter;
172 bool res = false; 172 bool res = false;
173 173
174 174
175 OContactAccess::List::Iterator it; 175 OContactAccess::List::Iterator it;
176 OContactAccess::List allList = access->allRecords(); 176 OContactAccess::List allList = access->allRecords();
177 for ( it = allList.begin(); it != allList.end(); ++it ) 177 for ( it = allList.begin(); it != allList.end(); ++it )
178 { 178 {
179 OContact c = (*it); 179 OContact c = (*it);
180 180
181 KABC::Addressee addressee; 181 KABC::Addressee addressee;
182 182
183 res = mConverter.opieToAddressee( c, addressee ); 183 res = mConverter.opieToAddressee( c, addressee );
184 184
185 if ( !addressee.isEmpty() && res ) { 185 if ( !addressee.isEmpty() && res ) {
186 adrlst.append( addressee ); 186 adrlst.append( addressee );
187 } 187 }
188 188
189// qDebug("found %s", c.fullName().latin1()); 189// qDebug("found %s", c.fullName().latin1());
190 } 190 }
191 191
192 delete access; 192 delete access;
193 193
194 return adrlst; 194 return adrlst;
195 195
196} 196}