Commit in reactos/subsys/system/explorer on MAIN
doxy-footer.html+1-11.39 -> 1.40
explorer.cpp+25-81.61 -> 1.62
globals.h+5-11.33 -> 1.34
taskbar/traynotify.cpp+1-11.49 -> 1.50
utility/utility.h+37-51.60 -> 1.61
       /xmlstorage.cpp+5-41.1 -> 1.2
       /xmlstorage.h+37-261.1 -> 1.2
+111-46
7 modified files
implemented UTF-8 conversion

reactos/subsys/system/explorer
doxy-footer.html 1.39 -> 1.40
diff -u -r1.39 -r1.40
--- doxy-footer.html	21 Mar 2004 23:36:23 -0000	1.39
+++ doxy-footer.html	22 Mar 2004 20:58:16 -0000	1.40
@@ -3,7 +3,7 @@
   <tr>
     <td><address style="align: right;"><small>
 ROS Explorer Source Code Documentation
-<br>generated on 21.03.2004 by <a href="http://www.doxygen.org/index.html">
+<br>generated on 22.03.2004 by <a href="http://www.doxygen.org/index.html">
 <img src="doxygen.png" alt="doxygen" align="middle" border=0>
 	</small></address>
 	</td>

reactos/subsys/system/explorer
explorer.cpp 1.61 -> 1.62
diff -u -r1.61 -r1.62
--- explorer.cpp	21 Mar 2004 23:36:23 -0000	1.61
+++ explorer.cpp	22 Mar 2004 20:58:16 -0000	1.62
@@ -81,6 +81,29 @@
 	_icon_cache.init();
 }
 
+bool ExplorerGlobals::read_cfg()
+{
+	 // read configuration file
+	_cfg_dir.printf(TEXT("%s\\ReactOS"), (LPCTSTR)SpecialFolderFSPath(CSIDL_APPDATA,0));
+	_cfg_path.printf(TEXT("%s\\ros-explorer.xml"), _cfg_dir.c_str());
+
+	if (_cfg.read(_cfg_path))
+		return true;
+
+	if (_cfg.read("explorer-cfg-template.xml"))
+		return true;
+
+	return false;
+}
+
+void ExplorerGlobals::write_cfg()
+{
+	 // write configuration file
+	RecursiveCreateDirectory(_cfg_dir);
+
+	_cfg.write(_cfg_path);
+}
+
 
 void _log_(LPCTSTR txt)
 {
@@ -746,12 +769,7 @@
 	 // init common controls library
 	CommonControlInit usingCmnCtrl;
 
-	 // read configuration file
-	String cfg_dir = FmtString(TEXT("%s\\ReactOS"), (LPCTSTR)SpecialFolderFSPath(CSIDL_APPDATA,0));
-	String cfg_path = FmtString(TEXT("%s\\ros-explorer.xml"), cfg_dir.c_str());
-
-	if (!g_Globals._cfg.read(cfg_path))
-		g_Globals._cfg.read("explorer-cfg-template.xml");
+	g_Globals.read_cfg();
 
 	if (startup_desktop) {
 		g_Globals._desktops.init();
@@ -779,8 +797,7 @@
 	int ret = explorer_main(hInstance, lpCmdLine, nShowCmd);
 
 	 // write configuration file
-	RecursiveCreateDirectory(cfg_dir);
-	g_Globals._cfg.write(cfg_path);
+	g_Globals.write_cfg();
 
 	return ret;
 }

reactos/subsys/system/explorer
globals.h 1.33 -> 1.34
diff -u -r1.33 -r1.34
--- globals.h	21 Mar 2004 23:36:23 -0000	1.33
+++ globals.h	22 Mar 2004 20:58:16 -0000	1.34
@@ -224,7 +224,9 @@
 {
 	ExplorerGlobals();
 
-	void		init(HINSTANCE hInstance);
+	void	init(HINSTANCE hInstance);
+	bool	read_cfg();
+	void	write_cfg();
 
 	HINSTANCE	_hInstance;
 	ATOM		_hframeClass;
@@ -249,6 +251,8 @@
 	Desktops	_desktops;
 
 	XMLDoc		_cfg;
+	String		_cfg_dir;
+	String		_cfg_path;
 } g_Globals;
 
 

reactos/subsys/system/explorer/taskbar
traynotify.cpp 1.49 -> 1.50
diff -u -r1.49 -r1.50
--- traynotify.cpp	21 Mar 2004 23:36:24 -0000	1.49
+++ traynotify.cpp	22 Mar 2004 20:58:16 -0000	1.50
@@ -199,7 +199,7 @@
 
 			for(XMLNode::Children::const_iterator it=children.begin(); it!=children.end(); ++it) {
 				const XMLNode& node = **it;
-				assert(node=="icon");
+				assert(node==TEXT("icon"));
 
 				NotifyIconConfig cfg;
 

reactos/subsys/system/explorer/utility
utility.h 1.60 -> 1.61
diff -u -r1.60 -r1.61
--- utility.h	21 Mar 2004 23:36:24 -0000	1.60
+++ utility.h	22 Mar 2004 20:58:16 -0000	1.61
@@ -680,7 +680,7 @@
 		WCHAR b[BUFFER_LEN];
 
 		if (s)
-			_p = SysAllocStringLen(b, MultiByteToWideChar(CP_ACP, 0, s, -1, b, BUFFER_LEN));
+			_p = SysAllocStringLen(b, MultiByteToWideChar(CP_ACP, 0, s, -1, b, BUFFER_LEN)-1);
 		else
 			_p = NULL;
 	}
@@ -744,7 +744,7 @@
 	String(LPCSTR s, int l) {assign(s, l);}
 	String(const string& other) {assign(other.c_str());}
 	String& operator=(LPCSTR s) {assign(s); return *this;}
-	void assign(LPCSTR s) {if (s) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, -1, b, BUFFER_LEN));} else erase();}
+	void assign(LPCSTR s) {if (s) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, -1, b, BUFFER_LEN)-1);} else erase();}
 	void assign(LPCSTR s, int l) {if (s) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, l, b, BUFFER_LEN));} else erase();}
 	void assign(const BStr& s) {int l = s.length(); super::assign(s, l);}
 #else
