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 __DMTSESSIONPROP_H__
     18 #define __DMTSESSIONPROP_H__
     19 
     20 #ifndef __cplusplus
     21 #error "This is a C++ header file; it requires C++ to compile."
     22 #endif
     23 
     24 /**
     25  \file dmtSessionProp.hpp
     26  \brief Contains DMFirmAlertVector and  DmtSessionProp classes  definition.\n
     27        The dmtSessionProp.hpp header file contains DMFirmAlertVector and  DmtSessionProp\n
     28        classes  definition. \n
     29        <b>Warning:</b>  All functions, structures, and classes from this header file are for internal usage only!!!\n
     30 
     31        The <b>DMFirmAlertVector</b> is a helper class; due to gcc limitations, declaring separate \n
     32        class instead of typedef  produces smaller binary.\n
     33        The <b>DmtSessionProp</b> is a structure with parameters for server session
     34 */
     35 
     36 #include "jem_defs.hpp"
     37 #include "dmtDefs.h"
     38 #include "dmtFirmAlert.hpp"
     39 #include "dmvector.h"
     40 
     41 /**
     42 * Helper class; due to gcc limitations, declaring separate class instead of typedef
     43 * produces smaller binary
     44 * \warning This class is using <b>ONLY</b> for firmware update session!
     45 * \par Category: General
     46 * \par Persistence: Transient
     47 * \par Security: Non-Secure
     48 * \par Migration State: FINAL
     49 */
     50 class DMFirmAlertVector : public DMVector<DmtFirmAlert>
     51 {
     52 };
     53 
     54 
     55 /**
     56 * This class is a structure with parameters for the server session
     57 * \par Category: General
     58 * \par Persistence: Transient
     59 * \par Security: Non-Secure
     60 * \par Migration State: FINAL
     61 */
     62 class DmtSessionProp
     63 {
     64 private:
     65   UINT16 m_nSessionID;            // session ID
     66   SYNCML_DM_SESSION_DIRECTION_T m_nDirection; // session direction
     67   BOOLEAN m_bWBXML;
     68 
     69   DMFirmAlertVector m_aFirmAlerts; // result of firmware update
     70 
     71 
     72 public:
     73  /**
     74   * Default constructor - no memory allocation performed.
     75   */
     76 
     77   DmtSessionProp()
     78   {
     79     m_nSessionID = 0;
     80     m_nDirection = SYNCML_DM_CLIENT_INITIATED_SESSION;
     81     m_bWBXML = true;
     82   }
     83 
     84   /**
     85   * Constructs (copy) a DMT Session Property object. The memory for this object  will be allocated.
     86   * \param oCopyFrom [in] - session property that should be copied
     87   */
     88   DmtSessionProp( const DmtSessionProp& oCopyFrom )
     89   {
     90      m_nSessionID = oCopyFrom.m_nSessionID;
     91      m_nDirection = oCopyFrom.m_nDirection;
     92      m_bWBXML = oCopyFrom.m_bWBXML;
     93      if ( oCopyFrom.m_aFirmAlerts.size() )
     94         m_aFirmAlerts =  oCopyFrom.m_aFirmAlerts;
     95   }
     96 
     97   /**
     98   * Constructs required fields for server initiated session. The memory for these fields  will be allocated.
     99   * \param sessionID [in] - provided by Syncml DM server in a notification package
    100   * \param bWBXML [in] - true to use binary xml
    101   */
    102   DmtSessionProp(UINT16 sessionID, BOOLEAN bWBXML)
    103   {
    104      m_nSessionID = sessionID;
    105      m_nDirection = SYNCML_DM_SERVER_INITIATED_SESSION;
    106      m_bWBXML = bWBXML;
    107   }
    108 
    109   /**
    110   * Constructs session property - no memory allocation performed.
    111   * \param bWBXML [in] -true to use binary xml
    112   */
    113   DmtSessionProp(BOOLEAN bWBXML)
    114   {
    115      m_nSessionID = 0;
    116      m_nDirection = SYNCML_DM_CLIENT_INITIATED_SESSION;
    117      m_bWBXML = bWBXML;
    118   }
    119 
    120 
    121   /**
    122   * Constructs session property for firmware.
    123   * \param aFirmAlert [in] - firm alert to send to the Syncml DM server
    124   * \param bWBXML [in] - true to use binary xml
    125   */
    126   DmtSessionProp(const DmtFirmAlert & aFirmAlert, BOOLEAN bWBXML)
    127   {
    128      m_nSessionID = 0;
    129      m_nDirection = SYNCML_DM_CLIENT_INITIATED_SESSION;
    130      m_bWBXML = bWBXML;
    131      m_aFirmAlerts.push_back(aFirmAlert);
    132   }
    133 
    134  /**
    135   * Retrieves session ID
    136   * \par Sync (or) Async:
    137   * This is a Synchronous function.
    138   * \par Secure (or) Non-Secure (or) N/A:
    139   * This is a Non-Secure function.
    140   * \returns session ID as an unsigned short.
    141   * \par Prospective Clients:
    142   * All potential applications that require configuration settings.
    143   */
    144  UINT16 getSessionID() const
    145  {
    146     return m_nSessionID;
    147  }
    148 
    149  /**
    150   * Retrieves direction
    151   * \par Sync (or) Async:
    152   * This is a Synchronous function.
    153   * \par Secure (or) Non-Secure (or) N/A:
    154   * This is a Non-Secure function.
    155   * \returns session direction as an  unsigned short.
    156   * \par Prospective Clients:
    157   * All potential applications that require configuration settings.
    158   */
    159  SYNCML_DM_SESSION_DIRECTION_T getDirection() const
    160  {
    161     return m_nDirection;
    162  }
    163 
    164  /**
    165   * Sets session ID
    166   * \par Sync (or) Async:
    167   * This is a Synchronous function.
    168   * \par Secure (or) Non-Secure (or) N/A:
    169   * This is a Non-Secure function.
    170   * \param sessionID [in] - session ID as an unsigned short.
    171   * \par Prospective Clients:
    172   * All potential applications that require configuration settings.
    173   */
    174  void setSessionID(UINT16 sessionID)
    175  {
    176     m_nSessionID = sessionID;
    177     m_nDirection = SYNCML_DM_SERVER_INITIATED_SESSION;
    178  }
    179 
    180  /**
    181   * Sets session direction
    182   * \par Sync (or) Async:
    183   * This is a Synchronous function.
    184   * \par Secure (or) Non-Secure (or) N/A:
    185   * This is a Non-Secure function.
    186   * \param direction [in] - session direction as an unsigned short.
    187   * \par Prospective Clients:
    188   * All potential applications that require configuration settings.
    189   */
    190  void setDirection(SYNCML_DM_SESSION_DIRECTION_T direction)
    191  {
    192     m_nDirection = direction;
    193  }
    194 
    195 /**
    196   * Generates session ID
    197   * \par Sync (or) Async:
    198   * This is a Synchronous function.
    199   * \par Secure (or) Non-Secure (or) N/A:
    200   * This is a Non-Secure function.
    201   * \par Prospective Clients:
    202   * All potential applications that require configuration settings.
    203   */
    204  void generateSessionID();
    205 
    206   /**
    207   * Sets session binary XML flag
    208   * \par Sync (or) Async:
    209   * This is a Synchronous function.
    210   * \par Secure (or) Non-Secure (or) N/A:
    211   * This is a Non-Secure function.
    212   * \param bWBXML [in] - true to use binary xml
    213   * \par Prospective Clients:
    214   * All potential applications that require configuration settings.
    215   */
    216 
    217  void setWBXML(BOOLEAN bWBXML)
    218  {
    219     m_bWBXML = bWBXML;
    220  }
    221 
    222  /**
    223   * Retrieves binary XML flag
    224   * \par Sync (or) Async:
    225   * This is a Synchronous function.
    226   * \par Secure (or) Non-Secure (or) N/A:
    227   * This is a Non-Secure function.
    228   * \returns binary XML flag as a boolean.
    229   * \par Prospective Clients:
    230   * All potential applications that require configuration settings.
    231   */
    232  BOOLEAN isWBXML() const
    233  {
    234     return m_bWBXML;
    235  }
    236 
    237 
    238  /**
    239   * Retrieves firmware alert
    240   * \par Sync (or) Async:
    241   * This is a Synchronous function.
    242   * \par Secure (or) Non-Secure (or) N/A:
    243   * This is a Non-Secure function.
    244   * \param aFirmAlert [out] - firmware update result code in DMFirmAlertVector.
    245   * \par Prospective Clients:
    246   * All potential applications that require configuration settings.
    247   */
    248  void getFirmAlerts(DMFirmAlertVector & aFirmAlert)
    249  {
    250     aFirmAlert = m_aFirmAlerts;
    251  }
    252 
    253 
    254  /**
    255   * Adds firmware update result
    256   * \par Sync (or) Async:
    257   * This is a Synchronous function.
    258   * \par Secure (or) Non-Secure (or) N/A:
    259   * This is a Non-Secure function.
    260   * \param aFirmAlert [in] - reference to a DmtFirmAlert object
    261   * \return index
    262   * \par Prospective Clients:
    263   * All potential applications that require configuration settings.
    264   */
    265  INT32 addFirmAlert(const DmtFirmAlert & aFirmAlert)
    266  {
    267    m_aFirmAlerts.push_back(aFirmAlert);
    268    return m_aFirmAlerts.size();
    269  }
    270 
    271 };
    272 
    273 #endif
    274