examples/SFExamples/symbian_os_communications_programming_book_v2/chapter8/receivingmessages/CMessageSummaryGenerator.cpp

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:
00015 // 
00016 
00017 #include "CMessageSummaryGenerator.h"
00018 #include "summaryscreenlog.h"
00019 
00020 // Get the message summary list that has already been generated
00021 const RArray<TMessageSummary>& CMessageSummaryGenerator::MessageSummaries() const
00022         {
00023         return iMessageSummaries;
00024         }
00025 
00026 
00027 CMessageSummaryGenerator::CMessageSummaryGenerator(TMsvId aInboxEntry,
00028                                                                 TUid aMessageType,
00029                                                                 CMsvEntry& aMessagingEntry) : iMessagingEntry(aMessagingEntry),
00030                                                                                                                                 iInboxEntry(aInboxEntry),
00031                                                                                                                                 iMessageType(aMessageType)
00032         {
00033 
00034         }
00035 
00036 void CMessageSummaryGenerator::StartL(TRequestStatus& aStatus)
00037         {
00038         LOG(">> CMessageSummaryGenerator::StartL(TRequestStatus& aStatus)");
00039         aStatus = KRequestPending;
00040         
00041         iMessageSummaries.Reset();
00042         // Set the CMsvEntry to point to the appropriate inbox, this will be the
00043         // global inbox for SMS or the remote POP3 inbox for email.
00044         iMessagingEntry.SetEntryL(iInboxEntry);
00045         // Get a list of the messages in the selected inbox of the type we are looking for (e.g. SMS or email)
00046         CMsvEntrySelection* filteredMessageIds = iMessagingEntry.ChildrenWithMtmL(iMessageType);
00047         CleanupStack::PushL(filteredMessageIds);
00048 
00049         // Calculate the number of messages to summarise
00050         TInt numberForSummary = filteredMessageIds->Count();
00051         if (numberForSummary > KMaxSummaryMessages)
00052                 numberForSummary = KMaxSummaryMessages;
00053         
00054         TInt index;
00055         TMsvEntry tempDataEntry;
00056         for (index = 0; index < numberForSummary; index++)
00057                 // Generate the message summaries
00058                 {
00059                 // Get the TMsvEntry data for the message at the current index.
00060                 tempDataEntry = iMessagingEntry.ChildDataL((*filteredMessageIds)[index]);
00061                 
00062                 // Copy the message details from TMsvEntry to the message summary structure (TMessageSummary)
00063                 TMessageSummary summary;
00064                 
00065                 summary.iFrom = tempDataEntry.iDetails.Left(KMaxSummaryStringSize - 9);
00066                 summary.iSummaryText = tempDataEntry.iDescription.Left(KMaxSummaryStringSize);
00067 
00068                 iMessageSummaries.AppendL(summary);
00069                 }
00070         
00071         TRequestStatus* status = &aStatus;
00072         User::RequestComplete(status, KErrNone);
00073         
00074         CleanupStack::Pop(filteredMessageIds);
00075 
00076         LOG("<< CMessageSummaryGenerator::StartL(TRequestStatus& aStatus)");
00077         }
00078 
00079 CMessageSummaryGenerator::~CMessageSummaryGenerator()
00080         {
00081         iMessageSummaries.Close();
00082         }

Generated by  doxygen 1.6.2