author | zautrix <zautrix> | 2004-10-29 11:24:47 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 11:24:47 (UTC) |
commit | 443116d2682cd221c25201926e35d825170bdbbd (patch) (unidiff) | |
tree | 86e8e5965b489cd3d537e9872ff106019476c559 | |
parent | 2d28a226645f56a96fe0a8252e0d7e7b2cc4df2e (diff) | |
download | kdepimpi-443116d2682cd221c25201926e35d825170bdbbd.zip kdepimpi-443116d2682cd221c25201926e35d825170bdbbd.tar.gz kdepimpi-443116d2682cd221c25201926e35d825170bdbbd.tar.bz2 |
fix
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/xxport/qtopia_xxport.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index cf6b11a..79ddaea 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp | |||
@@ -118,97 +118,97 @@ Ticket *ResourceQtopia::requestSaveTicket() | |||
118 | return 0; | 118 | return 0; |
119 | } | 119 | } |
120 | return createTicket( this ); | 120 | return createTicket( this ); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | bool ResourceQtopia::doOpen() | 124 | bool ResourceQtopia::doOpen() |
125 | { | 125 | { |
126 | qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); | 126 | qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); |
127 | 127 | ||
128 | 128 | ||
129 | if (mConverter == 0) | 129 | if (mConverter == 0) |
130 | { | 130 | { |
131 | mConverter = new QtopiaConverter(); | 131 | mConverter = new QtopiaConverter(); |
132 | bool res = mConverter->init(); | 132 | bool res = mConverter->init(); |
133 | if ( !res ) | 133 | if ( !res ) |
134 | { | 134 | { |
135 | QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); | 135 | QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); |
136 | qDebug(msg); | 136 | qDebug(msg); |
137 | return false; | 137 | return false; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | return true; | 141 | return true; |
142 | } | 142 | } |
143 | 143 | ||
144 | void ResourceQtopia::doClose() | 144 | void ResourceQtopia::doClose() |
145 | { | 145 | { |
146 | qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); | 146 | qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); |
147 | 147 | ||
148 | 148 | ||
149 | // it seems so, that deletion of access deletes backend as well | 149 | // it seems so, that deletion of access deletes backend as well |
150 | //delete backend; | 150 | //delete backend; |
151 | 151 | ||
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | 154 | ||
155 | bool ResourceQtopia::load() | 155 | bool ResourceQtopia::load() |
156 | { | 156 | { |
157 | 157 | ||
158 | QFile file( fileName() ); | 158 | QFile file( fileName() ); |
159 | if ( !file.open(IO_ReadOnly ) ) { | 159 | if ( !file.open(IO_ReadOnly ) ) { |
160 | return false; | 160 | return false; |
161 | } | 161 | } |
162 | 162 | ||
163 | QDomDocument doc("mydocument" ); | 163 | QDomDocument doc("mydocument" ); |
164 | if ( !doc.setContent( &file ) ) { | 164 | if ( !doc.setContent( &file ) ) { |
165 | file.close(); | 165 | file.close(); |
166 | return true; | 166 | return false; |
167 | } | 167 | } |
168 | bool res; | 168 | bool res; |
169 | QDomElement docElem = doc.documentElement( ); | 169 | QDomElement docElem = doc.documentElement( ); |
170 | QDomNode n = docElem.firstChild(); | 170 | QDomNode n = docElem.firstChild(); |
171 | while ( !n.isNull() ) { | 171 | while ( !n.isNull() ) { |
172 | QDomElement e = n.toElement(); | 172 | QDomElement e = n.toElement(); |
173 | if ( !e.isNull() ) { | 173 | if ( !e.isNull() ) { |
174 | if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) { | 174 | if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) { |
175 | QDomNode no = e.firstChild(); | 175 | QDomNode no = e.firstChild(); |
176 | while ( !no.isNull() ) { | 176 | while ( !no.isNull() ) { |
177 | QDomElement el = no.toElement(); | 177 | QDomElement el = no.toElement(); |
178 | if ( !el.isNull() ) { | 178 | if ( !el.isNull() ) { |
179 | KABC::Addressee addressee; | 179 | KABC::Addressee addressee; |
180 | res = mConverter->qtopiaToAddressee( el, addressee ); | 180 | res = mConverter->qtopiaToAddressee( el, addressee ); |
181 | if ( !addressee.isEmpty() && res ) | 181 | if ( !addressee.isEmpty() && res ) |
182 | { | 182 | { |
183 | addressee.setResource( this ); | 183 | addressee.setResource( this ); |
184 | addressBook()->insertAddressee( addressee ); | 184 | addressBook()->insertAddressee( addressee ); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | no = no.nextSibling(); | 188 | no = no.nextSibling(); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | n = n.nextSibling(); | 193 | n = n.nextSibling(); |
194 | } | 194 | } |
195 | return true; | 195 | return true; |
196 | } | 196 | } |
197 | 197 | ||
198 | bool ResourceQtopia::save( Ticket *ticket ) | 198 | bool ResourceQtopia::save( Ticket *ticket ) |
199 | { | 199 | { |
200 | #ifdef _USE_DIRWATCH_ | 200 | #ifdef _USE_DIRWATCH_ |
201 | mDirWatch.stopScan(); | 201 | mDirWatch.stopScan(); |
202 | #endif | 202 | #endif |
203 | KABC::AddressBook::Iterator it; | 203 | KABC::AddressBook::Iterator it; |
204 | bool res; | 204 | bool res; |
205 | QFile file( fileName() ); | 205 | QFile file( fileName() ); |
206 | if (!file.open( IO_WriteOnly ) ) { | 206 | if (!file.open( IO_WriteOnly ) ) { |
207 | return false; | 207 | return false; |
208 | } | 208 | } |
209 | QTextStream ts( &file ); | 209 | QTextStream ts( &file ); |
210 | QTextStream *stream = &ts; | 210 | QTextStream *stream = &ts; |
211 | stream->setEncoding( QTextStream::UnicodeUTF8 ); | 211 | stream->setEncoding( QTextStream::UnicodeUTF8 ); |
212 | *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>" << endl; | 212 | *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>" << endl; |
213 | *stream << " <Groups>" << endl; | 213 | *stream << " <Groups>" << endl; |
214 | *stream << " </Groups>" << endl; | 214 | *stream << " </Groups>" << endl; |
diff --git a/kaddressbook/xxport/qtopia_xxport.cpp b/kaddressbook/xxport/qtopia_xxport.cpp index fc4abbb..e3457a1 100644 --- a/kaddressbook/xxport/qtopia_xxport.cpp +++ b/kaddressbook/xxport/qtopia_xxport.cpp | |||
@@ -28,59 +28,59 @@ Copyright (c) 2004 Ulf Schenk | |||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | 32 | ||
33 | #include "addressee.h" | 33 | #include "addressee.h" |
34 | #include "xxportmanager.h" | 34 | #include "xxportmanager.h" |
35 | #include "qtopia_xxport.h" | 35 | #include "qtopia_xxport.h" |
36 | #include <kfiledialog.h> | 36 | #include <kfiledialog.h> |
37 | 37 | ||
38 | /*US | 38 | /*US |
39 | class QtopiaXXPortFactory : public XXPortFactory | 39 | class QtopiaXXPortFactory : public XXPortFactory |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 42 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
43 | { | 43 | { |
44 | return new QtopiaXXPort( ab, parent, name ); | 44 | return new QtopiaXXPort( ab, parent, name ); |
45 | } | 45 | } |
46 | }; | 46 | }; |
47 | */ | 47 | */ |
48 | 48 | ||
49 | extern "C" | 49 | extern "C" |
50 | { | 50 | { |
51 | void *init_microkaddrbk_qtopia_xxport() | 51 | void *init_microkaddrbk_qtopia_xxport() |
52 | { | 52 | { |
53 | return ( new QtopiaXXPortFactory() ); | 53 | return ( new QtopiaXXPortFactory() ); |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | QtopiaXXPort::QtopiaXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 59 | QtopiaXXPort::QtopiaXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
60 | : XXPortResourceObject( ab, parent, name ) | 60 | : XXPortResourceObject( ab, parent, name ) |
61 | { | 61 | { |
62 | defaultFileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 62 | defaultFileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
63 | 63 | ||
64 | if ( mFactory && !mFactory->typeName( "qtopia" ).isEmpty() ) | 64 | if ( mFactory && !mFactory->typeName( "qtopia" ).isEmpty() ) |
65 | { | 65 | { |
66 | createImportAction( i18n( "Import xml (Qtopia)..." ) ); | 66 | createImportAction( i18n( "Import xml (Qtopia)..." ) ); |
67 | createExportAction( i18n( "Export xml (Qtopia)..." ) ); | 67 | createExportAction( i18n( "Export xml (Qtopia)..." ) ); |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | bool QtopiaXXPort::exportContacts( const KABC::AddresseeList &list, const QString &identifier ) | 71 | bool QtopiaXXPort::exportContacts( const KABC::AddresseeList &list, const QString &identifier ) |
72 | { | 72 | { |
73 | QString fn =KFileDialog::getSaveFileName( defaultFileName, i18n("Import xml file"), 0 ); | 73 | QString fn =KFileDialog::getSaveFileName( defaultFileName, i18n("Import xml file"), 0 ); |
74 | if ( fn == "" ) | 74 | if ( fn == "" ) |
75 | return false; | 75 | return false; |
76 | 76 | ||
77 | return _exportContacts( list, identifier, fn ); | 77 | return _exportContacts( list, identifier, fn ); |
78 | } | 78 | } |
79 | 79 | ||
80 | KABC::AddresseeList QtopiaXXPort::importContacts( const QString &identifier ) const | 80 | KABC::AddresseeList QtopiaXXPort::importContacts( const QString &identifier ) const |
81 | { | 81 | { |
82 | QString fn =KFileDialog::getOpenFileName( defaultFileName, i18n("Import xml file"), 0 ); | 82 | QString fn =KFileDialog::getOpenFileName( defaultFileName, i18n("Import xml file"), 0 ); |
83 | if ( fn == "" ) | 83 | if ( fn == "" ) |
84 | return KABC::AddresseeList() ; | 84 | return KABC::AddresseeList() ; |
85 | return _importContacts( identifier, fn ); | 85 | return _importContacts( identifier, fn ); |
86 | } | 86 | } |