|
1 // Copyright (c) 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 // This contains CActiveCommandStore which store one and only one solicited active at command and a number of active |
|
15 // unsolicited at commands |
|
16 // |
|
17 |
|
18 #include "activecommandstore.h" |
|
19 #include "mslogger.h" |
|
20 |
|
21 //const TInt KLtsyActiveCommandStoreReserve = 5; |
|
22 |
|
23 CActiveCommandStore* CActiveCommandStore::NewL() |
|
24 { |
|
25 LOGTEXT(_L8("[Ltsy] Starting CActiveCommandStore::NewL()")); |
|
26 CActiveCommandStore *self = CActiveCommandStore::NewLC(); |
|
27 CleanupStack::Pop(self); |
|
28 return self; |
|
29 } |
|
30 |
|
31 CActiveCommandStore* CActiveCommandStore::NewLC() |
|
32 { |
|
33 LOGTEXT(_L8("[Ltsy] Starting CActiveCommandStore::NewLC()")); |
|
34 CActiveCommandStore *self = new (ELeave) CActiveCommandStore; |
|
35 CleanupStack::PushL(self); |
|
36 self->ConstructL(); |
|
37 return self; |
|
38 } |
|
39 |
|
40 CActiveCommandStore::~CActiveCommandStore() |
|
41 { |
|
42 LOGTEXT(_L8("[Ltsy] Starting CActiveCommandStore::~CActiveCommandStore()")); |
|
43 iArray.Close(); |
|
44 } |
|
45 |
|
46 CActiveCommandStore::CActiveCommandStore() |
|
47 { |
|
48 LOGTEXT(_L8("[Ltsy] Starting CActiveCommandStore::CActiveCommandStore()")); |
|
49 } |
|
50 |
|
51 void CActiveCommandStore::ConstructL() |
|
52 { |
|
53 LOGTEXT(_L8("[Ltsy] Starting CActiveCommandStore::ConstructL()")); |
|
54 iArray.Reset(); |
|
55 iArray.AppendL(NULL); |
|
56 //iArray.ReserveL(KLtsyActiveCommandStoreReserve); |
|
57 LOGTEXT2(_L8("[Ltsy] Active Store Count = %d"), iArray.Count()); |
|
58 } |
|
59 |
|
60 TInt CActiveCommandStore::AddUnsolicitedAtCommand(CAtCommandBase *aAtCommand) |
|
61 { |
|
62 LOGTEXT(_L8("[Ltsy] Starting CActiveCommandStore::AddUnsolicitedAtCommand()")); |
|
63 if (aAtCommand == NULL) |
|
64 { |
|
65 return KErrArgument; |
|
66 } |
|
67 |
|
68 TInt nRes(KErrNone); |
|
69 nRes = iArray.Append(aAtCommand); |
|
70 LOGTEXT2(_L8("[Ltsy] Active Store Count = %d"), iArray.Count()); |
|
71 return nRes; |
|
72 } |
|
73 |
|
74 TInt CActiveCommandStore::AddSolicitedAtCommand(CAtCommandBase *aAtCommand) |
|
75 { |
|
76 LOGTEXT(_L8("[Ltsy] Starting CActiveCommandStore::AddSolicitedAtCommand()")); |
|
77 if (aAtCommand == NULL) |
|
78 { |
|
79 return KErrArgument; |
|
80 } |
|
81 |
|
82 iArray[0] = aAtCommand; |
|
83 LOGTEXT2(_L8("[Ltsy] Active Store Count = %d"), iArray.Count()); |
|
84 return KErrNone; |
|
85 } |
|
86 |
|
87 TInt CActiveCommandStore::RemoveActiveAtCommand(const CAtCommandBase *aAtCommand) |
|
88 { |
|
89 LOGTEXT(_L8("[Ltsy] Starting CActiveCommandStore::RemoveActiveAtCommand()")); |
|
90 if (aAtCommand == NULL) |
|
91 { |
|
92 return KErrArgument; |
|
93 } |
|
94 |
|
95 TInt nFind = iArray.Find(aAtCommand); |
|
96 if (nFind != KErrNotFound) |
|
97 { |
|
98 if (nFind == 0) |
|
99 { |
|
100 iArray[0] = NULL; |
|
101 } |
|
102 else |
|
103 { |
|
104 iArray.Remove(nFind); |
|
105 } |
|
106 return KErrNone; |
|
107 } |
|
108 else |
|
109 { |
|
110 return KErrNotFound; |
|
111 } |
|
112 } |
|
113 |
|
114 RPointerArray<CAtCommandBase>& CActiveCommandStore::GetActiveCommandArray() |
|
115 { |
|
116 return iArray; |
|
117 } |
|
118 |
|
119 //End of file |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |