From 0b3afc6c04c7b61006f63f3be5401adc8144bf39 Mon Sep 17 00:00:00 2001 From: rashmi udaya Date: Tue, 2 Jul 2013 11:56:02 +0530 Subject: [PATCH] For NSE_43972 Change-Id: Ic8716cbd442ec4088767d81a67960b784baf0c3e --- inc/GlContentUpdateEventListener.h | 2 +- inc/GlFileListPresentationModel.h | 1 + src/GlContentUpdateEventListener.cpp | 35 +++++++++++++++++++++++++++++++++-- src/GlFileListPresentationModel.cpp | 29 +++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/inc/GlContentUpdateEventListener.h b/inc/GlContentUpdateEventListener.h index 91f768d..17c750f 100644 --- a/inc/GlContentUpdateEventListener.h +++ b/inc/GlContentUpdateEventListener.h @@ -34,7 +34,7 @@ public: void RemoveContentListener(void); bool GetChangeNotificationStatus(); void ResumeOperation(); - + Tizen::Base::String GetDirecotyNameFromFullPath(const Tizen::Base::String& fullPath) const; private: ContentUpdateEventListener(void); virtual ~ContentUpdateEventListener(void); diff --git a/inc/GlFileListPresentationModel.h b/inc/GlFileListPresentationModel.h index e506261..9d42499 100644 --- a/inc/GlFileListPresentationModel.h +++ b/inc/GlFileListPresentationModel.h @@ -100,6 +100,7 @@ public: void ClearImageCache(void); void ClearProviderId(void); + void AddDirectoryIfNew(const Tizen::Base::String& fullPath); private: FileListPresentationModel(void); virtual ~FileListPresentationModel(void); diff --git a/src/GlContentUpdateEventListener.cpp b/src/GlContentUpdateEventListener.cpp index f95a798..5efd30f 100644 --- a/src/GlContentUpdateEventListener.cpp +++ b/src/GlContentUpdateEventListener.cpp @@ -27,6 +27,7 @@ using namespace Tizen::Base; using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; using namespace Tizen::Content; ContentUpdateEventListener* ContentUpdateEventListener::__pContentUpdateEventListener = null; @@ -129,15 +130,45 @@ ContentUpdateEventListener::ResumeOperation() AppLogDebug("EXIT"); } +String +ContentUpdateEventListener::GetDirecotyNameFromFullPath(const String& fullPath)const +{ + AppLogDebug("ENTER"); + if (fullPath == null) + { + AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult())); + + return null; + } + String delim(DIRECTORY_SEPARATOR); + StringTokenizer st(fullPath,delim); + String token; + String tokenPrev; + while (st.HasMoreTokens()) + { + tokenPrev = token; + st.GetNextToken(token); + } + + AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult())); + + return tokenPrev; +} + void ContentUpdateEventListener::OnContentFileCreated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r) { AppLogDebug("ENTER"); - if ( contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO) { + Tizen::Content::ContentInfo* cntInfo = __pContentManager->GetContentInfoN(contentId); + String path = cntInfo->GetContentPath(); + String dirName = GetDirecotyNameFromFullPath(path); + + FileListPresentationModel* pFileListPM = FileListPresentationModel::GetInstance(); + pFileListPM->AddDirectoryIfNew(dirName); AlbumListPresentationModel::GetInstance()->OnContentCreated(); - FileListPresentationModel::GetInstance()->OnContentCreated(); + pFileListPM->OnContentCreated(); } AppLogDebug("EXIT"); diff --git a/src/GlFileListPresentationModel.cpp b/src/GlFileListPresentationModel.cpp index 06a7e0e..e59bc2f 100644 --- a/src/GlFileListPresentationModel.cpp +++ b/src/GlFileListPresentationModel.cpp @@ -1147,6 +1147,34 @@ FileListPresentationModel::RefreshCurrentAlbumContentInfoList(const ContentType return r; } +void +FileListPresentationModel::AddDirectoryIfNew(const String& dirName) +{ + bool isMatched = false; + int dirCount = __pDirectoryList->GetCount(); + if (__albumName != ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS"))//we are not in All albums + { + return; + } + for (int i = 0; i < dirCount ; ++i) + { + if (static_cast(__pDirectoryList->GetAt(i))->CompareTo(dirName) == 0) + { + isMatched = true; + break; + } + } + if (!isMatched) + { + String fullPath = Environment::GetMediaPath(); + fullPath.Append(dirName); + __pDirectoryList->Add(new (std::nothrow) String(fullPath)); + + } +} + + + result FileListPresentationModel::RefreshContentInfoList(const ContentType contentType) { @@ -1172,6 +1200,7 @@ FileListPresentationModel::RefreshContentInfoList(const ContentType contentType) delete __pContentInfoList; __pContentInfoList = null; } + __pContentInfoList = GetContentInfoListInDirectoryListN(*__pDirectoryList, __albumContentType); AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult())); -- 2.7.4