Home | History | Annotate | Download | only in native
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef __DMTEVENT_H__
     18 #define __DMTEVENT_H__
     19 
     20 #ifndef __cplusplus
     21 #error "This is a C++ header file; it requires C++ to compile."
     22 #endif
     23 
     24 /**
     25   \file dmtEvent.hpp
     26   \brief The dmtEvent.hpp header file contains DmtEventSubscription class  definition. \n
     27        This class represents a subscription on DMT update event.
     28 */
     29 
     30 #include "dmtDefs.h"
     31 #include "dmstring.h"
     32 #include "dmvector.h"
     33 #include "dmtPrincipal.hpp"
     34 
     35 /**Topic of DM event about start of server session */
     36 #define DMT_EVENT_OTA_SESSION_STARTED  "/motorola/dmt/ota/sessionstart"
     37 /**Topic of DM event about finish of server session */
     38 #define DMT_EVENT_OTA_SESSION_FINISHED "/motorola/dmt/ota/sessionend"
     39 /**Topic prefix of DM event about updates in the Screen3 sub tree */
     40 #define DMT_UPDATE_S3_PREFIX  "/motorola/dmt/S3/"
     41 /**Topic prefix of generic of DM update event */
     42 #define DMT_UPDATE_GENERIC_PREFIX  "/motorola/dmt/update/"
     43 
     44 /**Generic name for OTA principals */
     45 #define DM_SERVER_PRINCIPAL "OTA"
     46 
     47 
     48 
     49 /**
     50 * DmtEventSubscription represents subscription on DMT update event.
     51 * \par Category: General
     52 * \par Persistence: Transient
     53 * \par Security: Non-Secure
     54 * \par Migration State: FINAL
     55 */
     56 class DmtEventSubscription {
     57 
     58 public:
     59 
     60   /**
     61     * Default Constructor - no memory allocation performed.
     62     */
     63   DmtEventSubscription()
     64   {
     65     m_eAction = SYNCML_DM_EVENT_NONE;
     66     m_nType = SYNCML_DM_EVENT_NODE;
     67   }
     68 
     69 
     70    /**
     71   * Sets up subscription.
     72   * \par Sync (or) Async:
     73   * This is a Synchronous function.
     74   * \par Secure (or) Non-Secure (or) N/A:
     75   * This is a Non-Secure function.
     76   * \param eAction [in] - actions to track, Bit-wised
     77   * \param nType [in] - event type
     78   * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
     79   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
     80   * - All other codes indicate failure. The description can be found in dmtError.h
     81   * \par Prospective Clients:
     82   * All potential applications that require configuration settings and Internal Classes.
     83   */
     84 
     85   SYNCML_DM_RET_STATUS_T Set(SYNCML_DM_EVENT_ACTION_T eAction,
     86                                                 SYNCML_DM_EVENT_TYPE_T nType);
     87 
     88 
     89   /**
     90   * Sets up subscription.
     91   * \par Sync (or) Async:
     92   * This is a Synchronous function.
     93   * \par Secure (or) Non-Secure (or) N/A:
     94   * This is a Non-Secure function.
     95   * \param eAction [in] - actions to track, Bit-wised
     96   * \param nType [in] - event type
     97   * \param szTopic [in] - event topic suffix ( may be NULL )
     98   * \param aIgnorePrincipals [in] - vector of principals, which initiated updates are to be ignored
     99   * \param aNotifyPrincipals [in] - vector of principals, which initiated updates are to be processed
    100   * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
    101   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
    102   * - All other codes indicate failure. The description can be found in dmtError.h
    103   * \par Prospective Clients:
    104   * All potential applications that require configuration settings and Internal Classes.
    105   */
    106 
    107   SYNCML_DM_RET_STATUS_T Set(SYNCML_DM_EVENT_ACTION_T eAction,
    108                                                  SYNCML_DM_EVENT_TYPE_T nType,
    109                                                  CPCHAR szTopic,
    110                                                  const DMVector<DmtPrincipal> & aIgnorePrincipals,
    111                                                  const DMVector<DmtPrincipal> & aNotifyPrincipals);
    112 
    113    /**
    114   * Sets up topic suffix for DMT update event.
    115   * \par Sync (or) Async:
    116   * This is a Synchronous function.
    117   * \par Secure (or) Non-Secure (or) N/A:
    118   * This is a Non-Secure function.
    119   * \param szTopic [in] - event topic suffix
    120   * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
    121   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
    122   * - All other codes indicate failure. The description can be found in dmtError.h
    123   * \par Prospective Clients:
    124   * All potential applications that require configuration settings and Internal Classes.
    125   */
    126   SYNCML_DM_RET_STATUS_T SetTopic(CPCHAR szTopic);
    127 
    128   /**
    129   * Adds principal into internal vector.
    130   * \par Sync (or) Async:
    131   * This is a Synchronous function.
    132   * \par Secure (or) Non-Secure (or) N/A:
    133   * This is a Non-Secure function.
    134   * \param oPrincipal [in] - principal
    135   * \param bIsIgnore [in] - specifies type of principal \n
    136   *   - TRUE - principal to ignore \n
    137   *   - FALSE - principal to process updates
    138   * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
    139   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
    140   * - All other codes indicate failure. The description can be found in dmtError.h
    141   * \par Prospective Clients:
    142   * All potential applications that require configuration settings and Internal Classes.
    143   */
    144 
    145   SYNCML_DM_RET_STATUS_T AddPrincipal(const DmtPrincipal & oPrincipal, BOOLEAN bIsIgnore);
    146 
    147    /**
    148   * Retrieves operations (actions) to be tracked on node.
    149   * \par Sync (or) Async:
    150   * This is a Synchronous function.
    151   * \par Secure (or) Non-Secure (or) N/A:
    152   * This is a Non-Secure function.
    153   * \return Return Type (SYNCML_DM_EVENT_ACTION_T)\n
    154   * - Bit-wised actions to be tracked by DM engine
    155   * \par Prospective Clients:
    156   * All potential applications that require configuration settings and Internal Classes.
    157   */
    158   SYNCML_DM_EVENT_ACTION_T GetAction() const { return m_eAction; }
    159 
    160    /**
    161   * Retrieves subscription type.
    162   * \par Sync (or) Async:
    163   * This is a Synchronous function.
    164   * \par Secure (or) Non-Secure (or) N/A:
    165   * This is a Non-Secure function.
    166   * \return Return Type (SYNCML_DM_EVENT_TYPE_T) - subscription type\n
    167   * \par Prospective Clients:
    168   * All potential applications that require configuration settings and Internal Classes.
    169   */
    170   SYNCML_DM_EVENT_TYPE_T GetType() const { return m_nType; }
    171 
    172   /**
    173   * Retrieves topic suffix for DMT update event.
    174   * \par Sync (or) Async:
    175   * This is a Synchronous function.
    176   * \par Secure (or) Non-Secure (or) N/A:
    177   * This is a Non-Secure function.
    178   * \return topic suffix
    179   * \par Prospective Clients:
    180   * All potential applications that require configuration settings and Internal Classes.
    181   */
    182 
    183   const DMString & GetTopic() const { return m_strTopic; }
    184 
    185   /**
    186   * Retrieves vector of principals.
    187   * \par Sync (or) Async:
    188   * This is a Synchronous function.
    189   * \par Secure (or) Non-Secure (or) N/A:
    190   * This is a Non-Secure function.
    191   * \param bIsIgnore [in] - specifies type of principal \n
    192   *   - TRUE - principal to ignore \n
    193   *   - FALSE - principal to process updates
    194   * \return vector of principals
    195   * \par Prospective Clients:
    196   * All potential applications that require configuration settings and Internal Classes.
    197   */
    198   const DMVector<DmtPrincipal> & GetPrincipals(BOOLEAN bIsIgnore) const;
    199 
    200 protected:
    201  /** Event Action*/
    202   SYNCML_DM_EVENT_ACTION_T m_eAction;
    203  /** Event Type*/
    204   SYNCML_DM_EVENT_TYPE_T m_nType;
    205  /**Topic*/
    206   DMString m_strTopic;
    207  /** Collection with principals, which initiated updates are to be ignored*/
    208   DMVector<DmtPrincipal> m_aIgnorePrincipals;
    209  /** Collection with principals, which initiated updates are to be processed*/
    210   DMVector<DmtPrincipal> m_aNotifyPrincipals;
    211 
    212 };
    213 
    214 #endif
    215