author | ulf69 <ulf69> | 2004-10-07 01:08:56 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-07 01:08:56 (UTC) |
commit | 3338b7239dc2e5cdff95ebc76b6905e6385a5833 (patch) (side-by-side diff) | |
tree | b7a90a8cf3254fd41a609237b41b9d0f73b2d8c8 | |
parent | 0406c1ac252f2fa631f7a486e73b0a97d09874f9 (diff) | |
download | kdepimpi-3338b7239dc2e5cdff95ebc76b6905e6385a5833.zip kdepimpi-3338b7239dc2e5cdff95ebc76b6905e6385a5833.tar.gz kdepimpi-3338b7239dc2e5cdff95ebc76b6905e6385a5833.tar.bz2 |
implemented birthday lookup via QCop
-rw-r--r-- | korganizer/calendarview.cpp | 103 | ||||
-rw-r--r-- | korganizer/calendarview.h | 5 |
2 files changed, 106 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1de2759..b3b4cdb 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -80,12 +80,13 @@ #include <libkcal/calendarresources.h> #include <libkcal/qtopiaformat.h> #include "../kalarmd/alarmdialog.h" #ifndef DESKTOP_VERSION #include <libkcal/sharpformat.h> +#include <externalapphandler.h> #endif #include <libkcal/phoneformat.h> #ifndef KORG_NOMAIL #include "komailclient.h" #endif #ifndef KORG_NOPRINTER @@ -459,12 +460,20 @@ void CalendarView::init() connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); mAlarmDialog = new AlarmDialog( this ); connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); mAlarmDialog->setServerNotification( false ); mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); + + +#ifndef DESKTOP_VERSION +//US listen for arriving address resultsets + connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), + this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); +#endif + } CalendarView::~CalendarView() { // kdDebug() << "~CalendarView()" << endl; @@ -1321,13 +1330,15 @@ void CalendarView::syncSharp() } //#include <kabc/stdaddressbook.h> bool CalendarView::importBday() { -#if 0 +#ifndef KORG_NOKABC + +#ifdef DESKTOP_VERSION KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); KABC::AddressBook::Iterator it; int count = 0; for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { ++count; } @@ -1362,16 +1373,104 @@ bool CalendarView::importBday() if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) ++addCount; } } updateView(); topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); -#endif +#else //DESKTOP_VERSION + + ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); + // the result should now arrive through method insertBirthdays + +#endif //DESKTOP_VERSION + +#endif //KORG_NOKABC + + return true; } +// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI +void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, + const QStringList& anniversaryList, const QStringList& realNameList, + const QStringList& emailList, const QStringList& assembledNameList, + const QStringList& uidList) +{ + qDebug("CalendarView::insertBirthdays"); + if (uid == this->name()) + { + int count = birthdayList.count(); + int addCount = 0; + KCal::Attendee* a = 0; + + qDebug("CalView 1 %i", count); + + QProgressBar bar(count,0 ); + int w = 300; + if ( QApplication::desktop()->width() < 320 ) + w = 220; + int h = bar.sizeHint().height() ; + int dw = QApplication::desktop()->width(); + int dh = QApplication::desktop()->height(); + bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + bar.show(); + bar.setCaption (i18n("inserting birthdays - close to abort!") ); + qApp->processEvents(); + + QDate birthday; + QDate anniversary; + QString realName; + QString email; + QString assembledName; + QString uid; + bool ok = true; + for ( int i = 0; i < count; i++) + { + if ( ! bar.isVisible() ) + return; + bar.setProgress( i ); + qApp->processEvents(); + + qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); + + birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); + if (!ok) + qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); + + anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); + if (!ok) + qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); + realName = realNameList[i]; + email = emailList[i]; + assembledName = assembledNameList[i]; + uid = uidList[i]; + + if ( birthday.isValid() ){ + a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, + KCal::Attendee::ReqParticipant,uid) ; + if ( addAnniversary( birthday, assembledName, a, true ) ) + ++addCount; + } + + if ( anniversary.isValid() ){ + a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, + KCal::Attendee::ReqParticipant,uid) ; + if ( addAnniversary( anniversary, assembledName, a, false ) ) + ++addCount; + } + } + + updateView(); + topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); + + } + +} + + + bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) { //qDebug("addAnni "); Event * ev = new Event(); if ( a ) { ev->addAttendee( a ); diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 0f7e696..8d329a9 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -180,12 +180,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void removeAlarm(const QDateTime &qdt, const QString ¬i ); /** options dialog made a changed to the configuration. we catch this * and notify all widgets which need to update their configuration. */ void updateConfig(); + void insertBirthdays(const QString& uid, const QStringList& birthdayList, + const QStringList& anniversaryList, const QStringList& realNameList, + const QStringList& emailList, const QStringList& assembledNameList, + const QStringList& uidList); + /** Load calendar from file \a filename. If \a merge is true, load calendar into existing one, if it is false, clear calendar, before loading. Return true, if calendar could be successfully loaded. */ bool openCalendar(QString filename, bool merge=false); |