|
1 // Copyright (c) 2005-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 // |
|
15 |
|
16 |
|
17 #include "COperatorName.h" |
|
18 |
|
19 /** |
|
20 Factory constructor. |
|
21 |
|
22 @param aController Pointer to MExecAsync object passed to constructor of |
|
23 CISVAPIBase |
|
24 @return Instance of COperatorName class |
|
25 */ |
|
26 COperatorName* COperatorName::NewL(MExecAsync* aController) |
|
27 { |
|
28 COperatorName* self = new(ELeave) COperatorName(aController); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 /** |
|
36 Destructor. |
|
37 Cancels outstanding requests. |
|
38 */ |
|
39 COperatorName::~COperatorName() |
|
40 { |
|
41 Cancel(); |
|
42 } |
|
43 |
|
44 /** |
|
45 Gets the network operator name and stores it in the iOperatorNameV1Pckg |
|
46 package. |
|
47 */ |
|
48 void COperatorName::DoStartRequestL() |
|
49 { |
|
50 _LIT(KDummyAnswerPanic, "COperatorName Get Method"); |
|
51 __ASSERT_ALWAYS(!IsActive(), User::Panic(KDummyAnswerPanic, 1)); |
|
52 iRequestNotify = EFalse; |
|
53 |
|
54 // Retrieve ICC stored information about the currently registered mobile network |
|
55 iTelephony->GetOperatorName(iStatus, iOperatorNameV1Pckg); |
|
56 SetActive(); |
|
57 } |
|
58 |
|
59 /** |
|
60 Constructor. |
|
61 |
|
62 @param aController Pointer to an MExecAsync object passed to constructor of |
|
63 CISVAPIBase |
|
64 */ |
|
65 COperatorName::COperatorName(MExecAsync* aController) |
|
66 : CISVAPIAsync(aController, KOperatorName), |
|
67 iOperatorNameV1Pckg(iOperatorNameV1) |
|
68 { |
|
69 // Empty method |
|
70 } |
|
71 |
|
72 /** |
|
73 Second phase constructor. |
|
74 */ |
|
75 void COperatorName::ConstructL() |
|
76 { |
|
77 // Empty method |
|
78 } |
|
79 |
|
80 /** |
|
81 Checks the status of the active object and prints the operator name to the |
|
82 console if there is no error. |
|
83 */ |
|
84 void COperatorName::RunL() |
|
85 { |
|
86 if(iStatus != KErrNone) |
|
87 { |
|
88 iConsole->Printf(KError); |
|
89 |
|
90 // Print the error status code |
|
91 iConsole->Printf(_L("%d\n"), iStatus.Int()); |
|
92 } |
|
93 else |
|
94 { |
|
95 // Print the output to console if there is no error |
|
96 iConsole->Printf(KOperatorNameMsg); |
|
97 iConsole->Printf(iOperatorNameV1.iOperatorName); |
|
98 iConsole->Printf(KNewLine); |
|
99 ExampleComplete(); |
|
100 } |
|
101 } |
|
102 |
|
103 /** |
|
104 Cancels asynchronous request to CTelephony::GetOperatorName(). |
|
105 */ |
|
106 void COperatorName::DoCancel() |
|
107 { |
|
108 // Cancels an outstanding asynchronous request |
|
109 iTelephony->CancelAsync(CTelephony::EGetOperatorNameCancel); |
|
110 } |
|
111 |