sync with tizen_2.0
[platform/framework/native/appfw.git] / src / app / inc / FApp_AppLaunchConditionHandlerBase.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file         FApp_AppLaunchConditionHandlerBase.h
20  * @brief       This is the header file of the _AppLaunchConditionHandlerBase class.
21  *
22  * This header file contains the declarations of the _AppLaunchConditionHandlerBase class.
23  */
24 #ifndef _FAPP_INTERNAL_APP_LAUNCH_CONDITION_HANDLER_BASE_H_
25 #define _FAPP_INTERNAL_APP_LAUNCH_CONDITION_HANDLER_BASE_H_
26
27 #include <FBaseObject.h>
28 #include <FAppTypes.h>
29
30 #include <FBaseSysLog.h>
31 #include "FApp_IAppLaunchConditionEventListener.h"
32 #include "FApp_AppLaunchCondition.h"
33
34 namespace Tizen { namespace App {
35
36
37 /**
38  * @class               _AppLaunchConditionHandlerBase
39  * @brief               This class is the abstract base class of all conditional app launch handlers(plugin).
40  * @since 2.1
41  *
42  * All conditional app launch handlers(plugin) should inherit this abstract class.
43  * and all plugins must provide both a creation and a destruction function like following.
44  *
45  * @code
46  *      extern "C" _AppLaunchConditionHandlerBase* CreatePlugin()
47  *      {
48  *              return new (std::nothrow) _AlarmConditionHandler;// create and return your own class instance.
49  *      }
50  *
51  *      extern "C" void DestroyPlugin(_AppLaunchConditionHandlerBase* p)
52  *      {
53  *              delete p;
54  *      }
55  * @endcode
56  */
57 class _OSP_EXPORT_ _AppLaunchConditionHandlerBase
58         : public Tizen::Base::Object
59 {
60 public:
61         /**
62          * This is the constructor for this class.
63          *
64          * @since 2.1
65          */
66         _AppLaunchConditionHandlerBase(void);
67
68         /**
69          * This is the destructor for this class.
70          *
71          * @since 2.1
72          */
73         virtual ~_AppLaunchConditionHandlerBase(void);
74
75         /**
76          * Sets event listener instance. @n
77          * The listener can listen to OnAppLaunchConditionMet event.
78          *
79          * @since 2.1
80          * @param[in]   The operation   registered conditional operation with current condition.
81          * @remark              _ConditionManagerService uses this function to sets itself as listener.
82          */
83         result SetEventListener(_IAppLaunchConditionEventListener& eventListener);
84
85         /**
86          * Register app launch condition for the plug-in.
87          *
88          * @since 2.1
89          * @return              An error code
90          * @param[in]   operation               The conditional operation to register
91          * @exception   E_SUCCESS                       The method is successful.
92          * @exception   E_INVALID_FORMAT                The specified condition format is invalid.
93          * @exception   E_INVALID_CONDITION  The specified condition format is valid but the condition has at least one or more invalid values.
94          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
95          * @exception   E_SYSTEM                                A system error has occurred.
96          * @remark              Plugin should implement this register condition code
97          *                              _ConditionManagerService calls this method when RegisterAppLaunch method invoked.
98          * @see Unregister()
99          */
100         virtual result Register( _AppLaunchCondition& condition) = 0;//, const Tizen::Base::Object*& pHandle) = 0;
101
102         /**
103          * Unregister app launch condition for the plug-in.
104          *
105          * @since 2.1
106          * @param[in]   operation               The conditional operation to register
107          * @remark              Plugin should implement this unregister condition code
108          *                              _ConditionManagerService calls this method when UnregisterAppLaunch method invoked.
109          * @see Register()
110          */
111         virtual result Unregister( _AppLaunchCondition& condition) = 0;//, const Tizen::Base::Object* pHandle) = 0;
112
113
114 protected:
115         /**
116          * Fires the OnAppLaunchConditionMet event.
117          *
118          * @since 2.1
119          * @return      An error code
120          * @exception   E_SUCCESS                       The method is successful.
121          * @exception   E_INVALID_STATE         The event handler isn't initialized yet.
122          * @param[in]   operation               The conditional operation registered.
123          * @see _IAppLaunchConditionEventListener::OnAppLaunchConditionMet
124          */
125         result Fire(const _AppLaunchCondition& condition);
126
127 private:
128         _IAppLaunchConditionEventListener* __pEventListener;
129 };              //_AppLaunchConditionHandlerBase
130
131 }}//Tizen::App
132
133 #endif // _FAPP_INTERNAL_APP_LAUNCH_CONDITION_HANDLER_BASE_H_