|
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 "CSubscriberId.h" |
|
18 |
|
19 /** |
|
20 Factory constructor. |
|
21 |
|
22 @param aController Pointer to MExecAsync object passed to constructor of |
|
23 CISVAPIBase |
|
24 @return Instance of CSubscriberId class |
|
25 */ |
|
26 CSubscriberId* CSubscriberId::NewL(MExecSync* aController) |
|
27 { |
|
28 CSubscriberId* self = new(ELeave) CSubscriberId(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 CSubscriberId::~CSubscriberId() |
|
40 { |
|
41 Cancel(); |
|
42 } |
|
43 |
|
44 /** |
|
45 Gets the subscriber Id by calling 3rd party API function CTelephony::GetSubscriberId() |
|
46 and stores it in the iSubscripberIdV1Pckg package. |
|
47 */ |
|
48 void CSubscriberId::DoStartRequestL() |
|
49 { |
|
50 // Retrieves information about the mobile device's current subscriber |
|
51 iTelephony->GetSubscriberId(iStatus, iSubscriberIdV1Pckg); |
|
52 SetActive(); |
|
53 } |
|
54 |
|
55 /** |
|
56 Constructor. |
|
57 |
|
58 @param aController Pointer to an MExecAsync object passed to constructor of |
|
59 CISVAPIBase |
|
60 */ |
|
61 CSubscriberId::CSubscriberId(MExecSync* aController) |
|
62 : CISVAPISync(aController, KSubscriberId), |
|
63 iSubscriberIdV1Pckg(iSubscriberIdV1) |
|
64 { |
|
65 // Empty method |
|
66 } |
|
67 |
|
68 /** |
|
69 Second phase constructor. |
|
70 */ |
|
71 void CSubscriberId::ConstructL() |
|
72 { |
|
73 // Empty method |
|
74 } |
|
75 |
|
76 /** |
|
77 Checks the status of the active object and prints the subscriber information to |
|
78 the console if there is no error. |
|
79 */ |
|
80 void CSubscriberId::RunL() |
|
81 { |
|
82 if(iStatus != KErrNone) |
|
83 { |
|
84 iConsole->Printf(KError); |
|
85 |
|
86 // Print the error status code |
|
87 iConsole->Printf(_L("%d\n"), iStatus.Int()); |
|
88 } |
|
89 else |
|
90 { |
|
91 // Print Subscriber Info. |
|
92 TBuf<CTelephony::KIMSISize> subscriberId = iSubscriberIdV1.iSubscriberId; |
|
93 iConsole->Printf(KSubscriberIdMsg); |
|
94 |
|
95 // Print the subscriber information about the phone |
|
96 iConsole->Printf(subscriberId); |
|
97 iConsole->Printf(KNewLine); |
|
98 |
|
99 ExampleComplete(); |
|
100 } |
|
101 } |
|
102 |
|
103 /** |
|
104 Cancels the asynchronous request to CTelephony::GetSubscriberId(). |
|
105 */ |
|
106 void CSubscriberId::DoCancel() |
|
107 { |
|
108 // Cancels an outstanding asynchronous request. |
|
109 iTelephony->CancelAsync(CTelephony::EGetSubscriberIdCancel); |
|
110 } |
|
111 |