Fixed Nabi Issues 49466,55718,55225,52332
[apps/osp/Internet.git] / src / IntInternetApp.cpp
index 4121f6d..33e694c 100644 (file)
@@ -47,7 +47,7 @@ static const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_VIEWER = L"http://tizen.org/
 const int MIN_MEMORY_NEEDED = 1048576;
 
 InternetApp::InternetApp(void)
-: __pMultiWindowManager(NULL),__pNewWindowInfo(null),pSceneManagementFrame(null),__value(null)
+: __pMultiWindowManager(NULL),__pNewWindowInfo(null),pSceneManagementFrame(null),__value(null),__isShowMsg(false),__pAc(null)
 {
 }
 
@@ -176,14 +176,21 @@ InternetApp::OnAppInitialized(void)
 
        if (__operationId.CompareTo(L"http://tizen.org/appcontrol/operation/main") == 0)
        {
-               AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_IMAGE_VIEWER,
+               if(__pAc)
+               {
+                       r =__pAc->Stop();
+                       AppLog("AppControl Stop Result %s",GetErrorMessage(r));
+                       delete __pAc;
+                       __pAc = null;
+               }
+               __pAc = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_IMAGE_VIEWER,
                                APPCONTROL_OPERATION_ID_IMAGE_VIEWER);
-               if (pAc && __value && __value->GetLength() > 0)
+               if (__pAc && __value && __value->GetLength() > 0)
                {
                        AppLog("17jul __value is %S", __value->GetPointer());
-                       if (pAc->Start(__value, null, null, null) == E_SUCCESS)
+                       if (__pAc->Start(__value, null, null, null) == E_SUCCESS)
                        {
-                               delete pAc;
+//                             delete pAc;
                        }
                        delete __value;
                        __value = null;
@@ -263,13 +270,26 @@ InternetApp::OnForeground(void)
        {
                pCurrentForm->SendUserEvent(FORE_GROUND_APP_EVENT, NULL);
        }
+       Frame* pCurrentFrame = null;
+       pCurrentFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
 
+       if (pCurrentFrame != null)
+       {
+               pCurrentFrame->SetEnabled(true);
+               pCurrentFrame->Invalidate(true);
+       }
 
+       if ( __isShowMsg == true )
+       {
+               __isShowMsg = false;
+               SendUserEvent(FORE_GROUND_APP_EVENT, NULL);
+       }
 }
 
 void
 InternetApp::OnBackground(void)
 {
+       AppLog("InternetApp::OnBackground");
        Form* pCurrentForm = null;
        if(SceneManager::GetInstance()->GetCurrentScene() != null)
                pCurrentForm = (SceneManager::GetInstance()->GetCurrentScene()->GetForm());
@@ -316,6 +336,20 @@ InternetApp::OnSettingChanged(Tizen::Base::String& key)
        {
                Terminate();
        }
+       else if (key == L"http://tizen.org/setting/screen.brightness" )
+       {
+               AppRegistry* pAppRegistry = App::GetInstance()->GetAppRegistry();
+               String sliderKey("SliderValue");
+
+               int sliderValue = 10;
+
+
+               result r = pAppRegistry->Get(sliderKey, sliderValue);
+               r = PowerManager::SetScreenBrightness(sliderValue);
+               //      r = PowerManager::RestoreScreenBrightness();
+
+       }
+
 }
 
 void
@@ -329,6 +363,8 @@ InternetApp::OnAppControlRequestReceived(RequestId reqId, const String &operatio
 
        }
 
+       __isShowMsg = false;
+
        AppLogDebug("ABC::Internet::OnAppControlRequestReceivedN entered %ls",operationId.GetPointer());
        __operationId.Clear();
        __operationId.Append(operationId);
@@ -365,20 +401,21 @@ InternetApp::OnAppControlRequestReceived(RequestId reqId, const String &operatio
                if(pSceneManagementFrame)
                        pSceneManagementFrame->Show();
 
-               if (__pNewWindowInfo == null)
-               {
-                       __pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(urlData, true);
-               }
+
                if (__pNewWindowInfo == null)
                {
                        if (MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)
                        {
-                               String strTitle = L"";//CommonUtil::GetString(L"IDS_COM_SK_MAX_LIMIT_REACHED");
-                               String strText = CommonUtil::GetString(L"IDS_BR_BODY_COULD_NOT_OPEN_NEW_WINDOW_BECAUSE_YOU_HAVE_ALREADY_OPENED_MAXIMUM_NUMBER");
-                               ShowPopup(strTitle, strText);
+                               __isShowMsg = true;
+                               return;
                        }
-                       return;
                }
+
+               if (__pNewWindowInfo == null)
+               {
+                       __pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(urlData, true);
+               }
+
                if (__pMultiWindowManager != null && __pMultiWindowManager->GetAllWindowArrayList()->GetCount() != 0)
                {
                        //if the application is running in background and it receives an appcontrol request it will launch a new(std::nothrow) window here,
@@ -427,14 +464,21 @@ InternetApp::OnAppControlRequestReceived(RequestId reqId, const String &operatio
                                String typeVal = APPCONTROL_SELECT_VALUE_IMAGE;
                                extraData.Add(&typeKey, &typeVal);
 
-                               AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_IMAGE_VIEWER,
+                               if(__pAc)
+                               {
+                                       result r = __pAc->Stop();
+                                       AppLog("AppControl Stop Result %s",GetErrorMessage(r));
+                                       delete __pAc;
+                                       __pAc = null;
+                               }
+                               __pAc = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_IMAGE_VIEWER,
                                                APPCONTROL_OPERATION_ID_IMAGE_VIEWER);
-                               if (pAc)
+                               if (__pAc)
                                {
                                        AppLog("17jul __value is %S", __value->GetPointer());
-                                       if (pAc->Start(__value, null, null, null) == E_SUCCESS)
+                                       if (__pAc->Start(__value, null, null, null) == E_SUCCESS)
                                        {
-                                               delete pAc;
+//                                             delete pAc;
                                        }
                                }
                                delete __value;
@@ -466,3 +510,32 @@ InternetApp::GetAvailableMemory(void)
     return 0;
 }
 
+
+void
+InternetApp::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
+{
+       Form* pCurrentForm = null;
+       if(SceneManager::GetInstance()->GetCurrentScene() != null)
+               pCurrentForm = (SceneManager::GetInstance()->GetCurrentScene()->GetForm());
+       if (pCurrentForm)
+       {
+               AppLog("sending userevent for appcontrol");
+               pCurrentForm->SendUserEvent(APPCONTROL_LAUNCH_MAX_LIMIT_REACHED, NULL);
+       }
+
+       if(requestId == FORE_GROUND_APP_EVENT)
+       {
+               if( MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)
+                {
+                        String strText = CommonUtil::GetString(L"IDS_BR_BODY_COULD_NOT_OPEN_NEW_WINDOW_BECAUSE_YOU_HAVE_ALREADY_OPENED_MAXIMUM_NUMBER");
+                        MessageBox messageBox;
+                        messageBox.Construct(L"", strText, MSGBOX_STYLE_OK, 3000);
+                        int modalResult = 0;
+
+                        messageBox.ShowAndWait(modalResult);
+                }
+       }
+
+}
+
+