diff options
author | rajeev.ran <rajeev.ran@samsung.com> | 2013-10-07 15:07:06 +0530 |
---|---|---|
committer | rajeev.ran <rajeev.ran@samsung.com> | 2013-10-11 18:09:54 +0530 |
commit | 7242a98fa0b8f19dc7b0d6647960c9033b77a201 (patch) | |
tree | 22eb03d42b7514890d70675ea83632f74edaf16a | |
parent | d02a7270da187b9999bc83b752a602c187051193 (diff) | |
download | XmlParserApp-tizen_2.2.tar.gz XmlParserApp-tizen_2.2.tar.bz2 XmlParserApp-tizen_2.2.zip |
Addition of error popup to XmlWriter in xmlparser app - issue N_SE540002.2.1_releasetizen_2.2
Change-Id: I59faf42560f3eaca87f633ce48c229d35bedb404
Signed-off-by: rajeev.ran <rajeev.ran@samsung.com>
-rwxr-xr-x | project/inc/XmlWriter.h | 1 | ||||
-rw-r--r-- | project/src/XmlWriter.cpp | 52 |
2 files changed, 41 insertions, 12 deletions
diff --git a/project/inc/XmlWriter.h b/project/inc/XmlWriter.h index cb1f5a6..51a7cea 100755 --- a/project/inc/XmlWriter.h +++ b/project/inc/XmlWriter.h @@ -36,6 +36,7 @@ public: result RunXMLWrite(void); void RunXMLParseandDisplay(void); + void ShowError(void); virtual result OnInitializing(void); virtual result OnTerminating(void); diff --git a/project/src/XmlWriter.cpp b/project/src/XmlWriter.cpp index 211b0c5..e75f3a4 100644 --- a/project/src/XmlWriter.cpp +++ b/project/src/XmlWriter.cpp @@ -134,15 +134,18 @@ XmlWriter::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& list void XmlWriter::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) { - result err; + result r; switch (actionId) { case ID_BUTTON_WRITE: { - err = RunXMLWrite(); - TryReturnVoid(E_SUCCESS == err , "RunXMLWrite failed.%S", GetErrorMessage(err)); - - if(__display && _pItemList) + r = RunXMLWrite(); + if (r != E_SUCCESS) + { + ShowError(); + } + TryReturnVoid(r == E_SUCCESS , "[%s] Propagating.", GetErrorMessage(r)); + if (__display && _pItemList) { _pItemList->RemoveAll(true); } @@ -162,7 +165,7 @@ XmlWriter::RunXMLWrite(void) result r = E_FAILURE; // Create xml document - const String filepath = App::GetInstance()->GetAppRootPath() + L"data/writemap.xml"; + const String filepath = App::GetInstance()->GetAppDataPath() + L"writemap.xml"; ByteBuffer* pBuf = Tizen::Base::Utility::StringUtil::StringToUtf8N(filepath); TryReturn(pBuf, r, "String to ByteBuffer conversion failed."); @@ -234,14 +237,15 @@ void XmlWriter::RunXMLParseandDisplay(void) { - const String filepath = App::GetInstance()->GetAppRootPath() + L"data/writemap.xml"; + const String filepath = App::GetInstance()->GetAppDataPath() + L"writemap.xml"; xmlNodePtr pRoot = null; + xmlDocPtr pDocument = null; ByteBuffer* pBuf = Tizen::Base::Utility::StringUtil::StringToUtf8N(filepath); - TryReturnVoid(pBuf, "StringToUtf8N failed."); + TryCatch(pBuf, ,"StringToUtf8N failed."); - xmlDocPtr pDocument = xmlParseFile((const char*) pBuf->GetPointer()); - TryCatch(pBuf, , "xmlParseFile failed."); + pDocument = xmlParseFile((const char*) pBuf->GetPointer()); + TryCatch(pDocument, , "xmlParseFile failed."); pRoot = xmlDocGetRootElement(pDocument); TryCatch(pRoot, xmlFreeDoc(pDocument), "xmlDocGetRootElement failed."); @@ -268,11 +272,16 @@ XmlWriter::RunXMLParseandDisplay(void) _pList->UpdateList(); __display = true; + delete pBuf; xmlFreeDoc(pDocument); + return; CATCH: delete pBuf; - pBuf = null; - + if (pDocument) + { + xmlFreeDoc(pDocument); + } + ShowError(); } result @@ -294,3 +303,22 @@ XmlWriter::OnFormBackRequested(Tizen::Ui::Controls::Form& source) SceneManager* pSceneManager = SceneManager::GetInstance(); pSceneManager->GoBackward(BackwardSceneTransition()); } + +void +XmlWriter::ShowError(void) +{ + xmlErrorPtr errPtr = xmlGetLastError(); + if (errPtr != NULL) + { + MessageBox messageBox; + result r; + Tizen::Base::String errMsg = L"Writing error"; + + r=messageBox.Construct(L"", errMsg, MSGBOX_STYLE_NONE, 2000); + TryReturnVoid(r == E_SUCCESS, "MessageBox construction has failed. \n "); + + int modalResult = 0; + messageBox.ShowAndWait(modalResult); + } +} + |