Merge from tizen_2.2.1
[platform/framework/native/appfw.git] / src / app / inc / FApp_AppControlImpl.h
index b7d7dd3..4996ccf 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
 #ifndef _FAPP_INTERNAL_APP_CONTROL_IMPL_H_
 #define _FAPP_INTERNAL_APP_CONTROL_IMPL_H_
 
-#include <app_service.h>
-#include <bundle.h>
-
 #include <FBaseObject.h>
 #include <FAppTypes.h>
 #include <FOspConfig.h>
 #include <FAppAppControl.h>
+#include <FBaseColArrayListT.h>
+
+#include <FBaseRt_LibraryImpl.h>
 
 #include "FApp_AppManagerImpl.h"
+#include "FApp_IAppControlResponseEventListener.h"
+
+typedef struct _bundle_t bundle;
+
 
 namespace Tizen { namespace Base { class String; } }
 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
+namespace Tizen { namespace Base { namespace Runtime { class IEventListener; } } }
 
 namespace Tizen { namespace App
 {
@@ -42,73 +46,69 @@ namespace Tizen { namespace App
 class AppControl;
 class IAppControlEventListener;
 class IAppControlResponseListener;
-class _AppArg;
+class _IAppControlPluginProvider;
+class _AppMessageImpl;
 
 enum _AppControlProperty
 {
        _APPCONTROL_PROPERTY_NONE = 0x0,
        _APPCONTROL_PROPERTY_PUBLIC = 0x01,
-       _APPCONTROL_PROPERTY_PERSISTENT_DLL = 0x08,
-       _APPCONTROL_PROPERTY_SLP = 0x100,
-       _APPCONTROL_PROPERTY_OSP = 0x200,
-       _APPCONTROL_PROPERTY_ALIAS = 0x400,
-       _APPCONTROL_PROPERTY_APPID_CHANGE = 0x800,
+       _APPCONTROL_PROPERTY_SUBMODE = 0x1000,
+       _APPCONTROL_PROPERTY_SERVICE_CALLEE = 0x2000,
 };
 
-class _OSP_EXPORT_ _AppControlImpl
+class _OSP_LOCAL_ _AppControlImpl
        : public Tizen::Base::Object
+       , public Tizen::App::_IAppControlResponseEventListener
+       , virtual public Tizen::Base::Runtime::IEventListener
 {
 public:
        /**
         * AppControl delegate constructor
         */
-       static AppControl* CreateN(const Tizen::Base::String& path, const Tizen::Base::String& aId, const Tizen::Base::String& oId, const Tizen::Base::String& name, int prop);
-
-       /**
-        * AppControl delegate constructor
-        */
-       static AppControl* CreateN(const AppId& appId, const Tizen::Base::String& operationId, bool changeAppId);
-
-       /**
-        * AppControl delegate constructor
-        */
-       static AppControl* CreateN(const AppControl& ac);
+       static AppControl* CreateN(const Tizen::Base::String& path, const Tizen::Base::String& aId, const Tizen::Base::String& oId, int prop);
 
        /**
         * Internal GetImpl() method.
         */
-       static const _AppControlImpl* GetInstance(const AppControl& ac);
+       static const _AppControlImpl* GetInstance(const AppControl& ac)
+       {
+               return ac.__pAppControlImpl;
+       }
 
        /**
         * Internal GetImpl() method.
         */
-       static _AppControlImpl* GetInstance(AppControl& ac);
+       static _AppControlImpl* GetInstance(AppControl& ac)
+       {
+               return ac.__pAppControlImpl;
+       }
 
        /**
-       * Starts the resolved application control. @n
-       * Once the application starts, it goes to the background and the target
-       * application control is displayed.
-       *
-       * @return               An error code
-       * @param[in]    pDataList       The data list to deliver to the resolved application control @n
-                                                             The maximum size of the list is 4096 bytes.
-       * @param[in]    pListener       The application control callback listener @n
-                                                             Some application controls need to get the callback result by implementing
-                                                             the IAppControlEventListener interface.
-       * @exception    E_SUCCESS                               The method is successful.
-       * @exception    E_MAX_EXCEEDED                  The size of @c pDataList has exceeded the maximum limit.
-       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
-       * @exception    E_OBJ_NOT_FOUND                 The target application control resource is not found.
-       * @exception    E_IN_PROGRESS                   The application control is in progress: @n
-       *                                       - The application has already started an _AppControlImpl. @n
-       *                                       - The target application has already started.
-       * @exception    E_SYSTEM                                A system error has occurred.
-       * @remarks              If the %IAppControlEventListener instance (@c pListener) needs to get the
-       *               callback result for an application control, it should be valid till
-       *               IAppControlEventListener::OnAppControlCompleted() is invoked.
-       *               For example, a form object listener should not be deleted before the
-       *               system invokes IAppControlEventListener::OnAppControlCompleted().
-       */
+        * Starts the resolved application control. @n
+        * Once the application starts, it goes to the background and the target
+        * application control is displayed.
+        *
+        * @return              An error code
+        * @param[in]   pDataList       The data list to deliver to the resolved application control @n
+        *                                                      The maximum size of the list is 4096 bytes.
+        * @param[in]   pListener       The application control callback listener @n
+        *                                                      Some application controls need to get the callback result by implementing
+        *                                                      the IAppControlEventListener interface.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_MAX_EXCEEDED                  The size of @c pDataList has exceeded the maximum limit.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_OBJ_NOT_FOUND                 The target application control resource is not found.
+        * @exception   E_IN_PROGRESS                   The application control is in progress: @n
+        *                                       - The application has already started an _AppControlImpl. @n
+        *                                       - The target application has already started.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             If the %IAppControlEventListener instance (@c pListener) needs to get the
+        *               callback result for an application control, it should be valid till
+        *               IAppControlEventListener::OnAppControlCompleted() is invoked.
+        *               For example, a form object listener should not be deleted before the
+        *               system invokes IAppControlEventListener::OnAppControlCompleted().
+        */
        result Start(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
 
        /**
@@ -142,28 +142,37 @@ public:
         *
         * @return              The name of the application providing this %_AppControlImpl instance
         */
-       Tizen::Base::String GetAppName(void);
+       Tizen::Base::String GetAppName(void) const;
 
        /**
         * Gets the associated application ID. @n
         *
         * @return              The application control ID
         */
-       Tizen::Base::String GetAppId(void) const;
+       Tizen::Base::String GetAppId(void) const
+       {
+               return _appId;
+       }
 
        /**
         * Gets the associated application control provider ID. @n
         *
         * @return              The application control provider ID
         */
-       const Tizen::Base::String& GetAppControlProviderId(void) const;
+       Tizen::Base::String GetAppControlProviderId(void) const
+       {
+               return _appId;
+       }
 
        /**
         * Gets the associated operation ID. @n
         *
         * @return              The operation ID
         */
-       const Tizen::Base::String& GetOperationId(void) const;
+       Tizen::Base::String GetOperationId(void) const
+       {
+               return _opId;
+       }
 
        /**
         * Returns the associated application control categories.
@@ -209,7 +218,7 @@ public:
         * @exception  E_SYSTEM                              The method cannot proceed due to a severe system error.
         * @see IAppControlResponseListener, IAppControlProviderEventListener
         */
-       static result FindAndStart(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriPattern, const Tizen::Base::String* pDataType, const Tizen::Base::String* pCategory, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
+       _OSP_EXPORT_ static result FindAndStart(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriPattern, const Tizen::Base::String* pDataType, const Tizen::Base::String* pCategory, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
 
        /**
         * Stops the event listener for receiving application control result.
@@ -222,6 +231,8 @@ public:
 
        static result StartImplicit(bundle* pBundle, const Tizen::Base::Collection::IMap* pData, IAppControlResponseListener* pListener);
 
+       static result StartImplicit(const _AppMessageImpl& msg, Tizen::Base::Runtime::IEventListener* pListener, bool isLegacy);
+
        bool IsPublic(void) const
        {
                return (_property & _APPCONTROL_PROPERTY_PUBLIC);
@@ -232,8 +243,9 @@ public:
                _property |= prop;
        }
 
+       virtual void OnAppControlResponseEventReceivedN(const Tizen::Base::Runtime::IEventArg* arg);
 private:
-       _AppControlImpl(const AppControl& value);
+       explicit _AppControlImpl(const AppControl& value);
 
        /**
         * This is the default constructor for this class.
@@ -249,35 +261,31 @@ private:
         */
        virtual ~_AppControlImpl(void);
 
-       result StartOsp(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
-
-       result StartOsp(const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
-
-       result StartNative(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
-
-       result StartNative(const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
+       static _IAppControlPluginProvider* GetAppControlPluginProvider(const Tizen::Base::String& path);
 
-       static result InvokeStartAppControl(Tizen::Base::Runtime::_LibraryImpl& lib, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pMap);
+       static result InvokeStartAppControl(_IAppControlPluginProvider* pProvider, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pMap);
 
-       static result InvokeStartAppControl(Tizen::Base::Runtime::_LibraryImpl& lib, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::Collection::IList* pList);
+       static result InvokeStartAppControl(_IAppControlPluginProvider* pProvider, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::Collection::IList* pList);
 
-       static result AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop);
-
-       static result AppControlCb(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop);
+       static result InvokeStartAppControl(_IAppControlPluginProvider* pProvider, int req, const Tizen::Base::String& appId, const _AppMessageImpl& message);
 
 protected:
+       static const unsigned long _LIBRARY_OPTION = Tizen::Base::Runtime::_LIBRARY_LOAD_OPTION_LAZY | Tizen::Base::Runtime::_LIBRARY_LOAD_OPTION_NODELETE;
+
        const AppControl& _appControl;
 
        Tizen::Base::String _path;
-       Tizen::Base::String _provider;
+       Tizen::Base::String _appId;
        Tizen::Base::String _opId;
-       Tizen::Base::String _appName;
+       mutable Tizen::Base::String _appName;
        int     _reqId;
        int     _property;
        int _processId;
 
+private:
+       Tizen::Base::Collection::ArrayListT<int> __appControlResponseEventList;
+
        friend class AppControl;
-       friend class _AppArg;
 }; // _AppControlImpl
 
 } } // Tizen::App