2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file GlContentUpdateEventListener.cpp
19 * @brief This is the implementation file for ContentUpdateEventListener class.
22 #include "GlContentUpdateEventListener.h"
23 #include "GlFileListPresentationModel.h"
24 #include "GlAlbumListPresentationModel.h"
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::Content;
30 ContentUpdateEventListener* ContentUpdateEventListener::__pContentUpdateEventListener = null;
32 ContentUpdateEventListener::ContentUpdateEventListener(void)
33 : __pContentManager(null)
34 , __isSingleFileUpdate(false)
40 ContentUpdateEventListener::~ContentUpdateEventListener(void)
43 __pContentManager->RemoveContentUpdateEventListener(*this);
44 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
47 ContentUpdateEventListener*
48 ContentUpdateEventListener::GetInstance(void)
51 if (__pContentUpdateEventListener == null)
55 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
57 return __pContentUpdateEventListener;
60 void ContentUpdateEventListener::AddContentListener(void)
62 __pContentManager->AddContentUpdateEventListener(*this);
65 void ContentUpdateEventListener::RemoveContentListener(void)
67 __pContentManager->RemoveContentUpdateEventListener(*this);
71 ContentUpdateEventListener::Construct(void)
75 __pContentManager = new (std::nothrow) ContentManager();
76 __pContentManager->Construct();
77 __pContentManager->AddContentUpdateEventListener(*this);
79 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
84 ContentUpdateEventListener::CreateInstance(void)
87 __pContentUpdateEventListener = new (std::nothrow) ContentUpdateEventListener();
88 result r = __pContentUpdateEventListener->Construct();
89 if (IsFailed(r) == true)
91 delete __pContentUpdateEventListener;
92 __pContentUpdateEventListener = null;
93 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
98 std::atexit(DestroyInstance);
99 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
103 ContentUpdateEventListener::DestroyInstance(void)
105 AppLogDebug("ENTER");
107 delete __pContentUpdateEventListener;
108 __pContentUpdateEventListener = null;
110 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
114 ContentUpdateEventListener::OnContentFileCreated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
116 AppLogDebug("ENTER");
117 __isSingleFileUpdate = true;
119 if ( contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)
121 AlbumListPresentationModel::GetInstance()->OnContentCreated();
122 FileListPresentationModel::GetInstance()->OnContentCreated();
129 ContentUpdateEventListener::OnContentFileUpdated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
131 AppLogDebug("ENTER");
132 __isSingleFileUpdate = true;
134 if ( contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)
136 AlbumListPresentationModel::GetInstance()->OnContentUpdated();
137 FileListPresentationModel::GetInstance()->OnContentUpdated();
143 ContentUpdateEventListener::OnContentFileDeleted(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
145 AppLogDebug("ENTER");
146 __isSingleFileUpdate = true;
148 if ( contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)
150 AlbumListPresentationModel::GetInstance()->OnContentDeleted();
151 FileListPresentationModel::GetInstance()->OnContentDeleted();
158 ContentUpdateEventListener::OnContentDirectoryScanCompleted(const Tizen::Base::String& directoryPath, result r)
160 AppLogDebug("ENTER");
161 if (__isSingleFileUpdate == false)
163 AlbumListPresentationModel::GetInstance()->OnContentDeleted();
164 FileListPresentationModel::GetInstance()->OnContentDeleted();
165 AlbumListPresentationModel::GetInstance()->OnContentScanCompleted( directoryPath );
\r
169 __isSingleFileUpdate = false;