summaryrefslogtreecommitdiffabout
path: root/libkdepim/ol_access.cpp
Unidiff
Diffstat (limited to 'libkdepim/ol_access.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-xlibkdepim/ol_access.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/libkdepim/ol_access.cpp b/libkdepim/ol_access.cpp
index 1b05693..821f148 100755
--- a/libkdepim/ol_access.cpp
+++ b/libkdepim/ol_access.cpp
@@ -1,368 +1,368 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2006 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2006 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 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 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 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 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. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qframe.h> 25#include <q3frame.h>
26#include <qpixmap.h> 26#include <qpixmap.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qprogressbar.h> 28#include <q3progressbar.h>
29#include <qprogressdialog.h> 29#include <q3progressdialog.h>
30#include <qwidgetstack.h> 30#include <q3widgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qregexp.h> 34#include <qregexp.h>
35#include <qapplication.h> 35#include <qapplication.h>
36#include <qhbox.h> 36#include <q3hbox.h>
37#include <qheader.h> 37#include <q3header.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qlistview.h> 39#include <q3listview.h>
40 40
41#include <kdebug.h> 41#include <kdebug.h>
42#include <klocale.h> 42#include <klocale.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kmessagebox.h> 44#include <kmessagebox.h>
45#include <kfiledialog.h> 45#include <kfiledialog.h>
46#include <kstaticdeleter.h> 46#include <kstaticdeleter.h>
47#include <kdialogbase.h> 47#include <kdialogbase.h>
48 48
49 49
50#include <ol_access.h> 50#include <ol_access.h>
51 51
52#include "../outport/msoutl9.h" 52#include "../outport/msoutl9.h"
53#include <ole2.h> 53#include <ole2.h>
54#include <comutil.h> 54#include <comutil.h>
55 55
56 56
57class OLEListViewItem : public QCheckListItem 57class OLEListViewItem : public Q3CheckListItem
58{ 58{
59public: 59public:
60 OLEListViewItem( QListView *parent, QString text ) : 60 OLEListViewItem( Q3ListView *parent, QString text ) :
61 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; 61 Q3CheckListItem( parent, text, Q3CheckListItem::CheckBox ) { ; };
62 OLEListViewItem( QListViewItem *after, QString text ) : 62 OLEListViewItem( Q3ListViewItem *after, QString text ) :
63 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; 63 Q3CheckListItem( after, text, Q3CheckListItem::CheckBox ) { ; };
64 ~OLEListViewItem() {}; 64 ~OLEListViewItem() {};
65 void setData( DWORD data ) {mData= data; }; 65 void setData( DWORD data ) {mData= data; };
66 void setDataID( QString data ){ mDataID = data ;} 66 void setDataID( QString data ){ mDataID = data ;}
67 QString dataID() { return mDataID;} 67 QString dataID() { return mDataID;}
68 DWORD data() { return mData ;}; 68 DWORD data() { return mData ;};
69private: 69private:
70 DWORD mData; 70 DWORD mData;
71 QString mDataID; 71 QString mDataID;
72}; 72};
73 73
74class OLEFolderSelect : public KDialogBase 74class OLEFolderSelect : public KDialogBase
75{ 75{
76 public: 76 public:
77 OLEFolderSelect() : 77 OLEFolderSelect() :
78 KDialogBase( Plain, "", Ok | Cancel, Ok, 78 KDialogBase( Plain, "", Ok | Cancel, Ok,
79 0, "", true, false, i18n("Import!") ) 79 0, "", true, false, i18n("Import!") )
80 { 80 {
81 QHBox * mw = new QHBox( this ); 81 Q3HBox * mw = new Q3HBox( this );
82 setMainWidget( mw ); 82 setMainWidget( mw );
83 mListView = new QListView( mw ); 83 mListView = new Q3ListView( mw );
84 mListView->addColumn(i18n("Select Folder")); 84 mListView->addColumn(i18n("Select Folder"));
85 mListView->addColumn(i18n("Content Type")); 85 mListView->addColumn(i18n("Content Type"));
86 } 86 }
87 QListView* listView() { return mListView;} 87 Q3ListView* listView() { return mListView;}
88private: 88private:
89 QListView* mListView; 89 Q3ListView* mListView;
90}; 90};
91 91
92OL_access *OL_access::sInstance = 0; 92OL_access *OL_access::sInstance = 0;
93static KStaticDeleter<OL_access> staticDeleterPim; 93static KStaticDeleter<OL_access> staticDeleterPim;
94 94
95OL_access *OL_access::instance() 95OL_access *OL_access::instance()
96{ 96{
97 if ( !sInstance ) { 97 if ( !sInstance ) {
98 sInstance = staticDeleterPim.setObject( new OL_access() ); 98 sInstance = staticDeleterPim.setObject( new OL_access() );
99 } 99 }
100 return sInstance; 100 return sInstance;
101} 101}
102 102
103 103
104OL_access::OL_access() 104OL_access::OL_access()
105{ 105{
106 mErrorInit = true; 106 mErrorInit = true;
107 SCODE sc = ::OleInitialize(NULL); 107 SCODE sc = ::OleInitialize(NULL);
108 if ( FAILED ( sc ) ) { 108 if ( FAILED ( sc ) ) {
109 KMessageBox::information( 0 ,i18n("OLE initialisation failed" )); 109 KMessageBox::information( 0 ,i18n("OLE initialisation failed" ));
110 return; 110 return;
111 } 111 }
112 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ 112 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){
113 KMessageBox::information( 0, i18n("Sorry, cannot access Outlook") ); 113 KMessageBox::information( 0, i18n("Sorry, cannot access Outlook") );
114 return ; 114 return ;
115 } 115 }
116 mErrorInit = false; 116 mErrorInit = false;
117} 117}
118OL_access::~OL_access() 118OL_access::~OL_access()
119{ 119{
120 if (sInstance == this) 120 if (sInstance == this)
121 sInstance = staticDeleterPim.setObject(0); 121 sInstance = staticDeleterPim.setObject(0);
122} 122}
123 123
124KABC::Addressee::List OL_access::importOLcontacts() 124KABC::Addressee::List OL_access::importOLcontacts()
125{ 125{
126 KABC::Addressee::List retval; 126 KABC::Addressee::List retval;
127 if ( mErrorInit ) 127 if ( mErrorInit )
128 return retval; 128 return retval;
129 QStringList folderList = getFolderSelection( OL_CONTACT_DATA , i18n("Select Folders to import")); 129 QStringList folderList = getFolderSelection( OL_CONTACT_DATA , i18n("Select Folders to import"));
130 int numFolders = folderList.count()/2; 130 int numFolders = folderList.count()/2;
131 int i; 131 int i;
132 for ( i = 0; i < numFolders; ++i ) { 132 for ( i = 0; i < numFolders; ++i ) {
133 readContactData( getFolderFromID( 0, folderList[(i*2)+1] ) , &retval, false ); 133 readContactData( getFolderFromID( 0, folderList[(i*2)+1] ) , &retval, false );
134 } 134 }
135 KMessageBox::information( 0, i18n("%1 contacts read").arg( retval.count() ) ); 135 KMessageBox::information( 0, i18n("%1 contacts read").arg( retval.count() ) );
136 return retval; 136 return retval;
137} 137}
138void OL_access::readContactData( LPDISPATCH dispItem, KABC::Addressee::List* list, bool syncMode ) 138void OL_access::readContactData( LPDISPATCH dispItem, KABC::Addressee::List* list, bool syncMode )
139{ 139{
140 dispItem->AddRef(); 140 dispItem->AddRef();
141 MAPIFolder mf(dispItem); 141 MAPIFolder mf(dispItem);
142 mf.m_lpDispatch->AddRef(); 142 mf.m_lpDispatch->AddRef();
143 _Items folderItems; 143 _Items folderItems;
144 _variant_t indx((long)0); 144 _variant_t indx((long)0);
145 LPDISPATCH itm; 145 LPDISPATCH itm;
146 int i; 146 int i;
147 folderItems = mf.GetItems(); 147 folderItems = mf.GetItems();
148 QString cap = i18n("Importing contact data"); 148 QString cap = i18n("Importing contact data");
149 if ( syncMode ) { 149 if ( syncMode ) {
150 cap = i18n("Reading contact data..."); 150 cap = i18n("Reading contact data...");
151 } 151 }
152 QProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(), 0 ); 152 Q3ProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(), 0 );
153 bar.setCaption (i18n("Accessing OL") ); 153 bar.setCaption (i18n("Accessing OL") );
154 int h = bar.sizeHint().height() ; 154 int h = bar.sizeHint().height() ;
155 int w = 300; 155 int w = 300;
156 int dw = QApplication::desktop()->width(); 156 int dw = QApplication::desktop()->width();
157 int dh = QApplication::desktop()->height(); 157 int dh = QApplication::desktop()->height();
158 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 158 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
159 bar.show(); 159 bar.show();
160 for(i=1; i <= folderItems.GetCount(); ++i) 160 for(i=1; i <= folderItems.GetCount(); ++i)
161 { 161 {
162 qApp->processEvents(); 162 qApp->processEvents();
163 if ( ! bar.isVisible() ) 163 if ( ! bar.isVisible() )
164 return ; 164 return ;
165 bar.setProgress( i ); 165 bar.setProgress( i );
166 indx = (long)i; 166 indx = (long)i;
167 itm = folderItems.Item(indx.Detach()); 167 itm = folderItems.Item(indx.Detach());
168 _ContactItem * pItem = (_ContactItem *)&itm; 168 _ContactItem * pItem = (_ContactItem *)&itm;
169 list->append( ol2kapiContact( pItem, syncMode ) ); 169 list->append( ol2kapiContact( pItem, syncMode ) );
170 itm->Release(); 170 itm->Release();
171 } 171 }
172} 172}
173QStringList OL_access::getFolderSelection( int type , QString caption ) 173QStringList OL_access::getFolderSelection( int type , QString caption )
174{ 174{
175 OLEFolderSelect folder_dialog; 175 OLEFolderSelect folder_dialog;
176 QListView * listView = folder_dialog.listView(); 176 Q3ListView * listView = folder_dialog.listView();
177 MAPIFolder mfInbox; 177 MAPIFolder mfInbox;
178 MAPIFolder mfRoot; 178 MAPIFolder mfRoot;
179 CString szName; 179 CString szName;
180 _NameSpace olNS; 180 _NameSpace olNS;
181 olNS = gOlAppAB.GetNamespace(_T("MAPI")); 181 olNS = gOlAppAB.GetNamespace(_T("MAPI"));
182 mfInbox = olNS.GetDefaultFolder(6); 182 mfInbox = olNS.GetDefaultFolder(6);
183 mfRoot = mfInbox.GetParent(); 183 mfRoot = mfInbox.GetParent();
184 szName = mfRoot.GetName(); 184 szName = mfRoot.GetName();
185 long iType = mfRoot.GetDefaultItemType(); 185 long iType = mfRoot.GetDefaultItemType();
186 QString mes; 186 QString mes;
187 mes = QString::fromUcs2( szName.GetBuffer() ); 187 mes = QString::fromUcs2( szName.GetBuffer() );
188 OLEListViewItem * root = new OLEListViewItem( listView, mes ); 188 OLEListViewItem * root = new OLEListViewItem( listView, mes );
189 mfRoot.m_lpDispatch->AddRef(); 189 mfRoot.m_lpDispatch->AddRef();
190 addFolder( root, mfRoot.m_lpDispatch, type ); 190 addFolder( root, mfRoot.m_lpDispatch, type );
191 root->setOpen( true ); 191 root->setOpen( true );
192 listView->setSortColumn( 0 ); 192 listView->setSortColumn( 0 );
193 listView->sort( ); 193 listView->sort( );
194 folder_dialog.setCaption( caption ); 194 folder_dialog.setCaption( caption );
195 QStringList retval; 195 QStringList retval;
196 folder_dialog.resize( folder_dialog.sizeHint().width()+50, folder_dialog.sizeHint().height()+50 ); 196 folder_dialog.resize( folder_dialog.sizeHint().width()+50, folder_dialog.sizeHint().height()+50 );
197 if ( folder_dialog.exec() ) { 197 if ( folder_dialog.exec() ) {
198 OLEListViewItem* child = (OLEListViewItem*) listView->firstChild(); 198 OLEListViewItem* child = (OLEListViewItem*) listView->firstChild();
199 while ( child ) { 199 while ( child ) {
200 if ( child->isOn() && ! child->firstChild() ) { 200 if ( child->isOn() && ! child->firstChild() ) {
201 retval << child->text( 0 ); 201 retval << child->text( 0 );
202 retval << child->dataID(); 202 retval << child->dataID();
203 } 203 }
204 child = (OLEListViewItem*) child->itemBelow(); 204 child = (OLEListViewItem*) child->itemBelow();
205 } 205 }
206 //KMessageBox::information(0,retval.join(" \n ")); 206 //KMessageBox::information(0,retval.join(" \n "));
207 } 207 }
208 return retval; 208 return retval;
209} 209}
210void OL_access::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent, long fType) 210void OL_access::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent, long fType)
211{ 211{
212 MAPIFolder mfParent(dispParent), mfChild; 212 MAPIFolder mfParent(dispParent), mfChild;
213 _Folders folders; 213 _Folders folders;
214 _variant_t fndx((long)0); 214 _variant_t fndx((long)0);
215 CString szName; 215 CString szName;
216 long iType; 216 long iType;
217 OLEListViewItem* hChild; 217 OLEListViewItem* hChild;
218 218
219 folders = mfParent.GetFolders(); 219 folders = mfParent.GetFolders();
220 for(int i=1; i <= folders.GetCount(); ++i) 220 for(int i=1; i <= folders.GetCount(); ++i)
221 { 221 {
222 iParent->setEnabled( true ); 222 iParent->setEnabled( true );
223 fndx = (long)i; 223 fndx = (long)i;
224 mfChild = folders.Item(fndx.Detach()); 224 mfChild = folders.Item(fndx.Detach());
225 mfChild.m_lpDispatch->AddRef(); 225 mfChild.m_lpDispatch->AddRef();
226 szName = mfChild.GetName(); 226 szName = mfChild.GetName();
227 iType = mfChild.GetDefaultItemType(); 227 iType = mfChild.GetDefaultItemType();
228 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); 228 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
229 hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) ); 229 hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) );
230 if ( iType != fType) 230 if ( iType != fType)
231 hChild->setEnabled( false ); 231 hChild->setEnabled( false );
232 QString ts; 232 QString ts;
233 switch( iType ) { 233 switch( iType ) {
234 case 0: 234 case 0:
235 ts = i18n("Mail"); 235 ts = i18n("Mail");
236 break; 236 break;
237 case 1: 237 case 1:
238 ts = i18n("Calendar"); 238 ts = i18n("Calendar");
239 break; 239 break;
240 case 2: 240 case 2:
241 ts = i18n("Contacts"); 241 ts = i18n("Contacts");
242 break; 242 break;
243 case 3: 243 case 3:
244 ts = i18n("Todos"); 244 ts = i18n("Todos");
245 break; 245 break;
246 case 4: 246 case 4:
247 ts = i18n("Journals"); 247 ts = i18n("Journals");
248 break; 248 break;
249 case 5: 249 case 5:
250 ts = i18n("Notes"); 250 ts = i18n("Notes");
251 break; 251 break;
252 default: 252 default:
253 ts = i18n("Unknown"); 253 ts = i18n("Unknown");
254 } 254 }
255 hChild->setText( 1,ts); 255 hChild->setText( 1,ts);
256 hChild->setData( (DWORD) mfChild.m_lpDispatch ); 256 hChild->setData( (DWORD) mfChild.m_lpDispatch );
257 mfChild.m_lpDispatch->AddRef(); 257 mfChild.m_lpDispatch->AddRef();
258 addFolder(hChild, mfChild.m_lpDispatch, fType); 258 addFolder(hChild, mfChild.m_lpDispatch, fType);
259 } 259 }
260} 260}
261 261
262void OL_access::deleteAddressee( KABC::Addressee a ) 262void OL_access::deleteAddressee( KABC::Addressee a )
263{ 263{
264 LPDISPATCH itm = getOLcontactItemFromUid ( a.originalExternalUID() ); 264 LPDISPATCH itm = getOLcontactItemFromUid ( a.originalExternalUID() );
265 _ContactItem* cItem = (_ContactItem *)&itm; 265 _ContactItem* cItem = (_ContactItem *)&itm;
266 if ( cItem != 0 ) { 266 if ( cItem != 0 ) {
267 //KMessageBox::information(0,"delete: item found " + a.formattedName() + QString::fromUcs2(cItem->GetLastName().GetBuffer())); 267 //KMessageBox::information(0,"delete: item found " + a.formattedName() + QString::fromUcs2(cItem->GetLastName().GetBuffer()));
268 cItem->Delete(); 268 cItem->Delete();
269 } 269 }
270} 270}
271KABC::Addressee OL_access::changeAddressee( KABC::Addressee a ) 271KABC::Addressee OL_access::changeAddressee( KABC::Addressee a )
272{ 272{
273 LPDISPATCH itm = getOLcontactItemFromUid ( a.originalExternalUID() ); 273 LPDISPATCH itm = getOLcontactItemFromUid ( a.originalExternalUID() );
274 _ContactItem* cItem = (_ContactItem *)&itm; 274 _ContactItem* cItem = (_ContactItem *)&itm;
275 if ( cItem != 0 ) { 275 if ( cItem != 0 ) {
276 //KMessageBox::information(0,"Change: item found " + a.formattedName()); 276 //KMessageBox::information(0,"Change: item found " + a.formattedName());
277 writeData2OLitem( a, cItem ); 277 writeData2OLitem( a, cItem );
278 KABC::Addressee retval = ol2kapiContact( cItem , true ); 278 KABC::Addressee retval = ol2kapiContact( cItem , true );
279 retval.setUid( a.uid() ); 279 retval.setUid( a.uid() );
280 retval.setExternalUID( a.originalExternalUID() ); 280 retval.setExternalUID( a.originalExternalUID() );
281 retval.setOriginalExternalUID( a.originalExternalUID() ); 281 retval.setOriginalExternalUID( a.originalExternalUID() );
282 return retval; 282 return retval;
283 } 283 }
284 return KABC::Addressee(); 284 return KABC::Addressee();
285} 285}
286KABC::Addressee OL_access::addAddressee( KABC::Addressee a ) 286KABC::Addressee OL_access::addAddressee( KABC::Addressee a )
287{ 287{
288 QString newOLid; 288 QString newOLid;
289 LPDISPATCH c_itm = gOlAppAB.CreateItem(2); 289 LPDISPATCH c_itm = gOlAppAB.CreateItem(2);
290 _ContactItem * aItem = (_ContactItem *)&c_itm ; 290 _ContactItem * aItem = (_ContactItem *)&c_itm ;
291 writeData2OLitem( a, aItem ); 291 writeData2OLitem( a, aItem );
292 newOLid = QString::fromUcs2(aItem->GetEntryID().GetBuffer()); 292 newOLid = QString::fromUcs2(aItem->GetEntryID().GetBuffer());
293 KABC::Addressee retval = ol2kapiContact( aItem , true ); 293 KABC::Addressee retval = ol2kapiContact( aItem , true );
294 retval.setUid( a.uid() ); 294 retval.setUid( a.uid() );
295 retval.setExternalUID( newOLid ); 295 retval.setExternalUID( newOLid );
296 retval.setOriginalExternalUID( newOLid ); 296 retval.setOriginalExternalUID( newOLid );
297 return retval; 297 return retval;
298} 298}
299 299
300LPDISPATCH OL_access::getOLcontactItemFromUid( QString uid ) 300LPDISPATCH OL_access::getOLcontactItemFromUid( QString uid )
301{ 301{
302 _variant_t indx((long)0); 302 _variant_t indx((long)0);
303 LPDISPATCH itm; 303 LPDISPATCH itm;
304 int i; 304 int i;
305 for(i=1; i <= mFolderItems.GetCount(); ++i) 305 for(i=1; i <= mFolderItems.GetCount(); ++i)
306 { 306 {
307 qApp->processEvents(); 307 qApp->processEvents();
308 indx = (long)i; 308 indx = (long)i;
309 itm = mFolderItems.Item(indx.Detach()); 309 itm = mFolderItems.Item(indx.Detach());
310 _ContactItem * pItem = (_ContactItem *)&itm; 310 _ContactItem * pItem = (_ContactItem *)&itm;
311 if ( QString::fromUcs2(pItem->GetEntryID().GetBuffer()) == uid ) 311 if ( QString::fromUcs2(pItem->GetEntryID().GetBuffer()) == uid )
312 return itm; 312 return itm;
313 itm->Release(); 313 itm->Release();
314 } 314 }
315 return 0; 315 return 0;
316} 316}
317bool OL_access::setSelectedFolder( QString folderID ) 317bool OL_access::setSelectedFolder( QString folderID )
318{ 318{
319 if ( mErrorInit ) 319 if ( mErrorInit )
320 return false; 320 return false;
321 mSelectedFolderID = folderID; 321 mSelectedFolderID = folderID;
322 mSelectedFolder = getFolderFromID( 0,mSelectedFolderID ); 322 mSelectedFolder = getFolderFromID( 0,mSelectedFolderID );
323 if ( mSelectedFolder == 0 ) { 323 if ( mSelectedFolder == 0 ) {
324 KMessageBox::information(0,i18n("OL access: No folder found for id\n%1").arg( mSelectedFolderID )); 324 KMessageBox::information(0,i18n("OL access: No folder found for id\n%1").arg( mSelectedFolderID ));
325 return false; 325 return false;
326 } 326 }
327 LPDISPATCH dispItem = mSelectedFolder; 327 LPDISPATCH dispItem = mSelectedFolder;
328 dispItem->AddRef(); 328 dispItem->AddRef();
329 MAPIFolder mf(dispItem); 329 MAPIFolder mf(dispItem);
330 mf.m_lpDispatch->AddRef(); 330 mf.m_lpDispatch->AddRef();
331 mFolderItems = mf.GetItems(); 331 mFolderItems = mf.GetItems();
332 return true; 332 return true;
333} 333}
334 334
335QDateTime OL_access::mDdate2Qdtr( DATE dt) 335QDateTime OL_access::mDdate2Qdtr( DATE dt)
336{ 336{
337 COleDateTime odt; 337 COleDateTime odt;
338 SYSTEMTIME st; 338 SYSTEMTIME st;
339 odt = dt; 339 odt = dt;
340 if ( odt.GetStatus() != 0 ) 340 if ( odt.GetStatus() != 0 )
341 return QDateTime(); 341 return QDateTime();
342 odt.GetAsSystemTime(st); 342 odt.GetAsSystemTime(st);
343 if ( st.wYear > 4000 ) // this program as a year 4000 bug! 343 if ( st.wYear > 4000 ) // this program as a year 4000 bug!
344 return QDateTime(); 344 return QDateTime();
345 // it seems so, that 1.1.4501 indicates: DATE invalid 345 // it seems so, that 1.1.4501 indicates: DATE invalid
346 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); 346 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
347 return qdt; 347 return qdt;
348} 348}
349DATE OL_access::Qdt2date( QDateTime dt ) 349DATE OL_access::Qdt2date( QDateTime dt )
350{ 350{
351 DATE ddd; 351 DATE ddd;
352 COleDateTime odt; 352 COleDateTime odt;
353 odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(), 353 odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(),
354 dt.time().hour(), dt.time().minute(), dt.time().second() ); 354 dt.time().hour(), dt.time().minute(), dt.time().second() );
355 ddd = odt; 355 ddd = odt;
356 return ddd; 356 return ddd;
357} 357}
358 358
359LPDISPATCH OL_access::getFolderFromID( LPDISPATCH parentFolder, QString selectedFolderID ) 359LPDISPATCH OL_access::getFolderFromID( LPDISPATCH parentFolder, QString selectedFolderID )
360{ 360{
361 if ( parentFolder == 0 ) { 361 if ( parentFolder == 0 ) {
362 MAPIFolder mfInbox; 362 MAPIFolder mfInbox;
363 MAPIFolder mfRoot; 363 MAPIFolder mfRoot;
364 CString szName; 364 CString szName;
365 _NameSpace olNS; 365 _NameSpace olNS;
366 olNS = gOlAppAB.GetNamespace(_T("MAPI")); 366 olNS = gOlAppAB.GetNamespace(_T("MAPI"));
367 mfInbox = olNS.GetDefaultFolder(6); 367 mfInbox = olNS.GetDefaultFolder(6);
368 mfRoot = mfInbox.GetParent(); 368 mfRoot = mfInbox.GetParent();
@@ -946,553 +946,553 @@ KABC::Addressee OL_access::ol2kapiContact( _ContactItem * aItem , bool syncMode)
946 KABC::Address addressMail; 946 KABC::Address addressMail;
947 addressAdd = &addressMail; 947 addressAdd = &addressMail;
948 insert = false; 948 insert = false;
949 phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer()); 949 phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer());
950 phoneS.replace( QRegExp("\\r"), ""); 950 phoneS.replace( QRegExp("\\r"), "");
951 if ( ! phoneS.isEmpty()) { 951 if ( ! phoneS.isEmpty()) {
952 addressAdd->setCountry(phoneS ); 952 addressAdd->setCountry(phoneS );
953 insert = true; 953 insert = true;
954 } 954 }
955 phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer()); 955 phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer());
956 phoneS.replace( QRegExp("\\r"), ""); 956 phoneS.replace( QRegExp("\\r"), "");
957 if ( ! phoneS.isEmpty()) { 957 if ( ! phoneS.isEmpty()) {
958 addressAdd->setRegion(phoneS ); 958 addressAdd->setRegion(phoneS );
959 insert = true; 959 insert = true;
960 } 960 }
961 phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer()); 961 phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer());
962 phoneS.replace( QRegExp("\\r"), ""); 962 phoneS.replace( QRegExp("\\r"), "");
963 if ( ! phoneS.isEmpty()) { 963 if ( ! phoneS.isEmpty()) {
964 addressAdd->setLocality(phoneS ); 964 addressAdd->setLocality(phoneS );
965 insert = true; 965 insert = true;
966 } 966 }
967 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer()); 967 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer());
968 phoneS.replace( QRegExp("\\r"), ""); 968 phoneS.replace( QRegExp("\\r"), "");
969 if ( ! phoneS.isEmpty()) { 969 if ( ! phoneS.isEmpty()) {
970 addressAdd->setPostalCode(phoneS ); 970 addressAdd->setPostalCode(phoneS );
971 insert = true; 971 insert = true;
972 } 972 }
973 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer()); 973 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer());
974 phoneS.replace( QRegExp("\\r"), ""); 974 phoneS.replace( QRegExp("\\r"), "");
975 if ( ! phoneS.isEmpty()) { 975 if ( ! phoneS.isEmpty()) {
976 addressAdd->setPostOfficeBox(phoneS ); 976 addressAdd->setPostOfficeBox(phoneS );
977 insert = true; 977 insert = true;
978 } 978 }
979 phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer()); 979 phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer());
980 phoneS.replace( QRegExp("\\r"), ""); 980 phoneS.replace( QRegExp("\\r"), "");
981 if ( ! phoneS.isEmpty()) { 981 if ( ! phoneS.isEmpty()) {
982 addressAdd->setStreet(phoneS ); 982 addressAdd->setStreet(phoneS );
983 insert = true; 983 insert = true;
984 } 984 }
985 phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer()); 985 phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer());
986 phoneS.replace( QRegExp("\\r"), ""); 986 phoneS.replace( QRegExp("\\r"), "");
987 if ( ! phoneS.isEmpty()) { 987 if ( ! phoneS.isEmpty()) {
988 // redundant ! addressAdd->setExtended(phoneS ); 988 // redundant ! addressAdd->setExtended(phoneS );
989 // insert = true; 989 // insert = true;
990 } 990 }
991 addressAdd->setType( KABC::Address::Postal ); 991 addressAdd->setType( KABC::Address::Postal );
992 if ( insert ) { 992 if ( insert ) {
993 addressee.insertAddress( *addressAdd ); 993 addressee.insertAddress( *addressAdd );
994 } 994 }
995#endif 995#endif
996 // the following code is disabled 996 // the following code is disabled
997 // it does not seem to be useful 997 // it does not seem to be useful
998#if 0 998#if 0
999 if ( insert ) { 999 if ( insert ) {
1000 addressAdd->setType( KABC::Address::Home ); 1000 addressAdd->setType( KABC::Address::Home );
1001 if ( addressMail == addressHome ) { 1001 if ( addressMail == addressHome ) {
1002 addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); 1002 addressHome.setType( KABC::Address::Postal+ KABC::Address::Home );
1003 addressee.insertAddress( addressHome ); 1003 addressee.insertAddress( addressHome );
1004 } else { 1004 } else {
1005 addressAdd->setType( KABC::Address::Work ); 1005 addressAdd->setType( KABC::Address::Work );
1006 if ( addressMail == addressWork ){ 1006 if ( addressMail == addressWork ){
1007 addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); 1007 addressWork.setType( KABC::Address::Postal+ KABC::Address::Work );
1008 addressee.insertAddress( addressWork ); 1008 addressee.insertAddress( addressWork );
1009 1009
1010 } else { 1010 } else {
1011 addressAdd->setType( 0 ); 1011 addressAdd->setType( 0 );
1012 if ( addressOther == addressMail ){ 1012 if ( addressOther == addressMail ){
1013 addressOther.setType( KABC::Address::Postal ); 1013 addressOther.setType( KABC::Address::Postal );
1014 addressee.insertAddress( addressOther ); 1014 addressee.insertAddress( addressOther );
1015 } else { 1015 } else {
1016 addressee.insertAddress( *addressAdd ); 1016 addressee.insertAddress( *addressAdd );
1017 } 1017 }
1018 } 1018 }
1019 } 1019 }
1020 } 1020 }
1021#endif 1021#endif
1022 // ++++++++++++++++++++++ end of ALL addresses 1022 // ++++++++++++++++++++++ end of ALL addresses
1023 //GetUserProperties(); 1023 //GetUserProperties();
1024 tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); 1024 tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer());
1025 phoneS.replace( QRegExp("\\r"), ""); 1025 phoneS.replace( QRegExp("\\r"), "");
1026 if ( !tempS.isEmpty() ) 1026 if ( !tempS.isEmpty() )
1027 addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); 1027 addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS );
1028 tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); 1028 tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer());
1029 if ( !tempS.isEmpty() ) 1029 if ( !tempS.isEmpty() )
1030 addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); 1030 addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS );
1031 int gen = aItem->GetGender(); 1031 int gen = aItem->GetGender();
1032 if ( gen != 0 ) { // 0 undef - 1 female - 2 male 1032 if ( gen != 0 ) { // 0 undef - 1 female - 2 male
1033 if ( gen == 1 ) 1033 if ( gen == 1 )
1034 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); 1034 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
1035 else 1035 else
1036 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); 1036 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
1037 } 1037 }
1038 QString additionalInfo; 1038 QString additionalInfo;
1039 QString tempAdd; 1039 QString tempAdd;
1040 tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer()); 1040 tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer());
1041 if ( ! tempAdd.isEmpty() ) { 1041 if ( ! tempAdd.isEmpty() ) {
1042 additionalInfo += i18n("\nLanguage: "); 1042 additionalInfo += i18n("\nLanguage: ");
1043 additionalInfo += tempAdd; 1043 additionalInfo += tempAdd;
1044 } 1044 }
1045 tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer()); 1045 tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer());
1046 phoneS.replace( QRegExp("\\r"), ""); 1046 phoneS.replace( QRegExp("\\r"), "");
1047 if ( ! tempAdd.isEmpty() ) { 1047 if ( ! tempAdd.isEmpty() ) {
1048 additionalInfo += i18n("\nHobby: "); 1048 additionalInfo += i18n("\nHobby: ");
1049 additionalInfo += tempAdd;; 1049 additionalInfo += tempAdd;;
1050 } 1050 }
1051 tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer()); 1051 tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer());
1052 phoneS.replace( QRegExp("\\r"), ""); 1052 phoneS.replace( QRegExp("\\r"), "");
1053 if ( ! tempAdd.isEmpty() ) { 1053 if ( ! tempAdd.isEmpty() ) {
1054 additionalInfo += i18n("\nHomepage: "); 1054 additionalInfo += i18n("\nHomepage: ");
1055 additionalInfo += tempAdd;; 1055 additionalInfo += tempAdd;;
1056 } 1056 }
1057 tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer()); 1057 tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer());
1058 phoneS.replace( QRegExp("\\r"), ""); 1058 phoneS.replace( QRegExp("\\r"), "");
1059 if ( ! tempAdd.isEmpty() ) { 1059 if ( ! tempAdd.isEmpty() ) {
1060 additionalInfo += i18n("\nBilling information: "); 1060 additionalInfo += i18n("\nBilling information: ");
1061 additionalInfo += tempAdd;; 1061 additionalInfo += tempAdd;;
1062 } 1062 }
1063 tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer()); 1063 tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer());
1064 phoneS.replace( QRegExp("\\r"), ""); 1064 phoneS.replace( QRegExp("\\r"), "");
1065 if ( ! tempAdd.isEmpty() ) { 1065 if ( ! tempAdd.isEmpty() ) {
1066 additionalInfo += i18n("\nCustomer ID: "); 1066 additionalInfo += i18n("\nCustomer ID: ");
1067 additionalInfo += tempAdd;; 1067 additionalInfo += tempAdd;;
1068 } 1068 }
1069 tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer()); 1069 tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer());
1070 phoneS.replace( QRegExp("\\r"), ""); 1070 phoneS.replace( QRegExp("\\r"), "");
1071 if ( ! tempAdd.isEmpty() ) { 1071 if ( ! tempAdd.isEmpty() ) {
1072 additionalInfo += i18n("\nUser1: "); 1072 additionalInfo += i18n("\nUser1: ");
1073 additionalInfo += tempAdd;; 1073 additionalInfo += tempAdd;;
1074 } 1074 }
1075 tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer()); 1075 tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer());
1076 phoneS.replace( QRegExp("\\r"), ""); 1076 phoneS.replace( QRegExp("\\r"), "");
1077 if ( ! tempAdd.isEmpty() ) { 1077 if ( ! tempAdd.isEmpty() ) {
1078 additionalInfo += i18n("\nUser2: "); 1078 additionalInfo += i18n("\nUser2: ");
1079 additionalInfo += tempAdd;; 1079 additionalInfo += tempAdd;;
1080 } 1080 }
1081 tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer()); 1081 tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer());
1082 phoneS.replace( QRegExp("\\r"), ""); 1082 phoneS.replace( QRegExp("\\r"), "");
1083 if ( ! tempAdd.isEmpty() ) { 1083 if ( ! tempAdd.isEmpty() ) {
1084 additionalInfo += i18n("\nUser3: "); 1084 additionalInfo += i18n("\nUser3: ");
1085 additionalInfo += tempAdd;; 1085 additionalInfo += tempAdd;;
1086 } 1086 }
1087 tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer()); 1087 tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer());
1088 phoneS.replace( QRegExp("\\r"), ""); 1088 phoneS.replace( QRegExp("\\r"), "");
1089 if ( ! tempAdd.isEmpty() ) { 1089 if ( ! tempAdd.isEmpty() ) {
1090 additionalInfo += i18n("\nUser4: "); 1090 additionalInfo += i18n("\nUser4: ");
1091 additionalInfo += tempAdd;; 1091 additionalInfo += tempAdd;;
1092 } 1092 }
1093 if (!additionalInfo.isEmpty() && ! syncMode ) { 1093 if (!additionalInfo.isEmpty() && ! syncMode ) {
1094 tempAdd = notesStr; 1094 tempAdd = notesStr;
1095 notesStr = "+++++++++++++++++++++++++++\n"; 1095 notesStr = "+++++++++++++++++++++++++++\n";
1096 notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:"); 1096 notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:");
1097 notesStr += additionalInfo; 1097 notesStr += additionalInfo;
1098 notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n"); 1098 notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n");
1099 notesStr += "+++++++++++++++++++++++++++\n"; 1099 notesStr += "+++++++++++++++++++++++++++\n";
1100 notesStr += tempAdd; 1100 notesStr += tempAdd;
1101 } 1101 }
1102 addressee.setNote( notesStr ); 1102 addressee.setNote( notesStr );
1103#if 0 1103#if 0
1104 // pending 1104 // pending
1105 - IM address: no clue where to get info about the helper ID 1105 - IM address: no clue where to get info about the helper ID
1106 -custom fields: difficult to implement - not implemented 1106 -custom fields: difficult to implement - not implemented
1107 -keys: makes no sense 1107 -keys: makes no sense
1108#endif 1108#endif
1109 return addressee; 1109 return addressee;
1110} 1110}
1111#if 0 1111#if 0
1112 1112
1113 1113
1114QDateTime mDdate2Qdtr( DATE dt) 1114QDateTime mDdate2Qdtr( DATE dt)
1115{ 1115{
1116 COleDateTime odt; 1116 COleDateTime odt;
1117 SYSTEMTIME st; 1117 SYSTEMTIME st;
1118 odt = dt; 1118 odt = dt;
1119 if ( odt.GetStatus() != 0 ) 1119 if ( odt.GetStatus() != 0 )
1120 return QDateTime(); 1120 return QDateTime();
1121 odt.GetAsSystemTime(st); 1121 odt.GetAsSystemTime(st);
1122 if ( st.wYear > 4000 ) // this program as a year 4000 bug! 1122 if ( st.wYear > 4000 ) // this program as a year 4000 bug!
1123 return QDateTime(); 1123 return QDateTime();
1124 // it seems so, that 1.1.4501 indicates: DATE invalid 1124 // it seems so, that 1.1.4501 indicates: DATE invalid
1125 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); 1125 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
1126 return qdt; 1126 return qdt;
1127} 1127}
1128DATE Qdt2date( QDateTime dt ) 1128DATE Qdt2date( QDateTime dt )
1129{ 1129{
1130 DATE ddd; 1130 DATE ddd;
1131 COleDateTime odt; 1131 COleDateTime odt;
1132 odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(), 1132 odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(),
1133 dt.time().hour(), dt.time().minute(), dt.time().second() ); 1133 dt.time().hour(), dt.time().minute(), dt.time().second() );
1134 ddd = odt; 1134 ddd = odt;
1135 return ddd; 1135 return ddd;
1136} 1136}
1137 1137
1138class OLEListViewItem : public QCheckListItem 1138class OLEListViewItem : public Q3CheckListItem
1139{ 1139{
1140 public: 1140 public:
1141 OLEListViewItem( QListView *parent, QString text ) : 1141 OLEListViewItem( Q3ListView *parent, QString text ) :
1142 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; 1142 Q3CheckListItem( parent, text, Q3CheckListItem::CheckBox ) { ; };
1143 OLEListViewItem( QListViewItem *after, QString text ) : 1143 OLEListViewItem( Q3ListViewItem *after, QString text ) :
1144 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; 1144 Q3CheckListItem( after, text, Q3CheckListItem::CheckBox ) { ; };
1145 ~OLEListViewItem() {}; 1145 ~OLEListViewItem() {};
1146 void setData( DWORD data ) {mData= data; }; 1146 void setData( DWORD data ) {mData= data; };
1147 void setDataID( QString data ){ mDataID = data ;} 1147 void setDataID( QString data ){ mDataID = data ;}
1148 QString dataID() { return mDataID;} 1148 QString dataID() { return mDataID;}
1149 DWORD data() { return mData ;}; 1149 DWORD data() { return mData ;};
1150 private: 1150 private:
1151 DWORD mData; 1151 DWORD mData;
1152 QString mDataID; 1152 QString mDataID;
1153}; 1153};
1154bool KAImportOLdialog::sOLDispatch = false; 1154bool KAImportOLdialog::sOLDispatch = false;
1155 1155
1156KAImportOLdialog::KAImportOLdialog( const QString &caption, 1156KAImportOLdialog::KAImportOLdialog( const QString &caption,
1157 KABC::AddressBook * aBook, QWidget *parent ) : 1157 KABC::AddressBook * aBook, QWidget *parent ) :
1158 KDialogBase( Plain, caption, User1 | Close, Ok, 1158 KDialogBase( Plain, caption, User1 | Close, Ok,
1159 parent, caption, true, false, i18n("Import!") ) 1159 parent, caption, true, false, i18n("Import!") )
1160{ 1160{
1161 mSyncMode = false; 1161 mSyncMode = false;
1162 QHBox * mw = new QHBox( this ); 1162 Q3HBox * mw = new Q3HBox( this );
1163 setMainWidget( mw ); 1163 setMainWidget( mw );
1164 mListView = new QListView( mw ); 1164 mListView = new Q3ListView( mw );
1165 mListView->addColumn(i18n("Select Folder")); 1165 mListView->addColumn(i18n("Select Folder"));
1166 mListView->addColumn(i18n("Content Type")); 1166 mListView->addColumn(i18n("Content Type"));
1167 mABook = aBook; 1167 mABook = aBook;
1168 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); 1168 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
1169 setupFolderView(); 1169 setupFolderView();
1170 resize( sizeHint().width()+50, sizeHint().height()+50 ); 1170 resize( sizeHint().width()+50, sizeHint().height()+50 );
1171} 1171}
1172 1172
1173KAImportOLdialog::~KAImportOLdialog() 1173KAImportOLdialog::~KAImportOLdialog()
1174{ 1174{
1175 1175
1176} 1176}
1177 1177
1178void KAImportOLdialog::setSyncMode() 1178void KAImportOLdialog::setSyncMode()
1179{ 1179{
1180 mSyncMode = true; 1180 mSyncMode = true;
1181 findButton( User1 )->setText( i18n("Synchronize!") ); 1181 findButton( User1 )->setText( i18n("Synchronize!") );
1182} 1182}
1183KABC::Addressee::List KAImportOLdialog::getAddressList() 1183KABC::Addressee::List KAImportOLdialog::getAddressList()
1184{ 1184{
1185 return mAList; 1185 return mAList;
1186} 1186}
1187void KAImportOLdialog::setupFolderView() 1187void KAImportOLdialog::setupFolderView()
1188{ 1188{
1189 SCODE sc = ::OleInitialize(NULL); 1189 SCODE sc = ::OleInitialize(NULL);
1190 if ( FAILED ( sc ) ) { 1190 if ( FAILED ( sc ) ) {
1191 KMessageBox::information(this,"OLE initialisation failed"); 1191 KMessageBox::information(this,"OLE initialisation failed");
1192 return; 1192 return;
1193 } 1193 }
1194 if( ! KAImportOLdialog::sOLDispatch ) { 1194 if( ! KAImportOLdialog::sOLDispatch ) {
1195 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ 1195 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){
1196 KMessageBox::information(this,"Sorry, cannot access Outlook"); 1196 KMessageBox::information(this,"Sorry, cannot access Outlook");
1197 return ; 1197 return ;
1198 } 1198 }
1199 KAImportOLdialog::sOLDispatch = true; 1199 KAImportOLdialog::sOLDispatch = true;
1200 } 1200 }
1201 MAPIFolder mfInbox; 1201 MAPIFolder mfInbox;
1202 MAPIFolder mfRoot; 1202 MAPIFolder mfRoot;
1203 CString szName; 1203 CString szName;
1204 _NameSpace olNS; 1204 _NameSpace olNS;
1205 olNS = gOlAppAB.GetNamespace(_T("MAPI")); 1205 olNS = gOlAppAB.GetNamespace(_T("MAPI"));
1206 mfInbox = olNS.GetDefaultFolder(6); 1206 mfInbox = olNS.GetDefaultFolder(6);
1207 mfRoot = mfInbox.GetParent(); 1207 mfRoot = mfInbox.GetParent();
1208 szName = mfRoot.GetName(); 1208 szName = mfRoot.GetName();
1209 long iType = mfRoot.GetDefaultItemType(); 1209 long iType = mfRoot.GetDefaultItemType();
1210 QString mes; 1210 QString mes;
1211 mes = QString::fromUcs2( szName.GetBuffer() ); 1211 mes = QString::fromUcs2( szName.GetBuffer() );
1212 OLEListViewItem * root = new OLEListViewItem( mListView, mes ); 1212 OLEListViewItem * root = new OLEListViewItem( mListView, mes );
1213 mfRoot.m_lpDispatch->AddRef(); 1213 mfRoot.m_lpDispatch->AddRef();
1214 addFolder( root, mfRoot.m_lpDispatch ); 1214 addFolder( root, mfRoot.m_lpDispatch );
1215 root->setOpen( true ); 1215 root->setOpen( true );
1216 mListView->setSortColumn( 0 ); 1216 mListView->setSortColumn( 0 );
1217 mListView->sort( ); 1217 mListView->sort( );
1218} 1218}
1219 1219
1220 1220
1221void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) 1221void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent)
1222{ 1222{
1223 MAPIFolder mfParent(dispParent), mfChild; 1223 MAPIFolder mfParent(dispParent), mfChild;
1224 _Folders folders; 1224 _Folders folders;
1225 _variant_t fndx((long)0); 1225 _variant_t fndx((long)0);
1226 CString szName; 1226 CString szName;
1227 long iType; 1227 long iType;
1228 OLEListViewItem* hChild; 1228 OLEListViewItem* hChild;
1229 1229
1230 folders = mfParent.GetFolders(); 1230 folders = mfParent.GetFolders();
1231 for(int i=1; i <= folders.GetCount(); ++i) 1231 for(int i=1; i <= folders.GetCount(); ++i)
1232 { 1232 {
1233 fndx = (long)i; 1233 fndx = (long)i;
1234 mfChild = folders.Item(fndx.Detach()); 1234 mfChild = folders.Item(fndx.Detach());
1235 mfChild.m_lpDispatch->AddRef(); 1235 mfChild.m_lpDispatch->AddRef();
1236 szName = mfChild.GetName(); 1236 szName = mfChild.GetName();
1237 iType = mfChild.GetDefaultItemType(); 1237 iType = mfChild.GetDefaultItemType();
1238 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); 1238 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
1239 hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) ); 1239 hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) );
1240 if ( iType != 2) 1240 if ( iType != 2)
1241 hChild->setEnabled( false ); 1241 hChild->setEnabled( false );
1242 QString ts; 1242 QString ts;
1243 switch( iType ) { 1243 switch( iType ) {
1244 case 0: 1244 case 0:
1245 ts = i18n("Mail"); 1245 ts = i18n("Mail");
1246 break; 1246 break;
1247 case 1: 1247 case 1:
1248 ts = i18n("Calendar"); 1248 ts = i18n("Calendar");
1249 break; 1249 break;
1250 case 2: 1250 case 2:
1251 ts = i18n("Contacts"); 1251 ts = i18n("Contacts");
1252 break; 1252 break;
1253 case 3: 1253 case 3:
1254 ts = i18n("Todos"); 1254 ts = i18n("Todos");
1255 break; 1255 break;
1256 case 4: 1256 case 4:
1257 ts = i18n("Journals"); 1257 ts = i18n("Journals");
1258 break; 1258 break;
1259 case 5: 1259 case 5:
1260 ts = i18n("Notes"); 1260 ts = i18n("Notes");
1261 break; 1261 break;
1262 default: 1262 default:
1263 ts = i18n("Unknown"); 1263 ts = i18n("Unknown");
1264 } 1264 }
1265 hChild->setText( 1,ts); 1265 hChild->setText( 1,ts);
1266 hChild->setData( (DWORD) mfChild.m_lpDispatch ); 1266 hChild->setData( (DWORD) mfChild.m_lpDispatch );
1267 mfChild.m_lpDispatch->AddRef(); 1267 mfChild.m_lpDispatch->AddRef();
1268 addFolder(hChild, mfChild.m_lpDispatch); 1268 addFolder(hChild, mfChild.m_lpDispatch);
1269 } 1269 }
1270} 1270}
1271 1271
1272void KAImportOLdialog::slotApply() 1272void KAImportOLdialog::slotApply()
1273{ 1273{
1274 importedItems = 0; 1274 importedItems = 0;
1275 OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); 1275 OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
1276 while ( child ) { 1276 while ( child ) {
1277 if ( child->isOn() ) { 1277 if ( child->isOn() ) {
1278 readContactData( child->data() ); 1278 readContactData( child->data() );
1279 if ( mSyncMode ) { 1279 if ( mSyncMode ) {
1280 mSelectedFolderID = child->dataID(); 1280 mSelectedFolderID = child->dataID();
1281 accept(); 1281 accept();
1282 return; 1282 return;
1283 } 1283 }
1284 } 1284 }
1285 child = (OLEListViewItem*) child->itemBelow(); 1285 child = (OLEListViewItem*) child->itemBelow();
1286 } 1286 }
1287 QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); 1287 QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems);
1288 KMessageBox::information(this,mes); 1288 KMessageBox::information(this,mes);
1289} 1289}
1290void KAImportOLdialog::readContactData( DWORD folder ) 1290void KAImportOLdialog::readContactData( DWORD folder )
1291{ 1291{
1292 1292
1293 LPDISPATCH dispItem = (LPDISPATCH)folder; 1293 LPDISPATCH dispItem = (LPDISPATCH)folder;
1294 dispItem->AddRef(); 1294 dispItem->AddRef();
1295 MAPIFolder mf(dispItem); 1295 MAPIFolder mf(dispItem);
1296 mf.m_lpDispatch->AddRef(); 1296 mf.m_lpDispatch->AddRef();
1297 _Items folderItems; 1297 _Items folderItems;
1298 _variant_t indx((long)0); 1298 _variant_t indx((long)0);
1299 LPDISPATCH itm; 1299 LPDISPATCH itm;
1300 int i; 1300 int i;
1301 folderItems = mf.GetItems(); 1301 folderItems = mf.GetItems();
1302 QString cap = i18n("Importing contact data"); 1302 QString cap = i18n("Importing contact data");
1303 if ( mSyncMode ) { 1303 if ( mSyncMode ) {
1304 cap = i18n("Reading contact data..."); 1304 cap = i18n("Reading contact data...");
1305 } 1305 }
1306 QProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(),this); 1306 Q3ProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(),this);
1307 bar.setCaption (i18n("Accessing OL") ); 1307 bar.setCaption (i18n("Accessing OL") );
1308 int h = bar.sizeHint().height() ; 1308 int h = bar.sizeHint().height() ;
1309 int w = 300; 1309 int w = 300;
1310 int dw = QApplication::desktop()->width(); 1310 int dw = QApplication::desktop()->width();
1311 int dh = QApplication::desktop()->height(); 1311 int dh = QApplication::desktop()->height();
1312 //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1312 //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1313 bar.show(); 1313 bar.show();
1314 for(i=1; i <= folderItems.GetCount(); ++i) 1314 for(i=1; i <= folderItems.GetCount(); ++i)
1315 { 1315 {
1316 qApp->processEvents(); 1316 qApp->processEvents();
1317 if ( ! bar.isVisible() ) 1317 if ( ! bar.isVisible() )
1318 return ; 1318 return ;
1319 bar.setProgress( i ); 1319 bar.setProgress( i );
1320 indx = (long)i; 1320 indx = (long)i;
1321 itm = folderItems.Item(indx.Detach()); 1321 itm = folderItems.Item(indx.Detach());
1322 _ContactItem * pItem = (_ContactItem *)&itm; 1322 _ContactItem * pItem = (_ContactItem *)&itm;
1323 if ( addAddressee( ol2kapiContact( pItem, mSyncMode ) )) 1323 if ( addAddressee( ol2kapiContact( pItem, mSyncMode ) ))
1324 ++importedItems; 1324 ++importedItems;
1325 itm->Release(); 1325 itm->Release();
1326 } 1326 }
1327} 1327}
1328void KAImportOLdialog::slotOk() 1328void KAImportOLdialog::slotOk()
1329{ 1329{
1330 QDialog::accept(); 1330 QDialog::accept();
1331} 1331}
1332 1332
1333KABC::Addressee KAImportOLdialog::ol2kapiContact( _ContactItem * aItem , bool syncMode) 1333KABC::Addressee KAImportOLdialog::ol2kapiContact( _ContactItem * aItem , bool syncMode)
1334{ 1334{
1335 KABC::Addressee addressee; 1335 KABC::Addressee addressee;
1336 1336
1337 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); 1337 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
1338 //GetLastModificationTime() 1338 //GetLastModificationTime()
1339 //addressee.setName( const QString &name ); 1339 //addressee.setName( const QString &name );
1340 addressee.setFormattedName( QString::fromUcs2(aItem->GetFileAs().GetBuffer()) ); 1340 addressee.setFormattedName( QString::fromUcs2(aItem->GetFileAs().GetBuffer()) );
1341 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); 1341 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) );
1342 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); 1342 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
1343 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); 1343 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
1344 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); 1344 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
1345 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); 1345 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
1346 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); 1346 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
1347 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); 1347 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
1348 if ( dtb.isValid() ) 1348 if ( dtb.isValid() )
1349 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); 1349 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
1350 1350
1351 //QString::fromUcs2(aItem->.GetBuffer()) 1351 //QString::fromUcs2(aItem->.GetBuffer())
1352 //addressee.setMailer( const QString &mailer ); 1352 //addressee.setMailer( const QString &mailer );
1353 //addressee.setTimeZone( const TimeZone &timeZone ); 1353 //addressee.setTimeZone( const TimeZone &timeZone );
1354 //addressee.setGeo( const Geo &geo ); 1354 //addressee.setGeo( const Geo &geo );
1355 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix 1355 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix
1356 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); 1356 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );
1357 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); 1357 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") );
1358 QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); 1358 QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer());
1359 notesStr.replace( QRegExp("\\r"), ""); 1359 notesStr.replace( QRegExp("\\r"), "");
1360 1360
1361 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); 1361 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) );
1362 //addressee.setRevision( const QDateTime &revision ); 1362 //addressee.setRevision( const QDateTime &revision );
1363 // addressee.setSortString( const QString &sortString ); 1363 // addressee.setSortString( const QString &sortString );
1364 addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); 1364 addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) );
1365 1365
1366 QString tempS; 1366 QString tempS;
1367 tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer());//+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); 1367 tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer());//+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer());
1368 if ( tempS.length() > 12 ) 1368 if ( tempS.length() > 12 )
1369 addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); 1369 addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS );
1370 tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); 1370 tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer());
1371 if ( !tempS.isEmpty() ) 1371 if ( !tempS.isEmpty() )
1372 addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); 1372 addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS );
1373 tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); 1373 tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer());
1374 if ( !tempS.isEmpty() ) 1374 if ( !tempS.isEmpty() )
1375 addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); 1375 addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS );
1376 tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); 1376 tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer());
1377 if ( !tempS.isEmpty() ) 1377 if ( !tempS.isEmpty() )
1378 addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); 1378 addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS );
1379 tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); 1379 tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer());
1380 if ( !tempS.isEmpty() ) 1380 if ( !tempS.isEmpty() )
1381 addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); 1381 addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS );
1382 tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), ""); 1382 tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), "");
1383 if ( !tempS.isEmpty() ) 1383 if ( !tempS.isEmpty() )
1384 addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); 1384 addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS );
1385 tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); 1385 tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer());
1386 if ( !tempS.isEmpty() ) 1386 if ( !tempS.isEmpty() )
1387 addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); 1387 addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS );
1388 dtb = mDdate2Qdtr(aItem->GetAnniversary()); 1388 dtb = mDdate2Qdtr(aItem->GetAnniversary());
1389 if (dtb.isValid() ) { 1389 if (dtb.isValid() ) {
1390 QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); 1390 QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate);
1391 addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 1391 addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
1392 } 1392 }
1393 int sec = aItem->GetSensitivity() ; 1393 int sec = aItem->GetSensitivity() ;
1394 if ( sec > 1 )// mapping pers -> private 1394 if ( sec > 1 )// mapping pers -> private
1395 --sec; 1395 --sec;
1396 addressee.setSecrecy( sec ); 1396 addressee.setSecrecy( sec );
1397 //addressee.setLogo( const Picture &logo ); 1397 //addressee.setLogo( const Picture &logo );
1398 //addressee.setPhoto( const Picture &photo ); 1398 //addressee.setPhoto( const Picture &photo );
1399 //addressee.setSound( const Sound &sound ); 1399 //addressee.setSound( const Sound &sound );
1400 //addressee.setAgent( const Agent &agent ); 1400 //addressee.setAgent( const Agent &agent );
1401 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), ""); 1401 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), "");
1402 cat = cat.replace( QRegExp("; "), ";"); 1402 cat = cat.replace( QRegExp("; "), ";");
1403 addressee.setCategories( QStringList::split( ";", cat )); 1403 addressee.setCategories( QStringList::split( ";", cat ));
1404 1404
1405 QString phoneS; 1405 QString phoneS;
1406 1406
1407 phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); 1407 phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer());
1408 if ( ! phoneS.isEmpty()) 1408 if ( ! phoneS.isEmpty())
1409 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1409 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1410 KABC::PhoneNumber::Work + 1410 KABC::PhoneNumber::Work +
1411 KABC::PhoneNumber::Voice + 1411 KABC::PhoneNumber::Voice +
1412 KABC::PhoneNumber::Msg ) ); 1412 KABC::PhoneNumber::Msg ) );
1413 phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); 1413 phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer());
1414 if ( ! phoneS.isEmpty()) 1414 if ( ! phoneS.isEmpty())
1415 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1415 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1416 KABC::PhoneNumber::Work + 1416 KABC::PhoneNumber::Work +
1417 KABC::PhoneNumber::Pref) ); 1417 KABC::PhoneNumber::Pref) );
1418 phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); 1418 phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer());
1419 if ( ! phoneS.isEmpty()) 1419 if ( ! phoneS.isEmpty())
1420 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1420 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1421 KABC::PhoneNumber::Work ) ); 1421 KABC::PhoneNumber::Work ) );
1422 phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); 1422 phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer());
1423 if ( ! phoneS.isEmpty()) 1423 if ( ! phoneS.isEmpty())
1424 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1424 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1425 KABC::PhoneNumber::Work + 1425 KABC::PhoneNumber::Work +
1426 KABC::PhoneNumber::Fax ) ); 1426 KABC::PhoneNumber::Fax ) );
1427 phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); 1427 phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer());
1428 if ( ! phoneS.isEmpty()) 1428 if ( ! phoneS.isEmpty())
1429 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1429 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1430 KABC::PhoneNumber::Car ) ); 1430 KABC::PhoneNumber::Car ) );
1431 phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); 1431 phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer());
1432 if ( ! phoneS.isEmpty()) 1432 if ( ! phoneS.isEmpty())
1433 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1433 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1434 KABC::PhoneNumber::Home + 1434 KABC::PhoneNumber::Home +
1435 KABC::PhoneNumber::Pref ) ); 1435 KABC::PhoneNumber::Pref ) );
1436 phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); 1436 phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer());
1437 if ( ! phoneS.isEmpty()) 1437 if ( ! phoneS.isEmpty())
1438 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1438 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1439 KABC::PhoneNumber::Home ) ); 1439 KABC::PhoneNumber::Home ) );
1440 phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); 1440 phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer());
1441 if ( ! phoneS.isEmpty()) 1441 if ( ! phoneS.isEmpty())
1442 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1442 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1443 KABC::PhoneNumber::Home + 1443 KABC::PhoneNumber::Home +
1444 KABC::PhoneNumber::Fax ) ); 1444 KABC::PhoneNumber::Fax ) );
1445 phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); 1445 phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer());
1446 if ( ! phoneS.isEmpty()) 1446 if ( ! phoneS.isEmpty())
1447 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1447 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1448 KABC::PhoneNumber::Isdn ) ); 1448 KABC::PhoneNumber::Isdn ) );
1449 phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); 1449 phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer());
1450 if ( ! phoneS.isEmpty()) 1450 if ( ! phoneS.isEmpty())
1451 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1451 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1452 KABC::PhoneNumber::Cell ) ); 1452 KABC::PhoneNumber::Cell ) );
1453 phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); 1453 phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer());
1454 if ( ! phoneS.isEmpty()) 1454 if ( ! phoneS.isEmpty())
1455 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1455 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1456 KABC::PhoneNumber::Fax ) ); 1456 KABC::PhoneNumber::Fax ) );
1457 phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); 1457 phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer());
1458 if ( ! phoneS.isEmpty()) 1458 if ( ! phoneS.isEmpty())
1459 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1459 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1460 KABC::PhoneNumber::Voice ) ); 1460 KABC::PhoneNumber::Voice ) );
1461 phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); 1461 phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer());
1462 if ( ! phoneS.isEmpty()) 1462 if ( ! phoneS.isEmpty())
1463 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1463 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1464 KABC::PhoneNumber::Pager ) ); 1464 KABC::PhoneNumber::Pager ) );
1465 phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); 1465 phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer());
1466 if ( ! phoneS.isEmpty()) 1466 if ( ! phoneS.isEmpty())
1467 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1467 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1468 KABC::PhoneNumber::Pref ) ); 1468 KABC::PhoneNumber::Pref ) );
1469 phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); 1469 phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer());
1470 if ( ! phoneS.isEmpty()) 1470 if ( ! phoneS.isEmpty())
1471 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1471 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1472 KABC::PhoneNumber::Pcs + 1472 KABC::PhoneNumber::Pcs +
1473 KABC::PhoneNumber::Voice) ); 1473 KABC::PhoneNumber::Voice) );
1474 phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); 1474 phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer());
1475 if ( ! phoneS.isEmpty()) 1475 if ( ! phoneS.isEmpty())
1476 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1476 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1477 KABC::PhoneNumber::Pcs ) ); 1477 KABC::PhoneNumber::Pcs ) );
1478 phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); 1478 phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer());
1479 if ( ! phoneS.isEmpty()) 1479 if ( ! phoneS.isEmpty())
1480 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1480 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1481 KABC::PhoneNumber::Work + 1481 KABC::PhoneNumber::Work +
1482 KABC::PhoneNumber::Msg ) ); 1482 KABC::PhoneNumber::Msg ) );
1483 phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); 1483 phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer());
1484 if ( ! phoneS.isEmpty()) 1484 if ( ! phoneS.isEmpty())
1485 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1485 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1486 KABC::PhoneNumber::Pcs + 1486 KABC::PhoneNumber::Pcs +
1487 KABC::PhoneNumber::Pref ) ); 1487 KABC::PhoneNumber::Pref ) );
1488 phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); 1488 phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer());
1489 if ( ! phoneS.isEmpty()) 1489 if ( ! phoneS.isEmpty())
1490 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1490 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1491 KABC::PhoneNumber::Msg ) ); 1491 KABC::PhoneNumber::Msg ) );
1492 1492
1493 bool preferred = true; 1493 bool preferred = true;
1494 phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); 1494 phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer());
1495 if ( ! phoneS.isEmpty()) { 1495 if ( ! phoneS.isEmpty()) {
1496 addressee.insertEmail(phoneS , preferred ); 1496 addressee.insertEmail(phoneS , preferred );
1497 preferred = false; 1497 preferred = false;
1498 } 1498 }