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 GalleryApp::GalleryApp(void)
44 , __appControlResult(APP_CTRL_RESULT_SUCCEEDED)
45 , __frameActivated(false)
48 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
51 GalleryApp::~GalleryApp(void)
54 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
58 GalleryApp::CreateInstance(void)
61 UiApp* pUiApp = new (std::nothrow) GalleryApp();
62 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
68 GalleryApp::GetAppControlOperationId(void) const
71 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
77 GalleryApp::GetMimeType(void) const
80 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
85 GalleryApp::GetAppControlArguments(void) const
88 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
94 GalleryApp::SendAppControlResult(const AppCtrlResult appControlResult, const IMap* pExtraData)
97 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
98 result r = pAppManager->SendAppControlResult(__requestId, appControlResult, pExtraData);
99 if (r == E_MAX_EXCEEDED)
101 MessageBox messageBox;
102 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
103 MSGBOX_STYLE_NONE, 3000);
105 messageBox.ShowAndWait(modalResult);
108 AppLogDebug("appControlResult is %d", appControlResult);
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");
\r
140 ContentUpdateEventListener* pContentListener = ContentUpdateEventListener::GetInstance();
\r
141 if (pContentListener)
\r
143 pContentListener->RemoveContentListener();
\r
145 AlbumListPresentationModel* pAlbumListPresentationModel = AlbumListPresentationModel::GetInstance();
146 if (pAlbumListPresentationModel != null)
148 pAlbumListPresentationModel->ClearThumbnailRequests(true);
150 FileListPresentationModel* pFileListPresentationModel = FileListPresentationModel::GetInstance();
151 if (pFileListPresentationModel != null)
153 pFileListPresentationModel->ClearThumbnailRequests(true);
159 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
165 GalleryApp::OnForeground(void)
167 AppLogDebug("ENTER");
168 static bool bFirst = true;
175 MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
178 pMainFrame->SetEnabled(true);
179 pMainFrame->Invalidate(true);
182 ContentUpdateEventListener* pContentListener = ContentUpdateEventListener::GetInstance();
183 if (pContentListener->GetChangeNotificationStatus() == true)
185 pContentListener->ResumeOperation();
187 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
191 GalleryApp::OnAppControlRequestReceived(RequestId reqId, const String& operationId,
192 const String* pUriData, const String* pMimeType, const IMap* pExtraData)
194 AppLogDebug("ENTER");
196 __operationId = operationId;
198 if (pMimeType != null)
200 __mimeType = *pMimeType;
202 if (pExtraData != null)
204 HashMap* pArguments = new (std::nothrow) HashMap(SingleObjectDeleter);
205 pArguments->Construct();
207 const String* pKey = null;
208 const String* pValue = null;
209 IList* pKeyList = pExtraData->GetKeysN();
211 int loopCount = pKeyList->GetCount();
212 for (int i = 0; i < loopCount; ++i)
214 pKey = static_cast<const String*>(pKeyList->GetAt(i));
215 pValue = static_cast<const String*>(pExtraData->GetValue(*pKey));
217 pArguments->Add(new (std::nothrow) String(*pKey), new (std::nothrow) String(*pValue));
219 __pArguments = pArguments;
222 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
226 GalleryApp::OnSettingChanged(String& key)
228 AppLogDebug("ENTER key(%ls)", key.GetPointer());
229 if (key.CompareTo(SETTING_KEY_LANGUAGE) == 0 || key.CompareTo(SETTING_KEY_FONT_SIZE) == 0)
231 UiApp::GetInstance()->Terminate();
233 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
237 GalleryApp::SetFrameEnabled(const bool enabled)
239 MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
242 pMainFrame->SetEnabled(enabled);
247 GalleryApp::SetFrameActivated(bool frameActivated)
249 __frameActivated = frameActivated;
253 GalleryApp::GetFrameActivated(void) const
255 return __frameActivated;