@@ -752,7 +752,7 @@
 	String(LPCWSTR s, int l) {assign(s, l);}
 	String(const wstring& other) {assign(other.c_str());}
 	String& operator=(LPCWSTR s) {assign(s); return *this;}
-	void assign(LPCWSTR s) {if (s) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, -1, b, BUFFER_LEN, 0, 0));} else erase();}
+	void assign(LPCWSTR s) {if (s) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, -1, b, BUFFER_LEN, 0, 0)-1);} else erase();}
 	void assign(LPCWSTR s, int l) {if (s) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, l, b, BUFFER_LEN, 0, 0));} else erase();}
 	void assign(const BStr& s) {int l = s.length(); if (l) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, l, b, BUFFER_LEN, 0, 0));} else erase();}
 #endif
@@ -767,11 +767,43 @@
 	operator LPCTSTR() const {return c_str();}
 
 #ifdef UNICODE
-	operator string() const {char b[BUFFER_LEN]; return string(b, WideCharToMultiByte(CP_ACP, 0, c_str(), -1, b, BUFFER_LEN, 0, 0));}
+	operator string() const {char b[BUFFER_LEN]; return string(b, WideCharToMultiByte(CP_ACP, 0, c_str(), -1, b, BUFFER_LEN, 0, 0)-1);}
 #else
-	operator wstring() const {WCHAR b[BUFFER_LEN]; return wstring(b, MultiByteToWideChar(CP_ACP, 0, c_str(), -1, b, BUFFER_LEN));}
+	operator wstring() const {WCHAR b[BUFFER_LEN]; return wstring(b, MultiByteToWideChar(CP_ACP, 0, c_str(), -1, b, BUFFER_LEN)-1);}
 #endif
 
