messagingapp/msgappfw/utils/src/ccsclientconversation.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 47 5b14749788d7
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
    39 // Two phase construction
    39 // Two phase construction
    40 // ----------------------------------------------------------------------------
    40 // ----------------------------------------------------------------------------
    41 void CCsClientConversation::ConstructL()
    41 void CCsClientConversation::ConstructL()
    42     {
    42     {
    43     iConversationEntryID = 0;
    43     iConversationEntryID = 0;
    44     iFirstName = NULL;
    44     iDisplayName = NULL;
    45     iLastName = NULL;
       
    46     iContactId = KErrNotFound;
    45     iContactId = KErrNotFound;
    47     iConversationEntry = NULL;
    46     iConversationEntry = NULL;
    48     iUnreadMessagesCount = 0;
    47     iUnreadMessagesCount = 0;
    49     }
    48     }
    50 
    49 
    65 // CCsClientConversation::~CCsClientConversation
    64 // CCsClientConversation::~CCsClientConversation
    66 // Destructor
    65 // Destructor
    67 // ----------------------------------------------------------------------------
    66 // ----------------------------------------------------------------------------
    68 EXPORT_C CCsClientConversation::~CCsClientConversation()
    67 EXPORT_C CCsClientConversation::~CCsClientConversation()
    69     {
    68     {
    70     if (iNickName)
    69     if (iDisplayName)
    71         {
    70         {
    72         delete iNickName;
    71         delete iDisplayName;
    73         iNickName = NULL;
    72         iDisplayName = NULL;
    74         }
       
    75     
       
    76     if (iLastName)
       
    77         {
       
    78         delete iLastName;
       
    79         iLastName = NULL;
       
    80         }
       
    81     if (iFirstName)
       
    82         {
       
    83         delete iFirstName;
       
    84         iFirstName = NULL;
       
    85         }
    73         }
    86     if (iConversationEntry)
    74     if (iConversationEntry)
    87         {
    75         {
    88         delete iConversationEntry;
    76         delete iConversationEntry;
    89         iConversationEntry = NULL;
    77         iConversationEntry = NULL;
   109     {
    97     {
   110     iConversationEntryID = aEnryId;
    98     iConversationEntryID = aEnryId;
   111     }
    99     }
   112 
   100 
   113 // ----------------------------------------------------------------------------
   101 // ----------------------------------------------------------------------------
   114 // CCsClientConversation::GetFirstName
   102 // CCsClientConversation::GetDisplayName
   115 // this shall return the conversation first name of the object
   103 // this shall return the conversation name of the object
   116 // ----------------------------------------------------------------------------
   104 // ----------------------------------------------------------------------------
   117 EXPORT_C HBufC* CCsClientConversation::GetFirstName() const
   105 EXPORT_C HBufC* CCsClientConversation::GetDisplayName() const
   118     {
   106     {
   119     return iFirstName;
   107     return iDisplayName;
   120     }
   108     }
   121 
   109 
   122 // ----------------------------------------------------------------------------
   110 // ----------------------------------------------------------------------------
   123 // CCsClientConversation::SetFirstNameL
   111 // CCsClientConversation::SetDisplayNameL
   124 // this function shall set conversation first name in the object
   112 // this function shall set conversation name in the object
   125 // ----------------------------------------------------------------------------
   113 // ----------------------------------------------------------------------------
   126 EXPORT_C void
   114 EXPORT_C void
   127 CCsClientConversation::SetFirstNameL(const HBufC* aFirstName)
   115 CCsClientConversation::SetDisplayNameL(
   128     {
   116                            const HBufC* aDisplayName)
   129     if (aFirstName)
   117     {
   130         {
   118     if (aDisplayName)
   131         iFirstName = aFirstName->AllocL();
   119         {
   132         }
   120         iDisplayName = aDisplayName->AllocL();
   133     }
       
   134 
       
   135 // ----------------------------------------------------------------------------
       
   136 // CCsClientConversation::GetLastName
       
   137 // this shall return the conversation Last name of the object
       
   138 // ----------------------------------------------------------------------------
       
   139 EXPORT_C HBufC* CCsClientConversation::GetLastName() const
       
   140     {
       
   141     return iLastName;
       
   142     }
       
   143 
       
   144 // ----------------------------------------------------------------------------
       
   145 // CCsClientConversation::SetLastNameL
       
   146 // this function shall set conversation Last name in the object
       
   147 // ----------------------------------------------------------------------------
       
   148 EXPORT_C void
       
   149 CCsClientConversation::SetLastNameL(const HBufC* aLastName)
       
   150     {
       
   151     if (aLastName)
       
   152         {
       
   153         iLastName = aLastName->AllocL();
       
   154         }
       
   155     }
       
   156 
       
   157 // ----------------------------------------------------------------------------
       
   158 // CCsClientConversation::GetNickName
       
   159 // this shall return the conversation nick name of the object
       
   160 // ----------------------------------------------------------------------------
       
   161 EXPORT_C HBufC* CCsClientConversation::GetNickName() const
       
   162     {
       
   163     return iNickName;
       
   164     }
       
   165 
       
   166 // ----------------------------------------------------------------------------
       
   167 // CCsClientConversation::SetNickNameL
       
   168 // this function shall set conversation nick name in the object
       
   169 // ----------------------------------------------------------------------------
       
   170 EXPORT_C void
       
   171 CCsClientConversation::SetNickNameL(const HBufC* aNickName)
       
   172     {
       
   173     if (aNickName)
       
   174         {
       
   175         iNickName = aNickName->AllocL();
       
   176         }
   121         }
   177     }
   122     }
   178 
   123 
   179 // ----------------------------------------------------------------------------
   124 // ----------------------------------------------------------------------------
   180 // CCsClientConversation::GetContactId
   125 // CCsClientConversation::GetContactId
   230     {
   175     {
   231     CCsClientConversation* cloneObject = CCsClientConversation::NewL();
   176     CCsClientConversation* cloneObject = CCsClientConversation::NewL();
   232     CleanupStack::PushL(cloneObject);
   177     CleanupStack::PushL(cloneObject);
   233 
   178 
   234     cloneObject->SetConversationEntryId(iConversationEntryID);
   179     cloneObject->SetConversationEntryId(iConversationEntryID);
   235     cloneObject->SetFirstNameL(iFirstName);
   180     cloneObject->SetDisplayNameL(iDisplayName);
   236     cloneObject->SetLastNameL(iLastName);
       
   237     cloneObject->SetContactId(iContactId);
   181     cloneObject->SetContactId(iContactId);
   238     cloneObject->SetConversationEntryL(iConversationEntry);
   182     cloneObject->SetConversationEntryL(iConversationEntry);
   239     cloneObject->SetUnreadMessageCount(iUnreadMessagesCount);
   183     cloneObject->SetUnreadMessageCount(iUnreadMessagesCount);
   240     
   184     
   241     CleanupStack::Pop(cloneObject);
   185     CleanupStack::Pop(cloneObject);
   251     {
   195     {
   252     // write iConversationEntryID count into the stream
   196     // write iConversationEntryID count into the stream
   253     aStream.WriteInt32L(iConversationEntryID);
   197     aStream.WriteInt32L(iConversationEntryID);
   254     aStream.WriteUint16L(iUnreadMessagesCount);
   198     aStream.WriteUint16L(iUnreadMessagesCount);
   255 
   199 
   256     if (iFirstName)
   200     if (iDisplayName)
   257         {
   201         {
   258         // now write the display name
   202         // now write the display name
   259         aStream.WriteInt8L(iFirstName->Length());
   203         aStream.WriteInt8L(iDisplayName->Length());
   260         aStream << *iFirstName;
   204         aStream << *iDisplayName;
   261         }
       
   262     else
       
   263         {
       
   264         aStream.WriteInt8L(0);
       
   265         }
       
   266     
       
   267     if (iLastName)
       
   268         {
       
   269         // now write the display name
       
   270         aStream.WriteInt8L(iLastName->Length());
       
   271         aStream << *iLastName;
       
   272         }
       
   273     else
       
   274         {
       
   275         aStream.WriteInt8L(0);
       
   276         }
       
   277     
       
   278     if (iNickName)
       
   279         {
       
   280         // now write the display name
       
   281         aStream.WriteInt8L(iNickName->Length());
       
   282         aStream << *iNickName;
       
   283         }
   205         }
   284     else
   206     else
   285         {
   207         {
   286         aStream.WriteInt8L(0);
   208         aStream.WriteInt8L(0);
   287         }
   209         }
   306     // now read the conversation id
   228     // now read the conversation id
   307 
   229 
   308     iConversationEntryID = aStream.ReadInt32L();
   230     iConversationEntryID = aStream.ReadInt32L();
   309     iUnreadMessagesCount = aStream.ReadUint16L();
   231     iUnreadMessagesCount = aStream.ReadUint16L();
   310     // read first name
   232     // read first name
   311     TInt lenFirstname = aStream.ReadInt8L();
   233     TInt lenName = aStream.ReadInt8L();
   312     if (lenFirstname > 0)
   234     if (lenName > 0)
   313         {
   235         {
   314         iFirstName = HBufC::NewL(aStream, lenFirstname);
   236         iDisplayName = HBufC::NewL(aStream, lenName);
   315         }
   237         }
   316     // read last name
   238         
   317     TInt lenLastname = aStream.ReadInt8L();
       
   318     if (lenLastname > 0)
       
   319         {
       
   320         iLastName = HBufC::NewL(aStream, lenLastname);
       
   321         }
       
   322     
       
   323     //read nick name
       
   324     TInt lenNickname = aStream.ReadInt8L();
       
   325     if (lenNickname > 0)
       
   326         {
       
   327         iNickName = HBufC::NewL(aStream, lenNickname);
       
   328         }
       
   329     
       
   330     // read contact link
   239     // read contact link
   331     iContactId = aStream.ReadInt32L();    
   240     iContactId = aStream.ReadInt32L();    
   332         
   241         
   333     //Conversation entry
   242     //Conversation entry
   334     iConversationEntry = CCsConversationEntry::NewL();
   243     iConversationEntry = CCsConversationEntry::NewL();