2 // Open Service Platform
3 // Copyright (c) 2012-2013 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.
19 * @file FShell_AppWidgetPopupContext.cpp
20 * @brief This is the implementation for the _AppWidgetPopupContext class.
24 #include <unique_ptr.h>
26 #include "provider_buffer.h"
29 #include <FBaseSysLog.h>
30 #include <FBase_StringConverter.h>
32 #include <FApp_AppControlManager.h>
34 #include "FShell_AppWidgetManagerService.h"
35 #include "FShell_AppWidgetContext.h"
36 #include "FShell_AppWidgetPopupContext.h"
38 namespace Tizen { namespace Shell { namespace App
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Collection;
45 const char APPWIDGET_POPUP_ON_CREATE[] = "http://tizen.org/appcontrol/appwidgetpopup/create";
46 const char APPWIDGET_POPUP_ON_DESTROY[] = "http://tizen.org/appcontrol/appwidgetpopup/destroy";
47 const char APPWIDGET_POPUP_ON_TOUCH[] = "http://tizen.org/appcontrol/appwidgetpopup/touch";
50 _AppWidgetPopupContext::_AppWidgetPopupContext(const String& info, const String& appId, const String& instanceId, int width, int height, int priority, _AppWidgetContext* pParent)
51 :_AppWidgetContextBase(TYPE_PD, info, appId, instanceId, width, height, priority)
54 SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
57 _AppWidgetPopupContext::~_AppWidgetPopupContext()
59 SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d))", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
64 _AppWidgetPopupContext::OnPopupCreated(double x, double y, int width, int height)
66 SysLog(NID_SHELL, "width(%d), height(%d)", width, height);
67 SendPopupCreateRequest(x, y, width, height);
71 _AppWidgetPopupContext::OnPopupDestoyed()
73 SysLog(NID_SHELL, "");
74 SendPopupDestroyRequest();
78 _AppWidgetPopupContext::SendPopupCreateRequest(double x, double y, int width, int height)
80 std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
82 pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x)));
83 pArgs->Add(new String(ARG_KEY_Y), new String(Double::ToString(y)));
84 pArgs->Add(new String(ARG_KEY_POPUP_WIDTH), new String(Integer::ToString(width)));
85 pArgs->Add(new String(ARG_KEY_POPUP_HEIGHT), new String(Integer::ToString(height)));
87 return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_CREATE, pArgs.get());
91 _AppWidgetPopupContext::SendPopupDestroyRequest()
93 std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
95 return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_DESTROY, pArgs.get());
99 _AppWidgetPopupContext::SendTouchEvent(buffer_event event, double timestamp, double x, double y)
101 SysLog(NID_SHELL, "");
102 /*if( HasValidClientId() == false )
104 std::unique_ptr<ArrayList, AllElementsDeleter> pArgs (new (std::nothrow) ArrayList);
106 pArgs->Add(*new String(__instanceId));
107 pArgs->Add(*new String(__info));
108 pArgs->Add(*new String(Integer::ToString(event)));
109 pArgs->Add(*new String(Double::ToString(timestamp)));
110 pArgs->Add(*new String(Double::ToString(x)));
111 pArgs->Add(*new String(Double::ToString(y)));
113 return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_TOUCH, pArgs.get());
117 // SysAssertf( Tizen::App::AppManager::GetInstance()->IsRunning(__appId) == false, "application isn't running");
118 AppWidgetManagerService::GetInstance()->SendTouchEventForPD(__ipcClientId, __instanceId, event, timestamp, x, y);
124 _AppWidgetPopupContext::RequestUpdateRemote()
126 std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__providerId));
127 std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__instanceId));
129 int ret = provider_send_desc_updated(packageName.get(), id.get(), null);
130 SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated");
132 SysLog(NID_SHELL, "Done");
136 Tizen::Base::Collection::HashMap*
137 _AppWidgetPopupContext::CreateRequestArgs(void)
139 HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter);
141 pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(__instanceId));
142 pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(__providerName));
143 pArgs->Add(new String(ARG_KEY_USER_INFO), new String(__userInfo));
144 pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(__pParent->__width)));
145 pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(__pParent->__height)));
150 } } } // Tizen::Shell::App {