1 /* |
|
2 * Copyright (c) 2005-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 "T_DataWsGraphicBitmap.h" |
|
19 #include "T_GraphicsUtil.h" |
|
20 |
|
21 /*@{*/ |
|
22 /// Commands |
|
23 _LIT(KCmdNewL, "NewL"); |
|
24 _LIT(KCmdDestructor, "~CWsGraphicBitmap"); |
|
25 _LIT(KCmdDestructorGeneral, "~"); |
|
26 |
|
27 /// Fields |
|
28 _LIT(KFldBitmap, "bitmap"); |
|
29 _LIT(KFldMask, "mask"); |
|
30 _LIT(KFldReplace, "replace"); |
|
31 _LIT(KFldUid, "uid"); |
|
32 |
|
33 /// Logging |
|
34 _LIT(KLogError, "Error=%d"); |
|
35 /*@}*/ |
|
36 |
|
37 ////////////////////////////////////////////////////////////////////// |
|
38 // Construction/Destruction |
|
39 ////////////////////////////////////////////////////////////////////// |
|
40 |
|
41 CT_DataWsGraphicBitmap* CT_DataWsGraphicBitmap::NewL() |
|
42 { |
|
43 CT_DataWsGraphicBitmap* ret=new (ELeave) CT_DataWsGraphicBitmap(); |
|
44 CleanupStack::PushL(ret); |
|
45 ret->ConstructL(); |
|
46 CleanupStack::Pop(ret); |
|
47 return ret; |
|
48 } |
|
49 |
|
50 CT_DataWsGraphicBitmap::CT_DataWsGraphicBitmap() |
|
51 : CT_DataWsGraphic() |
|
52 , iWsGraphicBitmap(NULL) |
|
53 { |
|
54 } |
|
55 |
|
56 void CT_DataWsGraphicBitmap::ConstructL() |
|
57 { |
|
58 } |
|
59 |
|
60 CT_DataWsGraphicBitmap::~CT_DataWsGraphicBitmap() |
|
61 { |
|
62 DestroyData(); |
|
63 } |
|
64 |
|
65 void CT_DataWsGraphicBitmap::SetObjectL(TAny* aAny) |
|
66 { |
|
67 DestroyData(); |
|
68 iWsGraphicBitmap = static_cast<CWsGraphicBitmap*> (aAny); |
|
69 } |
|
70 |
|
71 void CT_DataWsGraphicBitmap::DisownObjectL() |
|
72 { |
|
73 iWsGraphicBitmap = NULL; |
|
74 } |
|
75 |
|
76 void CT_DataWsGraphicBitmap::DestroyData() |
|
77 { |
|
78 delete iWsGraphicBitmap; |
|
79 iWsGraphicBitmap=NULL; |
|
80 } |
|
81 |
|
82 // CT_DataWsGraphic Implementation |
|
83 CWsGraphic* CT_DataWsGraphicBitmap::GetWsGraphic() const |
|
84 { |
|
85 return iWsGraphicBitmap; |
|
86 } |
|
87 |
|
88 TInt CT_DataWsGraphicBitmap::Share(TSecureId aClientId) |
|
89 { |
|
90 return iWsGraphicBitmap->Share(aClientId); |
|
91 } |
|
92 |
|
93 TInt CT_DataWsGraphicBitmap::ShareGlobally() |
|
94 { |
|
95 return iWsGraphicBitmap->ShareGlobally(); |
|
96 } |
|
97 |
|
98 TInt CT_DataWsGraphicBitmap::UnShare(TSecureId aClientId) |
|
99 { |
|
100 return iWsGraphicBitmap->UnShare(aClientId); |
|
101 } |
|
102 |
|
103 TInt CT_DataWsGraphicBitmap::UnShareGlobally() |
|
104 { |
|
105 return iWsGraphicBitmap->UnShareGlobally(); |
|
106 } |
|
107 |
|
108 /** |
|
109 * Process a command read from the ini file |
|
110 * |
|
111 * @param aCommand the command to process |
|
112 * @param aSection the entry in the ini file requiring the command to be processed |
|
113 * @param aAsyncErrorIndex index of command. used for async calls |
|
114 * |
|
115 * @return ETrue if the command is processed |
|
116 */ |
|
117 TBool CT_DataWsGraphicBitmap::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
118 { |
|
119 TBool ret = ETrue; |
|
120 |
|
121 if ( aCommand==KCmdDestructor || aCommand==KCmdDestructorGeneral ) |
|
122 { |
|
123 DoCmdDestructor(); |
|
124 } |
|
125 else if ( aCommand==KCmdNewL ) |
|
126 { |
|
127 DoCmdNewL(aSection); |
|
128 } |
|
129 else |
|
130 { |
|
131 ret=CT_DataWsGraphic::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
132 } |
|
133 |
|
134 return ret; |
|
135 } |
|
136 |
|
137 void CT_DataWsGraphicBitmap::DoCmdNewL(const TDesC& aSection) |
|
138 { |
|
139 DestroyData(); |
|
140 |
|
141 // Get test data for command input parameter(s) |
|
142 CFbsBitmap* bitmap = NULL; |
|
143 CT_GraphicsUtil::GetFbsBitmapL(*this, aSection, KFldBitmap, bitmap); |
|
144 |
|
145 CFbsBitmap* mask = NULL; |
|
146 CT_GraphicsUtil::GetFbsBitmapL(*this, aSection, KFldMask, mask); |
|
147 |
|
148 TInt err=KErrNone; |
|
149 |
|
150 TInt datUid; |
|
151 if ( GetIntFromConfig(aSection, KFldUid, datUid) ) |
|
152 { |
|
153 // Execute command and log parameters |
|
154 INFO_PRINTF1(_L("execute NewL(TUid , CFbsBitmap*, CFbsBitmap*)")); |
|
155 TRAP(err, iWsGraphicBitmap = CWsGraphicBitmap::NewL(TUid::Uid(datUid), bitmap, mask)); |
|
156 } |
|
157 else |
|
158 { |
|
159 TWsGraphicId datReplace(TWsGraphicId::EUninitialized); |
|
160 if ( GetWsGraphicIdFromConfigL(aSection, KFldReplace, datReplace) ) |
|
161 { |
|
162 // Execute command and log parameters |
|
163 INFO_PRINTF1(_L("execute NewL(TWsGraphicId , CFbsBitmap*, CFbsBitmap*)")); |
|
164 TRAP(err, iWsGraphicBitmap = CWsGraphicBitmap::NewL(datReplace, bitmap, mask)); |
|
165 } |
|
166 else |
|
167 { |
|
168 // Execute command and log parameters |
|
169 INFO_PRINTF1(_L("execute NewL(CFbsBitmap*, CFbsBitmap*)")); |
|
170 TRAP(err, iWsGraphicBitmap = CWsGraphicBitmap::NewL(bitmap, mask)); |
|
171 } |
|
172 } |
|
173 |
|
174 if ( err!=KErrNone ) |
|
175 { |
|
176 ERR_PRINTF2(KLogError, err); |
|
177 SetError(err); |
|
178 } |
|
179 } |
|
180 |
|
181 void CT_DataWsGraphicBitmap::DoCmdDestructor() |
|
182 { |
|
183 // Execute command and log parameters |
|
184 INFO_PRINTF1(_L("execute ~CWsGraphicBitmap()")); |
|
185 DestroyData(); |
|
186 } |
|