Code clean up submit/tizen_2.2/20130714.134547 submit/tizen_2.2/20130714.143220
authorAbhismita Ghosh <g.abhismita@samsung.com>
Thu, 11 Jul 2013 11:36:27 +0000 (20:36 +0900)
committerAbhismita Ghosh <g.abhismita@samsung.com>
Thu, 11 Jul 2013 11:36:27 +0000 (20:36 +0900)
Change-Id: I46fbf91418871dcfe46e1f136c9b514ddddeed02

inc/VpVideoPlayerApp.h
inc/VpVideoPlayerForm.h
inc/VpVolumeSettingPopup.h
src/VpVideoPlayerApp.cpp
src/VpVideoPlayerForm.cpp
src/VpVideoPlayerPresentationModel.cpp
src/VpVolumeSettingPopup.cpp

index bbd045f..683c165 100755 (executable)
@@ -28,8 +28,8 @@
 #include <FUi.h>
 
 class VideoPlayerApp
-       : public Tizen::App::IAppControlProviderEventListener
-       , public Tizen::App::UiApp
+       : public Tizen::App::UiApp
+       , public Tizen::App::IAppControlProviderEventListener
        , public Tizen::System::IChargingEventListener
        , public Tizen::System::IDeviceEventListener
        , public Tizen::System::ISettingEventListener
@@ -46,16 +46,16 @@ public:
 
        void SetFrameEnabled(bool enabled);
 
-       virtual void OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId,
-                                               const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType,
-                                               const Tizen::Base::Collection::IMap* pExtraData);
-
        virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
        virtual bool OnAppInitialized(void);
        virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
        virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
        virtual void OnForeground(void);
 
+       virtual void OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId,
+                                               const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType,
+                                               const Tizen::Base::Collection::IMap* pExtraData);
+
        virtual void OnChargingStateChanged(bool charging);
 
        virtual void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state);
index 9862f85..0a887b8 100755 (executable)
@@ -34,10 +34,10 @@ class SoundPathPopup;
 class VideoPlayerPresentationModel;
 
 class VideoPlayerForm
-       : public Tizen::App::IAppControlResponseListener
+       : public Tizen::Ui::Controls::Form
+       , public Tizen::App::IAppControlResponseListener
        , public Tizen::Base::Runtime::ITimerEventListener
        , public Tizen::Media::IAudioRouteEventListener
-       , public Tizen::Ui::Controls::Form
        , public Tizen::Ui::Controls::IFormBackEventListener
        , public Tizen::Ui::Controls::ISliderEventListener
        , public Tizen::Ui::IActionEventListener
@@ -62,6 +62,10 @@ public:
        void SetFrameActivated(bool frameActivated);
        bool GetFrameActivated(void) const;
 
+       virtual result OnInitializing(void);
+       virtual result OnTerminating(void);
+       virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs);
+
        virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId,
                                const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult,
                                const Tizen::Base::Collection::IMap* pExtraData);
@@ -72,10 +76,6 @@ public:
        virtual void OnAudioRouteAdded(const Tizen::Media::AudioRouteInfo& route);
        virtual void OnAudioRouteRemoved(const Tizen::Media::AudioRouteInfo& route);
 
-       virtual result OnInitializing(void);
-       virtual result OnTerminating(void);
-       virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs);
-
        virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
 
        virtual void OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value);
index 313872f..774e58c 100644 (file)
@@ -27,9 +27,9 @@
 #include <FUi.h>
 
 class VolumeSettingPopup
-       : public Tizen::Base::Runtime::ITimerEventListener
+       : public Tizen::Ui::Controls::Popup
+       , public Tizen::Base::Runtime::ITimerEventListener
        , public Tizen::Ui::Controls::ISliderEventListener
-       , public Tizen::Ui::Controls::Popup
        , public Tizen::Ui::IActionEventListener
        , public Tizen::Ui::IAdjustmentEventListener
        , public Tizen::Ui::IKeyEventListener
