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 FAppServiceApp.cpp
19 * @brief This is the implementation for the ServiceApp class.
22 #include <FAppServiceApp.h>
24 #include <FBaseResult.h>
26 #include <FBaseSysLog.h>
27 #include "FApp_AppImpl.h"
28 #include "FApp_ServiceAppImpl.h"
29 #include "FApp_AppInfo.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
34 namespace Tizen { namespace App
37 ServiceApp::ServiceApp(void)
39 __pServiceAppImpl = new (std::nothrow) _ServiceAppImpl(this);
40 SysAssertf(__pServiceAppImpl != null, "Allocating memory for ServiceApp instance failed.");
41 SysTryReturnVoidResult(NID_APP, __pServiceAppImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
45 ServiceApp::~ServiceApp(void)
47 delete __pServiceAppImpl;
52 ServiceApp::GetInstance(void)
54 _ServiceAppImpl* pServiceAppImpl = _ServiceAppImpl::GetInstance();
55 if (pServiceAppImpl == null)
60 return pServiceAppImpl->GetServiceAppInstance();
65 ServiceApp::Execute(ServiceAppInstanceFactory pServiceAppFactory, const IList* pArguments)
68 ServiceApp* pServiceApp = null;
69 _AppImpl* pAppImpl = null;
71 SysTryReturnResult(NID_APP, pServiceAppFactory != null, E_INVALID_ARG, "pServiceAppFactory must not be null.");
72 SysTryReturnResult(NID_APP, pArguments != null, E_INVALID_ARG, "pArguments must not be null.");
73 _AppInfo::SetAppType(_APP_TYPE_SERVICE_APP);
76 pServiceApp = pServiceAppFactory();
77 SysTryReturnResult(NID_APP, pServiceApp != null, E_OUT_OF_MEMORY, "App allocation failed.");
78 SysTryReturnResult(NID_APP, !IsFailed(GetLastResult()), E_OUT_OF_MEMORY, "App allocation failed.");
80 pAppImpl = _AppImpl::GetInstance();
81 SysTryReturnResult(NID_APP, pAppImpl != null, E_SYSTEM, "application instance is not available.");
83 _ServiceAppImpl* pServiceAppImpl = _ServiceAppImpl::GetInstance();
84 SysTryReturnResult(NID_APP, pServiceAppImpl != null, E_INVALID_STATE, "Getting UiApp instance failed.");
86 r = pAppImpl->Construct(pArguments);
87 SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] %s.", GetErrorMessage(r));
89 r = pAppImpl->Execute(pServiceAppImpl);
90 SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] %s.", GetErrorMessage(r));