simpledatamodeladapter/inc/presenceplugindata.h
branchRCL_3
changeset 17 2669f8761a99
parent 16 2580314736af
child 18 fbd2e7cec7ef
equal deleted inserted replaced
16:2580314736af 17:2669f8761a99
     1 /*
       
     2 * Copyright (c) 2006-2010 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:  IETF SIMPLE Protocol implementation for XIMP Framework
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_PRESENCEPLUGINDATA_H
       
    20 #define C_PRESENCEPLUGINDATA_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 #include <presenceinfo.h>
       
    25 #include <mpresencebuddyinfo2.h>
       
    26 
       
    27 #include "mpresencepluginconnectionobs.h"
       
    28 #include "presencelogger.h"
       
    29 
       
    30 class MXIMPObjectFactory;
       
    31 class MPresenceObjectFactory;
       
    32 class MSimpleDocument;
       
    33 class MPresenceInfo;
       
    34 class MSimplePresenceList;
       
    35 class MPresenceInfoFieldCollection;
       
    36 class MXIMPObjectCollection;
       
    37 class MPersonPresenceInfo;
       
    38 class MPresenceInfoField;
       
    39 class MSimpleElement;
       
    40 class MPresenceCacheWriter2;
       
    41 class MPresenceCacheReader2;
       
    42 
       
    43 /**
       
    44  * CPresencePluginData
       
    45  *
       
    46  * @lib presenceplugin.dll
       
    47  * @since S60 v3.2
       
    48  */
       
    49 NONSHARABLE_CLASS( CPresencePluginData ): public CBase
       
    50     {
       
    51     public:
       
    52     
       
    53         /**
       
    54          * Two-phased constructor.
       
    55          *
       
    56          * @param none
       
    57          * @param none
       
    58          */
       
    59         static CPresencePluginData* NewL( 
       
    60 			MPresencePluginConnectionObs& aObs,
       
    61 			TInt aServiceId );
       
    62 
       
    63         /**
       
    64          * Two-phased constructor.
       
    65          *
       
    66          * @param none
       
    67          * @param none
       
    68          */
       
    69         static CPresencePluginData* NewLC( 
       
    70             MPresencePluginConnectionObs& aObs,
       
    71             TInt aServiceId );
       
    72 
       
    73         /**
       
    74          * Standard C++ destructor
       
    75          */
       
    76         virtual ~CPresencePluginData();
       
    77 
       
    78         /**
       
    79          * Convert to engine notification to MXIMPPresenceInfo
       
    80          *
       
    81          * @since S60 5.0
       
    82          * @param aPresenceFactory object factory
       
    83          * @param aPrInfo ximp info structure [out]
       
    84          * @param aUnicodeNoteContent note field content [out]
       
    85          */
       
    86         void NotifyToBlockedToXIMPL(
       
    87             MPresenceObjectFactory& aPresenceFactory,
       
    88             MPresenceInfo& aPrInfo,
       
    89             const TDesC& aUnicodeNoteContent = KNullDesC );
       
    90 
       
    91         /**
       
    92          * Convert to engine notification to MXIMPPresenceInfo
       
    93          *
       
    94          * @since S60 3.2
       
    95          * @param aFactory ximp Factory
       
    96          * @param aPrInfo ximp info structure [out]
       
    97          * @param aUnicodeNoteContent note field content [out]
       
    98          */
       
    99         void NotifyToPendingToXIMPL(
       
   100             MPresenceObjectFactory& aPresenceFactory,
       
   101             MPresenceInfo& aPrInfo,
       
   102             const TDesC& aUnicodeNoteContent = KNullDesC );
       
   103             
       
   104         /**
       
   105          * Convert to engine notification to MXIMPPresenceInfo
       
   106          *
       
   107          * @since S60 3.2
       
   108          * @param aFactory ximp Factory
       
   109          * @param aPrInfo ximp info structure [out]
       
   110          * @param aUnicodeNoteContent note field content [out]
       
   111          */
       
   112         void NotifyTerminatedToXIMPL(
       
   113             MPresenceObjectFactory& aPresenceFactory,
       
   114             MPresenceInfo& aPrInfo,
       
   115             const TDesC& aUnicodeNoteContent = KNullDesC );
       
   116             
       
   117         /**
       
   118          * Convert to engine notification to MXIMPPresenceInfo
       
   119          *
       
   120          * @since S60 3.2
       
   121          * @param aFactory ximp Factory
       
   122          * @param aPrInfo ximp info structure [out]
       
   123          * @param aUnicodeNoteContent note field content [out]
       
   124          * @param aAvailability availability value for cache entry [out]
       
   125          */
       
   126         void NotifyToActiveToXIMPL(
       
   127             MPresenceObjectFactory& aPresenceFactory,
       
   128             MPresenceInfo& aPrInfo,
       
   129             const TDesC& aUnicodeNoteContent = KNullDesC,
       
   130             NPresenceInfo::TAvailabilityValues aAvailability = 
       
   131                 NPresenceInfo::EAvailable );
       
   132             
       
   133         /**
       
   134          * Convert to engine notification to MximpPresenceInfo
       
   135          *
       
   136          * @since S60 3.2
       
   137          * @param aFactory ximp Factory
       
   138          * @param aDocument notification
       
   139          * @param aPrInfo ximp info structure [out]
       
   140          */
       
   141         void NotifyToPrInfoL(
       
   142             MXIMPObjectFactory& aFactory,
       
   143             MPresenceObjectFactory& aPresenceFactory,
       
   144             MSimpleDocument& aDocument,
       
   145             MPresenceInfo& aPrInfo );
       
   146            
       
   147         /**
       
   148          * Extracts cache data entries from presence info object.
       
   149          *
       
   150          * @since S60 5.0
       
   151          * @param aPrInfo ximp info structure
       
   152          * @param aAvailability will store cache availability
       
   153          * @param aExtendedAvailability will store extended availability
       
   154          * @param aStatusMessage will store custom status message
       
   155          */            
       
   156         void CacheEntriesFromPrInfo(
       
   157             MPresenceInfo& aPrInfo,
       
   158             MPresenceBuddyInfo2::TAvailabilityValues& aAvailability,
       
   159             TPtr& aExtendedAvailability,
       
   160             TPtr& aStatusMessage );
       
   161 
       
   162         /**
       
   163          * Convert to engine list notification to MximpPresenceInfo elements
       
   164          *
       
   165          * @since S60 3.2         
       
   166          * @param aFactory ximp Factory
       
   167          * @param aList notification
       
   168          * @param aEntities array of ximp info structure [out]
       
   169          * @param aTerminated array of ximp info structure for
       
   170          *        terminated  entities [out]
       
   171          */
       
   172         void NotifyListToPrInfoL(
       
   173             MXIMPObjectFactory& aFactory,
       
   174             MPresenceObjectFactory& aPresenceFactory,
       
   175             MSimplePresenceList& aList,
       
   176             RPointerArray<MPresenceInfo>& aEntities,
       
   177             RPointerArray<MXIMPIdentity>& aActives,
       
   178             RPointerArray<MXIMPIdentity>& aTerminated );
       
   179 
       
   180         /**
       
   181          * AddPrPersToSimpleDocumentL
       
   182          *
       
   183          * @since S60 3.2         
       
   184          * Add subscribed or blocked person to document
       
   185          * @param aInfo, presence info
       
   186          * @param aDocument, xml document
       
   187          * @param aSipId, sip identity
       
   188          * @param aTupleId, client tupleId
       
   189          */
       
   190         void AddPrPersToSimpleDocumentL(
       
   191             const MPersonPresenceInfo* aInfo,
       
   192             MSimpleDocument& aDocument,
       
   193             const TDesC8& aSipId,
       
   194             TInt aTupleId );
       
   195         
       
   196         /**
       
   197          * Creates document.
       
   198          *
       
   199          * @since S60 3.2         
       
   200          * @param aDocument XDM document
       
   201          * @param aSipId SIP profile id
       
   202          * @param aStatusField, status enum field 
       
   203          * @param aMessageField, message field 
       
   204          */    
       
   205         void DoCreateDocumentL(
       
   206             MSimpleDocument& aDocument,
       
   207             const TDesC8& aSipId,
       
   208             const MPresenceInfoField* aStatusField,
       
   209             const MPresenceInfoField* aMessageField ); 
       
   210         
       
   211         /**
       
   212          * DoCheckBasicStatusValueL
       
   213          *
       
   214          * @since S60 3.2         
       
   215          * @param aField 
       
   216          * @return TPtrC basic status value
       
   217          */ 
       
   218         TPtrC DoCheckBasicStatusValueL(
       
   219         	const MPresenceInfoField& aField );
       
   220         
       
   221         /**
       
   222          * DoCheckActivitiesValueL
       
   223          *
       
   224          * @since S60 3.2         
       
   225          * @param aField 
       
   226          * @return TPtrC activities value
       
   227          */ 
       
   228         TPtrC8 DoCheckActivitiesValueL(
       
   229         	const MPresenceInfoField& aField );
       
   230         
       
   231         /**
       
   232          * DoCheckNoteValueL
       
   233          *
       
   234          * @since S60 3.2         
       
   235          * @param aField 
       
   236          * @return TPtrC activities value
       
   237          */
       
   238         TPtrC DoCheckNoteValueL(
       
   239             const MPresenceInfoField& aField );
       
   240         
       
   241         /**
       
   242          * CreatePresenceUri8LC
       
   243          *
       
   244          * @since S60 3.2
       
   245          * @param aPresentityUri
       
   246          * @return presence URI
       
   247          */ 
       
   248         HBufC8* CreatePresenceUri8LC( 
       
   249             const TDesC8& aPresentityUri );          
       
   250 
       
   251         /**
       
   252          * GenerateTupleId()
       
   253          * Generate Tuple id for status document
       
   254          *
       
   255          * @since S60 3.2         
       
   256          * @param none
       
   257          * @return TInt, tupleid
       
   258          */
       
   259         TInt GenerateTupleId();
       
   260         
       
   261            
       
   262         /**
       
   263          * Removes prefix from uri.
       
   264          *
       
   265          * @since S60 3.2
       
   266          * @param aPresentityUri, presentity url
       
   267          * @return HBufC16, URL without prefix
       
   268          */            
       
   269         HBufC16* RemovePrefixLC( 
       
   270             const TDesC& aPresentityUri );
       
   271             
       
   272         /**
       
   273          * Returns service id.
       
   274          *
       
   275          * @since S60 5.0
       
   276          * @return TInt, service id related to this data instance
       
   277          */            
       
   278         TInt ServiceId();            
       
   279         
       
   280         /**
       
   281          * Resolve service name
       
   282          * 
       
   283          * @since   S60 5.0
       
   284          * @param   aServiceId Service Id.
       
   285          * @return  resolved service name, ownership returned to caller
       
   286          */
       
   287         HBufC* ServiceNameLC( TInt aServiceId ) const;
       
   288         
       
   289         /**
       
   290          * Writes status to presence cache
       
   291          *
       
   292          * @since S60 5.0
       
   293          * @param aPresentityId, identity of status
       
   294          * @param aAvailability, availability value to set
       
   295          * @param aAvailabilityText, text for extended states
       
   296          * @param aStatusMessage, status message from remote party
       
   297          * @return None
       
   298          */                    
       
   299         void WriteStatusToCacheL(
       
   300             const TDesC& aPresentityId, 
       
   301             MPresenceBuddyInfo2::TAvailabilityValues aAvailability,
       
   302             const TDesC& aAvailabilityText,
       
   303             const TDesC& aStatusMessage );
       
   304             
       
   305         /**
       
   306          * Removes cache entries for this service.
       
   307          *
       
   308          * @since S60 5.0
       
   309          * @return None
       
   310          */                             
       
   311         void RemoveCacheL();
       
   312         
       
   313         /**
       
   314          * Removes cache entries for certain person.
       
   315          *
       
   316          * @since S60 5.0
       
   317          * @param aIdentity, identity of presence entry
       
   318          * @return None
       
   319          */                                     
       
   320         void DeletePresenceL( const TDesC& aIdentity );
       
   321         
       
   322         /**
       
   323          * Stores own presence values to permanent storage.
       
   324          *
       
   325          * @since S60 5.0
       
   326          * @param aServiceId, service id
       
   327          * @param aAvailability, availability enumeration
       
   328          * @param aStatusMessage, custom status message
       
   329          * @return None
       
   330          */                                             
       
   331         void StorePresenceOwnPresenceL(
       
   332             const TUint aServiceId, 
       
   333             NPresenceInfo::TAvailabilityValues aAvailability,
       
   334             const TDesC& aStatusMessage );
       
   335             
       
   336         /**
       
   337          * Reads document id from permanent storage.
       
   338          *
       
   339          * @since S60 5.0
       
   340          * @param aServiceId, service id
       
   341          * @param aDocumentId, document id
       
   342          * @return None
       
   343          */                                   
       
   344         void ReadDocumentIdL(
       
   345             const TInt aServiceId, 
       
   346             TDes8& aDocumentId );
       
   347             
       
   348         /**
       
   349          * Deletes permanent data from storage
       
   350          *
       
   351          * @since S60 5.0
       
   352          * @param aServiceId, service id
       
   353          * @return None
       
   354          */                                               
       
   355         void DeletePresenceVariablesL( const TInt aServiceId );
       
   356         
       
   357     private:
       
   358 
       
   359         /**
       
   360          * Standard C++ constructor
       
   361          */ 
       
   362         CPresencePluginData( 
       
   363             MPresencePluginConnectionObs& aObs,
       
   364             TInt aServiceId );
       
   365             
       
   366         /**
       
   367          * Standard C++ constructor
       
   368          */             
       
   369         void ConstructL();
       
   370         
       
   371         /**
       
   372          * UserNoteToXIMPL
       
   373          *
       
   374          * @since S60 3.2 
       
   375          * This method not yet used
       
   376          * @param aPresenceFactory ximp Factory
       
   377          * @param aElement Simple elemnt
       
   378          * @param aCollection Field Collection
       
   379          */ 
       
   380         void UserNoteToXIMPL(
       
   381             MPresenceObjectFactory& aPresenceFactory,
       
   382             MSimpleElement* aElement,
       
   383             MPresenceInfoFieldCollection& aCollection );
       
   384         
       
   385         /**
       
   386          * SingleUserStatusToXIMPL
       
   387          *
       
   388          * @since S60 3.2          
       
   389          * @param aPresenceFactory ximp Factory
       
   390          * @param aElement Simple element
       
   391          * @param aActivitiesElement Simple element
       
   392          * @param aNoteElement Simple element for note elems (can be null)
       
   393          * @param aCollection Field Collection
       
   394          */     
       
   395         void SingleUserStatusToXIMPL(
       
   396             MPresenceObjectFactory& aPresenceFactory,
       
   397             MSimpleElement* aBasicElement,
       
   398             MSimpleElement* aActivitiesElement,
       
   399             MSimpleElement* aNoteElement,
       
   400             MPresenceInfoFieldCollection& aCollection );
       
   401         
       
   402         /**
       
   403          * Returns <note> element or NULL if no <note> is found in the given 
       
   404          * element list. <note> element which matches best current locale is 
       
   405          * returned.
       
   406          * 
       
   407          * @since   S60 5.1
       
   408          * @param   aElements   Element array.
       
   409          * @return  Best matching <note> or NULL.
       
   410          */
       
   411         MSimpleElement* ResolveNoteElementL( 
       
   412             const RPointerArray<MSimpleElement>& aElements ) const;
       
   413         
       
   414         /**
       
   415          * Checks if element has language attribute compatible with the 
       
   416          * current locale.
       
   417          *
       
   418          * @since   S60 5.1
       
   419          * @param   aElement    Simple element containing language attribute.
       
   420          * @return  ETrue if compatible language attribute is found, 
       
   421          *          EFalse otherwise.
       
   422          */ 
       
   423         TBool IsElementLanguageValidForCurrentLocaleL( 
       
   424             MSimpleElement& aElement ) const;
       
   425         
       
   426         /**
       
   427          * Resolve cache used identifier
       
   428          * 
       
   429          * @since   S60 5.0
       
   430          * @param   aIdentity presence id without prefix
       
   431          * @return  resolved cache identifier, ownership returned to caller
       
   432          */
       
   433         HBufC* ResolveCacheXspIdentifierL( const TDesC& aIdentity ) const;
       
   434         
       
   435         
       
   436     private: // data
       
   437 
       
   438         /**
       
   439          * Generated tuple/person id
       
   440          * Own.
       
   441          */
       
   442         TInt  iNumBuf;
       
   443 
       
   444         /**
       
   445          * ximp Plugin connection observer
       
   446          * Not Own.
       
   447          */
       
   448         MPresencePluginConnectionObs& iConnObs;
       
   449         
       
   450         /**
       
   451          * Stores service id.
       
   452          */        
       
   453         TInt iServiceId;
       
   454         
       
   455         /**
       
   456          * Writes service status to presence cache.
       
   457          * Own.
       
   458          */        
       
   459         MPresenceCacheWriter2* iPresenceCacheWriter;
       
   460               
       
   461         /**
       
   462          * Reads service status from presence cache.
       
   463          * Own.
       
   464          */        
       
   465         MPresenceCacheReader2* iPresenceCacheReader;  
       
   466         
       
   467         SIMPLE_UNIT_TEST( T_CPresencePluginData )
       
   468     };
       
   469 
       
   470 #endif //C_PRESENCEPLUGINDATA_H