|
1 /* |
|
2 * Copyright (c) 2008 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: utils class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "servicewidgetutils.h" |
|
21 #include "servicewidgetcpglobals.h" |
|
22 #include <coemain.h> |
|
23 #include <StringLoader.h> |
|
24 // ----------------------------------------------------------------------------- |
|
25 // ServiceWidgetUtils::DisplayId |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 TPtrC ServiceWidgetUtils::DisplayId( const TDesC& aId, |
|
29 TBool aDomainHiding ) |
|
30 { |
|
31 TPtrC ret( aId ); |
|
32 // locate ":" for userid, groupid. |
|
33 // locate "/" for list id. |
|
34 TInt pos = aId.FindC( aDomainHiding ? KSlash : KColon ); |
|
35 if ( ( pos != KErrNotFound) && ( pos != aId.Length()-1) ) |
|
36 { |
|
37 // contains the special character, and it is not the last char |
|
38 // remove everything before the special char (including the char) |
|
39 ret.Set( aId.Mid( pos + 1 ) ); |
|
40 } |
|
41 if( aDomainHiding) |
|
42 { |
|
43 // remove also the domain part |
|
44 TInt domainPos = ret.FindC( KAt ); |
|
45 if ( ( domainPos != KErrNotFound ) && ( domainPos != 0 ) ) |
|
46 { |
|
47 ret.Set( ret.Mid( 0, domainPos ) ); |
|
48 } |
|
49 } |
|
50 return ret; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // ServiceWidgetUtils::LoadResourceL |
|
55 // give ownership to caller |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 HBufC* ServiceWidgetUtils::LoadResourceLC( TInt aResourceId , |
|
59 CCoeEnv* aEnv /*= NULL*/) |
|
60 { |
|
61 HBufC* ret = NULL; |
|
62 if(aEnv) |
|
63 { |
|
64 ret = StringLoader::LoadLC( aResourceId ); |
|
65 } |
|
66 return ret; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // ServiceWidgetUtils::LoadResourceL |
|
71 // give ownership to caller |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 HBufC* ServiceWidgetUtils::LoadResourceLC( TInt aResourceId , |
|
75 const TDesC& aText , |
|
76 CCoeEnv* aEnv /*= NULL*/ ) |
|
77 { |
|
78 HBufC* ret = NULL; |
|
79 if(aEnv) |
|
80 { |
|
81 ret = StringLoader::LoadLC( aResourceId, aText ); |
|
82 } |
|
83 return ret; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // ServiceWidgetUtils::LoadResourceL |
|
88 // give ownership to caller |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 HBufC* ServiceWidgetUtils::LoadResourceLC( |
|
92 TInt aResourceId , |
|
93 TInt aInt , |
|
94 CCoeEnv* aEnv /*= NULL*/) |
|
95 { |
|
96 HBufC* ret = NULL; |
|
97 if(aEnv) |
|
98 { |
|
99 ret = StringLoader::LoadLC( aResourceId, aInt ); |
|
100 } |
|
101 return ret; |
|
102 } |
|
103 // ----------------------------------------------------------------------------- |
|
104 // ServiceWidgetUtils::LoadResourceL |
|
105 // give ownership to caller |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 HBufC* ServiceWidgetUtils::LoadResourceLC( |
|
109 TInt aResourceId , |
|
110 const CArrayFix<TInt>& aInts , |
|
111 CCoeEnv* aEnv /*= NULL*/ ) |
|
112 { |
|
113 HBufC* ret = NULL; |
|
114 if(aEnv) |
|
115 { |
|
116 ret = StringLoader::LoadLC( aResourceId, aInts ); |
|
117 } |
|
118 return ret; |
|
119 } |
|
120 |
|
121 // End of file |