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 OspAppWidgetService.cpp
19 * @brief This is the implementation for the OspAppWidgetService class.
22 #include <FAppAppControlProviderManager.h>
23 #include <FBase_StringConverter.h>
24 #include "FShell_AppWidgetManagerService.h"
25 #include "OspAppWidgetService.h"
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::System;
30 using namespace Tizen::Shell::App;
32 const wchar_t OPERATION_MAIN[] = L"http://tizen.org/appcontrol/operation/main";
33 const wchar_t KEY_NAME[] = L"name";
35 OspAppWidgetService::OspAppWidgetService(void)
39 OspAppWidgetService::~OspAppWidgetService(void)
44 OspAppWidgetService::CreateInstance(void)
46 // Create the instance through the constructor.
47 return new (std::nothrow) OspAppWidgetService();
51 OspAppWidgetService::OnAppInitializing(AppRegistry& appRegistry)
53 AppControlProviderManager::GetInstance()->SetAppControlProviderEventListener(this);
59 OspAppWidgetService::OnAppInitialized(void)
65 OspAppWidgetService::OnAppWillTerminate(void)
71 OspAppWidgetService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
77 OspAppWidgetService::OnLowMemory(void)
82 OspAppWidgetService::OnBatteryLevelChanged(BatteryLevel batteryLevel)
87 OspAppWidgetService::OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData)
89 if (operationId == OPERATION_MAIN)
91 static bool isServiceCreated = false;
93 if (isServiceCreated == true)
98 AppWidgetManagerService* pSvc = null;
99 String coreDaemonId = "osp-appwidget-service";
102 String key(KEY_NAME);
103 const String* pValue = dynamic_cast<const String*>(pExtraData->GetValue(key));
107 coreDaemonId = *pValue;
111 std::unique_ptr<char[]> pIdForCoreDaemon(_StringConverter::CopyToCharArrayN(coreDaemonId));
112 pSvc = AppWidgetManagerService::CreateInstance(pIdForCoreDaemon.get());
113 AppAssertf(pSvc != null, "AppWidgetManagerService::GetInstance() failed.");
114 isServiceCreated = true;
119 OspAppWidgetService::OnUserEventReceivedN(RequestId reqId, Tizen::Base::Collection::IList* pArgs)
121 AppWidgetManagerService::GetInstance()->OnUserEventReceivedN(reqId, pArgs);