#include "FAppPkg_PackageManagerImpl.h"
#include "FApp_AppManagerImpl.h"
#include "FApp_TemplateUtil.h"
+#include "FApp_IAppEventListener.h"
using namespace Tizen::App::Package;
using namespace Tizen::Base;
const wchar_t USE_UI_KEY[] = L"UseUi";
const wchar_t USE_UI_VAL_TRUE[] = L"True";
+const wchar_t LIFE_DURATION_KEY[] = L"LifeDuration";
+const int LIFE_DURATION_MSEC_MAX = 30000;
static const RequestId HANDLER_REQUEST_ALARMID = 2;
_ServiceAppImpl::_ServiceAppImpl(ServiceApp* pServiceApp)
: __pAppImpl(_AppImpl::GetInstance())
, __pServiceApp(pServiceApp)
+ , __pLifeDurationEventListener(null)
+ , __pLifeDurationTimer(null)
+ , __lifeDuration(0)
{
__pServiceAppImpl = this;
SysTryReturnVoidResult(NID_APP, __pAppImpl, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
_ServiceAppImpl::~_ServiceAppImpl(void)
{
__pServiceAppImpl = null;
+ if( __pLifeDurationTimer )
+ {
+ __pLifeDurationTimer->Cancel();
+ delete __pLifeDurationTimer;
+ }
}
{
free(pOperation);
}
+
+ if( __lifeDuration > 0)
+ {
+ SetLifeDurationTimer(__lifeDuration);
+ }
}
void
}
}
+ r = pInfo->GetValue(LIFE_DURATION_KEY, pFeature);
+ if (r == E_SUCCESS)
+ {
+ const String& val = pFeature->GetValue();
+ r = Integer::Parse(val, __lifeDuration);
+ if( r == E_SUCCESS )
+ {
+ __lifeDuration = ( __lifeDuration > LIFE_DURATION_MSEC_MAX ) ? LIFE_DURATION_MSEC_MAX : __lifeDuration;
+ SysLog(NID_APP, "LifeDuration is (%d)", __lifeDuration);
+ }
+ }
+
_DeleteCollectionMapValue<String, _AppFeatureInfoImpl>(*pInfo);
delete pInfo;
}
return __pServiceApp->OnAppTerminating(*(AppRegistry::GetInstance()), forcedTermination);
}
+void
+_ServiceAppImpl::SetLifeDurationTimer(int lifeDuration)
+{
+ if( lifeDuration <= 0)
+ {
+ return;
+ }
+
+ if( __pLifeDurationTimer == null)
+ {
+ __pLifeDurationTimer = new Timer;
+ __pLifeDurationTimer->Construct(*this);
+ SysLog(NID_APP, "Life duration timer is constructed.");
+ }
+ else
+ {
+ __pLifeDurationTimer->Cancel();
+ SysLog(NID_APP, "Life duration timer is cancelled.", lifeDuration );
+ }
+ __pLifeDurationTimer->Start(__lifeDuration);
+ SysLog(NID_APP, "Life duration timer is started with timeout.(%d)", lifeDuration );
+}
+
+void
+_ServiceAppImpl::OnTimerExpired(Timer& timer)
+{
+ SysLog(NID_APP, "Life duration timer is expired, so terminating the application.");
+ timer.Cancel();
+ if( __pLifeDurationEventListener)
+ {
+ __pLifeDurationEventListener->OnApplicationTerminated(L"", 0);
+ }
+ App::GetInstance()->Terminate();
+}
+
+void
+_ServiceAppImpl::SetLifeDurationEventListener(_IAppEventListener* pListener)
+{
+ __pLifeDurationEventListener = pListener;
+}
+
} } //Tizen::App
#include <app.h>
#include <FAppServiceApp.h>
-
+#include <FBaseRtIEventListener.h>
+#include <FBaseRtITimerEventListener.h>
#include "FApp_IAppImpl.h"
namespace Tizen { namespace Base { namespace Collection { class IList; } } }
-namespace Tizen { namespace Base { namespace Runtime { class _EventDispatcher; } } }
+namespace Tizen { namespace Base { namespace Runtime
+{
+class Timer;
+class IEventListener;
+class _EventDispatcher;
+}}}
+
namespace Tizen { namespace App
{
+class _IAppEventListener;
+
/**
* @class _ServiceAppImpl
* @brief This class is the Impl class of a ServiceApp class.
class _OSP_EXPORT_ _ServiceAppImpl
: public Tizen::Base::Object
, public Tizen::App::_IAppImpl
+ , public Tizen::Base::Runtime::ITimerEventListener
+ , virtual public Tizen::Base::Runtime::IEventListener
{
public:
/**
*/
result Execute(void);
+
+ void SetLifeDurationEventListener(_IAppEventListener* pListener);
+
private:
/**
* This is the default constructor for this class.
*/
virtual ~_ServiceAppImpl(void);
+ virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+
+ void SetLifeDurationTimer(int lifeDuration);
+
+
private:
static _ServiceAppImpl* __pServiceAppImpl;
ServiceApp* __pServiceApp;
+ _IAppEventListener* __pLifeDurationEventListener;
+
+ Tizen::Base::Runtime::Timer* __pLifeDurationTimer;
+
+ int __lifeDuration;
+
friend class ServiceApp;
}; // _ServiceAppImpl