|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "trksrvcmdcodes.h" |
|
19 #include "trksrvclientutils.h" |
|
20 #include "trksrvclientdefs.h" |
|
21 #include "trksrvclisession.h" |
|
22 |
|
23 // Type definitions |
|
24 |
|
25 // Constants |
|
26 const TInt KNumberOfServerStartupAttempts = 4; |
|
27 |
|
28 // Enumerations |
|
29 |
|
30 // |
|
31 // RTrkSrvCliSession (source) |
|
32 // |
|
33 |
|
34 // |
|
35 // RTrkSrvCliSession::RTrkSrvCliSession |
|
36 // |
|
37 // Constructor |
|
38 // |
|
39 RTrkSrvCliSession::RTrkSrvCliSession() |
|
40 { |
|
41 } |
|
42 |
|
43 // |
|
44 //RTrkSrvCliSession::ConnectToServer() |
|
45 // |
|
46 // Connects the client process to the TrkSrv server, starting the server |
|
47 // if it is not already running. |
|
48 // return KErrNone if successful, otherwise one of the system-wide errors. |
|
49 // |
|
50 TInt RTrkSrvCliSession::ConnectToServer() |
|
51 { |
|
52 TInt startupAttempts = KNumberOfServerStartupAttempts; |
|
53 for(;;) |
|
54 { |
|
55 TInt ret = CreateSession(TrkSrvClientDefs::ServerAndThreadName(), TrkSrvClientDefs::Version(), KTrkServerAsynchronousSlotCount); |
|
56 if (ret != KErrNotFound && ret != KErrServerTerminated) |
|
57 { |
|
58 return ret; |
|
59 } |
|
60 |
|
61 if (startupAttempts-- == 0) |
|
62 { |
|
63 return ret; |
|
64 } |
|
65 |
|
66 ret = TrkSrvClientUtils::StartTrkServer(); |
|
67 if (ret != KErrNone && ret != KErrAlreadyExists) |
|
68 { |
|
69 return ret; |
|
70 } |
|
71 |
|
72 } |
|
73 } |
|
74 |
|
75 // |
|
76 // RTrkSrvCliSession::GetTrkVersion() |
|
77 // |
|
78 // Provides the version number of the Trk server. |
|
79 // @return The version number. |
|
80 // |
|
81 TInt RTrkSrvCliSession::GetTrkVersion(TInt& aMajorVersion, TInt& aMinorVersion, TInt& aMajorAPIVersion, TInt& aMinorAPIVersion, TInt& aBuildNumber) |
|
82 { |
|
83 TTRKVersion trkVersion; |
|
84 TPckg<TTRKVersion> trkVersionPkg(trkVersion); |
|
85 TInt err = SendReceive(ETrkSrvGetVersion, TIpcArgs(&trkVersionPkg)); |
|
86 if (KErrNone == err) |
|
87 { |
|
88 aMajorVersion = trkVersion.iMajor; |
|
89 aMinorVersion = trkVersion.iMinor; |
|
90 aMajorAPIVersion = trkVersion.iMajorAPI; |
|
91 aMinorAPIVersion = trkVersion.iMinorAPI; |
|
92 aBuildNumber = trkVersion.iBuild; |
|
93 } |
|
94 |
|
95 return err; |
|
96 } |
|
97 |
|
98 // |
|
99 // RTrkSrvCliSession::Connect() |
|
100 // |
|
101 // |
|
102 TInt RTrkSrvCliSession::Connect() |
|
103 { |
|
104 return SendReceive(ETrkSrvCmdConnect); |
|
105 } |
|
106 |
|
107 // |
|
108 // RTrkSrvCliSession::ReadFile() |
|
109 // |
|
110 TInt RTrkSrvCliSession::DisConnect() |
|
111 { |
|
112 return SendReceive(ETrkSrvCmdDisConnect); |
|
113 } |
|
114 |
|
115 // |
|
116 // RTrkSrvCliSession::GetCurrentConnData() |
|
117 // |
|
118 TInt RTrkSrvCliSession::GetCurrentConnData(TTrkConnData& aConnData) |
|
119 { |
|
120 TPckg<TTrkConnData> package(aConnData); |
|
121 TIpcArgs args(&package); |
|
122 return SendReceive(ETrkSrvCmdGetCurrentConnData, args); |
|
123 } |
|
124 |
|
125 // |
|
126 // RTrkSrvCliSession::SetCurrentConnData() |
|
127 // |
|
128 TInt RTrkSrvCliSession::SetCurrentConnData(TTrkConnData& aConnData) |
|
129 { |
|
130 TPckg<TTrkConnData> package(aConnData); |
|
131 TIpcArgs args(&package); |
|
132 return SendReceive(ETrkSrvCmdSetCurrentConnData, args); |
|
133 } |
|
134 |
|
135 // |
|
136 // RTrkSrvCliSession::GetDebugConnStatus() |
|
137 // |
|
138 TInt RTrkSrvCliSession::GetDebugConnStatus(TTrkConnStatus& aConnStatus, TDes& aConnMsg) |
|
139 { |
|
140 TPckg<TTrkConnStatus> package(aConnStatus); |
|
141 TIpcArgs args(&package, aConnMsg.Length(), &aConnMsg); |
|
142 |
|
143 return SendReceive(ETrkSrvCmdGetDebugConnStatus, args); |
|
144 } |
|
145 |
|
146 // |
|
147 // RTrkSrvCliSession::DebugConnStatusNotify() |
|
148 // |
|
149 void RTrkSrvCliSession::DebugConnStatusNotify(TDes8& aConnStatus, TDes& aConnMsg, TRequestStatus& aStatus) |
|
150 { |
|
151 SendReceive(ETrkSrvDebugConnStatus, TIpcArgs(&aConnStatus, &aConnMsg), aStatus); |
|
152 } |
|
153 |
|
154 // |
|
155 // RTrkSrvCliSession::DebugConnStatusNotifyCancel() |
|
156 // |
|
157 TInt RTrkSrvCliSession::DebugConnStatusNotifyCancel() |
|
158 { |
|
159 return SendReceive(ETrkSrvDebugConnStatusCancel); |
|
160 } |
|
161 |
|
162 // |
|
163 // RTrkSrvCliSession::GetDebugStatus() |
|
164 // |
|
165 TInt RTrkSrvCliSession::GetDebuggingStatus(TBool& aDebugging) |
|
166 { |
|
167 TPckg<TBool> isDebugging(aDebugging); |
|
168 return SendReceive(ETrkSrvCmdGetDebuggingStatus, TIpcArgs(&isDebugging)); |
|
169 } |
|
170 |
|
171 // |
|
172 // RTrkSrvCliSession::DebuggingStatusNotify() |
|
173 // |
|
174 void RTrkSrvCliSession::DebuggingStatusNotify(TDes8& aDebugging, TRequestStatus& aStatus) |
|
175 { |
|
176 SendReceive(ETrkSrvDebuggingStatus, TIpcArgs(&aDebugging), aStatus); |
|
177 } |
|
178 |
|
179 // |
|
180 // RTrkSrvCliSession::DebuggingStatusNotifyCancel() |
|
181 // |
|
182 TInt RTrkSrvCliSession::DebuggingStatusNotifyCancel() |
|
183 { |
|
184 return SendReceive(ETrkSrvDebuggingStatusCancel); |
|
185 } |
|
186 |
|
187 TInt RTrkSrvCliSession::GetPlugAndPlayType(TBool& aPlugandPlay) |
|
188 { |
|
189 TPckg<TBool> package(aPlugandPlay); |
|
190 return SendReceive(ETrkGetPlugAndPlayType, TIpcArgs(&package)); |
|
191 |
|
192 } |
|
193 |
|
194 TInt RTrkSrvCliSession::SetPlugAndPlayType(TBool aPlugandPlay) |
|
195 { |
|
196 TPckg<TBool> package(aPlugandPlay); |
|
197 return SendReceive(ETrkSetPlugAndPlayType, TIpcArgs(&package)); |
|
198 } |
|
199 |
|
200 // |
|
201 // RTrkSrvCliSession::ShutDownServer() |
|
202 // |
|
203 // Closes the server. |
|
204 // @return KErrNone - if succesful |
|
205 // Negative - if failed. |
|
206 // |
|
207 TInt RTrkSrvCliSession::ShutDownServer() |
|
208 { |
|
209 return SendReceive(ETrkSrvCmdCodeShutDownServer); |
|
210 } |
|
211 |