NABI issue 43925
authorravi.n2 <ravi.n2@samsung.com>
Mon, 1 Jul 2013 08:36:54 +0000 (14:06 +0530)
committerravi.n2 <ravi.n2@samsung.com>
Mon, 1 Jul 2013 08:36:54 +0000 (14:06 +0530)
Change-Id: I7c48a3c61fd60ee300636ea8a2435f44803b8af2

12 files changed:
inc/CmBaseForm.h
inc/CmCameraApp.h
inc/CmCameraPresentationModel.h
inc/CmCameraSettingsPresentationModel.h
inc/CmUtility.h [new file with mode: 0644]
src/CmBaseForm.cpp
src/CmCamcorderForm.cpp
src/CmCameraApp.cpp
src/CmCameraForm.cpp
src/CmCameraPresentationModel.cpp
src/CmCameraSettingsPresentationModel.cpp
src/CmUtility.cpp [new file with mode: 0644]

index 0a7e798..1a27576 100644 (file)
@@ -42,6 +42,7 @@
 #include "CmCameraResourceManager.h"
 #include "CmCameraThumbnailPanel.h"
 #include "CmCameraInfoPanel.h"
+#include "CmUtility.h"
 
 class BaseForm :
 public Tizen::Ui::Controls::Form
@@ -151,6 +152,7 @@ protected:
        void HideScreenOverlayHelp();
        void OnHelpCloseTimerExpired(void);
        bool CheckCallStatus(void);
+       void ShowMemoryFullPopup(void);
 
 protected:
        CameraPresentationModel* _pCameraPresentationModel;
index ac875c8..8b39f3d 100644 (file)
@@ -28,6 +28,7 @@
 #include <FSystem.h>
 #include <FUi.h>
 #include "CmTypes.h"
+#include "CmUtility.h"
 
 class CameraPresentationModel;
 class CameraSettingsPresentationModel;
@@ -76,7 +77,6 @@ public:
 private:
        void OnRequestAppControlTest(void);
        result OnRequestAppControl(void);
-       long long GetAvailableMemory(void);
 
 private:
        RequestId __requestId;
index fcd8260..323e1d6 100644 (file)
@@ -33,6 +33,7 @@
 #include <FUi.h>
 #include "CmICameraEventListener.h"
 #include "CmTypes.h"
+#include "CmUtility.h"
 
 class CameraSettingsPresentationModel;
 
index 4f7c17c..8a4cf5d 100644 (file)
 
 #include <FApp.h>
 #include <FIo.h>
+#include <FBase.h>
 #include <FMedia.h>
+#include <FSystem.h>
 #include "CmTypes.h"
