|
1 /* |
|
2 * Copyright (c) 2006-2009 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: An interface to Location Manager server |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <f32file.h> |
|
19 #include <s32mem.h> |
|
20 #include <data_caging_path_literals.hrh> |
|
21 |
|
22 #include <rlocationmanager.h> |
|
23 #include <locationeventdef.h> |
|
24 #include "locationmanagerdefs.h" |
|
25 #include "locationmanagerdebug.h" |
|
26 |
|
27 // -------------------------------------------------------------------------- |
|
28 // LaunchServer |
|
29 // Launches the server. |
|
30 // -------------------------------------------------------------------------- |
|
31 // |
|
32 TInt LaunchServer() |
|
33 { |
|
34 LOG( "RLocationManager::LaunchServer begin" ); |
|
35 TParse parser; |
|
36 parser.Set( KLocServerFileName, &KDC_PROGRAMS_DIR, NULL ); |
|
37 |
|
38 // DLL launch |
|
39 RProcess server; |
|
40 const TInt ret = server.Create( parser.FullName(), KNullDesC ); |
|
41 |
|
42 if ( ret != KErrNone ) // Loading failed. |
|
43 { |
|
44 return ret; |
|
45 } |
|
46 |
|
47 TRequestStatus status( KErrNone ); |
|
48 server.Rendezvous( status ); |
|
49 |
|
50 if ( status != KRequestPending ) |
|
51 { |
|
52 LOG( "RLocationManager::LaunchServer Failed" ); |
|
53 server.Kill( 0 ); // Abort startup. |
|
54 server.Close(); |
|
55 return KErrGeneral; |
|
56 } |
|
57 else |
|
58 { |
|
59 server.Resume(); // Logon OK - start the server. |
|
60 } |
|
61 |
|
62 User::WaitForRequest( status ); |
|
63 server.Close(); |
|
64 LOG( "RLocationManager::LaunchServer end" ); |
|
65 return status.Int(); |
|
66 } |
|
67 |
|
68 // -------------------------------------------------------------------------- |
|
69 // RLocationManager::RLocationManager |
|
70 // C++ Constructor |
|
71 // -------------------------------------------------------------------------- |
|
72 // |
|
73 EXPORT_C RLocationManager::RLocationManager() |
|
74 { |
|
75 iNameBuf = NULL; |
|
76 } |
|
77 |
|
78 // -------------------------------------------------------------------------- |
|
79 // RLocationManager::Connect |
|
80 // Creates connection to server |
|
81 // -------------------------------------------------------------------------- |
|
82 // |
|
83 EXPORT_C TInt RLocationManager::Connect() |
|
84 { |
|
85 LOG( "RLocationManager::Connect(), begin" ); |
|
86 TInt ret = CreateSession( KLocServerName, Version(), KSessionSlotCount); |
|
87 if ( ret != KErrNone ) |
|
88 { |
|
89 ret = LaunchServer(); |
|
90 if ( ret == KErrNone ) |
|
91 { |
|
92 ret = CreateSession( KLocServerName, Version() ); |
|
93 } |
|
94 } |
|
95 LOG( "RLocationManager::Connect(), end" ); |
|
96 return ret; |
|
97 } |
|
98 |
|
99 // -------------------------------------------------------------------------- |
|
100 // RLocationManager::Close |
|
101 // -------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C void RLocationManager::Close() |
|
104 { |
|
105 LOG( "RLocationManager::Close(), begin" ); |
|
106 // close session |
|
107 delete iNameBuf; |
|
108 iNameBuf = NULL; |
|
109 RSessionBase::Close(); |
|
110 LOG( "RLocationManager::Close(), end" ); |
|
111 } |
|
112 |
|
113 // -------------------------------------------------------------------------- |
|
114 // RLocationManager::Version |
|
115 // Returns the version of Location Manager. |
|
116 // -------------------------------------------------------------------------- |
|
117 // |
|
118 TVersion RLocationManager::Version() const |
|
119 { |
|
120 return TVersion( KLocationManagerServerMajor, |
|
121 KLocationManagerServerMinor, |
|
122 KLocationManagerServerBuild ); |
|
123 } |
|
124 |
|
125 // -------------------------------------------------------------------------- |
|
126 // RLocationManager::CompleteRequest |
|
127 // Completes an asynchronous request with an error code. |
|
128 // -------------------------------------------------------------------------- |
|
129 // |
|
130 void RLocationManager::CompleteRequest( TRequestStatus& aStatus, TInt aError ) |
|
131 { |
|
132 TRequestStatus* status = &aStatus; |
|
133 User::RequestComplete( status, aError ); |
|
134 } |
|
135 |
|
136 |
|
137 //End of File |