[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    [Kde-pim] kaddressbook patch
From:       Eduardo Dominguez <edmz () yahoo ! com>
Date:       2001-11-27 19:45:34
[Download RAW message or body]

this patch is against kde 2.2.2...
it adds a function to kaddresbook called getNameByPhone() and a dcop
interface for it. 
This is my first attempt at doing such a thing and I think it went
ok.

Comments are appreciated.

In case you are wondering what this is for, well its for a small
caller-id application that needs the name of the caller. I know
that in some countries caller-id comes already with the name of the
caller, but all countries offer that info.

Thanks in advance.

Any comments, please reply directly as I am not subscribed.

--
edmz



["kaddressbook-getnamebyphone.patch" (kaddressbook-getnamebyphone.patch)]

? kaddressbook-getnamebyphone.patch
Index: kaddressbook.cpp
===================================================================
RCS file: /home/kde/kdebase/kaddressbook/kaddressbook.cpp,v
retrieving revision 1.5
diff -u -b -p -u -r1.5 kaddressbook.cpp
--- kaddressbook.cpp	2001/06/05 16:17:06	1.5
+++ kaddressbook.cpp	2001/11/27 20:07:24
@@ -7,6 +7,7 @@
 #include "browserentryeditor.h"
 
 #include <qkeycode.h>
+#include <qregexp.h>
 
 #include <kiconloader.h>
 #include <klocale.h>
@@ -434,4 +435,39 @@ void KAddressBook::exportCSV()
   }
 }
 
+QString KAddressBook::getNameByPhone( QString phone )
+{
+	QStringList keys = mDocument->keys();
+  QStringList::ConstIterator it = keys.begin();
+  QStringList::ConstIterator end = keys.end();
+
+  QRegExp r("[/*/-]");
+
+	bool bSuccess = false;
+	QString ownerName = "";	
+  do{
+  	ContactEntry *entry = mDocument->find(*it);
+  	
+  	QString homePhone   = entry->getHomePhone();
+  	QString mobilePhone = entry->getMobilePhone();
+  	QString bizPhone    = entry->getBusinessPhone();
+  	
+  	homePhone = homePhone.stripWhiteSpace();
+  	homePhone.replace( r, "" );
+  	
+  	bizPhone = bizPhone.stripWhiteSpace();
+  	bizPhone.replace( r, "" );
+  	
+  	mobilePhone = mobilePhone.stripWhiteSpace();
+  	mobilePhone.replace( r, "" );
+  	
+  	if( (homePhone == phone) || (mobilePhone == phone) || (bizPhone ==phone) ){
+  		bSuccess = true;
+  		ownerName = entry->getFirstName() + QString(" ") + entry->getLastName();
+  	}
+  	++it;
+  }while( it!=end && !bSuccess );
+
+  return ownerName;
+}
 #include "kaddressbook.moc"
Index: kaddressbook.h
===================================================================
RCS file: /home/kde/kdebase/kaddressbook/kaddressbook.h,v
retrieving revision 1.2
diff -u -b -p -u -r1.2 kaddressbook.h
--- kaddressbook.h	2001/05/30 22:55:21	1.2
+++ kaddressbook.h	2001/11/27 20:07:25
@@ -58,6 +58,7 @@ class KAddressBook : public KMainWindow,
     void importCSV();
     /** Export comma-seperated list of all addressbook entries. */
     void exportCSV();
+    QString getNameByPhone( QString phone );
     void exit();
 
   protected:
Index: kaddressbookiface.h
===================================================================
RCS file: /home/kde/kdebase/kaddressbook/kaddressbookiface.h,v
retrieving revision 1.1
diff -u -b -p -u -r1.1 kaddressbookiface.h
--- kaddressbookiface.h	2001/05/28 22:32:07	1.1
+++ kaddressbookiface.h	2001/11/27 20:07:25
@@ -25,6 +25,7 @@ class KAddressBookIface : virtual public
     virtual void changeEntry( QString key, ContactEntry changeEntry) = 0;
     virtual void removeEntry( QString key ) = 0;
   /** Save changes to the address book files */
+  	virtual QString getNameByPhone( QString phone ) = 0;
     virtual void save() = 0;
     virtual void exit() = 0;
 };

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic