|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Client side interface to the plugin |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32std.h> |
|
19 #include "../SERVER/w32cmd.h" |
|
20 #include "CLIENT.H" |
|
21 |
|
22 EXPORT_C RSoundPlugIn::RSoundPlugIn() |
|
23 /** Default constructor. */ |
|
24 {} |
|
25 |
|
26 EXPORT_C RSoundPlugIn::RSoundPlugIn(RWsSession& aWs) : MWsClientClass(aWs.iBuffer) |
|
27 /** C++ constructor. |
|
28 |
|
29 After calling this function, Construct() must be called to complete construction. |
|
30 |
|
31 @param aWs Connected session with the window server. */ |
|
32 {} |
|
33 |
|
34 EXPORT_C TInt RSoundPlugIn::Construct(TUid aUid) |
|
35 /** Second phase constructor. |
|
36 |
|
37 Creates the server side resource and initialises the client's handle to it. |
|
38 |
|
39 This function always causes a flush of the window server buffer. |
|
40 |
|
41 @param aUid Optional UID. This can be ignored unless you intend to use the CommandReply() |
|
42 function. If you do intend to use CommandReply(), this should be the plug-in DLL's third |
|
43 UID. CommandReply() will return the value ESoundWrongPlugIn if the plug-in DLL identified |
|
44 by this UID is not loaded. |
|
45 @return KErrNone if the function was successful, otherwise one of the system wide error |
|
46 codes. |
|
47 @panic TW32Panic 17 in debug builds if called on an already constructed object.*/ |
|
48 { |
|
49 __ASSERT_DEBUG(iWsHandle == KNullHandle, Panic(EW32PanicGraphicDoubleConstruction)); |
|
50 TInt ret; |
|
51 if ((ret=iBuffer->WriteReplyWs(&aUid,sizeof(aUid),EWsClOpCreateClick))>=0) |
|
52 { |
|
53 iWsHandle=ret; |
|
54 ret=KErrNone; |
|
55 } |
|
56 return(ret); |
|
57 } |
|
58 |
|
59 EXPORT_C void RSoundPlugIn::Close() |
|
60 /** Sets the handle to zero and frees the resource owned by the server. */ |
|
61 { |
|
62 if (iBuffer && iWsHandle) |
|
63 Write(EWsClickOpFree); |
|
64 iWsHandle=NULL; |
|
65 } |
|
66 |
|
67 EXPORT_C void RSoundPlugIn::Destroy() |
|
68 /** Closes (by calling Close()) and deletes the object. */ |
|
69 { |
|
70 Close(); |
|
71 delete this; |
|
72 } |
|
73 |
|
74 EXPORT_C TBool RSoundPlugIn::IsLoaded(TBool& aIsChangeAble) const |
|
75 /** Tests whether a key or pointer click plug-in DLL is currently loaded. |
|
76 |
|
77 If one is currently loaded, aIsChangeAble returns whether or not |
|
78 it can be unloaded. |
|
79 |
|
80 This function always causes a flush of the window server buffer. |
|
81 |
|
82 @param aIsChangeAble If a plug-in is currently loaded, this returns ETrue if it |
|
83 can be unloaded and EFalse if it cannot. This depends on whether the |
|
84 KEYCLICKPLUGINFIXED keyword is specified in wsini.ini for the plug-in. |
|
85 @return ETrue if a plug-in is currently loaded, EFalse if not. */ |
|
86 { |
|
87 TUint reply=WriteReply(EWsClickOpIsLoaded); |
|
88 aIsChangeAble=reply&EClickLoadable; |
|
89 return reply&EClickLoaded; |
|
90 } |
|
91 |
|
92 EXPORT_C TInt RSoundPlugIn::Unload() |
|
93 /** Unloads the plug-in if one is currently loaded and if it can be unloaded. |
|
94 |
|
95 This function always causes a flush of the window server buffer. |
|
96 |
|
97 @return KErrNone if the function was successful, KErrNotSupported if it could |
|
98 not be unloaded. |
|
99 @capability WriteDeviceData */ |
|
100 { |
|
101 return WriteReply(EWsClickOpUnLoad); |
|
102 } |
|
103 |
|
104 EXPORT_C TInt RSoundPlugIn::Load(const TDesC& aFileName) |
|
105 /** Loads a new plug-in, replacing the existing one, if any. |
|
106 |
|
107 This function always causes a flush of the window server buffer. |
|
108 |
|
109 @param aFileName The filename of the plug-in DLL to load. |
|
110 @return KErrNone if the function was successful. KErrNotSupported if the currently |
|
111 loaded plug-in could not be unloaded. |
|
112 @capability WriteDeviceData */ |
|
113 { |
|
114 TInt length=aFileName.Length(); |
|
115 return WriteReply(&length,sizeof(length),aFileName.Ptr(),aFileName.Size(),EWsClickOpLoad); |
|
116 } |
|
117 |
|
118 EXPORT_C void RSoundPlugIn::SetPenClick(TBool aEnabled) |
|
119 /** |
|
120 @publishedPartner |
|
121 @released |
|
122 |
|
123 Sets whether pointer clicks should be enabled or disabled. |
|
124 |
|
125 By default, pointer clicks are enabled. |
|
126 |
|
127 @param aEnabled ETrue to enable pointer clicks, EFalse to disable them. |
|
128 @capability WriteDeviceData */ |
|
129 { |
|
130 WriteInt(aEnabled,EWsClickOpSetPenClick); |
|
131 } |
|
132 |
|
133 EXPORT_C void RSoundPlugIn::SetKeyClick(TBool aEnabled) |
|
134 /** |
|
135 @publishedPartner |
|
136 @released |
|
137 |
|
138 Sets whether key clicks should be enabled or disabled. |
|
139 |
|
140 By default, key clicks are enabled. |
|
141 |
|
142 @param aEnabled ETrue to enable key clicks, EFalse to disable them. |
|
143 @capability WriteDeviceData */ |
|
144 { |
|
145 WriteInt(aEnabled,EWsClickOpSetKeyClick); |
|
146 } |
|
147 |
|
148 EXPORT_C TBool RSoundPlugIn::PenClickEnabled() const |
|
149 /** Tests whether pointer clicks are enabled, as set by SetPenClick(). |
|
150 |
|
151 This function always causes a flush of the window server buffer. |
|
152 |
|
153 @return ETrue if pointer clicks are enabled, EFalse if they are disabled. */ |
|
154 { |
|
155 return WriteReply(EWsClickOpPenClickEnabled); |
|
156 } |
|
157 |
|
158 EXPORT_C TBool RSoundPlugIn::KeyClickEnabled() const |
|
159 /** Tests whether key clicks are enabled, as set by SetKeyClick(). |
|
160 |
|
161 This function always causes a flush of the window server buffer. |
|
162 |
|
163 @return ETrue if key clicks are enabled, EFalse if they are disabled. */ |
|
164 { |
|
165 return WriteReply(EWsClickOpKeyClickEnabled); |
|
166 } |
|
167 |
|
168 EXPORT_C TInt RSoundPlugIn::CommandReply(TInt aOpcode, const TPtrC8& aArgs) |
|
169 /** Sends a command to the plug-in DLL and may receive a response. |
|
170 |
|
171 If the correct plug-in is loaded, its implementation of CommandReplyL() |
|
172 is called and its return code is returned by this function. |
|
173 |
|
174 Specify an opcode of zero if you just want the identity of the plug-in DLL |
|
175 being used. |
|
176 |
|
177 This function always causes a flush of the window server buffer. |
|
178 |
|
179 @param aOpcode Opcode understood by both the window server client and the |
|
180 plug-in DLL. If an opcode of zero is specified, this is intercepted by the |
|
181 window server, and the third UID of the plug-in is returned. This allows |
|
182 the caller to identify the plug-in DLL being used. |
|
183 @param aArgs Packaged arguments which are passed to the plug-in via the window |
|
184 server. |
|
185 @return KErrNone or another of the system error codes, as returned by the |
|
186 plug-in's CommandReplyL() implementation. ESoundWrongPlugIn is returned if no |
|
187 plug-in is loaded, or if the plug-in identified by the aUid parameter in Construct() |
|
188 is not loaded. */ |
|
189 { |
|
190 return WriteReply(&aOpcode,sizeof(aOpcode),aArgs.Ptr(),aArgs.Length(),EWsClickOpCommandReply); |
|
191 } |
|
192 |