[ekiga] Loudmouth: added an helper which simplifies a small function and will make things easier elsewhere
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Loudmouth: added an helper which simplifies a small function and will make things easier elsewhere
- Date: Mon, 6 Jan 2014 08:29:50 +0000 (UTC)
commit faa44264643965bb2631d7fde634b897890f20e2
Author: Julien Puydt <jpuydt free fr>
Date: Sun Jan 5 10:00:39 2014 +0100
Loudmouth: added an helper which simplifies a small function and will make things easier elsewhere
plugins/loudmouth/loudmouth-helpers.cpp | 18 ++++++++++++++++++
plugins/loudmouth/loudmouth-helpers.h | 4 ++++
plugins/loudmouth/loudmouth-presentity.cpp | 6 +-----
3 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/plugins/loudmouth/loudmouth-helpers.cpp b/plugins/loudmouth/loudmouth-helpers.cpp
index e58a578..f9aa0be 100644
--- a/plugins/loudmouth/loudmouth-helpers.cpp
+++ b/plugins/loudmouth/loudmouth-helpers.cpp
@@ -35,6 +35,24 @@
#include "loudmouth-helpers.h"
+
+std::pair<std::string, std::string>
+split_jid (const std::string jid)
+{
+ size_t pos = jid.find ('/');
+ std::string base = jid;
+ std::string resource;
+
+ if (pos != std::string::npos) {
+
+ base = jid.substr (0, pos);
+ resource = jid.substr (pos);
+ }
+
+ return std::pair<std::string, std::string> (base, resource);
+}
+
+
boost::shared_ptr<LmMessageHandler> ignore_message_handler;
struct handler_data
diff --git a/plugins/loudmouth/loudmouth-helpers.h b/plugins/loudmouth/loudmouth-helpers.h
index 4860561..43521a8 100644
--- a/plugins/loudmouth/loudmouth-helpers.h
+++ b/plugins/loudmouth/loudmouth-helpers.h
@@ -41,6 +41,10 @@
#include <loudmouth/loudmouth.h>
+/* This function helps splitting a jid into base and resource
+ */
+std::pair<std::string, std::string> split_jid (const std::string jid);
+
/* This function is intended to make it easy to use a C++ function
* as a callback for the lm_connection_send_with_reply C function ;
* so when launching an IQ request/order, then it's easy to get the
diff --git a/plugins/loudmouth/loudmouth-presentity.cpp b/plugins/loudmouth/loudmouth-presentity.cpp
index 51ff164..abae8b3 100644
--- a/plugins/loudmouth/loudmouth-presentity.cpp
+++ b/plugins/loudmouth/loudmouth-presentity.cpp
@@ -38,8 +38,6 @@
#include <stdlib.h>
#include <glib/gi18n.h>
-#include <boost/algorithm/string/predicate.hpp>
-
#include "form-request-simple.h"
#include "loudmouth-helpers.h"
@@ -77,9 +75,7 @@ LM::Presentity::get_name () const
bool
LM::Presentity::has_uri (const std::string uri) const
{
- std::string full_jid = get_jid ();
- std::string base_jid = full_jid.substr (0, full_jid.find ('/'));
- return boost::starts_with (uri, base_jid);
+ return split_jid(uri).first == split_jid(get_jid ()).first;
}
const std::string
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]