From 4697a94a91e34f9babdf26040145efd0943348f3 Mon Sep 17 00:00:00 2001
From: Emmanuel Lepage Vallee <elv1313@gmail.com>
Date: Fri, 28 Apr 2017 04:30:05 -0400
Subject: [PATCH] uri: Allow to set the scheme later.

When the user enters a string, it isn't always yet known if it is a
search for registered name, a SIP URI or some local DNS names.

However at some point the choice can be noarrowed down. This is a good
time to set the scheme. This help later on top pick the right account
and hopefully resolve the RingId before placing the call.

Change-Id: Iad8283fc4c6ff2e4cfe189bf216f00720202ce92
Reviewed-by: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
---
 src/uri.cpp | 9 +++++++++
 src/uri.h   | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/src/uri.cpp b/src/uri.cpp
index 0e266634..96dc4292 100644
--- a/src/uri.cpp
+++ b/src/uri.cpp
@@ -517,6 +517,15 @@ QString URI::userinfo() const
    return d_ptr->m_Userinfo;
 }
 
+/**
+ * Sometime, some metadata can be used to deduce the scheme even if it wasn't
+ * originally known. This will improve the result of ::format.
+ */
+void URI::setSchemeType(SchemeType t)
+{
+    d_ptr->m_HeaderType = t;
+}
+
 /**
  * Generate a new URI formatted with the sections passed in `sections`
  *
diff --git a/src/uri.h b/src/uri.h
index 5ff0e779..dadbb409 100644
--- a/src/uri.h
+++ b/src/uri.h
@@ -178,6 +178,9 @@ public:
    SchemeType schemeType    () const;
    ProtocolHint protocolHint() const;
 
+   //Setter
+   void setSchemeType(SchemeType t);
+
    //Converter
    QString format(FlagPack<URI::Section> sections) const;
 
-- 
GitLab