-rw-r--r-- | kaddressbook/xxport/sharpdtm/sharpdtmE.pro | 27 | ||||
-rw-r--r-- | kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp | 206 | ||||
-rw-r--r-- | kaddressbook/xxport/sharpdtm/sharpdtm_xxport.h | 51 |
3 files changed, 284 insertions, 0 deletions
diff --git a/kaddressbook/xxport/sharpdtm/sharpdtmE.pro b/kaddressbook/xxport/sharpdtm/sharpdtmE.pro new file mode 100644 index 0000000..6e83853 --- a/dev/null +++ b/kaddressbook/xxport/sharpdtm/sharpdtmE.pro | |||
@@ -0,0 +1,27 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt warn_on | ||
3 | TARGET = microkaddrbk_sharpdtm_xxport | ||
4 | |||
5 | OBJECTS_DIR = obj/$(PLATFORM) | ||
6 | MOC_DIR = moc/$(PLATFORM) | ||
7 | DESTDIR = $(QPEDIR)/lib | ||
8 | |||
9 | DEFINES += KAB_EMBEDDED | ||
10 | |||
11 | INCLUDEPATH += ../.. ../../../external/sharpdtm/include ../../.. ../../../kabc ../../../kabc/converter/qtopia ../../../microkde ../../../microkde/kdeui ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include | ||
12 | LIBS += -L$(QPEDIR)/lib | ||
13 | LIBS += -lmicrokde | ||
14 | LIBS += -lmicrokabc | ||
15 | LIBS += -lqpe | ||
16 | LIBS += -lqte | ||
17 | LIBS += -lzdtm | ||
18 | LIBS += -lmicrokabc_sharpdtmconverter | ||
19 | |||
20 | INTERFACES = \ | ||
21 | |||
22 | HEADERS = \ | ||
23 | sharpdtm_xxport.h \ | ||
24 | |||
25 | SOURCES = \ | ||
26 | sharpdtm_xxport.cpp \ | ||
27 | |||
diff --git a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp new file mode 100644 index 0000000..4e6a504 --- a/dev/null +++ b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp | |||
@@ -0,0 +1,206 @@ | |||
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 "qtopiaconverter.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::QtopiaConverter mConverter; | ||
104 | |||
105 | // bool res = mConverter.init(); | ||
106 | bool res = true; | ||
107 | if (!res) | ||
108 | { | ||
109 | QString text( i18n( "Unable to initialize sharpdtm converter.<br>Most likely a problem with the category file." ) ); | ||
110 | qDebug(text); | ||
111 | KMessageBox::error( parentWidget(), text ); | ||
112 | delete access; | ||
113 | return false; | ||
114 | } | ||
115 | |||
116 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | ||
117 | /*US | ||
118 | { //create a new scope | ||
119 | AddressBookIterator it(*access); | ||
120 | const PimContact* firstcontact = it.toFirst(); | ||
121 | if (firstcontact) | ||
122 | { | ||
123 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); | ||
124 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { | ||
125 | // Clean the database.. | ||
126 | |||
127 | AddressBookIterator it2(*access); | ||
128 | for (it2.toFirst(); it2.current(); ++it2) { | ||
129 | access->removeContact(*it2.current()); | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | |||
135 | KABC::Addressee::List::ConstIterator it; | ||
136 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
137 | PimContact c; | ||
138 | KABC::Addressee addressee = (*it); | ||
139 | |||
140 | res = mConverter.addresseeToQtopia( *it, c ); | ||
141 | if (res == true) | ||
142 | { | ||
143 | access->addContact(c); | ||
144 | } | ||
145 | } | ||
146 | */ | ||
147 | delete access; | ||
148 | |||
149 | return true; | ||
150 | } | ||
151 | |||
152 | KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | ||
153 | { | ||
154 | KABC::AddresseeList adrlst; | ||
155 | |||
156 | QString fileName = SlZDataBase::addressbookFileName(); | ||
157 | |||
158 | SlZDataBase* access = new SlZDataBase(fileName, | ||
159 | SlZDataBase::addressbookItems()); | ||
160 | |||
161 | |||
162 | if ( !access ) { | ||
163 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | ||
164 | qDebug(text.latin1()); | ||
165 | addressBook()->error( text ); | ||
166 | KMessageBox::error( parentWidget(), text ); | ||
167 | return KABC::AddresseeList(); | ||
168 | } | ||
169 | /*US | ||
170 | KABC::QtopiaConverter mConverter; | ||
171 | |||
172 | bool res = mConverter.init(); | ||
173 | if (!res) | ||
174 | { | ||
175 | QString text( i18n( "Unable to initialize sharp converter.<br>Most likely a problem with the category file." ) ); | ||
176 | qDebug(text); | ||
177 | KMessageBox::error( parentWidget(), text ); | ||
178 | delete access; | ||
179 | return KABC::AddresseeList(); | ||
180 | } | ||
181 | |||
182 | |||
183 | |||
184 | { //create a new scope | ||
185 | AddressBookIterator it(*access); | ||
186 | |||
187 | for (it.toFirst(); it.current(); ++it) { | ||
188 | const PimContact*contact = it.current(); | ||
189 | |||
190 | KABC::Addressee addressee; | ||
191 | |||
192 | res = mConverter.qtopiaToAddressee( (*contact), addressee ); | ||
193 | |||
194 | if ( !addressee.isEmpty() && res ) | ||
195 | { | ||
196 | adrlst.append( addressee ); | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | */ | ||
201 | |||
202 | delete access; | ||
203 | |||
204 | return adrlst; | ||
205 | |||
206 | } | ||
diff --git a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.h b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.h new file mode 100644 index 0000000..ec8e342 --- a/dev/null +++ b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.h | |||
@@ -0,0 +1,51 @@ | |||
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 | ||