systemswstubs/ssyreference/inc/ssyreferencechannel.h
branchRCL_3
changeset 44 b5894bb67e73
parent 35 37b610eb7fe3
equal deleted inserted replaced
35:37b610eb7fe3 44:b5894bb67e73
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Reference implementation of SSY Channel
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SSYREFERENCECHANNEL_H
       
    20 #define SSYREFERENCECHANNEL_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <sensrvtypes.h>
       
    24 #include "ssyreferenceconfig.h"
       
    25 
       
    26 class CSsyReferenceControl;
       
    27 class CSsyReferenceChannelDataProvider;
       
    28 class CSsyReferencePropertyProvider;
       
    29 class CSsyReferenceCmdHandler;
       
    30 
       
    31 /**
       
    32  *  Main control class for SSY. Controls sensor basic functionality and provides mandatory 
       
    33  *  ECOM interface specific things.
       
    34  *
       
    35  *  @lib ssyreferenceplugin.lib
       
    36  *  @since S60 5.0
       
    37  */
       
    38 class CSsyReferenceChannel : public CBase
       
    39     {
       
    40 
       
    41 public:
       
    42 
       
    43     /**
       
    44      * Enumeration of the state of this channel
       
    45      */
       
    46     enum TSsyReferenceChannelState
       
    47         {
       
    48         ESsyReferenceChannelIdle,      // Channel created, not opened
       
    49         ESsyReferenceChannelOpening,   // Processing channel opening
       
    50         ESsyReferenceChannelOpen,      // Channel is open
       
    51         ESsyReferenceChannelReceiving, // Channel is receiving data
       
    52         ESsyReferenceChannelClosing    // Processing channel closing. After this state is idle
       
    53         };
       
    54 
       
    55 public:
       
    56 
       
    57     /**
       
    58      * Two-phase constructor
       
    59      *
       
    60      * @since S60 5.0
       
    61      * @param[in] aSsyControl Reference to SSY control instance.
       
    62      * @param[in] aChannelInfo Information of this channel
       
    63      * @return CSsyReferenceControl* Pointer to created CSsyReferenceControl object
       
    64      */
       
    65     static CSsyReferenceChannel* NewL( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo );
       
    66 
       
    67     /**
       
    68      * Virtual destructor
       
    69      *
       
    70      * @since S60 5.0
       
    71      */
       
    72     virtual ~CSsyReferenceChannel();
       
    73 
       
    74     /**
       
    75      * Request for SSY to open a sensor channel asynchronously. 
       
    76      * Response to the request is delivered through MSsyCallback::ChannelOpened().
       
    77      * Initilizes SSY (and the sensor) to be ready for other control commands via
       
    78      * data and property providers. Multiple OpenChannel()-requests can be
       
    79      * active for different channels at the same time.
       
    80      *
       
    81      * @since S60 5.0
       
    82      * @return void Symbian OS error code
       
    83      */
       
    84     TInt OpenChannel();
       
    85 
       
    86     /**
       
    87      * Request to close a sensor channel asynchronously. 
       
    88      * Response to the request is delivered through MSsyCallback::ChannelClosed().
       
    89      * Multiple CloseChannel()-requests can be active for different channels 
       
    90      * at the same time.
       
    91      *
       
    92      * @since S60 5.0
       
    93      * @return void Symbian OS error code
       
    94      */  
       
    95     TInt CloseChannel();
       
    96 
       
    97     /**
       
    98      * Returns ID of this channel
       
    99      */
       
   100     TInt ChannelId();
       
   101 
       
   102     /**
       
   103      * Handles response directed to this channel
       
   104      *
       
   105      * @since S60 5.0
       
   106      * @param[in] aMessage Contains information of the response
       
   107      */
       
   108     void ProcessResponse( TSsyReferenceMsg* aMessage );
       
   109 
       
   110     /**
       
   111      * Updates the state of this channel
       
   112      * 
       
   113      * @since S60 5.0
       
   114      * @param[in] aNewState State to update this channel
       
   115      */
       
   116     void UpdateState( const TSsyReferenceChannelState aNewState );
       
   117 
       
   118     /**
       
   119      * Reference to SsyControl
       
   120      */
       
   121     CSsyReferenceControl& SsyControl() const;
       
   122 
       
   123     /**
       
   124      * Reference to command handler
       
   125      */
       
   126     CSsyReferenceCmdHandler& CommandHandler() const;
       
   127 
       
   128     /**
       
   129      * Search property of given property id from the channel properties and 
       
   130      * returns reference to that. Leaves with KErrNotFound if property is not found
       
   131      *
       
   132      * @since S60 5.0
       
   133      * @param[in] aPropertyId Property ID to locate
       
   134      * @param[in] aItemIndex Item index if this search conserns specific property
       
   135      * @param[in] aArrayIndex Indicates array index of property
       
   136      */
       
   137     TSensrvProperty& FindPropertyL( const TSensrvPropertyId aPropertyId,
       
   138                                     TInt aItemIndex = KErrNotFound,
       
   139                                     TInt aArrayIndex = ESensrvSingleProperty );
       
   140 
       
   141     /**
       
   142      * Search property of given property id from the channel properties and 
       
   143      * update property values, if not read only
       
   144      *
       
   145      * @since S60 5.0
       
   146      * @param[in] aProperty Property to find and update
       
   147      */
       
   148     void FindAndUpdatePropertyL( const TSensrvProperty& aProperty );
       
   149     
       
   150 
       
   151     /**
       
   152      * Copies properties to param PropertyList
       
   153      *
       
   154      * @since S60 5.0
       
   155      * @param[in, out] aPropertyList List where to copy properties
       
   156      */
       
   157     void GetProperties( RSensrvPropertyList& aPropertyList );
       
   158 
       
   159 private:
       
   160 
       
   161     /**
       
   162      * C++ constructor.
       
   163      *
       
   164      * @since S60 5.0
       
   165      * @param[in] aSsyControl Reference to SSY Control instance.
       
   166      * @param[in] aChannelInfo Information of this channel
       
   167      */
       
   168     CSsyReferenceChannel( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo );
       
   169 
       
   170     /**
       
   171      * Symbian 2nd phase constructor.
       
   172      */
       
   173     void ConstructL();
       
   174 
       
   175     /**
       
   176      * Handles response for OpenChannel and completes transaction by calling 
       
   177      * MSsyCallback::ChannelOpened
       
   178      *
       
   179      * @since S60 5.0
       
   180      * @param[in] aError Error code indicating the channel opening status
       
   181      */
       
   182     void HandleOpenChannelRespL( const TInt aError );
       
   183 
       
   184     /**
       
   185      * Handles response for CloseChannel and completes transaction by calling 
       
   186      * MSsyCallback::ChannelClosed
       
   187      *
       
   188      * @since S60 5.0
       
   189      */
       
   190     void HandleCloseChannelResp();
       
   191 
       
   192     /**
       
   193      * Handles response for StartChannelData. Loops all channel data items and sends 
       
   194      * each item to ChannelDataProvider
       
   195      *
       
   196      * @since S60 5.0
       
   197      */
       
   198     void HandleDataReceivedResp();
       
   199 
       
   200 private: // data
       
   201 
       
   202     /**
       
   203      * Reference to SSY Control to send responses to Sensor Server
       
   204      */
       
   205     CSsyReferenceControl& iSsyControl;
       
   206 
       
   207     /**
       
   208      * Pointer to CSsyReferenceChannelDataProvider owned by this channel
       
   209      */
       
   210     CSsyReferenceChannelDataProvider* iChannelDataProvider;
       
   211 
       
   212     /**
       
   213      * Pointer to CSsyReferencePropertyProvider owned by this channel
       
   214      */
       
   215     CSsyReferencePropertyProvider* iChannelPropertyProvider;
       
   216 
       
   217     /**
       
   218      * Pointer to command handler
       
   219      */
       
   220     CSsyReferenceCmdHandler* iCmdHandler;
       
   221 
       
   222     /**
       
   223      * Information of this channel
       
   224      */
       
   225     TSensrvChannelInfo iChannelInfo;
       
   226 
       
   227     /**
       
   228      * State of this channel. See CSsyReferenceChannel::TSsyReferenceChannelState
       
   229      */
       
   230     TInt iState;
       
   231 
       
   232     /**
       
   233      * Property list of this channel
       
   234      */
       
   235     RSensrvPropertyList iProperties;
       
   236     };
       
   237 
       
   238 #endif // SSYREFERENCECHANNEL_H