|
1 /* |
|
2 * Copyright (c) 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: Implements the class CSPCallArray |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <etelmm.h> |
|
20 |
|
21 #include "cspcallarray.h" |
|
22 #include "csplogger.h" |
|
23 #include "cspcall.h" |
|
24 #include "cspconsts.h" |
|
25 |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CSPCallArray::NewL. |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CSPCallArray* CSPCallArray::NewL( ) |
|
32 { |
|
33 CSPLOGSTRING(CSPOBJECT, |
|
34 "CSPCallArray::NewL()" ); |
|
35 CSPCallArray* self = new ( ELeave ) CSPCallArray( ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // Destructs the array including remaining calls. |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CSPCallArray::~CSPCallArray( ) |
|
44 { |
|
45 CSPLOGSTRING(CSPOBJECT, |
|
46 "CSPCallArray::~CSPCallArray()" ); |
|
47 TInt callCount = iCallArray.Count(); |
|
48 CSPLOGSTRING2(CSPOBJECT, "CSPCallArray::~CSPCallArray() calls %d", callCount); |
|
49 |
|
50 for (TInt callIndex = 0; callIndex < callCount; callIndex++) |
|
51 { |
|
52 CSPCall* call = iCallArray[ callIndex ]; |
|
53 delete call; |
|
54 } |
|
55 |
|
56 iCallArray.Reset(); |
|
57 iCallArray.Close(); |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // From MCSPCallInformation |
|
62 // Iterates through call objects finding the call matching the given name. |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 CSPCall* CSPCallArray::FindCall( const TName& aCallName ) |
|
66 { |
|
67 CSPLOGSTRING(CSPINT, "CSPCallArray::FindCall()"); |
|
68 |
|
69 TInt callCount = iCallArray.Count(); |
|
70 for (TInt callIndex = 0; callIndex < callCount; callIndex++) |
|
71 { |
|
72 |
|
73 CSPCall* call = iCallArray[ callIndex ]; |
|
74 if ( call ) |
|
75 { |
|
76 TName currentCallName; |
|
77 call->CallName( currentCallName ); |
|
78 if ( currentCallName.Compare( aCallName ) == 0 ) |
|
79 { |
|
80 CSPLOGSTRING(CSPINT, "CSPCallArray::FindCall() OK"); |
|
81 return call; |
|
82 } |
|
83 } |
|
84 } |
|
85 |
|
86 CSPLOGSTRING(CSPINT, "CSPCallArray::FindCall() NOT FOUND"); |
|
87 return NULL; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CSPCallArray::Add |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 TInt CSPCallArray::Add(CSPCall* aCall ) |
|
95 { |
|
96 CSPLOGSTRING(CSPINT, "CSPCallArray::Add()"); |
|
97 return iCallArray.Append( aCall ); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CSPCallArray::Remove |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 TInt CSPCallArray::Remove(CSPCall* aCall ) |
|
105 { |
|
106 CSPLOGSTRING(CSPINT, "CSPCallArray::Remove()"); |
|
107 TInt index = iCallArray.Find( aCall ); |
|
108 if ( index != KErrNotFound ) |
|
109 { |
|
110 iCallArray.Remove( index ); |
|
111 return KErrNone; |
|
112 } |
|
113 CSPLOGSTRING(CSPINT, "CSPCallArray::Remove() NOT FOUND"); |
|
114 return KErrNotFound; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CSPCallArray::GetCallCount |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 TInt CSPCallArray::GetCallCount( ) |
|
122 { |
|
123 return iCallArray.Count(); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CSPCallArray::Get |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 CSPCall* CSPCallArray::Get( TInt aIndex ) |
|
131 { |
|
132 return iCallArray[aIndex]; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // Constructs the monitor. |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 CSPCallArray::CSPCallArray() |
|
140 { |
|
141 CSPLOGSTRING(CSPOBJECT, |
|
142 "CSPCallArray::CSPCallArray()" ); |
|
143 } |
|
144 |
|
145 // End of File |