]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/url.cpp
Unicode compilation fix
[wxWidgets.git] / src / common / url.cpp
index 8c7ddb27d2dd2775ee970f2c46221db264c75f24..956f0266f471f3415fb97a0a32797a70e3a7c5e1 100644 (file)
@@ -20,6 +20,8 @@
 #pragma hdrstop
 #endif
 
+#if wxUSE_SOCKETS
+
 #ifndef WX_PRECOMP
 #endif
 
@@ -43,15 +45,13 @@ IMPLEMENT_CLASS(wxURL, wxObject)
 wxProtoInfo *wxURL::g_protocols = NULL;
 wxHTTP *wxURL::g_proxy;
 
-/////////////////////////////////////////////////////////////////
-// wxURL ////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
+// --------------------------------------------------------------
+// wxURL
+// --------------------------------------------------------------
 
-/*
- * --------------------------------------------------------------
- * --------- wxURL CONSTRUCTOR DESTRUCTOR -----------------------
- * --------------------------------------------------------------
- */
+// --------------------------------------------------------------
+// --------- wxURL CONSTRUCTOR DESTRUCTOR -----------------------
+// --------------------------------------------------------------
 
 wxURL::wxURL(const wxString& url)
 {
@@ -107,7 +107,7 @@ bool wxURL::ParseURL()
 
 void wxURL::CleanData()
 {
-  if (m_protoname != "proxy")
+  if (m_protoname != _T("proxy"))
     delete m_protocol;
 }
 
@@ -116,11 +116,10 @@ wxURL::~wxURL()
   CleanData();
 }
 
-/*
- * --------------------------------------------------------------
- * --------- wxURL urls decoders --------------------------------
- * --------------------------------------------------------------
- */
+// --------------------------------------------------------------
+// --------- wxURL urls decoders --------------------------------
+// --------------------------------------------------------------
+
 bool wxURL::PrepProto(wxString& url)
 {
   int pos;
@@ -209,7 +208,6 @@ bool wxURL::FetchProtocol()
 
       m_protoinfo = info;
       m_protocol = (wxProtocol *)m_protoinfo->m_cinfo->CreateObject();
-      wxSocketHandler::Master().Register(m_protocol);
       return TRUE;
     }
     info = info->next;
@@ -217,11 +215,10 @@ bool wxURL::FetchProtocol()
   return FALSE;
 }
 
-/*
- * --------------------------------------------------------------
- * --------- wxURL get ------------------------------------------
- * --------------------------------------------------------------
- */
+// --------------------------------------------------------------
+// --------- wxURL get ------------------------------------------
+// --------------------------------------------------------------
+
 wxInputStream *wxURL::GetInputStream(void)
 {
   wxIPV4address addr;
@@ -237,7 +234,7 @@ wxInputStream *wxURL::GetInputStream(void)
   }
 
   m_error = wxURL_NOERR;
-  if (m_user != "") {
+  if (m_user != _T("")) {
     m_protocol->SetUser(m_user);
     m_protocol->SetPassword(m_password);
   }
@@ -313,3 +310,30 @@ void wxURL::SetProxy(const wxString& url_proxy)
   m_protoname = "proxy";
   m_path = url_proxy;
 }
+
+wxString wxURL::ConvertToValidURI(const wxString& uri)
+{
+  wxString out_str;
+  wxString hexa_code;
+  size_t i;
+
+  for (i=0;i<uri.Len();i++) {
+    wxChar c = uri.GetChar(i);
+
+    if (c == _T(' '))
+      out_str += _T('+');
+    else {
+      if (!isalpha(c) && c != _T('.') && c != _T('+') && c != _T('.') && 
+                         c != _T('/')) {
+        hexa_code.Printf(_T("%%%02X"), c);
+        out_str += hexa_code;
+      } else
+        out_str += c;
+    }
+  }
+  
+  return out_str;
+}
+
+#endif
+  // wxUSE_SOCKETS