contentstorage/srvinc/casrvnotifier.h
changeset 60 f62f87b200ec
equal deleted inserted replaced
4:1a2a00e78665 60:f62f87b200ec
       
     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:  ?Description
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef CASRVNOTIFIER_H
       
    19 #define CASRVNOTIFIER_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include "cadef.h"
       
    23 
       
    24 // FORWARD DECLARATION
       
    25 
       
    26 class RMessage2;
       
    27 class CCaInnerNotifierFilter;
       
    28 class CCaInnerEntry;
       
    29 class CDesC16ArrayFlat;
       
    30 // CLASS DECLARATION
       
    31 
       
    32 /**
       
    33  * Server side notifier object.
       
    34  */
       
    35 NONSHARABLE_CLASS( CCaSrvNotifier ): public CBase
       
    36     {
       
    37 
       
    38 public:
       
    39     
       
    40     /**
       
    41      * Destructor.
       
    42      */
       
    43     virtual ~CCaSrvNotifier();
       
    44 
       
    45     /**
       
    46      * Two phase constructor. Leaves on failure.
       
    47      */
       
    48     static CCaSrvNotifier* NewL();
       
    49 
       
    50     /**
       
    51      * Two phase constructor. Leaves on failure.
       
    52      */
       
    53     static CCaSrvNotifier* NewLC();
       
    54 
       
    55     /**
       
    56      * Notification requested.
       
    57      * @param aMessage Message requesting the notification.
       
    58      */
       
    59     void NotifyL( const RMessage2& aMessage );
       
    60 
       
    61     /**
       
    62      * Cancel request, if any. 
       
    63      * Base implementation completes the message with KErrCancel. 
       
    64      * Override and add real cancellation of outstanding requests.
       
    65      */
       
    66     virtual void Cancel();
       
    67     
       
    68     /**
       
    69      * Complete message if filter is correct.
       
    70      * @param aEntry was changed.
       
    71      * @param aChangeType - update, add, remowe.
       
    72      * @param aParentIds - array with parents ids.
       
    73      */
       
    74     void EntryChangedL( const CCaInnerEntry* aEntry, TChangeType aChangeType,
       
    75             const RArray<TInt>& aParentIds );
       
    76 
       
    77     /**
       
    78      * Complete message if filter is correct.
       
    79      * @param aId entry id.
       
    80      */
       
    81     void EntryTouchedL( TInt aId );
       
    82 
       
    83     /**
       
    84      * Complete message if filter is correct.
       
    85      * @param aParentIds entries(groups) id.
       
    86      */
       
    87     void GroupContentChangedL( const RArray<TInt>& aParentIds );
       
    88 
       
    89     /**
       
    90      * Get info from latest changes.
       
    91      * @param aMessage message from client.
       
    92      */
       
    93     void GetChangeInfoL( const RMessage2& aMessage );
       
    94 
       
    95 private:
       
    96     
       
    97     /**
       
    98      * Constructor. Leaves on failure.
       
    99      */
       
   100     CCaSrvNotifier();
       
   101 
       
   102     /**
       
   103      * Second phase constructor. Leaves on failure.
       
   104      */
       
   105     void ConstructL();
       
   106 
       
   107     /**
       
   108      * Set this message as pending (take ownership of completion).
       
   109      * Call this as LAST thing in the request method,
       
   110      * and DO NOT LEAVE AFTER this is called.
       
   111      * Leaving after this method is called causes double completion of the
       
   112      * message (once by this object, once by the sessions ServiceError()).
       
   113      * @param aMessage Message to complete. Will be completed by this object.
       
   114      */
       
   115     void SetPendingL( const RMessage2& aMessage );
       
   116 
       
   117     /**
       
   118      * Panic aMessage and leave if this object is pending. 
       
   119      * Call this as first thing in request method. (Sanity checking.)
       
   120      * @param aMessage Message.
       
   121      */
       
   122     void PanicIfPendingL( const RMessage2& aMessage );
       
   123 
       
   124     /**
       
   125      * Completes the message, if pending. Does nothing if not pending.
       
   126      * @param aReason Completion code.
       
   127      */
       
   128     void Complete( TInt aReason = KErrNone );
       
   129 
       
   130     /**
       
   131      * Check filter for entry which was changed.
       
   132      * @param aEntry to check.
       
   133      * @param aParentIds - array with parents ids.
       
   134      * @return ETrue if entry is correct with filter.
       
   135      */
       
   136     TBool CheckFilterForEntry( const CCaInnerEntry* aEntry,
       
   137             const RArray<TInt>& aParentIds );
       
   138 
       
   139     /**
       
   140      * Prepare simply entry only with id.
       
   141      * @param aId entry id.
       
   142      */
       
   143     void AddEntryWithIdL( TInt aId );
       
   144 
       
   145     /**
       
   146      * If aIds array is not empty then it should contains aId.
       
   147      * @param aIds array with ids.
       
   148      * @param aId entry id which was changed.
       
   149      * @return EFalse if aIds is not empty and does not contain aId.
       
   150      */
       
   151     TBool CheckIds( const RArray<TInt>& aIds, TInt aId );
       
   152 
       
   153     /**
       
   154      * If aTypeNames array is not empty then it should contains aTypeName.
       
   155      * @param aTypeNames array with type names.
       
   156      * @param aTypeName entry type name which was changed.
       
   157      * @return EFalse if aTypeNames is not empty.
       
   158      * and does not contain aTypeName.
       
   159      */
       
   160     TBool CheckTypeName( const CDesC16ArrayFlat* aTypeNames,
       
   161             const RBuf& aTypeName );
       
   162 
       
   163 private:
       
   164     // data
       
   165 
       
   166     /*
       
   167      * Pending. (Owner of an incompleted message).
       
   168      */
       
   169     TBool iPending;
       
   170     
       
   171     /*
       
   172      * The message (valid only if iPending). Not own.
       
   173      */
       
   174     RMessage2 iMessage; 
       
   175     
       
   176     /*
       
   177      * Filter. Own.
       
   178      */
       
   179     CCaInnerNotifierFilter* iFilter; 
       
   180     
       
   181     /*
       
   182      * Array with externalized changed entries. Own.
       
   183      */
       
   184     RPointerArray<HBufC8> iBufArrayInfo;
       
   185     
       
   186     /*
       
   187      * Array with change type. Own.
       
   188      */
       
   189     RArray<TChangeType> iArrayChangeType;
       
   190     };
       
   191 
       
   192 #endif /* CASRVNOTIFIER_H */