[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-common-dev
Subject:    [Common-dev] [Fwd: [Fwd: [Fwd: CR: Fixed Bug 249168: Set the
From:       Vipin Kumar Tyagi <vtyagi () real ! com>
Date:       2010-01-19 6:41:28
Message-ID: 4B555148.70804 () real ! com
[Download RAW message or body]

This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.


If any body has no objection then I will check-in the changes by EOD 
20th JAN 2010.

Thanks,
Vipin
-------- Original Message --------
Subject: 	[Fwd: [Fwd: CR: Fixed Bug 249168: Set the logmessages.xml in a 
preference instead of dir scanning for it.]]
Date: 	Fri, 08 Jan 2010 12:56:49 +0530
From: 	Vipin Kumar Tyagi <vtyagi@real.com>
To: 	common-dev@helixcommunity.org
CC: 	Eric Hyche <ehyche@real.com>, Sujeet Kharkar <skharkar@real.com>, 
Mehran Azimi <mazimi@real.com>, Steve McMillen <stevemc@real.com>, Rahul 
Agarwal <rahul@real.com>, Vipin Kumar Tyagi <vtyagi@real.com>, 
"tools-dev@real.com" <tools-dev@real.com>



Resending.

Thanks,
Vipin

-------- Original Message --------
Subject: 	[Fwd: CR: Fixed Bug 249168: Set the logmessages.xml in a 
preference instead of dir scanning for it.]
Date: 	Tue, 05 Jan 2010 11:00:41 +0530
From: 	Vipin Kumar Tyagi <vtyagi@real.com>
To: 	common-dev@helixcommunity.org
CC: 	Sujeet Kharkar <skharkar@real.com>, Steve McMillen 
<stevemc@real.com>, Rahul Agarwal <rahul@real.com>, Vipin Kumar Tyagi 
<vtyagi@real.com>, "tools-dev@real.com" <tools-dev@real.com>, Mehran 
Azimi <mazimi@real.com>



Resending.

Thanks,
Vipin

-------- Original Message --------
Subject: 	CR: Fixed Bug 249168: Set the logmessages.xml in a preference 
instead of dir scanning for it.
Date: 	Wed, 30 Dec 2009 11:32:34 +0530
From: 	Vipin Kumar Tyagi <vtyagi@real.com>
To: 	common-dev@helixcommunity.org
CC: 	Sujeet Kharkar <skharkar@real.com>, Steve McMillen 
<stevemc@real.com>, Rahul Agarwal <rahul@real.com>, Vipin Kumar Tyagi 
<vtyagi@real.com>, "tools-dev@real.com" <tools-dev@real.com>, Mehran 
Azimi <mazimi@real.com>



*Branches:* Head

*Suggested Reviewer:* Anyone

*Synopsis:*
Fixed Bug 249168: Set the logmessages.xml in a preference instead of dir 
scanning for it.

*Overview:
*Changes to* *set the logmessages.xml in a preference instead of 
directory  scanning for it.
If directory path includes xml file name then it does not scan directory 
to find the xml file and calls ParseTranslationFile function.
If directory path does not include  xml file name then  it calls 
ScanTranslationFiles function to scan directory to find xml file.
It also calls new function ParseTranslationFile from inside  
ScanTranslationFiles function to avoid code duplication.

*Files Added: *
None
* 
Files Modified:*
common/log/logsystem/hxttranslationcentre.cpp
common/log/logsystem/hxttranslationcentre.h

*Image Size and Heap Use impact:*
None.

*Platforms and Profiles Affected:*
None

*Distribution Libraries Affected:*
None

*Distribution library impact and planned action:*
None

*Files Attached:*
logsystem_diff.txt

Thanks,
Vipin







["logsystem_diff.txt" (text/plain)]

Index: hxttranslationcentre.cpp
===================================================================
RCS file: /cvsroot/common/log/logsystem/hxttranslationcentre.cpp,v
retrieving revision 1.7.6.1
diff -u -r1.7.6.1 hxttranslationcentre.cpp
--- hxttranslationcentre.cpp	24 Aug 2009 21:18:35 -0000	1.7.6.1
+++ hxttranslationcentre.cpp	18 Dec 2009 06:06:45 -0000
@@ -182,13 +182,40 @@
 
 	m_sLanguage = szLanguage;
 	m_sTranslationFileDir = szTranslationFileDir;
-	ScanTranslationFiles(szTranslationFileDir);
 
+	if( IsDirPathContainsXMLFile(szTranslationFileDir) )
+	{
+		ParseTranslationFile(szTranslationFileDir);
+	}
+	else
+	{
+		ScanTranslationFiles(szTranslationFileDir);
+	}
 	m_bIsInitialized = true;
 
 	return HXR_OK;
 }
 
+HXBOOL
+CHXTTranslationCentre::IsDirPathContainsXMLFile(const char* szTranslationFile)
+{
+    HXBOOL bRet = FALSE;
+    if(szTranslationFile)
+    {
+        CHXString strTranslationFile(szTranslationFile);
+        int pos = strTranslationFile.ReverseFind('.');
+        if (pos != -1)
+        {
+            strTranslationFile = \
strTranslationFile.Right(strTranslationFile.GetLength() - (pos+1)); +            \
if(!strcmp(strTranslationFile, "xml")) +            {
+                bRet = TRUE;
+            }
+        }
+    }
+    return bRet;
+}
+
 HX_RESULT 
 CHXTTranslationCentre::IsCurrentLanguageUnicode(HXBOOL* pbIsUnicode)
 {
@@ -339,84 +366,90 @@
             CHXString sFullFileName = szTranslationFileDir;
             sFullFileName += OS_SEPARATOR_STRING;
             sFullFileName += szCurFileName;
-            // Read the first few bytes of this file into a buffer
-            BYTE*  pBuf   = NULL;
-            UINT32 ulSize = 0;
-            HX_RESULT rv = ReadIntoBuffer((const char*) sFullFileName, &pBuf, \
                &ulSize);
-            if (SUCCEEDED(rv))
+            //Parse TranslationFiles
+            ParseTranslationFile(sFullFileName);
+            // Get the next file
+            szCurFileName = pFileFinder->FindNext();
+        } // while(szCurFileName)
+        delete pFileFinder;
+    }
+}
+
+void 
+CHXTTranslationCentre::ParseTranslationFile(CHXString szTranslationFile)
+{
+    // Read the first few bytes of this file into a buffer
+    BYTE*  pBuf   = NULL;
+    UINT32 ulSize = 0;
+    HX_RESULT rv = ReadIntoBuffer((const char*)szTranslationFile, &pBuf, &ulSize);
+    if (SUCCEEDED(rv))
+    {
+        // Pre-scan this buffer to see if there is a "translationmap" in it
+        if (IsBufferATranslationMap(pBuf, ulSize))
+        {
+            CHXTXmlParser* pParser = new CHXTXmlParser();
+            if (pParser)
             {
-                // Pre-scan this buffer to see if there is a "translationmap" in it
-                if (IsBufferATranslationMap(pBuf, ulSize))
+                if (SUCCEEDED(pParser->ParseFile(szTranslationFile)))
                 {
-                    CHXTXmlParser* pParser = new CHXTXmlParser();
-                    if (pParser)
+                    CHXString sNamespace;
+                    CHXString sLanguage;
+                    CHXString sAttributeName;
+
+                    CHXTElement rootElement = pParser->GetRootElement();
+                    CHXPtrArray& attributes = \
(CHXPtrArray&)rootElement.GetAttributes(); // const_cast for iter +                   \
CHXPtrArray::Iterator iterAttributes = attributes.Begin(); +                    \
while(iterAttributes != attributes.End()) +                    {
+                        CHXTAttribute* pAttr = (CHXTAttribute*)*iterAttributes;
+                        sAttributeName = pAttr->GetName();
+                        if (sAttributeName == "namespace")
+                        {
+                            sNamespace = pAttr->GetValue();
+                            ++iterAttributes;
+                        }
+                        else if(sAttributeName == "language")
+                        {
+                            sLanguage = pAttr->GetValue();
+                            ++iterAttributes;
+                        }
+                        else
+                        {
+                            iterAttributes = attributes.End();
+                        }
+                    }
+
+                    if (sNamespace != "" && sLanguage != "")
                     {
-                        if (SUCCEEDED(pParser->ParseFile(sFullFileName)))
+                        CHXString sMapKey = sNamespace + sLanguage;
+                        CTranslationInfo* pTransInfo = new CTranslationInfo();
+                        if (pTransInfo)
                         {
-                            CHXString sNamespace;
-                            CHXString sLanguage;
-                            CHXString sAttributeName;
-
-                            CHXTElement rootElement = pParser->GetRootElement();
-                            CHXPtrArray& attributes = \
                (CHXPtrArray&)rootElement.GetAttributes(); // const_cast for iter
-                            CHXPtrArray::Iterator iterAttributes = \
                attributes.Begin();
-                            while(iterAttributes != attributes.End())
+                            pTransInfo->Loaded(false);
+                            pTransInfo->Namespace(sNamespace);
+                            pTransInfo->Language(sLanguage);
+                            pTransInfo->Filename(szTranslationFile);
+                            CHXMapStringToOb::Iterator iter = \
m_mapTranslate.Find(sMapKey); +                            if(iter == \
m_mapTranslate.End())  {
-                                CHXTAttribute* pAttr = \
                (CHXTAttribute*)*iterAttributes;
-                                sAttributeName = pAttr->GetName();
-                                if (sAttributeName == "namespace")
-                                {
-                                    sNamespace = pAttr->GetValue();
-                                    ++iterAttributes;
-                                }
-                                else if(sAttributeName == "language")
-                                {
-                                    sLanguage = pAttr->GetValue();
-                                    ++iterAttributes;
-                                }
-                                else
-                                {
-                                    iterAttributes = attributes.End();
-                                }
+                                m_mapTranslate[sMapKey] = pTransInfo;
                             }
-
-                            if (sNamespace != "" && sLanguage != "")
+                            else
                             {
-                                CHXString sMapKey = sNamespace + sLanguage;
-                                CTranslationInfo* pTransInfo = new \
                CTranslationInfo();
-                                if (pTransInfo)
-                                {
-                                    pTransInfo->Loaded(false);
-                                    pTransInfo->Namespace(sNamespace);
-                                    pTransInfo->Language(sLanguage);
-                                    pTransInfo->Filename(sFullFileName);
-                                    CHXMapStringToOb::Iterator iter = \
                m_mapTranslate.Find(sMapKey);
-                                    if(iter == m_mapTranslate.End())
-                                    {
-                                        m_mapTranslate[sMapKey] = pTransInfo;
-                                    }
-                                    else
-                                    {
-                                        HX_ASSERT("Duplicate resource file found" == \
                0);
-                                    }
-                                    sNamespace = "";
-                                    sLanguage = "";
-                                }
+                                HX_ASSERT("Duplicate resource file found" == 0);
                             }
+                            sNamespace = "";
+                            sLanguage = "";
                         }
-                    } // if (pParser)
-                    delete pParser;
-                } // if (IsBufferATranslationMap(pBuf, ulSize))
-            }
-            HX_VECTOR_DELETE(pBuf);
-            // Get the next file
-            szCurFileName = pFileFinder->FindNext();
-        } // while(szCurFileName)
-        delete pFileFinder;
+                    }
+                }
+            } // if (pParser)
+            delete pParser;
+        } // if (IsBufferATranslationMap(pBuf, ulSize))
     }
