|
1 /* |
|
2 * Copyright (c) 2005 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: General Active Object offering asynchronous service |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "atcodec.h" |
|
19 #include "btmcprotocol.h" |
|
20 #include "btmcnumber.h" |
|
21 #include <mmtsy_names.h> |
|
22 #include "debug.h" |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CBtmcNumber::NewL |
|
26 // ----------------------------------------------------------------------------- |
|
27 CBtmcNumber* CBtmcNumber::NewL( |
|
28 MBtmcActiveObserver& aObserver, |
|
29 CBtmcProtocol& aProtocol, |
|
30 CActive::TPriority aPriority, |
|
31 TInt aServiceId) |
|
32 { |
|
33 CBtmcNumber* self = new (ELeave) CBtmcNumber(aObserver, aProtocol, aPriority, aServiceId); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CBtmcNumber::~CBtmcNumber |
|
42 // ----------------------------------------------------------------------------- |
|
43 CBtmcNumber::~CBtmcNumber() |
|
44 { |
|
45 TRACE_FUNC_ENTRY |
|
46 Cancel(); |
|
47 iStore.Close(); |
|
48 iPhone.Close(); |
|
49 iServer.UnloadPhoneModule(KMmTsyModuleName); |
|
50 iServer.Close(); |
|
51 TRACE_FUNC_EXIT |
|
52 } |
|
53 |
|
54 // ------------------------------------------------------------------------------- |
|
55 // CBtmcNumber::GoActive |
|
56 // ------------------------------------------------------------------------------- |
|
57 void CBtmcNumber::GoActive() |
|
58 { |
|
59 TRACE_ASSERT(!IsActive(), KErrGeneral); |
|
60 iEntry.iIndex = 1; |
|
61 iStore.Read(iStatus, iPckg); |
|
62 SetActive(); |
|
63 TRACE_FUNC |
|
64 } |
|
65 |
|
66 // ------------------------------------------------------------------------------- |
|
67 // CBtmcNumber::RunL |
|
68 // ------------------------------------------------------------------------------- |
|
69 void CBtmcNumber::RunL() |
|
70 { |
|
71 TRACE_FUNC_ENTRY |
|
72 |
|
73 RATResultPtrArray resarr; |
|
74 ATObjArrayCleanupResetAndDestroyPushL(resarr); |
|
75 CATResult* okerr = NULL; |
|
76 if (iStatus == KErrNone) |
|
77 { |
|
78 TBuf8<RMobileONStore::KOwnNumberTextSize> nameBuf; |
|
79 nameBuf.Copy(iEntry.iNumber.iTelNumber); |
|
80 |
|
81 TRACE_INFO((_L8("ao status %d, phonebook returned %S"), iStatus.Int(), &nameBuf)) |
|
82 RATParamArray params; |
|
83 CleanupClosePushL(params); |
|
84 LEAVE_IF_ERROR(params.Append(TATParam())) |
|
85 LEAVE_IF_ERROR(params.Append(TATParam(nameBuf, EATDQStringParam))) |
|
86 |
|
87 TBTMonoATPhoneNumberType numType; |
|
88 if (nameBuf.Length() == 0) |
|
89 { |
|
90 numType = EBTMonoATPhoneNumberUnavailable; |
|
91 } |
|
92 else if(nameBuf.Locate('+') == 0) |
|
93 { |
|
94 numType = EBTMonoATPhoneNumberInternational; |
|
95 } |
|
96 else |
|
97 { |
|
98 numType = EBTMonoATPhoneNumberNational; |
|
99 } |
|
100 LEAVE_IF_ERROR(params.Append(TATParam(numType))) |
|
101 LEAVE_IF_ERROR(params.Append(TATParam())) |
|
102 LEAVE_IF_ERROR(params.Append(TATParam(4))) |
|
103 CATResult* code = CATResult::NewL(EATCNUM, EATActionResult, ¶ms); |
|
104 CleanupStack::PushL(code); |
|
105 resarr.AppendL(code); |
|
106 CleanupStack::Pop(code); |
|
107 CleanupStack::PopAndDestroy(¶ms); |
|
108 okerr = CATResult::NewL(EATOK); |
|
109 } |
|
110 else |
|
111 { |
|
112 okerr = CATResult::NewL(EATERROR); |
|
113 } |
|
114 CleanupStack::PushL(okerr); |
|
115 resarr.AppendL(okerr); |
|
116 CleanupStack::Pop(okerr); |
|
117 iProtocol.SendResponseL(resarr); |
|
118 CleanupStack::PopAndDestroy(&resarr); |
|
119 Observer().RequestCompletedL(*this, iStatus.Int()); |
|
120 TRACE_FUNC_EXIT |
|
121 } |
|
122 |
|
123 // ------------------------------------------------------------------------------- |
|
124 // CBtmcNumber::DoCancel |
|
125 // ------------------------------------------------------------------------------- |
|
126 void CBtmcNumber::DoCancel() |
|
127 { |
|
128 iStore.CancelAsyncRequest(EMobilePhoneStoreRead); |
|
129 TRACE_FUNC |
|
130 } |
|
131 |
|
132 |
|
133 // ------------------------------------------------------------------------------- |
|
134 // CBtmcNumber::RunError |
|
135 // ------------------------------------------------------------------------------- |
|
136 TInt CBtmcNumber::RunError(TInt /*aErr*/) |
|
137 { |
|
138 TRACE_FUNC |
|
139 return KErrNone; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CBtmcNumber::CBtmcNumber |
|
144 // ----------------------------------------------------------------------------- |
|
145 CBtmcNumber::CBtmcNumber( |
|
146 MBtmcActiveObserver& aObserver, |
|
147 CBtmcProtocol& aProtocol, |
|
148 CActive::TPriority aPriority, |
|
149 TInt aServiceId) |
|
150 : CBtmcActive(aObserver, aPriority, aServiceId), iProtocol(aProtocol), iPckg(iEntry) |
|
151 { |
|
152 } |
|
153 |
|
154 void CBtmcNumber::ConstructL() |
|
155 { |
|
156 TRACE_FUNC_ENTRY |
|
157 LEAVE_IF_ERROR(iServer.Connect()); |
|
158 iServer.LoadPhoneModule(KMmTsyModuleName); |
|
159 LEAVE_IF_ERROR(iPhone.Open(iServer, KMmTsyPhoneName)); |
|
160 LEAVE_IF_ERROR(iStore.Open(iPhone));//, KETelIccMsisdnPhoneBook)); |
|
161 TRACE_FUNC_EXIT |
|
162 } |
|
163 |
|
164 // End of File |