|
1 // Copyright (c) 2010 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: The main purpose of RTFXEffect implementation is to forward |
|
14 // RWsSession/RWindowBase calls to RegisterEffect and OverrideEffect to server side. |
|
15 // Please see documantion of RTFXEffect::RegisterTFXEffect() for more details. |
|
16 // |
|
17 |
|
18 #include "rtfxeffect.h" |
|
19 #include "w32comm.h" |
|
20 #include "client.h" |
|
21 |
|
22 /** |
|
23 Constructor which takes handle and buffer paratemter and initilaizes |
|
24 its member variables. |
|
25 |
|
26 @param aHandle Client side handle of the class derived from MWsClientClass |
|
27 @param aBuffer Pointer to the wserv client side buffer of the above class |
|
28 */ |
|
29 RTFXEffect::RTFXEffect(TInt aHandle, RWsBuffer* aBuffer) |
|
30 : MWsClientClass(aBuffer), iDirPathSizePaded(0), iFileName1SizePaded(0), |
|
31 iFileName2SizePaded(0), iCombSizePaded(0) |
|
32 { |
|
33 iWsHandle = aHandle; |
|
34 } |
|
35 |
|
36 /** |
|
37 Function checks the sent parmaters and pancis client if any of its length |
|
38 is greater than KMaxFileName. Calculates the padded lengths of sent parameters |
|
39 and stores them in member variables |
|
40 |
|
41 @param aResourceDir directory name of animation description file |
|
42 @param aFilenamePhase1 File name of first phase animation of TFX |
|
43 @param aFilenamePhase2 File name of second phase animation of TFX |
|
44 */ |
|
45 void RTFXEffect::CheckFileNameAndSetSizes(const TFileName& aResourceDir, |
|
46 const TFileName& aFilenamePhase1, const TFileName& aFilenamePhase2) |
|
47 { |
|
48 __ASSERT_ALWAYS(aResourceDir.Length() <= KMaxFileName, Panic(EW32PanicStringTooLong)); |
|
49 __ASSERT_ALWAYS(aFilenamePhase1.Length() <= KMaxFileName, Panic(EW32PanicStringTooLong)); |
|
50 __ASSERT_ALWAYS(aFilenamePhase2.Length() <= KMaxFileName, Panic(EW32PanicStringTooLong)); |
|
51 |
|
52 iDirPathSizePaded = PaddedValue(aResourceDir.Size()); |
|
53 iFileName1SizePaded = PaddedValue(aFilenamePhase1.Size()); |
|
54 iFileName2SizePaded = PaddedValue(aFilenamePhase2.Size()); |
|
55 |
|
56 iCombSizePaded = iDirPathSizePaded + iFileName1SizePaded + iFileName2SizePaded; |
|
57 } |
|
58 |
|
59 /** |
|
60 Appends folder and file names to wserv client's buffer using AppendData() of MWsClientClass. |
|
61 AppendData adds data directly to buffer. So before calling AppendData we must make sure that |
|
62 current command is added to buffer. Please see description of MWsClientClass::AppendData() |
|
63 for more details. |
|
64 |
|
65 @param aResourceDir directory name of animation description file |
|
66 @param aFilenamePhase1 File name of first phase animation of TFX |
|
67 @param aFilenamePhase2 File name of second phase animation of TFX |
|
68 */ |
|
69 void RTFXEffect::AppendFileNameData(const TFileName& aResourceDir, const TFileName& aFilenamePhase1, const TFileName& aFilenamePhase2) |
|
70 { |
|
71 AppendData(aResourceDir.Ptr(), aResourceDir.Size(), EFalse); |
|
72 AppendData(aFilenamePhase1.Ptr(), aFilenamePhase1.Size(), EFalse); |
|
73 AppendData(aFilenamePhase2.Ptr(), aFilenamePhase2.Size(), ETrue); |
|
74 } |
|
75 |
|
76 /** |
|
77 Writes file names using IPC args along with data related to TWsClCmdRegisterEffect |
|
78 First phase animation file name is sent in seocnd slot of IPC to server |
|
79 Second phase animation file name is sent in third slot of IPC to server |
|
80 Data related to TWsClCmdRegisterEffect and folder name are sent in the normal wserv buffer |
|
81 |
|
82 @param aForRegister an object of TWsClCmdRegisterEffect filled with data related to RegisterTFXEffect |
|
83 If non Empty then this function is called for Register effect |
|
84 @param aForOverride an object of TWsClCmdOverrideEffect filled with data related to OverrideTFXEffect |
|
85 If non Empty then this function is called for Overide effect |
|
86 @param aResourceDir directory name of animation description file |
|
87 @param aFilenamePhase1 File name of first phase animation of TFX |
|
88 @param aFilenamePhase2 File name of second phase animation of TFX |
|
89 @param aCalledFrom value from TFXEffect enum reprseting whether called from RWsSession or RWindowbase |
|
90 */ |
|
91 void RTFXEffect::WriteDataUsingIPC(TWsClCmdRegisterEffect* aForRegister, TWsClCmdOverrideEffect* aForOverride, |
|
92 const TFileName& aResourceDir, const TFileName& aFilenamePhase1, const TFileName& aFilenamePhase2, TFXEffect aCalledFrom) |
|
93 { |
|
94 TIpcArgs ipcArgsDesc; |
|
95 ipcArgsDesc.Set(1, &aFilenamePhase1); |
|
96 ipcArgsDesc.Set(2, &aFilenamePhase2); |
|
97 // If called for RegisterTFXEffect |
|
98 if (aForRegister) |
|
99 { |
|
100 Write(aForRegister, sizeof(*aForRegister), aResourceDir.Ptr(), aResourceDir.Size(), |
|
101 EWsClOpRegisterTFXEffectIPC, &ipcArgsDesc); |
|
102 } |
|
103 else // Else called for OverrideTFXEffect |
|
104 { |
|
105 Write(aForOverride, sizeof(*aForOverride), aResourceDir.Ptr(), aResourceDir.Size(), |
|
106 (aCalledFrom == ETFXSession ? EWsClOpOverrideEffectIPC : EWsWinOpOverrideEffectIPC), &ipcArgsDesc); |
|
107 } |
|
108 } |
|
109 |
|
110 /** |
|
111 Checks if the sum of iCombSizePaded, size of TWsCmdHeader and sent size is less than |
|
112 the current buffer size. |
|
113 |
|
114 @param aSize size to be compared with current buffer size |
|
115 @return ETrue if the combined size if less then or equal to current buffer size |
|
116 EFalse if the combined size is greater then current buffer size |
|
117 */ |
|
118 TBool RTFXEffect::CheckCombinedSizeWithCurrentBuffer(TInt aSize) const |
|
119 { |
|
120 return (iCombSizePaded + aSize + sizeof(TWsCmdHeader) <= iBuffer->BufferSize()); |
|
121 } |
|
122 |
|
123 /** |
|
124 Checks the length of sent variables and does as explained below |
|
125 |
|
126 Main logic involved in both RegisterTFXEffect() and OverrideTFXEffect() is as follows |
|
127 First check the sum of all strings |
|
128 If it is less then max wserv buffer |
|
129 Send unpadded sizes in TWsClCmdRegisterEffect/TWsClCmdOverrideEffect but when we append |
|
130 the data we make sure that we pad it |
|
131 Then at server side get the buffer for total length(inlcuding pading)and unpad it and |
|
132 send it to renderstage's RegisterEffect/OverrideEffect function |
|
133 If it is greater then max wserv buffer |
|
134 Send one string in the wserv buffer as done before ie. pading and unpading |
|
135 Other two strings are sent using IPC args in 2 and 3 slot of IPC and do explicit flush |
|
136 And at server side get one string from buffer and other 2 from IPC |
|
137 |
|
138 @param aAction Particular transition to register the animation for. |
|
139 @param aResourceDir The name of the directory that contains the animation description files. |
|
140 @param aFilenamePhase1 The file containing the description of the animation for the first phase(Phase1) of the transition. |
|
141 Specify KNullDesC for no Phase1 effect. |
|
142 @param aFilenamePhase2 The file containing the description of the animation for the second phase(Phase2) of the transition. |
|
143 Specify KNullDesC for no Phase2 effect. |
|
144 @param aAppUid The Application UID this effect applies to. Set to zero to specify that all apps will use default effect. |
|
145 */ |
|
146 void RTFXEffect::RegisterTFXEffect(TInt aAction, const TFileName& aResourceDir, |
|
147 const TFileName& aFilenamePhase1, const TFileName& aFilenamePhase2, TUint aAppUid) |
|
148 { |
|
149 CheckFileNameAndSetSizes(aResourceDir, aFilenamePhase1, aFilenamePhase2); |
|
150 if (CheckCombinedSizeWithCurrentBuffer(sizeof(TWsClCmdRegisterEffect))) |
|
151 { |
|
152 TWsClCmdRegisterEffect params(aAction, aAppUid, aResourceDir.Size(), aFilenamePhase1.Size(), aFilenamePhase2.Size()); |
|
153 // Here we just pass the length of combined strings so that it checks and does flush if needed. |
|
154 // Then AppendData actually adds the data to buffer at the end |
|
155 Write(¶ms, sizeof(params), iCombSizePaded, EWsClOpRegisterTFXEffectBuf); |
|
156 if (iCombSizePaded > 0) |
|
157 AppendFileNameData(aResourceDir, aFilenamePhase1, aFilenamePhase2); |
|
158 } |
|
159 else |
|
160 { |
|
161 TWsClCmdRegisterEffect params(aAction, aAppUid, aResourceDir.Size(), 0, 0); |
|
162 WriteDataUsingIPC(¶ms, NULL, aResourceDir, aFilenamePhase1, aFilenamePhase2, ETFXSession); |
|
163 } |
|
164 } |
|
165 |
|
166 /** |
|
167 Checks the length of sent variables and does as explained in |
|
168 RTFXEffect::RegisterTFXEffect() API description |
|
169 |
|
170 @param aOneShot A flag to see if the specified override should be applied once or on an ongoing basis |
|
171 @param aAction The particular transition to set the animation for. |
|
172 @param aResourceDir The name of the directory that contains the animation description files. |
|
173 @param aFilenamePhase1 The file containing the description of the animation for the first phase(Phase1) of the transition. |
|
174 Specify KNullDesC for no Phase1 effect. |
|
175 @param aFilenamePhase2 The file containing the description of the animation for the second phase(Phase2) of the transition. |
|
176 Specify KNullDesC for no Phase2 effect. |
|
177 */ |
|
178 void RTFXEffect::OverrideTFXEffect(TBool aOneShot, TInt aAction, const TFileName& aResourceDir, |
|
179 const TFileName& aFilenamePhase1, const TFileName& aFilenamePhase2, TFXEffect aCalledFrom) |
|
180 { |
|
181 CheckFileNameAndSetSizes(aResourceDir, aFilenamePhase1, aFilenamePhase2); |
|
182 if (CheckCombinedSizeWithCurrentBuffer(sizeof(TWsClCmdOverrideEffect))) |
|
183 { |
|
184 TWsClCmdOverrideEffect params(aOneShot, aAction, aResourceDir.Size(), aFilenamePhase1.Size(), aFilenamePhase2.Size()); |
|
185 Write(¶ms, sizeof(params), iCombSizePaded, (aCalledFrom == ETFXSession ? EWsClOpOverrideEffectBuf : EWsWinOpOverrideEffectBuf)); |
|
186 if (iCombSizePaded > 0) |
|
187 AppendFileNameData(aResourceDir, aFilenamePhase1, aFilenamePhase2); |
|
188 } |
|
189 else |
|
190 { |
|
191 TWsClCmdOverrideEffect params(aOneShot, aAction, aResourceDir.Size(), 0, 0); |
|
192 WriteDataUsingIPC(NULL, ¶ms, aResourceDir, aFilenamePhase1, aFilenamePhase2, aCalledFrom); |
|
193 } |
|
194 } |