For NSE_43972
authorrashmi udaya <rashmi.uday@samsung.com>
Tue, 2 Jul 2013 06:26:02 +0000 (11:56 +0530)
committerrashmi udaya <rashmi.uday@samsung.com>
Tue, 2 Jul 2013 06:26:02 +0000 (11:56 +0530)
Change-Id: Ic8716cbd442ec4088767d81a67960b784baf0c3e

inc/GlContentUpdateEventListener.h
inc/GlFileListPresentationModel.h
src/GlContentUpdateEventListener.cpp
src/GlFileListPresentationModel.cpp

index 91f768d..17c750f 100644 (file)
@@ -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);
index e506261..9d42499 100644 (file)
@@ -100,6 +100,7 @@ public:
 
        void ClearImageCache(void);
        void ClearProviderId(void);
+       void AddDirectoryIfNew(const Tizen::Base::String& fullPath);
 private:
        FileListPresentationModel(void);
        virtual ~FileListPresentationModel(void);
index f95a798..5efd30f 100644 (file)
@@ -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");
index 06a7e0e..e59bc2f 100644 (file)
@@ -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<String*>(__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()));