presencecache/inc/mpresencebuddyinfo2.h
changeset 40 b46a585f6909
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     1 /*
       
     2 * Copyright (c) 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:  Interface for presence buddy presence info.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef MPRESENCEBUDDYINFO2_H
       
    19 #define MPRESENCEBUDDYINFO2_H
       
    20 
       
    21 #include <e32std.h>
       
    22 #include <badesca.h>
       
    23 
       
    24 #include <s32strm.h>
       
    25 
       
    26 class RWriteStream;
       
    27 class RReadStream;
       
    28 
       
    29     /**
       
    30      * Common field names. 
       
    31      * If you make your own extension it is recommended to use "x-" prefix in your fields, 
       
    32      * e.g. "x-myapp-location".
       
    33      */ 
       
    34      namespace NPresenceCacheFieldName
       
    35         {
       
    36 
       
    37         /**
       
    38          * Field type for "status message" field.
       
    39          *
       
    40          * Status message field contains user written
       
    41          * free text, describing for example his/hers current
       
    42          * presence status. Status message is in unicode format.
       
    43          */
       
    44         _LIT( KStatusMessage, "statustext");
       
    45 
       
    46         /**
       
    47          * Field type for "avatar" field.
       
    48          *
       
    49          * Avatar field contains user selected image. Image may be
       
    50          * an avatar describing the user or it may be image showing
       
    51          * user current presence status.
       
    52          *
       
    53          * Image is in JPEG or similar format, for what there exists
       
    54          * image codes in the platform. Field contains image binary
       
    55          * content and MIME string describing the content format.
       
    56          */
       
    57         _LIT( KAvatar,             "avatar");
       
    58 
       
    59 
       
    60         /**
       
    61          * Field type for "availability-text" field.
       
    62          *
       
    63          * Availability text field describes presentity's communication
       
    64          * availability as text. This is useful in case of brande
       
    65          * presence availability, since any text value is possible.
       
    66          *
       
    67          * Field storage format: MPresenceInfoFieldValueText
       
    68          */
       
    69         _LIT( KAvailability,       "availabilitytext");
       
    70         
       
    71         /**
       
    72          * Field type for "serviceiconbrandid-text" field.
       
    73          *
       
    74          * Service icon brand ID text field identifies the service brand which
       
    75          * the current presence information is from. Brand information can
       
    76          * be used with BrandingServer to fetch branded content to UI.  
       
    77          *
       
    78          * Field storage format: 8bit descriptor
       
    79          */
       
    80         _LIT( KServiceIconBrand,   "ServiceBrandingID" );
       
    81         
       
    82         /**
       
    83          * Field type for "serviceiconentryid-text" field.
       
    84          *
       
    85          * Service icon entry ID text field identifies the icon which represents
       
    86          * the current presence service. Icon id can be used with branding
       
    87          * information to fetch the actual image from BrandingServer.  
       
    88          *
       
    89          * Field storage format: 8bit descriptor
       
    90          */
       
    91         _LIT( KServiceIconId,      "ServiceIconEntryID" );
       
    92         
       
    93         /**
       
    94          * Field type for "timestamp" field.
       
    95          *
       
    96          * TimeStamp field represents the time when the presence information
       
    97          * was last updated. Client can show the TimeStamp on the UI or omit
       
    98          * old presence information completely.
       
    99          *
       
   100          * Field storage format: TPckg<TTime>
       
   101          * 
       
   102          * Write example:
       
   103          *     TTime time;
       
   104          *     time.HomeTime();
       
   105          *     TPckg<TTime> timePck( time );
       
   106          *     aBuddyInfo.SetAnyFieldL( KTimeStamp, timePck );
       
   107          *
       
   108          * Read example:
       
   109          *     TTime time;
       
   110          *     TPckg<TTime> timePck( time );
       
   111          *     timePck.Copy( aBuddyInfo.GetAnyField( KTimeStamp ) );
       
   112          */
       
   113         _LIT( KTimeStamp,          "TimeStamp" );        
       
   114 
       
   115         /**
       
   116          * Field type for "expiry" field.
       
   117          *
       
   118          * Expiry field represents the time (microseconds) how long buddy 
       
   119          * information is valid with out new buddy info write events. 
       
   120          * See @MPresenceCacheWriter2
       
   121          * If Buddy information is not updated in expiry time then buddy 
       
   122          * information is removed automatilly from presence cache.
       
   123          *
       
   124          * Field storage format: TPckg<TInt64>
       
   125          * 
       
   126          * Write example:
       
   127          *     TInt64 expiry([EXPIRY_TIME]);
       
   128          *     TPckg<TInt64> expiryPck( expiry );
       
   129          *     aBuddyInfo.SetAnyFieldL( 
       
   130          *                      NPresenceCacheFieldName::KExpiry, expiryPck );
       
   131          *
       
   132          * Read example:
       
   133          *     TInt64 expiry;
       
   134          *     TPckg<TInt64> expiryPck( expiry );
       
   135          *     expiryPck.Copy( aBuddyInfo.GetAnyField( 
       
   136          *                      NPresenceCacheFieldName::KExpiry ) );
       
   137          */
       
   138         _LIT( KExpiry,          "expiry" );
       
   139 
       
   140         }
       
   141 
       
   142 /**
       
   143  * Interface buddy presence info. 
       
   144  *
       
   145  * @since S60 v5.1
       
   146  */
       
   147  
       
   148         
       
   149 class MPresenceBuddyInfo2 
       
   150 {
       
   151 public:
       
   152 
       
   153     /**
       
   154      * Common enumerated availability values for "availability"
       
   155      * presence information field.
       
   156      *
       
   157      * @since S60 v5.1
       
   158      */
       
   159     enum TAvailabilityValues
       
   160         {            
       
   161         /**
       
   162          * Presentity status is unknown.
       
   163          */
       
   164         EUnknownAvailability = 0,                
       
   165 
       
   166         /**
       
   167          * Presentity is not available for communication.
       
   168          */
       
   169         ENotAvailable = 1,
       
   170 
       
   171         /**
       
   172          * Presentity is currently busy.
       
   173          * Presentity may or may not be available
       
   174          * for for communication.
       
   175          */
       
   176         EBusy = 2,
       
   177 
       
   178         /**
       
   179          * Presentity is available for communication.
       
   180          */
       
   181         EAvailable = 3
       
   182         };
       
   183 
       
   184 
       
   185     /**
       
   186      * Factory method to instantiate MPresenceBuddyInfo2
       
   187      *
       
   188      * @return The new MPresenceFeeder object. Object
       
   189      *         ownership is returned to caller.
       
   190      */
       
   191     IMPORT_C static MPresenceBuddyInfo2* NewL( );
       
   192     
       
   193     /**
       
   194      * Factory method to instantiate MPresenceBuddyInfo2
       
   195      *
       
   196      * @return The new MPresenceFeeder object. Object
       
   197      *         ownership is returned to caller.
       
   198      */
       
   199     IMPORT_C static MPresenceBuddyInfo2* NewLC( );    
       
   200     
       
   201 
       
   202 
       
   203     /**
       
   204      * Public destructor.
       
   205      * Objects can be deleted through this interface.
       
   206      */
       
   207     virtual ~MPresenceBuddyInfo2() {}
       
   208     
       
   209 public:
       
   210 
       
   211     /**
       
   212      * Sets buddy's identity
       
   213      *
       
   214      * @param aBuddyId buddy id 
       
   215      */
       
   216     virtual void SetIdentityL( const TDesC& aBuddyId ) = 0;
       
   217         
       
   218     /**
       
   219      * Gets buddy's identity
       
   220      *
       
   221      * @return identity
       
   222      */
       
   223     virtual TPtrC BuddyId( ) const = 0;        
       
   224 
       
   225     /**
       
   226      * Sets buddy's availability
       
   227      *
       
   228      * @param aAvailability avalability value
       
   229      * @param aAvailabilityText avalability text, same as KAvailability field
       
   230      */
       
   231     virtual void SetAvailabilityL( 
       
   232         TAvailabilityValues aAvailability,
       
   233         const TDesC& aAvailabilityText ) = 0;
       
   234         
       
   235     /**
       
   236      * Gets buddy's availability
       
   237      *
       
   238      * @return availability
       
   239      */
       
   240     virtual TAvailabilityValues Availability( ) = 0;         
       
   241         
       
   242     /**
       
   243      * Gets buddy's availability text
       
   244      *
       
   245      * @return availability text
       
   246      */
       
   247     virtual TPtrC AvailabilityText( ) = 0;           
       
   248         
       
   249         
       
   250     /**
       
   251      * Sets buddy's avatar
       
   252      *
       
   253      * @param aAvatar avatar, same as KAvatar field
       
   254      */
       
   255     virtual void SetAvatarL( const TDesC8& aAvatar ) = 0;
       
   256         
       
   257     /**
       
   258      * Gets buddy's avatar
       
   259      *
       
   260      * @return avatar
       
   261      */
       
   262     virtual TPtrC8 Avatar( ) = 0;             
       
   263         
       
   264     /**
       
   265      * Sets buddy's status text
       
   266      *
       
   267      * @param aStatusMessage status text, same as KStatusMessage field
       
   268      */
       
   269     virtual void SetStatusMessageL( 
       
   270         const TDesC& aStatusMessage ) = 0; 
       
   271     
       
   272     /**
       
   273      * Gets buddy's status text.
       
   274      *
       
   275      * @return status text, same as KStatusMessage field
       
   276      */
       
   277     virtual TPtrC StatusMessage( ) = 0;     
       
   278         
       
   279     /**
       
   280      * Sets any key value parameter for the buddy
       
   281      *
       
   282      * @param aKey field name
       
   283      * @param aValue field value
       
   284      */
       
   285     virtual void SetAnyFieldL( 
       
   286         const TDesC16& aKey,
       
   287         const TDesC8& aValue ) = 0;
       
   288         
       
   289     /**
       
   290      * Gets any key value parameter for the buddy
       
   291      *
       
   292      * @param aKey field name
       
   293      * @return field value, zero length if not found.     
       
   294      */
       
   295     virtual TPtrC8 GetAnyField( 
       
   296         const TDesC16& aKey ) = 0; 
       
   297         
       
   298     /**
       
   299      * Gets all the keys that are in use
       
   300      *
       
   301      * @param aKeys array where the keys are written to.   
       
   302      */
       
   303     virtual void GetFieldKeysL( 
       
   304             CDesCArrayFlat& aKeys ) = 0;
       
   305     
       
   306     /**
       
   307      * Removes the field
       
   308      * @param aKey field name     
       
   309      */
       
   310     virtual void RemoveField(const TDesC& aKey ) = 0;      
       
   311                                 
       
   312                                                     
       
   313     /**
       
   314      * Return true if identity is same with other instance.
       
   315      *
       
   316      * @param aOtherInstance other instance of this object.
       
   317      * @return ETrue if same.
       
   318      */
       
   319     virtual TBool EqualsIdentity(
       
   320         const MPresenceBuddyInfo2& aOtherInstance ) const = 0;
       
   321     
       
   322     /**
       
   323      * Externalize
       
   324      * @param aStream write stream
       
   325      */
       
   326     virtual void ExternalizeL( RWriteStream& aStream ) const = 0;
       
   327 
       
   328 
       
   329     /**
       
   330      * Internalize
       
   331      * @param aStream read stream
       
   332      */
       
   333     virtual void InternalizeL( RReadStream& aStream ) = 0;     
       
   334     
       
   335     };
       
   336 
       
   337 #endif // MPRESENCEBUDDYINFO2_H
       
   338 
       
   339 
       
   340