summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp26
-rw-r--r--kaddressbook/kabcore.h3
-rw-r--r--kaddressbook/kaddressbook.pro11
-rw-r--r--kaddressbook/kaimportoldialog.cpp635
-rw-r--r--kaddressbook/kaimportoldialog.h85
5 files changed, 757 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7e3fc7c..f4263c4 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -110,6 +110,11 @@
110#include "addresseeconfig.h" 110#include "addresseeconfig.h"
111#include <kcmultidialog.h> 111#include <kcmultidialog.h>
112 112
113#ifdef _WIN32_
114
115#include "kaimportoldialog.h"
116#endif
117
113 118
114#ifdef KAB_EMBEDDED 119#ifdef KAB_EMBEDDED
115KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 120KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
@@ -162,6 +167,8 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
162 "X-Gender", "KADDRESSBOOK" ); 167 "X-Gender", "KADDRESSBOOK" );
163 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 168 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
164 "X-Children", "KADDRESSBOOK" ); 169 "X-Children", "KADDRESSBOOK" );
170 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
171 "X-FreeBusyUrl", "KADDRESSBOOK" );
165 172
166 initGUI(); 173 initGUI();
167 174
@@ -841,6 +848,17 @@ void KABCore::importVCard( const KURL &url, bool showPreview )
841{ 848{
842 mXXPortManager->importVCard( url, showPreview ); 849 mXXPortManager->importVCard( url, showPreview );
843} 850}
851void KABCore::importFromOL()
852{
853#ifdef _WIN32_
854 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
855 idgl->exec();
856 KABC::Addressee::List list = idgl->getAddressList();
857 if ( list.count() > 0 )
858 pasteContacts( list );
859 delete idgl;
860#endif
861}
844 862
845void KABCore::importVCard( const QString &vCard, bool showPreview ) 863void KABCore::importVCard( const QString &vCard, bool showPreview )
846{ 864{
@@ -1397,6 +1415,9 @@ void KABCore::initActions()
1397 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1415 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1398 SLOT( removeVoice() ), actionCollection(), 1416 SLOT( removeVoice() ), actionCollection(),
1399 "remove_voice" ); 1417 "remove_voice" );
1418 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
1419 SLOT( importFromOL() ), actionCollection(),
1420 "import_OL" );
1400#ifdef KAB_EMBEDDED 1421#ifdef KAB_EMBEDDED
1401 1422
1402 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1423 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
@@ -1477,8 +1498,9 @@ void KABCore::addActionsManually()
1477 mActionMailVCard->plug( fileMenu ); 1498 mActionMailVCard->plug( fileMenu );
1478 fileMenu->insertSeparator(); 1499 fileMenu->insertSeparator();
1479 mActionQuit->plug( fileMenu ); 1500 mActionQuit->plug( fileMenu );
1480 1501#ifdef _WIN32_
1481 1502 mActionImportOL->plug( ImportMenu );
1503#endif
1482 // edit menu 1504 // edit menu
1483 mActionUndo->plug( editMenu ); 1505 mActionUndo->plug( editMenu );
1484 mActionRedo->plug( editMenu ); 1506 mActionRedo->plug( editMenu );
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 8d6041e..69a98a5 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -318,7 +318,7 @@ class KABCore : public QWidget
318 void setDetailsToState(); 318 void setDetailsToState();
319 private slots: 319 private slots:
320 void setJumpButtonBarVisible( bool visible ); 320 void setJumpButtonBarVisible( bool visible );
321 321 void importFromOL();
322 void extensionModified( const KABC::Addressee::List &list ); 322 void extensionModified( const KABC::Addressee::List &list );
323 void clipboardDataChanged(); 323 void clipboardDataChanged();
324 void updateActionMenu(); 324 void updateActionMenu();
@@ -408,6 +408,7 @@ class KABCore : public QWidget
408 QPopupMenu *ExportMenu; 408 QPopupMenu *ExportMenu;
409 //LR additional methods 409 //LR additional methods
410 KAction *mActionRemoveVoice; 410 KAction *mActionRemoveVoice;
411 KAction * mActionImportOL;
411 412
412#ifndef KAB_EMBEDDED 413#ifndef KAB_EMBEDDED
413 KAddressBookService *mAddressBookService; 414 KAddressBookService *mAddressBookService;
diff --git a/kaddressbook/kaddressbook.pro b/kaddressbook/kaddressbook.pro
index 761c3e7..bc14e68 100644
--- a/kaddressbook/kaddressbook.pro
+++ b/kaddressbook/kaddressbook.pro
@@ -27,6 +27,7 @@ LIBS += ../bin/microkabc.lib
27QMAKE_LINK += /NODEFAULTLIB:LIBC 27QMAKE_LINK += /NODEFAULTLIB:LIBC
28OBJECTS_DIR = obj/win 28OBJECTS_DIR = obj/win
29MOC_DIR = moc/win 29MOC_DIR = moc/win
30LIBS += mfc71u.lib
30} 31}
31 32
32 33
@@ -164,3 +165,13 @@ xxport/csvimportdialog.cpp \
164# calendarview.cpp \ 165# calendarview.cpp \
165# timespanview.cpp 166# timespanview.cpp
166 167
168
169
170win32: {
171HEADERS += ../outport/msoutl9.h \
172 kaimportoldialog.h
173
174SOURCES += ../outport/msoutl9.cpp \
175 kaimportoldialog.cpp
176}
177
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp
new file mode 100644
index 0000000..5e7d7c4
--- a/dev/null
+++ b/kaddressbook/kaimportoldialog.cpp
@@ -0,0 +1,635 @@
1/*
2 This file is part of KAddressbook/Pi.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@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#include <qtooltip.h>
25#include <qframe.h>
26#include <qpixmap.h>
27#include <qlayout.h>
28#include <qprogressbar.h>
29#include <qwidgetstack.h>
30#include <qdatetime.h>
31#include <qdir.h>
32#include <qapplication.h>
33#include <qhbox.h>
34#include <qheader.h>
35#include <qdatetime.h>
36#include <qlistview.h>
37
38#include <kdebug.h>
39#include <klocale.h>
40#include <kstandarddirs.h>
41#include <kmessagebox.h>
42#include <kfiledialog.h>
43
44#include <libkdepim/categoryselectdialog.h>
45#include <libkdepim/kinputdialog.h>
46
47#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h>
49
50#include <kabc/addresseelist.h>
51#include <kabc/phonenumber.h>
52
53#include "kaimportoldialog.h"
54
55#include "../outport/msoutl9.h"
56#include <ole2.h>
57#include <comutil.h>
58_Application gOlAppAB;
59
60QDateTime mDdate2Qdtr( DATE dt)
61{
62 COleDateTime odt;
63 SYSTEMTIME st;
64 odt = dt;
65 if ( odt.GetStatus() != 0 )
66 return QDateTime();
67 odt.GetAsSystemTime(st);
68 if ( st.wYear > 4000 ) // this program as a year 4000 bug!
69 return QDateTime();
70 // it seems so, that 1.1.4501 indicates: DATE invalid
71 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
72 return qdt;
73}
74
75class OLEListViewItem : public QCheckListItem
76{
77 public:
78 OLEListViewItem( QListView *parent, QString text ) :
79 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; };
80 OLEListViewItem( QListViewItem *after, QString text ) :
81 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; };
82 ~OLEListViewItem() {};
83 void setData( DWORD data ) {mData= data; };
84 DWORD data() { return mData ;};
85 private:
86 DWORD mData;
87};
88
89KAImportOLdialog::KAImportOLdialog( const QString &caption,
90 KABC::AddressBook * aBook, QWidget *parent ) :
91 KDialogBase( Plain, caption, User1 | Close, Ok,
92 parent, caption, true, false, i18n("Import!") )
93{
94 QHBox * mw = new QHBox( this );
95 setMainWidget( mw );
96 mListView = new QListView( mw );
97 mListView->addColumn(i18n("Select Folder to import"));
98 mListView->addColumn(i18n("Content Type"));
99 mABook = aBook;
100 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
101 setupFolderView();
102 resize( sizeHint().width()+50, sizeHint().height()+50 );
103}
104
105KAImportOLdialog::~KAImportOLdialog()
106{
107
108}
109
110KABC::Addressee::List KAImportOLdialog::getAddressList()
111{
112 return mAList;
113}
114void KAImportOLdialog::setupFolderView()
115{
116 SCODE sc = ::OleInitialize(NULL);
117 if ( FAILED ( sc ) ) {
118 KMessageBox::information(this,"OLE initialisation failed");
119 return;
120 }
121
122 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){
123 KMessageBox::information(this,"Sorry, cannot access Outlook");
124 return ;
125 }
126 MAPIFolder mfInbox;
127 MAPIFolder mfRoot;
128 CString szName;
129 _NameSpace olNS;
130 olNS = gOlAppAB.GetNamespace(_T("MAPI"));
131 mfInbox = olNS.GetDefaultFolder(6);
132 mfRoot = mfInbox.GetParent();
133 szName = mfRoot.GetName();
134 long iType = mfRoot.GetDefaultItemType();
135 QString mes;
136 mes = QString::fromUcs2( szName.GetBuffer() );
137 OLEListViewItem * root = new OLEListViewItem( mListView, mes );
138 mfRoot.m_lpDispatch->AddRef();
139 addFolder( root, mfRoot.m_lpDispatch );
140 root->setOpen( true );
141 mListView->setSortColumn( 0 );
142 mListView->sort( );
143}
144
145
146void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent)
147{
148 MAPIFolder mfParent(dispParent), mfChild;
149 _Folders folders;
150 _variant_t fndx((long)0);
151 CString szName;
152 long iType;
153 OLEListViewItem* hChild;
154
155 folders = mfParent.GetFolders();
156 for(int i=1; i <= folders.GetCount(); ++i)
157 {
158 fndx = (long)i;
159 mfChild = folders.Item(fndx.Detach());
160 mfChild.m_lpDispatch->AddRef();
161 szName = mfChild.GetName();
162 iType = mfChild.GetDefaultItemType();
163 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
164 if ( iType != 2)
165 hChild->setEnabled( false );
166 QString ts;
167 switch( iType ) {
168 case 0:
169 ts = i18n("Mail");
170 break;
171 case 1:
172 ts = i18n("Calendar");
173 break;
174 case 2:
175 ts = i18n("Contacts");
176 break;
177 case 3:
178 ts = i18n("Todos");
179 break;
180 case 4:
181 ts = i18n("Journals");
182 break;
183 case 5:
184 ts = i18n("Notes");
185 break;
186 default:
187 ts = i18n("Unknown");
188 }
189 hChild->setText( 1,ts);
190 hChild->setData( (DWORD) mfChild.m_lpDispatch );
191 mfChild.m_lpDispatch->AddRef();
192 addFolder(hChild, mfChild.m_lpDispatch);
193 }
194}
195
196void KAImportOLdialog::slotApply()
197{
198 importedItems = 0;
199 OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
200 while ( child ) {
201 if ( child->isOn() )
202 readContactData( child->data() );
203 child = (OLEListViewItem*) child->itemBelow();
204 }
205 QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems);
206 KMessageBox::information(this,mes);
207}
208void KAImportOLdialog::readContactData( DWORD folder )
209{
210
211 LPDISPATCH dispItem = (LPDISPATCH)folder;
212 dispItem->AddRef();
213 MAPIFolder mf(dispItem);
214 mf.m_lpDispatch->AddRef();
215 _Items folderItems;
216 _variant_t indx((long)0);
217 LPDISPATCH itm;
218 int i;
219 folderItems = mf.GetItems();
220 QProgressBar bar( folderItems.GetCount(),0 );
221 bar.setCaption (i18n("Importing - close to abort!") );
222 int h = bar.sizeHint().height() ;
223 int w = 300;
224 int dw = QApplication::desktop()->width();
225 int dh = QApplication::desktop()->height();
226 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
227 bar.show();
228 for(i=1; i <= folderItems.GetCount(); ++i)
229 {
230 qApp->processEvents();
231 if ( ! bar.isVisible() )
232 return ;
233 bar.setProgress( i );
234 indx = (long)i;
235 itm = folderItems.Item(indx.Detach());
236 _ContactItem * pItem = (_ContactItem *)&itm;
237 ol2kapiContact( pItem );
238 itm->Release();
239 }
240}
241void KAImportOLdialog::slotOk()
242{
243 QDialog::accept();
244}
245
246void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem )
247{
248 KABC::Addressee addressee;
249
250 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
251
252 //addressee.setName( const QString &name );
253 //addressee.setFormattedName( const QString &formattedName );
254 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) );
255 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
256 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
257 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
258 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
259 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
260 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
261 if ( dtb.isValid() )
262 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
263
264 //QString::fromUcs2(aItem->.GetBuffer())
265 //addressee.setMailer( const QString &mailer );
266 //addressee.setTimeZone( const TimeZone &timeZone );
267 //addressee.setGeo( const Geo &geo );
268 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix
269 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );
270 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()) );
271 addressee.setNote( QString::fromUcs2(aItem->GetBody().GetBuffer()) );
272
273 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) );
274 //addressee.setRevision( const QDateTime &revision );
275 // addressee.setSortString( const QString &sortString );
276 addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) );
277
278 QString tempS;
279 tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer());
280 if ( tempS.length() > 12 )
281 addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS );
282 tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer());
283 if ( !tempS.isEmpty() )
284 addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS );
285 tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer());
286 if ( !tempS.isEmpty() )
287 addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS );
288 tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer());
289 if ( !tempS.isEmpty() )
290 addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS );
291 tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer());
292 if ( !tempS.isEmpty() )
293 addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS );
294 tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer());
295 if ( !tempS.isEmpty() )
296 addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS );
297 tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer());
298 if ( !tempS.isEmpty() )
299 addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS );
300 dtb = mDdate2Qdtr(aItem->GetAnniversary());
301 if (dtb.isValid() ) {
302 QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate);
303 addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
304 }
305 int sec = aItem->GetSensitivity() ;
306 if ( sec > 1 )// mapping pers -> private
307 --sec;
308 addressee.setSecrecy( sec );
309 //addressee.setLogo( const Picture &logo );
310 //addressee.setPhoto( const Picture &photo );
311 //addressee.setSound( const Sound &sound );
312 //addressee.setAgent( const Agent &agent );
313 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer());
314 addressee.setCategories( QStringList::split( ";", cat ));
315
316 QString phoneS;
317
318 phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer());
319 if ( ! phoneS.isEmpty())
320 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) );
321 phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer());
322 if ( ! phoneS.isEmpty())
323 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
324 phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer());
325 if ( ! phoneS.isEmpty())
326 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
327 phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer());
328 if ( ! phoneS.isEmpty())
329 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) );
330 phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer());
331 if ( ! phoneS.isEmpty())
332 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) );
333 phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer());
334 if ( ! phoneS.isEmpty())
335 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
336 phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer());
337 if ( ! phoneS.isEmpty())
338 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
339 phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer());
340 if ( ! phoneS.isEmpty())
341 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) );
342 phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer());
343 if ( ! phoneS.isEmpty())
344 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) );
345 phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer());
346 if ( ! phoneS.isEmpty())
347 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) );
348 phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer());
349 if ( ! phoneS.isEmpty())
350 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) );
351 phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer());
352 if ( ! phoneS.isEmpty())
353 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) );
354 phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer());
355 if ( ! phoneS.isEmpty())
356 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) );
357 phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer());
358 if ( ! phoneS.isEmpty())
359 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) );
360 phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer());
361 if ( ! phoneS.isEmpty())
362 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) );
363 phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer());
364 if ( ! phoneS.isEmpty())
365 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) );
366 phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer());
367 if ( ! phoneS.isEmpty())
368 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) );
369 phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer());
370 if ( ! phoneS.isEmpty())
371 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) );
372 phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer());
373 if ( ! phoneS.isEmpty())
374 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) );
375
376 bool preferred = true;
377 phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer());
378 if ( ! phoneS.isEmpty()) {
379 addressee.insertEmail(phoneS , preferred );
380 preferred = false;
381 }
382 phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer());
383 if ( ! phoneS.isEmpty()) {
384 addressee.insertEmail(phoneS , preferred );
385 preferred = false;
386 }
387 phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer());
388 if ( ! phoneS.isEmpty()) {
389 addressee.insertEmail(phoneS , preferred );
390 preferred = false;
391 }
392 // is this the number of the preferred email?
393 //long GetSelectedMailingAddress();???
394
395 KABC::Address addressHome;
396 KABC::Address* addressAdd = &addressHome;
397 bool insert = false;
398 phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer());
399 if ( ! phoneS.isEmpty()) {
400 addressAdd->setCountry(phoneS );
401 insert = true;
402 }
403 phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer());
404 if ( ! phoneS.isEmpty()) {
405 addressAdd->setRegion(phoneS );
406 insert = true;
407 }
408 phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer());
409 if ( ! phoneS.isEmpty()) {
410 addressAdd->setLocality(phoneS );
411 insert = true;
412 }
413 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer());
414 if ( ! phoneS.isEmpty()) {
415 addressAdd->setPostalCode(phoneS );
416 insert = true;
417 }
418 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer());
419 if ( ! phoneS.isEmpty()) {
420 addressAdd->setPostOfficeBox(phoneS );
421 insert = true;
422 }
423 phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer());
424 if ( ! phoneS.isEmpty()) {
425 addressAdd->setStreet(phoneS );
426 insert = true;
427 }
428 phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer());
429 if ( ! phoneS.isEmpty()) {
430 // redundant !addressAdd->setExtended(phoneS );
431 // insert = true;
432 }
433 addressAdd->setType( KABC::Address::Home );
434 if ( insert )
435 addressee.insertAddress( *addressAdd );
436 // ++++++++++++++++++++++ end of address
437
438 KABC::Address addressWork;
439 addressAdd = &addressWork;
440 insert = false;
441 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer());
442 if ( ! phoneS.isEmpty()) {
443 addressAdd->setCountry(phoneS );
444 insert = true;
445 }
446 phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer());
447 if ( ! phoneS.isEmpty()) {
448 addressAdd->setRegion(phoneS );
449 insert = true;
450 }
451 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer());
452 if ( ! phoneS.isEmpty()) {
453 addressAdd->setLocality(phoneS );
454 insert = true;
455 }
456 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer());
457 if ( ! phoneS.isEmpty()) {
458 addressAdd->setPostalCode(phoneS );
459 insert = true;
460 }
461 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer());
462 if ( ! phoneS.isEmpty()) {
463 addressAdd->setPostOfficeBox(phoneS );
464 insert = true;
465 }
466 phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer());
467 if ( ! phoneS.isEmpty()) {
468 addressAdd->setStreet(phoneS );
469 insert = true;
470 }
471 phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer());
472 if ( ! phoneS.isEmpty()) {
473 // redundant !addressAdd->setExtended(phoneS );
474 // insert = true;
475 }
476 addressAdd->setType( KABC::Address::Work );
477 if ( insert )
478 addressee.insertAddress( *addressAdd );
479 // ++++++++++++++++++++++ end of address
480
481 KABC::Address addressOther;
482 addressAdd = &addressOther;
483 insert = false;
484 phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer());
485 if ( ! phoneS.isEmpty()) {
486 addressAdd->setCountry(phoneS );
487 insert = true;
488 }
489 phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer());
490 if ( ! phoneS.isEmpty()) {
491 addressAdd->setRegion(phoneS );
492 insert = true;
493 }
494 phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer());
495 if ( ! phoneS.isEmpty()) {
496 addressAdd->setLocality(phoneS );
497 insert = true;
498 }
499 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer());
500 if ( ! phoneS.isEmpty()) {
501 addressAdd->setPostalCode(phoneS );
502 insert = true;
503 }
504 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer());
505 if ( ! phoneS.isEmpty()) {
506 addressAdd->setPostOfficeBox(phoneS );
507 insert = true;
508 }
509 phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer());
510 if ( ! phoneS.isEmpty()) {
511 addressAdd->setStreet(phoneS );
512 insert = true;
513 }
514 phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer());
515 if ( ! phoneS.isEmpty()) {
516 // redundant !addressAdd->setExtended(phoneS );
517 //insert = true;
518 }
519 //addressAdd->setId( );
520 if ( insert )
521 addressee.insertAddress( *addressAdd );
522 // ++++++++++++++++++++++ end of address
523 KABC::Address addressMail;
524 addressAdd = &addressMail;
525 insert = false;
526 phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer());
527 if ( ! phoneS.isEmpty()) {
528 addressAdd->setCountry(phoneS );
529 insert = true;
530 }
531 phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer());
532 if ( ! phoneS.isEmpty()) {
533 addressAdd->setRegion(phoneS );
534 insert = true;
535 }
536 phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer());
537 if ( ! phoneS.isEmpty()) {
538 addressAdd->setLocality(phoneS );
539 insert = true;
540 }
541 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer());
542 if ( ! phoneS.isEmpty()) {
543 addressAdd->setPostalCode(phoneS );
544 insert = true;
545 }
546 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer());
547 if ( ! phoneS.isEmpty()) {
548 addressAdd->setPostOfficeBox(phoneS );
549 insert = true;
550 }
551 phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer());
552 if ( ! phoneS.isEmpty()) {
553 addressAdd->setStreet(phoneS );
554 insert = true;
555 }
556 phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer());
557 if ( ! phoneS.isEmpty()) {
558 // redundant ! addressAdd->setExtended(phoneS );
559 // insert = true;
560 }
561 addressAdd->setType( KABC::Address::Postal );
562 if ( insert ) {
563 addressee.insertAddress( *addressAdd );
564 }
565 // the following code is disabled
566 // it does not seem to be useful
567#if 0
568 if ( insert ) {
569 addressAdd->setType( KABC::Address::Home );
570 if ( addressMail == addressHome ) {
571 addressHome.setType( KABC::Address::Postal+ KABC::Address::Home );
572 addressee.insertAddress( addressHome );
573 } else {
574 addressAdd->setType( KABC::Address::Work );
575 if ( addressMail == addressWork ){
576 addressWork.setType( KABC::Address::Postal+ KABC::Address::Work );
577 addressee.insertAddress( addressWork );
578
579 } else {
580 addressAdd->setType( 0 );
581 if ( addressOther == addressMail ){
582 addressOther.setType( KABC::Address::Postal );
583 addressee.insertAddress( addressOther );
584 } else {
585 addressee.insertAddress( *addressAdd );
586 }
587 }
588 }
589 }
590#endif
591 // ++++++++++++++++++++++ end of ALL addresses
592 //GetUserProperties();
593 tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer());
594 if ( !tempS.isEmpty() )
595 addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS );
596 tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer());
597 if ( !tempS.isEmpty() )
598 addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS );
599 int gen = aItem->GetGender();
600 if ( gen != 0 ) { // 0 undef - 1 female - 2 male
601 if ( gen == 1 )
602 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
603 else
604 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
605 }
606
607#if 0
608 // pending
609 - IM address: no clue where to get info about the helper ID
610 -custom fields: difficult to implement - not implemented
611 -keys: makes no sense
612#endif
613
614 if ( addAddressee( addressee ))
615 ++importedItems;
616}
617void KAImportOLdialog::slotCancel()
618{
619 reject();
620}
621
622bool KAImportOLdialog::addAddressee( KABC::Addressee a )
623{
624 bool add = true;
625 KABC::Addressee::List::Iterator it;
626 for ( it = mAList.begin(); it != mAList.end(); ++it ) {
627 if ( (*it).uid() == a.uid() ) {
628 add = false;
629 break;
630 }
631 }
632 if ( add )
633 mAList.append ( a );
634 return add;
635}
diff --git a/kaddressbook/kaimportoldialog.h b/kaddressbook/kaimportoldialog.h
new file mode 100644
index 0000000..41ea5f8
--- a/dev/null
+++ b/kaddressbook/kaimportoldialog.h
@@ -0,0 +1,85 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@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#ifndef KOINCIDENCEEDITOR_H
24#define KOINCIDENCEEDITOR_H
25
26#include <kdialogbase.h>
27
28#include <afxdisp.h>
29
30#include <kabc/addressee.h>
31#include <kabc/addressbook.h>
32
33class QDateTime;
34class QListView;
35class OLEListViewItem;
36class _ContactItem;
37
38
39//using namespace KABC;
40//class KABC::AddressBook;
41
42/**
43 This is the base class for the calendar component editors.
44*/
45class KAImportOLdialog : public KDialogBase
46{
47 Q_OBJECT
48 public:
49 /**
50 Construct new IncidenceEditor.
51 */
52 KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook,
53 QWidget *parent );
54 ~KAImportOLdialog();
55
56 /** Initialize editor. This function creates the tab widgets. */
57 void init();
58 KABC::Addressee::List getAddressList();
59 public slots:
60
61
62 signals:
63
64 protected slots:
65 void slotApply();
66 void slotOk();
67 void slotCancel();
68
69 protected:
70 void setupFolderView();
71 void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent);
72 void readContactData( DWORD folder );
73 void ol2kapiContact( _ContactItem * );
74
75 KABC::AddressBook * mABook;
76 QListView * mListView;
77 KABC::Addressee::List mAList;
78 bool addAddressee( KABC::Addressee a );
79 private:
80 int importedItems;
81};
82
83#endif
84
85