2 // Open Service Platform
3 // Copyright (c) 2012-2013 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.
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_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";
48 const String ARG_KEY_X = L"_X";
49 const String ARG_KEY_Y = L"_Y";
50 const String ARG_KEY_WIDTH = L"_Width";
51 const String ARG_KEY_HEIGHT = L"_Height";
54 _AppWidgetPopupContext::_AppWidgetPopupContext(const String& info, const String& appId, const String& instanceId, int width, int height, int priority)
55 :_AppWidgetContextBase(TYPE_PD, info, appId, instanceId, width, height, priority)
57 SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
60 _AppWidgetPopupContext::~_AppWidgetPopupContext()
62 SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d))", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height);
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()
76 SysLog(NID_SHELL, "");
77 SendPopupDestroyRequest();
81 _AppWidgetPopupContext::SendPopupCreateRequest(double x, double y, int width, int height)
83 std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
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_WIDTH), new String(Integer::ToString(width)));
88 pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(height)));
90 return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_CREATE, pArgs.get());
94 _AppWidgetPopupContext::SendPopupDestroyRequest()
96 std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
98 return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_DESTROY, pArgs.get());
102 _AppWidgetPopupContext::SendTouchEvent(buffer_event event, double timestamp, double x, double y)
104 SysLog(NID_SHELL, "");
105 /*if( HasValidClientId() == false )
107 std::unique_ptr<ArrayList, AllElementsDeleter> pArgs (new (std::nothrow) ArrayList);
109 pArgs->Add(*new String(__instanceId));
110 pArgs->Add(*new String(__info));
111 pArgs->Add(*new String(Integer::ToString(event)));
112 pArgs->Add(*new String(Double::ToString(timestamp)));
113 pArgs->Add(*new String(Double::ToString(x)));
114 pArgs->Add(*new String(Double::ToString(y)));
116 return SendRequestToApp( __appId, APPWIDGET_POPUP_ON_TOUCH, pArgs.get());
120 // SysAssertf( Tizen::App::AppManager::GetInstance()->IsRunning(__appId) == false, "application isn't running");
121 AppWidgetManagerService::GetInstance()->SendTouchEventForPD(__ipcClientId, __instanceId, event, timestamp, x, y);
127 _AppWidgetPopupContext::RequestUpdateRemote()
129 std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__providerId));
130 std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__instanceId));
132 int ret = provider_send_desc_updated(packageName.get(), id.get(), null);
133 SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated");
135 SysLog(NID_SHELL, "Done");
139 } } } // Tizen::Shell::App {