diff options
-rw-r--r-- | project/inc/FileManagerForm.h | 1 | ||||
-rw-r--r-- | project/src/FileManagerForm.cpp | 45 |
2 files changed, 45 insertions, 1 deletions
diff --git a/project/inc/FileManagerForm.h b/project/inc/FileManagerForm.h index 0a24ecc..84ebed3 100644 --- a/project/inc/FileManagerForm.h +++ b/project/inc/FileManagerForm.h @@ -68,6 +68,7 @@ private: const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + bool TestAlphaNumeric(Tizen::Base::String& str); private: static const int ID_FORMAT_STRING = 500; diff --git a/project/src/FileManagerForm.cpp b/project/src/FileManagerForm.cpp index 9bee61f..3e1485e 100644 --- a/project/src/FileManagerForm.cpp +++ b/project/src/FileManagerForm.cpp @@ -119,7 +119,30 @@ FileManagerForm::OnActionPerformed (const Tizen::Ui::Control &source, int action { fileName.Append(__extension); } - __currentImagePath = __currentPath + "/" + fileName; + + if(!(TestAlphaNumeric(fileName))) + { + MessageBox msgBox; + int modalResult; + + msgBox.Construct(L"Error", L"Please enter valid file name.\nOnly alphanumeric characters.", MSGBOX_STYLE_OK); + msgBox.ShowAndWait(modalResult); + return; + } + + if(*(fileName.GetPointer()) == '.') + { + MessageBox msgBox; + int modalResult; + + msgBox.Construct(L"Error", L"Please enter valid file name.\nOnly alphanumeric characters.", MSGBOX_STYLE_OK); + msgBox.ShowAndWait(modalResult); + return; + } + + fileName.Trim(); + + __currentImagePath = __currentPath + "/" + fileName; if (IsFile(__currentImagePath)) { @@ -420,6 +443,26 @@ FileManagerForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSce { } +bool +FileManagerForm::TestAlphaNumeric(Tizen::Base::String& str) +{ + Tizen::Base::String supportedSymbols = L"QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890."; + Tizen::Base::String tempStr = str; + + int legnth = supportedSymbols.GetLength(); + wchar_t ch; + + for(int i = 0; i < legnth; ++i) + { + supportedSymbols.GetCharAt(i,ch); + tempStr.Replace(ch," "); + } + tempStr.Trim(); + + return tempStr.IsEmpty(); + +} + void FileManagerForm::OnAppForeGround(void) { |