[ekiga] Canonise address introduced in new contact dialog box in roster
- From: Eugen Dedu <ededu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Canonise address introduced in new contact dialog box in roster
- Date: Mon, 5 Dec 2011 11:29:03 +0000 (UTC)
commit fde3959af517849e59ab9620e6b252e5988bf94e
Author: Eugen Dedu <Eugen Dedu pu-pm univ-fcomte fr>
Date: Mon Dec 5 12:24:19 2011 +0100
Canonise address introduced in new contact dialog box in roster
Trim and add sip: if no protocol specified.
lib/engine/components/local-roster/local-heap.cpp | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/lib/engine/components/local-roster/local-heap.cpp b/lib/engine/components/local-roster/local-heap.cpp
index 25b1f79..b0389ea 100644
--- a/lib/engine/components/local-roster/local-heap.cpp
+++ b/lib/engine/components/local-roster/local-heap.cpp
@@ -395,9 +395,18 @@ Local::Heap::new_presentity_form_submitted (bool submitted,
else
uri = result.text ("uri");
- size_t pos = uri.find_first_of (' ');
- if (pos != std::string::npos)
- uri = uri.substr (0, pos);
+ // remove leading and trailing spaces (useful for copy/paste)
+ const size_t begin_str = uri.find_first_not_of (" \t");
+ if (begin_str != std::string::npos) { // there is content
+ const size_t end_str = uri.find_last_not_of (" \t");
+ const size_t range = end_str - begin_str + 1;
+ uri = uri.substr (begin_str, range);
+ const size_t pos = uri.find (":");
+ // if no protocol specified, add leading "sip:"
+ if (pos == std::string::npos)
+ uri = uri.insert (0, "sip:");
+ }
+
if (presence_core->is_supported_uri (uri)
&& !has_presentity_with_uri (uri)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]