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
@@ -284,24 +284,25 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
SLOT( incrementalSearch( const QString& ) ) );
connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
mJumpButtonBar, SLOT( recreateButtons() ) );
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& ) ) );
connect( mDetails, SIGNAL( browse( const QString& ) ),
SLOT( browse( const QString& ) ) );
mAddressBookService = new KAddressBookService( this );
@@ -2146,24 +2147,92 @@ void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QSt
uint i=0;
for (i=0; i < list.count(); i++)
{
nameList.append(list[i].realName());
emailList.append(list[i].preferredEmail());
uidList.append(list[i].uid());
}
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());
QString foundUid = QString::null;
if ( ! uid.isEmpty() ) {
Addressee adrr = mAddressBook->findByUid( uid );
if ( !adrr.isEmpty() ) {
foundUid = uid;
}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index e6f286b..c9c0d38 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -326,24 +326,25 @@ class KABCore : public QWidget, public KSyncInterface
Creates a KAddressBookPrinter, which will display the print
dialog and do the printing.
*/
void print();
/**
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:
void setDetailsVisible( bool visible );
void setDetailsToState();
// void slotSyncMenu( int );
private slots:
void setJumpButtonBarVisible( bool visible );
void importFromOL();