summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp69
-rw-r--r--kaddressbook/kabcore.h1
2 files changed, 70 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 9041e45..d9eb391 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -292,8 +292,9 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
+ connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
#ifndef KAB_EMBEDDED
connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
@@ -2154,8 +2155,76 @@ void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QSt
bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
}
+/* this method will be called through the QCop interface from Ko/Pi to select birthdays
+ * to put them into the calendar.
+ */
+void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
+{
+ // qDebug("KABCore::requestForBirthdayList");
+ QStringList birthdayList;
+ QStringList anniversaryList;
+ QStringList realNameList;
+ QStringList preferredEmailList;
+ QStringList assembledNameList;
+ QStringList uidList;
+
+ KABC::AddressBook::Iterator it;
+
+ int count = 0;
+ for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
+ ++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("collecting birthdays - close to abort!") );
+ qApp->processEvents();
+
+ QDate bday;
+ QString anni;
+ QString formattedbday;
+
+ for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
+ {
+ if ( ! bar.isVisible() )
+ return;
+ bar.setProgress( count++ );
+ qApp->processEvents();
+ bday = (*it).birthday().date();
+ anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
+
+ if ( bday.isValid() || !anni.isEmpty())
+ {
+ if (bday.isValid())
+ formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
+ else
+ formattedbday = "NOTVALID";
+ if (anni.isEmpty())
+ anni = "INVALID";
+
+ birthdayList.append(formattedbday);
+ anniversaryList.append(anni); //should be ISODate
+ realNameList.append((*it).realName());
+ preferredEmailList.append((*it).preferredEmail());
+ assembledNameList.append((*it).assembledName());
+ uidList.append((*it).uid());
+
+ qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
+ }
+ }
+
+ bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
+
+}
+
/* this method will be called through the QCop interface from other apps to show details of a contact.
*/
void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
{
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index e6f286b..c9c0d38 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -334,8 +334,9 @@ class KABCore : public QWidget, public KSyncInterface
void addGUIClient( KXMLGUIClient *client );
void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
+ void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
signals:
void contactSelected( const QString &name );