|
1 /* |
|
2 * Copyright (c) 2002 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 of option container. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPhoneGsmOptionContainer.h" |
|
21 #include "PhoneGsmParser.h" |
|
22 #include "CPhoneParserFeatures.h" |
|
23 |
|
24 // CONSTANTS |
|
25 const TInt KPhoneGsmOptionGranularity = 5; |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CPhoneGsmOptionContainer::CPhoneGsmOptionContainer |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CPhoneGsmOptionContainer::CPhoneGsmOptionContainer() |
|
35 { |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CPhoneGsmOptionContainer::ConstructL |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 void CPhoneGsmOptionContainer::ConstructL() |
|
43 { |
|
44 iOptions = |
|
45 new ( ELeave ) COptionArray( KPhoneGsmOptionGranularity ); |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CPhoneGsmOptionContainer::NewL |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CPhoneGsmOptionContainer* CPhoneGsmOptionContainer::NewL() |
|
53 { |
|
54 CPhoneGsmOptionContainer* self = |
|
55 new (ELeave) CPhoneGsmOptionContainer; |
|
56 |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CPhoneGsmOptionContainer::~CPhoneGsmOptionContainer |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CPhoneGsmOptionContainer::~CPhoneGsmOptionContainer() |
|
69 { |
|
70 delete iOptions; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CPhoneGsmOptionContainer::IsOptionDefined |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 TBool CPhoneGsmOptionContainer::IsOptionDefined( |
|
78 TInt aOptionUid ) const |
|
79 { |
|
80 // For two digit calling, we have one option defined |
|
81 // in extension. |
|
82 if ( aOptionUid == KPhoneOptionTwoDigitCalling ) |
|
83 { |
|
84 return ETrue; |
|
85 } |
|
86 |
|
87 TKeyArrayFix key = MakeKey(); |
|
88 TOptionItem option; |
|
89 option.iUid = aOptionUid; |
|
90 TInt index; |
|
91 |
|
92 return !iOptions->FindIsq( option, key, index ); |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CPhoneGsmOptionContainer::FindOptionStatus |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TBool CPhoneGsmOptionContainer::FindOptionStatus( |
|
100 TInt aOptionUid ) const |
|
101 { |
|
102 // For two digit calling, we have one option defined |
|
103 // in extension. |
|
104 if ( aOptionUid == KPhoneOptionTwoDigitCalling ) |
|
105 { |
|
106 return CPhoneParserFeatures::TwoDigitCallingEnabled(); |
|
107 } |
|
108 |
|
109 TKeyArrayFix key = MakeKey(); |
|
110 TOptionItem option; |
|
111 option.iUid = aOptionUid; |
|
112 TInt index; |
|
113 |
|
114 if ( iOptions->FindIsq( option, key, index ) ) |
|
115 { |
|
116 PhoneGsmParser::Panic( PhoneGsmParser::EOptionNotDefined ); |
|
117 } |
|
118 |
|
119 TBool result = iOptions->At( index ).iStatus; |
|
120 return result; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CPhoneGsmOptionContainer::SetOptionStatus |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CPhoneGsmOptionContainer::SetOptionStatus( |
|
128 TInt aOptionUid, |
|
129 TBool aStatus ) |
|
130 { |
|
131 // For two digit calling, we have one option defined |
|
132 // in extension - not allowed to be modified. |
|
133 if ( aOptionUid == KPhoneOptionTwoDigitCalling ) |
|
134 { |
|
135 PhoneGsmParser::Panic( PhoneGsmParser::EIncorrectUse ); |
|
136 } |
|
137 |
|
138 TKeyArrayFix key = MakeKey(); |
|
139 TOptionItem option; |
|
140 option.iUid = aOptionUid; |
|
141 TInt index; |
|
142 |
|
143 if ( iOptions->FindIsq( option, key, index ) ) |
|
144 { |
|
145 PhoneGsmParser::Panic( PhoneGsmParser::EOptionNotDefined ); |
|
146 } |
|
147 |
|
148 iOptions->At( index ).iStatus = aStatus; |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CPhoneGsmOptionContainer::DefineOptionL |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CPhoneGsmOptionContainer::DefineOptionL( |
|
156 TInt aOptionUid, |
|
157 TBool aStatus ) |
|
158 { |
|
159 if ( IsOptionDefined( aOptionUid ) ) |
|
160 { |
|
161 PhoneGsmParser::Panic( PhoneGsmParser::EOptionAlreadyDefined ); |
|
162 } |
|
163 |
|
164 TKeyArrayFix key = MakeKey(); |
|
165 TOptionItem option; |
|
166 option.iUid = aOptionUid; |
|
167 option.iStatus = aStatus; |
|
168 |
|
169 iOptions->InsertIsqL( option, key ); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CPhoneGsmOptionContainer::MakeKey |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TKeyArrayFix CPhoneGsmOptionContainer::MakeKey() |
|
177 { |
|
178 return TKeyArrayFix( _FOFF( TOptionItem, iUid ), ECmpTInt ); |
|
179 } |
|
180 |
|
181 // End of File |