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