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"
60 using namespace Tizen::Base;
61 using namespace Tizen::Base::Collection;
62 using namespace Tizen::Base::Runtime;
63 using namespace Tizen::Io;
64 using namespace Tizen::System;
69 const int HEARTBEAT_WAIT_COUNT = 3;
70 const wchar_t SERVICE_APPID[] = L"aospd00043.osp-app-service";
71 const char SELECTOR_RESPONSE_KEY[] = "__APP_SVC_START_INFO__";
72 const wchar_t FILE_SCHEME_WITH_DELIMITER[] = L"file://";
73 #ifndef VCONFKEY_APPSERVICE_STATUS
74 #define VCONFKEY_APPSERVICE_STATUS "memory/appservice/status"
79 namespace Tizen { namespace App
82 _AppImpl* _AppImpl::__pAppImpl = null;
83 bool _AppImpl::__isTerminationRequested = false;
85 static const int _DATACONTROL_PACKET_INDEX_APPID = 0;
86 static const int _DATACONTROL_PACKET_INDEX_REQUESTTYPE = 1;
87 static const int _DATACONTROL_PACKET_INDEX_REQID = 2;
88 static const int _DATACONTROL_PACKET_INDEX_PROVIDERID = 3;
90 static const int _DATACONTROL_PACKET_INDEX_DATAID = 0;
91 static const int _DATACONTROL_PACKET_INDEX_COLUMNCOUNT = 1;
92 static const int _DATACONTROL_PACKET_INDEX_DELETEWHERE = 1;
93 static const int _DATACONTROL_PACKET_INDEX_MAPKEY = 1;
94 static const int _DATACONTROL_PACKET_INDEX_COLUMNLIST = 2;
95 static const int _DATACONTROL_PACKET_INDEX_INSERTMAP = 2;
96 static const int _DATACONTROL_PACKET_INDEX_UPDATEMAP = 2;
100 void operator()(char* pValue)
110 _AppImpl::_AppImpl(App* pApp)
111 : __pCheckpointEventListener(null)
112 , __pSqlDataControlProviderEventListener(null)
113 , __pMapDataControlProviderEventListener(null)
114 , __pAppControlProviderEventListener(null)
115 , __pAppControlProviderInternalEventListener(null)
116 , __pAppLaunchConditionEventListener(null)
119 , __pRequestHandler(&_AppImpl::HandleAppRequest)
120 , __pLegacyRequestHandler(&_AppImpl::HandleDummyAppRequest)
121 , __forcedTermination(false)
128 _AppImpl::Construct(const IList* pArgs)
130 SysTryReturnResult(NID_APP, pArgs != null, E_INVALID_ARG, "pArguments must not be null.");
131 SysAssertf(__pApp != null, "Getting App instance failed.");
133 result r = __appUserEvent.Construct();
134 SysTryLog(NID_APP, !IsFailed(r), "[%s] User event handler failure.", GetErrorMessage(r));
136 __appUserEvent.AddListener(*this);
138 _AppInfo::SetAppState(INITIALIZING);
145 _AppImpl::Execute(_IAppImpl* pIAppImpl)
147 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:start]", _AppInfo::GetAppExecutableName().GetPointer());
148 result r = E_SUCCESS;
149 int eflResult = APP_ERROR_NONE;
152 _IAppManager* pAppManager = null;
154 _AppImpl* pAppImpl = _AppImpl::GetInstance();
155 SysTryReturnResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
156 pAppImpl->__pIAppImpl = pIAppImpl;
158 // handle legacy version handling
159 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
161 pAppImpl->SetLegacyRequestHandler();
164 app_event_callback_s state_handler;
165 memset(&state_handler, 0, sizeof(app_event_callback_s));
167 state_handler.create = &OnCreate;
168 state_handler.service = &OnService;
169 state_handler.terminate = &OnTerminate;
170 state_handler.pause = &OnPause;
171 state_handler.resume = &OnResume;
172 state_handler.device_orientation = NULL;
174 state_handler.low_memory = &OnLowMemory;
175 state_handler.low_battery = NULL;
176 state_handler.language_changed = &OnLanguageChanged;
177 state_handler.region_format_changed = NULL;
179 _Aul::SetPowerOffNotiListener(OnPowerOffNotiReceived, this);
180 // if (pAppManager != null)
182 // r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), _AppInfo::GetAppType() , _AppInfo::GetProcessId());
183 // SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Application registration failed.", GetErrorMessage(r));
186 appinfo_get_argv(&argc, &pArgv);
187 eflResult = app_efl_main(&argc, &pArgv, &state_handler, this);
188 SysTryLog(NID_APP, eflResult == APP_ERROR_NONE, "app_efl_main failed with error (%d): Unknown", eflResult);
190 pAppManager = _AppManagerProxy::GetService();
192 if (pAppManager != null)
194 pAppManager->UnregisterApplication(_AppInfo::GetProcessId());
197 // clear outstanding ongoing notification
198 notification_delete_all_by_type(appinfo_get_appid(), NOTIFICATION_TYPE_ONGOING);
205 _AppImpl::OnCreate(void* user_data)
207 SysLog(NID_APP, "Platform creation event.");
209 _AppImpl* pAppImpl = static_cast<_AppImpl*>(user_data);
210 if (pAppImpl == null)
212 _AppInfo::SetAppState(TERMINATED);
213 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Invalid platform state.");
217 _AppInfo::SetAppState(INITIALIZING);
219 if (!ConfirmAppService())
221 _AppInfo::SetAppState(TERMINATED);
222 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Osp AppService is not running.");
226 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:start]", _AppInfo::GetAppExecutableName().GetPointer());
227 if (!pAppImpl->__pIAppImpl->OnAppInitializing())
229 _AppInfo::SetAppState(TERMINATED);
230 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] The initialization of your application failed.");
233 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:done]", _AppInfo::GetAppExecutableName().GetPointer());
235 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:start]", _AppInfo::GetAppExecutableName().GetPointer());
236 _IAppManager* pAppManager = _AppManagerProxy::GetService();
238 if (pAppManager != null)
240 result r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), static_cast<_AppType>(_AppInfo::GetAppType()), _AppInfo::GetProcessId());
241 SysTryLog(NID_APP, !IsFailed(r), "[%s] Application registration failed.", GetErrorMessage(r));
243 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:done]", _AppInfo::GetAppExecutableName().GetPointer());
244 // hide splash window
246 _PowerManagerImpl::InitBatteryEvent();
253 _AppImpl::OnService(service_s* service, void* user_data)
255 _AppImpl* pAppImpl = _AppImpl::GetInstance();
256 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
257 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
259 // ugly code for app selector event handling
260 bundle* pBundle = _AppArg::GetBundleFromSvc(service);
263 const char* pValue = appsvc_get_data(pBundle, SELECTOR_RESPONSE_KEY);
266 const int req = _AppArg::GetRequestIdFromBundle(pBundle);
268 const char* pOperation = appsvc_get_operation(pBundle);
270 SysLog(NID_APP, "App selector response [%s, %s], req(%d).", pValue, pOperation, req);
272 //_AppArg::Print(pBundle);
273 _AppControlManager::GetInstance()->SendAppControlStartResponse(req, pValue, pOperation);
278 //_AppArg::Print(pBundle);
280 _AppHandler handler = _APP_HANDLER_NONE;
281 pAppImpl->RegisterAppRequest(service, req, handler);
283 bool initialLaunch = false;
286 // (1) AppControl / DataControl provider listener
287 // (2) OnAppInitialized()
288 // (3) OnResume() (OnForeground()) (UiApp only)
289 // (4) OnUserEventReceivedN()
292 // (1) AppControl / DataControl provider listener
293 // (2) OnResume() (OnForeground()) (UiApp only)
294 // (3) OnUserEventReceivedN()
296 if (_AppInfo::GetAppState() == INITIALIZING)
298 initialLaunch = true;
300 unsigned int winId = 0;
301 service_get_window(service, &winId);
304 _AppInfo::SetParentWindowHandle(winId);
305 SysLog(NID_APP, "Saving window handle 0x%x.", winId);
307 // call for callbacks
308 // ptr to member function
309 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:start]", _AppInfo::GetAppExecutableName().GetPointer());
310 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
312 if (!pAppImpl->__pIAppImpl->OnAppInitialized())
314 _AppInfo::SetAppState(TERMINATING);
315 SysLog(NID_APP, "[E_INIT_FAILED] The Initialization of your application failed.");
319 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:done]", _AppInfo::GetAppExecutableName().GetPointer());
321 _AppInfo::SetAppState(RUNNING);
323 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:done]", _AppInfo::GetAppExecutableName().GetPointer());
329 // call for callbacks
330 // ptr to member function
331 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
333 std::unique_ptr<char[], charDeleter> pOperation(null);
336 int errVal = service_get_operation(service, &pBuf);
337 pOperation.reset(pBuf);
339 if((errVal == SERVICE_ERROR_NONE) && (!strcmp((const char*)pOperation.get(), "osp.operation.ALARM")))
341 std::unique_ptr<char[], charDeleter> pAlarmId(null);
344 errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pBuf);
345 pAlarmId.reset(pBuf);
346 SysTryReturnVoidResult(NID_SYS, errVal == SERVICE_ERROR_NONE, E_SYSTEM, "It is failed to get reserved alarm id.");
347 int alarmId = atoi((const char*)pAlarmId.get());
349 _AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
350 pAlarmManager->OnAlarmExpired(alarmId);
356 pAppImpl->__pIAppImpl->OnService(service, initialLaunch);
358 // ptr to member function
359 (pAppImpl->*pAppImpl->__pLegacyRequestHandler)(service, req, handler);
364 _AppImpl::OnTerminate(void* user_data)
366 SysLog(NID_APP, "Termination event 0x%x state", _AppInfo::GetAppState());
368 _AppImpl* pAppImpl = _AppImpl::GetInstance();
369 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
370 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
372 __isTerminationRequested = true;
373 pAppImpl->__pIAppImpl->OnTerminate();
378 _AppImpl::OnResume(void* user_data)
380 SysLog(NID_APP, "System resume event on 0x%x state", _AppInfo::GetAppState());
381 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:start]", _AppInfo::GetAppExecutableName().GetPointer());
383 _AppImpl* pAppImpl = _AppImpl::GetInstance();
384 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
385 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
386 pAppImpl->__pIAppImpl->OnResume();
387 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:done]", _AppInfo::GetAppExecutableName().GetPointer());
392 _AppImpl::OnPause(void* user_data)
394 SysLog(NID_APP, "System pause event on 0x%x state", _AppInfo::GetAppState());
395 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:start]", _AppInfo::GetAppExecutableName().GetPointer());
397 _AppImpl* pAppImpl = _AppImpl::GetInstance();
398 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
399 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
400 pAppImpl->__pIAppImpl->OnPause();
401 pAppImpl->OnAppCheckpoint();
402 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:done]", _AppInfo::GetAppExecutableName().GetPointer());
406 _AppImpl::~_AppImpl(void)
413 _AppImpl::GetInstance(void)
420 _AppImpl::GetAppInstance(void)
427 _AppImpl::GetAppArgumentListN(void) const
429 ArrayList* pList = null;
430 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
434 pList = pArg->GetArgListN(0);
439 pList = new (std::nothrow) ArrayList();
440 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
441 String* pData = new (std::nothrow) String(LEGACY_LAUNCH_REASON_NORMAL);
442 SysTryReturn(NID_APP, pData != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
443 String* pData2 = new (std::nothrow) String(LEGACY_OPERATION_MAIN);
444 SysTryReturn(NID_APP, pData2 != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
456 _AppImpl::Terminate(void)
458 result r = E_SUCCESS;
460 __isTerminationRequested = true;
468 _AppImpl::OnAppInitializing(void)
475 _AppImpl::OnAppWillTerminate(void)
477 SysTryReturn(NID_APP, __pApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
479 return __pApp->OnAppWillTerminate();
484 _AppImpl::RegisterAppRequest(service_s* service, int& req, _AppHandler& handler)
486 _AppControlManager* pManager = _AppControlManager::GetInstance();
487 SysTryReturnResult(NID_APP, pManager != null, E_SYSTEM, "Wrong system state.");
489 result r = pManager->RegisterRequest(service, req, handler);
490 SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
492 int providerType = _AppInfo::GetAppHandlerType();
493 providerType |= (_APP_HANDLER_LAUNCH_NORMAL | _APP_HANDLER_LAUNCH_COND);
495 SysTryLog(NID_APP, (handler & providerType) != 0, "Request 0x%x received for 0x%x.", handler,
496 _AppInfo::GetAppHandlerType());
502 _AppImpl::HandleAppRequest(service_s* service, int req, _AppHandler handler)
504 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(req);
505 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
511 case _APP_HANDLER_DATACONTROL:
512 SysLog(NID_APP, "Handling DataControl request");
514 OnDataControlRequestReceived(*pArg, static_cast< RequestId >(req));
516 //_AppControlManager::GetInstance()->RemoveResultRequest(req);
519 case _APP_HANDLER_LAUNCH_COND:
520 SysLog(NID_APP, "Handling conditional launch request");
522 OnConditionRequestReceived(*pArg, static_cast< RequestId >(req));
526 SysLog(NID_APP, "Handling AppControl request");
528 OnAppControlRequestReceived(*pArg, static_cast< RequestId >(req));
537 _AppImpl::HandleLegacyAppRequest(service_s* service, int req, _AppHandler handler)
539 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
540 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
546 case _APP_HANDLER_LAUNCH_NORMAL:
547 SysLog(NID_APP, "Handling normal launch request");
548 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req), true);
550 // [TODO] request handle memory cleanup confirm
551 _AppControlManager::GetInstance()->RemoveResultRequest(req);
554 case _APP_HANDLER_LAUNCH_COND:
555 SysLog(NID_APP, "Handling conditional launch request");
557 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req), true);
559 // [TODO] request handle memory cleanup confirm
560 _AppControlManager::GetInstance()->RemoveResultRequest(req);
572 _AppImpl::HandleDummyAppRequest(service_s* service, int req, _AppHandler handler)
574 SysLog(NID_APP, "Dummy handler");
581 _AppImpl::SetLegacyRequestHandler(void)
583 SysLog(NID_APP, "Setting request handler for legacy application.");
585 __pRequestHandler = &_AppImpl::HandleDummyAppRequest;
586 __pLegacyRequestHandler = &_AppImpl::HandleLegacyAppRequest;
593 _AppImpl::OnLowMemory(void* user_data)
595 _AppImpl* pAppImpl = _AppImpl::GetInstance();
597 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
598 SysTryReturnVoidResult(NID_APP, pAppImpl->__pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
600 if (_AppInfo::GetAppState() == RUNNING)
602 pAppImpl->__pApp->OnLowMemory();
608 _AppImpl::OnBatteryLevelChanged(BatteryLevel batteryLevel)
610 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
612 __pApp->OnBatteryLevelChanged(batteryLevel);
616 _AppImpl::OnLanguageChanged(void* user_data)
619 _AppInfo::UpdatePackageInfo(true);
621 _AppResourceImpl::Reinitialize();
622 SysLog(NID_APP, "Language change done.");
627 _AppImpl::SendUserEvent(RequestId requestId, const IList* pArgs, bool isPublic)
629 _AppUserEventArg* pArg = new (std::nothrow) _AppUserEventArg(requestId, pArgs, isPublic);
630 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "User event creation failure for %d.", requestId);
632 result r = __appUserEvent.FireAsync(*pArg);
639 _AppImpl::OnUserEventReceivedN(RequestId requestId, IList* pArgs, bool isPublic)
641 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
645 __pApp->OnUserEventReceivedN(requestId, pArgs);
651 case _APP_EVENT_TERMINATE:
652 SysLog(NID_APP, "App terminate is requested.");
655 case _APP_EVENT_RAISE:
656 SysLog(NID_APP, "App raise is requested.");
660 SysLog(NID_APP, "Unknown event : 0x%x.", requestId);
668 _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
670 IAppControlProviderEventListener* pAppControlProviderEventListener = null;
672 const String internalOperation = arg.GetValue(OSP_K_APPCONTROL_INTERNAL_OPERATION);
673 if( !internalOperation.IsEmpty() )
675 SysLog(NID_APP, "internalOperation:%ls", internalOperation.GetPointer() );
676 pAppControlProviderEventListener = __pAppControlProviderInternalEventListener;
680 pAppControlProviderEventListener = __pAppControlProviderEventListener;
683 if( pAppControlProviderEventListener == null)
685 SysLog(NID_APP, "No AppControl provider event listener set for request %d.", reqId);
689 const char* pAppId = appinfo_get_appid();
691 const char* p = appsvc_get_operation(arg.GetBundle());
692 String operationId = (p) ? String(p) : TIZEN_OPERATION_MAIN;
693 if (operationId == L"http://tizen.org/appcontrol/operation/default")
695 operationId = TIZEN_OPERATION_MAIN;
698 SysLog(NID_APP, "AppControl (%s, %ls).", pAppId, operationId.GetPointer());
702 const String* pUri = null;
703 const String* pMime = null;
704 p = appsvc_get_uri(arg.GetBundle());
710 // SLP deals with the URI as plain /opt/.../a.jpg.
711 uri.Insert(FILE_SCHEME_WITH_DELIMITER, 0);
715 SysLog(NID_APP, "Delivered uri is [%ls].", pUri->GetPointer());
718 p = appsvc_get_mime(arg.GetBundle());
725 std::unique_ptr<HashMap> pMap(arg.GetArgMapN());
727 pAppControlProviderEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
729 SysLog(NID_APP, "AppControl (%s, %ls) invocation finished.", pAppId, operationId.GetPointer());
734 _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
737 ISqlDataControlProviderEventListener* pSqlListener = null;
738 IMapDataControlProviderEventListener* pMapListener = null;
739 ArrayList* pColumnList = null;
740 HashMap* pInsertMap = null;
741 HashMap* pUpdateMap = null;
746 String* pDataId = null;
748 String* pColumnCount = null;
749 String* pColumn = null;
750 String* pValue = null;
751 String* pWhere = null;
752 String* pOrder = null;
753 String* pErrorMsg = null;
755 String* pCount = null;
756 String* pTmpPath = null;
757 String empty(L"NULL");
760 _DataControlRequestType requestType = _DATACONTROL_REQUEST_TYPE_UNDEFINED;
763 int countPerPage = 0;
766 result r = E_SUCCESS;
767 result res = E_SUCCESS;
768 ArrayList* pList = null;
770 String* pNewValue = null;
771 String* pOldValue = null;
773 SysLog(NID_APP, "[DC_PROV_RECV] Data control request is received.");
774 //arg.Print(); // request info
777 appId = arg.GetCallerAppId();
779 reqType = arg.GetValue(OSP_K_DATACONTROL_REQUEST_TYPE);
780 Integer::Parse(reqType, type);
781 requestType = static_cast< _DataControlRequestType >(type);
783 version = arg.GetValue(OSP_K_DATACONTROL_PROTOCOL_VERSION);
784 callerReqId = arg.GetValue(OSP_K_REQUEST_ID);
785 providerId = arg.GetValue(OSP_K_DATACONTROL_PROVIDER);
787 // list-based request
788 pList = _AppArg::GetListN(arg.GetBundle(), OSP_K_ARG);
789 SysTryCatch(NID_APP, pList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object");
791 pDataId = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DATAID));// request list[0]: data ID
792 SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
794 if (requestType >= _DATACONTROL_REQUEST_TYPE_SQL_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_SQL_DELETE)
796 pSqlListener = __pSqlDataControlProviderEventListener;
797 SysTryCatch(NID_APP, pSqlListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
799 else if (requestType >= _DATACONTROL_REQUEST_TYPE_MAP_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_MAP_DELETE)
801 pKey = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_MAPKEY)); // request list[1]
802 SysTryCatch(NID_APP, pKey, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
804 pMapListener = __pMapDataControlProviderEventListener;
805 SysTryCatch(NID_APP, pMapListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
809 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid request");
815 case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
816 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl SELECT");
818 // request list[1]: selected column count
819 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
820 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
822 if (pColumnCount->Equals(empty) == true)
828 Integer::Parse(*pColumnCount, columnCount);
829 pColumnList = new (std::nothrow) ArrayList();
830 SysTryReturnVoidResult(NID_APP, pColumnList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
831 pColumnList->Construct();
832 SysLog(NID_APP, "[DC_PROV_RECV] selected column count: %d", columnCount);
835 while (i < columnCount) // request list[2]: column list
837 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNLIST + i));
838 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
840 pColumnList->Add(*(new String(*pColumn)));
841 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", i, pColumn->GetPointer());
846 i += _DATACONTROL_PACKET_INDEX_COLUMNLIST;
847 pWhere = dynamic_cast< String* >(pList->GetAt(i)); // request list: where clause
848 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
850 if (pWhere->Equals(empty) == true)
856 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
860 pOrder = dynamic_cast< String* >(pList->GetAt(i)); // request list: order clause
861 SysTryCatch(NID_APP, pOrder, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
863 if (pOrder->Equals(empty) == true)
869 SysLog(NID_APP, "[DC_PROV_RECV] pOrder: %ls", pOrder->GetPointer());
873 pNo = dynamic_cast <String*>(pList->GetAt(i)); // request list: page number
874 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
875 Integer::Parse(*pNo, pageNo);
878 pCount = dynamic_cast <String*>(pList->GetAt(i)); // request list: count per page
879 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
880 Integer::Parse(*pCount, countPerPage);
882 pSqlListener->OnSqlDataControlSelectRequestReceived(reqId, providerId, *pDataId, pColumnList,
885 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",
886 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
887 pDataId->GetPointer(), pColumnList, pWhere, pOrder, pageNo, countPerPage);
889 case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
890 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl INSERT");
892 // request list[1]: inserted column count
893 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
894 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
896 Integer::Parse(*pColumnCount, columnCount);
897 SysLog(NID_APP, "[DC_PROV_RECV] inserted column count: %d", columnCount);
899 pInsertMap = new (std::nothrow) HashMap();
900 SysTryReturnVoidResult(NID_APP, pInsertMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
901 pInsertMap->Construct();
903 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
904 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
906 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
907 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
908 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
911 r = request.Construct(*pTmpPath, "r");
912 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
913 GetErrorMessage(r), pTmpPath->GetPointer());
915 for (i = 0; i < columnCount; ++i) // column-value pairs
918 int ret = request.Read(&length, sizeof(int));
919 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
920 GetErrorMessage(GetLastResult()));
922 char* pColumn = new (std::nothrow) char[length + 1];
923 ret = request.Read(pColumn, length);
924 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
925 GetErrorMessage(GetLastResult()));
926 pColumn[length] = '\0';
927 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
929 ret = request.Read(&length, sizeof(int));
930 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
931 GetErrorMessage(GetLastResult()));
933 char* pValue = new (std::nothrow) char[length + 1];
934 ret = request.Read(pValue, length);
937 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
941 pValue[length] = '\0';
942 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
944 pInsertMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
953 while (i < columnCount * 2) // request list: column-value pairs
955 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
956 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
957 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
959 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
960 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
961 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
963 pInsertMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
970 r = File::Remove(*pTmpPath);
971 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
974 pSqlListener->OnSqlDataControlInsertRequestReceived(reqId, providerId, *pDataId, *pInsertMap);
976 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pInsertMap: 0x%x",
977 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
978 pDataId->GetPointer(), pInsertMap);
980 case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
981 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl UPDATE");
983 // request list[1]: updated column count
984 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
985 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
987 Integer::Parse(*pColumnCount, columnCount);
988 SysLog(NID_APP, "[DC_PROV_RECV] updated column count: %d", columnCount);
990 pUpdateMap = new (std::nothrow) HashMap();
991 SysTryReturnVoidResult(NID_APP, pUpdateMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
992 pUpdateMap->Construct();
994 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
995 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
997 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
998 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
999 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
1002 r = request.Construct(*pTmpPath, "r");
1003 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
1004 GetErrorMessage(r), pTmpPath->GetPointer());
1006 for (i = 0; i < columnCount; ++i) // column-value pairs
1009 int ret = request.Read(&length, sizeof(int));
1010 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
1011 GetErrorMessage(GetLastResult()));
1013 char* pColumn = new (std::nothrow) char[length + 1];
1014 ret = request.Read(pColumn, length);
1015 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1016 GetErrorMessage(GetLastResult()));
1017 pColumn[length] = '\0';
1018 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
1020 ret = request.Read(&length, sizeof(int));
1021 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1022 GetErrorMessage(GetLastResult()));
1024 char* pValue = new (std::nothrow) char[length + 1];
1025 ret = request.Read(pValue, length);
1028 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
1032 pValue[length] = '\0';
1033 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
1035 pUpdateMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
1040 // request list: where clause
1041 pWhere = dynamic_cast< String* >(pList->GetAt(3));
1042 SysTryCatch(NID_APP, pWhere != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
1048 while (i < columnCount * 2) // request list: column-value pairs
1050 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1051 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1052 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
1054 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1055 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1056 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
1058 pUpdateMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
1062 // request list: where clause
1063 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i));
1064 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1067 if (pWhere->Equals(empty) == true)
1073 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1078 r = File::Remove(*pTmpPath);
1079 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
1082 pSqlListener->OnSqlDataControlUpdateRequestReceived(reqId, providerId, *pDataId, *pUpdateMap, pWhere);
1084 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pUpdateMap: 0x%x, pWhere: 0x%x",
1085 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1086 pDataId->GetPointer(), pUpdateMap, pWhere);
1088 case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
1089 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl DELETE");
1091 // request list[1]: where clause
1092 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DELETEWHERE));
1093 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1095 if (pWhere->Equals(empty) == true)
1101 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1104 pSqlListener->OnSqlDataControlDeleteRequestReceived(reqId, providerId, *pDataId, pWhere);
1106 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pWhere: 0x%x",
1107 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1108 pDataId->GetPointer(), pWhere);
1110 case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
1111 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl GetValue");
1113 pNo = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1114 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1115 Integer::Parse(*pNo, pageNo);
1117 pCount = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1118 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1119 Integer::Parse(*pCount, countPerPage);
1121 pMapListener->OnMapDataControlGetValueRequestReceived(reqId, providerId, *pDataId, *pKey);
1123 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, pageNo: %d, countPerPage: %d",
1124 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1125 pDataId->GetPointer(), pKey->GetPointer(), pageNo, countPerPage);
1127 case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
1128 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl AddValue");
1130 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1131 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1133 pMapListener->OnMapDataControlAddValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1135 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1136 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1137 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1139 case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
1140 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl SetValue");
1142 pOldValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1143 SysTryCatch(NID_APP, pOldValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1145 pNewValue = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1146 SysTryCatch(NID_APP, pNewValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1148 pMapListener->OnMapDataControlSetValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pOldValue, *pNewValue);
1150 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, oldValue: %ls, newValue: %ls",
1151 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1152 pDataId->GetPointer(), pKey->GetPointer(), pOldValue->GetPointer(), pNewValue->GetPointer());
1154 case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
1155 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl RemoveValue");
1157 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1158 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1160 pMapListener->OnMapDataControlRemoveValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1162 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1163 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1164 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1167 SysTryCatch(NID_APP, false, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1173 pColumnList->RemoveAll(true);
1179 pInsertMap->RemoveAll(true);
1185 pUpdateMap->RemoveAll(true);
1194 pColumnList->RemoveAll(true);
1200 pInsertMap->RemoveAll(true);
1206 pUpdateMap->RemoveAll(true);
1212 pErrorMsg = new (std::nothrow) String("[E_SYSTEM] A system error has occurred.");
1214 else if (r == E_OUT_OF_MEMORY)
1216 pErrorMsg = new (std::nothrow) String("[E_OUT_OF_MEMORY] The memory was insufficient.");
1218 SysTryReturnVoidResult(NID_APP, pErrorMsg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient.");
1220 res = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, *pErrorMsg);
1229 _AppImpl::OnConditionRequestReceived(const _AppArg& arg, RequestId reqId)
1231 if (__pAppLaunchConditionEventListener == null)
1233 SysLog(NID_APP, "No App launch condition event listener");
1237 String condition = arg.GetValue(OSP_K_COND);
1238 //Object* pExtraData = null;//TODO: retrieve NFC extra data.
1239 HashMap* pExtraData = arg.GetArgMapN();
1240 ArrayList* pList = arg.GetArgListN();
1242 __pAppLaunchConditionEventListener->OnAppLaunchConditionMetN(condition, pExtraData, pList);
1247 _AppImpl::GetWindowHandle(void) const
1249 SysTryReturn(NID_APP, __pIAppImpl != null, -1, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1251 return __pIAppImpl->OnWindowHandleRequest();
1256 _AppImpl::RaiseWindow(void)
1258 SysTryReturnVoidResult(NID_APP, __pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1260 __pIAppImpl->OnFrameRaiseRequested();
1265 _AppImpl::OnAppCheckpoint(void)
1267 if (__pCheckpointEventListener)
1269 __pCheckpointEventListener->OnAppCheckpointing(*(AppRegistry::GetInstance()));
1275 _AppImpl::ConfirmAppService(void)
1277 if (_AppInfo::GetApplicationId() == SERVICE_APPID)
1284 long interval = 100;
1288 int res = vconf_get_int(VCONFKEY_APPSERVICE_STATUS, &value);
1294 if (count >= HEARTBEAT_WAIT_COUNT)
1299 SysLog(NID_APP, "Waiting for app service %dth time(%d msec).", count, interval);
1301 Thread::Sleep(interval);
1309 _AppImpl::SetListener(_AppEvent appEvent, IEventListener* pListener)
1313 case _APP_EVENT_CHECKPOINT:
1314 SysTryReturnResult(NID_APP, __pCheckpointEventListener == null, E_OBJ_ALREADY_EXIST, "Checkpoint listener is already set.");
1317 case _APP_EVENT_CLEAR_LISTENER:
1318 __pCheckpointEventListener = dynamic_cast <IAppCheckpointEventListener*>(pListener);
1330 _AppImpl::SetSqlDataControlProviderEventListener(ISqlDataControlProviderEventListener* pListener)
1332 __pSqlDataControlProviderEventListener = pListener;
1333 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1334 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1335 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1341 _AppImpl::SetMapDataControlProviderEventListener(IMapDataControlProviderEventListener* pListener)
1343 __pMapDataControlProviderEventListener = pListener;
1344 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1345 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1346 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1352 _AppImpl::SetAppControlProviderEventListener(IAppControlProviderEventListener* pListener)
1354 __pAppControlProviderEventListener = pListener;
1355 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1356 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1357 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1362 _AppImpl::SetAppControlProviderInternalEventListener(IAppControlProviderEventListener* pListener)
1364 __pAppControlProviderInternalEventListener = pListener;
1365 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1366 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1367 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1373 _AppImpl::SetAppLaunchConditionEventListener(IAppLaunchConditionEventListener* pListener)
1375 __pAppLaunchConditionEventListener = pListener;
1376 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1377 tmpAppHandlerType |= _APP_HANDLER_LAUNCH_COND;
1378 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1385 _AppImpl::IsTerminationRequested(void)
1387 return __isTerminationRequested;
1391 _AppImpl::OnPowerOffNotiReceived(void* user_data)
1393 SysLog(NID_APP, "Application is being terminated by power off.");
1395 _AppImpl* pAppImpl = _AppImpl::GetInstance();
1396 if (pAppImpl != null)
1398 pAppImpl->__forcedTermination = true;
1405 _AppImpl::IsForcedTermination(void)
1407 return __forcedTermination;