messagingapp/msgappfw/server/src/ccssession.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
   223             PRINT ( _L("Received function EGetConversationId") )
   223             PRINT ( _L("Received function EGetConversationId") )
   224             GetConversationIdL(aMessage);
   224             GetConversationIdL(aMessage);
   225             break;
   225             break;
   226             
   226             
   227         case EGetConversationIdFromAddress:
   227         case EGetConversationIdFromAddress:
   228             PRINT ( _L("Received function EGetConversationId") )
   228             PRINT ( _L("Received function EGetConversationIdFromAddress") )
   229             GetConversationIdfromAddressL(aMessage);
   229             GetConversationIdfromAddressL(aMessage);
       
   230             break;
       
   231 			
       
   232 		case EGetConversationFromMessageId:
       
   233             PRINT ( _L("Received function EGetConversationFromMessageId") )
       
   234             GetConversationFromMessageIdL(aMessage);
   230             break;
   235             break;
   231 
   236 
   232         case EUserMarkReadConversation:
   237         case EUserMarkReadConversation:
   233             PRINT ( _L("Received function EUserMarkReadConversation") )
   238             PRINT ( _L("Received function EUserMarkReadConversation") )
   234             MarkConversationReadL(aMessage);
   239             MarkConversationReadL(aMessage);
  1403 
  1408 
  1404     aMessage.Write(1, *des);
  1409     aMessage.Write(1, *des);
  1405     aMessage.Complete(EGetConversationIdComplete);
  1410     aMessage.Complete(EGetConversationIdComplete);
  1406     delete des;
  1411     delete des;
  1407 }
  1412 }
       
  1413 
       
  1414 // ----------------------------------------------------------------------------
       
  1415 // GetConversationFromMessageIdL
       
  1416 // ----------------------------------------------------------------------------
       
  1417 void CCsSession::GetConversationFromMessageIdL(const RMessage2& aMessage)
       
  1418     {
       
  1419     // create a new buffer for writing into stream
       
  1420     CBufFlat* buf = CBufFlat::NewL(KBigBuffer);
       
  1421     CleanupStack::PushL(buf);
       
  1422 
       
  1423     RBufWriteStream writeStream(*buf);
       
  1424     writeStream.PushL();
       
  1425 
       
  1426     // Get the message id
       
  1427     TInt messageId = aMessage.Int0();
       
  1428     CCsConversationCache* cache = iServer->ConversationCacheInterface();
       
  1429     CCsClientConversation* conversation = cache->GetConversationFromMessageIdL(messageId);
       
  1430     
       
  1431     // if no conversation exists for given message-id, 
       
  1432     // create a dummy conversation and complete response
       
  1433     if(conversation == NULL)
       
  1434     {
       
  1435         //create dummy conversation
       
  1436         conversation = CCsClientConversation::NewL();
       
  1437         CleanupStack::PushL(conversation);
       
  1438         conversation->SetConversationEntryId(-1);
       
  1439         CCsConversationEntry* entry = CCsConversationEntry::NewL();
       
  1440 		CleanupStack::PushL(entry);
       
  1441         entry->SetEntryId(-1);
       
  1442         conversation->SetConversationEntryL(entry); // clone
       
  1443 		CleanupStack::PopAndDestroy(entry);
       
  1444     }
       
  1445     else
       
  1446     {
       
  1447         CleanupStack::PushL(conversation);
       
  1448     }
       
  1449 
       
  1450     // Externalize 
       
  1451     conversation->ExternalizeL(writeStream);
       
  1452     
       
  1453     // Results are already packed in the stream
       
  1454     writeStream.CommitL();
       
  1455     
       
  1456     // Create a heap descriptor from the buffer
       
  1457     HBufC8* des = HBufC8::NewLC(buf->Size());
       
  1458     CleanupStack::Pop(des);
       
  1459     TPtr8 ptr(des->Des());
       
  1460     buf->Read(0, ptr, buf->Size());
       
  1461     
       
  1462     CleanupStack::PopAndDestroy(3, buf); // conversation, writestream, buf
       
  1463     
       
  1464     aMessage.Write(1, *des);
       
  1465     aMessage.Complete(EGetConversationFromMessageIdComplete);
       
  1466     delete des;
       
  1467     }
       
  1468 
  1408 // ----------------------------------------------------------------------------
  1469 // ----------------------------------------------------------------------------
  1409 // CCsSession::GetConversationIdfromAddressL
  1470 // CCsSession::GetConversationIdfromAddressL
  1410 // ----------------------------------------------------------------------------
  1471 // ----------------------------------------------------------------------------
  1411 void CCsSession::GetConversationIdfromAddressL(const RMessage2& aMessage)
  1472 void CCsSession::GetConversationIdfromAddressL(const RMessage2& aMessage)
  1412 {
  1473 {