messagingapp/msgappfw/server/inc/ccsconversationcachehelper.h
changeset 31 ebfee66fde93
child 47 5b14749788d7
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     1 /*
       
     2  * Copyright (c) 2007 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:  This class helps CS Cache in processing the data. The class 
       
    15  *                takes up one conversation from plugin and resolve it by
       
    16  *                either with help of ContactResolver or update inside cache
       
    17  *
       
    18  */
       
    19 
       
    20 #ifndef __C_CS_CONVERSATION_CACHE_HELPER_H
       
    21 #define __C_CS_CONVERSATION_CACHE_HELPER_H
       
    22 
       
    23 // FORWARD DECLARATIONS
       
    24 class CCsConversationCache;
       
    25 class CCsConversation;
       
    26 class CCsConversationEntry;
       
    27 class CCsConversationEvent;
       
    28 class CCsClientConversation;
       
    29 
       
    30 // states of cache helper class
       
    31 enum
       
    32 {
       
    33     ECsProcessConversation,
       
    34     ECsSpecialConversation,
       
    35     ECsConversationFoundInCache,
       
    36     ECsResolveConversation,
       
    37 };
       
    38 
       
    39 // CLASS DECLARATION
       
    40 /** 
       
    41  * This class helps CS Cache in processing the data.
       
    42  * Puts request to phonebook for contact resolution
       
    43  */
       
    44 class CCsConversationCacheHelper : public CActive
       
    45 {
       
    46 
       
    47 public:
       
    48 
       
    49     /**
       
    50      * Two phase construction
       
    51      * 
       
    52      * @param aConversationCache, instance of CCsConversationCache
       
    53      * @return CCsConversationCacheHelper newly created instance
       
    54      */
       
    55     static CCsConversationCacheHelper
       
    56             * NewL(CCsConversationCache* aConversationCache);
       
    57 
       
    58     /**
       
    59      * Destructor
       
    60      */
       
    61     ~CCsConversationCacheHelper();
       
    62 
       
    63     /**
       
    64      * RunL implementation from CActive
       
    65      */
       
    66     void RunL();
       
    67 
       
    68     /**
       
    69      * DoCancel implementation from CActive
       
    70      */
       
    71     void DoCancel();
       
    72 
       
    73     /**
       
    74      * StartCacheUpdate
       
    75      * this shall start looking at cache data and update if entry already exists
       
    76      * shall put request to phonebook in case new data
       
    77      */
       
    78     void StartCacheUpdate();
       
    79 
       
    80     /**
       
    81      * IsNotifyRequiredL, returns true or false as if notify is required in 
       
    82      * conversation UI 
       
    83      * 
       
    84      * @param aConversation CCsConversation object
       
    85      * @param aConversationEntry CCsConversationEntry object
       
    86      * @param event type
       
    87      * @param previous unread message count
       
    88      * 
       
    89      * @return True/False for notification required
       
    90      */
       
    91     TBool IsNotifyRequiredL(CCsConversation* aConversation,
       
    92                             CCsConversationEntry* aConversationEntry,
       
    93                             TUint32 aEvent, TUint16 aPreviousUnreadMsgsCount);
       
    94 
       
    95     /**
       
    96      * ConversationList
       
    97      * Returns the internal event list
       
    98      * @return pointer to array of conversations
       
    99      */
       
   100     RPointerArray<CCsConversationEvent>* ConversationEventList();
       
   101 
       
   102 private:
       
   103 
       
   104     /**
       
   105      * Constructor
       
   106      * 
       
   107      * @param aConversationCache, instance of CCsConversationCache
       
   108      */
       
   109     CCsConversationCacheHelper(CCsConversationCache* aConversationCache);
       
   110 
       
   111     /**
       
   112      * Second phase constructor
       
   113      */
       
   114     void ConstructL();
       
   115 
       
   116     /**
       
   117      * CreateSpecialConversationL
       
   118      * This shall create all special type of Conversations like BT, Unknown Draft, IRDA etc.
       
   119      * Pls note this shall be placed by order at starting of cache
       
   120      */
       
   121     void CreateSpecialConversationL();
       
   122 
       
   123 private:
       
   124 
       
   125     /*
       
   126      * HandleProcessConversationL
       
   127      * Processes the Conversation and update cache
       
   128      */
       
   129     void HandleProcessConversationL();
       
   130 
       
   131     /*
       
   132      * HandleSpecialConversationL
       
   133      * Handles the case when the conversation is a special conversation
       
   134      * - BT/Drafts/IrDa
       
   135      */
       
   136     void HandleSpecialConversationL();
       
   137 
       
   138     /*
       
   139      * HandleConversationInCacheL
       
   140      * Handle the case when the conversation is found in the cache
       
   141      */
       
   142     void HandleConversationInCacheL();
       
   143 
       
   144     /**
       
   145      * NeedsSpecialProcessing
       
   146      * This function identifies if the conentry needs special processing
       
   147      * Drafts message with NULL contact,Bluetooth/IRDA need this handling 
       
   148      * 
       
   149      * @param aConversationEntry, Conversation entry to be checked
       
   150      * @return the conversation id for special cases or return 0  
       
   151      */
       
   152     TUint8 NeedsSpecialProcessing(CCsConversationEntry* aConversationEntry);
       
   153 
       
   154     /**
       
   155      * IssueRequest
       
   156      * Make the active object alive
       
   157      */
       
   158     void IssueRequest();
       
   159     
       
   160     /**
       
   161      * ResolveContact
       
   162      * Resolve contact by match with phonebook
       
   163      * @param aConverastionEvent consisting entry details
       
   164      */
       
   165     void ResolveContact(
       
   166               CCsConversationEvent* aConverastionEvent);
       
   167 
       
   168     /**
       
   169      * AddConversationEntryL
       
   170      * This will add new conversation Entry into the existing conversation in cache
       
   171      * 
       
   172      * @param aConEntry Conversation Entry to be added to the Conversation
       
   173      * @param aConversationIndex position of conversation in  cache
       
   174      */
       
   175     void AddConversationEntryL(CCsConversationEntry *aConEntry,
       
   176                                TInt aConversationIndex);
       
   177 
       
   178     /**
       
   179      * DeleteConversationEntryL
       
   180      * Deletes the Conversation Entry from a particular Conversation
       
   181      * 
       
   182      * @param aConversationEntry conversation entry to be deleted
       
   183      */
       
   184     void DeleteConversationEntryL(CCsConversationEntry* aConversationEntry);
       
   185 
       
   186     /**
       
   187      * AddNewConversationL
       
   188      * Adds a new conversation into cache with phonebook details and Conversation Entry
       
   189      * 
       
   190      * @param aConversationEntry instance of CCsConversationEntry
       
   191      * @param aContactId pointer to contact Id
       
   192      * @param aFirstName contact first name
       
   193      * @param aLastName contact last name
       
   194      */
       
   195     void AddNewConversationL(CCsConversationEntry* aConversationEntry,
       
   196                              TInt32 aContactId, const HBufC* aDisplayName);
       
   197 
       
   198     /**
       
   199      * GetPendingEventCount
       
   200      * Gets the number of pending events inside cache 
       
   201      * 
       
   202      * @return  - number of events still to be processed
       
   203      */
       
   204     TInt GetPendingEventCount();
       
   205 
       
   206     /**
       
   207      * GetNextEvent, This function is to get the next event to be processed 
       
   208      * from the pending cache event list
       
   209      * 
       
   210      * @return CCsConversationEvent instance
       
   211      */
       
   212     CCsConversationEvent* GetNextEvent();
       
   213 
       
   214     /**
       
   215      * FindEvent
       
   216      * Finds the conversation Event in temporary event list
       
   217      * 
       
   218      * @param aConvEvent refenrence of  CCsConversationEvent event to be searched
       
   219      * @return KErrNotFound or integer where event is located
       
   220      */
       
   221     TInt FindEvent(const CCsConversationEvent& aConvEvent);
       
   222 
       
   223     /**  
       
   224      * GetNextRowId
       
   225      * Get the conversation list count where to add next conversation
       
   226      * 
       
   227      * @return index as where to add next conversation
       
   228      */
       
   229     TInt16 GetNextRowId();
       
   230 
       
   231     /**
       
   232      * DeleteEvent
       
   233      * Deletes conversation event from temporary event list  
       
   234      * @param aConvEvent refenrence of CCsConversationEvent
       
   235      */
       
   236     void DeleteEvent(const CCsConversationEvent& aConvEvent);
       
   237 
       
   238 private:
       
   239 
       
   240     /** 
       
   241      * iConversationEventList;
       
   242      * Conversation event list in the cache
       
   243      * Own
       
   244      */
       
   245     RPointerArray<CCsConversationEvent>* iConversationEventList;
       
   246 
       
   247     /**
       
   248      * Reference of Conversation Cache entry list
       
   249      * Not Own
       
   250      */
       
   251     CCsConversationCache* iConversationCache;
       
   252 
       
   253     /**
       
   254      * Present Conversation event 
       
   255      * this is now which is being processed
       
   256      * Not Own
       
   257      */
       
   258     CCsConversationEvent* iConversationEvent;
       
   259 
       
   260     /**
       
   261      * State of the state machine 
       
   262      * which process the temporary event list
       
   263      */
       
   264     TInt iState;
       
   265 
       
   266     /** 
       
   267      * iConversationIndex;
       
   268      * this shall be used to generate row ids for storing conversation
       
   269      * 
       
   270      */
       
   271     TInt iConversationIndex;
       
   272 
       
   273     /** 
       
   274      * iConversationIndex;
       
   275      * this shall be used to generate row ids for storing conversation
       
   276      * 
       
   277      */
       
   278     TInt iCurrentConversationIndex;
       
   279 };
       
   280 
       
   281 #endif // __C_CS_CONVERSATION_CACHE_HELPER_H