[ekiga] Avahi: Various improvements and fixes.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Avahi: Various improvements and fixes.
- Date: Thu, 12 Nov 2015 18:37:33 +0000 (UTC)
commit cdb594a647177fdf29d49a4e77f009cacf3c0778
Author: Damien Sandras <dsandras seconix com>
Date: Tue Oct 13 20:03:01 2015 +0200
Avahi: Various improvements and fixes.
- Presentity is now using Actions.
- Presentity does not inherit from URIPresentity anymore. Removed the
latter from the engine.
- Fixed bugs with AvahiResolver preventing status changes to be
reflected in the roster.
lib/Makefile.am | 2 -
lib/engine/presence/uri-presentity.cpp | 130 --------------------------------
lib/engine/presence/uri-presentity.h | 113 ---------------------------
plugins/avahi/avahi-heap.cpp | 21 ++++--
plugins/avahi/avahi-heap.h | 1 +
plugins/avahi/avahi-presentity.cpp | 79 ++++++++++++++++++--
plugins/avahi/avahi-presentity.h | 34 ++++++++-
plugins/avahi/avahi-publisher.cpp | 3 +-
8 files changed, 121 insertions(+), 262 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 6f77b07..d46b2f4 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -244,8 +244,6 @@ libekiga_la_SOURCES += \
engine/presence/heap-impl.h \
engine/presence/cluster.h \
engine/presence/cluster-impl.h \
- engine/presence/uri-presentity.h \
- engine/presence/uri-presentity.cpp \
engine/presence/presence-core.h \
engine/presence/presence-core.cpp
diff --git a/plugins/avahi/avahi-heap.cpp b/plugins/avahi/avahi-heap.cpp
index 3d68baf..b5bc7ae 100644
--- a/plugins/avahi/avahi-heap.cpp
+++ b/plugins/avahi/avahi-heap.cpp
@@ -134,6 +134,9 @@ Avahi::Heap::Heap (Ekiga::ServiceCore & _core) : core(_core)
Avahi::Heap::~Heap ()
{
+ if (resolver != NULL)
+ avahi_service_resolver_free (resolver);
+
if (client != NULL)
avahi_client_free (client);
@@ -207,14 +210,14 @@ Avahi::Heap::BrowserCallback (AvahiServiceBrowser *browser,
const char *domain,
AvahiLookupResultFlags /*flags*/)
{
- AvahiServiceResolver *resolver = NULL;
-
switch (event) {
case AVAHI_BROWSER_NEW:
/* this may not be the final valid resolver pointer...
* we'll take what our callback gets
*/
+ if (resolver)
+ avahi_service_resolver_free (resolver);
resolver = avahi_service_resolver_new (client, interface, protocol,
name, type, domain,
AVAHI_PROTO_UNSPEC,
@@ -296,7 +299,7 @@ private:
};
void
-Avahi::Heap::ResolverCallback (AvahiServiceResolver *resolver,
+Avahi::Heap::ResolverCallback (AvahiServiceResolver * /*resolver*/,
AvahiIfIndex /*interface*/,
AvahiProtocol /*protocol*/,
AvahiResolverEvent event,
@@ -321,6 +324,7 @@ Avahi::Heap::ResolverCallback (AvahiServiceResolver *resolver,
if (flags & AVAHI_LOOKUP_RESULT_LOCAL) {
avahi_service_resolver_free (resolver);
+ resolver = NULL;
#if DEBUG
std::cout << __PRETTY_FUNCTION__ << " LOCAL RESULT" << std::endl;
#endif
@@ -329,7 +333,8 @@ Avahi::Heap::ResolverCallback (AvahiServiceResolver *resolver,
switch (event) {
- case AVAHI_RESOLVER_FOUND: {
+ case AVAHI_RESOLVER_FOUND:
+ {
#if DEBUG
std::cout << __PRETTY_FUNCTION__ << " AVAHI_RESOLVER_FOUND" << std::endl;
#endif
@@ -365,7 +370,8 @@ Avahi::Heap::ResolverCallback (AvahiServiceResolver *resolver,
/* known contact has been updated */
presence_received (helper.found_presentity ()->get_uri (), presence);
status_received (helper.found_presentity ()->get_uri (), status);
- } else {
+ }
+ else {
/* ok, this is a new contact */
gchar** broken = NULL;
@@ -385,14 +391,15 @@ Avahi::Heap::ResolverCallback (AvahiServiceResolver *resolver,
}
g_strfreev (broken);
}
- avahi_service_resolver_free (resolver);
- break;}
+ }
+ break;
case AVAHI_RESOLVER_FAILURE:
#if DEBUG
std::cout << __PRETTY_FUNCTION__ << " AVAHI_RESOLVER_FAILURE" << std::endl;
#endif
avahi_service_resolver_free (resolver);
+ resolver = NULL;
break;
default:
/* shouldn't happen */
diff --git a/plugins/avahi/avahi-heap.h b/plugins/avahi/avahi-heap.h
index b59c723..ce2a764 100644
--- a/plugins/avahi/avahi-heap.h
+++ b/plugins/avahi/avahi-heap.h
@@ -110,6 +110,7 @@ namespace Avahi
AvahiGLibPoll *poll;
AvahiClient *client;
+ AvahiServiceResolver *resolver;
Ekiga::ServiceCore &core;
diff --git a/plugins/avahi/avahi-presentity.cpp b/plugins/avahi/avahi-presentity.cpp
index 3136989..4663711 100644
--- a/plugins/avahi/avahi-presentity.cpp
+++ b/plugins/avahi/avahi-presentity.cpp
@@ -38,23 +38,90 @@
boost::shared_ptr<Avahi::Presentity>
-Avahi::Presentity::create (boost::shared_ptr<Ekiga::PresenceCore> _presence_core,
+Avahi::Presentity::create (boost::shared_ptr<Ekiga::PresenceCore> presence_core,
std::string _name,
std::string _uri,
std::list<std::string> _groups)
{
- return boost::shared_ptr<Avahi::Presentity> (new Avahi::Presentity (_presence_core, _name, _uri, _groups));
+ return boost::shared_ptr<Avahi::Presentity> (new Avahi::Presentity (presence_core, _name, _uri, _groups));
}
-
-Avahi::Presentity::Presentity (boost::shared_ptr<Ekiga::PresenceCore> _presence_core,
+Avahi::Presentity::Presentity (boost::shared_ptr<Ekiga::PresenceCore> presence_core,
std::string _name,
std::string _uri,
- std::list<std::string> _groups) : URIPresentity (_presence_core, _name, _uri,
_groups)
+ std::list<std::string> _groups)
+ : name(_name), uri(_uri), presence("unknown"), groups(_groups)
{
-}
+ boost::signals2::connection conn;
+
+ conn = presence_core->presence_received.connect (boost::bind (&Avahi::Presentity::on_presence_received,
this, _1, _2));
+ connections.add (conn);
+
+ conn = presence_core->status_received.connect (boost::bind (&Avahi::Presentity::on_status_received, this,
_1, _2));
+ connections.add (conn);
+ presence_core->pull_actions (*this, _name, _uri);
+}
Avahi::Presentity::~Presentity ()
{
}
+
+
+const std::string
+Avahi::Presentity::get_name () const
+{
+ return name;
+}
+
+const std::string
+Avahi::Presentity::get_presence () const
+{
+ return presence;
+}
+
+const std::string
+Avahi::Presentity::get_status () const
+{
+ return status;
+}
+
+const std::list<std::string>
+Avahi::Presentity::get_groups () const
+{
+ return groups;
+}
+
+const std::string
+Avahi::Presentity::get_uri () const
+{
+ return uri;
+}
+
+bool
+Avahi::Presentity::has_uri (const std::string uri_) const
+{
+ return uri == uri_;
+}
+
+void
+Avahi::Presentity::on_presence_received (std::string uri_,
+ std::string presence_)
+{
+ if (uri == uri_) {
+
+ presence = presence_;
+ updated (this->shared_from_this ());
+ }
+}
+
+void
+Avahi::Presentity::on_status_received (std::string uri_,
+ std::string status_)
+{
+ if (uri == uri_) {
+
+ status = status_;
+ updated (this->shared_from_this ());
+ }
+}
diff --git a/plugins/avahi/avahi-presentity.h b/plugins/avahi/avahi-presentity.h
index 7c6502d..fa4a690 100644
--- a/plugins/avahi/avahi-presentity.h
+++ b/plugins/avahi/avahi-presentity.h
@@ -38,14 +38,14 @@
#define __AVAHI_PRESENTITY_H__
#include "dynamic-object.h"
-#include "uri-presentity.h"
+#include "presentity.h"
#include "presence-core.h"
namespace Avahi
{
class Presentity:
- public Ekiga::URIPresentity,
+ public Ekiga::Presentity,
public Ekiga::DynamicObject<Presentity>
{
@@ -57,6 +57,36 @@ public:
~Presentity ();
+ /**
+ * Getters for the presentity
+ */
+ const std::string get_name () const;
+
+ const std::string get_presence () const;
+
+ const std::string get_status () const;
+
+ const std::list<std::string> get_groups () const;
+
+ bool has_uri (const std::string uri_) const;
+
+ const std::string get_uri () const;
+
+ private:
+ Ekiga::scoped_connections connections;
+
+ std::string name;
+ std::string uri;
+ std::string presence;
+ std::list<std::string> groups;
+ std::string status;
+
+ void on_presence_received (std::string uri_,
+ std::string presence_);
+
+ void on_status_received (std::string uri_,
+ std::string status_);
+
private:
Presentity (boost::shared_ptr<Ekiga::PresenceCore> presence_core,
std::string name,
diff --git a/plugins/avahi/avahi-publisher.cpp b/plugins/avahi/avahi-publisher.cpp
index 3699452..37d10c7 100644
--- a/plugins/avahi/avahi-publisher.cpp
+++ b/plugins/avahi/avahi-publisher.cpp
@@ -62,8 +62,7 @@ entry_group_cb (AvahiEntryGroup* group,
publisher->entry_group_callback (group, state);
}
-/* here is the real code of the Avahi::PresencePublisher implementation */
-
+/* Here is the real code of the Avahi::PresencePublisher implementation */
Avahi::PresencePublisher::PresencePublisher (Ekiga::ServiceCore& core_,
Ekiga::PersonalDetails& details_,
Ekiga::CallCore& call_core_):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]