FApp_AppControlResponseEvent.cpp
FApp_AppLifecycleEvent.cpp
FApp_ActiveWindowManager.cpp
+ FApp_RequestManagerT.cpp
)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SINGLETON_CLEANUP -fvisibility=hidden")
#include <appsvc/appsvc.h>
+#include <FBaseColHashMap.h>
+#include <FBaseSysLog.h>
#include <FAppAppControl.h>
#include <FAppAppManager.h>
#include <FAppPkgPackageAppInfo.h>
-#include <FBaseColHashMap.h>
-#include <FBaseSysLog.h>
+#include <FAppIAppControlEventListener.h>
+#include <FAppIAppControlResponseListener.h>
#include <FBaseRt_LibraryImpl.h>
#include <FIo_DirectoryImpl.h>
namespace Tizen { namespace App
{
-class IAppControlEventListener;
-class IAppControlResponseListener;
-
const wchar_t TIZEN_OPERATION_MAIN[] = L"http://tizen.org/appcontrol/operation/main";
_AppControlImpl::_AppControlImpl(const AppControl& value)
SysLog(NID_APP, "Exit.");
}
+void
+_AppControlManager::RemoveResultRequest(int reqId)
+{
+ __resultManager.RemoveItem(reqId);
+}
+
const _AppArg*
_AppControlManager::FindResultRequest(int reqId) const
{
AppControl*
-_AppControlRegistry::GetTizenAppControlN(const String& aId, const String& oId)
+_AppControlRegistry::GetTizenAppControlN(const String& aId, const String& oId) const
{
int count = 0;
const String* pAppId = &aId;
static _AppControlRegistry* GetInstance(void);
- AppControl* GetTizenAppControlN(const Tizen::Base::String& aId, const Tizen::Base::String& oId);
+ AppControl* GetTizenAppControlN(const Tizen::Base::String& aId, const Tizen::Base::String& oId) const;
AppControl* GetAppControlN(const Tizen::Base::String& appId, const Tizen::Base::String& operationId) const;
AliasMapType __aliasAppId;
- RuntimeAliasType __runtimeAlias;
+ mutable RuntimeAliasType __runtimeAlias;
static _AppControlRegistry* __pSelf;
}; // _AppControlRegistry
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FApp_RequestManagerT.cpp
+ * @brief This is the implementationfor the _RequestManagerT class.
+ */
+
+#include <limits.h>
+
+#include "FApp_RequestManagerT.h"
+#include "FApp_LaunchInfo.h"
+
+
+namespace Tizen { namespace App
+{
+
+template<typename T>
+_RequestManagerT<T>::_RequestManagerT(void)
+: __reqId(-1)
+{
+ __requestList.Construct();
+}
+
+template<typename T>
+_RequestManagerT<T>::~_RequestManagerT(void)
+{
+ RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+ if (pIter == null)
+ {
+ return;
+ }
+
+ while (pIter->MoveNext() == E_SUCCESS)
+ {
+ T* pInfo = null;
+ result r = pIter->GetValue(pInfo);
+
+ if (IsFailed(r))
+ {
+ continue;
+ }
+
+ delete pInfo;
+ }
+
+ delete pIter;
+}
+
+template<typename T> int
+_RequestManagerT<T>::InsertItem(T* pItem)
+{
+ SysTryReturn(NID_APP, pItem != null, -1, E_INVALID_ARG, "[E_INVALID_ARG] Empty argument.");
+
+#if 0
+ // [INFO] temporary disable due to OBS build system
+ __sync_add_and_fetch(&__reqId, 1);
+
+ // [TODO] awkward implementation after overflow
+ // overflow detection
+ __sync_bool_compare_and_swap(&__reqId, INT_MAX, 1);
+#else
+ __reqId++;
+ if (__reqId >= INT_MAX)
+ {
+ __reqId = 1;
+ }
+#endif
+ SysLog(NID_APP, "Current request ID : %d.", __reqId);
+
+ pItem->reqId = __reqId;
+ __requestList.Add(__reqId, pItem);
+
+ return __reqId;
+}
+
+template<typename T> void
+_RequestManagerT<T>::RemoveItem(int reqId)
+{
+ T* pItem = FindItem(reqId);
+ if (pItem)
+ {
+ __requestList.Remove(reqId);
+ delete pItem;
+ }
+}
+
+template<typename T> void
+_RequestManagerT<T>::RemoveItem(T* pItem)
+{
+ RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+ if (pItem == null || pIter == null)
+ {
+ return;
+ }
+
+ while (pIter->MoveNext() == E_SUCCESS)
+ {
+ T* pInfo = null;
+ result r = pIter->GetValue(pInfo);
+
+ if (pInfo == pItem)
+ {
+ int id = -1;
+ r = pIter->GetKey(id);
+ if (r == E_SUCCESS)
+ {
+ __requestList.Remove(id);
+ }
+
+ delete pItem;
+ delete pIter;
+
+ return;
+ }
+ }
+
+ delete pIter;
+}
+
+template<typename T> T*
+_RequestManagerT<T>::FindItem(int reqId) const
+{
+ T* pItem = null;
+ result r = __requestList.GetValue(reqId, pItem);
+
+ return (r == E_SUCCESS) ? pItem : null;
+}
+
+
+// partial specialization
+template<> void
+_RequestManagerT<_ResultInfo>::RemoveItem(int reqId)
+{
+ // 1st request is launch request itself and do not remove it ever.
+ if (reqId == 0)
+ {
+ return;
+ }
+
+ _ResultInfo* pItem = FindItem(reqId);
+ if (pItem)
+ {
+ __requestList.Remove(reqId);
+ delete pItem;
+ }
+}
+
+
+// explicit template initialization
+template class _RequestManagerT<_LaunchInfo>;
+template class _RequestManagerT<_InProcessInfo>;
+template class _RequestManagerT<_ResultInfo>;
+
+} } // Tizen::App
+
namespace Tizen { namespace App
{
-static const wchar_t* ALARM_PLUGIN_LIBRARY_PATH = L"/opt/apps/aospd00043/lib/libosp-cond-alarm.so";
+static const wchar_t* ALARM_PLUGIN_LIBRARY_PATH = L"/opt/usr/apps/aospd00043/lib/libosp-cond-alarm.so";
typedef void (*OnAlarmForLaunch)(int alarmId);
_ServiceAppImpl* _ServiceAppImpl::__pServiceAppImpl = null;
#include <FOspConfig.h>
#include <FBaseColArrayListT.h>
#include <FBaseObject.h>
-#include <FBaseString.h>
#include <FBaseRtIEventListener.h>
#include <FAppTypes.h>
-#include <FAppIAppControlEventListener.h>
-#include <FAppIAppControlResponseListener.h>
#include <FBaseSysLog.h>
#include "FApp_Types.h"
#include "FApp_IAppManagerServiceEventListener.h"
#include "FApp_RequestManagerT.h"
#include "FApp_IAppControlResponseEventListener.h"
+#include "FApp_LaunchInfo.h"
namespace Tizen { namespace Base
{
class String;
-namespace Runtime
-{
-class _LibraryImpl;
-}
namespace Collection
{
class IMap;
class _AppManagerEventArg;
class _AppMessageImpl;
class _AppControlResponseEvent;
-
-typedef result (*LaunchCbType)(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
+class IAppControlEventListener;
+class IAppControlResponseListener;
typedef void (*AppSvcResFn)(void* b, int requestCode, service_result_e res, void* data);
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// _LaunchInfo handles the launch request from this process
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-const long LAUNCH_INFO_MAGIC = 0x494C;
const int RESPONSE_EVENT_REQID_MAGIC = 65536;
-class _LaunchInfo
-{
-public:
- _LaunchInfo(_AppArg* pArg, LaunchCbType pCb, void* pData, int prop)
- : magic(LAUNCH_INFO_MAGIC)
- , reqId(-1)
- , pArg(pArg)
- , launchCb(pCb)
- , pUserData(pData)
- , property(prop)
- {
- }
-
- ~_LaunchInfo(void);
-
-private:
- _LaunchInfo(const _LaunchInfo& rhs);
- _LaunchInfo& operator =(const _LaunchInfo& rhs);
-
-public:
- const long magic;
- int reqId;
- _AppArg* pArg;
- const LaunchCbType launchCb;
- void* pUserData;
- int property;
-}; // _LaunchInfo
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// _InAppRequestManager manges In-process AppControl request
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-struct _InProcessInfo
-{
-public:
- _InProcessInfo(const Tizen::Base::String& aId, const Tizen::Base::String& oId, int prop, bool legacy, Tizen::Base::Runtime::_LibraryImpl& lib, Tizen::Base::Runtime::IEventListener* pListener)
- : reqId(-1)
- , providerId(aId)
- , operationId(oId)
- , property(prop)
- , pLib(&lib)
- , pListener(pListener)
- , isLegacy(legacy)
- {
- }
-
- ~_InProcessInfo(void);
-
-private:
- _InProcessInfo(const _InProcessInfo& rhs);
- _InProcessInfo& operator =(const _InProcessInfo& rhs);
-
-public:
- int reqId;
- const Tizen::Base::String providerId;
- const Tizen::Base::String operationId;
- const int property;
- Tizen::Base::Runtime::_LibraryImpl* pLib; // non-empty
- Tizen::Base::Runtime::IEventListener* pListener;
- bool isLegacy;
-}; // _InProcessInfo
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// _RequestManager manges out-of-process launch request and handles the return arguments
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-class _ResultInfo
-{
-public:
- _ResultInfo(_AppArg& arg)
- : reqId(-1)
- , arg(arg)
- {
- }
-
- ~_ResultInfo(void)
- {
- }
-
-private:
- _ResultInfo(const _ResultInfo& rhs);
- _ResultInfo& operator =(const _ResultInfo& rhs);
-
-public:
- int reqId;
- _AppArg& arg;
-}; // _ResultInfo
-
-// partial specialization
-template<> inline void _RequestManagerT<_ResultInfo>::RemoveItem(int reqId)
-{
- // 1st request is launch request itself and do not remove it ever.
- if (reqId == 0)
- {
- return;
- }
-
- _ResultInfo* pItem = FindItem(reqId);
- if (pItem)
- {
- __requestList.Remove(reqId);
- delete pItem;
- }
-}
-
class _OSP_EXPORT_ _AppControlManager
: public Tizen::Base::Object
_OSP_LOCAL_ result SendAppControlEvent(Tizen::Base::Runtime::IEventArg& arg);
_OSP_LOCAL_ Tizen::Base::Collection::IMapT<int,_AppControlResponseEvent*>* GetAppControlResponseEventContainer(void);
+
_OSP_LOCAL_ result RegisterRequest(service_s* service, int& req, _AppHandler& handler);
- _OSP_LOCAL_ void RemoveResultRequest(int reqId)
- {
- __resultManager.RemoveItem(reqId);
- }
+ _OSP_LOCAL_ void RemoveResultRequest(int reqId);
const _AppArg* FindResultRequest(int reqId) const;
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FApp_LaunchInfo.h
+ * @brief This is the header file for the _LaunchInfo class.
+ */
+
+#ifndef _FAPP_INTERNAL_LAUNCH_INFO_H_
+#define _FAPP_INTERNAL_LAUNCH_INFO_H_
+
+#include <app_service.h>
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FAppTypes.h>
+
+namespace Tizen { namespace Base
+{
+namespace Runtime
+{
+class _LibraryImpl;
+class IEventListener;
+}
+}}
+
+namespace Tizen { namespace App
+{
+
+class _AppArg;
+
+typedef result (*LaunchCbType)(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// _LaunchInfo handles the launch request from this process
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+const long LAUNCH_INFO_MAGIC = 0x494C;
+
+class _LaunchInfo
+{
+public:
+ _LaunchInfo(_AppArg* pArg, LaunchCbType pCb, void* pData, int prop)
+ : magic(LAUNCH_INFO_MAGIC)
+ , reqId(-1)
+ , pArg(pArg)
+ , launchCb(pCb)
+ , pUserData(pData)
+ , property(prop)
+ {
+ }
+
+ ~_LaunchInfo(void);
+
+private:
+ _LaunchInfo(const _LaunchInfo& rhs);
+ _LaunchInfo& operator =(const _LaunchInfo& rhs);
+
+public:
+ const long magic;
+ int reqId;
+ _AppArg* pArg;
+ const LaunchCbType launchCb;
+ void* pUserData;
+ int property;
+}; // _LaunchInfo
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// _InAppRequestManager manges In-process AppControl request
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+struct _InProcessInfo
+{
+public:
+ _InProcessInfo(const Tizen::Base::String& aId, const Tizen::Base::String& oId, int prop, bool legacy, Tizen::Base::Runtime::_LibraryImpl& lib, Tizen::Base::Runtime::IEventListener* pListener)
+ : reqId(-1)
+ , providerId(aId)
+ , operationId(oId)
+ , property(prop)
+ , pLib(&lib)
+ , pListener(pListener)
+ , isLegacy(legacy)
+ {
+ }
+
+ ~_InProcessInfo(void);
+
+private:
+ _InProcessInfo(const _InProcessInfo& rhs);
+ _InProcessInfo& operator =(const _InProcessInfo& rhs);
+
+public:
+ int reqId;
+ const Tizen::Base::String providerId;
+ const Tizen::Base::String operationId;
+ const int property;
+ Tizen::Base::Runtime::_LibraryImpl* pLib; // non-empty
+ Tizen::Base::Runtime::IEventListener* pListener;
+ bool isLegacy;
+}; // _InProcessInfo
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// _RequestManager manges out-of-process launch request and handles the return arguments
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+class _ResultInfo
+{
+public:
+ _ResultInfo(_AppArg& arg)
+ : reqId(-1)
+ , arg(arg)
+ {
+ }
+
+ ~_ResultInfo(void)
+ {
+ }
+
+private:
+ _ResultInfo(const _ResultInfo& rhs);
+ _ResultInfo& operator =(const _ResultInfo& rhs);
+
+public:
+ int reqId;
+ _AppArg& arg;
+}; // _ResultInfo
+
+
+}} // Tizen::App
+
+#endif // _FAPP_INTERNAL_LAUNCH_INFO_H_
#ifndef _FAPP_INTERNAL_REQUEST_MANAGERT_H_
#define _FAPP_INTERNAL_REQUEST_MANAGERT_H_
-#include <limits.h>
-
#include <FOspConfig.h>
#include <FBaseColHashMapT.h>
-
#include <FBaseSysLog.h>
-namespace Tizen { namespace Base
-{
-class String;
-}}
-
namespace Tizen { namespace App
{
typedef Tizen::Base::Collection::HashMapT<int, T*> RequestListType;
typedef Tizen::Base::Collection::IMapEnumeratorT<int, T*> RequestListEnumType;
- _RequestManagerT(void)
- : __reqId(-1)
- {
- __requestList.Construct();
- }
-
- ~_RequestManagerT(void)
- {
- RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
- if (pIter == null)
- {
- return;
- }
-
- while (pIter->MoveNext() == E_SUCCESS)
- {
- T* pInfo = null;
- result r = pIter->GetValue(pInfo);
-
- if (IsFailed(r))
- {
- continue;
- }
-
- delete pInfo;
- }
-
- delete pIter;
- }
-
- int InsertItem(T* pItem)
- {
- SysTryReturn(NID_APP, pItem != null, -1, E_INVALID_ARG, "[E_INVALID_ARG] Empty argument.");
-
-#if 0
- // [INFO] temporary disable due to OBS build system
- __sync_add_and_fetch(&__reqId, 1);
-
- // [TODO] awkward implementation after overflow
- // overflow detection
- __sync_bool_compare_and_swap(&__reqId, INT_MAX, 1);
-#else
- __reqId++;
- if (__reqId >= INT_MAX)
- {
- __reqId = 1;
- }
-#endif
- SysLog(NID_APP, "Current request ID : %d.", __reqId);
-
- pItem->reqId = __reqId;
- __requestList.Add(__reqId, pItem);
-
- return __reqId;
- }
-
- void RemoveItem(int reqId)
- {
- T* pItem = FindItem(reqId);
- if (pItem)
- {
- __requestList.Remove(reqId);
- delete pItem;
- }
- }
-
- void RemoveItem(T* pItem)
- {
- RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
- if (pItem == null || pIter == null)
- {
- return;
- }
-
- while (pIter->MoveNext() == E_SUCCESS)
- {
- T* pInfo = null;
- result r = pIter->GetValue(pInfo);
-
- if (pInfo == pItem)
- {
- int id = -1;
- r = pIter->GetKey(id);
- if (r == E_SUCCESS)
- {
- __requestList.Remove(id);
- }
-
- delete pItem;
- delete pIter;
-
- return;
- }
- }
-
- delete pIter;
- }
-
- T* FindItem(int reqId) const
- {
- T* pItem = null;
- result r = __requestList.GetValue(reqId, pItem);
-
- return (r == E_SUCCESS) ? pItem : null;
- }
+ _RequestManagerT(void);
+
+ ~_RequestManagerT(void);
+
+ int InsertItem(T* pItem);
+
+ void RemoveItem(int reqId);
+
+ void RemoveItem(T* pItem);
+
+ T* FindItem(int reqId) const;
private:
_RequestManagerT(const T& rhs);
RequestListType __requestList;
}; // _RequestManagerT
+
} } // Tizen::App
#endif // _FAPP_INTERNAL_REQUEST_MANAGERT_H_