3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (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;
58 pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
60 pWebCanvasBitmap = null;
61 pFormCanvasBitmap = null;
64 WindowInfo::~WindowInfo(void)
66 // if ( pFavicon != NULL)
73 MultipleWindowPresentationModel::MultipleWindowPresentationModel(void)
78 MultipleWindowPresentationModel::~MultipleWindowPresentationModel(void)
82 delete __pAllWindowList;
83 __pAllWindowList = NULL;
85 __keyAndValues.RemoveAll();
89 MultipleWindowPresentationModel::CreateInstance(void)
91 if (__pMultiWindowManager == NULL)
93 __pMultiWindowManager = new(std::nothrow) MultipleWindowPresentationModel();
94 result r = __pMultiWindowManager->Construct();
97 delete __pMultiWindowManager;
98 __pMultiWindowManager = null;
103 MultipleWindowPresentationModel*
104 MultipleWindowPresentationModel::GetInstance(void)
106 if (__pMultiWindowManager == NULL)
110 return __pMultiWindowManager;
115 MultipleWindowPresentationModel::DestroyInstance(void)
117 if (__pMultiWindowManager)
119 delete __pMultiWindowManager;
120 __pMultiWindowManager = null;
125 MultipleWindowPresentationModel::Construct(void)
127 result r = E_SUCCESS;
128 __pAllWindowList = new(std::nothrow) ArrayList();
129 r = __pAllWindowList->Construct();
134 r = __keyAndValues.Construct();
143 MultipleWindowPresentationModel::UnInitialize(void)
145 AppLogDebug(" MultiWindowManager::Denitialize");
150 MultipleWindowPresentationModel::AddWindoInfo(WindowInfo* pWindowInfo)
152 result r = E_FAILURE;
154 if (pWindowInfo != NULL)
156 r = __pAllWindowList->Add(*pWindowInfo);
163 MultipleWindowPresentationModel::GetAllWindowArrayList(void)
165 return __pAllWindowList;
169 MultipleWindowPresentationModel::GetValue(Key key, Object** value)
171 result r = E_FAILURE;
172 bool containKey = false;
174 AppLogDebug("Workspace::GetValue");
175 r = __keyAndValues.ContainsKey(key, containKey);
176 TryCatch(!IsFailed(r),,"ContainsKey failed %s",GetErrorMessage(r));
178 if (containKey == true)
179 r = __keyAndValues.GetValue(key, *value);
186 MultipleWindowPresentationModel::SetValue(Key key, Object* value)
188 result r = E_FAILURE;
189 bool containKey = false;
191 r = __keyAndValues.ContainsKey(key, containKey);
192 TryCatch(!IsFailed(r),,"ContainsKey failed %s",GetErrorMessage(r));
194 if (containKey == false)
195 r = __keyAndValues.Add(key, value);
197 r = __keyAndValues.SetValue(key, value);
204 MultipleWindowPresentationModel::CreateNewMainViewScene(const String& Url, bool isAppControlTriggered)
207 if (GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)
211 WindowInfo* pWindowInfo = new(std::nothrow) WindowInfo();
212 if (pWindowInfo == NULL)
216 pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
217 pWindowInfo->pageUrl = Url;
218 pWindowInfo->isAppcontrolTriggered = isAppControlTriggered;
219 MultipleWindowPresentationModel::GetInstance()->AddWindoInfo(pWindowInfo);
220 SceneRegister::RegisterNewMainView(pWindowInfo->sceneID, pWindowInfo->formID);
227 MultipleWindowPresentationModel::SetCurrentSceneID(const String& currentSceneId)
230 __currentSceneId.Clear();
231 __currentSceneId.Append(currentSceneId);
232 for (int index = 0; index < GetInstance()->GetAllWindowArrayList()->GetCount(); index ++)
234 WindowInfo* pWindowInfo = static_cast< WindowInfo* >(GetInstance()->GetAllWindowArrayList()->GetAt(index));
236 if ( pWindowInfo == NULL )
241 if (pWindowInfo->sceneID.CompareTo(__currentSceneId) == 0)
243 __pCurWindowInfo = pWindowInfo;
251 MultipleWindowPresentationModel::GetCurrentSceneId(String& currentSceneId)
253 currentSceneId = __currentSceneId;
258 MultipleWindowPresentationModel::GetActiveWindowInfo()
260 return __pCurWindowInfo;