|
1 /* |
|
2 * Copyright (c) 2010 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: Implementation of server core class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "posindicatorservercore.h" |
|
19 #include "posindicatorserversession.h" |
|
20 #include "posindicatorserverconst.h" |
|
21 #include "posindicatorlogger.h" |
|
22 |
|
23 // Priorty of server |
|
24 // This number has its origin in Symbian development. |
|
25 // The priority of a server active object should be 950. |
|
26 enum |
|
27 { |
|
28 EPriority=950 |
|
29 }; |
|
30 |
|
31 //--------------------------------------------------------------- |
|
32 // CPosIndicatorServerCore::NewLC |
|
33 //--------------------------------------------------------------- |
|
34 CPosIndicatorServerCore* CPosIndicatorServerCore::NewLC() |
|
35 { |
|
36 FUNC("CPosIndicatorServerCore::NewLC"); |
|
37 CPosIndicatorServerCore* self = new( ELeave ) |
|
38 CPosIndicatorServerCore; |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL(); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 //--------------------------------------------------------------- |
|
46 // CPosIndicatorServerCore::CPosIndicatorServerCore |
|
47 //--------------------------------------------------------------- |
|
48 CPosIndicatorServerCore::CPosIndicatorServerCore( |
|
49 TServerType aServerType ): |
|
50 CServer2( EPriority,aServerType ), |
|
51 iSessionCount( 0 ) |
|
52 { |
|
53 FUNC("CPosIndicatorServerCore::CPosIndicatorServerCore"); |
|
54 } |
|
55 |
|
56 //--------------------------------------------------------------- |
|
57 // CPosIndicatorServerCore::~CPosIndicatorServerCore |
|
58 //--------------------------------------------------------------- |
|
59 CPosIndicatorServerCore::~CPosIndicatorServerCore() |
|
60 { |
|
61 FUNC("CPosIndicatorServerCore::~CPosIndicatorServerCore"); |
|
62 delete iLocationRequestor; |
|
63 iLocationRequestor = NULL; |
|
64 } |
|
65 |
|
66 //--------------------------------------------------------------- |
|
67 // CPosIndicatorServerCore::StartL |
|
68 //--------------------------------------------------------------- |
|
69 void CPosIndicatorServerCore::StartL(const TDesC &aName) |
|
70 { |
|
71 FUNC("CPosIndicatorServerCore::StartL"); |
|
72 CServer2::StartL(aName); |
|
73 } |
|
74 |
|
75 //--------------------------------------------------------------- |
|
76 // CPosIndicatorServerCore::ConstructL |
|
77 //--------------------------------------------------------------- |
|
78 void CPosIndicatorServerCore::ConstructL() |
|
79 { |
|
80 FUNC("CPosIndicatorServerCore::ConstructL"); |
|
81 iLocationRequestor = CPosIndicatorLocationRequestor::NewL(); |
|
82 } |
|
83 |
|
84 //--------------------------------------------------------------- |
|
85 // CPosIndicatorServerCore::NewSessionL |
|
86 //--------------------------------------------------------------- |
|
87 CSession2* CPosIndicatorServerCore::NewSessionL( const TVersion& aVersion, |
|
88 const RMessage2& /*aMessage*/ ) const |
|
89 { |
|
90 FUNC("CPosIndicatorServerCore::NewSessionL"); |
|
91 // Check if we're the right version |
|
92 TVersion version( KMajorVersionNumber, |
|
93 KMinorVersionNumber, |
|
94 KBuildVersionNumber ); |
|
95 if (!User::QueryVersionSupported(version, aVersion)) |
|
96 { |
|
97 User::Leave(KErrNotSupported); |
|
98 } |
|
99 CPosIndicatorServerSession* session = CPosIndicatorServerSession::NewL( *this ); |
|
100 iSessionCount++; |
|
101 return session; |
|
102 } |
|
103 |
|
104 //--------------------------------------------------------------- |
|
105 // CPosIndicatorServerCore::GetLocationRequestorHandle |
|
106 //--------------------------------------------------------------- |
|
107 CPosIndicatorLocationRequestor* CPosIndicatorServerCore:: |
|
108 GetLocationRequestorHandle() const |
|
109 { |
|
110 FUNC("CPosIndicatorServerCore::GetLocationRequestorHandle"); |
|
111 return iLocationRequestor; |
|
112 } |
|
113 |
|
114 //--------------------------------------------------------------- |
|
115 // CPosIndicatorServerCore::HandleSessionClosure |
|
116 //--------------------------------------------------------------- |
|
117 void CPosIndicatorServerCore::HandleSessionClosure() const |
|
118 { |
|
119 FUNC("CPosIndicatorServerCore::HandleSessionClosure"); |
|
120 // If all the sessions are closed, server should exit. |
|
121 // This can be achieved by stop the active scheduler. |
|
122 iSessionCount--; |
|
123 |
|
124 // Check the count of session iterator |
|
125 if( !iSessionCount ) |
|
126 { |
|
127 CActiveScheduler::Stop(); |
|
128 } |
|
129 } |
|
130 |
|
131 |
|
132 // End of file. |