summaryrefslogtreecommitdiffabout
path: root/kaddressbook/xxport
authorulf69 <ulf69>2004-07-17 00:37:00 (UTC)
committer ulf69 <ulf69>2004-07-17 00:37:00 (UTC)
commit2439711b1ac7ee38269baff704293eb37a27f6c9 (patch) (unidiff)
tree706d4a329b557b28db14442b41229d11fede854b /kaddressbook/xxport
parentb306ee8c93dd563f42a32a1ee2c63eacc6050604 (diff)
downloadkdepimpi-2439711b1ac7ee38269baff704293eb37a27f6c9.zip
kdepimpi-2439711b1ac7ee38269baff704293eb37a27f6c9.tar.gz
kdepimpi-2439711b1ac7ee38269baff704293eb37a27f6c9.tar.bz2
implementation of sharp import and export
Diffstat (limited to 'kaddressbook/xxport') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/sharpdtm/sharpdtmE.pro2
-rw-r--r--kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp103
2 files changed, 49 insertions, 56 deletions
diff --git a/kaddressbook/xxport/sharpdtm/sharpdtmE.pro b/kaddressbook/xxport/sharpdtm/sharpdtmE.pro
index 6e83853..0425c42 100644
--- a/kaddressbook/xxport/sharpdtm/sharpdtmE.pro
+++ b/kaddressbook/xxport/sharpdtm/sharpdtmE.pro
@@ -8,7 +8,7 @@ DESTDIR = $(QPEDIR)/lib
8 8
9DEFINES += KAB_EMBEDDED 9DEFINES += KAB_EMBEDDED
10 10
11INCLUDEPATH += ../.. ../../../external/sharpdtm/include ../../.. ../../../kabc ../../../kabc/converter/qtopia ../../../microkde ../../../microkde/kdeui ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include 11INCLUDEPATH += ../.. ../../../external/sharpdtm/include ../../.. ../../../kabc ../../../kabc/converter/sharpdtm ../../../microkde ../../../microkde/kdeui ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include
12LIBS += -L$(QPEDIR)/lib 12LIBS += -L$(QPEDIR)/lib
13LIBS += -lmicrokde 13LIBS += -lmicrokde
14LIBS += -lmicrokabc 14LIBS += -lmicrokabc
diff --git a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp
index 4e6a504..8593814 100644
--- a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp
+++ b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp
@@ -53,7 +53,7 @@ $Id$
53*/ 53*/
54 54
55#include "xxportmanager.h" 55#include "xxportmanager.h"
56//#include "qtopiaconverter.h" 56#include "sharpdtmconverter.h"
57 57
58#include "sharpdtm_xxport.h" 58#include "sharpdtm_xxport.h"
59 59
@@ -90,8 +90,8 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr
90 QString fileName = SlZDataBase::addressbookFileName(); 90 QString fileName = SlZDataBase::addressbookFileName();
91 91
92 SlZDataBase* access = new SlZDataBase(fileName, 92 SlZDataBase* access = new SlZDataBase(fileName,
93 SlZDataBase::addressbookItems()); 93 SlZDataBase::addressbookItems());
94 94
95 if ( !access ) { 95 if ( !access ) {
96 QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); 96 QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) );
97 qDebug(text.latin1()); 97 qDebug(text.latin1());
@@ -100,65 +100,60 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr
100 return false; 100 return false;
101 } 101 }
102 102
103// KABC::QtopiaConverter mConverter; 103 KABC::SharpDTMConverter mConverter;
104 104
105// bool res = mConverter.init(); 105 bool res = mConverter.init();
106 bool res = true;
107 if (!res) 106 if (!res)
108 { 107 {
109 QString text( i18n( "Unable to initialize sharpdtm converter.<br>Most likely a problem with the category file." ) ); 108 QString text( i18n( "Unable to initialize sharpdtm converter.<br>Most likely a problem with the category file." ) );
110 qDebug(text); 109 qDebug(text);
111 KMessageBox::error( parentWidget(), text ); 110 KMessageBox::error( parentWidget(), text );
112 delete access; 111 delete access;
113 return false; 112 return false;
114 } 113 }
115 114
116 //Now check if the file has already entries, and ask the user if he wants to delete them first. 115 //Now check if the file has already entries, and ask the user if he wants to delete them first.
117/*US 116 if (access->count() > 0)
118 { //create a new scope 117 {
119 AddressBookIterator it(*access); 118 QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) );
120 const PimContact* firstcontact = it.toFirst(); 119 if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) {
121 if (firstcontact) 120 // Clean the database..
122 { 121 access->deleteCard(0, SlZDataBase::AllCard );
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 } 122 }
133 } 123 }
134 124
135 KABC::Addressee::List::ConstIterator it; 125 KABC::Addressee::List::ConstIterator it;
136 for ( it = list.begin(); it != list.end(); ++it ) { 126 for ( it = list.begin(); it != list.end(); ++it ) {
137 PimContact c; 127 CardId c;
138 KABC::Addressee addressee = (*it); 128 res = access->editNewCard();
139 129
140 res = mConverter.addresseeToQtopia( *it, c );
141 if (res == true) 130 if (res == true)
142 { 131 {
143 access->addContact(c); 132 res = mConverter.addresseeToSharp( *it, access, c );
144 } 133
134 if (res == true)
135 access->finishEditCard(&c);
136 else
137 access->cancelEditCard();
138 }
145 } 139 }
146*/ 140
147 delete access; 141 delete access;
148 142
149 return true; 143 return true;
150} 144}
151 145
152KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const 146KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const
153{ 147{
154 KABC::AddresseeList adrlst; 148 KABC::AddresseeList adrlst;
155 149
156 QString fileName = SlZDataBase::addressbookFileName(); 150 QString fileName = SlZDataBase::addressbookFileName();
157 151
152 // the last parameter in the SlZDataBase constructor means "readonly"
158 SlZDataBase* access = new SlZDataBase(fileName, 153 SlZDataBase* access = new SlZDataBase(fileName,
159 SlZDataBase::addressbookItems()); 154 SlZDataBase::addressbookItems(), NULL, true);
155
160 156
161
162 if ( !access ) { 157 if ( !access ) {
163 QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); 158 QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) );
164 qDebug(text.latin1()); 159 qDebug(text.latin1());
@@ -166,8 +161,8 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const
166 KMessageBox::error( parentWidget(), text ); 161 KMessageBox::error( parentWidget(), text );
167 return KABC::AddresseeList(); 162 return KABC::AddresseeList();
168 } 163 }
169/*US 164
170 KABC::QtopiaConverter mConverter; 165 KABC::SharpDTMConverter mConverter;
171 166
172 bool res = mConverter.init(); 167 bool res = mConverter.init();
173 if (!res) 168 if (!res)
@@ -178,29 +173,27 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const
178 delete access; 173 delete access;
179 return KABC::AddresseeList(); 174 return KABC::AddresseeList();
180 } 175 }
181 176
182 177
183 178 { //create a new scope
184 { //create a new scope 179 CardId id;
185 AddressBookIterator it(*access); 180
186 181 for (bool res=access->first(); res == true; res=access->next()) {
187 for (it.toFirst(); it.current(); ++it) { 182 id = access->cardId();
188 const PimContact*contact = it.current(); 183
189
190 KABC::Addressee addressee; 184 KABC::Addressee addressee;
191 185
192 res = mConverter.qtopiaToAddressee( (*contact), addressee ); 186 res = mConverter.sharpToAddressee( id, access, addressee );
193 187
194 if ( !addressee.isEmpty() && res ) 188 if ( !addressee.isEmpty() && res )
195 { 189 {
196 adrlst.append( addressee ); 190 adrlst.append( addressee );
197 } 191 }
198 } 192 }
199 } 193 }
200*/ 194
201
202 delete access; 195 delete access;
203 196
204 return adrlst; 197 return adrlst;
205 198
206} 199}