+#include "CmUtility.h"
 
 class CameraSettingsPresentationModel
 {
diff --git a/inc/CmUtility.h b/inc/CmUtility.h
new file mode 100644 (file)
index 0000000..cf47ed9
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file: MfUtility.h
+ * @brief: This file contains the declaration of MfUtility class, which is a common utility function class and
+ * contains helper functions which are used throughout the Application.
+ */
+
+#ifndef _CM_UTILITY_H_
+#define _CM_UTILITY_H_
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FIo.h>
+#include <FSystem.h>
+
+class CmUtility
+{
+public:
+       static long long GetAvailableMemory(void);
+};
+
+#endif /* _CM_UTILITY_H_ */
index c27a316..c3cf85c 100644 (file)
@@ -1153,3 +1153,44 @@ BaseForm::OnAccessibilityScreenReaderStatusChanged (const Control &control, cons
        AppLogDebug("Enter");
        AppLogDebug("Exit");
 }
+
+
+void
+BaseForm::ShowMemoryFullPopup(void)
+{
+       AppLogDebug("ENTER");
+       int modalResult = 0;
+       MessageBox msgBox;
+       AppResource* pAppResource = null;
+       String memoryLowTitle;
+       String memoryLowMessage;
+       result r = E_SUCCESS;
+
+       pAppResource = Application::GetInstance()->GetAppResource();
+       TryReturnVoid(pAppResource != null, "Failed to allocate memory for pAppResource");
+
+       pAppResource->GetString(L"IDS_LOW_MEMORY_MSG_TITLE", memoryLowTitle);
+       pAppResource->GetString(L"IDS_LOW_MEMORY_MSG", memoryLowMessage);
+
+
+       r = msgBox.Construct(memoryLowTitle, memoryLowMessage, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
+       TryReturnVoid(r == E_SUCCESS, "msgBox::Construct() failed by [%s]", GetErrorMessage(r));
+       msgBox.ShowAndWait(modalResult);
+
+       switch (modalResult)
+       {
+       case MSGBOX_RESULT_CLOSE:
+               {
+                       AppLogDebug("MSGBOX_RESULT_CLOSE");
+                       _pCameraPresentationModel->SetAppControlRequestType(CameraPresentationModel::APP_CONTROL_REQUEST_TYPE_FAILED);
+
+                       r = TerminateApp();
+                       AppLogDebug("TerminateApp fail [%s]", GetErrorMessage(r));
+               }
+               break;
+
+       default:
+               break;
+       }
+       AppLogDebug("EXIT");
+}
index b8b5e81..3cb948d 100644 (file)
@@ -1994,6 +1994,7 @@ CamcorderForm::OnCameraActionPerformed(CameraActionEvent event)
                        bool isInitCameraStaus = false;
 
                        bool isCharging = false;
+                       int mem = 0;
                        BatteryLevel batteryLevel;
 
                        CameraApp* pCameraApp = static_cast<CameraApp*>(CameraApp::GetInstance());
@@ -2053,6 +2054,12 @@ CamcorderForm::OnCameraActionPerformed(CameraActionEvent event)
                                        _pCameraPresentationModel->SetStartPreviewException(false);
                                }
 
+                               if(mem < MIN_MEMORY_NEEDED)
+                               {
+                                       ShowMemoryFullPopup();
+                                       return;
+                               }
+
                                batteryLevel = _pCameraPresentationModel->GetBatteryLevel();
                                isCharging = _pCameraPresentationModel->IsCharging();
 
index 617ab74..da153e8 100644 (file)
@@ -182,49 +182,18 @@ CameraApp::OnAppInitialized(void)
        int mode = 0;
        NotificationManager notiMgr;
        String errorMessage;
-       String memoryLowTitle;
-       String memoryLowMessage;
-
-       MessageBox errorMsgBox;
-       int badgeNumber = 0, modResult=0;
-
-       long long mem = GetAvailableMemory();
-       AppResource* pAppResource = null;
-       pAppResource = Application::GetInstance()->GetAppResource();
-
-       pAppResource->GetString(L"IDS_LOW_MEMORY_MSG_TITLE", memoryLowTitle);
-       pAppResource->GetString(L"IDS_LOW_MEMORY_MSG", memoryLowMessage);
-
-       AppLogDebug("%lld",mem);
-       if(mem < MIN_MEMORY_NEEDED)
-       {
-               MessageBox LowMemory;
-               String msg = L"";
-               LowMemory.Construct(memoryLowTitle, memoryLowMessage, MSGBOX_STYLE_NONE,1000);
-               int modalResult = 0;
-               // Calls ShowAndWait() : Draws and Shows itself and processes events
-               LowMemory.ShowAndWait(modalResult);
-
-               if ( GetAppControlType() == APP_CONTROL_TYPE_REQUESET)
-               {
-                       r = AppControlProviderManager::GetInstance()->SendAppControlResult(__requestId, APP_CTRL_RESULT_FAILED, null);
-                       AppLogDebug("Appcontrol result is %s",GetErrorMessage(r));
-               }
-
-               return false;
-
-       }
+       CameraPresentationModel* pCameraPresentationModel = null;
 
        MainFrame* pCameraAppFrame = new (std::nothrow) MainFrame();
        r = pCameraAppFrame->Construct();
 
-       CameraPresentationModel* pCameraPresentationModel = CameraPresentationModel::GetInstance();
-       TryCatch(pCameraPresentationModel != null, r = GetLastResult(), "pCameraPresentationModel is null");
-
        pCameraAppFrame->SetName(STRING_FRAME_NAME);
        r = AddFrame(*pCameraAppFrame);
        TryCatch(r == E_SUCCESS, , "UiApp::AddFrame() fail[%s]", GetErrorMessage(r));
 
+       pCameraPresentationModel = CameraPresentationModel::GetInstance();
+       TryCatch(pCameraPresentationModel != null, r = GetLastResult(), "pCameraPresentationModel is null");
+
        r = pCameraPresentationModel->GetValue(CURRENT_MODE, mode);
        AppLogDebug("Registry :GetvalueResult : %s", GetErrorMessage(r));
 
@@ -241,7 +210,6 @@ CameraApp::OnAppInitialized(void)
                         errorMessage =L"Camera can't launch due to unknown exception, try again!!!";
        }
 
-       TryCatch(r == E_SUCCESS, , "Read register GetValue() fail[%s]", GetErrorMessage(r));
        r = pCameraAppFrame->Initialize(mode);
        TryCatch(r == E_SUCCESS, , "MainFrame::Initialize() fail[%s]", GetErrorMessage(r));
 
@@ -249,14 +217,6 @@ CameraApp::OnAppInitialized(void)
        return true;
 
 CATCH:
