2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FShell_AppWidgetPopupContext.cpp
19 * @brief This is the implementation for the _AppWidgetPopupContext class.
23 #include <unique_ptr.h>
25 #include "provider_buffer.h"
28 #include <FBaseSysLog.h>
29 #include <FBase_StringConverter.h>
31 #include <FApp_AppControlManager.h>
33 #include "FShell_AppWidgetManagerService.h"
34 #include "FShell_AppWidgetContext.h"
35 #include "FShell_AppWidgetPopupContext.h"
37 namespace Tizen { namespace Shell { namespace App
40 using namespace Tizen::Base;
41 using namespace Tizen::Base::Collection;
44 const char APPWIDGET_POPUP_ON_CREATE[] = "http://tizen.org/appcontrol/appwidgetpopup/create";
45 const char APPWIDGET_POPUP_ON_DESTROY[] = "http://tizen.org/appcontrol/appwidgetpopup/destroy";
46 const char APPWIDGET_POPUP_ON_TOUCH[] = "http://tizen.org/appcontrol/appwidgetpopup/touch";
49 _AppWidgetPopupContext::_AppWidgetPopupContext(const String& info, const String& appId, const String& instanceId, int width, int height, int priority, _AppWidgetContext* pParent)
50 :_AppWidgetContextBase(TYPE_PD, info, appId, instanceId, width, height, priority)
53 SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
56 _AppWidgetPopupContext::~_AppWidgetPopupContext()
58 SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d))", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
63 _AppWidgetPopupContext::OnPopupCreated(double x, double y, int width, int height)
65 SysLog(NID_SHELL, "width(%d), height(%d)", width, height);
66 SendPopupCreateRequest(x, y, width, height);
70 _AppWidgetPopupContext::OnPopupDestoyed()
72 SysLog(NID_SHELL, "");
73 SendPopupDestroyRequest();
77 _AppWidgetPopupContext::SendPopupCreateRequest(double x, double y, int width, int height)
79 std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
81 pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x)));
82 pArgs->Add(new String(ARG_KEY_Y), new String(Double::ToString(y)));
83 pArgs->Add(new String(ARG_KEY_POPUP_WIDTH), new String(Integer::ToString(width)));
84 pArgs->Add(new String(ARG_KEY_POPUP_HEIGHT), new String(Integer::ToString(height)));
86 return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_CREATE, pArgs.get());
90 _AppWidgetPopupContext::SendPopupDestroyRequest()
92 std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
94 return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_DESTROY, pArgs.get());
98 _AppWidgetPopupContext::SendTouchEvent(buffer_event event, double timestamp, double x, double y)
100 SysLog(NID_SHELL, "");
101 /*if( HasValidClientId() == false )
103 std::unique_ptr<ArrayList, AllElementsDeleter> pArgs (new (std::nothrow) ArrayList);
105 pArgs->Add(*new String(__instanceId));
106 pArgs->Add(*new String(__info));
107 pArgs->Add(*new String(Integer::ToString(event)));
108 pArgs->Add(*new String(Double::ToString(timestamp)));
109 pArgs->Add(*new String(Double::ToString(x)));
110 pArgs->Add(*new String(Double::ToString(y)));
112 return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_TOUCH, pArgs.get());
116 // SysAssertf( Tizen::App::AppManager::GetInstance()->IsRunning(__appId) == false, "application isn't running");
117 AppWidgetManagerService::GetInstance()->SendTouchEventForPD(__ipcClientId, __instanceId, event, timestamp, x, y);
123 _AppWidgetPopupContext::RequestUpdateRemote()
125 std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__providerId));
126 std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__instanceId));
128 int ret = provider_send_desc_updated(packageName.get(), id.get(), null);
129 SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated");
131 SysLog(NID_SHELL, "Done");
135 Tizen::Base::Collection::HashMap*
136 _AppWidgetPopupContext::CreateRequestArgs(void)
138 HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter);
140 pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(__instanceId));
141 pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(__providerName));
142 pArgs->Add(new String(ARG_KEY_USER_INFO), new String(__userInfo));
143 pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(__pParent->__width)));
144 pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(__pParent->__height)));
149 } } } // Tizen::Shell::App {