|
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 "toolsclientsession.h" |
|
19 #include "toolsclientdefs.h" |
|
20 #include <f32file.h> |
|
21 #include "ToolsCmdCodes.h" |
|
22 |
|
23 // System includes |
|
24 |
|
25 // User includes |
|
26 |
|
27 #include "toolsclientutils.h" |
|
28 // Type definitions |
|
29 |
|
30 // Constants |
|
31 const TInt KNumberOfServerStartupAttempts = 2; |
|
32 |
|
33 // Enumerations |
|
34 |
|
35 // |
|
36 // RToolsClientSession (source) |
|
37 // |
|
38 |
|
39 // |
|
40 // RToolsClientSession::RToolsClientSession |
|
41 // |
|
42 // Constructor |
|
43 // |
|
44 EXPORT_C RToolsClientSession::RToolsClientSession() |
|
45 { |
|
46 |
|
47 } |
|
48 |
|
49 // |
|
50 //RToolsClientSession::Connect() |
|
51 // |
|
52 // Connects the client process to the Tools server, starting the server |
|
53 // if it is not already running. |
|
54 // return KErrNone if successful, otherwise one of the system-wide errors. |
|
55 // |
|
56 EXPORT_C TInt RToolsClientSession::Connect() |
|
57 { |
|
58 TInt startupAttempts = KNumberOfServerStartupAttempts; |
|
59 for(;;) |
|
60 { |
|
61 TInt ret = CreateSession(ToolsClientDefs::ServerAndThreadName(), ToolsClientDefs::Version(), KToolsServerAsynchronousSlotCount); |
|
62 if (ret != KErrNotFound && ret != KErrServerTerminated) |
|
63 { |
|
64 return ret; |
|
65 } |
|
66 |
|
67 if (startupAttempts-- == 0) |
|
68 { |
|
69 return ret; |
|
70 } |
|
71 /* |
|
72 ret = ToolsClientUtils::StartToolsServer(); |
|
73 if (ret != KErrNone && ret != KErrAlreadyExists) |
|
74 { |
|
75 return ret; |
|
76 } |
|
77 */ |
|
78 } |
|
79 } |
|
80 |
|
81 // |
|
82 // RToolsClientSession::Version() |
|
83 // |
|
84 // Provides the version number of the Tools server. |
|
85 // @return The version number. |
|
86 // |
|
87 EXPORT_C TVersion RToolsClientSession::Version() const |
|
88 { |
|
89 return ToolsClientDefs::Version(); |
|
90 } |
|
91 |
|
92 // |
|
93 // RToolsClientSession::GetConnStatus() |
|
94 // |
|
95 // Provides the connection status |
|
96 // |
|
97 |
|
98 EXPORT_C TInt RToolsClientSession::GetConnStatus(TConnectionStatus& aConnStatus) |
|
99 { |
|
100 |
|
101 TPckg<TConnectionStatus> package(aConnStatus); |
|
102 TIpcArgs args(&package); |
|
103 return SendReceive(EToolsCmdCodeGetUsbConnStatus, args); |
|
104 } |
|
105 |
|
106 // |
|
107 // RToolsClientSession::UsbConnNotify() |
|
108 // |
|
109 // Asynchronous method to register for USB connection notifications |
|
110 // |
|
111 EXPORT_C void RToolsClientSession::UsbConnNotify(TDes8& aDes, TRequestStatus& aStatus) |
|
112 { |
|
113 TIpcArgs args(&aDes); |
|
114 SendReceive(EToolsCmdCodeConnNotify, args,aStatus); |
|
115 } |
|
116 |
|
117 // |
|
118 // RToolsClientSession::UsbConnNotifyCancel() |
|
119 // |
|
120 // To cancel the registration for USB connection notifications |
|
121 // |
|
122 EXPORT_C TInt RToolsClientSession::UsbConnNotifyCancel() |
|
123 { |
|
124 TIpcArgs args; |
|
125 return SendReceive(EToolsCmdCodeConnNotify, args); |
|
126 } |
|
127 |
|
128 |
|
129 // |
|
130 // RToolsClientSession::ShutDownServer() |
|
131 // |
|
132 // Closes the server. |
|
133 // @return KErrNone - if succesful |
|
134 // Negative - if failed. |
|
135 // |
|
136 |
|
137 EXPORT_C TInt RToolsClientSession::ShutDownServer() |
|
138 { |
|
139 TIpcArgs args; |
|
140 return SendReceive(EToolsCmdCodeShutDownServer, args); |
|
141 } |
|
142 |