author | ulf69 <ulf69> | 2004-07-29 18:16:39 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-29 18:16:39 (UTC) |
commit | 8a394f316feb828954d69480553f85c9c0f4b353 (patch) (unidiff) | |
tree | 18790dee2338be39b142131f1b6fcfb73464ab57 /kaddressbook | |
parent | f49170ad20f2c6253e1b0fa752cc284a4bc3ecec (diff) | |
download | kdepimpi-8a394f316feb828954d69480553f85c9c0f4b353.zip kdepimpi-8a394f316feb828954d69480553f85c9c0f4b353.tar.gz kdepimpi-8a394f316feb828954d69480553f85c9c0f4b353.tar.bz2 |
the export/import will be done now from within the resources.
Therefore we need no additional lib for the exportmodules
-rw-r--r-- | kaddressbook/xxport/opie/opie_xxport.cpp | 221 | ||||
-rw-r--r-- | kaddressbook/xxport/opie/opie_xxport.h | 51 | ||||
-rw-r--r-- | kaddressbook/xxport/qtopia/qtopia_xxport.cpp | 200 | ||||
-rw-r--r-- | kaddressbook/xxport/qtopia/qtopia_xxport.h | 51 | ||||
-rw-r--r-- | kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp | 199 | ||||
-rw-r--r-- | kaddressbook/xxport/sharpdtm/sharpdtm_xxport.h | 51 |
6 files changed, 0 insertions, 773 deletions
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp deleted file mode 100644 index c9b0163..0000000 --- a/kaddressbook/xxport/opie/opie_xxport.cpp +++ b/dev/null | |||
@@ -1,221 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of KAddressbook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #include <qdir.h> | ||
32 | |||
33 | #include <kfiledialog.h> | ||
34 | #include <kmessagebox.h> | ||
35 | |||
36 | #include <opie/ocontactaccess.h> | ||
37 | #include <opie/ocontactaccessbackend_xml.h> | ||
38 | |||
39 | #include "stdaddressbook.h" | ||
40 | |||
41 | /*US | ||
42 | #include <qfile.h> | ||
43 | #include <qtextstream.h> | ||
44 | |||
45 | #include <kabc/vcardconverter.h> | ||
46 | #ifndef KAB_EMBEDDED | ||
47 | #include <kio/netaccess.h> | ||
48 | #endif //KAB_EMBEDDED | ||
49 | |||
50 | #include <klocale.h> | ||
51 | #include <kmessagebox.h> | ||
52 | #include <ktempfile.h> | ||
53 | #include <kurl.h> | ||
54 | */ | ||
55 | |||
56 | #include "xxportmanager.h" | ||
57 | #include "opieconverter.h" | ||
58 | |||
59 | #include "opie_xxport.h" | ||
60 | |||
61 | |||
62 | class OpieXXPortFactory : public XXPortFactory | ||
63 | { | ||
64 | public: | ||
65 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) | ||
66 | { | ||
67 | return new OpieXXPort( ab, parent, name ); | ||
68 | } | ||
69 | }; | ||
70 | |||
71 | |||
72 | extern "C" | ||
73 | { | ||
74 | void *init_microkaddrbk_opie_xxport() | ||
75 | { | ||
76 | return ( new OpieXXPortFactory() ); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | |||
81 | OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | ||
82 | : XXPortObject( ab, parent, name ) | ||
83 | { | ||
84 | createImportAction( i18n( "Import Opie..." ) ); | ||
85 | createExportAction( i18n( "Export Opie..." ) ); | ||
86 | } | ||
87 | |||
88 | bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | ||
89 | { | ||
90 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | ||
91 | |||
92 | #ifndef KAB_EMBEDDED | ||
93 | QString fileName = KFileDialog::getSaveFileName( name ); | ||
94 | #else //KAB_EMBEDDED | ||
95 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); | ||
96 | #endif //KAB_EMBEDDED | ||
97 | |||
98 | if ( fileName.isEmpty() ) | ||
99 | return false; | ||
100 | |||
101 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); | ||
102 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); | ||
103 | |||
104 | if ( !access ) { | ||
105 | qDebug("Unable to access file() %s", fileName.latin1()); | ||
106 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | KABC::OpieConverter mConverter; | ||
111 | |||
112 | bool res = mConverter.init(); | ||
113 | if (!res) | ||
114 | { | ||
115 | QString text( i18n( "Unable to initialize opie converter.<br>Most likely a problem with the category file." ) ); | ||
116 | qDebug(text); | ||
117 | KMessageBox::error( parentWidget(), text ); | ||
118 | delete access; | ||
119 | return false; | ||
120 | } | ||
121 | |||
122 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | ||
123 | OContactAccess::List contactList = access->allRecords(); | ||
124 | if (contactList.count() > 0) | ||
125 | { | ||
126 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); | ||
127 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { | ||
128 | // Clean the database.. | ||
129 | access->clear(); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | |||
134 | KABC::Addressee::List::ConstIterator it; | ||
135 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
136 | OContact c; | ||
137 | KABC::Addressee addressee = (*it); | ||
138 | |||
139 | res = mConverter.addresseeToOpie( *it, c ); | ||
140 | if (res == true) | ||
141 | { | ||
142 | res = access->add(c); | ||
143 | if (res == false) | ||
144 | qDebug("Unable to append Contact %s", c.fullName().latin1()); | ||
145 | } | ||
146 | else | ||
147 | { | ||
148 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); | ||
149 | } | ||
150 | } | ||
151 | |||
152 | access->save(); | ||
153 | |||
154 | delete access; | ||
155 | //US the deletion of the access object deletes the backend object as well. | ||
156 | |||
157 | return true; | ||
158 | } | ||
159 | |||
160 | KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const | ||
161 | { | ||
162 | KABC::AddresseeList adrlst; | ||
163 | |||
164 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | ||
165 | |||
166 | #ifndef KAB_EMBEDDED | ||
167 | QString fileName = KFileDialog::getOpenFileName( name ); | ||
168 | #else //KAB_EMBEDDED | ||
169 | QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); | ||
170 | #endif //KAB_EMBEDDED | ||
171 | |||
172 | if ( fileName.isEmpty() ) | ||
173 | return KABC::AddresseeList(); | ||
174 | |||
175 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); | ||
176 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); | ||
177 | |||
178 | if ( !access ) { | ||
179 | qDebug("Unable to access file() %s", fileName.latin1()); | ||
180 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | ||
181 | return KABC::AddresseeList(); | ||
182 | } | ||
183 | |||
184 | access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available | ||
185 | |||
186 | KABC::OpieConverter mConverter; | ||
187 | |||
188 | bool res = mConverter.init(); | ||
189 | if (!res) | ||
190 | { | ||
191 | QString text( i18n( "Unable to initialize opie converter.<br>Most likely a problem with the category file." ) ); | ||
192 | qDebug(text); | ||
193 | KMessageBox::error( parentWidget(), text ); | ||
194 | delete access; | ||
195 | return KABC::AddresseeList(); | ||
196 | } | ||
197 | |||
198 | |||
199 | OContactAccess::List::Iterator it; | ||
200 | OContactAccess::List allList = access->allRecords(); | ||
201 | for ( it = allList.begin(); it != allList.end(); ++it ) | ||
202 | { | ||
203 | OContact c = (*it); | ||
204 | |||
205 | KABC::Addressee addressee; | ||
206 | |||
207 | res = mConverter.opieToAddressee( c, addressee ); | ||
208 | |||
209 | if ( !addressee.isEmpty() && res ) { | ||
210 | adrlst.append( addressee ); | ||
211 | } | ||
212 | |||
213 | // qDebug("found %s", c.fullName().latin1()); | ||
214 | } | ||
215 | |||
216 | delete access; | ||
217 | //US the deletion of the access object deletes the backend object as well. | ||
218 | |||
219 | return adrlst; | ||
220 | |||
221 | } | ||
diff --git a/kaddressbook/xxport/opie/opie_xxport.h b/kaddressbook/xxport/opie/opie_xxport.h deleted file mode 100644 index d6aa776..0000000 --- a/kaddressbook/xxport/opie/opie_xxport.h +++ b/dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of KAddressbook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #ifndef OPIE_XXPORT_H | ||
32 | #define OPIE_XXPORT_H | ||
33 | |||
34 | #include <xxportobject.h> | ||
35 | |||
36 | class OpieXXPort : public XXPortObject | ||
37 | { | ||
38 | Q_OBJECT | ||
39 | |||
40 | public: | ||
41 | OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 ); | ||
42 | |||
43 | QString identifier() const { return "opie"; } | ||
44 | |||
45 | public slots: | ||
46 | bool exportContacts( const KABC::AddresseeList &list, const QString &data ); | ||
47 | KABC::AddresseeList importContacts( const QString &data ) const; | ||
48 | |||
49 | }; | ||
50 | |||
51 | #endif | ||
diff --git a/kaddressbook/xxport/qtopia/qtopia_xxport.cpp b/kaddressbook/xxport/qtopia/qtopia_xxport.cpp deleted file mode 100644 index c1ed03e..0000000 --- a/kaddressbook/xxport/qtopia/qtopia_xxport.cpp +++ b/dev/null | |||
@@ -1,200 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of KAddressbook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #include <qdir.h> | ||
32 | |||
33 | #include <kfiledialog.h> | ||
34 | #include <kmessagebox.h> | ||
35 | |||
36 | #include <qpe/pim/addressbookaccess.h> | ||
37 | |||
38 | #include "stdaddressbook.h" | ||
39 | |||
40 | /*US | ||
41 | #include <qfile.h> | ||
42 | #include <qtextstream.h> | ||
43 | |||
44 | #include <kabc/vcardconverter.h> | ||
45 | #ifndef KAB_EMBEDDED | ||
46 | #include <kio/netaccess.h> | ||
47 | #endif //KAB_EMBEDDED | ||
48 | |||
49 | #include <klocale.h> | ||
50 | #include <kmessagebox.h> | ||
51 | #include <ktempfile.h> | ||
52 | #include <kurl.h> | ||
53 | */ | ||
54 | |||
55 | #include "xxportmanager.h" | ||
56 | #include "qtopiaconverter.h" | ||
57 | |||
58 | #include "qtopia_xxport.h" | ||
59 | |||
60 | |||
61 | class QtopiaXXPortFactory : public XXPortFactory | ||
62 | { | ||
63 | public: | ||
64 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) | ||
65 | { | ||
66 | return new QtopiaXXPort( ab, parent, name ); | ||
67 | } | ||
68 | }; | ||
69 | |||
70 | |||
71 | extern "C" | ||
72 | { | ||
73 | void *init_microkaddrbk_qtopia_xxport() | ||
74 | { | ||
75 | return ( new QtopiaXXPortFactory() ); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | |||
80 | QtopiaXXPort::QtopiaXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | ||
81 | : XXPortObject( ab, parent, name ) | ||
82 | { | ||
83 | createImportAction( i18n( "Import Qtopia..." ) ); | ||
84 | createExportAction( i18n( "Export Qtopia..." ) ); | ||
85 | } | ||
86 | |||
87 | bool QtopiaXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | ||
88 | { | ||
89 | // we can not choose the filename. Therefore use the default to display | ||
90 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | ||
91 | |||
92 | AddressBookAccess* access = new AddressBookAccess(); | ||
93 | |||
94 | if ( !access ) { | ||
95 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | ||
96 | qDebug(text.latin1()); | ||
97 | KMessageBox::error( parentWidget(), text ); | ||
98 | addressBook()->error( text ); | ||
99 | return false; | ||
100 | } | ||
101 | |||
102 | KABC::QtopiaConverter mConverter; | ||
103 | |||
104 | bool res = mConverter.init(); | ||
105 | if (!res) | ||
106 | { | ||
107 | QString text( i18n( "Unable to initialize qtopia converter.<br>Most likely a problem with the category file." ) ); | ||
108 | qDebug(text); | ||
109 | KMessageBox::error( parentWidget(), text ); | ||
110 | delete access; | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | ||
115 | { //create a new scope | ||
116 | AddressBookIterator it(*access); | ||
117 | const PimContact* firstcontact = it.toFirst(); | ||
118 | if (firstcontact) | ||
119 | { | ||
120 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); | ||
121 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { | ||
122 | // Clean the database.. | ||
123 | |||
124 | AddressBookIterator it2(*access); | ||
125 | for (it2.toFirst(); it2.current(); ++it2) { | ||
126 | access->removeContact(*it2.current()); | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | |||
132 | KABC::Addressee::List::ConstIterator it; | ||
133 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
134 | PimContact c; | ||
135 | |||
136 | res = mConverter.addresseeToQtopia( *it, c ); | ||
137 | if (res == true) | ||
138 | { | ||
139 | access->addContact(c); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | delete access; | ||
144 | |||
145 | return true; | ||
146 | } | ||
147 | |||
148 | KABC::AddresseeList QtopiaXXPort::importContacts( const QString& ) const | ||
149 | { | ||
150 | KABC::AddresseeList adrlst; | ||
151 | |||
152 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | ||
153 | |||
154 | AddressBookAccess* access = new AddressBookAccess(); | ||
155 | |||
156 | if ( !access ) { | ||
157 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | ||
158 | qDebug(text.latin1()); | ||
159 | addressBook()->error( text ); | ||
160 | KMessageBox::error( parentWidget(), text ); | ||
161 | return KABC::AddresseeList(); | ||
162 | } | ||
163 | |||
164 | KABC::QtopiaConverter mConverter; | ||
165 | |||
166 | bool res = mConverter.init(); | ||
167 | if (!res) | ||
168 | { | ||
169 | QString text( i18n( "Unable to initialize qtopia converter.<br>Most likely a problem with the category file." ) ); | ||
170 | qDebug(text); | ||
171 | KMessageBox::error( parentWidget(), text ); | ||
172 | delete access; | ||
173 | return KABC::AddresseeList(); | ||
174 | } | ||
175 | |||
176 | |||
177 | |||
178 | { //create a new scope | ||
179 | AddressBookIterator it(*access); | ||
180 | |||
181 | for (it.toFirst(); it.current(); ++it) { | ||
182 | const PimContact*contact = it.current(); | ||
183 | |||
184 | KABC::Addressee addressee; | ||
185 | |||
186 | res = mConverter.qtopiaToAddressee( (*contact), addressee ); | ||
187 | |||
188 | if ( !addressee.isEmpty() && res ) | ||
189 | { | ||
190 | adrlst.append( addressee ); | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | delete access; | ||
196 | //US the deletion of the access object deletes the backend object as well. | ||
197 | |||
198 | return adrlst; | ||
199 | |||
200 | } | ||
diff --git a/kaddressbook/xxport/qtopia/qtopia_xxport.h b/kaddressbook/xxport/qtopia/qtopia_xxport.h deleted file mode 100644 index 689afd2..0000000 --- a/kaddressbook/xxport/qtopia/qtopia_xxport.h +++ b/dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of KAddressbook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #ifndef QTOPIA_XXPORT_H | ||
32 | #define QTOPIA_XXPORT_H | ||
33 | |||
34 | #include <xxportobject.h> | ||
35 | |||
36 | class QtopiaXXPort : public XXPortObject | ||
37 | { | ||
38 | Q_OBJECT | ||
39 | |||
40 | public: | ||
41 | QtopiaXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 ); | ||
42 | |||
43 | QString identifier() const { return "qtopia"; } | ||
44 | |||
45 | public slots: | ||
46 | bool exportContacts( const KABC::AddresseeList &list, const QString &data ); | ||
47 | KABC::AddresseeList importContacts( const QString &data ) const; | ||
48 | |||
49 | }; | ||
50 | |||
51 | #endif | ||
diff --git a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp deleted file mode 100644 index 8593814..0000000 --- a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp +++ b/dev/null | |||
@@ -1,199 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of KAddressbook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #include <qdir.h> | ||
32 | |||
33 | #include <kfiledialog.h> | ||
34 | #include <kmessagebox.h> | ||
35 | |||
36 | #include <sl/slzdb.h> | ||
37 | |||
38 | #include "stdaddressbook.h" | ||
39 | |||
40 | /*US | ||
41 | #include <qfile.h> | ||
42 | #include <qtextstream.h> | ||
43 | |||
44 | #include <kabc/vcardconverter.h> | ||
45 | #ifndef KAB_EMBEDDED | ||
46 | #include <kio/netaccess.h> | ||
47 | #endif //KAB_EMBEDDED | ||
48 | |||
49 | #include <klocale.h> | ||
50 | #include <kmessagebox.h> | ||
51 | #include <ktempfile.h> | ||
52 | #include <kurl.h> | ||
53 | */ | ||
54 | |||
55 | #include "xxportmanager.h" | ||
56 | #include "sharpdtmconverter.h" | ||
57 | |||
58 | #include "sharpdtm_xxport.h" | ||
59 | |||
60 | |||
61 | class SharpDTMXXPortFactory : public XXPortFactory | ||
62 | { | ||
63 | public: | ||
64 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) | ||
65 | { | ||
66 | return new SharpDTMXXPort( ab, parent, name ); | ||
67 | } | ||
68 | }; | ||
69 | |||
70 | |||
71 | extern "C" | ||
72 | { | ||
73 | void *init_microkaddrbk_sharpdtm_xxport() | ||
74 | { | ||
75 | return ( new SharpDTMXXPortFactory() ); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | |||
80 | SharpDTMXXPort::SharpDTMXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | ||
81 | : XXPortObject( ab, parent, name ) | ||
82 | { | ||
83 | createImportAction( i18n( "Import Sharp..." ) ); | ||
84 | createExportAction( i18n( "Export Sharp..." ) ); | ||
85 | } | ||
86 | |||
87 | bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | ||
88 | { | ||
89 | // we can not choose the filename. Therefore use the default to display | ||
90 | QString fileName = SlZDataBase::addressbookFileName(); | ||
91 | |||
92 | SlZDataBase* access = new SlZDataBase(fileName, | ||
93 | SlZDataBase::addressbookItems()); | ||
94 | |||
95 | if ( !access ) { | ||
96 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | ||
97 | qDebug(text.latin1()); | ||
98 | KMessageBox::error( parentWidget(), text ); | ||
99 | addressBook()->error( text ); | ||
100 | return false; | ||
101 | } | ||
102 | |||
103 | KABC::SharpDTMConverter mConverter; | ||
104 | |||
105 | bool res = mConverter.init(); | ||
106 | if (!res) | ||
107 | { | ||
108 | QString text( i18n( "Unable to initialize sharpdtm converter.<br>Most likely a problem with the category file." ) ); | ||
109 | qDebug(text); | ||
110 | KMessageBox::error( parentWidget(), text ); | ||
111 | delete access; | ||
112 | return false; | ||
113 | } | ||
114 | |||
115 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | ||
116 | if (access->count() > 0) | ||
117 | { | ||
118 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); | ||
119 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { | ||
120 | // Clean the database.. | ||
121 | access->deleteCard(0, SlZDataBase::AllCard ); | ||
122 | } | ||
123 | } | ||
124 | |||
125 | KABC::Addressee::List::ConstIterator it; | ||
126 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
127 | CardId c; | ||
128 | res = access->editNewCard(); | ||
129 | |||
130 | if (res == true) | ||
131 | { | ||
132 | res = mConverter.addresseeToSharp( *it, access, c ); | ||
133 | |||
134 | if (res == true) | ||
135 | access->finishEditCard(&c); | ||
136 | else | ||
137 | access->cancelEditCard(); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | delete access; | ||
142 | |||
143 | return true; | ||
144 | } | ||
145 | |||
146 | KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | ||
147 | { | ||
148 | KABC::AddresseeList adrlst; | ||
149 | |||
150 | QString fileName = SlZDataBase::addressbookFileName(); | ||
151 | |||
152 | // the last parameter in the SlZDataBase constructor means "readonly" | ||
153 | SlZDataBase* access = new SlZDataBase(fileName, | ||
154 | SlZDataBase::addressbookItems(), NULL, true); | ||
155 | |||
156 | |||
157 | if ( !access ) { | ||
158 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | ||
159 | qDebug(text.latin1()); | ||
160 | addressBook()->error( text ); | ||
161 | KMessageBox::error( parentWidget(), text ); | ||
162 | return KABC::AddresseeList(); | ||
163 | } | ||
164 | |||
165 | KABC::SharpDTMConverter mConverter; | ||
166 | |||
167 | bool res = mConverter.init(); | ||
168 | if (!res) | ||
169 | { | ||
170 | QString text( i18n( "Unable to initialize sharp converter.<br>Most likely a problem with the category file." ) ); | ||
171 | qDebug(text); | ||
172 | KMessageBox::error( parentWidget(), text ); | ||
173 | delete access; | ||
174 | return KABC::AddresseeList(); | ||
175 | } | ||
176 | |||
177 | |||
178 | { //create a new scope | ||
179 | CardId id; | ||
180 | |||
181 | for (bool res=access->first(); res == true; res=access->next()) { | ||
182 | id = access->cardId(); | ||
183 | |||
184 | KABC::Addressee addressee; | ||
185 | |||
186 | res = mConverter.sharpToAddressee( id, access, addressee ); | ||
187 | |||
188 | if ( !addressee.isEmpty() && res ) | ||
189 | { | ||
190 | adrlst.append( addressee ); | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | delete access; | ||
196 | |||
197 | return adrlst; | ||
198 | |||
199 | } | ||
diff --git a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.h b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.h deleted file mode 100644 index ec8e342..0000000 --- a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.h +++ b/dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of KAddressbook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #ifndef SHARPDTM_XXPORT_H | ||
32 | #define SHARPDTM_XXPORT_H | ||
33 | |||
34 | #include <xxportobject.h> | ||
35 | |||
36 | class SharpDTMXXPort : public XXPortObject | ||
37 | { | ||
38 | Q_OBJECT | ||
39 | |||
40 | public: | ||
41 | SharpDTMXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 ); | ||
42 | |||
43 | QString identifier() const { return "qtopia"; } | ||
44 | |||
45 | public slots: | ||
46 | bool exportContacts( const KABC::AddresseeList &list, const QString &data ); | ||
47 | KABC::AddresseeList importContacts( const QString &data ) const; | ||
48 | |||
49 | }; | ||
50 | |||
51 | #endif | ||