|
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 : CSIPSecDigestObserver.cpp |
|
15 // Part of : SIPSec |
|
16 // Version : SIP/6.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "SipLogs.h" |
|
22 #include "CSIPSecDigestObserver.h" |
|
23 #include "CSIPSecDigestCacheEntry.h" |
|
24 |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 |
|
29 // ---------------------------------------------------------------------------- |
|
30 // CSIPSecDigestObserver::CSIPSecDigestObserver |
|
31 // ---------------------------------------------------------------------------- |
|
32 // |
|
33 CSIPSecDigestObserver::CSIPSecDigestObserver( |
|
34 MSIPSecSecurityMechanismObserver& aObserver ) : |
|
35 iPendingOperations( 0 ), |
|
36 iAtLeastOneSuccessfulOperation( EFalse ), |
|
37 iObserver( &aObserver ), |
|
38 iStatus( EWaiting ) |
|
39 { |
|
40 } |
|
41 |
|
42 // ---------------------------------------------------------------------------- |
|
43 // CSIPSecDigestObserver::CSIPSecDigestObserver |
|
44 // ---------------------------------------------------------------------------- |
|
45 // |
|
46 CSIPSecDigestObserver::~CSIPSecDigestObserver() |
|
47 { |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CSIPSecDigestObserver::OperationStarted |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 void CSIPSecDigestObserver::OperationStarted() |
|
55 { |
|
56 ++iPendingOperations; |
|
57 } |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // CSIPSecDigestObserver::OperationCompleted |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 void CSIPSecDigestObserver::OperationCompleted( TStatus aReason, |
|
64 TBool /*aAuthenticated*/ ) |
|
65 { |
|
66 __SIP_INT_LOG1( "SIPSecDigestObs:OperCompl status", aReason ) |
|
67 __ASSERT_ALWAYS( iPendingOperations > 0, |
|
68 User::Panic( _L( "Digest: OpComp no pending ops" ), KErrNotFound ) ); |
|
69 |
|
70 switch ( aReason ) |
|
71 { |
|
72 case EComplete: |
|
73 iAtLeastOneSuccessfulOperation = ETrue; |
|
74 break; |
|
75 |
|
76 case ECancelled: |
|
77 iStatus = aReason; |
|
78 break; |
|
79 |
|
80 case EFailure: |
|
81 if ( iStatus != ECancelled ) |
|
82 { |
|
83 iStatus = aReason; |
|
84 } |
|
85 break; |
|
86 |
|
87 default: // EWaiting |
|
88 User::Panic( _L( "Digest: OpComp waiting" ), KErrArgument ); |
|
89 } |
|
90 |
|
91 if( --iPendingOperations == 0) |
|
92 { |
|
93 // Inform observer also if the challenge was ignored (ECancelled) |
|
94 DoCompleted(); |
|
95 |
|
96 iStatus = EComplete; |
|
97 |
|
98 // Clear the flag, in case CSIPSecDigestObserver will be re-used. |
|
99 iAtLeastOneSuccessfulOperation = EFalse; |
|
100 } |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CSIPSecDigestObserver::IsCompleted |
|
105 // ---------------------------------------------------------------------------- |
|
106 // |
|
107 TBool CSIPSecDigestObserver::IsCompleted() const |
|
108 { |
|
109 return iStatus == EComplete; |
|
110 } |
|
111 |
|
112 // ---------------------------------------------------------------------------- |
|
113 // CSIPSecDigestObserver::DoCompleted |
|
114 // ---------------------------------------------------------------------------- |
|
115 // |
|
116 void CSIPSecDigestObserver::DoCompleted() |
|
117 { |
|
118 __SIP_INT_LOG1( "SIPSecDigestObs:DoCompl, iAtLeastOne", |
|
119 iAtLeastOneSuccessfulOperation ) |
|
120 |
|
121 iObserver->CacheUpdated( iAtLeastOneSuccessfulOperation, ETrue ); |
|
122 |
|
123 __SIP_LOG( "SIPSecDigestObs:DoCompl ends" ) |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // CSIPSecDigestObserver::HasObserver |
|
128 // ---------------------------------------------------------------------------- |
|
129 // |
|
130 TBool CSIPSecDigestObserver::HasObserver( |
|
131 const MSIPSecSecurityMechanismObserver& aObserver ) const |
|
132 { |
|
133 return &aObserver == iObserver; |
|
134 } |