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 GlGalleryApp.cpp
19 * @brief This is the implementation file for GalleryApp class.
23 #include "GlAlbumListPresentationModel.h"
24 #include "GlContentUpdateEventListener.h"
\r
25 #include "GlFileListPresentationModel.h"
26 #include "GlGalleryApp.h"
27 #include "GlMainFrame.h"
28 #include "GlSettingPresentationModel.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Base::Runtime;
35 using namespace Tizen::Base::Utility;
36 using namespace Tizen::System;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
41 static const wchar_t* PARAM_LANGUAGE = L"http://tizen.org/setting/locale.language";
42 static const wchar_t* PARAM_LOCALE = L"http://tizen.org/setting/locale.country";
44 GalleryApp::GalleryApp(void)
47 , __appControlResult(APP_CTRL_RESULT_SUCCEEDED)
50 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
53 GalleryApp::~GalleryApp(void)
56 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
60 GalleryApp::CreateInstance(void)
63 UiApp* pUiApp = new (std::nothrow) GalleryApp();
64 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
70 GalleryApp::GetAppControlOperationId(void) const
73 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
79 GalleryApp::GetMimeType(void) const
82 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
87 GalleryApp::GetAppControlArguments(void) const
90 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
96 GalleryApp::SendAppControlResult(const AppCtrlResult appControlResult, const IMap* pExtraData)
99 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
100 result r = pAppManager->SendAppControlResult(__requestId, appControlResult, pExtraData);
101 if (r == E_MAX_EXCEEDED)
103 MessageBox messageBox;
104 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
105 MSGBOX_STYLE_NONE, 3000);
107 messageBox.ShowAndWait(modalResult);
110 AppLogDebug("appControlResult is %d", appControlResult);
111 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
115 GalleryApp::OnAppInitializing(AppRegistry& appRegistry)
117 AppLogDebug("ENTER");
118 AppControlProviderManager::GetInstance()->SetAppControlProviderEventListener(this);
119 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
125 GalleryApp::OnAppInitialized(void)
127 AppLogDebug("ENTER");
128 MainFrame* pMainFrame = new (std::nothrow) MainFrame();
129 pMainFrame->Construct();
130 AddFrame(*pMainFrame);
132 SettingInfo::AddSettingEventListener(*this);
133 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
139 GalleryApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
141 AppLogDebug("ENTER");
\r
142 ContentUpdateEventListener* pContentListener = ContentUpdateEventListener::GetInstance();
\r
143 if (pContentListener)
\r
145 pContentListener->RemoveContentListener();
\r
147 AlbumListPresentationModel* pAlbumListPresentationModel = AlbumListPresentationModel::GetInstance();
148 if (pAlbumListPresentationModel != null)
150 pAlbumListPresentationModel->ClearThumbnailRequests(true);
152 FileListPresentationModel* pFileListPresentationModel = FileListPresentationModel::GetInstance();
153 if (pFileListPresentationModel != null)
155 pFileListPresentationModel->ClearThumbnailRequests(true);
161 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
167 GalleryApp::OnForeground(void)
169 AppLogDebug("ENTER");
170 static bool bFirst = true;
177 MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
180 pMainFrame->SetEnabled(true);
181 pMainFrame->Invalidate(true);
184 ContentUpdateEventListener* pContentListener = ContentUpdateEventListener::GetInstance();
185 if (pContentListener->GetChangeNotificationStatus() == true)
187 pContentListener->ResumeOperation();
189 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
193 GalleryApp::OnAppControlRequestReceived(RequestId reqId, const String& operationId,
194 const String* pUriData, const String* pMimeType, const IMap* pExtraData)
196 AppLogDebug("ENTER");
198 __operationId = operationId;
200 if (pMimeType != null)
202 __mimeType = *pMimeType;
204 if (pExtraData != null)
206 HashMap* pArguments = new (std::nothrow) HashMap(SingleObjectDeleter);
207 pArguments->Construct();
209 const String* pKey = null;
210 const String* pValue = null;
211 IList* pKeyList = pExtraData->GetKeysN();
213 int loopCount = pKeyList->GetCount();
214 for (int i = 0; i < loopCount; ++i)
216 pKey = static_cast<const String*>(pKeyList->GetAt(i));
217 pValue = static_cast<const String*>(pExtraData->GetValue(*pKey));
219 pArguments->Add(new (std::nothrow) String(*pKey), new (std::nothrow) String(*pValue));
221 __pArguments = pArguments;
224 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
228 GalleryApp::OnSettingChanged(String& key)
230 AppLogDebug("ENTER");
231 if (key.CompareTo(PARAM_LANGUAGE) == 0 || key.CompareTo(PARAM_LOCALE) == 0)
233 UiApp::GetInstance()->Terminate();
235 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
239 GalleryApp::SetFrameEnabled(const bool enabled)
241 MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
244 pMainFrame->SetEnabled(enabled);
249 GalleryApp::IsHwKeySupported(void)
251 AppLogDebug("ENTER");
253 bool isHwKeyExist = false;
254 Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.back", isHwKeyExist);
256 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));