-rw-r--r-- | kaddressbook/xxport/opie/opie_xxport.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/xxportmanager.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp index 8ee0725..12c83af 100644 --- a/kaddressbook/xxport/opie/opie_xxport.cpp +++ b/kaddressbook/xxport/opie/opie_xxport.cpp | |||
@@ -26,97 +26,97 @@ Enhanced Version of the file for platform independent KDE tools. | |||
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (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 <opie/ocontactaccessbackend_xml.h> | 37 | #include <opie/ocontactaccessbackend_xml.h> |
38 | 38 | ||
39 | #include "stdaddressbook.h" | 39 | #include "stdaddressbook.h" |
40 | 40 | ||
41 | /*US | 41 | /*US |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
44 | 44 | ||
45 | #include <kabc/vcardconverter.h> | 45 | #include <kabc/vcardconverter.h> |
46 | #ifndef KAB_EMBEDDED | 46 | #ifndef KAB_EMBEDDED |
47 | #include <kio/netaccess.h> | 47 | #include <kio/netaccess.h> |
48 | #endif //KAB_EMBEDDED | 48 | #endif //KAB_EMBEDDED |
49 | 49 | ||
50 | #include <klocale.h> | 50 | #include <klocale.h> |
51 | #include <kmessagebox.h> | 51 | #include <kmessagebox.h> |
52 | #include <ktempfile.h> | 52 | #include <ktempfile.h> |
53 | #include <kurl.h> | 53 | #include <kurl.h> |
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "xxportmanager.h" | 56 | #include "xxportmanager.h" |
57 | #include "opieconverter.h" | 57 | #include "opieconverter.h" |
58 | 58 | ||
59 | #include "opie_xxport.h" | 59 | #include "opie_xxport.h" |
60 | 60 | ||
61 | 61 | ||
62 | class OpieXXPortFactory : public XXPortFactory | 62 | class OpieXXPortFactory : public XXPortFactory |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 65 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
66 | { | 66 | { |
67 | return new OpieXXPort( ab, parent, name ); | 67 | return new OpieXXPort( ab, parent, name ); |
68 | } | 68 | } |
69 | }; | 69 | }; |
70 | 70 | ||
71 | 71 | ||
72 | extern "C" | 72 | extern "C" |
73 | { | 73 | { |
74 | void *init_kaddrbk_opie_xxport() | 74 | void *init_microkaddrbk_opie_xxport() |
75 | { | 75 | { |
76 | return ( new OpieXXPortFactory() ); | 76 | return ( new OpieXXPortFactory() ); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 81 | OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
82 | : XXPortObject( ab, parent, name ) | 82 | : XXPortObject( ab, parent, name ) |
83 | { | 83 | { |
84 | createImportAction( i18n( "Import Opie..." ) ); | 84 | createImportAction( i18n( "Import Opie..." ) ); |
85 | createExportAction( i18n( "Export Opie..." ) ); | 85 | createExportAction( i18n( "Export Opie..." ) ); |
86 | } | 86 | } |
87 | 87 | ||
88 | bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | 88 | bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) |
89 | { | 89 | { |
90 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 90 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
91 | 91 | ||
92 | #ifndef KAB_EMBEDDED | 92 | #ifndef KAB_EMBEDDED |
93 | QString fileName = KFileDialog::getSaveFileName( name ); | 93 | QString fileName = KFileDialog::getSaveFileName( name ); |
94 | #else //KAB_EMBEDDED | 94 | #else //KAB_EMBEDDED |
95 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); | 95 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); |
96 | #endif //KAB_EMBEDDED | 96 | #endif //KAB_EMBEDDED |
97 | 97 | ||
98 | if ( fileName.isEmpty() ) | 98 | if ( fileName.isEmpty() ) |
99 | return true; | 99 | return true; |
100 | 100 | ||
101 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); | 101 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); |
102 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); | 102 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); |
103 | 103 | ||
104 | if ( !access ) { | 104 | if ( !access ) { |
105 | qDebug("Unable to access file() %s", fileName.latin1()); | 105 | qDebug("Unable to access file() %s", fileName.latin1()); |
106 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | 106 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); |
107 | return false; | 107 | return false; |
108 | } | 108 | } |
109 | 109 | ||
110 | KABC::OpieConverter mConverter; | 110 | KABC::OpieConverter mConverter; |
111 | 111 | ||
112 | bool res = mConverter.init(); | 112 | bool res = mConverter.init(); |
113 | if (!res) | 113 | if (!res) |
114 | { | 114 | { |
115 | QString text( i18n( "Unable to initialize opie converter.<br>Most likely a problem with the category file." ) ); | 115 | QString text( i18n( "Unable to initialize opie converter.<br>Most likely a problem with the category file." ) ); |
116 | qDebug(text); | 116 | qDebug(text); |
117 | KMessageBox::error( parentWidget(), text ); | 117 | KMessageBox::error( parentWidget(), text ); |
118 | delete access; | 118 | delete access; |
119 | return false; | 119 | return false; |
120 | } | 120 | } |
121 | 121 | ||
122 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | 122 | //Now check if the file has already entries, and ask the user if he wants to delete them first. |
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 20cde49..248fcab 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp | |||
@@ -152,94 +152,94 @@ void XXPortManager::slotExport( const QString &identifier, const QString &data ) | |||
152 | KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); | 152 | KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); |
153 | return; | 153 | return; |
154 | } | 154 | } |
155 | 155 | ||
156 | KABC::AddresseeList addrList; | 156 | KABC::AddresseeList addrList; |
157 | XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); | 157 | XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); |
158 | if ( dlg.exec() ) | 158 | if ( dlg.exec() ) |
159 | addrList = dlg.contacts(); | 159 | addrList = dlg.contacts(); |
160 | else | 160 | else |
161 | return; | 161 | return; |
162 | 162 | ||
163 | if ( !obj->exportContacts( addrList, data ) ) | 163 | if ( !obj->exportContacts( addrList, data ) ) |
164 | KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); | 164 | KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); |
165 | else | 165 | else |
166 | KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); | 166 | KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); |
167 | } | 167 | } |
168 | 168 | ||
169 | void XXPortManager::loadPlugins() | 169 | void XXPortManager::loadPlugins() |
170 | { | 170 | { |
171 | mXXPortObjects.clear(); | 171 | mXXPortObjects.clear(); |
172 | 172 | ||
173 | #ifndef KAB_EMBEDDED | 173 | #ifndef KAB_EMBEDDED |
174 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" ); | 174 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" ); |
175 | KTrader::OfferList::ConstIterator it; | 175 | KTrader::OfferList::ConstIterator it; |
176 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 176 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
177 | if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) | 177 | if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) |
178 | continue; | 178 | continue; |
179 | 179 | ||
180 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 180 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
181 | if ( !factory ) { | 181 | if ( !factory ) { |
182 | kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; | 182 | kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; |
183 | continue; | 183 | continue; |
184 | } | 184 | } |
185 | 185 | ||
186 | XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); | 186 | XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); |
187 | 187 | ||
188 | if ( !xxportFactory ) { | 188 | if ( !xxportFactory ) { |
189 | kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; | 189 | kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; |
190 | continue; | 190 | continue; |
191 | } | 191 | } |
192 | 192 | ||
193 | #else //KAB_EMBEDDED | 193 | #else //KAB_EMBEDDED |
194 | QList<XXPortFactory> factorylist; | 194 | QList<XXPortFactory> factorylist; |
195 | factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_csv_xxport())); | 195 | factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_csv_xxport())); |
196 | factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_kde2_xxport())); | 196 | factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_kde2_xxport())); |
197 | factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_vcard_xxport())); | 197 | factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_vcard_xxport())); |
198 | 198 | ||
199 | //now add the opie import library dynamically | 199 | //now add the opie import library dynamically |
200 | KLibFactory *factory = KLibLoader::self()->factory( "kaddrbk_opie_xxport" ); | 200 | KLibFactory *factory = KLibLoader::self()->factory( "microkaddrbk_opie_xxport" ); |
201 | if ( factory ) { | 201 | if ( factory ) { |
202 | XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); | 202 | XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); |
203 | factorylist.append(xxportFactory); | 203 | factorylist.append(xxportFactory); |
204 | } | 204 | } |
205 | 205 | ||
206 | QListIterator<XXPortFactory> it(factorylist); | 206 | QListIterator<XXPortFactory> it(factorylist); |
207 | for ( ; it.current(); ++it ) | 207 | for ( ; it.current(); ++it ) |
208 | { | 208 | { |
209 | XXPortFactory *xxportFactory = it.current(); | 209 | XXPortFactory *xxportFactory = it.current(); |
210 | #endif //KAB_EMBEDDED | 210 | #endif //KAB_EMBEDDED |
211 | 211 | ||
212 | XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); | 212 | XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); |
213 | if ( obj ) { | 213 | if ( obj ) { |
214 | mCore->addGUIClient( obj ); | 214 | mCore->addGUIClient( obj ); |
215 | mXXPortObjects.insert( obj->identifier(), obj ); | 215 | mXXPortObjects.insert( obj->identifier(), obj ); |
216 | connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), | 216 | connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), |
217 | this, SLOT( slotExport( const QString&, const QString& ) ) ); | 217 | this, SLOT( slotExport( const QString&, const QString& ) ) ); |
218 | connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), | 218 | connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), |
219 | this, SLOT( slotImport( const QString&, const QString& ) ) ); | 219 | this, SLOT( slotImport( const QString&, const QString& ) ) ); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, | 226 | PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, |
227 | const char *name ) | 227 | const char *name ) |
228 | : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent, | 228 | : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent, |
229 | name, true, true ) | 229 | name, true, true ) |
230 | { | 230 | { |
231 | QWidget *page = plainPage(); | 231 | QWidget *page = plainPage(); |
232 | QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); | 232 | QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); |
233 | 233 | ||
234 | KPIM::AddresseeView *view = new KPIM::AddresseeView( page ); | 234 | KPIM::AddresseeView *view = new KPIM::AddresseeView( page ); |
235 | view->setAddressee( addr ); | 235 | view->setAddressee( addr ); |
236 | 236 | ||
237 | layout->addWidget( view ); | 237 | layout->addWidget( view ); |
238 | 238 | ||
239 | resize( 400, 300 ); | 239 | resize( 400, 300 ); |
240 | } | 240 | } |
241 | 241 | ||
242 | #ifndef KAB_EMBEDDED | 242 | #ifndef KAB_EMBEDDED |
243 | #include "xxportmanager.moc" | 243 | #include "xxportmanager.moc" |
244 | #endif //KAB_EMBEDDED | 244 | #endif //KAB_EMBEDDED |
245 | 245 | ||