-       r = notiMgr.Construct();
-       badgeNumber = notiMgr.GetBadgeNumber();
-       badgeNumber++;
-
-       notiMgr.Notify(errorMessage, 1);
-
-       errorMsgBox.Construct(L"Camera launch failed", errorMessage, MSGBOX_STYLE_NONE, 3000);
-       errorMsgBox.ShowAndWait(modResult);
 
        if ( GetAppControlType() == APP_CONTROL_TYPE_REQUESET)
                AppControlProviderManager::GetInstance()->SendAppControlResult(__requestId, APP_CTRL_RESULT_FAILED, null);
@@ -606,20 +566,3 @@ CameraApp::GetAppControlSwitch(void)
        return switchEnabled;
        AppLogDebug("Exit");
 }
-
-long long
-CameraApp::GetAvailableMemory(void)
-{
-    result r = E_SUCCESS;
-
-    String key(L"http://tizen.org/runtime/storage.available.internal");
-    long long allocatedMemory = 0;
-
-    r = RuntimeInfo::GetValue(key, allocatedMemory);
-    TryCatch(r == E_SUCCESS, , "MyRuntimeInfo: Failed to get value");
-
-    return allocatedMemory;
-
-   CATCH:
-    return 0;
-}
index dc7c67a..033458d 100644 (file)
@@ -1148,6 +1148,7 @@ CameraForm::OnCameraActionPerformed(CameraActionEvent event)
                        bool isInitCameraStaus = false;
                        bool isCharging = false;
                        BatteryLevel batteryLevel = BATTERY_FULL;
+                       int mem = 0;
 
                        __formStatusFrameDeattivated = false;
 
@@ -1192,6 +1193,12 @@ CameraForm::OnCameraActionPerformed(CameraActionEvent event)
                                isCharging = _pCameraPresentationModel->IsCharging();
 
                                AppLogDebug("batteryLevel = %d", batteryLevel);
+                               
+                               if(mem < MIN_MEMORY_NEEDED)
+                               {
+                                       ShowMemoryFullPopup();
+                                       return;
+                               }
 
                                if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
                                {
index c4c8ed5..bc54bd4 100644 (file)
@@ -4272,13 +4272,10 @@ CameraPresentationModel::SetMemoryFullException(bool status)
 bool
 CameraPresentationModel::GetMemoryFullExceptionStatus(void)
 {
-       String key(L"http://tizen.org/runtime/storage.available.internal");
        long long allocatedMemory = 0;
        bool memoryStatus = false;
-       result r = E_SUCCESS;
 
-       r = RuntimeInfo::GetValue(key, allocatedMemory);
-       AppLogDebug("available memory is %lld",allocatedMemory);
+       allocatedMemory = CmUtility::GetAvailableMemory();
 
        if (__memoryFullException && allocatedMemory < MIN_MEMORY_NEEDED)
        {
index 9db7d68..cb33070 100644 (file)
@@ -28,6 +28,7 @@ using namespace Tizen::Base;
 using namespace Tizen::Io;
 using namespace Tizen::Media;
 using namespace Tizen::Graphics;
+using namespace Tizen::System;
 
 static const int DEFAULT_VALUE_ZERO = 0;
 static const int DEFAULT_VALUE_ONE = 1;
@@ -433,9 +434,11 @@ CameraSettingsPresentationModel::CreateRegistry(bool bResetSettings)
        r = __pDefaultCameraRegistry->AddValue(SECTION_CAMCORDER, OVERLAY_HELP_ENABLE, DEFAULT_VALUE_ZERO);
                TryCatch(r == E_SUCCESS, , "Registry::AddValue() failed[%s]", GetErrorMessage(r));
 
-       r = __pDefaultCameraRegistry->Flush();
-       TryCatch(r == E_SUCCESS, , "Registry::Flush() failed[%s]", GetErrorMessage(r));
-
+       if (!(CmUtility::GetAvailableMemory() < MIN_MEMORY_NEEDED))
+       {
+               r = __pDefaultCameraRegistry->Flush();
+               TryCatch(r == E_SUCCESS, , "Registry::Flush() failed[%s]", GetErrorMessage(r));
+       }
        AppLogDebug("Exit");
        return r;
 
diff --git a/src/CmUtility.cpp b/src/CmUtility.cpp
new file mode 100644 (file)
index 0000000..34a33c0
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file: MfUtility.cpp
+ * @brief: This file contains the implementation of MfUtility class, which is a common utility function class and
+ * contains helper functions which are used throughout the Application.
+ */
+
+#include "CmUtility.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::System;
+
+long long
+CmUtility::GetAvailableMemory(void)
+{
+       result r = E_SUCCESS;
+
+       String key(L"http://tizen.org/runtime/storage.available.internal");
+       long long allocatedMemory = 0;
+
+       r = RuntimeInfo::GetValue(key, allocatedMemory);
+       TryCatch(r == E_SUCCESS, , "MyRuntimeInfo: Failed to get value");
+
+       return allocatedMemory;
+
+CATCH:
+       return 0;
+}