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.
24 #include "GlContentUpdateEventListener.h"
25 #include "GlFileListPresentationModel.h"
26 #include "GlAlbumListPresentationModel.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Content;
32 ContentUpdateEventListener* ContentUpdateEventListener::__pContentUpdateEventListener = null;
34 ContentUpdateEventListener::ContentUpdateEventListener(void)
35 : __pContentManager(null)
41 ContentUpdateEventListener::~ContentUpdateEventListener(void)
44 __pContentManager->RemoveContentUpdateEventListener(*this);
45 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
48 ContentUpdateEventListener*
49 ContentUpdateEventListener::GetInstance(void)
52 if (__pContentUpdateEventListener == null)
56 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
58 return __pContentUpdateEventListener;
61 void ContentUpdateEventListener::AddContentListener(void)
63 __pContentManager->AddContentUpdateEventListener(*this);
66 void ContentUpdateEventListener::RemoveContentListener(void)
68 __pContentManager->RemoveContentUpdateEventListener(*this);
72 ContentUpdateEventListener::Construct(void)
76 __pContentManager = new (std::nothrow) ContentManager();
77 __pContentManager->Construct();
78 __pContentManager->AddContentUpdateEventListener(*this);
80 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
85 ContentUpdateEventListener::CreateInstance(void)
88 __pContentUpdateEventListener = new (std::nothrow) ContentUpdateEventListener();
89 result r = __pContentUpdateEventListener->Construct();
90 if (IsFailed(r) == true)
92 delete __pContentUpdateEventListener;
93 __pContentUpdateEventListener = null;
94 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
99 std::atexit(DestroyInstance);
100 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
104 ContentUpdateEventListener::DestroyInstance(void)
106 AppLogDebug("ENTER");
108 delete __pContentUpdateEventListener;
109 __pContentUpdateEventListener = null;
111 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
115 ContentUpdateEventListener::GetChangeNotificationStatus()
117 AppLogDebug("ENTER");
119 return __changeNotificationReceived;
123 ContentUpdateEventListener::ResumeOperation()
125 AppLogDebug("ENTER");
126 AlbumListPresentationModel::GetInstance()->OnContentDeleted();
127 FileListPresentationModel::GetInstance()->OnContentDeleted();
128 __changeNotificationReceived = false;
133 ContentUpdateEventListener::OnContentFileCreated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
135 AppLogDebug("ENTER");
137 if ( contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)
139 AlbumListPresentationModel::GetInstance()->OnContentCreated();
140 FileListPresentationModel::GetInstance()->OnContentCreated();
147 ContentUpdateEventListener::OnContentFileUpdated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
149 AppLogDebug("ENTER");
151 if ( contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)
153 AlbumListPresentationModel::GetInstance()->OnContentUpdated();
154 FileListPresentationModel::GetInstance()->OnContentUpdated();
160 ContentUpdateEventListener::OnContentFileDeleted(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
162 AppLogDebug("ENTER");
164 if ( contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)
166 Tizen::App::UiApp* appPtr = Tizen::App::UiApp::GetInstance();
167 if (appPtr->GetAppUiState() == Tizen::App::APP_UI_STATE_FOREGROUND)
169 AlbumListPresentationModel::GetInstance()->OnContentDeleted();
170 FileListPresentationModel::GetInstance()->OnContentDeleted();
174 __changeNotificationReceived = true;
182 ContentUpdateEventListener::OnContentDirectoryScanCompleted(const Tizen::Base::String& directoryPath, result r)
184 AppLogDebug("ENTER");
186 Tizen::App::UiApp* appPtr = Tizen::App::UiApp::GetInstance();
187 if (appPtr->GetAppUiState() == Tizen::App::APP_UI_STATE_FOREGROUND)
189 AlbumListPresentationModel::GetInstance()->OnContentDeleted();
190 FileListPresentationModel::GetInstance()->OnContentDeleted();
191 AlbumListPresentationModel::GetInstance()->OnContentScanCompleted( directoryPath );
195 __changeNotificationReceived = true;