[Release] wrt-commons_0.2.145
[framework/web/wrt-commons.git] / modules / utils / src / warp_iri.cpp
index 54c320a..a08551f 100644 (file)
  * but there are some patent issue between  W3C WARP SPEC and APPLE.
  * so if you want to use this file, refer to the README file in root directory
  */
-
+#include <stddef.h>
 #include <list>
 #include <set>
 #include <string>
-#include <warp_iri.h>
+#include <dpl/utils/warp_iri.h>
 #include <dpl/string.h>
 #include <dpl/auto_ptr.h>
 #include <dpl/foreach.h>
@@ -40,8 +40,9 @@ namespace {
 // Unfortunatly all widgets are using file protocol to load its data from
 // hard drive. What's why we cannot check any iri with file schema.
 
-const char *IRI_IGNORED_SCHEME[] = { "file://", "widget://", "tel:", "sms:",
-                                    "mmsto:", "mailto:", "data:", "blob:", 0 };
+const char *IRI_IGNORED_SCHEME[] = { "file://", "widget://", "app://", "tel:",
+                                     "sms:", "smsto:", "mmsto:", "mailto:", "data:", "blob:",
+                                     "tizen-service:", 0 };
 
 const DPL::String SCHEMA_HTTP = DPL::FromUTF8String("http");
 const DPL::String SCHEMA_HTTPS = DPL::FromUTF8String("https");
@@ -51,7 +52,7 @@ const DPL::String SCHEMA_FTP = DPL::FromUTF8String("ftp");
 // This will create AutoPtr deleter for iri_struct.
 // Deleter must be in the same namespace as definition of AutoPtr.
 
-namespace DPL{
+namespace DPL {
 DECLARE_DELETER(iri_struct, iri_destroy)
 } // namespace DPL
 
@@ -60,11 +61,10 @@ WarpIRI::WarpIRI() :
     m_port(UNKNOWN_PORT),
     m_isAccessDefinition(false),
     m_isIRIValid(false)
-{
-}
+{}
 
 void WarpIRI::set(const char *p_iri,
-        bool domain)
+                  bool domain)
 {
     if (!p_iri) {
         m_isAccessDefinition = m_isIRIValid = false;
@@ -111,8 +111,6 @@ void WarpIRI::set(const char *p_iri,
         }
     }
 
-    DPL::String str = DPL::FromASCIIString(std::string(iri->host));
-
     std::string utf8host = iri->host;
     std::list<std::string> hostTokenList;
     DPL::Tokenize(utf8host, ".", std::front_inserter(hostTokenList));
@@ -147,7 +145,7 @@ void WarpIRI::set(const char *p_iri,
 }
 
 void WarpIRI::set(const DPL::String &iristring,
-        bool domain)
+                  bool domain)
 {
     set(DPL::ToUTF8String(iristring).c_str(), domain);
 }
@@ -167,9 +165,15 @@ unsigned int WarpIRI::getPort(const DPL::String &schema) const
 
 bool WarpIRI::isSubDomain(const WarpIRI &second) const
 {
-    if (!m_isAccessDefinition || !second.m_isIRIValid) { return false; }
-    if (m_schema != second.m_schema) { return false; }
-    if (m_port != second.m_port) { return false; }
+    if (!m_isAccessDefinition || !second.m_isIRIValid) {
+        return false;
+    }
+    if (m_schema != second.m_schema) {
+        return false;
+    }
+    if (m_port != second.m_port) {
+        return false;
+    }
 
     size_t size = m_host.size() < second.m_host.size() ?
         m_host.size() : second.m_host.size();
@@ -195,10 +199,6 @@ bool WarpIRI::isAccessDefinition() const
     return m_isAccessDefinition;
 }
 
-// KW bool WarpIRI::isIRIValid() const {
-// KW     return m_isIRIValid;
-// KW }
-
 bool WarpIRI::getSubDomain() const
 {
     return m_domain;
@@ -209,7 +209,8 @@ bool WarpIRI::isIRISchemaIgnored(const char *iri)
     for (int i = 0; IRI_IGNORED_SCHEME[i]; ++i) {
         if (0 ==
             strncmp(iri, IRI_IGNORED_SCHEME[i],
-                    strlen(IRI_IGNORED_SCHEME[i]))) {
+                    strlen(IRI_IGNORED_SCHEME[i])))
+        {
             return true;
         }
     }