+	void assign_utf8(const char* str)
+	{
+		TCHAR buffer[BUFFER_LEN];
+
+#ifdef UNICODE
+		int l = MultiByteToWideChar(CP_UTF8, 0, str, -1, buffer, BUFFER_LEN) - 1;
+#else
+		WCHAR wbuffer[BUFFER_LEN];
+
+		int l = MultiByteToWideChar(CP_UTF8, 0, str, -1, wbuffer, BUFFER_LEN) - 1;
+		l = WideCharToMultiByte(CP_ACP, 0, wbuffer, l, buffer, BUFFER_LEN, 0, 0);
+#endif
+
+		assign(buffer, l);
+	}
+
+	string get_utf8() const
+	{
+		char buffer[BUFFER_LEN];
+
+#ifdef UNICODE
+		int l = WideCharToMultiByte(CP_UTF8, 0, c_str(), length(), buffer, BUFFER_LEN, 0, 0);
+#else
+		WCHAR wbuffer[BUFFER_LEN];
+
+		int l = MultiByteToWideChar(CP_ACP, 0, c_str(), length(), wbuffer, BUFFER_LEN);
+		l = WideCharToMultiByte(CP_UTF8, 0, wbuffer, l, buffer, BUFFER_LEN, 0, 0);
+#endif
+
+		return string(buffer, l);
+	}
+
 	String& printf(LPCTSTR fmt, ...)
 	{
 		va_list l;

reactos/subsys/system/explorer/utility
xmlstorage.cpp 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- xmlstorage.cpp	21 Mar 2004 23:36:24 -0000	1.1
+++ xmlstorage.cpp	22 Mar 2004 20:58:16 -0000	1.2
@@ -72,15 +72,16 @@
 void XMLCALL XMLReader::XML_StartElementHandler(void* userData, const XML_Char* name, const XML_Char** atts)
 {
 	XMLReader* pThis = (XMLReader*) userData;
-	XMLNode* node = new XMLNode(name);
+
+	XMLNode* node = new XMLNode(String_from_XML_Char(name));
 
 	pThis->_pos.add_down(node);
 
 	while(*atts) {
-		const XML_Char* name = *atts++;
-		const XML_Char* value = *atts++;
+		const XML_Char* attr_name = *atts++;
+		const XML_Char* attr_value = *atts++;
 
-		(*node)[name] = value;
+		(*node)[String_from_XML_Char(attr_name)] = String_from_XML_Char(attr_value);
 	}
 
 	pThis->_in_tag = true;

reactos/subsys/system/explorer/utility
xmlstorage.h 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- xmlstorage.h	21 Mar 2004 23:36:24 -0000	1.1
+++ xmlstorage.h	22 Mar 2004 20:58:16 -0000	1.2
@@ -41,14 +41,31 @@
 #define	XML_INDENT_SPACE "  "
 
 
+#ifdef XML_UNICODE	// Are XML_Char strings UTF-16 encoded?
+
+typedef String String_from_XML_Char;
+
+#else
+
+struct String_from_XML_Char : public String
+{
+	String_from_XML_Char(const XML_Char* str)
+	{
+		assign_utf8(str);
+	}
+};
+
+#endif
+
+
  /// in memory representation of an XML node
-struct XMLNode : public string
+struct XMLNode : public String
 {
-	typedef map<string, string> AttributeMap;
+	typedef map<String, String> AttributeMap;
 	typedef list<XMLNode*> Children;
 
-	XMLNode(const string& name)
-	 :	string(name)
+	XMLNode(const String& name)
+	 :	String(name)
 	{
 	}
 
@@ -67,13 +84,13 @@
 	}
 
 	 /// write access to an attribute
-	string& operator[](const string& attr_name)
+	String& operator[](const String& attr_name)
 	{
 		return _attributes[attr_name];
 	}
 
 	 /// read only access to an attribute
-	string operator[](const string& attr_name) const
+	String operator[](const String& attr_name) const
 	{
 		AttributeMap::const_iterator found = _attributes.find(attr_name);
 
@@ -96,7 +113,7 @@
 			return NULL;
 	}
 
-	XMLNode* find_first(const string& name) const
+	XMLNode* find_first(const String& name) const
 	{
 		for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it)
 			if (**it == name)
@@ -105,18 +122,12 @@
 		return NULL;
 	}
 
-	XMLNode* find_first(const string& name, const string& attr_name, const string& attr_value) const
+	XMLNode* find_first(const String& name, const String& attr_name, const String& attr_value) const
 	{
 		for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it) {
 			const XMLNode& node = **it;
 
-			if (node==name &&
-#ifdef UNICODE
-				!strcmp(node[attr_name].c_str(), attr_value.c_str())	// workaround because of STL bug
-#else
-				node[attr_name]==attr_value
-#endif
-				)
+			if (node==name && node[attr_name]==attr_value)
 				return *it;
 		}
 
@@ -142,10 +153,10 @@
 	 /// write XML stream preserving original white space and comments
 	ostream& write(ostream& out)
 	{
-		out << "<" << *this;
+		out << "<" << get_utf8();
 
 		for(AttributeMap::const_iterator it=_attributes.begin(); it!=_attributes.end(); ++it)
-			out << " " << it->first << "=\"" << it->second << "\"";
+			out << " " << it->first.get_utf8() << "=\"" << it->second.get_utf8() << "\"";
 
 		if (!_children.empty() || !_content.empty()) {
 			out << ">" << _content;
@@ -153,7 +164,7 @@
 			for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it)
 				(*it)->write(out);
 
-			out << "</" << *this << ">" << _trailing;
+			out << "</" << get_utf8() << ">" << _trailing;
 		} else {
 			out << "/>" << _trailing;
 		}
@@ -167,10 +178,10 @@
 		for(int i=indent; i--; )
 			out << XML_INDENT_SPACE;
 
-		out << "<" << *this;
+		out << "<" << get_utf8();
 
 		for(AttributeMap::const_iterator it=_attributes.begin(); it!=_attributes.end(); ++it)
-			out << " " << it->first << "=\"" << it->second << "\"";
+			out << " " << it->first.get_utf8() << "=\"" << it->second.get_utf8() << "\"";
 
 		if (!_children.empty()) {
 			out << ">\n";
@@ -181,7 +192,7 @@
 			for(int i=indent; i--; )
 				out << XML_INDENT_SPACE;
 
-			out << "</" << *this << ">\n";
+			out << "</" << get_utf8() << ">\n";
 		} else {
 			out << "/>\n";
 		}
@@ -215,8 +226,8 @@
 	const XMLNode& operator*() const {return *_cur;}
 
 	 /// attribute access
-	string& operator[](const string& attr_name) {return (*_cur)[attr_name];}
-	string operator[](const string& attr_name) const {return (*_cur)[attr_name];}
+	String& operator[](const String& attr_name) {return (*_cur)[attr_name];}
+	String operator[](const String& attr_name) const {return (*_cur)[attr_name];}
 
 	 /// insert children when building tree
 	void add_down(XMLNode* child)
@@ -249,7 +260,7 @@
 	}
 
 	 /// search for child and go down
-	bool go_down(const string& name)
+	bool go_down(const String& name)
 	{
 		XMLNode* node = _cur->find_first(name);
 
@@ -261,7 +272,7 @@
 	}
 
 	 /// create node if not already existing and move to it
-	void create(const string& name)
+	void create(const String& name)
 	{
 		XMLNode* node = _cur->find_first(name);
 
@@ -272,7 +283,7 @@
 	}
 
 	 /// search matching child node identified by key name and an attribute value
-	void create(const string& name, const string& attr_name, const string& attr_value)
+	void create(const String& name, const String& attr_name, const String& attr_value)
 	{
 		XMLNode* node = _cur->find_first(name, attr_name, attr_value);
 
CVSspam 0.2.8