summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp103
-rw-r--r--korganizer/calendarview.h5
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
@@ -84,4 +84,5 @@
#ifndef DESKTOP_VERSION
#include <libkcal/sharpformat.h>
+#include <externalapphandler.h>
#endif
#include <libkcal/phoneformat.h>
@@ -463,4 +464,12 @@ void CalendarView::init()
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
+
}
@@ -1325,5 +1334,7 @@ void CalendarView::syncSharp()
bool CalendarView::importBday()
{
-#if 0
+#ifndef KORG_NOKABC
+
+#ifdef DESKTOP_VERSION
KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
KABC::AddressBook::Iterator it;
@@ -1366,8 +1377,96 @@ bool CalendarView::importBday()
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)
{
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 0f7e696..8d329a9 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -184,4 +184,9 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
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