|
1 /* |
|
2 * Copyright (c) 2006-2007 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "irdebug.h" |
|
20 #include "irsockettimeouttimer.h" |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // Default constructor |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 CIRSocketTimeOutTimer::CIRSocketTimeOutTimer( const TInt aPriority, |
|
27 MIRSocketTimeoutNotifier& aNotify) : CTimer( aPriority ), |
|
28 iNotify( aNotify ) |
|
29 { |
|
30 // Definition not required |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // Default destructor |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CIRSocketTimeOutTimer::~CIRSocketTimeOutTimer() |
|
38 { |
|
39 // Cancel any pending requests |
|
40 Cancel(); |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Creates the CTimer object |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 void CIRSocketTimeOutTimer::ConstructL() |
|
48 { |
|
49 // Create the Timer |
|
50 CTimer::ConstructL(); |
|
51 // Add the active object active scheduler |
|
52 CActiveScheduler::Add( this ); |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CIRSocketTimeOutTimer::NewL |
|
57 // Creates an object of CIRSocketTimeOutTimer |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CIRSocketTimeOutTimer* CIRSocketTimeOutTimer::NewL( const TInt aPriority, |
|
61 MIRSocketTimeoutNotifier& aNotify ) |
|
62 { |
|
63 CIRSocketTimeOutTimer* self = CIRSocketTimeOutTimer::NewLC( aPriority, |
|
64 aNotify ); |
|
65 CleanupStack::Pop( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CIRSocketTimeOutTimer::NewLC |
|
71 // Creates an object of CIRSocketTimeOutTimer |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CIRSocketTimeOutTimer* CIRSocketTimeOutTimer::NewLC( const TInt aPriority, |
|
75 MIRSocketTimeoutNotifier& aNotify ) |
|
76 { |
|
77 CIRSocketTimeOutTimer* self = new (ELeave) CIRSocketTimeOutTimer( |
|
78 aPriority, aNotify ); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL(); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CIRSocketTimeOutTimer::RunL |
|
86 // Called when the timer expires |
|
87 // This is used to notify the observer that timer has expired |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void CIRSocketTimeOutTimer::RunL() |
|
91 { |
|
92 IRLOG_INFO2( "CIRSocketTimeOutTimer::RunL - Timer expired (%d).", iStatus.Int() ); |
|
93 if( iStatus == KErrNone ) |
|
94 { |
|
95 iNotify.TimerExpired(); |
|
96 } |
|
97 else |
|
98 { |
|
99 User::Leave(iStatus.Int()); |
|
100 } |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CIRSocketTimeOutTimer::RunError |
|
105 // Called if RunL leaves |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 TInt CIRSocketTimeOutTimer::RunError( TInt /*aError*/ ) |
|
109 { |
|
110 // Ignore any timer expiry errors as they are not critical in this case |
|
111 IRLOG_DEBUG( "CIRSocketTimeOutTimer::RunError" ); |
|
112 return KErrNone; |
|
113 } |