|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Implementation class is used to get function call from SIP Server. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "musavasipobserver.h" |
|
21 #include "musavasipadapter.h" |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <sipservertransaction.h> |
|
25 // ----------------------------------------------------------------------------- |
|
26 // Two-phased constructor. |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 CMusAvaSipObserver* CMusAvaSipObserver::NewL() |
|
30 { |
|
31 CMusAvaSipObserver* self = new (ELeave) CMusAvaSipObserver(); |
|
32 CleanupStack::PushL (self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop( self ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // C++ destructor. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CMusAvaSipObserver::~CMusAvaSipObserver() |
|
43 { |
|
44 iObservers.Reset(); |
|
45 iObservers.Close(); |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // Symbian second-phase constructor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CMusAvaSipObserver::ConstructL() |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // C++ constructor. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CMusAvaSipObserver::CMusAvaSipObserver() |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // A SIP request has been received from the network. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CMusAvaSipObserver::IncomingRequest( |
|
69 TUint32 aIapId, |
|
70 CSIPServerTransaction* aTransaction ) |
|
71 { |
|
72 for( TInt i=0; i<iObservers.Count(); i++ ) |
|
73 { |
|
74 TInt retval( KErrNotFound ); |
|
75 retval = iObservers[i]->IncomingRequest( aIapId, |
|
76 aTransaction ); |
|
77 if( retval == KErrNone) |
|
78 { |
|
79 return; |
|
80 } |
|
81 } |
|
82 delete aTransaction; |
|
83 } |
|
84 // ----------------------------------------------------------------------------- |
|
85 // The received SIP request time-outed and it is invalid i.e. cannot be used |
|
86 // anymore. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CMusAvaSipObserver::TimedOut(CSIPServerTransaction& aTransaction ) |
|
90 { |
|
91 for( TInt i=0; i<iObservers.Count(); i++ ) |
|
92 { |
|
93 TInt retval( KErrNotFound ); |
|
94 retval = iObservers[i]->TimedOut( aTransaction ); |
|
95 if( retval == KErrNone) |
|
96 { |
|
97 return; |
|
98 } |
|
99 } |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CMusAvaSipObserver::AddObserverL( MMusAvaSipAdapter& aAdapter, TInt aIndex ) |
|
107 { |
|
108 TInt index = iObservers.Find( &aAdapter ); |
|
109 |
|
110 if( index == KErrNotFound ) |
|
111 { |
|
112 if ( aIndex > KErrNotFound && aIndex < iObservers.Count() ) |
|
113 { |
|
114 iObservers.InsertL( &aAdapter, aIndex ); |
|
115 } |
|
116 else |
|
117 { |
|
118 iObservers.AppendL( &aAdapter ); |
|
119 } |
|
120 } |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CMusAvaSipObserver::RemoveObserver( MMusAvaSipAdapter& aAdapter ) |
|
128 { |
|
129 TInt index = iObservers.Find( &aAdapter ); |
|
130 |
|
131 if( index != KErrNotFound ) |
|
132 { |
|
133 iObservers.Remove( index ); |
|
134 } |
|
135 } |
|
136 |