|
1 // Copyright (c) 1997-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 // |
|
15 |
|
16 #include "APGWGNAM.H" |
|
17 #include "APGSTD.H" |
|
18 #include "APGTASK.H" |
|
19 |
|
20 const TInt KUidBufLength=8; |
|
21 const TInt KMinWindowGroupNameLength=5/*delimiters+status)*/+KUidBufLength; |
|
22 const TInt KMaxWindowGroupNameLength=KMinWindowGroupNameLength+2*KMaxFileName; |
|
23 const TInt KMaxSearchStringLength=KMaxFileName+6/* 3*delim+3*wild */; |
|
24 typedef TBuf<KMaxSearchStringLength> TApaSearchString; |
|
25 |
|
26 _LIT(KDefaultWindowGroupName,"00\x00\x30\x30\x30\x30\x30\x30\x30\x30\x0\x0"); |
|
27 _LIT(KSearchAnyFile,"*"); |
|
28 _LIT(KFormatStatus,"%02x"); |
|
29 |
|
30 EXPORT_C CApaWindowGroupName::~CApaWindowGroupName() |
|
31 /** Destructor. |
|
32 |
|
33 Frees resources owned by the object prior to its destruction. */ |
|
34 { |
|
35 delete iBuf; |
|
36 } |
|
37 |
|
38 EXPORT_C CApaWindowGroupName* CApaWindowGroupName::New(const RWsSession& aWsSession, HBufC* aWgName) |
|
39 // |
|
40 // non leaving static initializer from full name - takes ownership |
|
41 // ONLY TO BE USED WITH A VALID (i.e existing) WINDOW GROUP NAME |
|
42 // |
|
43 /** Creates a window group name object and takes ownership of the heap descriptor |
|
44 containing a name. |
|
45 |
|
46 The name must have valid format. Typically, this is an existing window group |
|
47 name. |
|
48 |
|
49 Note that the function cannot leave. |
|
50 |
|
51 @param aWsSession A window server session. |
|
52 @param aWgName A heap descriptor containing a valid window group name. This |
|
53 pointer must not be null, otherwise the function raises an APGRFX 3 panic. |
|
54 @return A pointer to the new window group name object. */ |
|
55 { |
|
56 CApaWindowGroupName* This=NULL; |
|
57 if (aWgName) |
|
58 { |
|
59 This=new CApaWindowGroupName(aWsSession); |
|
60 if (This) |
|
61 { |
|
62 This->iBuf=aWgName; |
|
63 This->GetStatusFromName(); |
|
64 } |
|
65 } |
|
66 else |
|
67 Panic(EPanicNullWindowGroupName); |
|
68 return This; |
|
69 } |
|
70 |
|
71 EXPORT_C CApaWindowGroupName* CApaWindowGroupName::NewL(const RWsSession& aWsSession) |
|
72 // |
|
73 // static initializer for blank window group name |
|
74 // |
|
75 /** Creates a window group name object and assigns a default name to it. |
|
76 |
|
77 @param aWsSession A window server session. |
|
78 @return A pointer to the new window group name object. */ |
|
79 { |
|
80 CApaWindowGroupName* This=NewLC(aWsSession); |
|
81 CleanupStack::Pop(); |
|
82 return This; |
|
83 } |
|
84 |
|
85 EXPORT_C CApaWindowGroupName* CApaWindowGroupName::NewL(const RWsSession& aWsSession, TInt aWgId) |
|
86 // |
|
87 // static initializer for existing window group name given by aWgId |
|
88 // |
|
89 /** Creates a window group name object and assigns to it the name taken from the |
|
90 specified window group. |
|
91 |
|
92 @param aWsSession A window server session. |
|
93 @param aWgId The ID of a window group. |
|
94 @return A pointer to the new window group name object. */ |
|
95 { |
|
96 CApaWindowGroupName* This=NewLC(aWsSession, aWgId); |
|
97 CleanupStack::Pop(); |
|
98 return This; |
|
99 } |
|
100 |
|
101 EXPORT_C CApaWindowGroupName* CApaWindowGroupName::NewL(const RWsSession& aWsSession, const TDesC& aWgName) |
|
102 // |
|
103 // static initializer from full name |
|
104 // ONLY TO BE USED WITH A VALID (i.e existing) WINDOW GROUP NAME |
|
105 // |
|
106 /** Creates a window group name object and assigns to it the specified name. |
|
107 |
|
108 The name must have a valid format. Typically, this is an existing window group |
|
109 name. |
|
110 |
|
111 @param aWsSession A window server session. |
|
112 @param aWgName A valid window group name. |
|
113 @return A pointer to the new window group name object. */ |
|
114 { |
|
115 CApaWindowGroupName* This=NewLC(aWsSession, aWgName); |
|
116 CleanupStack::Pop(); |
|
117 return This; |
|
118 } |
|
119 |
|
120 EXPORT_C CApaWindowGroupName* CApaWindowGroupName::NewLC(const RWsSession& aWsSession) |
|
121 // |
|
122 // static initializer for blank window group name |
|
123 // |
|
124 /** Creates a window group name object, assigns a default name to it, and puts |
|
125 a pointer to the new object onto the cleanup stack. |
|
126 |
|
127 @param aWsSession A window server session. |
|
128 @return A pointer to the new window group name object. */ |
|
129 { |
|
130 CApaWindowGroupName* This=new(ELeave) CApaWindowGroupName(aWsSession); |
|
131 CleanupStack::PushL(This); |
|
132 This->DefaultConstructL(); |
|
133 return This; |
|
134 } |
|
135 |
|
136 EXPORT_C CApaWindowGroupName* CApaWindowGroupName::NewLC(const RWsSession& aWsSession, TInt aWgId) |
|
137 // |
|
138 // static initializer for existing window group name given by aWgId |
|
139 // |
|
140 /** Creates a window group name object, assigns to it the name taken from the specified |
|
141 window group, and puts a pointer to the new object onto the cleanup stack. |
|
142 |
|
143 @param aWsSession A window server session. |
|
144 @param aWgId The ID of a window group. |
|
145 @return A pointer to the new window group name object. */ |
|
146 { |
|
147 CApaWindowGroupName* This=new(ELeave) CApaWindowGroupName(aWsSession); |
|
148 CleanupStack::PushL(This); |
|
149 This->ConstructFromWgIdL(aWgId); |
|
150 return This; |
|
151 } |
|
152 |
|
153 EXPORT_C CApaWindowGroupName* CApaWindowGroupName::NewLC(const RWsSession& aWsSession, const TDesC& aWgName) |
|
154 // |
|
155 // static initializer from full name |
|
156 // ONLY TO BE USED WITH A VALID (i.e existing) WINDOW GROUP NAME |
|
157 // |
|
158 /** Creates a window group name object, assigns to it the specified name, and puts |
|
159 a pointer to the new object onto the cleanup stack. |
|
160 |
|
161 The name must have valid format. Typically, this is an existing window group |
|
162 name. |
|
163 |
|
164 @param aWsSession A window server session. |
|
165 @param aWgName A valid window group name. |
|
166 @return A pointer to the new window group name object. */ |
|
167 { |
|
168 CApaWindowGroupName* This=new(ELeave) CApaWindowGroupName(aWsSession); |
|
169 CleanupStack::PushL(This); |
|
170 This->iBuf=aWgName.AllocL(); |
|
171 This->GetStatusFromName(); |
|
172 return This; |
|
173 } |
|
174 |
|
175 CApaWindowGroupName::CApaWindowGroupName(const RWsSession& aWsSession) |
|
176 : iWsSession(aWsSession) |
|
177 // |
|
178 // private c'tor |
|
179 // |
|
180 { |
|
181 } |
|
182 |
|
183 |
|
184 void CApaWindowGroupName::DefaultConstructL() |
|
185 { |
|
186 iStatus=0; |
|
187 iBuf = KDefaultWindowGroupName().AllocL(); |
|
188 } |
|
189 |
|
190 EXPORT_C void CApaWindowGroupName::ConstructFromWgIdL(TInt aWgId) |
|
191 // |
|
192 // Allocate and format iBuf according to existing name given by aWgId |
|
193 // |
|
194 /** Assigns to this object the name taken from the specified window group. |
|
195 |
|
196 Any previously existing name contained by this window group name object is |
|
197 lost. |
|
198 |
|
199 If the specified window group does not exist or it has no name, then a default |
|
200 name is assigned. |
|
201 |
|
202 @param aWgId The ID of a window group. */ |
|
203 { |
|
204 delete iBuf; |
|
205 iBuf=NULL; |
|
206 if (aWgId>0) |
|
207 { |
|
208 TBuf<KMaxWindowGroupNameLength> name; |
|
209 ((RWsSession&)iWsSession).GetWindowGroupNameFromIdentifier(aWgId, name); |
|
210 if (name.Length()==0) // name not set |
|
211 DefaultConstructL(); |
|
212 else |
|
213 { |
|
214 iBuf=name.AllocL(); |
|
215 GetStatusFromName(); |
|
216 } |
|
217 } |
|
218 else |
|
219 DefaultConstructL(); |
|
220 } |
|
221 |
|
222 EXPORT_C void CApaWindowGroupName::SetWindowGroupNameL(const TDesC& aWgName) |
|
223 /** Sets the full window group name in this object. |
|
224 |
|
225 @param aWgName The full window group name. */ |
|
226 { |
|
227 delete iBuf; |
|
228 iBuf=NULL; |
|
229 iBuf=aWgName.AllocL(); |
|
230 GetStatusFromName(); |
|
231 } |
|
232 |
|
233 EXPORT_C void CApaWindowGroupName::SetWindowGroupName(HBufC* aWgName) |
|
234 /** Sets the full window group name in this object, taking ownership of the specified |
|
235 heap descriptor. |
|
236 |
|
237 The function cannot leave. |
|
238 |
|
239 @param aWgName A heap descriptor containing the full window group name. The |
|
240 pointer must not be null, otherwise the function raises a APGRFX 3 panic. */ |
|
241 { |
|
242 if (aWgName) |
|
243 { |
|
244 if (iBuf != aWgName) |
|
245 { |
|
246 delete iBuf; |
|
247 iBuf=aWgName; |
|
248 } |
|
249 GetStatusFromName(); |
|
250 } |
|
251 else |
|
252 Panic(EPanicNullWindowGroupName); |
|
253 } |
|
254 |
|
255 EXPORT_C void CApaWindowGroupName::FindByAppUid(TUid aAppUid, RWsSession& aWsSession, TInt& aPrevWgId) |
|
256 /** Searches for the next window group by application UID. |
|
257 |
|
258 A running application, also known as a task, is associated with a window group. |
|
259 The function searches for the next task running the specified application, |
|
260 and returns its associated window group ID. |
|
261 |
|
262 @param aAppUid The application specific UID. |
|
263 @param aWsSession A window server session. |
|
264 @param aPrevWgId On entry, the previous window group ID. On return, the next |
|
265 window group ID. On first call to this function pass a zero value. When there |
|
266 are no more matching window groups, contains KErrNotFound. */ |
|
267 { |
|
268 TBuf<20> match(KSearchAnyFile); // status |
|
269 match.Append(0); |
|
270 TBuf<8> uidBuf; |
|
271 //Type casting the Uid (which is TInt) to TUint to perform proper conversion |
|
272 //when aAppUid.iUid is negative. |
|
273 uidBuf.Num(TUint(aAppUid.iUid), EHex); |
|
274 match.Append(uidBuf); // uid |
|
275 match.Append(0); |
|
276 match.Append('*'); // caption |
|
277 match.Append(0); |
|
278 match.Append('*'); // docname |
|
279 aPrevWgId=aWsSession.FindWindowGroupIdentifier(aPrevWgId, match, 0); |
|
280 } |
|
281 |
|
282 EXPORT_C void CApaWindowGroupName::FindByCaption(const TDesC& aCaption, RWsSession& aWsSession, TInt& aPrevWgId) |
|
283 /** Searches for the next window group by caption. |
|
284 |
|
285 A running application, also known as a task, is associated with a window group. |
|
286 The function searches for the next task having the specified caption, and |
|
287 returns its associated window group ID. |
|
288 |
|
289 @param aCaption The caption. |
|
290 @param aWsSession A window server session. |
|
291 @param aPrevWgId On entry, the previous window group ID. On return, the next |
|
292 window group ID. On first call to this function pass a zero value. When there |
|
293 are no more matching window groups, contains KErrNotFound. */ |
|
294 { |
|
295 TApaSearchString match(KSearchAnyFile); // status |
|
296 match.Append(0); |
|
297 match.Append('*'); // uid |
|
298 match.Append(0); |
|
299 match.Append(aCaption); // caption |
|
300 match.Append(0); |
|
301 match.Append('*'); //doc name |
|
302 aPrevWgId=aWsSession.FindWindowGroupIdentifier(aPrevWgId, match, 0); |
|
303 } |
|
304 |
|
305 EXPORT_C void CApaWindowGroupName::FindByDocName(const TDesC& aDocName, RWsSession& aWsSession, TInt& aPrevWgId) |
|
306 /** Searches for the next window group by document name. |
|
307 |
|
308 A running application, also known as a task, is associated with a window group. |
|
309 The function searches for the next task handling the specified document, and |
|
310 returns its associated window group ID. |
|
311 |
|
312 @param aDocName The name of the document. |
|
313 @param aWsSession A window server session. |
|
314 @param aPrevWgId On entry, the previous window group ID. On return, the next |
|
315 window group ID. On first call to this function pass a zero value. When there |
|
316 are no more matching window groups, contains KErrNotFound. */ |
|
317 { |
|
318 TApaSearchString match(KSearchAnyFile); // status |
|
319 match.Append(0); |
|
320 match.Append('*'); // uid |
|
321 match.Append(0); |
|
322 match.Append('*'); // caption |
|
323 match.Append(0); |
|
324 match.Append(aDocName); |
|
325 aPrevWgId=aWsSession.FindWindowGroupIdentifier(aPrevWgId, match, 0); |
|
326 } |
|
327 |
|
328 EXPORT_C void CApaWindowGroupName::SetBusy(TBool aBusy) |
|
329 /** Sets the task's busy status in this object. |
|
330 |
|
331 @param aBusy ETrue, marks the task as busy; EFalse, marks the task as not |
|
332 busy. |
|
333 @see CEikonEnv::SetBusy() */ |
|
334 { |
|
335 iStatus&=(~EBusy); |
|
336 if (aBusy) |
|
337 iStatus|=EBusy; |
|
338 WriteStatusToName(); |
|
339 } |
|
340 |
|
341 EXPORT_C TBool CApaWindowGroupName::IsBusy() const |
|
342 /** Tests whether the task is marked as busy. |
|
343 |
|
344 @return True, if the task is marked as busy; false, otherwise. |
|
345 @see CEikonEnv::IsBusy() */ |
|
346 { |
|
347 return iStatus&EBusy; |
|
348 } |
|
349 |
|
350 EXPORT_C void CApaWindowGroupName::SetSystem(TBool aSystem) |
|
351 /** Sets the task's system status in this object. |
|
352 |
|
353 @param aSystem ETrue, marks the task as a system task; EFalse, marks the task |
|
354 as not a system task. |
|
355 @see CEikonEnv::SetSystem() */ |
|
356 { |
|
357 iStatus&=(~ESystem); |
|
358 if (aSystem) |
|
359 iStatus|=ESystem; |
|
360 WriteStatusToName(); |
|
361 } |
|
362 |
|
363 EXPORT_C TBool CApaWindowGroupName::IsSystem() const |
|
364 /** Tests whether the task is marked as a system task. |
|
365 |
|
366 @return True, if the task is marked as a system task; false, otherwise. |
|
367 @see CEikonEnv::IsSystem() */ |
|
368 { |
|
369 return iStatus&ESystem; |
|
370 } |
|
371 |
|
372 EXPORT_C void CApaWindowGroupName::SetDocNameIsAFile(TBool aDocNameIsAFile) |
|
373 /** Sets the document name status in this object. |
|
374 |
|
375 @param aDocNameIsAFile ETrue, the document name is a filename; EFalse, the |
|
376 document name is not a filename. |
|
377 @see CEikonEnv::SetDocNameIsAFile() */ |
|
378 { |
|
379 iStatus&=(~EDocNameNotAFile); |
|
380 if (!aDocNameIsAFile) |
|
381 iStatus|=EDocNameNotAFile; |
|
382 WriteStatusToName(); |
|
383 } |
|
384 |
|
385 EXPORT_C TBool CApaWindowGroupName::DocNameIsAFile() const |
|
386 /** Tests whether the document name is a file. |
|
387 |
|
388 @return True, if the document name is a file; false, otherwise. |
|
389 @see CEikonEnv::DocNameIsAFile() */ |
|
390 { |
|
391 return !(iStatus&EDocNameNotAFile); |
|
392 } |
|
393 |
|
394 EXPORT_C void CApaWindowGroupName::SetRespondsToShutdownEvent(TBool aRespondsToShutdownEvent) |
|
395 /** Sets the task's shutdown handling status in this object. |
|
396 |
|
397 @param aRespondsToShutdownEvent ETrue, if the task can deal with a shutdown |
|
398 request; EFalse, if the task cannot deal with a shutdown request. |
|
399 @see CEikonEnv::SetRespondsToShutdownEvent() */ |
|
400 { |
|
401 iStatus&=(~EDoesNotRespondToShutdownEvent); |
|
402 if (!aRespondsToShutdownEvent) |
|
403 iStatus|=EDoesNotRespondToShutdownEvent; |
|
404 WriteStatusToName(); |
|
405 } |
|
406 |
|
407 EXPORT_C TBool CApaWindowGroupName::RespondsToShutdownEvent() const |
|
408 /** Tests whether the task can deal with a request to shutdown. |
|
409 |
|
410 @return True, if the task can deal with a request to shutdown; false, otherwise. |
|
411 |
|
412 @see CEikonEnv::RespondsToShutdownEvent() */ |
|
413 { |
|
414 return !(iStatus&EDoesNotRespondToShutdownEvent); |
|
415 } |
|
416 |
|
417 EXPORT_C void CApaWindowGroupName::SetRespondsToSwitchFilesEvent(TBool aRespondsToSwitchFilesEvent) |
|
418 /** Sets the task's switch file handling status in this object. |
|
419 |
|
420 @param aRespondsToSwitchFilesEvent ETrue, if the task can deal with a request |
|
421 to switch file; EFalse, if the task cannot deal with with a request to switch |
|
422 files. |
|
423 @see CEikonEnv::SetRespondsToSwitchFilesEvent() */ |
|
424 { |
|
425 iStatus&=(~EDoesNotRespondToSwitchFilesEvent); |
|
426 if (!aRespondsToSwitchFilesEvent) |
|
427 iStatus|=EDoesNotRespondToSwitchFilesEvent; |
|
428 WriteStatusToName(); |
|
429 } |
|
430 |
|
431 EXPORT_C TBool CApaWindowGroupName::RespondsToSwitchFilesEvent() const |
|
432 /** Tests whether the task can deal with a request to switch files. |
|
433 |
|
434 @return True, if the task can deal with a request to switch files; false otherwise. |
|
435 @see CEikonEnv::RespondsToSwitchFilesEvent() */ |
|
436 { |
|
437 return !(iStatus&EDoesNotRespondToSwitchFilesEvent); |
|
438 } |
|
439 |
|
440 EXPORT_C void CApaWindowGroupName::SetHidden(TBool aIsHidden) |
|
441 /** Marks the task as hidden. |
|
442 |
|
443 In general, tasks marked as hidden do not appear in tasklists. |
|
444 Specifically, TApaTask::FindByPos() will ignore any tasks marked as hidden. |
|
445 |
|
446 @param aIsHidden ETrue if the task is to be marked as hidden; EFalse if not. */ |
|
447 { |
|
448 iStatus&=(~EIsHidden); |
|
449 if (aIsHidden) |
|
450 iStatus|=EIsHidden; |
|
451 WriteStatusToName(); |
|
452 } |
|
453 |
|
454 EXPORT_C TBool CApaWindowGroupName::Hidden() const |
|
455 /** Tests whether the task is marked as hidden. |
|
456 |
|
457 @return True if the task is hidden; false otherwise. */ |
|
458 { |
|
459 return (iStatus&EIsHidden); |
|
460 } |
|
461 |
|
462 EXPORT_C void CApaWindowGroupName::SetAppReady(TBool aIsReady) |
|
463 /** Sets the task as ready. |
|
464 |
|
465 @param aIsReady ETrue if the task is to be marked as ready; EFalse if not. */ |
|
466 { |
|
467 iStatus&=(~EAppReady); |
|
468 if (aIsReady) |
|
469 iStatus|=EAppReady; |
|
470 WriteStatusToName(); |
|
471 } |
|
472 |
|
473 EXPORT_C TBool CApaWindowGroupName::IsAppReady() const |
|
474 /** Tests whether the task is marked as ready. |
|
475 |
|
476 @return True if the task is ready; false otherwise. */ |
|
477 { |
|
478 return (iStatus&EAppReady); |
|
479 } |
|
480 |
|
481 EXPORT_C void CApaWindowGroupName::SetAppUid(TUid aAppUid) |
|
482 /** Sets the specified UID into the window group name in this object. |
|
483 |
|
484 @param aAppUid The application specific UID. */ |
|
485 { |
|
486 TInt start=FindDelimiter(EEndStatus); |
|
487 if (start>0) |
|
488 { |
|
489 start++; |
|
490 TInt end=FindDelimiter(EEndUid); |
|
491 if (end>0) |
|
492 { |
|
493 TBuf<KUidBufLength> uidBuf; |
|
494 //Type casting the Uid (which is TInt) to TUint to perform proper conversion |
|
495 //when aAppUid.iUid is negative. |
|
496 uidBuf.Num(TUint(aAppUid.iUid), EHex); |
|
497 TPtr des=iBuf->Des(); |
|
498 des.Replace(start, end-start, uidBuf); |
|
499 } |
|
500 } |
|
501 } |
|
502 |
|
503 |
|
504 EXPORT_C TUid CApaWindowGroupName::AppUid() const |
|
505 /** Gets the UID of the task's application. |
|
506 |
|
507 @return The application specific UID. If the format of the window group name |
|
508 is not recognized, then this is zero. */ |
|
509 { |
|
510 TUid uid=TUid::Null(); |
|
511 TInt start=FindDelimiter(EEndStatus); |
|
512 if (start>0) |
|
513 { |
|
514 start++; |
|
515 TInt end=FindDelimiter(EEndUid); |
|
516 if ((end-start) == KUidBufLength) |
|
517 { |
|
518 TBuf<KUidBufLength> uidBuf=iBuf->Mid(start, end-start); |
|
519 TLex lex(uidBuf); |
|
520 TUint32 val = 0; |
|
521 lex.Val(val, EHex); //Ignoring error code since we anyways have to return null uid if this returns an error. |
|
522 uid.iUid = val; |
|
523 } |
|
524 } |
|
525 return uid; |
|
526 } |
|
527 |
|
528 EXPORT_C void CApaWindowGroupName::SetCaptionL(const TDesC& aCaption) |
|
529 /** Sets the specified caption into the window group name in this object. |
|
530 |
|
531 @param aCaption The caption. */ |
|
532 { |
|
533 TInt start=FindDelimiter(EEndUid); |
|
534 if (start>0) |
|
535 { |
|
536 start++; |
|
537 TInt end=FindDelimiter(EEndCaption); |
|
538 if (end>0) |
|
539 { |
|
540 TInt length=end-start; |
|
541 ReAllocIfNecessaryL(aCaption.Length()-length); |
|
542 TPtr des=iBuf->Des(); |
|
543 des.Replace(start, length, aCaption); |
|
544 } |
|
545 } |
|
546 } |
|
547 |
|
548 EXPORT_C TPtrC CApaWindowGroupName::Caption() const |
|
549 /** Gets the task's caption. |
|
550 |
|
551 @return A non-modifiable pointer descriptor representing the caption. If the |
|
552 format of the window group name is not recognized, then this is a zero length |
|
553 descriptor. */ |
|
554 { |
|
555 TInt start=FindDelimiter(EEndUid); |
|
556 if (start>0) |
|
557 { |
|
558 start++; |
|
559 TInt end=FindDelimiter(EEndCaption); |
|
560 if (end>0) |
|
561 return iBuf->Mid(start, end-start); |
|
562 } |
|
563 return TPtrC(); // error |
|
564 } |
|
565 |
|
566 EXPORT_C void CApaWindowGroupName::SetDocNameL(const TDesC& aDocName) |
|
567 /** Sets the specified document name into the window group name in this object. |
|
568 |
|
569 @param aDocName The document name. */ |
|
570 { |
|
571 TInt start=FindDelimiter(EEndCaption); |
|
572 if (start>0) |
|
573 { |
|
574 start++; |
|
575 TInt end=iBuf->Length(); |
|
576 if (end>0) |
|
577 { |
|
578 TInt length=end-start; |
|
579 ReAllocIfNecessaryL(aDocName.Length()-length); |
|
580 TPtr des=iBuf->Des(); |
|
581 des.Replace(start, length, aDocName); |
|
582 } |
|
583 } |
|
584 } |
|
585 |
|
586 EXPORT_C TPtrC CApaWindowGroupName::DocName() const |
|
587 /** Gets the name of the document that the task is handling. |
|
588 |
|
589 @return A non-modifiable pointer descriptor representing the document name. |
|
590 If the format of the window group name is not recognized, then this is a zero |
|
591 length descriptor. */ |
|
592 { |
|
593 TInt start=FindDelimiter(EEndCaption); |
|
594 if (start>0) |
|
595 { |
|
596 start++; |
|
597 TInt end=iBuf->Length(); |
|
598 if (end>0) |
|
599 return iBuf->Mid(start, end-start); |
|
600 } |
|
601 return TPtrC(); // error |
|
602 } |
|
603 |
|
604 EXPORT_C TInt CApaWindowGroupName::SetWindowGroupName(RWindowGroup& aGroupWin) const |
|
605 // |
|
606 // Set aGroupWin's name to the current name in iBuf (returns WServ error code) |
|
607 // |
|
608 /** Sets the window group name contained by this object into the specified window |
|
609 group. |
|
610 |
|
611 @param aGroupWin The window group. |
|
612 @return KErrNone, if successful; otherwise, one of the other system-wide error |
|
613 codes. */ |
|
614 { |
|
615 return aGroupWin.SetName(*iBuf); |
|
616 } |
|
617 |
|
618 EXPORT_C TPtrC CApaWindowGroupName::WindowGroupName() const |
|
619 /** Gets the full window group name. |
|
620 |
|
621 @return A non-modifiable pointer descriptor representing the full window group |
|
622 name. */ |
|
623 { |
|
624 return *iBuf; |
|
625 } |
|
626 |
|
627 void CApaWindowGroupName::WriteStatusToName() |
|
628 // |
|
629 // replaces two digit hex number at front of iBuf by iStatus |
|
630 // |
|
631 { |
|
632 TBuf<2> status; |
|
633 status.Format(KFormatStatus, iStatus); |
|
634 TPtr des=iBuf->Des(); |
|
635 des.Replace(0,2,status); |
|
636 } |
|
637 |
|
638 void CApaWindowGroupName::GetStatusFromName() |
|
639 // |
|
640 // Extracts the two digit hex number at front of iBuf into iStatus |
|
641 // |
|
642 { |
|
643 TBuf<2> status=iBuf->Left(2); |
|
644 TLex lex(status); |
|
645 lex.Val(iStatus, EHex); |
|
646 } |
|
647 |
|
648 TInt CApaWindowGroupName::FindDelimiter(TApaDelimiter aDelim) const |
|
649 // |
|
650 // returns the pos of aDelim or KErrNotFound |
|
651 // |
|
652 { |
|
653 TInt pos=-1; |
|
654 TInt length=iBuf->Length(); |
|
655 for (TInt i=0; i<aDelim; i++) |
|
656 { |
|
657 TInt nextPos=(iBuf->Right(length-pos-1)).Locate(0); |
|
658 if (nextPos<0) |
|
659 return KErrNotFound; |
|
660 pos=pos+nextPos+1; |
|
661 } |
|
662 return pos; |
|
663 } |
|
664 |
|
665 void CApaWindowGroupName::ReAllocIfNecessaryL(TInt aExtraLengthReqd) |
|
666 // |
|
667 // Reallocates iBuf if currentLength+extraLength<totalLength |
|
668 // |
|
669 { |
|
670 TInt existing=iBuf->Length(); |
|
671 TInt total=existing+aExtraLengthReqd; |
|
672 if (total>iBuf->Des().MaxLength()) |
|
673 iBuf=iBuf->ReAllocL(total); |
|
674 } |
|
675 |