2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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 FApp_AppImpl.cpp
19 * @brief This is the implementation for the _AppImpl class.
22 #include <unique_ptr.h>
24 #include <notification/notification.h>
25 #include <appsvc/appsvc.h>
29 #include <FBaseInteger.h>
30 #include <FBaseColArrayList.h>
31 #include <FBaseColHashMap.h>
32 #include <FBaseRtThread.h>
33 #include <FAppAppRegistry.h>
34 #include <FAppAppControl.h>
35 #include <FAppDataControlProviderManager.h>
36 #include <FAppIAppCheckPointEventListener.h>
37 #include <FAppISqlDataControlProviderEventListener.h>
38 #include <FAppIMapDataControlProviderEventListener.h>
39 #include <FAppIAppControlProviderEventListener.h>
40 #include <FAppIAppLaunchConditionEventListener.h>
42 #include <FBaseSysLog.h>
44 #include <FBase_StringConverter.h>
45 #include <FIo_RegistryImpl.h>
46 #include <FSys_EnvironmentImpl.h>
47 #include <FSys_PowerManagerImpl.h>
49 #include <FSys_AlarmManager.h>
51 #include "FApp_IAppManager.h"
52 #include "FApp_AppManagerProxy.h"
53 #include "FApp_AppImpl.h"
54 #include "FApp_AppInfo.h"
55 #include "FApp_AppControlManager.h"
56 #include "FApp_AppArg.h"
57 #include "FApp_IAppImpl.h"
58 #include "FApp_AppResourceImpl.h"
59 #include <FSys_SettingInfoImpl.h>
61 using namespace Tizen::Base;
62 using namespace Tizen::Base::Collection;
63 using namespace Tizen::Base::Runtime;
64 using namespace Tizen::Io;
65 using namespace Tizen::System;
70 const int HEARTBEAT_WAIT_COUNT = 3;
71 const wchar_t SERVICE_APPID[] = L"aospd00043.osp-app-service";
72 const char SELECTOR_RESPONSE_KEY[] = "__APP_SVC_START_INFO__";
73 const wchar_t FILE_SCHEME_WITH_DELIMITER[] = L"file://";
74 #ifndef VCONFKEY_APPSERVICE_STATUS
75 #define VCONFKEY_APPSERVICE_STATUS "memory/appservice/status"
80 namespace Tizen { namespace App
83 _AppImpl* _AppImpl::__pAppImpl = null;
84 bool _AppImpl::__isTerminationRequested = false;
86 static const int _DATACONTROL_PACKET_INDEX_APPID = 0;
87 static const int _DATACONTROL_PACKET_INDEX_REQUESTTYPE = 1;
88 static const int _DATACONTROL_PACKET_INDEX_REQID = 2;
89 static const int _DATACONTROL_PACKET_INDEX_PROVIDERID = 3;
91 static const int _DATACONTROL_PACKET_INDEX_DATAID = 0;
92 static const int _DATACONTROL_PACKET_INDEX_COLUMNCOUNT = 1;
93 static const int _DATACONTROL_PACKET_INDEX_DELETEWHERE = 1;
94 static const int _DATACONTROL_PACKET_INDEX_MAPKEY = 1;
95 static const int _DATACONTROL_PACKET_INDEX_COLUMNLIST = 2;
96 static const int _DATACONTROL_PACKET_INDEX_INSERTMAP = 2;
97 static const int _DATACONTROL_PACKET_INDEX_UPDATEMAP = 2;
101 void operator()(char* pValue)
111 _AppImpl::_AppImpl(App* pApp)
112 : __pCheckpointEventListener(null)
113 , __pSqlDataControlProviderEventListener(null)
114 , __pMapDataControlProviderEventListener(null)
115 , __pAppControlProviderEventListener(null)
116 , __pAppControlProviderInternalEventListener(null)
117 , __pAppLaunchConditionEventListener(null)
120 , __pRequestHandler(&_AppImpl::HandleAppRequest)
121 , __pLegacyRequestHandler(&_AppImpl::HandleDummyAppRequest)
122 , __forcedTermination(false)
129 _AppImpl::Construct(const IList* pArgs)
131 SysTryReturnResult(NID_APP, pArgs != null, E_INVALID_ARG, "pArguments must not be null.");
132 SysAssertf(__pApp != null, "Getting App instance failed.");
134 result r = __appUserEvent.Construct();
135 SysTryLog(NID_APP, !IsFailed(r), "[%s] User event handler failure.", GetErrorMessage(r));
137 __appUserEvent.AddListener(*this);
139 _AppInfo::SetAppState(INITIALIZING);
141 r = _SettingInfoImpl::AddSettingEventListenerForInternal(*this);
142 SysTryLog(NID_APP, !IsFailed(r), "[%s] failed to add setting event listener.", GetErrorMessage(r));
148 _AppImpl::Execute(_IAppImpl* pIAppImpl)
150 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:start]", _AppInfo::GetAppExecutableName().GetPointer());
151 result r = E_SUCCESS;
152 int eflResult = APP_ERROR_NONE;
155 _IAppManager* pAppManager = null;
157 _AppImpl* pAppImpl = _AppImpl::GetInstance();
158 SysTryReturnResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
159 pAppImpl->__pIAppImpl = pIAppImpl;
161 // handle legacy version handling
162 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
164 pAppImpl->SetLegacyRequestHandler();
167 app_event_callback_s state_handler;
168 memset(&state_handler, 0, sizeof(app_event_callback_s));
170 state_handler.create = &OnCreate;
171 state_handler.service = &OnService;
172 state_handler.terminate = &OnTerminate;
173 state_handler.pause = &OnPause;
174 state_handler.resume = &OnResume;
175 state_handler.device_orientation = NULL;
177 state_handler.low_memory = &OnLowMemory;
178 state_handler.low_battery = NULL;
179 state_handler.language_changed = NULL;
180 state_handler.region_format_changed = NULL;
182 _Aul::SetPowerOffNotiListener(OnPowerOffNotiReceived, this);
183 // if (pAppManager != null)
185 // r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), _AppInfo::GetAppType() , _AppInfo::GetProcessId());
186 // SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Application registration failed.", GetErrorMessage(r));
189 appinfo_get_argv(&argc, &pArgv);
190 eflResult = app_efl_main(&argc, &pArgv, &state_handler, this);
191 SysTryLog(NID_APP, eflResult == APP_ERROR_NONE, "app_efl_main failed with error (%d): Unknown", eflResult);
193 pAppManager = _AppManagerProxy::GetService();
195 if (pAppManager != null)
197 pAppManager->UnregisterApplication(_AppInfo::GetProcessId());
200 // clear outstanding ongoing notification
201 notification_delete_all_by_type(appinfo_get_appid(), NOTIFICATION_TYPE_ONGOING);
208 _AppImpl::OnCreate(void* user_data)
210 SysLog(NID_APP, "Platform creation event.");
212 _AppImpl* pAppImpl = static_cast<_AppImpl*>(user_data);
213 if (pAppImpl == null)
215 _AppInfo::SetAppState(TERMINATED);
216 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Invalid platform state.");
220 _AppInfo::SetAppState(INITIALIZING);
222 if (!ConfirmAppService())
224 _AppInfo::SetAppState(TERMINATED);
225 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Osp AppService is not running.");
229 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:start]", _AppInfo::GetAppExecutableName().GetPointer());
230 if (!pAppImpl->__pIAppImpl->OnAppInitializing())
232 _AppInfo::SetAppState(TERMINATED);
233 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] The initialization of your application failed.");
236 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:done]", _AppInfo::GetAppExecutableName().GetPointer());
238 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:start]", _AppInfo::GetAppExecutableName().GetPointer());
239 _IAppManager* pAppManager = _AppManagerProxy::GetService();
241 if (pAppManager != null)
243 result r = pAppManager->RegisterApplication(_AppInfo::GetApplicationId(), static_cast<_AppType>(_AppInfo::GetAppType()), _AppInfo::GetProcessId());
244 SysTryLog(NID_APP, !IsFailed(r), "[%s] Application registration failed.", GetErrorMessage(r));
246 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:done]", _AppInfo::GetAppExecutableName().GetPointer());
247 // hide splash window
249 _PowerManagerImpl::InitBatteryEvent();
256 _AppImpl::OnService(service_s* service, void* user_data)
258 _AppImpl* pAppImpl = _AppImpl::GetInstance();
259 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
260 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
262 // ugly code for app selector event handling
263 bundle* pBundle = _AppArg::GetBundleFromSvc(service);
266 const char* pValue = appsvc_get_data(pBundle, SELECTOR_RESPONSE_KEY);
269 const int req = _AppArg::GetRequestIdFromBundle(pBundle);
271 const char* pOperation = appsvc_get_operation(pBundle);
273 SysLog(NID_APP, "App selector response [%s, %s], req(%d).", pValue, pOperation, req);
275 //_AppArg::Print(pBundle);
276 _AppControlManager::GetInstance()->SendAppControlStartResponse(req, pValue, pOperation);
281 //_AppArg::Print(pBundle);
283 _AppHandler handler = _APP_HANDLER_NONE;
284 pAppImpl->RegisterAppRequest(service, req, handler);
286 bool initialLaunch = false;
289 // (1) AppControl / DataControl provider listener
290 // (2) OnAppInitialized()
291 // (3) OnResume() (OnForeground()) (UiApp only)
292 // (4) OnUserEventReceivedN()
295 // (1) AppControl / DataControl provider listener
296 // (2) OnResume() (OnForeground()) (UiApp only)
297 // (3) OnUserEventReceivedN()
299 if (_AppInfo::GetAppState() == INITIALIZING)
301 initialLaunch = true;
303 unsigned int winId = 0;
304 service_get_window(service, &winId);
307 _AppInfo::SetParentWindowHandle(winId);
308 SysLog(NID_APP, "Saving window handle 0x%x.", winId);
310 // call for callbacks
311 // ptr to member function
312 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:start]", _AppInfo::GetAppExecutableName().GetPointer());
313 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
315 if (!pAppImpl->__pIAppImpl->OnAppInitialized())
317 _AppInfo::SetAppState(TERMINATING);
318 SysLog(NID_APP, "[E_INIT_FAILED] The Initialization of your application failed.");
322 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:done]", _AppInfo::GetAppExecutableName().GetPointer());
324 _AppInfo::SetAppState(RUNNING);
326 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:done]", _AppInfo::GetAppExecutableName().GetPointer());
332 // call for callbacks
333 // ptr to member function
334 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
336 std::unique_ptr<char[], charDeleter> pOperation(null);
339 int errVal = service_get_operation(service, &pBuf);
340 pOperation.reset(pBuf);
342 if((errVal == SERVICE_ERROR_NONE) && (!strcmp((const char*)pOperation.get(), "osp.operation.ALARM")))
344 std::unique_ptr<char[], charDeleter> pAlarmId(null);
347 errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pBuf);
348 pAlarmId.reset(pBuf);
349 SysTryReturnVoidResult(NID_SYS, errVal == SERVICE_ERROR_NONE, E_SYSTEM, "It is failed to get reserved alarm id.");
350 int alarmId = atoi((const char*)pAlarmId.get());
352 _AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
353 pAlarmManager->OnAlarmExpired(alarmId);
359 pAppImpl->__pIAppImpl->OnService(service, initialLaunch);
361 // ptr to member function
362 (pAppImpl->*pAppImpl->__pLegacyRequestHandler)(service, req, handler);
367 _AppImpl::OnTerminate(void* user_data)
369 SysLog(NID_APP, "Termination event 0x%x state", _AppInfo::GetAppState());
371 _AppImpl* pAppImpl = _AppImpl::GetInstance();
372 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
373 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
375 result r = _SettingInfoImpl::RemoveSettingEventListenerForInternal(*pAppImpl);
376 SysTryLog(NID_APP, !IsFailed(r), "[%s] failed to remove setting event listener.", GetErrorMessage(r));
378 __isTerminationRequested = true;
379 pAppImpl->__pIAppImpl->OnTerminate();
384 _AppImpl::OnResume(void* user_data)
386 SysLog(NID_APP, "System resume event on 0x%x state", _AppInfo::GetAppState());
387 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:start]", _AppInfo::GetAppExecutableName().GetPointer());
389 _AppImpl* pAppImpl = _AppImpl::GetInstance();
390 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
391 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
392 pAppImpl->__pIAppImpl->OnResume();
393 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:done]", _AppInfo::GetAppExecutableName().GetPointer());
398 _AppImpl::OnPause(void* user_data)
400 SysLog(NID_APP, "System pause event on 0x%x state", _AppInfo::GetAppState());
401 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:start]", _AppInfo::GetAppExecutableName().GetPointer());
403 _AppImpl* pAppImpl = _AppImpl::GetInstance();
404 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
405 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
406 pAppImpl->__pIAppImpl->OnPause();
407 pAppImpl->OnAppCheckpoint();
408 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:done]", _AppInfo::GetAppExecutableName().GetPointer());
412 _AppImpl::~_AppImpl(void)
419 _AppImpl::GetInstance(void)
426 _AppImpl::GetAppInstance(void)
433 _AppImpl::GetAppArgumentListN(void) const
435 ArrayList* pList = null;
436 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
440 pList = pArg->GetArgListN(0);
445 pList = new (std::nothrow) ArrayList();
446 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
447 String* pData = new (std::nothrow) String(LEGACY_LAUNCH_REASON_NORMAL);
448 SysTryReturn(NID_APP, pData != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
449 String* pData2 = new (std::nothrow) String(LEGACY_OPERATION_MAIN);
450 SysTryReturn(NID_APP, pData2 != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
462 _AppImpl::Terminate(void)
464 result r = E_SUCCESS;
466 SysLog(NID_APP, "Terminate() is called by application itself");
468 __isTerminationRequested = true;
476 _AppImpl::OnAppInitializing(void)
483 _AppImpl::OnAppWillTerminate(void)
485 SysTryReturn(NID_APP, __pApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
487 return __pApp->OnAppWillTerminate();
492 _AppImpl::RegisterAppRequest(service_s* service, int& req, _AppHandler& handler)
494 _AppControlManager* pManager = _AppControlManager::GetInstance();
495 SysTryReturnResult(NID_APP, pManager != null, E_SYSTEM, "Wrong system state.");
497 result r = pManager->RegisterRequest(service, req, handler);
498 SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
500 int providerType = _AppInfo::GetAppHandlerType();
501 providerType |= (_APP_HANDLER_LAUNCH_NORMAL | _APP_HANDLER_LAUNCH_COND);
503 SysTryLog(NID_APP, (handler & providerType) != 0, "Request 0x%x received for 0x%x.", handler,
504 _AppInfo::GetAppHandlerType());
510 _AppImpl::HandleAppRequest(service_s* service, int req, _AppHandler handler)
512 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(req);
513 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
519 case _APP_HANDLER_DATACONTROL:
520 SysLog(NID_APP, "Handling DataControl request");
522 OnDataControlRequestReceived(*pArg, static_cast< RequestId >(req));
524 //_AppControlManager::GetInstance()->RemoveResultRequest(req);
527 case _APP_HANDLER_LAUNCH_COND:
528 SysLog(NID_APP, "Handling conditional launch request");
530 OnConditionRequestReceived(*pArg, static_cast< RequestId >(req));
534 SysLog(NID_APP, "Handling AppControl request");
536 OnAppControlRequestReceived(*pArg, static_cast< RequestId >(req));
545 _AppImpl::HandleLegacyAppRequest(service_s* service, int req, _AppHandler handler)
547 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
548 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
554 case _APP_HANDLER_LAUNCH_NORMAL:
555 SysLog(NID_APP, "Handling normal launch request");
556 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req), true);
558 // [TODO] request handle memory cleanup confirm
559 _AppControlManager::GetInstance()->RemoveResultRequest(req);
562 case _APP_HANDLER_LAUNCH_COND:
563 SysLog(NID_APP, "Handling conditional launch request");
565 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req), true);
567 // [TODO] request handle memory cleanup confirm
568 _AppControlManager::GetInstance()->RemoveResultRequest(req);
580 _AppImpl::HandleDummyAppRequest(service_s* service, int req, _AppHandler handler)
582 SysLog(NID_APP, "Dummy handler");
589 _AppImpl::SetLegacyRequestHandler(void)
591 SysLog(NID_APP, "Setting request handler for legacy application.");
593 __pRequestHandler = &_AppImpl::HandleDummyAppRequest;
594 __pLegacyRequestHandler = &_AppImpl::HandleLegacyAppRequest;
601 _AppImpl::OnLowMemory(void* user_data)
603 _AppImpl* pAppImpl = _AppImpl::GetInstance();
605 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
606 SysTryReturnVoidResult(NID_APP, pAppImpl->__pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
608 if (_AppInfo::GetAppState() == RUNNING)
610 pAppImpl->__pApp->OnLowMemory();
616 _AppImpl::OnBatteryLevelChanged(BatteryLevel batteryLevel)
618 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
620 __pApp->OnBatteryLevelChanged(batteryLevel);
624 _AppImpl::SendUserEvent(RequestId requestId, const IList* pArgs, bool isPublic)
626 _AppUserEventArg* pArg = new (std::nothrow) _AppUserEventArg(requestId, pArgs, isPublic);
627 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "User event creation failure for %d.", requestId);
629 result r = __appUserEvent.FireAsync(*pArg);
636 _AppImpl::OnUserEventReceivedN(RequestId requestId, IList* pArgs, bool isPublic)
638 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
642 __pApp->OnUserEventReceivedN(requestId, pArgs);
648 case _APP_EVENT_TERMINATE:
649 SysLog(NID_APP, "App terminate is requested.");
652 case _APP_EVENT_RAISE:
653 SysLog(NID_APP, "App raise is requested.");
657 SysLog(NID_APP, "Unknown event : 0x%x.", requestId);
665 _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
667 IAppControlProviderEventListener* pAppControlProviderEventListener = null;
669 const String internalOperation = arg.GetValue(OSP_K_APPCONTROL_INTERNAL_OPERATION);
670 if( !internalOperation.IsEmpty() )
672 SysLog(NID_APP, "internalOperation:%ls", internalOperation.GetPointer() );
673 pAppControlProviderEventListener = __pAppControlProviderInternalEventListener;
677 pAppControlProviderEventListener = __pAppControlProviderEventListener;
680 if( pAppControlProviderEventListener == null)
682 SysLog(NID_APP, "No AppControl provider event listener set for request %d.", reqId);
686 const char* pAppId = appinfo_get_appid();
688 const char* p = appsvc_get_operation(arg.GetBundle());
689 String operationId = (p) ? String(p) : TIZEN_OPERATION_MAIN;
690 if (operationId == L"http://tizen.org/appcontrol/operation/default")
692 operationId = TIZEN_OPERATION_MAIN;
695 SysLog(NID_APP, "AppControl (%s, %ls).", pAppId, operationId.GetPointer());
699 const String* pUri = null;
700 const String* pMime = null;
701 p = appsvc_get_uri(arg.GetBundle());
707 // SLP deals with the URI as plain /opt/.../a.jpg.
708 uri.Insert(FILE_SCHEME_WITH_DELIMITER, 0);
712 SysLog(NID_APP, "Delivered uri is [%ls].", pUri->GetPointer());
715 p = appsvc_get_mime(arg.GetBundle());
722 std::unique_ptr<HashMap> pMap(arg.GetArgMapN());
724 pAppControlProviderEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
726 SysLog(NID_APP, "AppControl (%s, %ls) invocation finished.", pAppId, operationId.GetPointer());
731 _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
734 ISqlDataControlProviderEventListener* pSqlListener = null;
735 IMapDataControlProviderEventListener* pMapListener = null;
736 ArrayList* pColumnList = null;
737 HashMap* pInsertMap = null;
738 HashMap* pUpdateMap = null;
743 String* pDataId = null;
745 String* pColumnCount = null;
746 String* pColumn = null;
747 String* pValue = null;
748 String* pWhere = null;
749 String* pOrder = null;
750 String* pErrorMsg = null;
752 String* pCount = null;
753 String* pTmpPath = null;
754 String empty(L"NULL");
757 _DataControlRequestType requestType = _DATACONTROL_REQUEST_TYPE_UNDEFINED;
760 int countPerPage = 0;
763 result r = E_SUCCESS;
764 result res = E_SUCCESS;
765 ArrayList* pList = null;
767 String* pNewValue = null;
768 String* pOldValue = null;
770 SysLog(NID_APP, "[DC_PROV_RECV] Data control request is received.");
771 //arg.Print(); // request info
774 appId = arg.GetCallerAppId();
776 reqType = arg.GetValue(OSP_K_DATACONTROL_REQUEST_TYPE);
777 Integer::Parse(reqType, type);
778 requestType = static_cast< _DataControlRequestType >(type);
780 version = arg.GetValue(OSP_K_DATACONTROL_PROTOCOL_VERSION);
781 callerReqId = arg.GetValue(OSP_K_REQUEST_ID);
782 providerId = arg.GetValue(OSP_K_DATACONTROL_PROVIDER);
784 // list-based request
785 pList = _AppArg::GetListN(arg.GetBundle(), OSP_K_ARG);
786 SysTryCatch(NID_APP, pList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object");
788 pDataId = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DATAID));// request list[0]: data ID
789 SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
791 if (requestType >= _DATACONTROL_REQUEST_TYPE_SQL_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_SQL_DELETE)
793 pSqlListener = __pSqlDataControlProviderEventListener;
794 SysTryCatch(NID_APP, pSqlListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
796 else if (requestType >= _DATACONTROL_REQUEST_TYPE_MAP_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_MAP_DELETE)
798 pKey = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_MAPKEY)); // request list[1]
799 SysTryCatch(NID_APP, pKey, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
801 pMapListener = __pMapDataControlProviderEventListener;
802 SysTryCatch(NID_APP, pMapListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
806 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid request");
812 case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
813 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl SELECT");
815 // request list[1]: selected column count
816 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
817 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
819 if (pColumnCount->Equals(empty) == true)
825 Integer::Parse(*pColumnCount, columnCount);
826 pColumnList = new (std::nothrow) ArrayList();
827 SysTryReturnVoidResult(NID_APP, pColumnList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
828 pColumnList->Construct();
829 SysLog(NID_APP, "[DC_PROV_RECV] selected column count: %d", columnCount);
832 while (i < columnCount) // request list[2]: column list
834 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNLIST + i));
835 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
837 pColumnList->Add(*(new String(*pColumn)));
838 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", i, pColumn->GetPointer());
843 i += _DATACONTROL_PACKET_INDEX_COLUMNLIST;
844 pWhere = dynamic_cast< String* >(pList->GetAt(i)); // request list: where clause
845 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
847 if (pWhere->Equals(empty) == true)
853 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
857 pOrder = dynamic_cast< String* >(pList->GetAt(i)); // request list: order clause
858 SysTryCatch(NID_APP, pOrder, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
860 if (pOrder->Equals(empty) == true)
866 SysLog(NID_APP, "[DC_PROV_RECV] pOrder: %ls", pOrder->GetPointer());
870 pNo = dynamic_cast <String*>(pList->GetAt(i)); // request list: page number
871 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
872 Integer::Parse(*pNo, pageNo);
875 pCount = dynamic_cast <String*>(pList->GetAt(i)); // request list: count per page
876 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
877 Integer::Parse(*pCount, countPerPage);
879 pSqlListener->OnSqlDataControlSelectRequestReceived(reqId, providerId, *pDataId, pColumnList,
882 SysSecureLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pColumnList: 0x%0x, pWhere: 0x%x, pOrder: 0x%x, pageNo: %d, countPerPage: %d",
883 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
884 pDataId->GetPointer(), pColumnList, pWhere, pOrder, pageNo, countPerPage);
886 case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
887 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl INSERT");
889 // request list[1]: inserted column count
890 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
891 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
893 Integer::Parse(*pColumnCount, columnCount);
894 SysLog(NID_APP, "[DC_PROV_RECV] inserted column count: %d", columnCount);
896 pInsertMap = new (std::nothrow) HashMap();
897 SysTryReturnVoidResult(NID_APP, pInsertMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
898 pInsertMap->Construct();
900 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
901 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
903 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
904 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
905 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
908 r = request.Construct(*pTmpPath, "r");
909 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
910 GetErrorMessage(r), pTmpPath->GetPointer());
912 for (i = 0; i < columnCount; ++i) // column-value pairs
915 int ret = request.Read(&length, sizeof(int));
916 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
917 GetErrorMessage(GetLastResult()));
919 char* pColumn = new (std::nothrow) char[length + 1];
920 ret = request.Read(pColumn, length);
921 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
922 GetErrorMessage(GetLastResult()));
923 pColumn[length] = '\0';
924 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
926 ret = request.Read(&length, sizeof(int));
927 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
928 GetErrorMessage(GetLastResult()));
930 char* pValue = new (std::nothrow) char[length + 1];
931 ret = request.Read(pValue, length);
934 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
938 pValue[length] = '\0';
939 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
941 pInsertMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
950 while (i < columnCount * 2) // request list: column-value pairs
952 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
953 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
954 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
956 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
957 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
958 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
960 pInsertMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
967 r = File::Remove(*pTmpPath);
968 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
971 pSqlListener->OnSqlDataControlInsertRequestReceived(reqId, providerId, *pDataId, *pInsertMap);
973 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pInsertMap: 0x%x",
974 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
975 pDataId->GetPointer(), pInsertMap);
977 case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
978 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl UPDATE");
980 // request list[1]: updated column count
981 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
982 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
984 Integer::Parse(*pColumnCount, columnCount);
985 SysLog(NID_APP, "[DC_PROV_RECV] updated column count: %d", columnCount);
987 pUpdateMap = new (std::nothrow) HashMap();
988 SysTryReturnVoidResult(NID_APP, pUpdateMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
989 pUpdateMap->Construct();
991 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
992 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
994 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
995 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
996 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
999 r = request.Construct(*pTmpPath, "r");
1000 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
1001 GetErrorMessage(r), pTmpPath->GetPointer());
1003 for (i = 0; i < columnCount; ++i) // column-value pairs
1006 int ret = request.Read(&length, sizeof(int));
1007 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
1008 GetErrorMessage(GetLastResult()));
1010 char* pColumn = new (std::nothrow) char[length + 1];
1011 ret = request.Read(pColumn, length);
1012 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1013 GetErrorMessage(GetLastResult()));
1014 pColumn[length] = '\0';
1015 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
1017 ret = request.Read(&length, sizeof(int));
1018 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1019 GetErrorMessage(GetLastResult()));
1021 char* pValue = new (std::nothrow) char[length + 1];
1022 ret = request.Read(pValue, length);
1025 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
1029 pValue[length] = '\0';
1030 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
1032 pUpdateMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
1037 // request list: where clause
1038 pWhere = dynamic_cast< String* >(pList->GetAt(3));
1039 SysTryCatch(NID_APP, pWhere != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
1045 while (i < columnCount * 2) // request list: column-value pairs
1047 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1048 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1049 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
1051 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1052 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1053 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
1055 pUpdateMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
1059 // request list: where clause
1060 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i));
1061 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1064 if (pWhere->Equals(empty) == true)
1070 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1075 r = File::Remove(*pTmpPath);
1076 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
1079 pSqlListener->OnSqlDataControlUpdateRequestReceived(reqId, providerId, *pDataId, *pUpdateMap, pWhere);
1081 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pUpdateMap: 0x%x, pWhere: 0x%x",
1082 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1083 pDataId->GetPointer(), pUpdateMap, pWhere);
1085 case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
1086 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl DELETE");
1088 // request list[1]: where clause
1089 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DELETEWHERE));
1090 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1092 if (pWhere->Equals(empty) == true)
1098 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1101 pSqlListener->OnSqlDataControlDeleteRequestReceived(reqId, providerId, *pDataId, pWhere);
1103 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pWhere: 0x%x",
1104 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1105 pDataId->GetPointer(), pWhere);
1107 case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
1108 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl GetValue");
1110 pNo = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1111 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1112 Integer::Parse(*pNo, pageNo);
1114 pCount = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1115 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1116 Integer::Parse(*pCount, countPerPage);
1118 pMapListener->OnMapDataControlGetValueRequestReceived(reqId, providerId, *pDataId, *pKey);
1120 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, pageNo: %d, countPerPage: %d",
1121 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1122 pDataId->GetPointer(), pKey->GetPointer(), pageNo, countPerPage);
1124 case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
1125 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl AddValue");
1127 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1128 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1130 pMapListener->OnMapDataControlAddValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1132 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1133 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1134 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1136 case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
1137 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl SetValue");
1139 pOldValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1140 SysTryCatch(NID_APP, pOldValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1142 pNewValue = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1143 SysTryCatch(NID_APP, pNewValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1145 pMapListener->OnMapDataControlSetValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pOldValue, *pNewValue);
1147 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, oldValue: %ls, newValue: %ls",
1148 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1149 pDataId->GetPointer(), pKey->GetPointer(), pOldValue->GetPointer(), pNewValue->GetPointer());
1151 case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
1152 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl RemoveValue");
1154 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1155 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1157 pMapListener->OnMapDataControlRemoveValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1159 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1160 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1161 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1164 SysTryCatch(NID_APP, false, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1170 pColumnList->RemoveAll(true);
1176 pInsertMap->RemoveAll(true);
1182 pUpdateMap->RemoveAll(true);
1191 pColumnList->RemoveAll(true);
1197 pInsertMap->RemoveAll(true);
1203 pUpdateMap->RemoveAll(true);
1209 pErrorMsg = new (std::nothrow) String("[E_SYSTEM] A system error has occurred.");
1211 else if (r == E_OUT_OF_MEMORY)
1213 pErrorMsg = new (std::nothrow) String("[E_OUT_OF_MEMORY] The memory was insufficient.");
1215 SysTryReturnVoidResult(NID_APP, pErrorMsg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient.");
1217 res = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, *pErrorMsg);
1226 _AppImpl::OnConditionRequestReceived(const _AppArg& arg, RequestId reqId)
1228 if (__pAppLaunchConditionEventListener == null)
1230 SysLog(NID_APP, "No App launch condition event listener");
1234 String condition = arg.GetValue(OSP_K_COND);
1235 //Object* pExtraData = null;//TODO: retrieve NFC extra data.
1236 HashMap* pExtraData = arg.GetArgMapN();
1237 ArrayList* pList = arg.GetArgListN();
1239 __pAppLaunchConditionEventListener->OnAppLaunchConditionMetN(condition, pExtraData, pList);
1244 _AppImpl::GetWindowHandle(void) const
1246 SysTryReturn(NID_APP, __pIAppImpl != null, -1, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1248 return __pIAppImpl->OnWindowHandleRequest();
1253 _AppImpl::RaiseWindow(void)
1255 SysTryReturnVoidResult(NID_APP, __pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1257 __pIAppImpl->OnFrameRaiseRequested();
1262 _AppImpl::OnAppCheckpoint(void)
1264 if (__pCheckpointEventListener)
1266 __pCheckpointEventListener->OnAppCheckpointing(*(AppRegistry::GetInstance()));
1272 _AppImpl::ConfirmAppService(void)
1274 if (_AppInfo::GetApplicationId() == SERVICE_APPID)
1281 long interval = 100;
1285 int res = vconf_get_int(VCONFKEY_APPSERVICE_STATUS, &value);
1291 if (count >= HEARTBEAT_WAIT_COUNT)
1296 SysLog(NID_APP, "Waiting for app service %dth time(%d msec).", count, interval);
1298 Thread::Sleep(interval);
1306 _AppImpl::SetListener(_AppEvent appEvent, IEventListener* pListener)
1310 case _APP_EVENT_CHECKPOINT:
1311 SysTryReturnResult(NID_APP, __pCheckpointEventListener == null, E_OBJ_ALREADY_EXIST, "Checkpoint listener is already set.");
1314 case _APP_EVENT_CLEAR_LISTENER:
1315 __pCheckpointEventListener = dynamic_cast <IAppCheckpointEventListener*>(pListener);
1327 _AppImpl::SetSqlDataControlProviderEventListener(ISqlDataControlProviderEventListener* pListener)
1329 __pSqlDataControlProviderEventListener = pListener;
1330 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1331 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1332 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1338 _AppImpl::SetMapDataControlProviderEventListener(IMapDataControlProviderEventListener* pListener)
1340 __pMapDataControlProviderEventListener = pListener;
1341 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1342 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1343 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1349 _AppImpl::SetAppControlProviderEventListener(IAppControlProviderEventListener* pListener)
1351 __pAppControlProviderEventListener = pListener;
1352 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1353 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1354 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1359 _AppImpl::SetAppControlProviderInternalEventListener(IAppControlProviderEventListener* pListener)
1361 __pAppControlProviderInternalEventListener = pListener;
1362 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1363 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1364 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1370 _AppImpl::SetAppLaunchConditionEventListener(IAppLaunchConditionEventListener* pListener)
1372 __pAppLaunchConditionEventListener = pListener;
1373 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1374 tmpAppHandlerType |= _APP_HANDLER_LAUNCH_COND;
1375 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1382 _AppImpl::IsTerminationRequested(void)
1384 return __isTerminationRequested;
1387 typedef void (*cbForVconf)(keynode_t* node, void *pData);
1390 _AppImpl::OnPowerOffNotiReceived(void* node, void* user_data)
1393 if (!vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &value))
1395 if (value == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || value == VCONFKEY_SYSMAN_POWER_OFF_RESTART)
1397 SysLog(NID_APP, "Application is being terminated by power off.");
1399 if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (cbForVconf)_AppImpl::OnPowerOffNotiReceived))
1401 SysLog(NID_APP, "Fail to ignore vconf for key(%s)", VCONFKEY_SYSMAN_POWER_OFF_STATUS);
1404 _AppImpl* pAppImpl = _AppImpl::GetInstance();
1405 if (pAppImpl != null)
1407 pAppImpl->__forcedTermination = true;
1416 _AppImpl::OnSettingChanged(String& key)
1418 if (key == L"http://tizen.org/setting/locale.language")
1420 _AppInfo::UpdatePackageInfo(true);
1421 _AppResourceImpl::Reinitialize();
1422 SysLog(NID_APP, "Reinitialized resources due to locale change.");
1427 _AppImpl::IsForcedTermination(void)
1429 return __forcedTermination;