|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Describes one tracked invitation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CCAInviteTracker.h" |
|
21 #include "CCAInvitation.h" |
|
22 #include "MCAInviteTrackerCallback.h" |
|
23 #include "ChatDebugPrint.h" |
|
24 #include "PrivateEngineDefinitions.h" |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 |
|
28 //----------------------------------------------------------------------------- |
|
29 // CCAInviteTracker::CCAInviteTracker |
|
30 // C++ default constructor can NOT contain any code, that might leave. |
|
31 //----------------------------------------------------------------------------- |
|
32 CCAInviteTracker::CCAInviteTracker( MCAInviteTrackerCallback* aCallback, |
|
33 MCAInvitation* aInvitation ) |
|
34 : CTimer( CActive::EPriorityHigh ), |
|
35 iInvitation( aInvitation ), |
|
36 iCallback( aCallback ) |
|
37 { |
|
38 } |
|
39 |
|
40 //----------------------------------------------------------------------------- |
|
41 // CCAInviteTracker::ConstructL |
|
42 // Symbian OS default constructor can leave. |
|
43 //----------------------------------------------------------------------------- |
|
44 void CCAInviteTracker::ConstructL() |
|
45 { |
|
46 CTimer::ConstructL(); |
|
47 CActiveScheduler::Add( this ); |
|
48 |
|
49 if ( iInvitation ) |
|
50 { |
|
51 iTimeout = iInvitation->Timeout(); |
|
52 |
|
53 CHAT_DP( D_CHAT_LIT( "Reveived invites timeout-value: %d" ), iTimeout ); |
|
54 |
|
55 // If no expiry-information is available, then use our default value |
|
56 if ( iTimeout == 0 ) |
|
57 { |
|
58 iTimeout = KDefaultInviteTimeout; |
|
59 } |
|
60 |
|
61 // Because CTimer can't handle long periods, we must divide total |
|
62 // expiry-time to sub-periods. |
|
63 if ( iTimeout > KInviteTimeoutCycleLength ) |
|
64 { |
|
65 iTimeout = - KInviteTimeoutCycleLength; |
|
66 // timeout value changed from seconds to microseconds |
|
67 After( KInviteTimeoutCycleLength * 1000000 ); |
|
68 } |
|
69 else |
|
70 { |
|
71 TInt timeOut( iTimeout ); |
|
72 iTimeout = 0; |
|
73 // timeout value changed from seconds to microseconds |
|
74 After( timeOut * 1000000 ); |
|
75 } |
|
76 } |
|
77 } |
|
78 |
|
79 //----------------------------------------------------------------------------- |
|
80 // CCAInviteTracker::NewL |
|
81 // Two-phased constructor. |
|
82 //----------------------------------------------------------------------------- |
|
83 CCAInviteTracker* CCAInviteTracker::NewL( MCAInviteTrackerCallback* aCallback, |
|
84 MCAInvitation* aInvitation ) |
|
85 { |
|
86 CCAInviteTracker* self = new ( ELeave ) CCAInviteTracker( aCallback, |
|
87 aInvitation ); |
|
88 |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop( self ); |
|
92 |
|
93 return self; |
|
94 } |
|
95 |
|
96 //----------------------------------------------------------------------------- |
|
97 // CCAInviteTracker::~CCAInviteTracker |
|
98 // Destructor |
|
99 //----------------------------------------------------------------------------- |
|
100 CCAInviteTracker::~CCAInviteTracker() |
|
101 { |
|
102 delete iInvitation; |
|
103 } |
|
104 |
|
105 //----------------------------------------------------------------------------- |
|
106 // CCAInviteTracker::Invitation |
|
107 // ( Other items commented in header ) |
|
108 //----------------------------------------------------------------------------- |
|
109 MCAInvitation* CCAInviteTracker::Invitation() const |
|
110 { |
|
111 return iInvitation; |
|
112 } |
|
113 |
|
114 //----------------------------------------------------------------------------- |
|
115 // CCAInviteTracker::RunL |
|
116 // ( Other items commented in header ) |
|
117 //----------------------------------------------------------------------------- |
|
118 void CCAInviteTracker::RunL() |
|
119 { |
|
120 TInt realTimeout( 0 ); |
|
121 |
|
122 // Sub-period handling |
|
123 if ( iTimeout > KInviteTimeoutCycleLength ) |
|
124 { |
|
125 realTimeout = KInviteTimeoutCycleLength; |
|
126 iTimeout = - KInviteTimeoutCycleLength; |
|
127 CHAT_DP( D_CHAT_LIT( "Invite expiration timer starting new wait: \ |
|
128 %d secs" ), realTimeout ); |
|
129 // timeout value changed from seconds to microseconds |
|
130 After( realTimeout * 1000000 ); |
|
131 } |
|
132 else if ( iTimeout > 0 ) |
|
133 { |
|
134 realTimeout = iTimeout; |
|
135 iTimeout = 0; |
|
136 CHAT_DP( D_CHAT_LIT( "Invite expiration timer starting new wait: %d \ |
|
137 secs" ), realTimeout ); |
|
138 // timeout value changed from seconds to microseconds |
|
139 After( realTimeout * 1000000 ); |
|
140 } |
|
141 else |
|
142 { |
|
143 iCallback->InviteExpiredL( iInvitation ); |
|
144 } |
|
145 } |
|
146 |
|
147 |
|
148 // End of File |