messagingfw/scheduledsendmtm/schedulesendmtm/src/MsvScheduleSettings.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 <msvstd.h>
       
    18 #include <msventry.h>
       
    19 #include <msvschedulesettings.h>
       
    20 #include <schsend_panic.h>
       
    21 
       
    22 /**
       
    23 Allocates and creates a new CMsvScheduleSettings object.
       
    24 
       
    25 @return New object
       
    26 */
       
    27 EXPORT_C CMsvScheduleSettings* CMsvScheduleSettings::NewL()
       
    28 	{
       
    29 	CMsvScheduleSettings* self = CMsvScheduleSettings::NewLC();
       
    30 	CleanupStack::Pop(self); 
       
    31 	return self;
       
    32 	}
       
    33 
       
    34 /**
       
    35 Allocates and creates a new CMsvScheduleSettings object.
       
    36 
       
    37 @return New object
       
    38 */
       
    39 EXPORT_C CMsvScheduleSettings* CMsvScheduleSettings::NewLC()
       
    40 	{
       
    41 	CMsvScheduleSettings* self = new (ELeave) CMsvScheduleSettings();
       
    42 	CleanupStack::PushL(self);
       
    43 	self->ConstructL();
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 void CMsvScheduleSettings::ConstructL()
       
    48 	{
       
    49 	iVariableIntervals = new (ELeave) CArrayFixFlat<TTimeIntervalSeconds>(1);
       
    50 	}
       
    51 
       
    52 /*
       
    53 	Sets all the members to their default value.
       
    54 */
       
    55 CMsvScheduleSettings::CMsvScheduleSettings()
       
    56 	{
       
    57 	Reset();
       
    58 	}
       
    59 
       
    60 /**
       
    61 Destructor.
       
    62 */
       
    63 EXPORT_C CMsvScheduleSettings::~CMsvScheduleSettings()
       
    64 	{
       
    65 	delete iVariableIntervals;
       
    66 	}
       
    67 
       
    68 /**
       
    69 Resets the object.
       
    70 
       
    71 This sets all data members to their default values.
       
    72 */
       
    73 EXPORT_C void CMsvScheduleSettings::Reset()
       
    74 	{
       
    75 	iPriority		= EDefaultPriority;
       
    76 	iValidityPeriod = EDefaultValidityPeriod;
       
    77 	iIntervalType	= (TIntervalType) EDefaultIntervalType;
       
    78 
       
    79 	iShortInterval	= EDefaultShortInterval;
       
    80 	iLongInterval	= EDefaultLongInterval;
       
    81 
       
    82 	iLatency		= EDefaultLatency;
       
    83 	iPendingConditionsTimeout = EDefaultPendingConditionsTimeout;
       
    84 
       
    85 	if (iVariableIntervals)
       
    86 		iVariableIntervals->Reset();
       
    87 	}
       
    88 
       
    89 
       
    90 /**
       
    91 Gets the priority of the messages on the Task Scheduler. 
       
    92 
       
    93 @return Priority value
       
    94 */
       
    95 
       
    96 EXPORT_C TInt CMsvScheduleSettings::Priority() const
       
    97 	{
       
    98 	return iPriority;
       
    99 	}
       
   100 
       
   101 /**
       
   102 Sets the priority of the messages on the Task Scheduler. 
       
   103 
       
   104 @param aPriority
       
   105 Priority value.
       
   106 */
       
   107 
       
   108 EXPORT_C void CMsvScheduleSettings::SetPriority(const TInt aPriority)
       
   109 	{
       
   110 	iPriority = aPriority;
       
   111 	}
       
   112 
       
   113 /**
       
   114 Gets the time period for which the messages are valid on the Task Scheduler. 
       
   115 
       
   116 @return Validity period
       
   117 */
       
   118 EXPORT_C const TTimeIntervalMinutes& CMsvScheduleSettings::ValidityPeriod() const
       
   119 	{
       
   120 	return iValidityPeriod;
       
   121 	}
       
   122 
       
   123 /**
       
   124 Sets the time period for which the messages are valid on the Task Scheduler. 
       
   125 
       
   126 This is ignored if a message has to be sent off-peak.
       
   127 
       
   128 @param aValidityPeriod
       
   129 Validity period.
       
   130 
       
   131 @panic ScheduleSend-DLL 10
       
   132 The validity period is invalid (negative or null).
       
   133 */
       
   134 EXPORT_C void CMsvScheduleSettings::SetValidityPeriod(const TTimeIntervalMinutes& aValidityPeriod)
       
   135 	{
       
   136 	__ASSERT_ALWAYS(aValidityPeriod.Int() > 0, gPanic(EInvalidValidityPeriod));
       
   137 	
       
   138 	iValidityPeriod = aValidityPeriod;
       
   139 	}
       
   140 
       
   141 /**
       
   142 Gets the schedule interval type.
       
   143 
       
   144 @return The schedule interval type
       
   145 */
       
   146 
       
   147 EXPORT_C TIntervalType CMsvScheduleSettings::IntervalType() const
       
   148 	{
       
   149 	return iIntervalType;
       
   150 	}
       
   151 
       
   152 /**
       
   153 Sets the schedule interval type.
       
   154 
       
   155 @param aIntervalType
       
   156 The schedule interval type.
       
   157 */
       
   158 EXPORT_C void CMsvScheduleSettings::SetIntervalType(const TIntervalType aIntervalType)
       
   159 	{
       
   160 	iIntervalType = aIntervalType;
       
   161 	}
       
   162 
       
   163 /**
       
   164 Sets the long retry interval value.
       
   165 
       
   166 This is used by CMsvScheduleSend to determine when to next send the message, 
       
   167 if the TMsvSendErrorAction::iAction equals ESendActionRetryLater and 
       
   168 TMsvSendErrorAction::iRetrySpacing equals ESendRetriesFixed.
       
   169 
       
   170 @param aInterval
       
   171 Long interval value.
       
   172 
       
   173 @panic ScheduleSend-DLL 18
       
   174 The long interval is out of range (negative or null).
       
   175 */
       
   176 EXPORT_C void CMsvScheduleSettings::SetLongInterval(const TTimeIntervalSeconds& aInterval)
       
   177 	{
       
   178 	__ASSERT_ALWAYS(aInterval.Int() > 0, gPanic(ELongIntervalOutOfRange)); //TO DO: Always or Debug only?
       
   179 
       
   180 	iLongInterval = aInterval;
       
   181 	}
       
   182 
       
   183 /**
       
   184 Gets the long retry interval value.
       
   185 
       
   186 @return Long interval value
       
   187 
       
   188 @panic ScheduleSend-DLL 18
       
   189 The long interval is out of range (negative or null).
       
   190 */
       
   191 EXPORT_C const TTimeIntervalSeconds& CMsvScheduleSettings::LongInterval() const
       
   192 	{
       
   193 	__ASSERT_ALWAYS(iLongInterval.Int() > 0, gPanic(ELongIntervalOutOfRange)); //TO DO: Always or Debug only?
       
   194 
       
   195 	return iLongInterval;
       
   196 	}
       
   197 
       
   198 /**
       
   199 Sets the short retry interval value.
       
   200 
       
   201 This is used by CMsvScheduleSend to determine when to next send the message, 
       
   202 if the TMsvSendErrorAction::iAction equals ESendActionRetryImmediately.
       
   203 
       
   204 @param aInterval
       
   205 Short interval value.
       
   206 
       
   207 @panic ScheduleSend-DLL 19
       
   208 The short interval is out of range (negative or null).
       
   209 */
       
   210 EXPORT_C void CMsvScheduleSettings::SetShortInterval(const TTimeIntervalSeconds& aInterval)
       
   211 	{
       
   212 	__ASSERT_ALWAYS(aInterval.Int() > 0, gPanic(EShortIntervalOutOfRange)); //TO DO: Always or Debug only?
       
   213 
       
   214 	iShortInterval = aInterval;
       
   215 	}
       
   216 
       
   217 /**
       
   218 Gets the short retry interval value.
       
   219 
       
   220 @return Short interval value
       
   221 
       
   222 @panic ScheduleSend-DLL 19
       
   223 The short interval is out of range (negative or null).
       
   224 */
       
   225 EXPORT_C const TTimeIntervalSeconds& CMsvScheduleSettings::ShortInterval() const
       
   226 	{
       
   227 	__ASSERT_ALWAYS(iShortInterval.Int() > 0, gPanic(EShortIntervalOutOfRange)); //TO DO: Always or Debug only?
       
   228 
       
   229 	return iShortInterval;
       
   230 	}
       
   231 
       
   232 /**
       
   233 Sets variable retry intervals.
       
   234 
       
   235 @param aIntervals
       
   236 Variable retry intervals.
       
   237 
       
   238 @leave One of the system wide error codes
       
   239 One of the intervals could not be appended to the array holding the variable
       
   240 intervals.
       
   241 
       
   242 @panic ScheduleSend-DLL 20
       
   243 At least one of the intervals is out of range (negative or null).
       
   244 */
       
   245 EXPORT_C void CMsvScheduleSettings::SetVariableIntervalsL(const CArrayFixFlat<TTimeIntervalSeconds>& aIntervals)
       
   246 	{
       
   247 	iVariableIntervals->Reset();
       
   248 
       
   249 	TInt count = aIntervals.Count();
       
   250 
       
   251 	for (TInt curInt = 0; curInt < count; curInt++)
       
   252 		{
       
   253 		TTimeIntervalSeconds interval = aIntervals[curInt];
       
   254 
       
   255 		__ASSERT_ALWAYS(interval.Int() > 0, gPanic(EVariableIntervalOutOfRange)); //TO DO: Always or Debug only?
       
   256 
       
   257 		iVariableIntervals->AppendL(interval);
       
   258 		}
       
   259 	}
       
   260 
       
   261 /**
       
   262 Gets variable retry intervals.
       
   263 
       
   264 This is used by CMsvScheduleSend to determine when to next send the message. 
       
   265 It is only used if TMsvSendErrorAction::iAction equals ESendActionRetryLater 
       
   266 and TMsvSendErrorAction::iRetrySpacing equals ESendRetrySpacingVariable.
       
   267 
       
   268 @return Variable retry intervals
       
   269 */
       
   270 EXPORT_C const CArrayFixFlat<TTimeIntervalSeconds>& CMsvScheduleSettings::VariableIntervals() const
       
   271 	{
       
   272 	return *iVariableIntervals;
       
   273 	}
       
   274 
       
   275 
       
   276 /**
       
   277 Sets the minimum message sending latency.
       
   278 
       
   279 @param aLatency
       
   280 Minimum message sending latency.
       
   281 
       
   282 @panic ScheduleSend-DLL 25
       
   283 The latency is invalid (negative).
       
   284 */
       
   285 EXPORT_C void CMsvScheduleSettings::SetLatency(const TTimeIntervalMicroSeconds32& aLatency)
       
   286 	{
       
   287 	__ASSERT_ALWAYS(aLatency.Int() >= 0, gPanic(ELatencyOutOfRange)); //TO DO: Always or Debug only?
       
   288 
       
   289 	iLatency = aLatency;
       
   290 	}
       
   291 
       
   292 /**
       
   293 Gets the minimum message sending latency.
       
   294 
       
   295 This is the minimum amount of time from the current time that must elapse 
       
   296 before the message is sent. This must be greater than or equal to zero. 
       
   297 
       
   298 If the client specifies that the message should be scheduled in the past, 
       
   299 then CMsvScheduleSend will actually schedule the message in Latency() seconds 
       
   300 from the current time.
       
   301 
       
   302 @return Minimum message sending latency
       
   303 
       
   304 @panic ScheduleSend-DLL 25
       
   305 The latency is invalid (negative).
       
   306 */
       
   307 EXPORT_C const TTimeIntervalMicroSeconds32& CMsvScheduleSettings::Latency() const
       
   308 	{
       
   309 	__ASSERT_ALWAYS(iLatency.Int() >= 0, gPanic(ELatencyOutOfRange)); //TO DO: Always or Debug only?
       
   310 
       
   311 	return iLatency;
       
   312 	}
       
   313 	
       
   314 /**
       
   315 Sets the timeout interval when re-scheduling messages for pending conditions
       
   316 to be met.
       
   317 
       
   318 A value of zero indicates that there is no timeout when pending conditions to 
       
   319 be met. The default value is zero.
       
   320 
       
   321 @param aTimeout
       
   322 The timeout interval in minutes.
       
   323 
       
   324 @panic ScheduleSend-DLL 25
       
   325 The timeout interval is invalid (negative).
       
   326 */
       
   327 EXPORT_C void CMsvScheduleSettings::SetPendingConditionsTimeout(const TTimeIntervalMinutes& aTimeout)
       
   328 	{
       
   329 	__ASSERT_ALWAYS(aTimeout.Int() >= 0, gPanic(EPendingConditionsTimeoutOutOfRange));
       
   330 
       
   331 	iPendingConditionsTimeout = aTimeout;
       
   332 	}
       
   333 
       
   334 /**
       
   335 Gets the timeout interval when re-scheduling messages for pending conditions
       
   336 to be met.
       
   337 
       
   338 A value of zero indicates that there is no timeout when pending conditions to 
       
   339 be met. The default value is zero.
       
   340 
       
   341 @return
       
   342 The timeout interval in minutes.
       
   343 */
       
   344 EXPORT_C const TTimeIntervalMinutes& CMsvScheduleSettings::PendingConditionsTimeout() const
       
   345 	{
       
   346 	return iPendingConditionsTimeout;
       
   347 	}