3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 //!Internet MultipleWindowScene class
19 /*@file: IntMultipleWindowScene.cpp
20 *@brief: The MultipleWindowScene provides multiple instance of mainscenes and displays them in a Listview
25 #include "IntCommonLib.h"
26 #include "IntMultipleWindowPresentationModel.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Ui::Controls;
32 using namespace Tizen::Ui::Scenes;
34 MultipleWindowPresentationModel* MultipleWindowPresentationModel::__pMultiWindowManager = NULL;
35 ArrayList* MultipleWindowPresentationModel::__pAllWindowList = NULL;
36 HashMapT< Key, Object* > MultipleWindowPresentationModel::__keyAndValues;
37 int WindowInfo::__windowId = 0;
38 String MultipleWindowPresentationModel::__currentSceneId = L"" ;
39 WindowInfo* MultipleWindowPresentationModel::__pCurWindowInfo = null;
40 Bitmap* WindowInfo::pFormCanvasBitmap = null;
42 WindowInfo::WindowInfo(void)
47 sceneID.Append(IDSCN_MAIN_VIEW);
50 formID.Append(IDL_FORM_MAIN_VIEW_SCENE);
52 isAppcontrolTriggered = false;
53 isJavascriptInitiated = false;
59 pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
61 pWebCanvasBitmap = null;
62 pFormCanvasBitmap = null;
65 WindowInfo::~WindowInfo(void)
67 // if ( pFavicon != NULL)
74 MultipleWindowPresentationModel::MultipleWindowPresentationModel(void)
79 MultipleWindowPresentationModel::~MultipleWindowPresentationModel(void)
83 delete __pAllWindowList;
84 __pAllWindowList = NULL;
86 __keyAndValues.RemoveAll();
90 MultipleWindowPresentationModel::CreateInstance(void)
92 if (__pMultiWindowManager == NULL)
94 __pMultiWindowManager = new(std::nothrow) MultipleWindowPresentationModel();
95 result r = __pMultiWindowManager->Construct();
98 delete __pMultiWindowManager;
99 __pMultiWindowManager = null;
104 MultipleWindowPresentationModel*
105 MultipleWindowPresentationModel::GetInstance(void)
107 if (__pMultiWindowManager == NULL)
111 return __pMultiWindowManager;
116 MultipleWindowPresentationModel::DestroyInstance(void)
118 if (__pMultiWindowManager)
120 delete __pMultiWindowManager;
121 __pMultiWindowManager = null;
126 MultipleWindowPresentationModel::Construct(void)
128 result r = E_SUCCESS;
129 __pAllWindowList = new(std::nothrow) ArrayList();
130 r = __pAllWindowList->Construct();
135 r = __keyAndValues.Construct();
144 MultipleWindowPresentationModel::UnInitialize(void)
146 AppLogDebug(" MultiWindowManager::Denitialize");
151 MultipleWindowPresentationModel::AddWindoInfo(WindowInfo* pWindowInfo)
153 result r = E_FAILURE;
155 if (pWindowInfo != NULL)
157 r = __pAllWindowList->Add(*pWindowInfo);
164 MultipleWindowPresentationModel::GetAllWindowArrayList(void)
166 return __pAllWindowList;
170 MultipleWindowPresentationModel::GetValue(Key key, Object** value)
172 result r = E_FAILURE;
173 bool containKey = false;
175 AppLogDebug("Workspace::GetValue");
176 r = __keyAndValues.ContainsKey(key, containKey);
177 TryCatch(!IsFailed(r),,"ContainsKey failed %s",GetErrorMessage(r));
179 if (containKey == true)
180 r = __keyAndValues.GetValue(key, *value);
187 MultipleWindowPresentationModel::SetValue(Key key, Object* value)
189 result r = E_FAILURE;
190 bool containKey = false;
192 r = __keyAndValues.ContainsKey(key, containKey);
193 TryCatch(!IsFailed(r),,"ContainsKey failed %s",GetErrorMessage(r));
195 if (containKey == false)
196 r = __keyAndValues.Add(key, value);
198 r = __keyAndValues.SetValue(key, value);
205 MultipleWindowPresentationModel::CreateNewMainViewSceneN(const String& Url, bool isAppControlTriggered)
208 if (GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)
210 AppLog("9 windows already opened");
212 String strTitle = L"";//CommonUtil::GetString(L"IDS_COM_SK_MAX_LIMIT_REACHED");
213 String strText = CommonUtil::GetString(L"IDS_BR_BODY_COULD_NOT_OPEN_NEW_WINDOW_BECAUSE_YOU_HAVE_ALREADY_OPENED_MAXIMUM_NUMBER");
214 ShowPopup(strTitle, strText);
218 WindowInfo* pWindowInfo = new(std::nothrow) WindowInfo();
219 if (pWindowInfo == NULL)
223 pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE");
224 pWindowInfo->pageUrl = Url;
225 pWindowInfo->isAppcontrolTriggered = isAppControlTriggered;
226 MultipleWindowPresentationModel::GetInstance()->AddWindoInfo(pWindowInfo);
227 SceneRegister::RegisterNewMainView(pWindowInfo->sceneID, pWindowInfo->formID);
234 MultipleWindowPresentationModel::SetCurrentSceneID(const String& currentSceneId)
237 __currentSceneId.Clear();
238 __currentSceneId.Append(currentSceneId);
239 for (int index = 0; index < GetInstance()->GetAllWindowArrayList()->GetCount(); index ++)
241 WindowInfo* pWindowInfo = static_cast< WindowInfo* >(GetInstance()->GetAllWindowArrayList()->GetAt(index));
243 if ( pWindowInfo == NULL )
248 if (pWindowInfo->sceneID.CompareTo(__currentSceneId) == 0)
250 __pCurWindowInfo = pWindowInfo;
258 MultipleWindowPresentationModel::GetCurrentSceneId(String& currentSceneId)
260 currentSceneId = __currentSceneId;
265 MultipleWindowPresentationModel::GetActiveWindowInfo()
267 return __pCurWindowInfo;
272 MultipleWindowPresentationModel::ShowPopup(String& pTitle, String& pText)
274 MessageBox messageBox;
275 messageBox.Construct(pTitle, pText,MSGBOX_STYLE_OK,3000);
278 messageBox.ShowAndWait(modalResult);
281 case MSGBOX_RESULT_OK: