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

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 #ifndef _CMESSAGESUMMARYGENERATOR_H
00018 #define _CMESSAGESUMMARYGENERATOR_H
00019 
00020 #include <e32base.h>
00021 #include <e32cons.h>
00022 
00023 #include <msvstd.h>
00024 #include <msvapi.h>
00025 #include <msvids.h>
00026 
00027 #include <smut.h> // For SMS message ID
00028 
00029 
00033 
00034 // The maximum number of messages of a particular type to include in the summary
00035 const TInt KMaxSummaryMessages = 3;
00036 
00037 // The maximum number of characters to include from each message in the summary
00038 const TInt KMaxSummaryStringSize = 20;
00039 
00040 // How far the subject is indented into the summary screen
00041 const TInt KSubjectIndent = 15;
00042 
00043 
00044 struct TMessageSummary
00045         {
00046         TBuf<KMaxSummaryStringSize> iFrom;
00047         TBuf<KMaxSummaryStringSize> iSummaryText;
00048         };
00049 
00050 class CMessageSummaryGenerator : public CBase
00051         {
00052 public:
00053         CMessageSummaryGenerator(TMsvId aInboxEntry,
00054                                                                 TUid aMessageType,
00055                                                                 CMsvEntry& aMessagingEntry);
00056                                                                                                                                 
00057         // Extract the appropriate message details into iMessageSummaries
00058         // Completes with KErrNone when done
00059         void StartL(TRequestStatus& aStatus);
00060 
00061         // Get the message summary list that has already been generated
00062         const RArray<TMessageSummary>& MessageSummaries() const;
00063         
00064         // If the new message is of the appropriate type and is in the appropriate inbox
00065         // then update the message summary.
00066         // Returns ETrue if the message is added.
00067         // Returns EFalse if the message is of the wrong type or in the wrong folder.
00068         inline TBool MessageOfCorrectType(const TMsvEntry& aEntry) const;
00069 
00070         ~CMessageSummaryGenerator();
00071 
00072 private:
00073         // Returns an EFalse if there are no more messages to summarise
00074         TBool SummariseNextMessage();
00075         
00076 private:
00077         CMsvEntry& iMessagingEntry;
00078         TMsvId iInboxEntry;
00079         TUid iMessageType;
00080         
00081 private:
00082         RArray<TMessageSummary> iMessageSummaries;
00083         };
00084 
00085 
00086 
00087 // If the new message is of the appropriate type and is in the appropriate inbox
00088 // then update the message summary.
00089 // Returns ETrue if the message is added.
00090 // Returns EFalse if the message is of the wrong type or in the wrong folder.
00091 TBool CMessageSummaryGenerator::MessageOfCorrectType(const TMsvEntry& aEntry) const
00092         {
00093         if ((aEntry.Parent() == iInboxEntry) // Is the message in the appropriate inbox?
00094                 && (aEntry.iMtm == iMessageType)) // Is the message of the appropriate type?
00095                 return ETrue;
00096         else
00097                 return EFalse;          
00098         }
00099 
00100 #endif
00101 

Generated by  doxygen 1.6.2