+    HX_VECTOR_DELETE(pBuf);
 }
 
-
 void 
 CHXTTranslationCentre::LoadTranslationFile(CTranslationInfo* pTransInfo)
 {
Index: hxttranslationcentre.h
===================================================================
RCS file: /cvsroot/common/log/logsystem/hxttranslationcentre.h,v
retrieving revision 1.4.6.1
diff -u -r1.4.6.1 hxttranslationcentre.h
--- hxttranslationcentre.h	24 Aug 2009 21:18:35 -0000	1.4.6.1
+++ hxttranslationcentre.h	18 Dec 2009 06:06:45 -0000
@@ -222,6 +222,7 @@
 
 	// *** Called on thread that creates LogSystem (Apps Main Thread) ***
 	HX_RESULT Init(const char* szLanguage, const char* szTranslationFileDir);
+       HXBOOL IsDirPathContainsXMLFile(const char* szTranslationFile);
 	HX_RESULT GetNamespacesForLanguage(const char* szLanguage, CHXSimpleList& nsList \
/*CHXString* */);  
 	// *** Called on all Threads that Log Messages (users of WriterManager) ***
@@ -234,6 +235,7 @@
 private:
 	
 	void ScanTranslationFiles(const char* szTranslationFileDir);
+	void ParseTranslationFile(CHXString szTranslationFile);
 	void LoadTranslationFile(CTranslationInfo* pTransInfo);
         HX_RESULT ReadIntoBuffer(const char* pszFileName, BYTE** ppBuf, UINT32* \
pulSize);  HXBOOL    IsBufferATranslationMap(BYTE* pBuf, UINT32 ulSize);



_______________________________________________
Common-dev mailing list
Common-dev@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/common-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic