summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show 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
@@ -78,16 +78,17 @@
#include <libkcal/freebusy.h>
#include <libkcal/filestorage.h>
#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
#include "calprinter.h"
#endif
@@ -457,16 +458,24 @@ void CalendarView::init()
mRecheckAlarmTimer = new QTimer( this );
connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
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;
//qDebug("CalendarView::~CalendarView() ");
delete mDialogManager;
@@ -1319,17 +1328,19 @@ void CalendarView::syncSharp()
syncExternal( 0 );
}
//#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;
}
QProgressBar bar(count,0 );
int w = 300;
@@ -1360,20 +1371,108 @@ bool CalendarView::importBday()
if ( anni.isValid() ){
a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
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 );
}
QString kind;
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 0f7e696..8d329a9 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -178,16 +178,21 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
void addAlarm(const QDateTime &qdt, const QString &noti );
void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
void removeAlarm(const QDateTime &qdt, const QString &noti );
/** 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);
bool syncCalendar(QString filename,int mode = 0 );