--- /dev/null
+#include "contactinterface.h"
+#include "xmlcontroler.h"
+#include "xmlstring.h"
+
+ContactInterface* ContactInterface::instance = 0;
+
+ContactInterface* ContactInterface::getInstance()
+{
+ if( !instance )
+ {
+ instance = new ContactInterface();
+ }
+ return instance;
+}
+
+ContactInterface::ContactInterface(QObject *parent) :
+ QObject(parent)
+{
+ instance = this;
+
+ initEbook();
+}
+
+ContactInterface::~ContactInterface()
+{
+ for( int i = 0; i < all_contacts_items_db.size(); i++ )
+ {
+ delete all_contacts_items_db.at(i);
+ }
+ all_contacts_items_db.clear();
+}
+
+void ContactInterface::setItemObserver(ItemObserver *observer)
+{
+ XmlControler::getInstance()->setItemObserver( observer );
+}
+
+void ContactInterface::setItemSelectObserver( ItemSelectObserver *observer )
+{
+ XmlControler::getInstance()->setItemSelectObserver( observer );
+}
+
+bool ContactInterface::initEbook()
+{
+ //qDebug() << "ContactInterface::initEbook(), Entry";
+
+#ifdef ONLY_FOR_EBOOK
+ GError *error = NULL;
+ roster = osso_abook_aggregator_get_default(&error);
+ if( error )
+ {
+ //qDebug() << "Couldn't open roster %s\n" << error->message;
+ g_error_free( error );
+ }
+ osso_abook_roster_start(roster);
+
+ //qDebug() << "osso_abook_roster_start";
+
+ osso_abook_waitable_run(OSSO_ABOOK_WAITABLE(roster), g_main_context_default(), &error);
+
+ if (!osso_abook_waitable_is_ready(OSSO_ABOOK_WAITABLE(roster), &error) )
+ g_critical("osso_abook_waitable_is_ready: %s\n", error->message);
+
+ //* for test
+// OssoABookAggregator *_aggr;
+// GList *list, *c;
+// GError *err;
+
+// osso_abook_waitable_run(OSSO_ABOOK_WAITABLE(roster), g_main_context_default(), &err);
+
+// if (! osso_abook_waitable_is_ready(OSSO_ABOOK_WAITABLE(roster), &err))
+// g_critical("osso_abook_waitable_is_ready: %s\n", err->message);
+
+// _aggr = OSSO_ABOOK_AGGREGATOR(roster);
+// list = osso_abook_aggregator_list_master_contacts(_aggr);
+
+// printf("count = %d\n", g_list_length(list)); // list is not empty !
+
+// g_list_free(list);
+ //* test end
+#endif
+ return true;
+}
+
+bool ContactInterface::updateContactsFromEbookToXml()
+{
+ removeGroup( STR_XML_ALLCONTACTS );
+ getAllContacts();
+ addContactToGroup( all_contacts_items_db, STR_XML_ALLCONTACTS );
+ return true;
+}
+
+ItemListPtr ContactInterface::getAllContacts()
+{
+ //qDebug() << "ContactInterface::getAllContacts() from EBook, Entry";
+
+#ifdef ONLY_FOR_EBOOK
+ GList *list = NULL;
+ GList *it = NULL;
+ EContact *contact = NULL;
+ OssoABookAggregator *aggregator = OSSO_ABOOK_AGGREGATOR(roster);
+
+ list = osso_abook_aggregator_list_master_contacts( aggregator );
+
+ qDebug() << "get list from EBook";
+ //qDebug() << "list length is :" << g_list_length(list);
+
+ QString str;
+
+ for( it = list; it; it = it->next )
+ {
+ //qDebug() << "into list loop";
+
+ contact = (EContact *)it->data;
+ Item *item = new Item();
+
+ str = QString::fromLocal8Bit( (char*)e_contact_get(contact, E_CONTACT_FULL_NAME) );
+ item->full_name = str;
+ qDebug() << "fullname is : " << item->full_name;
+
+ str = QString::fromLocal8Bit( (char*)e_contact_get(contact, E_CONTACT_PHONE_MOBILE) );
+ item->mobile_number = str;
+ qDebug() << "mobile_number is : " << item->mobile_number;
+
+ item->group_owner = "";
+ item->user_pic_uri = ":/images/male.png";
+
+ item->uid = QString::fromLocal8Bit( (char*)e_contact_get(contact, E_CONTACT_UID) );
+ qDebug() << "uid is : " << item->uid;
+
+ all_contacts_items_db.append( item );
+ }
+
+ g_list_free( list );
+#endif
+ return all_contacts_items_db;
+}
+
+void ContactInterface::getAllContactsFromXml()
+{
+ //qDebug() << "ContactInterface::getAllContactsFromXml(), Entry";
+
+ XmlControler::getInstance()->getAllContactItems();
+}
+
+void ContactInterface::getAllContactsFromXml(const QString &groupname)
+{
+ //qDebug() << "ContactInterface::getAllContactsFromXml(const QString &groupname), Entry";
+
+ XmlControler::getInstance()->getAllContactItemsFromGroup(groupname);
+}
+
+QStringList ContactInterface::getAllGroupNames()
+{
+ //qDebug() << "ContactInterface::getAllGroupNames(), Entry";
+ return XmlControler::getInstance()->getAllGroupNames();
+}
+
+bool ContactInterface::createGroup(const QString &groupname)
+{
+ return XmlControler::getInstance()->createGroup(groupname);
+}
+
+bool ContactInterface::removeGroup(const QString &groupname)
+{
+ return XmlControler::getInstance()->removeGroup( groupname );
+}
+
+bool ContactInterface::addContactToGroup(ItemListPtr items, const QString &groupname)
+{
+ return XmlControler::getInstance()->createContact( groupname, items );
+}
+
+bool ContactInterface::removeContactToGroup( ItemListPtr items, const QString &groupname )
+{
+ return XmlControler::getInstance()->removeContactFromGroup( items, groupname );
+}
+
+bool ContactInterface::removeContactToGroup( ItemListPtr items )
+{
+ return XmlControler::getInstance()->removeContactFromGroup( items );
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+