2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FAppServiceApp.cpp
20 * @brief This is the implementation for the ServiceApp class.
23 #include <FAppServiceApp.h>
25 #include <FBaseResult.h>
27 #include <FBaseSysLog.h>
28 #include "FApp_AppImpl.h"
29 #include "FApp_ServiceAppImpl.h"
30 #include "FApp_AppInfo.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
35 namespace Tizen { namespace App
38 ServiceApp::ServiceApp(void)
40 __pServiceAppImpl = new (std::nothrow) _ServiceAppImpl(this);
41 SysAssertf(__pServiceAppImpl != null, "Allocating memory for ServiceApp instance failed.");
42 SysTryReturnVoidResult(NID_APP, __pServiceAppImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
46 ServiceApp::~ServiceApp(void)
48 delete __pServiceAppImpl;
53 ServiceApp::GetInstance(void)
55 _ServiceAppImpl* pServiceAppImpl = _ServiceAppImpl::GetInstance();
56 if (pServiceAppImpl == null)
61 return pServiceAppImpl->GetServiceAppInstance();
66 ServiceApp::Execute(ServiceAppInstanceFactory pServiceAppFactory, const IList* pArguments)
69 ServiceApp* pServiceApp = null;
70 _AppImpl* pAppImpl = null;
72 SysTryReturnResult(NID_APP, pServiceAppFactory != null, E_INVALID_ARG, "pServiceAppFactory must not be null.");
73 SysTryReturnResult(NID_APP, pArguments != null, E_INVALID_ARG, "pArguments must not be null.");
74 _AppInfo::SetAppType(_APP_TYPE_SERVICE_APP);
77 pServiceApp = pServiceAppFactory();
78 SysTryReturnResult(NID_APP, pServiceApp != null, E_OUT_OF_MEMORY, "App allocation failed.");
79 SysTryReturnResult(NID_APP, !IsFailed(GetLastResult()), E_OUT_OF_MEMORY, "App allocation failed.");
81 pAppImpl = _AppImpl::GetInstance();
82 SysTryReturnResult(NID_APP, pAppImpl != null, E_SYSTEM, "application instance is not available.");
84 _ServiceAppImpl* pServiceAppImpl = _ServiceAppImpl::GetInstance();
85 SysTryReturnResult(NID_APP, pServiceAppImpl != null, E_INVALID_STATE, "Getting UiApp instance failed.");
87 r = pAppImpl->Construct(pArguments);
88 SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] %s.", GetErrorMessage(r));
90 r = pAppImpl->Execute(pServiceAppImpl);
91 SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] %s.", GetErrorMessage(r));