summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (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
@@ -80,12 +80,13 @@
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h>
86#endif 87#endif
87#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
88#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
89#include "komailclient.h" 90#include "komailclient.h"
90#endif 91#endif
91#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
@@ -459,12 +460,20 @@ void CalendarView::init()
459 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 460 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
460 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 461 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
461 mAlarmDialog = new AlarmDialog( this ); 462 mAlarmDialog = new AlarmDialog( this );
462 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 463 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
463 mAlarmDialog->setServerNotification( false ); 464 mAlarmDialog->setServerNotification( false );
464 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 465 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
466
467
468#ifndef DESKTOP_VERSION
469//US listen for arriving address resultsets
470 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
471 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
472#endif
473
465} 474}
466 475
467 476
468CalendarView::~CalendarView() 477CalendarView::~CalendarView()
469{ 478{
470 // kdDebug() << "~CalendarView()" << endl; 479 // kdDebug() << "~CalendarView()" << endl;
@@ -1321,13 +1330,15 @@ void CalendarView::syncSharp()
1321} 1330}
1322 1331
1323 1332
1324//#include <kabc/stdaddressbook.h> 1333//#include <kabc/stdaddressbook.h>
1325bool CalendarView::importBday() 1334bool CalendarView::importBday()
1326{ 1335{
1327#if 0 1336#ifndef KORG_NOKABC
1337
1338#ifdef DESKTOP_VERSION
1328 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1339 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1329 KABC::AddressBook::Iterator it; 1340 KABC::AddressBook::Iterator it;
1330 int count = 0; 1341 int count = 0;
1331 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1342 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1332 ++count; 1343 ++count;
1333 } 1344 }
@@ -1362,16 +1373,104 @@ bool CalendarView::importBday()
1362 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1373 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1363 ++addCount; 1374 ++addCount;
1364 } 1375 }
1365 } 1376 }
1366 updateView(); 1377 updateView();
1367 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1378 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1368#endif 1379#else //DESKTOP_VERSION
1380
1381 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1382 // the result should now arrive through method insertBirthdays
1383
1384#endif //DESKTOP_VERSION
1385
1386#endif //KORG_NOKABC
1387
1388
1369 return true; 1389 return true;
1370} 1390}
1371 1391
1392// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1393void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1394 const QStringList& anniversaryList, const QStringList& realNameList,
1395 const QStringList& emailList, const QStringList& assembledNameList,
1396 const QStringList& uidList)
1397{
1398 qDebug("CalendarView::insertBirthdays");
1399 if (uid == this->name())
1400 {
1401 int count = birthdayList.count();
1402 int addCount = 0;
1403 KCal::Attendee* a = 0;
1404
1405 qDebug("CalView 1 %i", count);
1406
1407 QProgressBar bar(count,0 );
1408 int w = 300;
1409 if ( QApplication::desktop()->width() < 320 )
1410 w = 220;
1411 int h = bar.sizeHint().height() ;
1412 int dw = QApplication::desktop()->width();
1413 int dh = QApplication::desktop()->height();
1414 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1415 bar.show();
1416 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1417 qApp->processEvents();
1418
1419 QDate birthday;
1420 QDate anniversary;
1421 QString realName;
1422 QString email;
1423 QString assembledName;
1424 QString uid;
1425 bool ok = true;
1426 for ( int i = 0; i < count; i++)
1427 {
1428 if ( ! bar.isVisible() )
1429 return;
1430 bar.setProgress( i );
1431 qApp->processEvents();
1432
1433 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() );
1434
1435 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1436 if (!ok)
1437 qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1438
1439 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1440 if (!ok)
1441 qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1442 realName = realNameList[i];
1443 email = emailList[i];
1444 assembledName = assembledNameList[i];
1445 uid = uidList[i];
1446
1447 if ( birthday.isValid() ){
1448 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1449 KCal::Attendee::ReqParticipant,uid) ;
1450 if ( addAnniversary( birthday, assembledName, a, true ) )
1451 ++addCount;
1452 }
1453
1454 if ( anniversary.isValid() ){
1455 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1456 KCal::Attendee::ReqParticipant,uid) ;
1457 if ( addAnniversary( anniversary, assembledName, a, false ) )
1458 ++addCount;
1459 }
1460 }
1461
1462 updateView();
1463 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1464
1465 }
1466
1467}
1468
1469
1470
1372bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1471bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1373{ 1472{
1374 //qDebug("addAnni "); 1473 //qDebug("addAnni ");
1375 Event * ev = new Event(); 1474 Event * ev = new Event();
1376 if ( a ) { 1475 if ( a ) {
1377 ev->addAttendee( a ); 1476 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
180 void removeAlarm(const QDateTime &qdt, const QString &noti ); 180 void removeAlarm(const QDateTime &qdt, const QString &noti );
181 181
182 /** options dialog made a changed to the configuration. we catch this 182 /** options dialog made a changed to the configuration. we catch this
183 * and notify all widgets which need to update their configuration. */ 183 * and notify all widgets which need to update their configuration. */
184 void updateConfig(); 184 void updateConfig();
185 185
186 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
187 const QStringList& anniversaryList, const QStringList& realNameList,
188 const QStringList& emailList, const QStringList& assembledNameList,
189 const QStringList& uidList);
190
186 /** 191 /**
187 Load calendar from file \a filename. If \a merge is true, load 192 Load calendar from file \a filename. If \a merge is true, load
188 calendar into existing one, if it is false, clear calendar, before 193 calendar into existing one, if it is false, clear calendar, before
189 loading. Return true, if calendar could be successfully loaded. 194 loading. Return true, if calendar could be successfully loaded.
190 */ 195 */
191 bool openCalendar(QString filename, bool merge=false); 196 bool openCalendar(QString filename, bool merge=false);