index cd3eb41..7ff027b 100644 (file)
@@ -135,7 +135,7 @@ VideoPlayerApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTerminatio
 void
 VideoPlayerApp::OnBatteryLevelChanged(BatteryLevel batteryLevel)
 {
-       AppLogDebug("OnBatteryLevelChanged");
+       AppLogDebug("OnBatteryLevelChanged: [%d]", batteryLevel);
 
        UiApp* pApp = UiApp::GetInstance();
        TryReturnVoid(pApp != null, "pApp is null");
@@ -155,31 +155,23 @@ VideoPlayerApp::OnBatteryLevelChanged(BatteryLevel batteryLevel)
 void
 VideoPlayerApp::OnChargingStateChanged(bool charging)
 {
-       AppLogDebug("OnChargingStateChanged");
+       AppLogDebug("OnChargingStateChanged [%d]", charging);
 
        if (charging == false)
        {
                UiApp* pApp = UiApp::GetInstance();
+               TryReturnVoid(pApp != null, "pApp is null");
 
-               if (pApp != null)
-               {
-                       IAppFrame* pAppFrame = pApp->GetAppFrame();
+               IAppFrame* pAppFrame = pApp->GetAppFrame();
+               TryReturnVoid(pAppFrame != null, "pAppFrame is null");
 
-                       if (pAppFrame != null)
-                       {
-                               Frame* pFrame = pAppFrame->GetFrame();
+               Frame* pFrame = pAppFrame->GetFrame();
+               TryReturnVoid(pFrame != null, "pFrame is null");
 
-                               if (pFrame != null)
-                               {
-                                       VideoPlayerForm* pForm = static_cast<VideoPlayerForm*>(pFrame->GetCurrentForm());
+               VideoPlayerForm* pForm = static_cast<VideoPlayerForm*>(pFrame->GetCurrentForm());
+               TryReturnVoid(pForm != null, "pForm is null");
 
-                                       if (pForm != null)
-                                       {
-                                               pForm->SendUserEvent(REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED, null);
-                                       }
-                               }
-                       }
-               }
+               pForm->SendUserEvent(REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED, null);
        }
 }
 
@@ -198,7 +190,7 @@ VideoPlayerApp::OnAppControlRequestReceived(RequestId reqId, const String& opera
                String replace;
                __uriData = *pUriData;
                __uriData.Replace(original, replace);
-               AppLog("__uriData(%ls) pUriData(%ls)", __uriData.GetPointer(), pUriData->GetPointer());
+               AppLogDebug("__uriData(%ls) pUriData(%ls)", __uriData.GetPointer(), pUriData->GetPointer());
        }
 
        if (pExtraData != null)
@@ -245,7 +237,9 @@ VideoPlayerApp::OnSettingChanged(String& key)
 
        if (key.CompareTo(SETTING_KEY_LANGUAGE) == 0 || key.CompareTo(SETTING_KEY_FONT_SIZE) == 0)
        {
-               UiApp::GetInstance()->Terminate();
+               UiApp* pApp = UiApp::GetInstance();
+               TryReturnVoid(pApp != null, "pApp is null");
+               pApp->Terminate();
        }
 }
 
