messagingapp/msgappfw/server/src/ccsconversationcache.cpp
changeset 52 12db4185673b
parent 44 36f374c67aa8
equal deleted inserted replaced
44:36f374c67aa8 52:12db4185673b
   198             conversationCount );
   198             conversationCount );
   199     }
   199     }
   200 
   200 
   201 // ----------------------------------------------------------------------------
   201 // ----------------------------------------------------------------------------
   202 // CCsConversationCache::GetConversationsL
   202 // CCsConversationCache::GetConversationsL
       
   203 // Get segment of  conversations for a given conversation Id, knownIndex and page size.
       
   204 // The return list is set inside aConversationEntryList and aTotalConversationCount
       
   205 // has total conversation count.
       
   206 // ----------------------------------------------------------------------------
       
   207 void 
       
   208 CCsConversationCache::GetConversationsL(
       
   209         const CCsClientConversation*  aClientConversation,
       
   210         RPointerArray<CCsConversationEntry>* aConversationEntryList,
       
   211         TInt aKnownIndex,
       
   212         TInt aPageSize,
       
   213         TInt& aTotalConversationCount)
       
   214     {
       
   215     TInt conversationCount = iConversationList->Count();
       
   216 
       
   217     // Get the entry id from Client Conversation for which conversations are required
       
   218     TCsConversationEntryID conversationEntryID =
       
   219         aClientConversation->GetConversationEntryId();
       
   220 
       
   221     for (TInt loop= 0; loop < conversationCount; loop++ )
       
   222         {
       
   223         //match entry ID;
       
   224         CCsConversation* conversation =
       
   225             static_cast<CCsConversation*>((*iConversationList)[loop]);
       
   226         
       
   227         if(conversationEntryID == conversation->GetConversationId())
       
   228             {
       
   229             TInt endIndex = conversation->GetEntryCount();
       
   230             TInt startIndex(0);
       
   231             if((aKnownIndex!= 0) || (aPageSize !=0 ))
       
   232                 {
       
   233                 endIndex = endIndex- aKnownIndex;
       
   234                 startIndex = endIndex - aPageSize;
       
   235                 if( startIndex < 0 ) startIndex = 0;
       
   236                 }
       
   237             // Search the conversation id and get the list inside
       
   238             // No need to check, becz it is initialize here only.
       
   239             conversation->GetEntryListL(aConversationEntryList,
       
   240                     startIndex,endIndex);
       
   241             // May, meanwhile new conversation cached.
       
   242             aTotalConversationCount = conversation->GetEntryCount();
       
   243             break;
       
   244             }
       
   245         }
       
   246     PRINT1 ( _L("CCsConversationCache::GetConversationsL - conversationCount:%d"),
       
   247             conversationCount );
       
   248     }
       
   249 // ----------------------------------------------------------------------------
       
   250 // CCsConversationCache::GetConversationsL
   203 // Get All Conversations for a given conversation Id
   251 // Get All Conversations for a given conversation Id
   204 // the return list is set inside aConversationEntryList
   252 // the return list is set inside aConversationEntryList
   205 // ----------------------------------------------------------------------------
   253 // ----------------------------------------------------------------------------
   206 void CCsConversationCache::GetConversationsL(
   254 void CCsConversationCache::GetConversationsL(
   207                                              const CCsClientConversation* aClientConversation,
   255                                              const CCsClientConversation* aClientConversation,
   687 // CCsConversationCache::GetConversationFromMessageIdL
   735 // CCsConversationCache::GetConversationFromMessageIdL
   688 // ---------------------------------------------------------------------------
   736 // ---------------------------------------------------------------------------
   689 CCsClientConversation* CCsConversationCache::GetConversationFromMessageIdL(TInt aMessageId)
   737 CCsClientConversation* CCsConversationCache::GetConversationFromMessageIdL(TInt aMessageId)
   690 {
   738 {
   691     TInt conversationCount = iConversationList->Count();
   739     TInt conversationCount = iConversationList->Count();
   692 
   740     CCsClientConversation *clientConv = NULL;
   693     for ( TInt loop = 0; loop < conversationCount; loop++ )
   741     for ( TInt loop = 0; loop < conversationCount; loop++ )
   694     {
   742     {
   695         CCsConversation* conversation =
   743         CCsConversation* conversation =
   696             static_cast<CCsConversation*>((*iConversationList)[loop]);
   744             static_cast<CCsConversation*>((*iConversationList)[loop]);
   697 
   745 
   702         for ( TInt loop1 = 0; loop1 < entryList.Count(); loop1++ )
   750         for ( TInt loop1 = 0; loop1 < entryList.Count(); loop1++ )
   703         {
   751         {
   704             TInt messageId = entryList[loop1]->EntryId();
   752             TInt messageId = entryList[loop1]->EntryId();
   705             if ( messageId == aMessageId )
   753             if ( messageId == aMessageId )
   706             {
   754             {
   707                 CCsClientConversation *clientConv = CreateClientConvLC(conversation, entryList[loop1]);
   755                 clientConv = CreateClientConvLC(conversation, entryList[loop1]);
   708                 CleanupStack::Pop();
   756                 CleanupStack::Pop();
   709                 return clientConv;
   757                 break;
   710             }
   758             }
   711         }
   759         }
   712     }
   760     }
   713     return NULL;
   761     return clientConv;
   714 }
   762 }
   715 
   763 
   716 //end of file
   764 //end of file