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