-rw-r--r-- | kaddressbook/kaimportoldialog.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp index 7bb8bd8..2f794d6 100644 --- a/kaddressbook/kaimportoldialog.cpp +++ b/kaddressbook/kaimportoldialog.cpp | |||
@@ -1,419 +1,420 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook/Pi. | 2 | This file is part of KAddressbook/Pi. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 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 <qframe.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qprogressbar.h> | 28 | #include <qprogressbar.h> |
29 | #include <qprogressdialog.h> | ||
29 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
30 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
31 | #include <qdir.h> | 32 | #include <qdir.h> |
32 | #include <qregexp.h> | 33 | #include <qregexp.h> |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qhbox.h> | 35 | #include <qhbox.h> |
35 | #include <qheader.h> | 36 | #include <qheader.h> |
36 | #include <qdatetime.h> | 37 | #include <qdatetime.h> |
37 | #include <qlistview.h> | 38 | #include <qlistview.h> |
38 | 39 | ||
39 | #include <kdebug.h> | 40 | #include <kdebug.h> |
40 | #include <klocale.h> | 41 | #include <klocale.h> |
41 | #include <kstandarddirs.h> | 42 | #include <kstandarddirs.h> |
42 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
43 | #include <kfiledialog.h> | 44 | #include <kfiledialog.h> |
44 | 45 | ||
45 | #include <libkdepim/categoryselectdialog.h> | 46 | #include <libkdepim/categoryselectdialog.h> |
46 | #include <libkdepim/kinputdialog.h> | 47 | #include <libkdepim/kinputdialog.h> |
47 | 48 | ||
48 | #include <libkcal/calendarlocal.h> | 49 | #include <libkcal/calendarlocal.h> |
49 | #include <libkcal/icalformat.h> | 50 | #include <libkcal/icalformat.h> |
50 | 51 | ||
51 | #include <kabc/addresseelist.h> | 52 | #include <kabc/addresseelist.h> |
52 | #include <kabc/phonenumber.h> | 53 | #include <kabc/phonenumber.h> |
53 | 54 | ||
54 | #include "kaimportoldialog.h" | 55 | #include "kaimportoldialog.h" |
55 | 56 | ||
56 | #include "../outport/msoutl9.h" | 57 | #include "../outport/msoutl9.h" |
57 | #include <ole2.h> | 58 | #include <ole2.h> |
58 | #include <comutil.h> | 59 | #include <comutil.h> |
59 | _Application gOlAppAB; | 60 | _Application gOlAppAB; |
60 | 61 | ||
61 | QDateTime mDdate2Qdtr( DATE dt) | 62 | QDateTime mDdate2Qdtr( DATE dt) |
62 | { | 63 | { |
63 | COleDateTime odt; | 64 | COleDateTime odt; |
64 | SYSTEMTIME st; | 65 | SYSTEMTIME st; |
65 | odt = dt; | 66 | odt = dt; |
66 | if ( odt.GetStatus() != 0 ) | 67 | if ( odt.GetStatus() != 0 ) |
67 | return QDateTime(); | 68 | return QDateTime(); |
68 | odt.GetAsSystemTime(st); | 69 | odt.GetAsSystemTime(st); |
69 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! | 70 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! |
70 | return QDateTime(); | 71 | return QDateTime(); |
71 | // it seems so, that 1.1.4501 indicates: DATE invalid | 72 | // it seems so, that 1.1.4501 indicates: DATE invalid |
72 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); | 73 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); |
73 | return qdt; | 74 | return qdt; |
74 | } | 75 | } |
75 | 76 | ||
76 | class OLEListViewItem : public QCheckListItem | 77 | class OLEListViewItem : public QCheckListItem |
77 | { | 78 | { |
78 | public: | 79 | public: |
79 | OLEListViewItem( QListView *parent, QString text ) : | 80 | OLEListViewItem( QListView *parent, QString text ) : |
80 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; | 81 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; |
81 | OLEListViewItem( QListViewItem *after, QString text ) : | 82 | OLEListViewItem( QListViewItem *after, QString text ) : |
82 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; | 83 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; |
83 | ~OLEListViewItem() {}; | 84 | ~OLEListViewItem() {}; |
84 | void setData( DWORD data ) {mData= data; }; | 85 | void setData( DWORD data ) {mData= data; }; |
85 | DWORD data() { return mData ;}; | 86 | DWORD data() { return mData ;}; |
86 | private: | 87 | private: |
87 | DWORD mData; | 88 | DWORD mData; |
88 | }; | 89 | }; |
89 | 90 | ||
90 | KAImportOLdialog::KAImportOLdialog( const QString &caption, | 91 | KAImportOLdialog::KAImportOLdialog( const QString &caption, |
91 | KABC::AddressBook * aBook, QWidget *parent ) : | 92 | KABC::AddressBook * aBook, QWidget *parent ) : |
92 | KDialogBase( Plain, caption, User1 | Close, Ok, | 93 | KDialogBase( Plain, caption, User1 | Close, Ok, |
93 | parent, caption, true, false, i18n("Import!") ) | 94 | parent, caption, true, false, i18n("Import!") ) |
94 | { | 95 | { |
95 | QHBox * mw = new QHBox( this ); | 96 | QHBox * mw = new QHBox( this ); |
96 | setMainWidget( mw ); | 97 | setMainWidget( mw ); |
97 | mListView = new QListView( mw ); | 98 | mListView = new QListView( mw ); |
98 | mListView->addColumn(i18n("Select Folder to import")); | 99 | mListView->addColumn(i18n("Select Folder to import")); |
99 | mListView->addColumn(i18n("Content Type")); | 100 | mListView->addColumn(i18n("Content Type")); |
100 | mABook = aBook; | 101 | mABook = aBook; |
101 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); | 102 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); |
102 | setupFolderView(); | 103 | setupFolderView(); |
103 | resize( sizeHint().width()+50, sizeHint().height()+50 ); | 104 | resize( sizeHint().width()+50, sizeHint().height()+50 ); |
104 | } | 105 | } |
105 | 106 | ||
106 | KAImportOLdialog::~KAImportOLdialog() | 107 | KAImportOLdialog::~KAImportOLdialog() |
107 | { | 108 | { |
108 | 109 | ||
109 | } | 110 | } |
110 | 111 | ||
111 | KABC::Addressee::List KAImportOLdialog::getAddressList() | 112 | KABC::Addressee::List KAImportOLdialog::getAddressList() |
112 | { | 113 | { |
113 | return mAList; | 114 | return mAList; |
114 | } | 115 | } |
115 | void KAImportOLdialog::setupFolderView() | 116 | void KAImportOLdialog::setupFolderView() |
116 | { | 117 | { |
117 | SCODE sc = ::OleInitialize(NULL); | 118 | SCODE sc = ::OleInitialize(NULL); |
118 | if ( FAILED ( sc ) ) { | 119 | if ( FAILED ( sc ) ) { |
119 | KMessageBox::information(this,"OLE initialisation failed"); | 120 | KMessageBox::information(this,"OLE initialisation failed"); |
120 | return; | 121 | return; |
121 | } | 122 | } |
122 | 123 | ||
123 | if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ | 124 | if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ |
124 | KMessageBox::information(this,"Sorry, cannot access Outlook"); | 125 | KMessageBox::information(this,"Sorry, cannot access Outlook"); |
125 | return ; | 126 | return ; |
126 | } | 127 | } |
127 | MAPIFolder mfInbox; | 128 | MAPIFolder mfInbox; |
128 | MAPIFolder mfRoot; | 129 | MAPIFolder mfRoot; |
129 | CString szName; | 130 | CString szName; |
130 | _NameSpace olNS; | 131 | _NameSpace olNS; |
131 | olNS = gOlAppAB.GetNamespace(_T("MAPI")); | 132 | olNS = gOlAppAB.GetNamespace(_T("MAPI")); |
132 | mfInbox = olNS.GetDefaultFolder(6); | 133 | mfInbox = olNS.GetDefaultFolder(6); |
133 | mfRoot = mfInbox.GetParent(); | 134 | mfRoot = mfInbox.GetParent(); |
134 | szName = mfRoot.GetName(); | 135 | szName = mfRoot.GetName(); |
135 | long iType = mfRoot.GetDefaultItemType(); | 136 | long iType = mfRoot.GetDefaultItemType(); |
136 | QString mes; | 137 | QString mes; |
137 | mes = QString::fromUcs2( szName.GetBuffer() ); | 138 | mes = QString::fromUcs2( szName.GetBuffer() ); |
138 | OLEListViewItem * root = new OLEListViewItem( mListView, mes ); | 139 | OLEListViewItem * root = new OLEListViewItem( mListView, mes ); |
139 | mfRoot.m_lpDispatch->AddRef(); | 140 | mfRoot.m_lpDispatch->AddRef(); |
140 | addFolder( root, mfRoot.m_lpDispatch ); | 141 | addFolder( root, mfRoot.m_lpDispatch ); |
141 | root->setOpen( true ); | 142 | root->setOpen( true ); |
142 | mListView->setSortColumn( 0 ); | 143 | mListView->setSortColumn( 0 ); |
143 | mListView->sort( ); | 144 | mListView->sort( ); |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) | 148 | void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) |
148 | { | 149 | { |
149 | MAPIFolder mfParent(dispParent), mfChild; | 150 | MAPIFolder mfParent(dispParent), mfChild; |
150 | _Folders folders; | 151 | _Folders folders; |
151 | _variant_t fndx((long)0); | 152 | _variant_t fndx((long)0); |
152 | CString szName; | 153 | CString szName; |
153 | long iType; | 154 | long iType; |
154 | OLEListViewItem* hChild; | 155 | OLEListViewItem* hChild; |
155 | 156 | ||
156 | folders = mfParent.GetFolders(); | 157 | folders = mfParent.GetFolders(); |
157 | for(int i=1; i <= folders.GetCount(); ++i) | 158 | for(int i=1; i <= folders.GetCount(); ++i) |
158 | { | 159 | { |
159 | fndx = (long)i; | 160 | fndx = (long)i; |
160 | mfChild = folders.Item(fndx.Detach()); | 161 | mfChild = folders.Item(fndx.Detach()); |
161 | mfChild.m_lpDispatch->AddRef(); | 162 | mfChild.m_lpDispatch->AddRef(); |
162 | szName = mfChild.GetName(); | 163 | szName = mfChild.GetName(); |
163 | iType = mfChild.GetDefaultItemType(); | 164 | iType = mfChild.GetDefaultItemType(); |
164 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); | 165 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); |
165 | if ( iType != 2) | 166 | if ( iType != 2) |
166 | hChild->setEnabled( false ); | 167 | hChild->setEnabled( false ); |
167 | QString ts; | 168 | QString ts; |
168 | switch( iType ) { | 169 | switch( iType ) { |
169 | case 0: | 170 | case 0: |
170 | ts = i18n("Mail"); | 171 | ts = i18n("Mail"); |
171 | break; | 172 | break; |
172 | case 1: | 173 | case 1: |
173 | ts = i18n("Calendar"); | 174 | ts = i18n("Calendar"); |
174 | break; | 175 | break; |
175 | case 2: | 176 | case 2: |
176 | ts = i18n("Contacts"); | 177 | ts = i18n("Contacts"); |
177 | break; | 178 | break; |
178 | case 3: | 179 | case 3: |
179 | ts = i18n("Todos"); | 180 | ts = i18n("Todos"); |
180 | break; | 181 | break; |
181 | case 4: | 182 | case 4: |
182 | ts = i18n("Journals"); | 183 | ts = i18n("Journals"); |
183 | break; | 184 | break; |
184 | case 5: | 185 | case 5: |
185 | ts = i18n("Notes"); | 186 | ts = i18n("Notes"); |
186 | break; | 187 | break; |
187 | default: | 188 | default: |
188 | ts = i18n("Unknown"); | 189 | ts = i18n("Unknown"); |
189 | } | 190 | } |
190 | hChild->setText( 1,ts); | 191 | hChild->setText( 1,ts); |
191 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | 192 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); |
192 | mfChild.m_lpDispatch->AddRef(); | 193 | mfChild.m_lpDispatch->AddRef(); |
193 | addFolder(hChild, mfChild.m_lpDispatch); | 194 | addFolder(hChild, mfChild.m_lpDispatch); |
194 | } | 195 | } |
195 | } | 196 | } |
196 | 197 | ||
197 | void KAImportOLdialog::slotApply() | 198 | void KAImportOLdialog::slotApply() |
198 | { | 199 | { |
199 | importedItems = 0; | 200 | importedItems = 0; |
200 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | 201 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); |
201 | while ( child ) { | 202 | while ( child ) { |
202 | if ( child->isOn() ) | 203 | if ( child->isOn() ) |
203 | readContactData( child->data() ); | 204 | readContactData( child->data() ); |
204 | child = (OLEListViewItem*) child->itemBelow(); | 205 | child = (OLEListViewItem*) child->itemBelow(); |
205 | } | 206 | } |
206 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | 207 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); |
207 | KMessageBox::information(this,mes); | 208 | KMessageBox::information(this,mes); |
208 | } | 209 | } |
209 | void KAImportOLdialog::readContactData( DWORD folder ) | 210 | void KAImportOLdialog::readContactData( DWORD folder ) |
210 | { | 211 | { |
211 | 212 | ||
212 | LPDISPATCH dispItem = (LPDISPATCH)folder; | 213 | LPDISPATCH dispItem = (LPDISPATCH)folder; |
213 | dispItem->AddRef(); | 214 | dispItem->AddRef(); |
214 | MAPIFolder mf(dispItem); | 215 | MAPIFolder mf(dispItem); |
215 | mf.m_lpDispatch->AddRef(); | 216 | mf.m_lpDispatch->AddRef(); |
216 | _Items folderItems; | 217 | _Items folderItems; |
217 | _variant_t indx((long)0); | 218 | _variant_t indx((long)0); |
218 | LPDISPATCH itm; | 219 | LPDISPATCH itm; |
219 | int i; | 220 | int i; |
220 | folderItems = mf.GetItems(); | 221 | folderItems = mf.GetItems(); |
221 | QProgressBar bar( folderItems.GetCount(),0 ); | 222 | QProgressDialog bar( i18n("Importing contact data"),i18n("Abort"), folderItems.GetCount(),this); |
222 | bar.setCaption (i18n("Importing - close to abort!") ); | 223 | bar.setCaption (i18n("Importing!") ); |
223 | int h = bar.sizeHint().height() ; | 224 | int h = bar.sizeHint().height() ; |
224 | int w = 300; | 225 | int w = 300; |
225 | int dw = QApplication::desktop()->width(); | 226 | int dw = QApplication::desktop()->width(); |
226 | int dh = QApplication::desktop()->height(); | 227 | int dh = QApplication::desktop()->height(); |
227 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 228 | //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
228 | bar.show(); | 229 | bar.show(); |
229 | for(i=1; i <= folderItems.GetCount(); ++i) | 230 | for(i=1; i <= folderItems.GetCount(); ++i) |
230 | { | 231 | { |
231 | qApp->processEvents(); | 232 | qApp->processEvents(); |
232 | if ( ! bar.isVisible() ) | 233 | if ( ! bar.isVisible() ) |
233 | return ; | 234 | return ; |
234 | bar.setProgress( i ); | 235 | bar.setProgress( i ); |
235 | indx = (long)i; | 236 | indx = (long)i; |
236 | itm = folderItems.Item(indx.Detach()); | 237 | itm = folderItems.Item(indx.Detach()); |
237 | _ContactItem * pItem = (_ContactItem *)&itm; | 238 | _ContactItem * pItem = (_ContactItem *)&itm; |
238 | ol2kapiContact( pItem ); | 239 | ol2kapiContact( pItem ); |
239 | itm->Release(); | 240 | itm->Release(); |
240 | } | 241 | } |
241 | } | 242 | } |
242 | void KAImportOLdialog::slotOk() | 243 | void KAImportOLdialog::slotOk() |
243 | { | 244 | { |
244 | QDialog::accept(); | 245 | QDialog::accept(); |
245 | } | 246 | } |
246 | 247 | ||
247 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) | 248 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) |
248 | { | 249 | { |
249 | KABC::Addressee addressee; | 250 | KABC::Addressee addressee; |
250 | 251 | ||
251 | addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); | 252 | addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); |
252 | //GetLastModificationTime() | 253 | //GetLastModificationTime() |
253 | //addressee.setName( const QString &name ); | 254 | //addressee.setName( const QString &name ); |
254 | //addressee.setFormattedName( const QString &formattedName ); | 255 | //addressee.setFormattedName( const QString &formattedName ); |
255 | addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); | 256 | addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); |
256 | addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); | 257 | addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); |
257 | addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); | 258 | addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); |
258 | addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); | 259 | addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); |
259 | addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); | 260 | addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); |
260 | addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); | 261 | addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); |
261 | QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); | 262 | QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); |
262 | if ( dtb.isValid() ) | 263 | if ( dtb.isValid() ) |
263 | addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); | 264 | addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); |
264 | 265 | ||
265 | //QString::fromUcs2(aItem->.GetBuffer()) | 266 | //QString::fromUcs2(aItem->.GetBuffer()) |
266 | //addressee.setMailer( const QString &mailer ); | 267 | //addressee.setMailer( const QString &mailer ); |
267 | //addressee.setTimeZone( const TimeZone &timeZone ); | 268 | //addressee.setTimeZone( const TimeZone &timeZone ); |
268 | //addressee.setGeo( const Geo &geo ); | 269 | //addressee.setGeo( const Geo &geo ); |
269 | //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix | 270 | //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix |
270 | addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); | 271 | addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); |
271 | addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); | 272 | addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); |
272 | QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); | 273 | QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); |
273 | notesStr.replace( QRegExp("\\r"), ""); | 274 | notesStr.replace( QRegExp("\\r"), ""); |
274 | 275 | ||
275 | addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); | 276 | addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); |
276 | //addressee.setRevision( const QDateTime &revision ); | 277 | //addressee.setRevision( const QDateTime &revision ); |
277 | // addressee.setSortString( const QString &sortString ); | 278 | // addressee.setSortString( const QString &sortString ); |
278 | addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); | 279 | addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); |
279 | 280 | ||
280 | QString tempS; | 281 | QString tempS; |
281 | tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); | 282 | tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); |
282 | if ( tempS.length() > 12 ) | 283 | if ( tempS.length() > 12 ) |
283 | addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); | 284 | addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); |
284 | tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); | 285 | tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); |
285 | if ( !tempS.isEmpty() ) | 286 | if ( !tempS.isEmpty() ) |
286 | addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); | 287 | addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); |
287 | tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); | 288 | tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); |
288 | if ( !tempS.isEmpty() ) | 289 | if ( !tempS.isEmpty() ) |
289 | addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); | 290 | addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); |
290 | tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); | 291 | tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); |
291 | if ( !tempS.isEmpty() ) | 292 | if ( !tempS.isEmpty() ) |
292 | addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); | 293 | addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); |
293 | tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); | 294 | tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); |
294 | if ( !tempS.isEmpty() ) | 295 | if ( !tempS.isEmpty() ) |
295 | addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); | 296 | addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); |
296 | tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), ""); | 297 | tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), ""); |
297 | if ( !tempS.isEmpty() ) | 298 | if ( !tempS.isEmpty() ) |
298 | addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); | 299 | addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); |
299 | tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); | 300 | tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); |
300 | if ( !tempS.isEmpty() ) | 301 | if ( !tempS.isEmpty() ) |
301 | addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); | 302 | addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); |
302 | dtb = mDdate2Qdtr(aItem->GetAnniversary()); | 303 | dtb = mDdate2Qdtr(aItem->GetAnniversary()); |
303 | if (dtb.isValid() ) { | 304 | if (dtb.isValid() ) { |
304 | QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); | 305 | QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); |
305 | addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 306 | addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
306 | } | 307 | } |
307 | int sec = aItem->GetSensitivity() ; | 308 | int sec = aItem->GetSensitivity() ; |
308 | if ( sec > 1 )// mapping pers -> private | 309 | if ( sec > 1 )// mapping pers -> private |
309 | --sec; | 310 | --sec; |
310 | addressee.setSecrecy( sec ); | 311 | addressee.setSecrecy( sec ); |
311 | //addressee.setLogo( const Picture &logo ); | 312 | //addressee.setLogo( const Picture &logo ); |
312 | //addressee.setPhoto( const Picture &photo ); | 313 | //addressee.setPhoto( const Picture &photo ); |
313 | //addressee.setSound( const Sound &sound ); | 314 | //addressee.setSound( const Sound &sound ); |
314 | //addressee.setAgent( const Agent &agent ); | 315 | //addressee.setAgent( const Agent &agent ); |
315 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), ""); | 316 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), ""); |
316 | cat = cat.replace( QRegExp("; "), ";"); | 317 | cat = cat.replace( QRegExp("; "), ";"); |
317 | addressee.setCategories( QStringList::split( ";", cat )); | 318 | addressee.setCategories( QStringList::split( ";", cat )); |
318 | 319 | ||
319 | QString phoneS; | 320 | QString phoneS; |
320 | 321 | ||
321 | phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); | 322 | phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); |
322 | if ( ! phoneS.isEmpty()) | 323 | if ( ! phoneS.isEmpty()) |
323 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) ); | 324 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) ); |
324 | phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); | 325 | phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); |
325 | if ( ! phoneS.isEmpty()) | 326 | if ( ! phoneS.isEmpty()) |
326 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | 327 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); |
327 | phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); | 328 | phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); |
328 | if ( ! phoneS.isEmpty()) | 329 | if ( ! phoneS.isEmpty()) |
329 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | 330 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); |
330 | phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); | 331 | phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); |
331 | if ( ! phoneS.isEmpty()) | 332 | if ( ! phoneS.isEmpty()) |
332 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) ); | 333 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) ); |
333 | phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); | 334 | phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); |
334 | if ( ! phoneS.isEmpty()) | 335 | if ( ! phoneS.isEmpty()) |
335 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) ); | 336 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) ); |
336 | phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); | 337 | phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); |
337 | if ( ! phoneS.isEmpty()) | 338 | if ( ! phoneS.isEmpty()) |
338 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | 339 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); |
339 | phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); | 340 | phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); |
340 | if ( ! phoneS.isEmpty()) | 341 | if ( ! phoneS.isEmpty()) |
341 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | 342 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); |
342 | phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); | 343 | phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); |
343 | if ( ! phoneS.isEmpty()) | 344 | if ( ! phoneS.isEmpty()) |
344 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) ); | 345 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) ); |
345 | phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); | 346 | phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); |
346 | if ( ! phoneS.isEmpty()) | 347 | if ( ! phoneS.isEmpty()) |
347 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) ); | 348 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) ); |
348 | phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); | 349 | phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); |
349 | if ( ! phoneS.isEmpty()) | 350 | if ( ! phoneS.isEmpty()) |
350 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) ); | 351 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) ); |
351 | phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); | 352 | phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); |
352 | if ( ! phoneS.isEmpty()) | 353 | if ( ! phoneS.isEmpty()) |
353 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) ); | 354 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) ); |
354 | phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); | 355 | phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); |
355 | if ( ! phoneS.isEmpty()) | 356 | if ( ! phoneS.isEmpty()) |
356 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) ); | 357 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) ); |
357 | phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); | 358 | phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); |
358 | if ( ! phoneS.isEmpty()) | 359 | if ( ! phoneS.isEmpty()) |
359 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) ); | 360 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) ); |
360 | phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); | 361 | phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); |
361 | if ( ! phoneS.isEmpty()) | 362 | if ( ! phoneS.isEmpty()) |
362 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) ); | 363 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) ); |
363 | phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); | 364 | phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); |
364 | if ( ! phoneS.isEmpty()) | 365 | if ( ! phoneS.isEmpty()) |
365 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) ); | 366 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) ); |
366 | phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); | 367 | phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); |
367 | if ( ! phoneS.isEmpty()) | 368 | if ( ! phoneS.isEmpty()) |
368 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) ); | 369 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) ); |
369 | phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); | 370 | phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); |
370 | if ( ! phoneS.isEmpty()) | 371 | if ( ! phoneS.isEmpty()) |
371 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) ); | 372 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) ); |
372 | phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); | 373 | phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); |
373 | if ( ! phoneS.isEmpty()) | 374 | if ( ! phoneS.isEmpty()) |
374 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) ); | 375 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) ); |
375 | phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); | 376 | phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); |
376 | if ( ! phoneS.isEmpty()) | 377 | if ( ! phoneS.isEmpty()) |
377 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) ); | 378 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) ); |
378 | 379 | ||
379 | bool preferred = true; | 380 | bool preferred = true; |
380 | phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); | 381 | phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); |
381 | if ( ! phoneS.isEmpty()) { | 382 | if ( ! phoneS.isEmpty()) { |
382 | addressee.insertEmail(phoneS , preferred ); | 383 | addressee.insertEmail(phoneS , preferred ); |
383 | preferred = false; | 384 | preferred = false; |
384 | } | 385 | } |
385 | phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); | 386 | phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); |
386 | if ( ! phoneS.isEmpty()) { | 387 | if ( ! phoneS.isEmpty()) { |
387 | addressee.insertEmail(phoneS , preferred ); | 388 | addressee.insertEmail(phoneS , preferred ); |
388 | preferred = false; | 389 | preferred = false; |
389 | } | 390 | } |
390 | phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); | 391 | phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); |
391 | if ( ! phoneS.isEmpty()) { | 392 | if ( ! phoneS.isEmpty()) { |
392 | addressee.insertEmail(phoneS , preferred ); | 393 | addressee.insertEmail(phoneS , preferred ); |
393 | preferred = false; | 394 | preferred = false; |
394 | } | 395 | } |
395 | // is this the number of the preferred email? | 396 | // is this the number of the preferred email? |
396 | //long GetSelectedMailingAddress();??? | 397 | //long GetSelectedMailingAddress();??? |
397 | 398 | ||
398 | KABC::Address addressHome; | 399 | KABC::Address addressHome; |
399 | KABC::Address* addressAdd = &addressHome; | 400 | KABC::Address* addressAdd = &addressHome; |
400 | bool insert = false; | 401 | bool insert = false; |
401 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); | 402 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); |
402 | phoneS.replace( QRegExp("\\r"), ""); | 403 | phoneS.replace( QRegExp("\\r"), ""); |
403 | if ( ! phoneS.isEmpty()) { | 404 | if ( ! phoneS.isEmpty()) { |
404 | addressAdd->setCountry(phoneS ); | 405 | addressAdd->setCountry(phoneS ); |
405 | insert = true; | 406 | insert = true; |
406 | } | 407 | } |
407 | phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); | 408 | phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); |
408 | phoneS.replace( QRegExp("\\r"), ""); | 409 | phoneS.replace( QRegExp("\\r"), ""); |
409 | if ( ! phoneS.isEmpty()) { | 410 | if ( ! phoneS.isEmpty()) { |
410 | addressAdd->setRegion(phoneS ); | 411 | addressAdd->setRegion(phoneS ); |
411 | insert = true; | 412 | insert = true; |
412 | } | 413 | } |
413 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); | 414 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); |
414 | phoneS.replace( QRegExp("\\r"), ""); | 415 | phoneS.replace( QRegExp("\\r"), ""); |
415 | if ( ! phoneS.isEmpty()) { | 416 | if ( ! phoneS.isEmpty()) { |
416 | addressAdd->setLocality(phoneS ); | 417 | addressAdd->setLocality(phoneS ); |
417 | insert = true; | 418 | insert = true; |
418 | } | 419 | } |
419 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); | 420 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); |