summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-07 01:10:30 (UTC)
committer ulf69 <ulf69>2004-10-07 01:10:30 (UTC)
commitf434ef382b60c1a420dd0e037d119d082e478491 (patch) (side-by-side diff)
treec68247486b6f714d0d8e01d8b503a4d36c9325e3
parent3338b7239dc2e5cdff95ebc76b6905e6385a5833 (diff)
downloadkdepimpi-f434ef382b60c1a420dd0e037d119d082e478491.zip
kdepimpi-f434ef382b60c1a420dd0e037d119d082e478491.tar.gz
kdepimpi-f434ef382b60c1a420dd0e037d119d082e478491.tar.bz2
added methods to collect birthday data via QCop (from kopi)
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
@@ -290,12 +290,13 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
SLOT( sendMail( const QString& ) ) );
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& ) ),
mXXPortManager, SLOT( importVCard( const KURL& ) ) );
@@ -2152,12 +2153,80 @@ 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)
{
qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index e6f286b..c9c0d38 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -332,12 +332,13 @@ class KABCore : public QWidget, public KSyncInterface
Registers a new GUI client, so plugins can register its actions.
*/
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 );
void contactSelected( const QPixmap &pixmap );
public slots: