email/imap4mtm/imapsession/src/cimapfolderinfo.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 #include "cimapfolderinfo.h"
       
    18 
       
    19 #include "imappaniccodes.h"
       
    20 
       
    21 EXPORT_C CImapFolderInfo* CImapFolderInfo::NewL()
       
    22 // static method
       
    23 	{
       
    24 	CImapFolderInfo* self = new(ELeave)CImapFolderInfo();
       
    25 	return self;
       
    26 	}
       
    27 	
       
    28 CImapFolderInfo::~CImapFolderInfo()
       
    29 	{
       
    30 	delete iName;
       
    31 	iExpungedMessages.Close();
       
    32 	}
       
    33 
       
    34 EXPORT_C void CImapFolderInfo::SetMsvId(TMsvId aMsvId)
       
    35 	{
       
    36 	iMsvId = aMsvId;
       
    37 	}
       
    38 EXPORT_C TMsvId CImapFolderInfo::MsvId() const
       
    39 	{
       
    40 	return iMsvId;
       
    41 	}
       
    42 	
       
    43 EXPORT_C void CImapFolderInfo::SetNameL(const TDesC& aName)
       
    44 	{
       
    45 	HBufC* name = aName.AllocL();
       
    46 	delete iName;
       
    47 	iName = name;
       
    48 	}
       
    49 EXPORT_C const TDesC& CImapFolderInfo::Name() const
       
    50 	{
       
    51 	return iName ? *iName : KNullDesC();
       
    52 	}
       
    53 
       
    54 void CImapFolderInfo::SetExists(TInt aExists)
       
    55 	{
       
    56 	iExists = aExists;
       
    57 	}
       
    58 EXPORT_C TInt CImapFolderInfo::Exists() const
       
    59 	{
       
    60 	return iExists;
       
    61 	}
       
    62 
       
    63 EXPORT_C void CImapFolderInfo::SetRecent(TInt aRecent)
       
    64 	{
       
    65 	iRecent = aRecent;
       
    66 	}
       
    67 EXPORT_C TInt CImapFolderInfo::Recent() const
       
    68 	{
       
    69 	return iRecent;
       
    70 	}
       
    71 
       
    72 /**
       
    73 Appends the message sequence number to the array of expunged messages,
       
    74 and decrements the overall message count.
       
    75 */	
       
    76 void CImapFolderInfo::AddExpungedMessageL(TUint aMessageSequenceNumber)
       
    77 	{
       
    78 	iExpungedMessages.AppendL(aMessageSequenceNumber);
       
    79 	--iExists;
       
    80 	
       
    81 	__ASSERT_DEBUG(iExists >= 0, TImapServerPanic::ImapPanic(TImapServerPanic::EFolderInfoNegativeExistsCount));
       
    82 	}
       
    83 
       
    84 EXPORT_C void CImapFolderInfo::ResetExpungedMessages()
       
    85 	{
       
    86 	iExpungedMessages.Reset();
       
    87 	}
       
    88 
       
    89 /**
       
    90 @return A read-only version of the expunged message array.
       
    91 */
       
    92 EXPORT_C const RArray<TUint> CImapFolderInfo::ExpungedMessages()
       
    93 	{
       
    94 	return iExpungedMessages;
       
    95 	}
       
    96 
       
    97 /**
       
    98 Sets to ETrue when the IMAP server has indicated that the flags of one or more messages has changed.
       
    99 Resets to EFalse in order to wait for the next server notification.
       
   100 @param aMessageFlagsChanged Whether the IMAP server has recently indicated that the flags of one or more messages has changed.
       
   101 */
       
   102 EXPORT_C void CImapFolderInfo::SetMessageFlagsChanged(TBool aMessageFlagsChanged)
       
   103 	{
       
   104 	iMessageFlagsChanged = aMessageFlagsChanged;
       
   105 	}
       
   106 	
       
   107 /**
       
   108 @return Whether the IMAP server has recently indicated that the flags of one or more messages has changed.
       
   109 */
       
   110 EXPORT_C TBool CImapFolderInfo::MessageFlagsChanged() const
       
   111 	{
       
   112 	return iMessageFlagsChanged;
       
   113 	}
       
   114 
       
   115 /**
       
   116 Returns the value of iUnseen 
       
   117 The meaning of this value depends upon the context in which it is being used.
       
   118 In response to a SELECT command, iUnseen is the ID of the first unseen message
       
   119 See section 7.1 of RFC 3501.
       
   120 The CImapFolderInfo object returned by CImapSession::SelectedFolderInfo() will always 
       
   121 have this meaning.
       
   122 In response to a STATUS command, iUnseen is the number of unseen messages.
       
   123 See section 6.3.10 of RFC 3501.
       
   124 The CImapFolderInfo object populated by CImapSession::StatusL() will always 
       
   125 have this meaning.
       
   126 @return the value of iUnseen.
       
   127 */
       
   128 void CImapFolderInfo::SetUnseen(TUint aUnseen)
       
   129 	{
       
   130 	iUnseen = aUnseen;
       
   131 	}
       
   132 EXPORT_C TUint CImapFolderInfo::Unseen() const
       
   133 	{
       
   134 	return iUnseen;
       
   135 	}
       
   136 
       
   137 void CImapFolderInfo::SetUidNext(TUint aUidNext)
       
   138 	{
       
   139 	iUidNext = aUidNext;
       
   140 	}
       
   141 EXPORT_C TUint CImapFolderInfo::UidNext() const
       
   142 	{
       
   143 	return iUidNext;
       
   144 	}
       
   145 
       
   146 void CImapFolderInfo::SetUidValidity(TUint aUidValidity)
       
   147 	{
       
   148 	iUidValidity = aUidValidity;
       
   149 	}
       
   150 EXPORT_C TUint CImapFolderInfo::UidValidity() const
       
   151 	{
       
   152 	return iUidValidity;
       
   153 	}
       
   154 
       
   155 void CImapFolderInfo::SetMessages(TInt aMessages)
       
   156 	{
       
   157 	iMessages = aMessages;
       
   158 	}
       
   159 	
       
   160 EXPORT_C TInt CImapFolderInfo::Messages() const
       
   161 	{
       
   162 	return iMessages;
       
   163 	}
       
   164 
       
   165 void CImapFolderInfo::SetReadWrite(TBool aMailboxWritable)
       
   166 	{
       
   167 	 iMailboxWritable = aMailboxWritable;
       
   168 	}
       
   169 	
       
   170 EXPORT_C TBool CImapFolderInfo::GetReadWrite() const
       
   171 	{
       
   172 	return iMailboxWritable;
       
   173 	}
       
   174 	
       
   175 /**
       
   176 Set the flag identified by aFlagId to the value of aValue.
       
   177 @param aFlagId Identifies which flag to set.
       
   178 @param aValue The value to apply to the flag.
       
   179 */
       
   180 void CImapFolderInfo::SetFlag(TIMapMailboxFlags aFlagId, TBool aValue)
       
   181 	{
       
   182 	if (aValue)
       
   183 		{
       
   184 		iFlags |= aFlagId;
       
   185 		}
       
   186 	else
       
   187 		{
       
   188 		iFlags &= ~aFlagId;
       
   189 		}
       
   190 	}
       
   191 	
       
   192 /**
       
   193 Retrieve the value of the flag identified by aFlagId.
       
   194 @param aFlagId Identifies which flag to query.
       
   195 @return The value of the querried flag.
       
   196 */
       
   197 EXPORT_C TBool CImapFolderInfo::QueryFlag(TIMapMailboxFlags aFlagId) const
       
   198 	{
       
   199 	return iFlags & aFlagId;
       
   200 	}