@@ -272,7 +266,7 @@ VideoPlayerApp::OnForeground(void)
 void
 VideoPlayerApp::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
 {
-       AppLogDebug("OnDeviceStateChanged");
+       AppLogDebug("OnDeviceStateChanged [%d][%ls]", deviceType, state.GetPointer());
 
        String extStoragePath = Environment::GetExternalStoragePath();
        String uriData = GetUriData();
index bdb6e9d..0be6db5 100644 (file)
@@ -48,7 +48,7 @@ static const int MAX_PROGRESS_RANGE = 100;
 static const int SHOW_CONTROL_DURATION = 5000;
 
 static const int MILLISECOND = 1000;
-static const int START_TIME = 0;
+static const int SLIDER_START_VALUE = 0;
 static const int SEEK_TIME_NONE = -1;
 
 static const int X_BASE = 0;
@@ -67,9 +67,9 @@ static const int COLOR_THUMB_ALPHA = 0;
 
 static const int MULTI_CONTENT_COUNT = 2;
 
-static const int MESSAGEBOX_DISPLAY_TIME_3_SEC = 3000;
+static const int MESSAGEBOX_DISPLAY_TIMEOUT = 3000;
 
-static const wchar_t* INIT_TIME = L"00:00:00";
+static const wchar_t* SLIDER_INIT_TIME = L"00:00:00";
 
 static const RequestId REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU = 111;
 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU = 112;
@@ -274,8 +274,7 @@ VideoPlayerForm::SetScreenMode(const ScreenMode mode, bool destroyOverlay)
 
        case SCREEN_MODE_FIT:
                {
-                       Rectangle videoRect = __pVideoPlayerPresentationModel->GetVideoInfoN(
-                                       __pVideoPlayerPresentationModel->GetMediaPathName());
+                       Rectangle videoRect = __pVideoPlayerPresentationModel->GetVideoInfoN(__pVideoPlayerPresentationModel->GetMediaPathName());
 
                        Rectangle rect(0, 0, videoRect.width, videoRect.height);
 
@@ -627,9 +626,9 @@ VideoPlayerForm::OnPlayEndOfClip(bool playNextContent, int repeatMode, int media
 
        __pUiControlTimer->Cancel();
        ShowControl(true);
-       UpdateProgressBar(START_TIME);
+       UpdateProgressBar(SLIDER_START_VALUE);
 
-       __pCurrenTimeLabel->SetText(INIT_TIME);
+       __pCurrenTimeLabel->SetText(SLIDER_INIT_TIME);
        __pCurrenTimeLabel->Invalidate(true);
 
        pPlayBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_play.png");
@@ -761,7 +760,7 @@ VideoPlayerForm::OnPlayErrorOccurred(PlayerErrorReason r)
                        pAppResource = Application::GetInstance()->GetAppResource();
                        pAppResource->GetString(IDS_COM_POP_UNSUPPORTED_FILE_TYPE, messageBoxString);
 
-                       messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
+                       messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
                        messageBox.ShowAndWait(modalResult);
 
                        UiApp* pApp = UiApp::GetInstance();
@@ -777,7 +776,7 @@ VideoPlayerForm::OnPlayErrorOccurred(PlayerErrorReason r)
                        pAppResource = Application::GetInstance()->GetAppResource();
                        pAppResource->GetString(IDS_VPL_POP_UNABLE_TO_PLAY_VIDEO_ERROR_OCCURRED, messageBoxString);
 
-                       messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
+                       messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
                        messageBox.ShowAndWait(modalResult);
 
                        UiApp* pApp = UiApp::GetInstance();
@@ -1034,15 +1033,13 @@ VideoPlayerForm::OnActionPerformed(const Control& source, int actionId)
        case IDA_CONTEXTMENU_MESSAGE:
                {
                        AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE);
-                       if (pAppControl == null)
-                       {
-                               return;
-                       }
+                       TryReturnVoid(pAppControl != null, "pAppControl is null");
 
                        String filePath = __pVideoPlayerPresentationModel->GetMediaPathName();
-                       AppLog("filePath(%ls)", filePath.GetPointer());
+
                        HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
                        pDataList->Construct();
+
                        ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
                        pList->Add(new (std::nothrow) String(filePath));
                        pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
@@ -1064,15 +1061,13 @@ VideoPlayerForm::OnActionPerformed(const Control& source, int actionId)
        case IDA_CONTEXTMENU_EMAIL:
                {
                        AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE);
-                       if (pAppControl == null)
-                       {
-                               return;
-                       }
+                       TryReturnVoid(pAppControl != null, "pAppControl is null");
 
                        String filePath = __pVideoPlayerPresentationModel->GetMediaPathName();
 
                        HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
                        pDataList->Construct();
+
                        ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
                        pList->Add(new (std::nothrow) String(filePath));
                        pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
@@ -1167,8 +1162,7 @@ VideoPlayerForm::OnTouchReleased(const Control& source, const Point& currentPosi
 
        playState = __pVideoPlayerPresentationModel->GetState();
 
-       if (playState == PLAYER_STATE_PLAYING || playState == PLAYER_STATE_PAUSED
-                       || playState == PLAYER_STATE_ENDOFCLIP)
+       if (playState == PLAYER_STATE_PLAYING || playState == PLAYER_STATE_PAUSED || playState == PLAYER_STATE_ENDOFCLIP)
        {
                if (source.GetName() == L"IDL_MAIN_FORM"
                        || source.GetHashCode() == __pOverlayPanel->GetHashCode()
@@ -1710,7 +1704,7 @@ VideoPlayerForm::CheckLowBatteryStatus(void)
                        AppResource* pAppResource = Application::GetInstance()->GetAppResource();
                        pAppResource->GetString(IDS_COM_POP_LOW_BATTERY_UNABLE_TO_LAUNCH_APPLICATION, messageBoxString);
 
-                       msgBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
+                       msgBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
                        msgBox.ShowAndWait(result);
 
                        switch (result)
@@ -1748,7 +1742,7 @@ VideoPlayerForm::CheckCallStatus(void)
                AppResource* pAppResource = Application::GetInstance()->GetAppResource();
                pAppResource->GetString(L"IDS_VPL_BODY_UNABLE_TO_PLAY_VIDEO_DURING_CALL", dispString);
 
-               msgBox.Construct(L"", dispString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
+               msgBox.Construct(L"", dispString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
                msgBox.ShowAndWait(modalResult);
 
                switch (modalResult)
index 7e4899d..ac48c94 100644 (file)
@@ -48,6 +48,8 @@ static const int INIT_CONTENT_INDEX = 0;
 static const int MULTI_CONTENT_COUNT = 2;
 static const int MAX_PROGRESS_RANGE = 100;
 
+static const int MESSAGEBOX_DISPLAY_TIMEOUT = 3000;
+
 VideoPlayerPresentationModel*
 VideoPlayerPresentationModel::__pVideoPlayerPresentationModel = null;
 
@@ -131,7 +133,6 @@ VideoPlayerPresentationModel::CreateInstance(void)
        {
                delete __pVideoPlayerPresentationModel;
                __pVideoPlayerPresentationModel = null;
-               return;
        }
 }
 
@@ -155,22 +156,13 @@ VideoPlayerPresentationModel::GetVideoInfoN(const String& mediaLocalPath)
        if (GetState() == PLAYER_STATE_PLAYING)
        {
                pStreamInfo = __pPlayer->GetCurrentMediaStreamInfoN();
-               if (pStreamInfo == null)
-               {
-                       TryCatch(pStreamInfo != null, r = E_FAILURE, "__pPlayer->GetCurrentMediaStreamInfoN() is null");
-               }
+               TryCatch(pStreamInfo != null, r = E_FAILURE, "__pPlayer->GetCurrentMediaStreamInfoN() is null");
 
                pInfoList = pStreamInfo->GetVideoStreamInfoList();
-               if (pInfoList == null)
-               {
-                       TryCatch(pInfoList != null, r = E_FAILURE, "pStreamInfo->GetVideoStreamInfoList() is null");
-               }
+               TryCatch(pInfoList != null, r = E_FAILURE, "pStreamInfo->GetVideoStreamInfoList() is null");
 
                pInfo = (const VideoStreamInfo*)pInfoList->GetAt(0);
-               if (pInfo == null)
-               {
-                       TryCatch(pInfo != null, r = E_FAILURE, "pInfoList->GetAt() is null");
-               }
+               TryCatch(pInfo != null, r = E_FAILURE, "pInfoList->GetAt() is null");
 
                rect.width = pInfo->GetWidth();
                rect.height = pInfo->GetHeight();
@@ -207,9 +199,7 @@ VideoPlayerPresentationModel::ConstructPlayerInstanceWithBufferInfo(void)
        TryCatch(r == E_SUCCESS,, "__pOverlayRegion->GetBackgroundBufferInfo() failed:%s", GetErrorMessage(r));
 
        delete __pPlayer;
-
        __pPlayer = new (std::nothrow) Player();
-
        AppLogDebug("__pPlayer [%x]", __pPlayer);
 
        r = __pPlayer->Construct(*this, &bufferInfo);
@@ -286,6 +276,7 @@ VideoPlayerPresentationModel::SetPlayerBuffer(const BufferInfo& bufferInfo)
 {
        result r = E_FAILURE;
        TryReturnVoid(__pPlayer != null, "__pPlayer is null");
+
        r = __pPlayer->SetRenderingBuffer(bufferInfo);
        TryReturnVoid(r == E_SUCCESS, "__pPlayer->SetRenderingBuffer failed:%s", GetErrorMessage(r));
 }
@@ -338,7 +329,7 @@ VideoPlayerPresentationModel::StartPlay(void)
                                String messageBoxString;
                                pAppResource->GetString(IDS_COM_POP_UNSUPPORTED_FILE_TYPE, messageBoxString);
                                MessageBox messageBox;
-                               messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, 3000);
+                               messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
                                int modalResult = 0;
                                messageBox.ShowAndWait(modalResult);
 
index 8bae203..86ad5a0 100755 (executable)
@@ -35,9 +35,9 @@ using namespace Tizen::Ui::Controls;
 static const int W_VOLUME_POPUP = 600;
 static const int H_VOLUME_POPUP = 180;
 
-static const int SLIDER_MIN_VALUE = 0;
+static const int MIN_SLIDER_VALUE = 0;
 
-static const int START_CLOSE_TIME = 3000;
+static const int VOLUME_SETTING_POPUP_TIMEOUT = 3000;
 static const int VOLUME_SETTING_DURATION = 200;
 
 static const int X_VOLUME_SLIDER = 100;
@@ -86,7 +86,7 @@ VolumeSettingPopup::Construct(void)
        __pVolumeSliderTimer = new (std::nothrow) Timer();
 
        r = __pVolumeSettingSlider->Construct(Rectangle(X_VOLUME_SLIDER, Y_VOLUME_SLIDER, W_VOLUME_SLIDER, H_VOLUME_SLIDER),
-                       BACKGROUND_STYLE_NONE, false, SLIDER_MIN_VALUE, MaxMediaSoundVolume);
+                       BACKGROUND_STYLE_NONE, false, MIN_SLIDER_VALUE, MaxMediaSoundVolume);
        TryCatch(r == E_SUCCESS,, "__pVolumeSettingSlider->Construct() Failed:%s", GetErrorMessage(r));
 
        r = __pCloseTimer->Construct(*this);
@@ -133,7 +133,7 @@ VolumeSettingPopup::ShowPopup(bool state)
        r = Show();
        TryReturnVoid(r == E_SUCCESS, "Show() failed:%s", GetErrorMessage(r));
 
-       r = __pCloseTimer->Start(START_CLOSE_TIME);
+       r = __pCloseTimer->Start(VOLUME_SETTING_POPUP_TIMEOUT);
        TryReturnVoid(r == E_SUCCESS, "__pCloseTimer->Start() failed:%s", GetErrorMessage(r));
 }
 
@@ -150,8 +150,7 @@ VolumeSettingPopup::HidePopup(bool state)
 }
 
 void
-VolumeSettingPopup::OnTouchReleased(const Control& source, const Point& currentPosition,
-               const TouchEventInfo& touchInfo)
+VolumeSettingPopup::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
 {
        result r = E_FAILURE;
 
@@ -201,8 +200,7 @@ VolumeSettingPopup::OnKeyPressed(const Control& source, KeyCode keyCode)
 
        SystemInfo::GetValue(MAX_MEDIA_SOUND_VOLUME, maxMediaVolume);
 
-       if (keyCode == KEY_SIDE_UP
-               || keyCode == KEY_SIDE_DOWN)
+       if (keyCode == KEY_SIDE_UP || keyCode == KEY_SIDE_DOWN)
        {
                if (GetShowState() == true)
                {
@@ -242,7 +240,7 @@ VolumeSettingPopup::OnAdjustmentValueChanged(const Control& source, int adjustme
        r = SettingInfo::SetVolume(MEDIA_SOUND_VOLUME, adjustment);
        TryReturnVoid(r == E_SUCCESS, "SettingInfo::SetVolume() failed:%s", GetErrorMessage(r));
 
-       r = __pCloseTimer->Start(START_CLOSE_TIME);
+       r = __pCloseTimer->Start(VOLUME_SETTING_POPUP_TIMEOUT);
        TryReturnVoid(r == E_SUCCESS, "__pCloseTimer->Start() failed:%s", GetErrorMessage(r));
 }