|
1 // Copyright (c) 2007-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 // Name : TimerValues.cpp |
|
15 // Part of : TransactionUser |
|
16 // Version : SIP/6.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "TimerValues.h" |
|
22 |
|
23 const TInt KBitsToShiftToMultiplyBy64 = 6; |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // TTimerValues::TTimerValues |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 TTimerValues::TTimerValues( TUint aT1, TUint aT2, TUint aT4 ) : |
|
30 iT1( aT1 ), |
|
31 iT2( aT2 ), |
|
32 iT4( aT4 ) |
|
33 { |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // TTimerValues::TTimerValues |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 TTimerValues::TTimerValues() : iT1( 0 ), iT2( 0 ), iT4( 0 ) |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // TTimerValues::CheckValuesL |
|
46 // If T1 is larger than T2, T1 wouldn't affect retransmissions at all, it would |
|
47 // only affect the transaction timeout duration. |
|
48 // It doesn't make sense to set T1, T2 or T4 with a zero value. |
|
49 // If T1 is very large, calculating 64*T1 with Duration64xT1 would be too large |
|
50 // to fit into TUint. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 TBool TTimerValues::CheckValues() const |
|
54 { |
|
55 return ( iT1 <= iT2 ) && |
|
56 ( iT1 > 0 ) && |
|
57 ( iT2 > 0 ) && |
|
58 ( iT4 > 0 ) && |
|
59 ( iT1 <= ( KMaxTUint >> KBitsToShiftToMultiplyBy64 ) ); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // TTimerValues::DoubleUptoT2 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void TTimerValues::DoubleUptoT2( TUint& aDuration ) const |
|
67 { |
|
68 if ( aDuration == 0 ) |
|
69 { |
|
70 aDuration = iT1; |
|
71 } |
|
72 else |
|
73 { |
|
74 aDuration = aDuration << 1; |
|
75 } |
|
76 |
|
77 if ( aDuration > iT2 ) |
|
78 { |
|
79 aDuration = iT2; |
|
80 } |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // TTimerValues::Duration64xT1 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 TUint TTimerValues::Duration64xT1() const |
|
88 { |
|
89 return iT1 << KBitsToShiftToMultiplyBy64; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // TTimerValues::T1 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 TUint TTimerValues::T1() const |
|
97 { |
|
98 return iT1; |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // TTimerValues::T2 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 TUint TTimerValues::T2() const |
|
106 { |
|
107 return iT2; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // TTimerValues::T4 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 TUint TTimerValues::T4() const |
|
115 { |
|
116 return iT4; |
|
117 } |