summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorulf69 <ulf69>2004-08-02 22:35:50 (UTC)
committer ulf69 <ulf69>2004-08-02 22:35:50 (UTC)
commit464ed9d13592965a63b614a1f2902000eb26f1ae (patch) (unidiff)
tree8da5e8fc363ddedff10250553a12758404de0bf9 /kaddressbook
parent5e9c7a34f68d9e41d73ca5c9238d69252a80595f (diff)
downloadkdepimpi-464ed9d13592965a63b614a1f2902000eb26f1ae.zip
kdepimpi-464ed9d13592965a63b614a1f2902000eb26f1ae.tar.gz
kdepimpi-464ed9d13592965a63b614a1f2902000eb26f1ae.tar.bz2
load all export managers statically instead dynamically
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxportmanager.cpp24
1 files changed, 3 insertions, 21 deletions
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp
index a6797c9..713b0fc 100644
--- a/kaddressbook/xxportmanager.cpp
+++ b/kaddressbook/xxportmanager.cpp
@@ -105,157 +105,139 @@ void XXPortManager::importVCard( const KURL &url, bool showPreview )
105void XXPortManager::importVCard( const QString &vCard, bool showPreview ) 105void XXPortManager::importVCard( const QString &vCard, bool showPreview )
106{ 106{
107 importData = vCard; 107 importData = vCard;
108 mShowPreview = showPreview; 108 mShowPreview = showPreview;
109 slotImport( "vcard", "<empty>" ); 109 slotImport( "vcard", "<empty>" );
110 mShowPreview = false; 110 mShowPreview = false;
111 importData = ""; 111 importData = "";
112} 112}
113 113
114void XXPortManager::slotImport( const QString &identifier, const QString &data ) 114void XXPortManager::slotImport( const QString &identifier, const QString &data )
115{ 115{
116 XXPortObject *obj = mXXPortObjects[ identifier ]; 116 XXPortObject *obj = mXXPortObjects[ identifier ];
117 if ( !obj ) { 117 if ( !obj ) {
118 KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); 118 KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) );
119 return; 119 return;
120 } 120 }
121 121
122 KABC::Resource *resource = mCore->requestResource( mCore ); 122 KABC::Resource *resource = mCore->requestResource( mCore );
123 if ( !resource ) 123 if ( !resource )
124 return; 124 return;
125 125
126 KABC::AddresseeList list = obj->importContacts( data ); 126 KABC::AddresseeList list = obj->importContacts( data );
127 KABC::AddresseeList::Iterator it; 127 KABC::AddresseeList::Iterator it;
128 bool imported = false; 128 bool imported = false;
129 for ( it = list.begin(); it != list.end(); ++it ) { 129 for ( it = list.begin(); it != list.end(); ++it ) {
130 if ( mShowPreview ) { 130 if ( mShowPreview ) {
131 PreviewDialog dlg( *it, mCore ); 131 PreviewDialog dlg( *it, mCore );
132 if ( !dlg.exec() ) 132 if ( !dlg.exec() )
133 continue; 133 continue;
134 } 134 }
135 135
136 (*it).setResource( resource ); 136 (*it).setResource( resource );
137 // We use a PwNewCommand so the user can undo it. 137 // We use a PwNewCommand so the user can undo it.
138 PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); 138 PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it );
139 UndoStack::instance()->push( command ); 139 UndoStack::instance()->push( command );
140 RedoStack::instance()->clear(); 140 RedoStack::instance()->clear();
141 imported = true; 141 imported = true;
142 } 142 }
143 143
144 if ( imported ) { 144 if ( imported ) {
145 KMessageBox::information( mCore, i18n( "contacts successfully imported." ) ); 145 KMessageBox::information( mCore, i18n( "contacts successfully imported." ) );
146 146
147 emit modified(); 147 emit modified();
148 } 148 }
149} 149}
150 150
151void XXPortManager::slotExport( const QString &identifier, const QString &data ) 151void XXPortManager::slotExport( const QString &identifier, const QString &data )
152{ 152{
153 XXPortObject *obj = mXXPortObjects[ identifier ]; 153 XXPortObject *obj = mXXPortObjects[ identifier ];
154 if ( !obj ) { 154 if ( !obj ) {
155 KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); 155 KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) );
156 return; 156 return;
157 } 157 }
158 158
159 KABC::AddresseeList addrList; 159 KABC::AddresseeList addrList;
160 XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); 160 XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore );
161 if ( dlg.exec() ) 161 if ( dlg.exec() )
162 addrList = dlg.contacts(); 162 addrList = dlg.contacts();
163 else 163 else
164 return; 164 return;
165 165
166 if ( !obj->exportContacts( addrList, data ) ) 166 if ( !obj->exportContacts( addrList, data ) )
167 KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); 167 KMessageBox::error( mCore, i18n( "Unable to export contacts." ) );
168 else 168 else
169 KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); 169 KMessageBox::information( mCore, i18n( "contacts successfully exported." ) );
170} 170}
171 171
172void XXPortManager::loadPlugins() 172void XXPortManager::loadPlugins()
173{ 173{
174 mXXPortObjects.clear(); 174 mXXPortObjects.clear();
175 175
176#ifndef KAB_EMBEDDED 176#ifndef KAB_EMBEDDED
177 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" ); 177 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" );
178 KTrader::OfferList::ConstIterator it; 178 KTrader::OfferList::ConstIterator it;
179 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 179 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
180 if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) 180 if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) )
181 continue; 181 continue;
182 182
183 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 183 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
184 if ( !factory ) { 184 if ( !factory ) {
185 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; 185 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl;
186 continue; 186 continue;
187 } 187 }
188 188
189 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); 189 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
190 190
191 if ( !xxportFactory ) { 191 if ( !xxportFactory ) {
192 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; 192 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl;
193 continue; 193 continue;
194 } 194 }
195 195
196#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
197 QList<XXPortFactory> factorylist; 197 QList<XXPortFactory> factorylist;
198 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport())); 198 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport()));
199 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport())); 199 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport()));
200 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport())); 200 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport()));
201 201 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport()));
202 //add the opie import library dynamically 202 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport()));
203 KLibFactory *factory = KLibLoader::self()->factory( "microkaddrbk_opie_xxport" ); 203 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport()));
204 if ( factory ) {
205 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
206 factorylist.append(xxportFactory);
207 }
208
209 //add the qtopia import library dynamically
210 factory = KLibLoader::self()->factory( "microkaddrbk_qtopia_xxport" );
211 if ( factory ) {
212 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
213 factorylist.append(xxportFactory);
214 }
215
216 //add the sharp import library dynamically
217 factory = KLibLoader::self()->factory( "microkaddrbk_sharpdtm_xxport" );
218 if ( factory ) {
219 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
220 factorylist.append(xxportFactory);
221 }
222 204
223 QListIterator<XXPortFactory> it(factorylist); 205 QListIterator<XXPortFactory> it(factorylist);
224 for ( ; it.current(); ++it ) 206 for ( ; it.current(); ++it )
225 { 207 {
226 XXPortFactory *xxportFactory = it.current(); 208 XXPortFactory *xxportFactory = it.current();
227#endif //KAB_EMBEDDED 209#endif //KAB_EMBEDDED
228 210
229 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); 211 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore );
230 if ( obj ) { 212 if ( obj ) {
231 mCore->addGUIClient( obj ); 213 mCore->addGUIClient( obj );
232 mXXPortObjects.insert( obj->identifier(), obj ); 214 mXXPortObjects.insert( obj->identifier(), obj );
233 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), 215 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ),
234 this, SLOT( slotExport( const QString&, const QString& ) ) ); 216 this, SLOT( slotExport( const QString&, const QString& ) ) );
235 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), 217 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ),
236 this, SLOT( slotImport( const QString&, const QString& ) ) ); 218 this, SLOT( slotImport( const QString&, const QString& ) ) );
237 } 219 }
238 } 220 }
239} 221}
240 222
241 223
242PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, 224PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent,
243 const char *name ) 225 const char *name )
244 : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent, 226 : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent,
245 name, true, true ) 227 name, true, true )
246{ 228{
247 QWidget *page = plainPage(); 229 QWidget *page = plainPage();
248 QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); 230 QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() );
249 231
250 KPIM::AddresseeView *view = new KPIM::AddresseeView( page ); 232 KPIM::AddresseeView *view = new KPIM::AddresseeView( page );
251 view->setAddressee( addr ); 233 view->setAddressee( addr );
252 234
253 layout->addWidget( view ); 235 layout->addWidget( view );
254 236
255 resize( 400, 300 ); 237 resize( 400, 300 );
256} 238}
257 239
258#ifndef KAB_EMBEDDED 240#ifndef KAB_EMBEDDED
259#include "xxportmanager.moc" 241#include "xxportmanager.moc"
260#endif //KAB_EMBEDDED 242#endif //KAB_EMBEDDED
261 243