2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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.
22 #include "GlAlbumListPresentationModel.h"
23 #include "GlBaseForm.h"
24 #include "GlBasePanel.h"
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::GetUriData(void) const
82 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
87 GalleryApp::GetMimeType(void) const
90 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
95 GalleryApp::GetAppControlArguments(void) const
98 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
104 GalleryApp::SendAppControlResult(AppCtrlResult appControlResult, IMap* pExtraData)
106 AppLogDebug("ENTER");
107 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
108 pAppManager->SendAppControlResult(__requestId, appControlResult, pExtraData);
109 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
113 GalleryApp::OnAppInitializing(AppRegistry& appRegistry)
115 AppLogDebug("ENTER");
116 AppControlProviderManager::GetInstance()->SetAppControlProviderEventListener(this);
117 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
123 GalleryApp::OnAppInitialized(void)
125 AppLogDebug("ENTER");
126 MainFrame* pMainFrame = new (std::nothrow) MainFrame();
127 pMainFrame->Construct();
128 AddFrame(*pMainFrame);
130 SettingInfo::AddSettingEventListener(*this);
131 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
137 GalleryApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
139 AppLogDebug("ENTER");
140 AlbumListPresentationModel* pAlbumListPresentationModel = AlbumListPresentationModel::GetInstance();
141 if (pAlbumListPresentationModel != null)
143 pAlbumListPresentationModel->ClearThumbnailRequests(true);
145 FileListPresentationModel* pFileListPresentationModel = FileListPresentationModel::GetInstance();
146 if (pFileListPresentationModel != null)
148 pFileListPresentationModel->ClearThumbnailRequests(true);
156 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
162 GalleryApp::OnForeground(void)
164 AppLogDebug("ENTER");
165 static bool bFirst = true;
172 MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
173 pMainFrame->SetEnabled(true);
174 pMainFrame->Invalidate(true);
176 SceneManager* pSceneManager = SceneManager::GetInstance();
177 AppAssert(pSceneManager);
179 Scene* pScene = pSceneManager->GetCurrentScene();
180 AppAssert(pSceneManager);
182 BasePanel* pBasePanel = dynamic_cast<BasePanel*>(pScene->GetPanel());
183 BaseForm* pBaseForm = dynamic_cast<BaseForm*>(pScene->GetForm());
185 if(pBasePanel != null )
187 pBasePanel->OnUpdateContentList();
191 if (pBaseForm != null)
193 pBaseForm->OnUpdateContentList();
196 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
200 GalleryApp::OnAppControlRequestReceived(RequestId reqId, const String& operationId,
201 const String* pUriData, const String* pMimeType, const IMap* pExtraData)
203 AppLogDebug("ENTER");
205 __operationId = operationId;
207 if (pUriData != null)
209 __uriData = *pUriData;
211 if (pMimeType != null)
213 __mimeType = *pMimeType;
215 if (pExtraData != null)
217 HashMap* pArguments = new (std::nothrow) HashMap(SingleObjectDeleter);
218 pArguments->Construct();
220 const String* pKey = null;
221 const String* pValue = null;
222 IList* pKeyList = pExtraData->GetKeysN();
224 int loopCount = pKeyList->GetCount();
225 for (int i = 0; i < loopCount; ++i)
227 pKey = static_cast<const String*>(pKeyList->GetAt(i));
228 pValue = static_cast<const String*>(pExtraData->GetValue(*pKey));
230 if (pValue != null && pKey->CompareTo(APPCONTROL_RESULT_KEY_LEGACY_RESULT) != 0)
232 pArguments->Add(new (std::nothrow) String(*pKey), new (std::nothrow) String(*pValue));
235 __pArguments = pArguments;
238 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
242 GalleryApp::OnSettingChanged(String& key)
244 AppLogDebug("ENTER");
245 if (key.CompareTo(PARAM_LANGUAGE) == 0 || key.CompareTo(PARAM_LOCALE) == 0)
247 UiApp::GetInstance()->Terminate();
249 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
253 GalleryApp::SetFrameEnabled(bool enabled)
255 MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
256 pMainFrame->SetEnabled(enabled);