|
1 /** |
|
2 This file is part of CWRT package ** |
|
3 |
|
4 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** |
|
5 |
|
6 This program is free software: you can redistribute it and/or modify |
|
7 it under the terms of the GNU (Lesser) General Public License as |
|
8 published by the Free Software Foundation, version 2.1 of the License. |
|
9 This program is distributed in the hope that it will be useful, but |
|
10 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 (Lesser) General Public License for more details. You should have |
|
13 received a copy of the GNU (Lesser) General Public License along |
|
14 with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 */ |
|
16 |
|
17 |
|
18 #include "serviceipcsymbiansession.h" |
|
19 |
|
20 namespace WRT |
|
21 { |
|
22 // ============================== MEMBER FUNCTIONS ============================ |
|
23 |
|
24 /*! |
|
25 \class RServiceIPCSession |
|
26 |
|
27 Symbian class encapsulating RMessage2 interface |
|
28 */ |
|
29 |
|
30 /*! |
|
31 Send a message |
|
32 @param aFunction function code |
|
33 @return message completion code |
|
34 */ |
|
35 TInt RServiceIPCSession::SendReceiveL(TInt aFunction) const |
|
36 { |
|
37 return User::LeaveIfError(RSessionBase::SendReceive(aFunction)); |
|
38 } |
|
39 |
|
40 /*! |
|
41 Send a message |
|
42 @param aFunction function code |
|
43 @param aArgs parameter to server |
|
44 @return message completion code |
|
45 */ |
|
46 TInt RServiceIPCSession::SendReceiveL(TInt aFunction, const TIpcArgs& aArgs) const |
|
47 { |
|
48 return User::LeaveIfError(RSessionBase::SendReceive(aFunction, aArgs)); |
|
49 } |
|
50 |
|
51 /*! |
|
52 Send message asynchronously |
|
53 @param aFunction function code |
|
54 @param aStatus the request status object used to contain the |
|
55 completion status of the request |
|
56 */ |
|
57 EXPORT_C void RServiceIPCSession::SendReceive(TInt aFunction, |
|
58 TRequestStatus& aStatus) const |
|
59 { |
|
60 RSessionBase::SendReceive(aFunction, aStatus); |
|
61 } |
|
62 |
|
63 /*! |
|
64 Send message asynchronously |
|
65 @param aFunction function code |
|
66 @param aArgs parameter to server |
|
67 @param aStatus the request status object used to contain the |
|
68 completion status of the request |
|
69 */ |
|
70 void RServiceIPCSession::SendReceive(TInt aFunction, |
|
71 const TIpcArgs& aArgs, |
|
72 TRequestStatus& aStatus) const |
|
73 { |
|
74 RSessionBase::SendReceive(aFunction, aArgs, aStatus); |
|
75 } |
|
76 |
|
77 /*! |
|
78 Connect to server |
|
79 @param aServer server name |
|
80 @param aVersion version of the server |
|
81 @return KErrNone success, otherwise system error code |
|
82 */ |
|
83 TInt RServiceIPCSession::Connect(const TDesC& aServer, const TVersion& aVersion) |
|
84 { |
|
85 iVersion = aVersion; |
|
86 return CreateSession(aServer, aVersion, 1); |
|
87 } |
|
88 |
|
89 /*! |
|
90 Get version info |
|
91 @return version info |
|
92 */ |
|
93 TVersion RServiceIPCSession::Version() const |
|
94 { |
|
95 return iVersion; |
|
96 } |
|
97 |
|
98 /*! |
|
99 Start the server |
|
100 @param aImage binary name to start |
|
101 @return KErrNone if started properly |
|
102 */ |
|
103 TInt RServiceIPCSession::StartServer(const TDesC& aImage) |
|
104 { |
|
105 RProcess server; |
|
106 TInt ret = server.Create(aImage, KNullDesC); |
|
107 if (ret == KErrNone) { |
|
108 TRequestStatus status; |
|
109 server.Rendezvous(status); |
|
110 if (status != KRequestPending) |
|
111 server.Kill(0); |
|
112 else |
|
113 server.Resume(); |
|
114 User::WaitForRequest(status); |
|
115 ret = (server.ExitType() == EExitPanic) ? KErrGeneral : status.Int(); |
|
116 server.Close(); |
|
117 } |
|
118 return ret; |
|
119 } |
|
120 } |
|
121 |
|
122 // END OF FILE |