N_SE-40980
authorabhismita ghosh <g.abhismita@samsung.com>
Tue, 11 Jun 2013 11:10:47 +0000 (16:40 +0530)
committerabhismita ghosh <g.abhismita@samsung.com>
Tue, 11 Jun 2013 11:10:47 +0000 (16:40 +0530)
Change-Id: Ie3aa3d45490d43aded3e888be31482ebc9c97d6b

inc/VpTypes.h
inc/VpVideoPlayerApp.h [changed mode: 0644->0755]
src/VpTypes.cpp
src/VpVideoPlayerApp.cpp

index 8940848..2e8d447 100755 (executable)
@@ -91,4 +91,7 @@ extern const wchar_t* IDC_LABEL_FULLTIME;
 extern const wchar_t* IDC_LABEL_VIDEO_TITLE;
 extern const wchar_t* IDC_SLIDER;
 
+extern const wchar_t* DEVICE_STORAGE_CARD_MOUNTED;
+extern const wchar_t* DEVICE_STORAGE_CARD_UNMOUNTED;
+
 #endif // _VP_TYPES_H_
old mode 100644 (file)
new mode 100755 (executable)
index a636a03..e6a2b10
@@ -31,6 +31,7 @@ class VideoPlayerApp
        : public Tizen::App::UiApp
        , public Tizen::App::IAppControlProviderEventListener
        , public Tizen::System::IChargingEventListener
+       , public Tizen::System::IDeviceEventListener
        , public Tizen::System::ISettingEventListener
 {
 public:
@@ -66,6 +67,8 @@ public:
 
        virtual void OnForeground(void);
 
+       virtual void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state);
+
        const Tizen::Base::String* GetArgument(const Tizen::Base::String& key) const;
 
 private:
index 2f71243..cc25bc3 100755 (executable)
@@ -61,3 +61,6 @@ const wchar_t* IDC_LABEL_CURRENTTIME = L"IDC_LABEL_CURRENTTIME";
 const wchar_t* IDC_LABEL_FULLTIME = L"IDC_LABEL_FULLTIME";
 const wchar_t* IDC_LABEL_VIDEO_TITLE = L"IDC_LABEL_VIDEO_TITLE";
 const wchar_t* IDC_SLIDER = L"IDC_SLIDER";
+
+const wchar_t* DEVICE_STORAGE_CARD_MOUNTED = L"Mounted";
+const wchar_t* DEVICE_STORAGE_CARD_UNMOUNTED = L"Unmounted";
index d295c10..ebea012 100755 (executable)
@@ -104,6 +104,8 @@ VideoPlayerApp::OnAppInitializing(AppRegistry& appRegistry)
 
        PowerManager::SetChargingEventListener(*this);
 
+       DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+
        return true;
 }
 
@@ -129,6 +131,8 @@ VideoPlayerApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTerminatio
 
        PowerManager::RemoveChargingEventListener(*this);
 
+       DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+
        delete __pArguments;
        __pArguments = null;
 
@@ -252,6 +256,7 @@ VideoPlayerApp::OnSettingChanged(String& key)
        if (key.CompareTo(PARAM_LANGUAGE) == 0 || key.CompareTo(PARAM_COUNTRY) == 0)
        {
                UiApp* pApp = UiApp::GetInstance();
+               TryReturnVoid(pApp != null, "pApp is null");
                pApp->Terminate();
        }
 }
@@ -275,3 +280,20 @@ VideoPlayerApp::OnForeground(void)
                pMainFrame->Invalidate(true);
        }
 }
+
+void
+VideoPlayerApp::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
+{
+       AppLogDebug("OnDeviceStateChanged");
+
+       String extStoragePath = Environment::GetExternalStoragePath();
+       String uriData = GetUriData();
+
+       if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED
+               && uriData.StartsWith(extStoragePath, 0) == true)
+       {
+               UiApp* pApp = UiApp::GetInstance();
+               TryReturnVoid(pApp != null, "pApp is null");
+               pApp->Terminate();
+       }
+}