[ekiga] Made the call history code fetch engine services at startup
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Made the call history code fetch engine services at startup
- Date: Wed, 23 Jan 2013 16:56:42 +0000 (UTC)
commit a27935106bd66b0ca75daecab54a04691fc09e8f
Author: Julien Puydt <jpuydt free fr>
Date: Wed Jan 23 17:46:35 2013 +0100
Made the call history code fetch engine services at startup
.../components/call-history/history-book.cpp | 12 ++++++----
lib/engine/components/call-history/history-book.h | 2 +-
.../components/call-history/history-contact.cpp | 21 +++++++++++--------
.../components/call-history/history-contact.h | 6 ++--
4 files changed, 23 insertions(+), 18 deletions(-)
---
diff --git a/lib/engine/components/call-history/history-book.cpp b/lib/engine/components/call-history/history-book.cpp
index 6fc1b63..4f23e55 100644
--- a/lib/engine/components/call-history/history-book.cpp
+++ b/lib/engine/components/call-history/history-book.cpp
@@ -45,8 +45,8 @@
#include "history-book.h"
-History::Book::Book (Ekiga::ServiceCore &_core) :
- core(_core), doc()
+History::Book::Book (Ekiga::ServiceCore& core):
+ contact_core(core.get<Ekiga::ContactCore>("contact-core")), doc()
{
xmlNodePtr root = NULL;
@@ -113,7 +113,8 @@ History::Book::visit_contacts (boost::function1<bool, Ekiga::ContactPtr> visitor
void
History::Book::add (xmlNodePtr node)
{
- common_add (ContactPtr (new Contact (core, doc, node)));
+ boost::shared_ptr<Ekiga::ContactCore> ccore = contact_core.lock ();
+ common_add (ContactPtr (new Contact (ccore, doc, node)));
}
void
@@ -123,13 +124,14 @@ History::Book::add (const std::string & name,
const std::string & call_duration,
const call_type c_t)
{
+ boost::shared_ptr<Ekiga::ContactCore> ccore = contact_core.lock ();
if ( !uri.empty ()) {
xmlNodePtr root = xmlDocGetRootElement (doc.get ());
- ContactPtr contact(new Contact (core, doc, name, uri,
- call_start, call_duration, c_t));
+ ContactPtr contact(new Contact (ccore, doc, name, uri,
+ call_start, call_duration, c_t));
xmlAddChild (root, contact->get_node ());
diff --git a/lib/engine/components/call-history/history-book.h b/lib/engine/components/call-history/history-book.h
index 91b7e33..8acf3dc 100644
--- a/lib/engine/components/call-history/history-book.h
+++ b/lib/engine/components/call-history/history-book.h
@@ -107,7 +107,7 @@ namespace History
void enforce_size_limit();
- Ekiga::ServiceCore &core;
+ boost::weak_ptr<Ekiga::ContactCore> contact_core;
boost::shared_ptr<xmlDoc> doc;
std::list<ContactPtr> ordered_contacts;
};
diff --git a/lib/engine/components/call-history/history-contact.cpp b/lib/engine/components/call-history/history-contact.cpp
index 6d6c683..fc28090 100644
--- a/lib/engine/components/call-history/history-contact.cpp
+++ b/lib/engine/components/call-history/history-contact.cpp
@@ -54,13 +54,12 @@ struct null_deleter
};
-History::Contact::Contact (Ekiga::ServiceCore &_core,
+History::Contact::Contact (boost::shared_ptr<Ekiga::ContactCore> _contact_core,
boost::shared_ptr<xmlDoc> _doc,
xmlNodePtr _node):
- core(_core), doc(_doc), node(_node)
+ contact_core(_contact_core), doc(_doc), node(_node)
{
xmlChar* xml_str = NULL;
- boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get<Ekiga::ContactCore> ("contact-core");
xml_str = xmlGetProp (node, (const xmlChar *)"type");
if (xml_str != NULL) {
@@ -111,18 +110,18 @@ History::Contact::Contact (Ekiga::ServiceCore &_core,
}
-History::Contact::Contact (Ekiga::ServiceCore &_core,
+History::Contact::Contact (boost::shared_ptr<Ekiga::ContactCore> _contact_core,
boost::shared_ptr<xmlDoc> _doc,
const std::string _name,
const std::string _uri,
time_t _call_start,
const std::string _call_duration,
call_type c_t):
- core(_core), doc(_doc), name(_name), uri(_uri), call_start(_call_start), call_duration(_call_duration), m_type(c_t)
+ contact_core(_contact_core), doc(_doc),
+ name(_name), uri(_uri), call_start(_call_start), call_duration(_call_duration), m_type(c_t)
{
gchar* tmp = NULL;
std::string callp;
- boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get<Ekiga::ContactCore> ("contact-core");
node = xmlNewNode (NULL, BAD_CAST "entry");
@@ -187,9 +186,13 @@ History::Contact::get_groups () const
bool
History::Contact::populate_menu (Ekiga::MenuBuilder &builder)
{
- boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get<Ekiga::ContactCore> ("contact-core");
- return contact_core->populate_contact_menu (ContactPtr (this, null_deleter ()),
- uri, builder);
+
+ boost::shared_ptr<Ekiga::ContactCore> ccore = contact_core.lock ();
+ if (ccore)
+ return ccore->populate_contact_menu (ContactPtr (this, null_deleter ()),
+ uri, builder);
+ else
+ return false;
}
xmlNodePtr
diff --git a/lib/engine/components/call-history/history-contact.h b/lib/engine/components/call-history/history-contact.h
index d109f6b..3836659 100644
--- a/lib/engine/components/call-history/history-contact.h
+++ b/lib/engine/components/call-history/history-contact.h
@@ -65,11 +65,11 @@ namespace History
{
public:
- Contact (Ekiga::ServiceCore &_core,
+ Contact (boost::shared_ptr<Ekiga::ContactCore> _contact_core,
boost::shared_ptr<xmlDoc> _doc,
xmlNodePtr _node);
- Contact (Ekiga::ServiceCore &_core,
+ Contact (boost::shared_ptr<Ekiga::ContactCore> _contact_core,
boost::shared_ptr<xmlDoc> _doc,
const std::string _name,
const std::string _uri,
@@ -101,7 +101,7 @@ namespace History
private:
- Ekiga::ServiceCore &core;
+ boost::weak_ptr<Ekiga::ContactCore> contact_core;
boost::shared_ptr<xmlDoc> doc;
xmlNodePtr node;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]