summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koimportoldialog.cpp21
-rw-r--r--korganizer/koimportoldialog.h1
2 files changed, 17 insertions, 5 deletions
diff --git a/korganizer/koimportoldialog.cpp b/korganizer/koimportoldialog.cpp
index 36363e5..16f2eca 100644
--- a/korganizer/koimportoldialog.cpp
+++ b/korganizer/koimportoldialog.cpp
@@ -1,96 +1,97 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qtooltip.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qlayout.h>
#include <qprogressbar.h>
#include <qwidgetstack.h>
#include <qdatetime.h>
#include <qdir.h>
#include <qapplication.h>
#include <qhbox.h>
#include <qheader.h>
#include <qdatetime.h>
#include <qlistview.h>
#include <kdebug.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#include <libkdepim/categoryselectdialog.h>
#include <libkdepim/kinputdialog.h>
#include <libkcal/calendarlocal.h>
#include <libkcal/icalformat.h>
+#include <kabc/stdaddressbook.h>
#include "koprefs.h"
#include "koglobals.h"
#include "koimportoldialog.h"
#include "../outport/msoutl9.h"
#include <ole2.h>
#include <comutil.h>
_Application gOlApp;
QDateTime mDdate2Qdtr( DATE dt)
{
COleDateTime odt;
SYSTEMTIME st;
odt = dt;
odt.GetAsSystemTime(st);
QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
return qdt;
}
class OLEListViewItem : public QCheckListItem
{
public:
OLEListViewItem( QListView *parent, QString text ) :
QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; };
OLEListViewItem( QListViewItem *after, QString text ) :
QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; };
~OLEListViewItem() {};
void setData( DWORD data ) {mData= data; };
DWORD data() { return mData ;};
private:
DWORD mData;
};
KOImportOLdialog::KOImportOLdialog( const QString &caption,
Calendar *calendar, QWidget *parent ) :
KDialogBase( Plain, caption, User1 | Close, Ok,
parent, caption, true, false, i18n("Import!") )
{
QHBox * mw = new QHBox( this );
setMainWidget( mw );
mListView = new QListView( mw );
mListView->addColumn(i18n("Select Folder to import"));
mListView->addColumn(i18n("Content Type"));
mCalendar = calendar;
connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
setupFolderView();
@@ -395,72 +396,82 @@ void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRe
LPDISPATCH itm;
int i;
QString optAtt = QString::fromUcs2( aItem->GetOptionalAttendees().GetBuffer());
QString reqAtt = QString::fromUcs2( aItem->GetRequiredAttendees().GetBuffer());
//GetRequiredAttendees()
for(i=1; i <= mf.GetCount(); ++i) {
indx = (long)i;
itm = mf.Item( indx.Detach() );
Recipient * pItem = (Recipient *)&itm;
//a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
QString name = QString::fromUcs2( pItem->GetName().GetBuffer());
KCal::Attendee::PartStat stat;
bool rsvp = false;
switch ( pItem->GetMeetingResponseStatus() ) {
case 0: //not answered
rsvp = true;
case 5: //not answered
stat = Attendee::NeedsAction;
break;
case 1: //organizer
stat = Attendee::Delegated ;
break;
case 2: //tentative
stat = Attendee::Tentative ;
break;
case 3: //accepted
stat = Attendee::Accepted;
break;
case 4: //declined
stat =Attendee::Declined ;
break;
default:
stat = Attendee::NeedsAction ;
}
KCal::Attendee::Role role;
if ( event->organizer() == name )
role = KCal::Attendee::Chair;
else if ( reqAtt.find( name ) >= 0 )
role = KCal::Attendee::ReqParticipant;
else if ( optAtt.find( name ) >= 0 )
role = KCal::Attendee::OptParticipant;
else
role = KCal::Attendee::NonParticipant;
QString mail = QString::fromUcs2(pItem->GetAddress().GetBuffer());
if( mail.isEmpty() && name.find("@") > 0 )
mail = name;
- QString uid;
- if ( mail.isEmpty() )
- uid = QString::fromUcs2( pItem->GetEntryID().GetBuffer());
- else
- uid = mail;
mail = mail.stripWhiteSpace();
+
+ QString uid = getUidByEmail( mail );
+ //uid = QString::fromUcs2( pItem->GetEntryID().GetBuffer());
KCal::Attendee * a = new KCal::Attendee( name, mail,rsvp,stat,role,uid) ;
event->addAttendee( a , false );
itm->Release();
}
if ( !mCalendar->addEventNoDup( event ))
delete event;
else {
// QString mes = i18n("Importing %1.\n date: %2 date: %3").arg( event->summary()).arg( event->dtStart().toString()).arg( event->dtEnd().toString());
//KMessageBox::information(this,mes);
++importedItems;
}
}
void KOImportOLdialog::slotCancel()
{
reject();
}
+
+QString KOImportOLdialog::getUidByEmail( QString email )
+{
+ KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
+ KABC::AddressBook::Iterator it;
+ for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
+ QStringList em = (*it).emails();
+ if ( em.contains( email ))
+ return (*it).uid();
+ }
+ return "";
+}
diff --git a/korganizer/koimportoldialog.h b/korganizer/koimportoldialog.h
index f6a753d..c8847c5 100644
--- a/korganizer/koimportoldialog.h
+++ b/korganizer/koimportoldialog.h
@@ -28,56 +28,57 @@
#include <afxdisp.h>
#include <libkcal/calendar.h>
#include <libkcal/event.h>
class QDateTime;
class QListView;
class OLEListViewItem;
class _AppointmentItem;
namespace KPIM { class CategorySelectDialog; }
using namespace KCal;
/**
This is the base class for the calendar component editors.
*/
class KOImportOLdialog : public KDialogBase
{
Q_OBJECT
public:
/**
Construct new IncidenceEditor.
*/
KOImportOLdialog( const QString &caption, Calendar *calendar,
QWidget *parent );
virtual ~KOImportOLdialog();
/** Initialize editor. This function creates the tab widgets. */
void init();
public slots:
signals:
protected slots:
void slotApply();
void slotOk();
void slotCancel();
protected:
void setupFolderView();
void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent);
void readCalendarData( DWORD folder );
void ol2kopiCalendar( _AppointmentItem * , bool computeRecurrence = true );
Calendar *mCalendar;
QListView * mListView;
+ QString getUidByEmail( QString email );
private:
int importedItems;
};
#endif