HW key changes
[apps/osp/Gallery.git] / src / GlGalleryApp.cpp
index 223f92b..93b84d4 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
@@ -19,9 +19,9 @@
  * @brief              This is the implementation file for GalleryApp class.
  */
 
+#include <FUi.h>
 #include "GlAlbumListPresentationModel.h"
-#include "GlBaseForm.h"
-#include "GlBasePanel.h"
+#include "GlContentUpdateEventListener.h"\r
 #include "GlFileListPresentationModel.h"
 #include "GlGalleryApp.h"
 #include "GlMainFrame.h"
@@ -76,14 +76,6 @@ GalleryApp::GetAppControlOperationId(void) const
 }
 
 String
-GalleryApp::GetUriData(void) const
-{
-       AppLogDebug("ENTER");
-       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
-       return __uriData;
-}
-
-String
 GalleryApp::GetMimeType(void) const
 {
        AppLogDebug("ENTER");
@@ -101,11 +93,21 @@ GalleryApp::GetAppControlArguments(void) const
 }
 
 void
-GalleryApp::SendAppControlResult(AppCtrlResult appControlResult, IMap* pExtraData)
+GalleryApp::SendAppControlResult(const AppCtrlResult appControlResult, const IMap* pExtraData)
 {
        AppLogDebug("ENTER");
        AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
-       pAppManager->SendAppControlResult(__requestId, appControlResult, pExtraData);
+       result r = pAppManager->SendAppControlResult(__requestId, appControlResult, pExtraData);
+       if (r == E_MAX_EXCEEDED)
+       {
+               MessageBox messageBox;
+               messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
+                               MSGBOX_STYLE_NONE, 3000);
+               int modalResult;
+               messageBox.ShowAndWait(modalResult);
+       }
+
+       AppLogDebug("appControlResult is %d", appControlResult);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -127,7 +129,6 @@ GalleryApp::OnAppInitialized(void)
        pMainFrame->Construct();
        AddFrame(*pMainFrame);
 
-       DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
        SettingInfo::AddSettingEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -137,7 +138,12 @@ GalleryApp::OnAppInitialized(void)
 bool
 GalleryApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
 {
-       AppLogDebug("ENTER");
+       AppLogDebug("ENTER");\r
+       ContentUpdateEventListener* pContentListener = ContentUpdateEventListener::GetInstance();\r
+       if (pContentListener)\r
+       {\r
+               pContentListener->RemoveContentListener();\r
+       }\r
        AlbumListPresentationModel* pAlbumListPresentationModel = AlbumListPresentationModel::GetInstance();
        if (pAlbumListPresentationModel != null)
        {
@@ -149,8 +155,6 @@ GalleryApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
                pFileListPresentationModel->ClearThumbnailRequests(true);
        }
 
-       Thread::Sleep(1000);
-
        delete __pArguments;
        __pArguments = null;
 
@@ -171,29 +175,12 @@ GalleryApp::OnForeground(void)
        }
 
        MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
-       pMainFrame->SetEnabled(true);
-       pMainFrame->Invalidate(true);
-
-       SceneManager* pSceneManager = SceneManager::GetInstance();
-       AppAssert(pSceneManager);
-
-       Scene* pScene = pSceneManager->GetCurrentScene();
-       AppAssert(pSceneManager);
-
-       BasePanel* pBasePanel = dynamic_cast<BasePanel*>(pScene->GetPanel());
-       BaseForm* pBaseForm = dynamic_cast<BaseForm*>(pScene->GetForm());
-
-       if (pBasePanel != null)
+       if (pMainFrame)
        {
-               pBasePanel->OnUpdateContentList();
-       }
-       else
-       {
-               if (pBaseForm != null)
-               {
-                       pBaseForm->OnUpdateContentList();
-               }
+               pMainFrame->SetEnabled(true);
+               pMainFrame->Invalidate(true);
        }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -205,10 +192,6 @@ GalleryApp::OnAppControlRequestReceived(RequestId reqId, const String& operation
        __requestId = reqId;
        __operationId = operationId;
 
-       if (pUriData != null)
-       {
-               __uriData = *pUriData;
-       }
        if (pMimeType != null)
        {
                __mimeType = *pMimeType;
@@ -228,10 +211,7 @@ GalleryApp::OnAppControlRequestReceived(RequestId reqId, const String& operation
                        pKey = static_cast<const String*>(pKeyList->GetAt(i));
                        pValue = static_cast<const String*>(pExtraData->GetValue(*pKey));
 
-                       if (pValue != null && pKey->CompareTo(APPCONTROL_RESULT_KEY_LEGACY_RESULT) != 0)
-                       {
-                               pArguments->Add(new (std::nothrow) String(*pKey), new (std::nothrow) String(*pValue));
-                       }
+                       pArguments->Add(new (std::nothrow) String(*pKey), new (std::nothrow) String(*pValue));
                }
                __pArguments = pArguments;
                delete pKeyList;
@@ -240,49 +220,35 @@ GalleryApp::OnAppControlRequestReceived(RequestId reqId, const String& operation
 }
 
 void
-GalleryApp::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
+GalleryApp::OnSettingChanged(String& key)
 {
        AppLogDebug("ENTER");
-       if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
+       if (key.CompareTo(PARAM_LANGUAGE) == 0 || key.CompareTo(PARAM_LOCALE) == 0)
        {
-               SceneManager* pSceneManager = SceneManager::GetInstance();
-               AppAssert(pSceneManager);
-
-               Scene* pScene = pSceneManager->GetCurrentScene();
-               AppAssert(pSceneManager);
-
-               BasePanel* pBasePanel = dynamic_cast<BasePanel*>(pScene->GetPanel());
-               BaseForm* pBaseForm = dynamic_cast<BaseForm*>(pScene->GetForm());
-
-               if (pBasePanel != null  )
-               {
-                       pBasePanel->OnUpdateContentList();
-               }
-               else
-               {
-                       if (pBaseForm != null)
-                       {
-                               pBaseForm->OnUpdateContentList();
-                       }
-               }
+               UiApp::GetInstance()->Terminate();
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
 void
-GalleryApp::OnSettingChanged(String& key)
+GalleryApp::SetFrameEnabled(const bool enabled)
 {
-       AppLogDebug("ENTER");
-       if (key.CompareTo(PARAM_LANGUAGE) == 0 || key.CompareTo(PARAM_LOCALE) == 0)
+       MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
+       if (pMainFrame)
        {
-               UiApp::GetInstance()->Terminate();
+               pMainFrame->SetEnabled(enabled);
        }
-       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
-void
-GalleryApp::SetFrameEnabled(bool enabled)
+bool
+GalleryApp::IsHwKeySupported(void)
 {
-       MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
-       pMainFrame->SetEnabled(enabled);
+       AppLogDebug("ENTER");
+
+       bool isHwKeyExist = false;
+       Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.back", isHwKeyExist);
+
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+
+       return isHwKeyExist;
 }