messagingapp/msgappfw/server/src/ccsconversationcachehelper.cpp
changeset 37 518b245aa84c
parent 25 84d9eb65b26f
child 41 25fe1fe642e3
equal deleted inserted replaced
25:84d9eb65b26f 37:518b245aa84c
    27 #include "ccsconversation.h"
    27 #include "ccsconversation.h"
    28 #include "ccsconversationentry.h"
    28 #include "ccsconversationentry.h"
    29 #include "ccsconversationevent.h"
    29 #include "ccsconversationevent.h"
    30 #include "ccscontactsmanager.h"
    30 #include "ccscontactsmanager.h"
    31 #include "ccscontactsresolver.h"
    31 #include "ccscontactsresolver.h"
    32 #include "s60qconversions.h"
    32 #include <xqconversions.h>
    33 #include "ccsdebug.h"
    33 #include "ccsdebug.h"
    34 
    34 
    35 // ============================== MEMBER FUNCTIONS ============================
    35 // ============================== MEMBER FUNCTIONS ============================
    36 
    36 
    37 // ----------------------------------------------------------------------------
    37 // ----------------------------------------------------------------------------
   329     {
   329     {
   330         HBufC* Contact = ConvEntry->Contact();
   330         HBufC* Contact = ConvEntry->Contact();
   331         if (Contact)
   331         if (Contact)
   332         {
   332         {
   333             QString contactAddress =
   333             QString contactAddress =
   334                     S60QConversions::s60DescToQString(Contact->Des());
   334                     XQConversions::s60DescToQString(Contact->Des());
   335 
   335 
   336             iConversationCache->ContactsManager()->resolver()->resolveContact(contactAddress,
   336             iConversationCache->ContactsManager()->resolver()->resolveContact(contactAddress,
   337                                                                               contactDetail);
   337                                                                               contactDetail);
   338 
   338 
   339             int contactId = contactDetail.contactId;
   339             int contactId = contactDetail.contactId;
   343             {
   343             {
   344                 // Add as new conversation
   344                 // Add as new conversation
   345                 HBufC* displayName = NULL;
   345                 HBufC* displayName = NULL;
   346                 if(!contactDetail.displayName.isEmpty())
   346                 if(!contactDetail.displayName.isEmpty())
   347                 {
   347                 {
   348                     displayName=S60QConversions::qStringToS60Desc(contactDetail.displayName);
   348                     displayName=XQConversions::qStringToS60Desc(contactDetail.displayName);
   349                 }
   349                 }
   350                 TRAPD(error, AddNewConversationL( aConverastionEvent->
   350                 TRAPD(error, AddNewConversationL( aConverastionEvent->
   351                                 ClientConversation()->GetConversationEntry(),
   351                                 ClientConversation()->GetConversationEntry(),
   352                                 contactId,
   352                                 contactId,
   353                                 displayName));
   353                                 displayName));
   537             // check if all entries are deleted then 
   537             // check if all entries are deleted then 
   538             // delete the conversation from cache
   538             // delete the conversation from cache
   539             if (conversation->GetEntryCount() == 0
   539             if (conversation->GetEntryCount() == 0
   540                     && !conversation->IsSpecialConversation())
   540                     && !conversation->IsSpecialConversation())
   541             {
   541             {
   542                 conversationList->Remove(loop);
   542             
   543                 delete conversation;
   543             conversationList->Remove(loop);
   544                 //reset the counters
   544             delete conversation;
   545                 loop -= 1;
   545             //reset the counters
       
   546             loop -= 1;
   546             }
   547             }
   547 
   548 
   548             // Stop searching    
   549             // Stop searching    
   549             if (stopOnFirstMatch) break;
   550             if (stopOnFirstMatch) break;
   550         }
   551         }
   570 
   571 
   571     // add the conversation entry
   572     // add the conversation entry
   572     conversation->AddEntryL(aConversationEntry);
   573     conversation->AddEntryL(aConversationEntry);
   573 
   574 
   574     // fill firstname and lastname and contact Id
   575     // fill firstname and lastname and contact Id
   575     conversation->AddContactDetailsL(aContactId,
   576     if(aDisplayName)
   576                                      *aDisplayName);
   577    		conversation->AddContactDetailsL(aContactId,
       
   578                                      aDisplayName);
   577 
   579 
   578     // fill the phone number
   580     // fill the phone number
   579     if (aConversationEntry->Contact())
   581     if (aConversationEntry->Contact())
   580     {
   582     {
   581         conversation->AddContactDetailsL(* (aConversationEntry->Contact()));
   583         conversation->AddContactDetailsL(* (aConversationEntry->Contact()));
   596         clientConv->GetConversationEntry()->
   598         clientConv->GetConversationEntry()->
   597         ChangeAttributes(ECsAttributeNewEntryAdded,ECsAttributeNone);
   599         ChangeAttributes(ECsAttributeNewEntryAdded,ECsAttributeNone);
   598         }
   600         }
   599 
   601 
   600     iConversationCache->NotifyL(clientConv, KConversationListEventNew);
   602     iConversationCache->NotifyL(clientConv, KConversationListEventNew);
       
   603     // send the new conversation event as well, so that if there are nay listeners for the cv
       
   604     // then they will get the notification.
       
   605     iConversationCache->NotifyL(clientConv, KConversationEventNew);
   601     CleanupStack::PopAndDestroy(clientConv);
   606     CleanupStack::PopAndDestroy(clientConv);
   602 
   607 
   603     CleanupStack::Pop(conversation);
   608     CleanupStack::Pop(conversation);
   604 
   609 
   605     PRINT ( _L("CCsConversationCacheHelper::AddNewConversationL - Conversation Added") );
   610     PRINT ( _L("CCsConversationCacheHelper::AddNewConversationL - Conversation Added") );