|
1 /* |
|
2 * Copyright (c) 2003 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32svr.h> |
|
21 #include "saepubsubnotifier.h" |
|
22 #include "saeetelobserver.h" |
|
23 #include "saegprsavailabilityobs.h" |
|
24 #include "sae_debug.h" |
|
25 |
|
26 #include <mmtsy_names.h> |
|
27 |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // |
|
34 CSaeEtelObserver::CSaeEtelObserver( CSaePubSubNotifier* aPubSubNotifier ) : |
|
35 iPubSubNotifier( aPubSubNotifier ), |
|
36 iGprsAvailabilityObs( 0 ) |
|
37 { |
|
38 } |
|
39 |
|
40 // EPOC default constructor can leave. |
|
41 void CSaeEtelObserver::ConstructL() |
|
42 { |
|
43 COM_TRACE_( "SAE: CSaeEtelObserver::ConstructL()" ); |
|
44 } |
|
45 |
|
46 // Two-phased constructor. |
|
47 CSaeEtelObserver* CSaeEtelObserver::NewL( CSaePubSubNotifier* aPubSubNotifier ) |
|
48 { |
|
49 CSaeEtelObserver* self = new (ELeave) CSaeEtelObserver( aPubSubNotifier ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // Destructor |
|
57 CSaeEtelObserver::~CSaeEtelObserver() |
|
58 { |
|
59 delete iGprsAvailabilityObs; |
|
60 |
|
61 COM_TRACE_( "SAE: CSaeEtelObserver dtor: RPacketService::Close()" ); |
|
62 iService.Close(); |
|
63 COM_TRACE_( "SAE: CSaeEtelObserver dtor: RPhone::Close()" ); |
|
64 iPhone.Close(); |
|
65 COM_TRACE_( "SAE: CSaeEtelObserver dtor: RTelServer::Close()" ); |
|
66 iEtelServer.Close(); |
|
67 } |
|
68 |
|
69 // Create GPRS session and observers, and start listening for events. |
|
70 TInt CSaeEtelObserver::StartListeningL() |
|
71 { |
|
72 COM_TRACE_( "SAE: CSaeEtelObserver: StartListeningL() START ->" ); |
|
73 TInt err = iEtelServer.Connect(); |
|
74 if( err != KErrNone ) |
|
75 { |
|
76 // Retry |
|
77 User::LeaveIfError( iEtelServer.Connect() ); |
|
78 } |
|
79 |
|
80 COM_TRACE_( "SAE: CSaeEtelObserver: Loading phone module..." ); |
|
81 err = iEtelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
82 |
|
83 COM_TRACE_( "SAE: CSaeEtelObserver: phone module loaded, now opening phone..." ); |
|
84 User::LeaveIfError(iPhone.Open( iEtelServer, KMmTsyPhoneName )); |
|
85 // Assumes RPhone created previously. Create RPacketService sub-session. |
|
86 COM_TRACE_( "SAE: CSaeEtelObserver: phone opened, now opening service..." ); |
|
87 User::LeaveIfError(iService.Open( iPhone )); |
|
88 COM_TRACE_( "SAE: CSaeEtelObserver: service opened" ); |
|
89 |
|
90 // iService.Attach() gets called automatically on context creation, so no |
|
91 // need to call it manually. |
|
92 |
|
93 if( err == KErrNone ) |
|
94 { |
|
95 COM_TRACE_( "SAE: CSaeEtelObserver: trying to create availability observer..." ); |
|
96 iGprsAvailabilityObs = new (ELeave) CSaeGprsAvailabilityObs( this, &iService ); |
|
97 COM_TRACE_( "SAE: CSaeEtelObserver: availability observer created" ); |
|
98 } |
|
99 else |
|
100 { |
|
101 User::Leave(err); |
|
102 } |
|
103 |
|
104 COM_TRACE_( "SAE: CSaeEtelObserver: StartListeningL() <- END" ); |
|
105 return err; |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------- |
|
109 // CSaeEtelObserver::NotifyPubSub |
|
110 // |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 void CSaeEtelObserver::NotifyPubSub( const TUid aVariable, const TInt aState ) |
|
114 { |
|
115 iPubSubNotifier->NotifyPubSub( aVariable, aState ); |
|
116 } |
|
117 // End of File |