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 <FBaseSysLog.h>
26 #include <FBaseInteger.h>
27 #include <FBaseDouble.h>
28 #include <FBaseColHashMap.h>
29 #include <FBaseColAllElementsDeleter.h>
30 #include <FBase_StringConverter.h>
31 #include <FApp_AppControlManager.h>
32 #include "FShell_AppWidgetManagerService.h"
33 #include "FShell_AppWidgetContext.h"
34 #include "FShell_AppWidgetPopupContext.h"
35 #include "FShell_AppWidgetContextHelper.h"
36 #include "FShell_AppWidgetRemoteBuffer.h"
38 namespace Tizen { namespace Shell { namespace App
42 using namespace Tizen::Base;
43 using namespace Tizen::Base::Collection;
45 const wchar_t APPWIDGET_POPUP_ON_CREATE[] = L"http://tizen.org/appcontrol/appwidgetpopup/create";
46 const wchar_t APPWIDGET_POPUP_ON_DESTROY[] = L"http://tizen.org/appcontrol/appwidgetpopup/destroy";
47 const wchar_t APPWIDGET_POPUP_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidgetpopup/touch";
49 _AppWidgetPopupContext::_AppWidgetPopupContext(const _AppWidgetContext* pParent)
52 __pAppWidgetRemoteBuffer = new (nothrow) _AppWidgetRemoteBuffer(__pParent->GetProviderId(), __pParent->GetInstanceId(), TYPE_PD, this);
53 SysTryReturnVoidResult(NID_SHELL, __pAppWidgetRemoteBuffer, E_OUT_OF_MEMORY, "");
55 SysLog(NID_SHELL, "The drop view for %ls is constructed.", (__pParent->GetInstanceId()).GetPointer());
58 _AppWidgetPopupContext::~_AppWidgetPopupContext(void)
61 delete __pAppWidgetRemoteBuffer;
63 SysLog(NID_SHELL, "The drop view for %ls destructed.", (__pParent->GetInstanceId()).GetPointer());
67 _AppWidgetPopupContext::OnPopupCreated(double x, double y, int width, int height)
69 SysLog(NID_SHELL, "width(%d), height(%d)", width, height);
70 SendPopupCreateRequest(x, y, width, height);
74 _AppWidgetPopupContext::OnPopupDestoyed(void)
76 SysLog(NID_SHELL, "");
77 SendPopupDestroyRequest();
81 _AppWidgetPopupContext::SendPopupCreateRequest(double x, double y, int width, int height)
83 std::unique_ptr<HashMap, AllElementsDeleter> pArgs (__pParent->CreateRequestArgsN() );
85 pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x)));
86 pArgs->Add(new String(ARG_KEY_Y), new String(Double::ToString(y)));
87 pArgs->Add(new String(ARG_KEY_POPUP_WIDTH), new String(Integer::ToString(width)));
88 pArgs->Add(new String(ARG_KEY_POPUP_HEIGHT), new String(Integer::ToString(height)));
90 return _AppWidgetRequestHelper::SendAppControlRequest(__pParent->GetAppId(), APPWIDGET_POPUP_ON_CREATE, pArgs.get());
94 _AppWidgetPopupContext::SendPopupDestroyRequest(void)
96 std::unique_ptr<HashMap, AllElementsDeleter> pArgs (__pParent->CreateRequestArgsN() );
98 return _AppWidgetRequestHelper::SendAppControlRequest(__pParent->GetAppId(), APPWIDGET_POPUP_ON_DESTROY, pArgs.get());
102 _AppWidgetPopupContext::OnTouchEventReceived(buffer_event event, double timestamp, double x, double y)
104 SysLog(NID_SHELL, "");
105 AppWidgetManagerService::GetInstance()->SendTouchEventForPD(__pParent->GetAppContext()->GetClientId(), __pParent->GetInstanceId(), event, timestamp, x, y);
109 _AppWidgetPopupContext::SyncRemoteBuffer(void)
111 std::unique_ptr<char[]> providerId(_StringConverter::CopyToCharArrayN(__pParent->GetProviderId()));
112 std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__pParent->GetInstanceId()));
114 int ret = provider_send_desc_updated(providerId.get(), id.get(), null);
115 SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated");
117 SysLog(NID_SHELL, "Done");
122 _AppWidgetPopupContext::GetClientId(void) const
124 return __pParent->GetAppContext()->GetClientId();
128 _AppWidgetPopupContext::AcquireRemoteBuffer(int w, int h) const
130 return __pAppWidgetRemoteBuffer->Acquire(w, h);
133 }}} // Tizen::Shell::App