[ekiga] Made Ekiga::URIPresentity not use the core, and made the Opal SIP text messages code cope with it
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Made Ekiga::URIPresentity not use the core, and made the Opal SIP text messages code cope with it
- Date: Fri, 25 Jan 2013 13:39:39 +0000 (UTC)
commit 93868915225e1039487110a6b32f11301687c024
Author: Julien Puydt <jpuydt free fr>
Date: Fri Jan 25 09:22:17 2013 +0100
Made Ekiga::URIPresentity not use the core, and made the Opal SIP text messages code cope with it
lib/engine/components/opal/sip-chat-simple.cpp | 12 ++++++---
lib/engine/components/opal/sip-chat-simple.h | 11 +++++++-
lib/engine/components/opal/sip-dialect.cpp | 27 ++++++++++++++++------
lib/engine/components/opal/sip-dialect.h | 3 +-
lib/engine/presence/uri-presentity.cpp | 28 ++++++++++++-----------
lib/engine/presence/uri-presentity.h | 4 +-
6 files changed, 55 insertions(+), 30 deletions(-)
---
diff --git a/lib/engine/components/opal/sip-chat-simple.cpp b/lib/engine/components/opal/sip-chat-simple.cpp
index 092b6a0..7af1bad 100644
--- a/lib/engine/components/opal/sip-chat-simple.cpp
+++ b/lib/engine/components/opal/sip-chat-simple.cpp
@@ -39,11 +39,12 @@
#include "uri-presentity.h"
#include "personal-details.h"
-SIP::SimpleChat::SimpleChat (Ekiga::ServiceCore& core_,
+SIP::SimpleChat::SimpleChat (boost::shared_ptr<Ekiga::PresenceCore> core,
+ boost::shared_ptr<Ekiga::PersonalDetails> details,
std::string name,
std::string uri_,
- boost::function1<bool, std::string> sender_)
- : core(core_), sender(sender_), uri(uri_)
+ boost::function1<bool, std::string> sender_):
+ personal_details(details), sender(sender_), uri(uri_)
{
presentity = boost::shared_ptr<Ekiga::URIPresentity> (new Ekiga::URIPresentity (core, name, uri,
std::set<std::string>()));
@@ -85,7 +86,10 @@ bool
SIP::SimpleChat::send_message (const std::string msg)
{
bool result;
- boost::shared_ptr<Ekiga::PersonalDetails> personal = core.get<Ekiga::PersonalDetails> ("personal-details");
+ boost::shared_ptr<Ekiga::PersonalDetails> personal = personal_details.lock ();
+ if (!personal)
+ return false;
+
result = sender (msg);
for (std::list<boost::shared_ptr<Ekiga::ChatObserver> >::iterator iter = observers.begin ();
iter != observers.end ();
diff --git a/lib/engine/components/opal/sip-chat-simple.h b/lib/engine/components/opal/sip-chat-simple.h
index fd2f110..5b50169 100644
--- a/lib/engine/components/opal/sip-chat-simple.h
+++ b/lib/engine/components/opal/sip-chat-simple.h
@@ -41,12 +41,19 @@
#include "chat-simple.h"
#include "services.h"
+namespace Ekiga
+{
+ class PersonalDetails;
+ class PresenceCore;
+};
+
namespace SIP
{
class SimpleChat: public Ekiga::SimpleChat
{
public:
- SimpleChat (Ekiga::ServiceCore& core,
+ SimpleChat (boost::shared_ptr<Ekiga::PresenceCore> presence_core,
+ boost::shared_ptr<Ekiga::PersonalDetails> personal_details,
std::string name,
std::string uri,
boost::function1<bool, std::string> sender_);
@@ -73,7 +80,7 @@ namespace SIP
private:
- Ekiga::ServiceCore& core;
+ boost::weak_ptr<Ekiga::PersonalDetails> personal_details;
boost::function1<bool, std::string> sender;
std::list<boost::shared_ptr<Ekiga::ChatObserver> > observers;
Ekiga::PresentityPtr presentity;
diff --git a/lib/engine/components/opal/sip-dialect.cpp b/lib/engine/components/opal/sip-dialect.cpp
index bb81b42..2aba323 100644
--- a/lib/engine/components/opal/sip-dialect.cpp
+++ b/lib/engine/components/opal/sip-dialect.cpp
@@ -38,10 +38,14 @@
#include "config.h"
#include "sip-dialect.h"
-
-SIP::Dialect::Dialect (Ekiga::ServiceCore& core_,
- boost::function2<bool, std::string, std::string> sender_)
- : core(core_), sender(sender_)
+#include "presence-core.h"
+#include "personal-details.h"
+
+SIP::Dialect::Dialect (Ekiga::ServiceCore& core,
+ boost::function2<bool, std::string, std::string> sender_):
+ presence_core(core.get<Ekiga::PresenceCore> ("presence-core")),
+ personal_details(core.get<Ekiga::PersonalDetails> ("personal-details")),
+ sender(sender_)
{
}
@@ -58,7 +62,8 @@ SIP::Dialect::push_message (const std::string uri,
chat = open_chat_with (uri, name, false);
- chat->receive_message (msg);
+ if (chat)
+ chat->receive_message (msg);
}
void
@@ -101,11 +106,17 @@ SIP::Dialect::open_chat_with (std::string uri,
if ( !result) {
- result = SimpleChatPtr (new SimpleChat (core, name, uri, boost::bind(sender, uri, _1)));
- add_simple_chat (result);
+ boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
+ boost::shared_ptr<Ekiga::PersonalDetails> details = personal_details.lock ();
+ if (pcore && details) {
+
+ result = SimpleChatPtr (new SimpleChat (pcore, details, name, uri,
+ boost::bind(sender, uri, _1)));
+ add_simple_chat (result);
+ }
}
- if (user_request)
+ if (user_request && result)
result->user_requested ();
return result;
diff --git a/lib/engine/components/opal/sip-dialect.h b/lib/engine/components/opal/sip-dialect.h
index d42c42a..6ebcded 100644
--- a/lib/engine/components/opal/sip-dialect.h
+++ b/lib/engine/components/opal/sip-dialect.h
@@ -66,7 +66,8 @@ namespace SIP
std::string name);
private:
- Ekiga::ServiceCore& core;
+ boost::weak_ptr<Ekiga::PresenceCore> presence_core;
+ boost::weak_ptr<Ekiga::PersonalDetails> personal_details;
/* the strings are : uri then msg */
boost::function2<bool, std::string, std::string> sender;
diff --git a/lib/engine/presence/uri-presentity.cpp b/lib/engine/presence/uri-presentity.cpp
index b10e471..a80a7b1 100644
--- a/lib/engine/presence/uri-presentity.cpp
+++ b/lib/engine/presence/uri-presentity.cpp
@@ -45,23 +45,22 @@ struct null_deleter
}
};
-Ekiga::URIPresentity::URIPresentity (Ekiga::ServiceCore &_core,
+Ekiga::URIPresentity::URIPresentity (boost::shared_ptr<Ekiga::PresenceCore> pcore,
std::string name_,
std::string uri_,
- std::set<std::string> groups_)
- : core(_core), name(name_), uri(uri_), presence("unknown"), groups(groups_)
+ std::set<std::string> groups_):
+ presence_core(pcore), name(name_), uri(uri_), presence("unknown"), groups(groups_)
{
- boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");
- presence_core->presence_received.connect (boost::bind (&Ekiga::URIPresentity::on_presence_received, this, _1, _2));
- presence_core->status_received.connect (boost::bind (&Ekiga::URIPresentity::on_status_received, this, _1, _2));
- presence_core->fetch_presence (uri);
+ pcore->presence_received.connect (boost::bind (&Ekiga::URIPresentity::on_presence_received, this, _1, _2));
+ pcore->status_received.connect (boost::bind (&Ekiga::URIPresentity::on_status_received, this, _1, _2));
+ pcore->fetch_presence (uri);
}
Ekiga::URIPresentity::~URIPresentity ()
{
- boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");
- if (presence_core)
- presence_core->unfetch_presence (uri);
+ boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
+ if (pcore)
+ pcore->unfetch_presence (uri);
}
const std::string
@@ -103,9 +102,12 @@ Ekiga::URIPresentity::has_uri (const std::string uri_) const
bool
Ekiga::URIPresentity::populate_menu (Ekiga::MenuBuilder &builder)
{
- boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");
- return presence_core->populate_presentity_menu (PresentityPtr(this, null_deleter ()),
- uri, builder);
+ boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
+ if (pcore)
+ return pcore->populate_presentity_menu (PresentityPtr(this, null_deleter ()),
+ uri, builder);
+ else
+ return false;
}
void
diff --git a/lib/engine/presence/uri-presentity.h b/lib/engine/presence/uri-presentity.h
index 6300a70..9d3f0bb 100644
--- a/lib/engine/presence/uri-presentity.h
+++ b/lib/engine/presence/uri-presentity.h
@@ -67,7 +67,7 @@ namespace Ekiga
/**
* Constructor and destructor
*/
- URIPresentity (Ekiga::ServiceCore& _core,
+ URIPresentity (boost::shared_ptr<Ekiga::PresenceCore> _presence_core,
std::string name_,
std::string uri_,
std::set<std::string> groups_);
@@ -97,7 +97,7 @@ namespace Ekiga
private:
- Ekiga::ServiceCore &core;
+ boost::weak_ptr<Ekiga::PresenceCore> presence_core;
std::string name;
std::string uri;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]