|
1 /* |
|
2 * Copyright (c) 2007 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: PSM Server message |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <psmtypes.h> |
|
20 #include "psmsrvmessage.h" |
|
21 #include "psmmanager.h" |
|
22 #include "psmsettingsprovider.h" |
|
23 #include "psmclientserver.h" |
|
24 #include "psmtrace.h" |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CPsmMessage::NewL |
|
28 // Two-phased constructor. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CPsmMessage* CPsmMessage::NewL( CPsmManager& aPsmManager ) |
|
32 { |
|
33 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::NewL()" ) ) ); |
|
34 |
|
35 CPsmMessage* self = CPsmMessage::NewLC( aPsmManager ); |
|
36 CleanupStack::Pop( self ); |
|
37 |
|
38 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::NewL - return 0x%x" ), self ) ); |
|
39 |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CPsmMessage::NewLC |
|
45 // Two-phased constructor. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CPsmMessage* CPsmMessage::NewLC( CPsmManager& aPsmManager ) |
|
49 { |
|
50 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::NewLC()" ) ) ); |
|
51 |
|
52 CPsmMessage* self = new( ELeave ) CPsmMessage( aPsmManager ); |
|
53 |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 |
|
57 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::NewLC - return 0x%x" ), self ) ); |
|
58 |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CPsmMessage::CPsmMessage |
|
64 // C++ default constructor can NOT contain any code, that |
|
65 // might leave. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CPsmMessage::CPsmMessage( CPsmManager& aPsmManager ) : |
|
69 iPsmManager( aPsmManager ) |
|
70 { |
|
71 // Nothing to do |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CPsmMessage::ConstructL |
|
76 // Symbian 2nd phase constructor can leave. |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CPsmMessage::ConstructL() |
|
80 { |
|
81 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::ConstructL()" ) ) ); |
|
82 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::ConstructL - return" ) ) ); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // Initializes the message |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CPsmMessage::Initialize(const RMessage2& aMessage) |
|
90 { |
|
91 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::Initialize()" ) ) ); |
|
92 |
|
93 if ( iMessage.Handle() ) |
|
94 { |
|
95 ERROR_TRACE( ( _L( "PSM Server - CPsmMessage::Initialize - ERROR: Previous message not completed, canceling it" ) ) ); |
|
96 iMessage.Complete( KErrCancel ); |
|
97 } |
|
98 |
|
99 iMessage = aMessage; |
|
100 |
|
101 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::Initialize - return") ) ); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // Destructor |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 CPsmMessage::~CPsmMessage() |
|
109 { |
|
110 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::~CPsmMessage()" ) ) ); |
|
111 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::~CPsmMessage - return") ) ); |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // Completes the message |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CPsmMessage::Complete( TInt aReason ) const |
|
119 { |
|
120 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::Complete(%d)" ), aReason ) ); |
|
121 |
|
122 if ( iMessage.Handle() ) |
|
123 { |
|
124 iMessage.Complete( aReason ); |
|
125 } |
|
126 else |
|
127 { |
|
128 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::Complete - No handle!" ) ) ); |
|
129 } |
|
130 |
|
131 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::Complete - return" ) ) ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CPsmMessage::NotifyPsmModeChangeComplete |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CPsmMessage::NotifyPsmModeChangeComplete( const TInt aError ) |
|
139 { |
|
140 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::NotifyPsmModeChangeComplete()" ) ) ); |
|
141 |
|
142 // Complete message with error code if request is pending for PSM change to |
|
143 // complete or if error code is other than KErrNone |
|
144 if ( KErrNone != aError ) |
|
145 { |
|
146 Complete( aError ); |
|
147 } |
|
148 else |
|
149 { |
|
150 // Request is pending notification about PSM change, complete with mode |
|
151 Complete( iPsmManager.SettingsProvider().Mode() ); |
|
152 } |
|
153 |
|
154 COMPONENT_TRACE( ( _L( "PSM Server - CPsmMessage::NotifyPsmModeChangeComplete - return" ) ) ); |
|
155 } |
|
156 |
|
157 // End of file |