messagingfw/scheduledsendmtm/schedulesendmtm/src/MsvEntryScheduleData.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 1999-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 #include <e32base.h>
       
    17 #include <e32std.h>
       
    18 #include <msvstd.h>
       
    19 #include <msventryscheduledata.h>
       
    20 
       
    21 //
       
    22 //
       
    23 //	Type Class TMsvEntryScheduleData
       
    24 //
       
    25 //
       
    26 
       
    27 /**
       
    28 Default constructor.
       
    29 */
       
    30 
       
    31 EXPORT_C TMsvEntryScheduleData::TMsvEntryScheduleData()
       
    32 	{
       
    33 	Reset();
       
    34 	}
       
    35 
       
    36 
       
    37 /**
       
    38 Resets the object.
       
    39 
       
    40 It sets all member data to zero.
       
    41 */
       
    42 
       
    43 EXPORT_C void TMsvEntryScheduleData::Reset()
       
    44 	{
       
    45 	iVersion		= KMsvEntryScheduleDataVersion;
       
    46 	iRetryCount		= 0;
       
    47 	iTaskId			= KErrNotFound; //must not be 0 because Task Scheduler may create a task with id 0
       
    48 	iRef.iHandle	= KErrNotFound; //must not be 0 because Task Scheduler may create a schedule with id 0
       
    49 	}
       
    50 
       
    51 
       
    52 /**
       
    53 Tests if all the members are set to their default value.
       
    54 
       
    55 @return True if all the members are set to their default value.
       
    56 */
       
    57 
       
    58 EXPORT_C TBool TMsvEntryScheduleData::IsReset() const
       
    59 	{
       
    60 	return ((iRetryCount == 0) && (iTaskId == KErrNotFound));
       
    61 	}
       
    62 
       
    63 
       
    64 /**
       
    65 Restores the object from a store.
       
    66 
       
    67 @param aStore
       
    68 Store to read from.
       
    69 */
       
    70 
       
    71 EXPORT_C void TMsvEntryScheduleData::RestoreL(CMsvStore& aStore)
       
    72 	{
       
    73 	Reset();
       
    74 	
       
    75 	if (aStore.IsPresentL(KUidMsvFileScheduleData))
       
    76 		{
       
    77 		RMsvReadStream readStream;
       
    78 		readStream.OpenLC(aStore, KUidMsvFileScheduleData);
       
    79 
       
    80 		//Internalize
       
    81 		InternalizeL(readStream);
       
    82 
       
    83 		CleanupStack::PopAndDestroy(); //readStream
       
    84 		}
       
    85 	}
       
    86 
       
    87 
       
    88 /**
       
    89 Removes the object from a store.
       
    90 
       
    91 @param aStore 
       
    92 Store to remove from.
       
    93 
       
    94 @leave CMsvStore::IsPresentL()
       
    95 @leave CMsvStore::RemoveL()
       
    96 */
       
    97 
       
    98 EXPORT_C void TMsvEntryScheduleData::RemoveL(CMsvStore& aStore) const
       
    99 	{
       
   100 	if (aStore.IsPresentL(KUidMsvFileScheduleData))
       
   101 		{
       
   102 		aStore.RemoveL(KUidMsvFileScheduleData);
       
   103 		}
       
   104 	}
       
   105 
       
   106 
       
   107 /**
       
   108 Stores the object in a store.
       
   109 
       
   110 This method leaves if the the object's data cannot be written to a 
       
   111 RMsvWriteStream stream.
       
   112 
       
   113 @param aStore
       
   114 Store to write to.
       
   115 */
       
   116 
       
   117 EXPORT_C void TMsvEntryScheduleData::StoreL(CMsvStore& aStore) const
       
   118 	{
       
   119 	RMsvWriteStream writeStream;
       
   120 	writeStream.AssignLC(aStore, KUidMsvFileScheduleData);
       
   121 
       
   122 	//Externalize
       
   123 	ExternalizeL(writeStream);
       
   124 
       
   125 	writeStream.CommitL();
       
   126 	CleanupStack::PopAndDestroy(); //writeStream
       
   127 	}
       
   128 
       
   129 
       
   130 /**
       
   131 Externalises the object to the specified stream.
       
   132 
       
   133 @param aWriteStream
       
   134 Stream to write to.
       
   135 */
       
   136 
       
   137 void TMsvEntryScheduleData::ExternalizeL(RWriteStream& aWriteStream) const
       
   138 	{
       
   139 	aWriteStream.WriteInt16L(iVersion);
       
   140 	aWriteStream.WriteInt32L(iRetryCount);
       
   141 	aWriteStream.WriteInt32L(iTaskId);
       
   142 	aWriteStream.WriteInt32L(iRef.iHandle);
       
   143 	aWriteStream << iRef.iName;
       
   144 	}
       
   145 
       
   146 
       
   147 /**
       
   148 Internalises the object from the specified stream.
       
   149 
       
   150 @param aReadStream
       
   151 Stream to read from.
       
   152 */
       
   153 
       
   154 void TMsvEntryScheduleData::InternalizeL(RReadStream& aReadStream)
       
   155 	{
       
   156 	iVersion		= aReadStream.ReadInt16L();
       
   157 
       
   158 	if (iVersion >= 1)
       
   159 		{
       
   160 		iRetryCount		= aReadStream.ReadInt32L();
       
   161 		iTaskId			= aReadStream.ReadInt32L();
       
   162 		iRef.iHandle	= aReadStream.ReadInt32L();
       
   163 		aReadStream >> iRef.iName;
       
   164 		}
       
   165 	}
       
   166 
       
   167 
       
   168 /**
       
   169 Gets how many retries have been made to send this message.
       
   170 
       
   171 @return Number of retries.
       
   172 */
       
   173 
       
   174 EXPORT_C TInt TMsvEntryScheduleData::Retries() const
       
   175 	{
       
   176 	return iRetryCount;
       
   177 	}
       
   178 
       
   179 
       
   180 /**
       
   181 Adds one to the value of the iRetryCount member.
       
   182 */
       
   183 
       
   184 EXPORT_C void TMsvEntryScheduleData::IncreaseRetries()
       
   185 	{
       
   186 	iRetryCount++;
       
   187 	}
       
   188 
       
   189 
       
   190 /**
       
   191 Sets the iRetryCount member to zero.
       
   192 */
       
   193 
       
   194 EXPORT_C void TMsvEntryScheduleData::ResetRetries()
       
   195 	{
       
   196 	iRetryCount = 0;
       
   197 	}
       
   198