serviceapifw_plat/liw_criteria_api/inc/liwcommon.h
changeset 57 61b27eec6533
parent 45 7aa6007702af
equal deleted inserted replaced
45:7aa6007702af 57:61b27eec6533
     1 /*
       
     2 * Copyright (c) 2003-2005 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 the License "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:       Declares common constants, types, classes etc. to be used both
       
    15 *                consumer and provider side.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef LIW_COMMON_H
       
    26 #define LIW_COMMON_H
       
    27 
       
    28 // INCLUDES
       
    29 #include <liwcommon.hrh>
       
    30 #include <barsread.h> 
       
    31 #include <liwgenericparam.h>
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // MACROS
       
    36 
       
    37 // FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class CEikMenuPane;
       
    41 class CLiwGenericParamList;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 /**
       
    46  * Criteria item data.
       
    47  * This class encapsulates an LIW criteria item. Criteria items are building 
       
    48  * blocks for LIW interests, i.e. an interest is a list of criteria items. 
       
    49  * A criteria item can be defined dynamically (by using this class) or 
       
    50  * in a resource file.
       
    51  *
       
    52  * @lib ServiceHandler.lib
       
    53  * @since Series 60 2.6
       
    54  */
       
    55 class CLiwCriteriaItem : public CBase
       
    56     {
       
    57     public:   // Constructors and destructor
       
    58         /** 
       
    59         * Constructs a criteria item instance with null items.
       
    60         *
       
    61         * @return A pointer to the new object.
       
    62         */
       
    63         IMPORT_C static CLiwCriteriaItem* NewL();
       
    64 
       
    65         /** 
       
    66         * Constructs a criteria item instance with null items. Leaves the 
       
    67         * pointer to the cleanup stack.
       
    68         *
       
    69         * @return A pointer to the new object.
       
    70         */
       
    71         IMPORT_C static CLiwCriteriaItem* NewLC();
       
    72 
       
    73         /** 
       
    74         * Constructs a criteria item instance.
       
    75         *
       
    76         * @param aCriteriaId The criteria ID.
       
    77         * @param aServiceCmd The service command.
       
    78         * @param aContentType The content type.
       
    79         * @return A pointer to the new object.
       
    80         */
       
    81         IMPORT_C static CLiwCriteriaItem* NewL(
       
    82             TInt aCriteriaId,
       
    83             TInt aServiceCmd,
       
    84             const TDesC8& aContentType);
       
    85 
       
    86         /** 
       
    87         * Constructs a criteria item instance. Leaves the pointer to the 
       
    88         * cleanup stack.
       
    89         *
       
    90         * @param aCriteriaId The criteria ID.
       
    91         * @param aServiceCmd The service command.
       
    92         * @param aContentType The content type.
       
    93         * @return A pointer to the new object.
       
    94         */
       
    95         IMPORT_C static CLiwCriteriaItem* NewLC(
       
    96             TInt aCriteriaId,
       
    97             TInt aServiceCmd,
       
    98             const TDesC8& aContentType);
       
    99 
       
   100         /** 
       
   101         * Constructs a criteria item instance.
       
   102         *
       
   103         * @param aCriteriaId The criteria ID.
       
   104         * @param aServiceCmd The service command.
       
   105         * @param aContentType Content type.
       
   106         * @return A pointer to the new object.
       
   107         */
       
   108         IMPORT_C static CLiwCriteriaItem* NewL(
       
   109             TInt aCriteriaId,
       
   110             const TDesC8& aServiceCmd,
       
   111             const TDesC8& aContentType);
       
   112 
       
   113         /** 
       
   114         * Constructs a criteria item instance.
       
   115         *
       
   116         * @param aCriteriaId The criteria ID.
       
   117         * @param aServiceCmd The service command.
       
   118         * @param aContentType Content type.
       
   119         * @return A pointer to the new object.
       
   120         */
       
   121         IMPORT_C static CLiwCriteriaItem* NewLC(
       
   122             TInt aCriteriaId,
       
   123             const TDesC8& aServiceCmd,
       
   124             const TDesC8& aContentType);
       
   125 
       
   126         /** 
       
   127         * Destructor.
       
   128         */        
       
   129         IMPORT_C virtual ~CLiwCriteriaItem();
       
   130 
       
   131     public: // New functions
       
   132         /** 
       
   133         * Sets the criteria ID.
       
   134         *
       
   135         * @param aId The criteria ID.
       
   136         */
       
   137         IMPORT_C void SetId(TInt aId);
       
   138 
       
   139         /** 
       
   140         * Sets the service class.
       
   141         *
       
   142         * @param aServiceUid The service class, see TLiwServiceClass.
       
   143         */
       
   144         IMPORT_C void SetServiceClass(const TUid& aServiceUid);
       
   145         
       
   146         /** 
       
   147         * Sets the service command UID.
       
   148         *
       
   149         * @param aServiceCmd The LIW service command, see TLiwServiceCommands.
       
   150         */
       
   151         IMPORT_C void SetServiceCmd(TInt aServiceCmd);
       
   152 
       
   153         /** 
       
   154         * Sets the service command name.
       
   155         *
       
   156         * @param aServiceCmd The LIW service command.
       
   157         */
       
   158         IMPORT_C void SetServiceCmdL(const TDesC8& aServiceCmd);
       
   159 
       
   160         /** 
       
   161         * Sets the content type. Makes a copy of the string data.
       
   162         *
       
   163         * @param aContentType Content MIME type, event type or any agreed one.
       
   164         */
       
   165         IMPORT_C void SetContentTypeL(const TDesC8& aContentType);
       
   166 
       
   167         /** 
       
   168         * Gets the criteria ID, 0 if not defined.
       
   169         *
       
   170         * @return The criteria ID.
       
   171         */
       
   172         IMPORT_C TInt Id() const;
       
   173 
       
   174         /** 
       
   175         * Gets the service class UID.
       
   176         *
       
   177         * @return The service class UID, see TLiwServiceClass.
       
   178         */
       
   179         IMPORT_C const TUid& ServiceClass() const;
       
   180         
       
   181         /** 
       
   182         * Gets the service command UID. KNullUid, if not defined.
       
   183         *
       
   184         * @return The service command UID, see TLiwServiceCommands.
       
   185         */
       
   186         IMPORT_C TInt ServiceCmd() const;
       
   187 
       
   188         /** 
       
   189         * Gets the service command name.
       
   190         *
       
   191         * @return The service command name.  
       
   192         */
       
   193         IMPORT_C const TDesC8& ServiceCmdStr() const;
       
   194 
       
   195         /** 
       
   196         * Gets the content type.
       
   197         *
       
   198         * @return The content type.
       
   199         */
       
   200         IMPORT_C const TDesC8& ContentType() const;
       
   201 
       
   202         /** 
       
   203         * Sets the options.
       
   204         *
       
   205         * @param aOptions Options.
       
   206         */
       
   207         IMPORT_C void SetOptions(TUint aOptions);
       
   208 
       
   209         /** 
       
   210         * Gets the options.
       
   211         * 
       
   212         * @return Options.
       
   213         */
       
   214         IMPORT_C TUint Options() const;
       
   215 
       
   216         /** 
       
   217         * Maximum number of providers allowed for this criteria item. 
       
   218         * 
       
   219         * @return Maximum number of providers allowed for this criteria item.
       
   220         */
       
   221         IMPORT_C TInt MaxProviders() const;
       
   222 
       
   223         /** 
       
   224         * Reads a criteria item from a resource.  
       
   225         *
       
   226         * @param aReader A resource reader pointing to a criteria item.
       
   227         */
       
   228         IMPORT_C void ReadFromResoureL(TResourceReader& aReader);
       
   229 
       
   230         /** 
       
   231         * Returns the default provider.
       
   232         * 
       
   233         * @return The default provider UID.        
       
   234         */
       
   235         IMPORT_C TUid DefaultProvider() const;
       
   236 
       
   237         /** 
       
   238         * Sets the default provider.
       
   239         *
       
   240         * @param aDefault The UID of a default provider.
       
   241         */
       
   242         IMPORT_C void SetDefaultProvider(TInt aDefault);
       
   243 
       
   244         /** 
       
   245         * Equality operator. Two criteria items are considered equal only if all
       
   246         * parameters match. The parameters are: criteria id, service command, 
       
   247         * content type, service class, default provider, max providers and options). 
       
   248         *
       
   249         * @param aItem Criteria item to compare.
       
   250         * @return ETrue if criteria items are equal, EFalse otherwise.
       
   251         */
       
   252         IMPORT_C TBool operator==(const CLiwCriteriaItem& aItem);
       
   253 
       
   254         /** 
       
   255         * Sets the maximum number of providers.
       
   256         *
       
   257         * @param aMaxProviders The maximum number of providers.
       
   258         */
       
   259         IMPORT_C void SetMaxProviders(TInt aMaxProviders);
       
   260 
       
   261     public:
       
   262         /** 
       
   263         * If set, only ROM based providers can be attached to this criteria.
       
   264         *
       
   265         * @return ETrue if LIW_OPTIONS_ROM_ONLY bit is set, EFalse otherwise.
       
   266         */    
       
   267         inline TBool RomOnly() const;
       
   268         
       
   269         IMPORT_C void SetMetaDataOptions(const TLiwVariant& aMetaDataOptions);
       
   270 
       
   271         IMPORT_C void GetMetaDataOptions(TLiwVariant& aMetaDataOptions) const;
       
   272         
       
   273 	private:
       
   274         /**
       
   275         * C++ default constructor.
       
   276         */
       
   277         CLiwCriteriaItem();    
       
   278     
       
   279         /**
       
   280         * By default Symbian 2nd phase constructor is private.
       
   281         */
       
   282         void ConstructL();
       
   283         
       
   284         /**
       
   285         * By default Symbian 2nd phase constructor is private.
       
   286         */
       
   287         void ConstructL(
       
   288             TInt aCriteriaId,
       
   289             TInt aServiceCmd,
       
   290             const TDesC8& aContentType);
       
   291 
       
   292         void ConstructL( 
       
   293             TInt aCriteriaId,
       
   294             const TDesC8& aServiceCmd,
       
   295             const TDesC8& aContentType);
       
   296 
       
   297     private:
       
   298         // Criteria ID.
       
   299         TInt iCriteriaId;
       
   300         // Service class UID
       
   301         TUid iServiceClass;
       
   302         // Service command UID
       
   303         TInt iServiceCmd;
       
   304         // Content type (MIME type). 
       
   305         HBufC8* iContentType;
       
   306         // Additional options for ROM
       
   307         TLiwVariant iOptions;        
       
   308         //Default provider implementation uid
       
   309         TUid iDefaultProvider;
       
   310         // Reserved member
       
   311         TLiwVariant iReserved;
       
   312         // Max providers
       
   313         TInt iMaxProviders;        
       
   314         // Metadata Options
       
   315         TLiwVariant iMetadataOptions;
       
   316     };
       
   317 
       
   318 
       
   319 inline TBool CLiwCriteriaItem::RomOnly() const
       
   320     {
       
   321     return (Options() & LIW_OPTIONS_ROM_ONLY) != 0;
       
   322     }
       
   323 
       
   324 
       
   325 /**
       
   326 * Interest is an array of criteria items.
       
   327 */
       
   328 typedef RPointerArray<CLiwCriteriaItem> RCriteriaArray;
       
   329 
       
   330 /**
       
   331 * Abstact callback interface to handle callbacks or events
       
   332 * from providers. This callback is needed when
       
   333 * - Consumer wants to pre-check output parameters before returning
       
   334 *   synchronous Handle*Cmd.
       
   335 * - Asynchronous Handle*Cmd is used.
       
   336 * - An asynchronous event occurs in the system.
       
   337 * 
       
   338 *  @lib ServiceHandler.lib
       
   339 *  @since Series 60 2.6
       
   340 */ 
       
   341 class MLiwNotifyCallback                                  // needs to handle this as well?
       
   342     {
       
   343     public:
       
   344         /**
       
   345         * Handles notifications caused by an asynchronous Execute*CmdL call
       
   346         * or an event.
       
   347         *
       
   348         * @param aCmdId The service command associated to the event.
       
   349         * @param aEventId Occured event, see LiwCommon.hrh.
       
   350         * @param aEventParamList Event parameters, if any, as defined per
       
   351         *        each event.
       
   352         * @param aInParamList Input parameters, if any, given in the
       
   353         *        related HandleCommmandL.
       
   354         * @return Error code for the callback.
       
   355         */
       
   356         virtual TInt HandleNotifyL(
       
   357             TInt aCmdId,
       
   358             TInt aEventId,
       
   359             CLiwGenericParamList& aEventParamList,
       
   360             const CLiwGenericParamList& aInParamList) = 0;
       
   361     	IMPORT_C static TInt32 GetTransactionID();
       
   362     };
       
   363 
       
   364 #endif // LIW_COMMON_H
       
   365 
       
   366 // End of File
       
   367 
       
   368