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_AppWidgetContextHelper.cpp
19 * @brief This is the implementation for the _AppWidgetContextHelper class.
22 #include <unique_ptr.h>
23 #include <FBaseColHashMap.h>
24 #include <FBaseString.h>
25 #include <FAppTypes.h>
26 #include <FBase_StringConverter.h>
27 #include <FApp_AppArg.h>
28 #include <FApp_AppMessageImpl.h>
29 #include <FApp_AppControlManager.h>
30 #include "FShell_AppWidgetContextHelper.h"
31 #include "FShell_AppWidgetManagerService.h"
33 namespace Tizen { namespace Shell { namespace App
36 using namespace Tizen::App;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
41 _AppWidgetRequestHelper::SendAppControlRequest(const AppId& appId, const String& operation, HashMap* pArgs)
43 const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(String(ARG_KEY_INSTANCE_ID)));
44 SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to get the instance id.");
46 SysSecureLog(NID_SHELL, "[ac] pInstanceId(%ls), operation(%ls), appId(%ls), arg count(%d)", pInstanceId->GetPointer(), operation.GetPointer(), appId.GetPointer(), pArgs->GetCount());
49 msg.AddData(OSP_K_APPCONTROL_INTERNAL_OPERATION, L"appwidget");
50 Tizen::App::_AppArg::AddStrMap(msg.GetBundle(), pArgs);
52 std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId) );
53 std::unique_ptr<char[]> pOperation(_StringConverter::CopyToCharArrayN(operation) );
55 const int TRY_COUNT = 3;
56 const int TRY_SLEEP_TIME = 65;
63 r = Tizen::App::_AppControlManager::GetInstance()->LaunchPkg(msg, pAppId.get(), pOperation.get(), null, null, null, null);
66 SysLog(NID_SHELL, "[%s] Successed to invoke LaunchPkg()", GetErrorMessage(r));
70 if( retry ++ >= TRY_COUNT)
75 SysLogException(NID_SHELL, r, "[%s] Failed to invoke LaunchPkg(%s), %dth retry.", GetErrorMessage(r), pOperation.get(), retry);
76 Tizen::Base::Runtime::Thread::Sleep(TRY_SLEEP_TIME);
83 _AppWidgetRequestHelper::SendIpcRequest(const int clientId, const String& operation, HashMap* pArgs)
85 const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(String(ARG_KEY_INSTANCE_ID)));
86 SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to get the instance id.");
88 SysSecureLog(NID_SHELL, "[ipc] pInstanceId(%ls), operation(%ls), clientId(%d)", pInstanceId->GetPointer(), operation.GetPointer(), clientId);
90 bool sendResult = AppWidgetManagerService::GetInstance()->SendAppWidgetEvent(clientId, *pInstanceId, operation, pArgs);
91 SysTryReturnResult(NID_SHELL, sendResult, E_FAILURE, "Propagated.");
96 }}} // Tizen::Shell::App