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>
28 #include <FBaseInteger.h>
29 #include <FBaseColArrayList.h>
30 #include <FBaseColHashMap.h>
31 #include <FBaseRtThread.h>
32 #include <FAppAppRegistry.h>
33 #include <FAppAppControl.h>
34 #include <FAppDataControlProviderManager.h>
35 #include <FAppIAppCheckPointEventListener.h>
36 #include <FAppISqlDataControlProviderEventListener.h>
37 #include <FAppIMapDataControlProviderEventListener.h>
38 #include <FAppIAppControlProviderEventListener.h>
39 #include <FAppIAppLaunchConditionEventListener.h>
42 #include <FBaseSysLog.h>
43 #include <FIo_RegistryImpl.h>
44 #include <FSys_EnvironmentImpl.h>
45 #include <FSys_PowerManagerImpl.h>
47 #include <FSys_AlarmManager.h>
49 #include "FApp_IAppManager.h"
50 #include "FApp_AppManagerProxy.h"
51 #include "FApp_AppImpl.h"
52 #include "FApp_AppInfo.h"
53 #include "FApp_AppControlManager.h"
54 #include "FApp_AppArg.h"
55 #include "FApp_IAppImpl.h"
56 #include "FApp_AppResourceImpl.h"
58 using namespace Tizen::Base;
59 using namespace Tizen::Base::Collection;
60 using namespace Tizen::Base::Runtime;
61 using namespace Tizen::Io;
62 using namespace Tizen::System;
67 const int HEARTBEAT_WAIT_COUNT = 3;
68 const wchar_t SERVICE_APPID[] = L"aospd00043.osp-app-service";
69 const char SELECTOR_RESPONSE_KEY[] = "__APP_SVC_START_INFO__";
70 const wchar_t FILE_SCHEME_WITH_DELIMITER[] = L"file://";
71 #ifndef VCONFKEY_APPSERVICE_STATUS
72 #define VCONFKEY_APPSERVICE_STATUS "memory/appservice/status"
77 namespace Tizen { namespace App
80 _AppImpl* _AppImpl::__pAppImpl = null;
81 bool _AppImpl::__isTerminationRequested = false;
83 static const int _DATACONTROL_PACKET_INDEX_APPID = 0;
84 static const int _DATACONTROL_PACKET_INDEX_REQUESTTYPE = 1;
85 static const int _DATACONTROL_PACKET_INDEX_REQID = 2;
86 static const int _DATACONTROL_PACKET_INDEX_PROVIDERID = 3;
88 static const int _DATACONTROL_PACKET_INDEX_DATAID = 0;
89 static const int _DATACONTROL_PACKET_INDEX_COLUMNCOUNT = 1;
90 static const int _DATACONTROL_PACKET_INDEX_DELETEWHERE = 1;
91 static const int _DATACONTROL_PACKET_INDEX_MAPKEY = 1;
92 static const int _DATACONTROL_PACKET_INDEX_COLUMNLIST = 2;
93 static const int _DATACONTROL_PACKET_INDEX_INSERTMAP = 2;
94 static const int _DATACONTROL_PACKET_INDEX_UPDATEMAP = 2;
98 void operator()(char* pValue)
108 _AppImpl::_AppImpl(App* pApp)
109 : __pCheckpointEventListener(null)
110 , __pSqlDataControlProviderEventListener(null)
111 , __pMapDataControlProviderEventListener(null)
112 , __pAppControlProviderEventListener(null)
113 , __pAppControlProviderInternalEventListener(null)
114 , __pAppLaunchConditionEventListener(null)
117 , __pRequestHandler(&_AppImpl::HandleAppRequest)
118 , __pLegacyRequestHandler(&_AppImpl::HandleDummyAppRequest)
119 , __forcedTermination(false)
126 _AppImpl::Construct(const IList* pArgs)
128 SysTryReturnResult(NID_APP, pArgs != null, E_INVALID_ARG, "pArguments must not be null.");
129 SysAssertf(__pApp != null, "Getting App instance failed.");
131 result r = __appUserEvent.Construct();
132 SysTryLog(NID_APP, !IsFailed(r), "[%s] User event handler failure.", GetErrorMessage(r));
134 __appUserEvent.AddListener(*this);
136 _AppInfo::SetAppState(INITIALIZING);
143 _AppImpl::Execute(_IAppImpl* pIAppImpl)
145 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:start]", _AppInfo::GetAppExecutableName().GetPointer());
146 result r = E_SUCCESS;
147 int eflResult = APP_ERROR_NONE;
148 int argc = _AppInfo::GetArgc();
149 char** pArgv = _AppInfo::GetArgv();
150 _IAppManager* pAppManager = null;
152 _AppImpl* pAppImpl = _AppImpl::GetInstance();
153 SysTryReturnResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
154 pAppImpl->__pIAppImpl = pIAppImpl;
156 // handle legacy version handling
157 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
159 pAppImpl->SetLegacyRequestHandler();
162 app_event_callback_s state_handler;
163 memset(&state_handler, 0, sizeof(app_event_callback_s));
165 state_handler.create = &OnCreate;
166 state_handler.service = &OnService;
167 state_handler.terminate = &OnTerminate;
168 state_handler.pause = &OnPause;
169 state_handler.resume = &OnResume;
170 state_handler.device_orientation = NULL;
172 state_handler.low_memory = &OnLowMemory;
173 state_handler.low_battery = NULL;
174 state_handler.language_changed = &OnLanguageChanged;
175 state_handler.region_format_changed = NULL;
177 _Aul::SetPowerOffNotiListener(OnPowerOffNotiReceived, this);
178 // if (pAppManager != null)
180 // r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), _AppInfo::GetAppType() , _AppInfo::GetProcessId());
181 // SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Application registration failed.", GetErrorMessage(r));
184 eflResult = app_efl_main(&argc, &pArgv, &state_handler, this);
186 SysTryLog(NID_APP, eflResult == APP_ERROR_NONE, "app_efl_main failed with error (%d): Unknown", eflResult);
188 // clear outstanding ongoing notification
189 notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
192 pAppManager = _AppManagerProxy::GetService();
194 if (pAppManager != null)
196 pAppManager->UnregisterApplication(_AppInfo::GetProcessId());
204 _AppImpl::OnCreate(void* user_data)
206 SysLog(NID_APP, "Platform creation event.");
208 _AppImpl* pAppImpl = static_cast<_AppImpl*>(user_data);
209 if (pAppImpl == null)
211 _AppInfo::SetAppState(TERMINATED);
212 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Invalid platform state.");
216 _AppInfo::SetAppState(INITIALIZING);
218 if (!ConfirmAppService())
220 _AppInfo::SetAppState(TERMINATED);
221 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Osp AppService is not running.");
225 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:start]", _AppInfo::GetAppExecutableName().GetPointer());
226 if (!pAppImpl->__pIAppImpl->OnAppInitializing())
228 _AppInfo::SetAppState(TERMINATED);
229 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] The initialization of your application failed.");
232 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:done]", _AppInfo::GetAppExecutableName().GetPointer());
234 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:start]", _AppInfo::GetAppExecutableName().GetPointer());
235 _IAppManager* pAppManager = _AppManagerProxy::GetService();
237 if (pAppManager != null)
239 result r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), static_cast<_AppType>(_AppInfo::GetAppType()), _AppInfo::GetProcessId());
240 SysTryLog(NID_APP, !IsFailed(r), "[%s] Application registration failed.", GetErrorMessage(r));
242 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:done]", _AppInfo::GetAppExecutableName().GetPointer());
243 // hide splash window
245 _PowerManagerImpl::InitBatteryEvent();
252 _AppImpl::OnService(service_s* service, void* user_data)
254 _AppImpl* pAppImpl = _AppImpl::GetInstance();
255 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
256 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
258 // ugly code for app selector event handling
259 bundle* pBundle = _AppArg::GetBundleFromSvc(service);
262 const char* pValue = appsvc_get_data(pBundle, SELECTOR_RESPONSE_KEY);
265 const int req = _AppArg::GetRequestIdFromBundle(pBundle);
267 const char* pOperation = appsvc_get_operation(pBundle);
269 SysLog(NID_APP, "App selector response [%s, %s], req(%d).", pValue, pOperation, req);
271 //_AppArg::Print(pBundle);
272 _AppControlManager::GetInstance()->SendAppControlStartResponse(req, pValue, pOperation);
277 //_AppArg::Print(pBundle);
279 _AppHandler handler = _APP_HANDLER_NONE;
280 pAppImpl->RegisterAppRequest(service, req, handler);
282 bool initialLaunch = false;
285 // (1) AppControl / DataControl provider listener
286 // (2) OnAppInitialized()
287 // (3) OnResume() (OnForeground()) (UiApp only)
288 // (4) OnUserEventReceivedN()
291 // (1) AppControl / DataControl provider listener
292 // (2) OnResume() (OnForeground()) (UiApp only)
293 // (3) OnUserEventReceivedN()
295 if (_AppInfo::GetAppState() == INITIALIZING)
297 initialLaunch = true;
299 unsigned int winId = 0;
300 service_get_window(service, &winId);
303 _AppInfo::GetAppInfo()->SetParentWindowHandle(winId);
304 SysLog(NID_APP, "Saving window handle 0x%x.", winId);
306 // call for callbacks
307 // ptr to member function
308 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:start]", _AppInfo::GetAppExecutableName().GetPointer());
309 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
311 if (!pAppImpl->__pIAppImpl->OnAppInitialized())
313 _AppInfo::SetAppState(TERMINATING);
314 SysLog(NID_APP, "[E_INIT_FAILED] The Initialization of your application failed.");
318 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:done]", _AppInfo::GetAppExecutableName().GetPointer());
320 _AppInfo::SetAppState(RUNNING);
322 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:done]", _AppInfo::GetAppExecutableName().GetPointer());
328 // call for callbacks
329 // ptr to member function
330 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
332 std::unique_ptr<char[], charDeleter> pOperation(null);
335 int errVal = service_get_operation(service, &pBuf);
336 pOperation.reset(pBuf);
338 if((errVal == SERVICE_ERROR_NONE) && (!strcmp((const char*)pOperation.get(), "osp.operation.ALARM")))
340 std::unique_ptr<char[], charDeleter> pAlarmId(null);
343 errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pBuf);
344 pAlarmId.reset(pBuf);
345 SysTryReturnVoidResult(NID_SYS, errVal == SERVICE_ERROR_NONE, E_SYSTEM, "It is failed to get reserved alarm id.");
346 int alarmId = atoi((const char*)pAlarmId.get());
348 _AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
349 pAlarmManager->OnAlarmExpired(alarmId);
355 pAppImpl->__pIAppImpl->OnService(service, initialLaunch);
357 // ptr to member function
358 (pAppImpl->*pAppImpl->__pLegacyRequestHandler)(service, req, handler);
363 _AppImpl::OnTerminate(void* user_data)
365 SysLog(NID_APP, "Termination event 0x%x state", _AppInfo::GetAppState());
367 _AppImpl* pAppImpl = _AppImpl::GetInstance();
368 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
369 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
371 __isTerminationRequested = true;
372 pAppImpl->__pIAppImpl->OnTerminate();
377 _AppImpl::OnResume(void* user_data)
379 SysLog(NID_APP, "System resume event on 0x%x state", _AppInfo::GetAppState());
380 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:start]", _AppInfo::GetAppExecutableName().GetPointer());
382 _AppImpl* pAppImpl = _AppImpl::GetInstance();
383 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
384 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
385 pAppImpl->__pIAppImpl->OnResume();
386 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:done]", _AppInfo::GetAppExecutableName().GetPointer());
391 _AppImpl::OnPause(void* user_data)
393 SysLog(NID_APP, "System pause event on 0x%x state", _AppInfo::GetAppState());
394 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:start]", _AppInfo::GetAppExecutableName().GetPointer());
396 _AppImpl* pAppImpl = _AppImpl::GetInstance();
397 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
398 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
399 pAppImpl->__pIAppImpl->OnPause();
400 pAppImpl->OnAppCheckpoint();
401 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:done]", _AppInfo::GetAppExecutableName().GetPointer());
405 _AppImpl::~_AppImpl(void)
412 _AppImpl::GetInstance(void)
419 _AppImpl::GetAppInstance(void)
426 _AppImpl::GetAppArgumentListN(void) const
428 ArrayList* pList = null;
429 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
433 pList = pArg->GetArgListN(0);
438 pList = new (std::nothrow) ArrayList();
439 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
440 String* pData = new (std::nothrow) String(LEGACY_LAUNCH_REASON_NORMAL);
441 SysTryReturn(NID_APP, pData != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
442 String* pData2 = new (std::nothrow) String(L"osp.operation.MAIN");
443 SysTryReturn(NID_APP, pData2 != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
455 _AppImpl::Terminate(void)
457 result r = E_SUCCESS;
459 __isTerminationRequested = true;
467 _AppImpl::OnAppInitializing(void)
474 _AppImpl::OnAppWillTerminate(void)
476 SysTryReturn(NID_APP, __pApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
478 return __pApp->OnAppWillTerminate();
483 _AppImpl::RegisterAppRequest(service_s* service, int& req, _AppHandler& handler)
485 _AppControlManager* pManager = _AppControlManager::GetInstance();
486 SysTryReturnResult(NID_APP, pManager != null, E_SYSTEM, "Wrong system state.");
488 result r = pManager->RegisterRequest(service, req, handler);
489 SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
491 int providerType = _AppInfo::GetAppHandlerType();
492 providerType |= (_APP_HANDLER_LAUNCH_NORMAL | _APP_HANDLER_LAUNCH_COND);
494 SysTryLog(NID_APP, (handler & providerType) != 0, "Request 0x%x received for 0x%x.", handler,
495 _AppInfo::GetAppHandlerType());
501 _AppImpl::HandleAppRequest(service_s* service, int req, _AppHandler handler)
503 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(req);
504 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
510 case _APP_HANDLER_DATACONTROL:
511 SysLog(NID_APP, "Handling DataControl request");
513 OnDataControlRequestReceived(*pArg, static_cast< RequestId >(req));
515 //_AppControlManager::GetInstance()->RemoveResultRequest(req);
518 case _APP_HANDLER_LAUNCH_COND:
519 SysLog(NID_APP, "Handling conditional launch request");
521 OnConditionRequestReceived(*pArg, static_cast< RequestId >(req));
525 SysLog(NID_APP, "Handling AppControl request");
527 OnAppControlRequestReceived(*pArg, static_cast< RequestId >(req));
536 _AppImpl::HandleLegacyAppRequest(service_s* service, int req, _AppHandler handler)
538 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
539 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
545 case _APP_HANDLER_LAUNCH_NORMAL:
546 SysLog(NID_APP, "Handling normal launch request");
547 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req));
549 // [TODO] request handle memory cleanup confirm
550 _AppControlManager::GetInstance()->RemoveResultRequest(req);
553 case _APP_HANDLER_LAUNCH_COND:
554 SysLog(NID_APP, "Handling conditional launch request");
556 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req));
558 // [TODO] request handle memory cleanup confirm
559 _AppControlManager::GetInstance()->RemoveResultRequest(req);
571 _AppImpl::HandleDummyAppRequest(service_s* service, int req, _AppHandler handler)
573 SysLog(NID_APP, "Dummy handler");
580 _AppImpl::SetLegacyRequestHandler(void)
582 SysLog(NID_APP, "Setting request handler for legacy application.");
584 __pRequestHandler = &_AppImpl::HandleDummyAppRequest;
585 __pLegacyRequestHandler = &_AppImpl::HandleLegacyAppRequest;
592 _AppImpl::OnLowMemory(void* user_data)
594 _AppImpl* pAppImpl = _AppImpl::GetInstance();
596 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
597 SysTryReturnVoidResult(NID_APP, pAppImpl->__pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
599 if (_AppInfo::GetAppState() == RUNNING)
601 pAppImpl->__pApp->OnLowMemory();
607 _AppImpl::OnBatteryLevelChanged(BatteryLevel batteryLevel)
609 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
611 __pApp->OnBatteryLevelChanged(batteryLevel);
615 _AppImpl::OnLanguageChanged(void* user_data)
618 _AppInfo::UpdatePackageInfo(true);
620 _AppResourceImpl::Reinitialize();
621 SysLog(NID_APP, "Language change done.");
626 _AppImpl::SendUserEvent(RequestId requestId, const IList* pArgs)
628 _AppUserEventArg* pArg = new (std::nothrow) _AppUserEventArg(requestId, pArgs);
629 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "User event creation failure for %d.", requestId);
631 result r = __appUserEvent.FireAsync(*pArg);
638 _AppImpl::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
640 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
642 __pApp->OnUserEventReceivedN(requestId, pArgs);
647 _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
649 IAppControlProviderEventListener* pAppControlProviderEventListener = null;
651 const String internalOperation = arg.GetValue(OSP_K_APPCONTROL_INTERNAL_OPERATION);
652 if( !internalOperation.IsEmpty() )
654 SysLog(NID_APP, "internalOperation:%ls", internalOperation.GetPointer() );
655 pAppControlProviderEventListener = __pAppControlProviderInternalEventListener;
659 pAppControlProviderEventListener = __pAppControlProviderEventListener;
662 if( pAppControlProviderEventListener == null)
664 SysLog(NID_APP, "No AppControl provider event listener set for request %d.", reqId);
668 const String& appId = _AppInfo::GetApplicationId();
670 const char* p = appsvc_get_operation(arg.GetBundle());
671 String operationId = (p) ? String(p) : TIZEN_OPERATION_MAIN;
672 if (operationId == L"http://tizen.org/appcontrol/operation/default")
674 operationId = TIZEN_OPERATION_MAIN;
677 SysLog(NID_APP, "AppControl (%ls, %ls).", appId.GetPointer(), operationId.GetPointer());
681 const String* pUri = null;
682 const String* pMime = null;
683 p = appsvc_get_uri(arg.GetBundle());
689 // SLP deals with the URI as plain /opt/.../a.jpg.
690 uri.Insert(FILE_SCHEME_WITH_DELIMITER, 0);
694 SysLog(NID_APP, "Delivered uri is [%ls].", pUri->GetPointer());
697 p = appsvc_get_mime(arg.GetBundle());
704 std::unique_ptr<HashMap> pMap(arg.GetArgMapN());
706 pAppControlProviderEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
708 SysLog(NID_APP, "AppControl (%ls, %ls) invocation finished.", appId.GetPointer(), operationId.GetPointer());
713 _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
716 ISqlDataControlProviderEventListener* pSqlListener = null;
717 IMapDataControlProviderEventListener* pMapListener = null;
718 ArrayList* pColumnList = null;
719 HashMap* pInsertMap = null;
720 HashMap* pUpdateMap = null;
725 String* pDataId = null;
727 String* pColumnCount = null;
728 String* pColumn = null;
729 String* pValue = null;
730 String* pWhere = null;
731 String* pOrder = null;
732 String* pErrorMsg = null;
734 String* pCount = null;
735 String* pTmpPath = null;
736 String empty(L"NULL");
739 _DataControlRequestType requestType = _DATACONTROL_REQUEST_TYPE_UNDEFINED;
742 int countPerPage = 0;
745 result r = E_SUCCESS;
746 result res = E_SUCCESS;
747 ArrayList* pList = null;
749 String* pNewValue = null;
750 String* pOldValue = null;
752 SysLog(NID_APP, "[DC_PROV_RECV] Data control request is received.");
753 //arg.Print(); // request info
756 appId = arg.GetCallerAppId();
758 reqType = arg.GetValue(OSP_K_DATACONTROL_REQUEST_TYPE);
759 Integer::Parse(reqType, type);
760 requestType = static_cast< _DataControlRequestType >(type);
762 version = arg.GetValue(OSP_K_DATACONTROL_PROTOCOL_VERSION);
763 callerReqId = arg.GetValue(OSP_K_REQUEST_ID);
764 providerId = arg.GetValue(OSP_K_DATACONTROL_PROVIDER);
766 // list-based request
767 pList = _AppArg::GetListN(arg.GetBundle(), OSP_K_ARG);
768 SysTryCatch(NID_APP, pList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object");
770 pDataId = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DATAID));// request list[0]: data ID
771 SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
773 if (requestType >= _DATACONTROL_REQUEST_TYPE_SQL_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_SQL_DELETE)
775 pSqlListener = __pSqlDataControlProviderEventListener;
776 SysTryCatch(NID_APP, pSqlListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
778 else if (requestType >= _DATACONTROL_REQUEST_TYPE_MAP_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_MAP_DELETE)
780 pKey = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_MAPKEY)); // request list[1]
781 SysTryCatch(NID_APP, pKey, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
783 pMapListener = __pMapDataControlProviderEventListener;
784 SysTryCatch(NID_APP, pMapListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
788 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid request");
794 case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
795 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl SELECT");
797 // request list[1]: selected column count
798 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
799 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
801 if (pColumnCount->Equals(empty) == true)
807 Integer::Parse(*pColumnCount, columnCount);
808 pColumnList = new (std::nothrow) ArrayList();
809 SysTryReturnVoidResult(NID_APP, pColumnList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
810 pColumnList->Construct();
811 SysLog(NID_APP, "[DC_PROV_RECV] selected column count: %d", columnCount);
814 while (i < columnCount) // request list[2]: column list
816 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNLIST + i));
817 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
819 pColumnList->Add(*(new String(*pColumn)));
820 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", i, pColumn->GetPointer());
825 i += _DATACONTROL_PACKET_INDEX_COLUMNLIST;
826 pWhere = dynamic_cast< String* >(pList->GetAt(i)); // request list: where clause
827 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
829 if (pWhere->Equals(empty) == true)
835 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
839 pOrder = dynamic_cast< String* >(pList->GetAt(i)); // request list: order clause
840 SysTryCatch(NID_APP, pOrder, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
842 if (pOrder->Equals(empty) == true)
848 SysLog(NID_APP, "[DC_PROV_RECV] pOrder: %ls", pOrder->GetPointer());
852 pNo = dynamic_cast <String*>(pList->GetAt(i)); // request list: page number
853 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
854 Integer::Parse(*pNo, pageNo);
857 pCount = dynamic_cast <String*>(pList->GetAt(i)); // request list: count per page
858 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
859 Integer::Parse(*pCount, countPerPage);
861 pSqlListener->OnSqlDataControlSelectRequestReceived(reqId, providerId, *pDataId, pColumnList,
864 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",
865 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
866 pDataId->GetPointer(), pColumnList, pWhere, pOrder, pageNo, countPerPage);
868 case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
869 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl INSERT");
871 // request list[1]: inserted column count
872 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
873 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
875 Integer::Parse(*pColumnCount, columnCount);
876 SysLog(NID_APP, "[DC_PROV_RECV] inserted column count: %d", columnCount);
878 pInsertMap = new (std::nothrow) HashMap();
879 SysTryReturnVoidResult(NID_APP, pInsertMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
880 pInsertMap->Construct();
882 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
883 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
885 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
886 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
887 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
890 r = request.Construct(*pTmpPath, "r");
891 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
892 GetErrorMessage(r), pTmpPath->GetPointer());
894 for (i = 0; i < columnCount; ++i) // column-value pairs
897 int ret = request.Read(&length, sizeof(int));
898 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
899 GetErrorMessage(GetLastResult()));
901 char* pColumn = new (std::nothrow) char[length + 1];
902 ret = request.Read(pColumn, length);
903 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
904 GetErrorMessage(GetLastResult()));
905 pColumn[length] = '\0';
906 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
908 ret = request.Read(&length, sizeof(int));
909 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
910 GetErrorMessage(GetLastResult()));
912 char* pValue = new (std::nothrow) char[length + 1];
913 ret = request.Read(pValue, length);
916 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
920 pValue[length] = '\0';
921 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
923 pInsertMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
932 while (i < columnCount * 2) // request list: column-value pairs
934 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
935 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
936 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
938 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
939 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
940 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
942 pInsertMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
949 r = File::Remove(*pTmpPath);
950 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
953 pSqlListener->OnSqlDataControlInsertRequestReceived(reqId, providerId, *pDataId, *pInsertMap);
955 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pInsertMap: 0x%x",
956 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
957 pDataId->GetPointer(), pInsertMap);
959 case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
960 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl UPDATE");
962 // request list[1]: updated column count
963 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
964 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
966 Integer::Parse(*pColumnCount, columnCount);
967 SysLog(NID_APP, "[DC_PROV_RECV] updated column count: %d", columnCount);
969 pUpdateMap = new (std::nothrow) HashMap();
970 SysTryReturnVoidResult(NID_APP, pUpdateMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
971 pUpdateMap->Construct();
973 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
974 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
976 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
977 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
978 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
981 r = request.Construct(*pTmpPath, "r");
982 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
983 GetErrorMessage(r), pTmpPath->GetPointer());
985 for (i = 0; i < columnCount; ++i) // column-value pairs
988 int ret = request.Read(&length, sizeof(int));
989 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
990 GetErrorMessage(GetLastResult()));
992 char* pColumn = new (std::nothrow) char[length + 1];
993 ret = request.Read(pColumn, length);
994 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
995 GetErrorMessage(GetLastResult()));
996 pColumn[length] = '\0';
997 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
999 ret = request.Read(&length, sizeof(int));
1000 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1001 GetErrorMessage(GetLastResult()));
1003 char* pValue = new (std::nothrow) char[length + 1];
1004 ret = request.Read(pValue, length);
1007 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
1011 pValue[length] = '\0';
1012 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
1014 pUpdateMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
1019 // request list: where clause
1020 pWhere = dynamic_cast< String* >(pList->GetAt(3));
1021 SysTryCatch(NID_APP, pWhere != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
1027 while (i < columnCount * 2) // request list: column-value pairs
1029 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1030 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1031 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
1033 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1034 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1035 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
1037 pUpdateMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
1041 // request list: where clause
1042 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i));
1043 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1046 if (pWhere->Equals(empty) == true)
1052 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1057 r = File::Remove(*pTmpPath);
1058 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
1061 pSqlListener->OnSqlDataControlUpdateRequestReceived(reqId, providerId, *pDataId, *pUpdateMap, pWhere);
1063 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pUpdateMap: 0x%x, pWhere: 0x%x",
1064 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1065 pDataId->GetPointer(), pUpdateMap, pWhere);
1067 case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
1068 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl DELETE");
1070 // request list[1]: where clause
1071 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DELETEWHERE));
1072 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1074 if (pWhere->Equals(empty) == true)
1080 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1083 pSqlListener->OnSqlDataControlDeleteRequestReceived(reqId, providerId, *pDataId, pWhere);
1085 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pWhere: 0x%x",
1086 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1087 pDataId->GetPointer(), pWhere);
1089 case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
1090 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl GetValue");
1092 pNo = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1093 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1094 Integer::Parse(*pNo, pageNo);
1096 pCount = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1097 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1098 Integer::Parse(*pCount, countPerPage);
1100 pMapListener->OnMapDataControlGetValueRequestReceived(reqId, providerId, *pDataId, *pKey);
1102 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, pageNo: %d, countPerPage: %d",
1103 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1104 pDataId->GetPointer(), pKey->GetPointer(), pageNo, countPerPage);
1106 case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
1107 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl AddValue");
1109 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1110 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1112 pMapListener->OnMapDataControlAddValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1114 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1115 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1116 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1118 case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
1119 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl SetValue");
1121 pOldValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1122 SysTryCatch(NID_APP, pOldValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1124 pNewValue = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1125 SysTryCatch(NID_APP, pNewValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1127 pMapListener->OnMapDataControlSetValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pOldValue, *pNewValue);
1129 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, oldValue: %ls, newValue: %ls",
1130 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1131 pDataId->GetPointer(), pKey->GetPointer(), pOldValue->GetPointer(), pNewValue->GetPointer());
1133 case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
1134 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl RemoveValue");
1136 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1137 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1139 pMapListener->OnMapDataControlRemoveValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1141 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1142 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1143 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1146 SysTryCatch(NID_APP, false, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1152 pColumnList->RemoveAll(true);
1158 pInsertMap->RemoveAll(true);
1164 pUpdateMap->RemoveAll(true);
1173 pErrorMsg = new (std::nothrow) String("[E_SYSTEM] A system error has occurred.");
1175 else if (r == E_OUT_OF_MEMORY)
1177 pErrorMsg = new (std::nothrow) String("[E_OUT_OF_MEMORY] The memory was insufficient.");
1179 SysTryReturnVoidResult(NID_APP, pErrorMsg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient.");
1181 res = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, *pErrorMsg);
1185 pColumnList->RemoveAll(true);
1191 pInsertMap->RemoveAll(true);
1197 pUpdateMap->RemoveAll(true);
1208 _AppImpl::OnConditionRequestReceived(const _AppArg& arg, RequestId reqId)
1210 if (__pAppLaunchConditionEventListener == null)
1212 SysLog(NID_APP, "No App launch condition event listener");
1216 String condition = arg.GetValue(OSP_K_COND);
1217 //Object* pExtraData = null;//TODO: retrieve NFC extra data.
1218 HashMap* pExtraData = arg.GetArgMapN();
1219 ArrayList* pList = arg.GetArgListN();
1221 __pAppLaunchConditionEventListener->OnAppLaunchConditionMetN(condition, pExtraData, pList);
1226 _AppImpl::GetWindowHandle(void) const
1228 SysTryReturn(NID_APP, __pIAppImpl != null, -1, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1230 return __pIAppImpl->OnWindowHandleRequest();
1235 _AppImpl::RaiseWindow(void)
1237 SysTryReturnVoidResult(NID_APP, __pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1239 __pIAppImpl->OnFrameRaiseRequested();
1244 _AppImpl::OnAppCheckpoint(void)
1246 if (__pCheckpointEventListener)
1248 __pCheckpointEventListener->OnAppCheckpointing(*(AppRegistry::GetInstance()));
1254 _AppImpl::ConfirmAppService(void)
1256 if (_AppInfo::GetApplicationId() == SERVICE_APPID)
1263 long interval = 100;
1267 int res = vconf_get_int(VCONFKEY_APPSERVICE_STATUS, &value);
1273 if (count >= HEARTBEAT_WAIT_COUNT)
1278 SysLog(NID_APP, "Waiting for app service %dth time(%d msec).", count, interval);
1280 Thread::Sleep(interval);
1288 _AppImpl::SetListener(_AppEvent appEvent, IEventListener* pListener)
1293 SysTryReturnResult(NID_APP, __pCheckpointEventListener == null, E_OBJ_ALREADY_EXIST, "Checkpoint listener is already set.");
1296 case AE_CLEAR_LISTENER:
1297 __pCheckpointEventListener = dynamic_cast <IAppCheckpointEventListener*>(pListener);
1309 _AppImpl::SetSqlDataControlProviderEventListener(ISqlDataControlProviderEventListener* pListener)
1311 __pSqlDataControlProviderEventListener = pListener;
1312 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1313 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1314 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1320 _AppImpl::SetMapDataControlProviderEventListener(IMapDataControlProviderEventListener* pListener)
1322 __pMapDataControlProviderEventListener = pListener;
1323 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1324 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1325 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1331 _AppImpl::SetAppControlProviderEventListener(IAppControlProviderEventListener* pListener)
1333 __pAppControlProviderEventListener = pListener;
1334 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1335 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1336 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1341 _AppImpl::SetAppControlProviderInternalEventListener(IAppControlProviderEventListener* pListener)
1343 __pAppControlProviderInternalEventListener = pListener;
1344 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1345 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1346 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1352 _AppImpl::SetAppLaunchConditionEventListener(IAppLaunchConditionEventListener* pListener)
1354 __pAppLaunchConditionEventListener = pListener;
1355 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1356 tmpAppHandlerType |= _APP_HANDLER_LAUNCH_COND;
1357 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1364 _AppImpl::IsTerminationRequested(void)
1366 return __isTerminationRequested;
1370 _AppImpl::OnPowerOffNotiReceived(void* user_data)
1372 SysLog(NID_APP, "Application is being terminated by power off.");
1374 _AppImpl* pAppImpl = _AppImpl::GetInstance();
1375 if (pAppImpl != null)
1377 pAppImpl->__forcedTermination = true;
1384 _AppImpl::IsForcedTermination(void)
1386 return __forcedTermination;