sensorservices/sensorserver/inc/common/sensrvclientserver.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:  Sensor server client-server API. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SENSRVCLIENTSERVER_H
       
    20 #define SENSRVCLIENTSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <sensrvchannelinfo.h>
       
    24 #include "sensrvdefines.h"
       
    25 #include "sensrvtypes.h"
       
    26 
       
    27 /**
       
    28 * Data holder class for ESensrvSrvReqAsyncChannelData return values.
       
    29 * @since S60 5.0
       
    30 */
       
    31 class TSensrvAsyncChannelDataCountsRetval
       
    32     {
       
    33     public:
       
    34         TSensrvAsyncChannelDataCountsRetval()
       
    35             {}
       
    36             
       
    37         TSensrvAsyncChannelDataCountsRetval(TInt aDataItemCount,
       
    38                                             TInt aDataLostCount)
       
    39          : iDataItemCount(aDataItemCount),
       
    40            iDataLostCount(aDataLostCount)
       
    41             {
       
    42             }
       
    43         
       
    44         /** 
       
    45         * Amount of data items written to message 
       
    46         */
       
    47         TInt iDataItemCount;
       
    48         
       
    49         /** 
       
    50         * Amount of data items lost due buffer overwrite
       
    51         */
       
    52         TInt iDataLostCount;
       
    53     };
       
    54 
       
    55 /**
       
    56 * Data holder class for ESensrvSrvReqStartListening parameter values.
       
    57 * @since S60 5.0
       
    58 */
       
    59 class TSensrvStartListeningParameters
       
    60     {
       
    61     public:
       
    62         TSensrvStartListeningParameters()
       
    63             {}
       
    64             
       
    65         TSensrvStartListeningParameters(TInt aDesiredBufferingCount,
       
    66                                         TInt aMaximumBufferingCount,
       
    67                                         TInt aBufferingPeriod)
       
    68          : iDesiredBufferingCount(aDesiredBufferingCount),
       
    69            iMaximumBufferingCount(aMaximumBufferingCount),
       
    70            iBufferingPeriod(aBufferingPeriod)
       
    71             {
       
    72             }
       
    73         
       
    74         /** 
       
    75         * The minimum desired count of items in each request.
       
    76         * Count must be less than half of the buffer size assigned
       
    77         * to channel.
       
    78         * Count less than one or count over maximum means maximum
       
    79         * allowed count is used.
       
    80         */
       
    81         TInt iDesiredBufferingCount;
       
    82         
       
    83         /** 
       
    84         * The maximum count of items in each request.
       
    85         * Count must be less than half of the buffer size assigned
       
    86         * to channel and more than iDesiredBufferingCount.
       
    87         * Count less than iDesiredBufferingCount or count over
       
    88         * maximum means maximum allowed count is used.
       
    89         */
       
    90         TInt iMaximumBufferingCount;
       
    91 
       
    92         /** 
       
    93         * Buffering period in milliseconds. 
       
    94         * If buffering period is very short, it can
       
    95         * easily be affected by system load. 
       
    96         * This value will be converted into 32-bit microseconds       
       
    97         * value on server side, so maximum period is 30 minutes.
       
    98         * Period over maximum means maximum period is used.
       
    99         * Zero or negative period means no buffering period is used.
       
   100         */
       
   101         TInt iBufferingPeriod;
       
   102     };
       
   103 
       
   104 /**
       
   105 * Data holder class for ESensrvSrvReqAddConditionSet parameter values.
       
   106 * @since S60 5.0
       
   107 */
       
   108 class TSensrvAsyncConditionRetval
       
   109     {
       
   110     public:
       
   111         TSensrvAsyncConditionRetval()
       
   112             {}
       
   113             
       
   114         TSensrvAsyncConditionRetval(
       
   115             TInt aConditionSetId,
       
   116             TInt aConditionId )
       
   117          : iConditionSetId(aConditionSetId),
       
   118            iConditionId(aConditionId)
       
   119             {
       
   120             }
       
   121         
       
   122         /** 
       
   123         * An identifier for condition set which was met. Must be unique within 
       
   124         * currently active condition sets for this client.
       
   125         */
       
   126         TInt iConditionSetId;
       
   127         
       
   128         /** 
       
   129         * An identifier for the specific condition that was met.
       
   130         * If multiple conditions in a set were met by the same data,
       
   131         * only the first match is indicated here.
       
   132         * Must be unique within currently active conditions for this client.
       
   133         */
       
   134         TInt iConditionId;
       
   135     };
       
   136 
       
   137 // Package buffers for return values    
       
   138 typedef TPckgBuf<TSensrvAsyncChannelDataCountsRetval> TSensrvAsyncChannelDataCountsRetvalPckgBuf;  
       
   139 typedef TPckgBuf<TSensrvStartListeningParameters> TSensrvStartListeningParametersPckgBuf;  
       
   140 typedef TPckgBuf<TSensrvAsyncConditionRetval> TSensrvAsyncConditionRetvalPckgBuf;
       
   141 typedef TPckgBuf<TInt> TSensrvTIntPckgBuf;
       
   142 typedef TPckgBuf<TSensrvChannelInfo> TSensrvChannelInfoPckgBuf;
       
   143 typedef TPckg<TSensrvProperty> TPropertyPckg;
       
   144 typedef TPckgBuf<TSensrvProperty> TPropertyPckgBuf;
       
   145 typedef TPckgBuf<TSensrvChannelChangeType> TSensrvTSensrvChannelChangeTypePckgBuf;
       
   146 
       
   147 // Message slot constants
       
   148 const TInt KSensrvChannelIdSlot(0); // Channel id must always be in slot zero.
       
   149 
       
   150 const TInt KSensrvQueryChannelsQueryParametersSlot(0);
       
   151 const TInt KSensrvQueryChannelsChannelInfoArraySlot(1);
       
   152 const TInt KSensrvQueryChannelsCountSlot(2);
       
   153 
       
   154 const TInt KSensrvOpenChannelBufferSizeSlot(1);
       
   155 const TInt KSensrvOpenChannelDataItemSizeSizeSlot(2);
       
   156 
       
   157 const TInt KSensrvStartListeningParametersSlot(1); // Used for data and condition listening
       
   158 
       
   159 const TInt KSensrvAsyncChannelDataBufferSlot(1);
       
   160 const TInt KSensrvAsyncChannelDataCountSlot(2);
       
   161 
       
   162 const TInt KSensrvGetPropertyPropertySlot(1);
       
   163 const TInt KSensrvGetAllPropertiesPropertyArraySlot(1);
       
   164 const TInt KSensrvGetAllPropertiesPropertyCountSlot(2);
       
   165 const TInt KSensrvSetPropertyPropertySlot(1);
       
   166 const TInt KSensrvAsyncPropertyDataPropertySlot(1);
       
   167 
       
   168 const TInt KSensrvAddConditionSetDataSlot(1);
       
   169 
       
   170 const TInt KSensrvRemoveConditionSetIdSlot(1);
       
   171 
       
   172 const TInt KSensrvAsyncConditionMetReturnDataSlot(1);
       
   173 const TInt KSensrvAsyncConditionMetReturnIdSlot(2);
       
   174 
       
   175 const TInt KSensrvAsyncChannelChangeInfoSlot(0);
       
   176 const TInt KSensrvAsyncChannelChangeTypeSlot(1);
       
   177 const TInt KSensrvAsyncChannelSearchParamsSlot(2);
       
   178 
       
   179 // Completion codes for the property set success indicator notification
       
   180 const TInt KSensrvErrPropertySetAvailable(-500000);
       
   181 const TInt KSensrvErrPropertySetPossible(-500001);
       
   182 const TInt KSensrvErrPropertySetUnavailable(-500002);
       
   183 
       
   184 /**
       
   185 * Opcodes used in message passing between client and server
       
   186 *
       
   187 * NOTE: If TSensrvServerRequest enumeration is changed, 
       
   188 * Sensor Server's policy defined in sensrvserver.h must also be
       
   189 * checked and changed correspondingly, if necessary.
       
   190 */
       
   191 enum TSensrvServerRequest
       
   192     {
       
   193 // ---------------------------------------------------------------
       
   194 // Channel listening and property getting operations
       
   195 // ---------------------------------------------------------------
       
   196 
       
   197     /**
       
   198     * Query channels
       
   199     *
       
   200     * parameters:
       
   201     * 0 - in  - TSensrvChannelInfoPckgBuf instance containing required channel properties.
       
   202     * 1 - out - TDes8 indicating the data area where fetched channels are written to.
       
   203     *           Note: Client must reserve enough space to contain all returned channels.
       
   204     *                 If there was not enough space, information in array is not valid,
       
   205     *                 and must be requested again with larger buffer. 
       
   206     *                 The count parameter indicates the actual channel count in that case.
       
   207     * 2 - out - TSensrvTIntPckgBuf, Count of returned channel infos.
       
   208     *
       
   209     * Errors:
       
   210     * KErrBadDescriptor - Invalid data descriptor for returning data
       
   211     * KErrOverflow - Not enough space to return all found channels.
       
   212     * KErrCancel - Request was canceled
       
   213     * KErrNoMemory - Not enough memory to fulfill request.
       
   214     */
       
   215     ESensrvSrvReqQueryChannels,
       
   216 
       
   217     /**
       
   218     * Open a channel for the client 
       
   219     *
       
   220     * parameters:
       
   221     * 0 - in - TSensrvChannelID identifying the channel to open
       
   222     * 1 - out - TSensrvTIntPckgBuf Maximum client buffer count
       
   223     * 2 - out - TSensrvTIntPckgBuf Actual channel data item size
       
   224     *
       
   225     * Errors:
       
   226     * KErrNotFound - Invalid channel id or channel handler creation failure.
       
   227     * KErrAlreadyExists - Session already has channel open.
       
   228     * KErrCancel - Request was canceled
       
   229     * KErrNoMemory - Not enough memory to fulfill request.
       
   230     */
       
   231     ESensrvSrvReqOpenChannel,
       
   232     
       
   233     /**
       
   234     * Close a channel for the client
       
   235     * Channel must be opened.
       
   236     *
       
   237     * parameters:
       
   238     * 0 - in - TSensrvChannelID identifying the channel to close
       
   239     *
       
   240     * Errors:
       
   241     * KErrNotFound - No channel with that id found.
       
   242     * KErrNotReady - Plugin is not in loaded state
       
   243     * KErrCancel - Request was canceled
       
   244     * KErrNoMemory - Not enough memory to fulfill request.
       
   245     */
       
   246     ESensrvSrvReqCloseChannel,
       
   247 
       
   248     /**
       
   249     * Start listening for a channel.
       
   250     * Channel must be opened. 
       
   251     *
       
   252     * parameters:
       
   253     * 0 - in - TSensrvChannelID identifying the channel
       
   254     * 1 - in - TSensrvStartListeningParameters specifying
       
   255     *          listening parameters.
       
   256     *
       
   257     * Errors:
       
   258     * KErrNotFound - No open channel with that id for this client found.
       
   259     * KErrAlreadyExists - This client is already listening for this channel.
       
   260     * KErrNotReady - Plugin is not in loaded state
       
   261     * KErrCancel - Request was canceled
       
   262     * KErrNoMemory - Not enough memory to fulfill request.
       
   263     */
       
   264     ESensrvSrvReqStartListening,
       
   265     
       
   266     /**
       
   267     * Stop listening for a channel.
       
   268     * Channel must be opened and listened to.
       
   269     *
       
   270     * parameters:
       
   271     * 0 - in - TSensrvChannelID identifying the channel
       
   272     *
       
   273     * Errors:
       
   274     * KErrNotFound - No open and listened channel with that id for this client found.
       
   275     * KErrNotReady - Plugin is not in loaded state
       
   276     * KErrCancel - Request was canceled
       
   277     * KErrNoMemory - Not enough memory to fulfill request.
       
   278     */
       
   279     ESensrvSrvReqStopListening,
       
   280     
       
   281     /**
       
   282     * Request data from a channel.
       
   283     * Channel must be opened and listened to.
       
   284     * This request is asynchronous.
       
   285     *
       
   286     * Parameters:
       
   287     * 0 - in      - TSensrvChannelID identifying the channel 
       
   288     * 1 - out     - TDes8 indicating the data area where fetched data is written to.
       
   289     * 2 - out     - TSensrvAsyncChannelDataCountsRetvalPckgBuf 
       
   290     *               Actual number of returned items and lost items. 
       
   291     *               Rest of data area is invalid.
       
   292     *
       
   293     * Errors:
       
   294     * KErrNotFound - No open and listened channel with that id for this client found.
       
   295     * KErrBadDescriptor - Invalid data descriptor for returning data.
       
   296     * KErrOverflow - Not enough space to return data. All out parameters are invalid.
       
   297     * KErrCancel - Request was canceled
       
   298     * KErrNotReady - Plugin is not in loaded state
       
   299     * KErrNoMemory - Not enough memory to fulfill request.
       
   300     */
       
   301     ESensrvSrvReqAsyncChannelData,
       
   302 
       
   303     /**
       
   304     * Get a channel property value synchronously. 
       
   305     *
       
   306     * parameters:
       
   307     * 0 - in     - TSensrvChannelID identifying the channel
       
   308     * 1 - in/out - TPropertyPckg, returned properties for a property.
       
   309     *              Name of the property(iPropertyId)
       
   310     *              and channel data type index number (iItemIndex)
       
   311     *              are transferred inside TSensrvProperty towards server.
       
   312     * Errors:
       
   313     * KErrNotFound - No open channel with that id for this client found.
       
   314     * KErrArgument - Property doesn't exist.
       
   315     * KErrCancel - Request was canceled
       
   316     * KErrNotReady - Plugin is not in loaded state
       
   317     * KErrNoMemory - Not enough memory to fulfill request.
       
   318     */
       
   319     ESensrvSrvReqGetProperty,
       
   320     
       
   321     /**
       
   322     * Start listening for a channel property changes.
       
   323     * Channel must be opened and listened to.
       
   324     * This request is asynchronous.
       
   325     *
       
   326     * Parameters:
       
   327     * 0 - in  - TSensrvChannelID identifying the channel 
       
   328     * 1 - out - TPropertyPckgBuf, changed property.
       
   329     *
       
   330     * Errors:
       
   331     * KErrNotFound - No open channel with that id for this client found.
       
   332     * KErrCancel - Request was canceled
       
   333     * KErrNotReady - Plugin is not in loaded state
       
   334     * KErrNoMemory - Not enough memory to fulfill request.
       
   335     */
       
   336     ESensrvSrvReqAsyncPropertyData,
       
   337     
       
   338     /**
       
   339     * Stop listening for a channel property changes.
       
   340     *
       
   341     * parameters:
       
   342     * 0 - in - TSensrvChannelID identifying the channel
       
   343     *
       
   344     * Errors:
       
   345     * KErrNotFound - No open channel with that id for this client found.
       
   346     * KErrCancel - Request was canceled
       
   347     * KErrNotReady - Plugin is not in loaded state
       
   348     * KErrNoMemory - Not enough memory to fulfill request.
       
   349     */
       
   350     ESensrvSrvReqStopPropertyListening,
       
   351     
       
   352     /**
       
   353     * Get all channel properties.
       
   354     *
       
   355     * parameters:
       
   356     * 0 - in  - TSensrvChannelID identifying the channel
       
   357     * 1 - out - TPtr8 indicating the data area where changed properties are written to.
       
   358     *           Note: Client must reserve enough space to contain all returned properties.
       
   359     *                 If there was not enough space, information in array is not valid,
       
   360     *                 and must be requested again with larger buffer. 
       
   361     *                 The count parameter indicates the actual property count in that case.
       
   362     * 2 - out - TSensrvTIntPckgBuf, Count of returned properties.
       
   363     *
       
   364     * Errors:
       
   365     * KErrNotFound - No open channel with that id for this client found.
       
   366     * KErrCancel - Request was canceled
       
   367     * KErrNotReady - Plugin is not in loaded state
       
   368     * KErrNoMemory - Not enough memory to fulfill request.
       
   369     */
       
   370     ESensrvSrvReqGetAllProperties,
       
   371     
       
   372     /**
       
   373     * Add a condition set for this channel. 
       
   374     * Channel must be opened. 
       
   375     *
       
   376     * parameters:
       
   377     * 0 - in - TSensrvChannelID identifying the channel
       
   378     * 1 - in - TDesC8 Externalized CSensrvChannelConditionSetImpl
       
   379     *
       
   380     * Errors:
       
   381     * KErrNotFound - No open channel with that id for this client found.
       
   382     * KErrAlreadyExists - This set is already active.
       
   383     * KErrNotReady - Plugin is not in loaded state
       
   384     * KErrCancel - Request was canceled
       
   385     * KErrNoMemory - Not enough memory to fulfill request.
       
   386     */
       
   387     ESensrvSrvReqAddConditionSet,
       
   388     
       
   389     /**
       
   390     * Remove a condition set for this channel if one is found.
       
   391     * Channel must be opened. 
       
   392     *
       
   393     * parameters:
       
   394     * 0 - in - TSensrvChannelID identifying the channel
       
   395     * 1 - in - TSensrvTIntPckgBuf identifying the set to remove.
       
   396     *
       
   397     * Errors:
       
   398     * KErrNotFound - No open channel with specified id
       
   399     *                for this client found.
       
   400     * KErrNotReady - Plugin is not in loaded state
       
   401     * KErrCancel - Request was canceled
       
   402     * KErrNoMemory - Not enough memory to fulfill request.
       
   403     */
       
   404     ESensrvSrvReqRemoveConditionSet,
       
   405        
       
   406     /**
       
   407     * Start listening for condition set.
       
   408     * Channel must be opened. 
       
   409     *
       
   410     * parameters:
       
   411     * 0 - in - TSensrvChannelID identifying the channel
       
   412     * 1 - in - TSensrvStartListeningParameters specifying
       
   413     *          listening parameters. Maximum count doesn't
       
   414     *          really matter in condition listening, as
       
   415     *          long as it is at least as much as desired count.
       
   416     *
       
   417     * Errors:
       
   418     * KErrNotFound - No open channel with that id for this client found.
       
   419     * KErrAlreadyExists - This client is already listening for this channel.
       
   420     * KErrNotReady - Plugin is not in loaded state
       
   421     * KErrCancel - Request was canceled
       
   422     * KErrNoMemory - Not enough memory to fulfill request.
       
   423     */
       
   424     ESensrvSrvReqStartConditionListening,
       
   425     
       
   426     /**
       
   427     * Stop condition listening for a channel.
       
   428     * Channel must be opened and listened to.
       
   429     *
       
   430     * parameters:
       
   431     * 0 - in - TSensrvChannelID identifying the channel
       
   432     *
       
   433     * Errors:
       
   434     * KErrNotFound - No open and listened channel with that id for this client found.
       
   435     * KErrNotReady - Plugin is not in loaded state
       
   436     * KErrCancel - Request was canceled
       
   437     * KErrNoMemory - Not enough memory to fulfill request.
       
   438     */
       
   439     ESensrvSrvReqStopConditionListening,
       
   440     
       
   441     /**
       
   442     * Request condition met notifications from a channel.
       
   443     * Channel must be opened and conditions listened to.
       
   444     * This request is asynchronous.
       
   445     *
       
   446     * Parameters:
       
   447     * 0 - in      - TSensrvChannelID identifying the channel 
       
   448     * 1 - out     - TDes8 indicating the data area where triggering data value is written to.
       
   449     * 2 - out     - TSensrvTIntPckgBuf Id of returned set
       
   450     *
       
   451     * Errors:
       
   452     * KErrNotFound - No open and listened channel with that id for this client found.
       
   453     * KErrBadDescriptor - Invalid data descriptor for returning data.
       
   454     * KErrOverflow - Not enough space to return data. All out parameters are invalid.
       
   455     * KErrCancel - Request was canceled
       
   456     * KErrNotReady - Plugin is not in loaded state
       
   457     * KErrNoMemory - Not enough memory to fulfill request.
       
   458     */
       
   459     ESensrvSrvReqAsyncConditionMet,
       
   460     
       
   461     /**
       
   462     * Start listening for new and removed channels.
       
   463     * This request is asynchronous.
       
   464     *
       
   465     * Parameters:
       
   466     * 0 - out - TSensrvChannelInfoPckgBuf Channel information.
       
   467     * 1 - out - TSensrvTSensrvChannelChangeTypePckgBuf, Indicates if channel was removed or added,
       
   468     *           value must be one of those defined in TSensrvChannelChangeType enum.
       
   469     * 2 - in - TSensrvChannelInfoPckgBuf Search parameter.
       
   470     *
       
   471     * Errors:
       
   472     * KErrCancel - Request was canceled
       
   473     * KErrNoMemory - Not enough memory to fulfill request.
       
   474     */
       
   475     ESensrvSrvReqAsyncChannelChangeNotification,
       
   476     
       
   477     /**
       
   478     * Stop listening for a channel changes.
       
   479     * If not listening, still completes without error.
       
   480     *
       
   481     * parameters:
       
   482     * None
       
   483     *
       
   484     * Errors:
       
   485     * KErrCancel - Request was canceled
       
   486     * KErrNoMemory - Not enough memory to fulfill request.
       
   487     */
       
   488     ESensrvSrvReqStopChannelChangeListening,
       
   489 
       
   490 // ---------------------------------------------------------------
       
   491 // Property Writing
       
   492 // ---------------------------------------------------------------
       
   493 
       
   494     /**
       
   495     * Set a property value.
       
   496     *
       
   497     * parameters:
       
   498     * 0 - in - TSensrvChannelID identifying the channel
       
   499     * 1 - in - TPropertyPckg, property to be set.
       
   500     *
       
   501     * Errors:
       
   502     * KErrNotFound - No open channel with that id for this client found, or property
       
   503     *                does not exist.
       
   504     * KErrPermissionDenied - Client capabilities do not match proprety set requirements.
       
   505     * KErrArgument - Property value is not valid.
       
   506     * KErrCancel - Request was canceled
       
   507     * KErrNotReady - Plugin is not in loaded state
       
   508     * KErrNoMemory - Not enough memory to fulfill request.
       
   509     */
       
   510     ESensrvSrvReqSetProperty,
       
   511     
       
   512 // ---------------------------------------------------------------
       
   513 // Server shutdown, 
       
   514 // ---------------------------------------------------------------
       
   515 
       
   516     /**
       
   517     * Shuts down the server gracefully.
       
   518     * This function can only be issued by test framework (KSensrvTestFrameworkUid).
       
   519     *
       
   520     * parameters:
       
   521     * None
       
   522     *
       
   523     * Errors:
       
   524     * KErrPermissionDenied - Invalid client SID
       
   525     */
       
   526     ESensrvSrvReqShutdownServer,
       
   527     
       
   528 // ---------------------------------------------------------------
       
   529 // End of enum
       
   530 // ---------------------------------------------------------------
       
   531 
       
   532     /**
       
   533     * Indicates end of enumeration values. 
       
   534     * Only used in security check and is not supported
       
   535     * as a real operation.
       
   536     */
       
   537     ESensrvSrvReqEnd 
       
   538     };
       
   539 
       
   540 
       
   541 #endif // SENSRVCLIENTSERVER_H