|
1 /* |
|
2 * Copyright (c) 2004 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 for IM modules. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CAUTILS_H__ |
|
20 #define __CAUTILS_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <s32strm.h> |
|
24 #include <badesca.h> |
|
25 |
|
26 // FORWARD CLASS DECLERATIONS |
|
27 |
|
28 // CLASS DECLARATION |
|
29 |
|
30 /** |
|
31 * Utils for IM modules. |
|
32 * |
|
33 * @lib CAEngine.dll |
|
34 * @since 3.0 |
|
35 */ |
|
36 class CAUtils // CSI: 51 # This is not a C-class although it begins with CA |
|
37 { |
|
38 public: // new methods |
|
39 |
|
40 /** |
|
41 * Case insensitive comparison of WVIDs, using protocol ("wv:") neutral |
|
42 * comparison. The "wv:" part (actually everything up to the first |
|
43 * ":") is ignored in the comparison. If aDomainNeutral is ETrue, does |
|
44 * domain-neutral comparison with the following logic: |
|
45 * - If only one of aId1 or aId2 (but not both) contains domain, |
|
46 * domain-neutral comparison is done |
|
47 * - If both or none of aId1 and aId2 contain domain, ordinary |
|
48 * wv-neutral comparison is done |
|
49 * If aDomainNeutral is EFalse, then falls back to the old way of |
|
50 * comparing, i.e. wv-neutral only |
|
51 * @param aId1 The first id to compare (network-given) |
|
52 * @param aId2 The second id to compare |
|
53 * @param aDomainNeutral Do domain neutral comparison (ETrue, default) |
|
54 * @return -1, 0 or +1, like CompareC. |
|
55 * @since 2.5 |
|
56 */ |
|
57 static TInt NeutralCompare( const TDesC& aId1, const TDesC& aId2, TBool |
|
58 aDomainNeutral = ETrue ); |
|
59 /** |
|
60 * Process userid/groupid/listid so that the "wv:" part is hidden, |
|
61 * depending on the branded setting coming from the UI. |
|
62 * @param aId The id to process |
|
63 * @return The id with the "wv:" (userid, groupid) or "wv:user" (listid) |
|
64 * part hidden |
|
65 */ |
|
66 static TPtrC DisplayId( const TDesC& aId, TBool aListHiding = EFalse ); |
|
67 |
|
68 /** |
|
69 * Generates a valid Wireless Village Id by removing all |
|
70 * characters that cannot appear in Wireless Village Ids. |
|
71 * @param aId The Id to process |
|
72 * @param aNum if within range (1...9999) the number is appended to the |
|
73 * string. Appending might replace some part of the string |
|
74 * if number doesn't fit otherwise. |
|
75 * @return The Id without invalid characters. Onwership is transferred. |
|
76 */ |
|
77 static HBufC* GenerateIdLC( const TDesC& aId, TInt aNum = 0 ); |
|
78 |
|
79 /** |
|
80 * Externalize buffer to stream |
|
81 * @param aBuffer Buffer to externalize |
|
82 * @param aStream stream to externalize to |
|
83 */ |
|
84 static void ExternalizeBufferToStreamL( const TDesC& aBuffer, |
|
85 RWriteStream& aStream ); |
|
86 static void ExternalizeBufferToStreamL( const TDesC8& aBuffer, |
|
87 RWriteStream& aStream ); |
|
88 |
|
89 /** |
|
90 * Internalize buffer from stream |
|
91 * @param aStream stream to internalize from |
|
92 * @return Internalized buffer. |
|
93 */ |
|
94 static HBufC* InternalizeBufferFromStreamLC( RReadStream& aStream ); |
|
95 static HBufC* InternalizeBufferFromStreamL( RReadStream& aStream ); |
|
96 static HBufC8* InternalizeBuffer8FromStreamLC( RReadStream& aStream ); |
|
97 static HBufC8* InternalizeBuffer8FromStreamL( RReadStream& aStream ); |
|
98 |
|
99 /** |
|
100 * Checks wether the user id is correct or not |
|
101 * @return ETrue if valid id |
|
102 */ |
|
103 static TBool ValidLoginIdL( const TDesC& aPresenceId ); |
|
104 |
|
105 /** |
|
106 * Adds the removed "wv:" and "@something" parts |
|
107 * @param aOrigId Original user id, i.e. "wv:user@domain.com" |
|
108 * @param aUserId User entered id, i.e. "otheruser" |
|
109 * @return The reconstructed id, i.e. "wv:otheruser@domain.com" |
|
110 * The ownership is transferred to caller! |
|
111 */ |
|
112 static HBufC* ReconstructIdL( const TDesC& aOrigId, const TDesC& aUserId ); |
|
113 |
|
114 /** |
|
115 * Find if user is on userlist using NeutralCompare |
|
116 * @param aUserList list of wvid's |
|
117 * @param aUserId user id to find |
|
118 * @return position of founding, KErrNotFound if not found |
|
119 */ |
|
120 static TInt NeutralFind( const MDesCArray& aUserList, const TDesC& aUserId ); |
|
121 |
|
122 /** |
|
123 * This routine is used to convert between arabic-indic digits and european digits |
|
124 * based on existing language setting. So it'll convert any digit from the string |
|
125 * to use either european digits or arabic-indic digits based on current settings. |
|
126 * |
|
127 * This method can be also called in european release. The method is required |
|
128 * to do the correct thing with all the languages. |
|
129 * |
|
130 * Never store the converted string as unicode. |
|
131 * |
|
132 * @since S60 v3 dot 1 |
|
133 * @param aDes Descriptor data to be converted. |
|
134 */ |
|
135 static void LanguageSpecificNumberConversion( TDes& aDes ); |
|
136 /** |
|
137 * UI CR ID: 101-39727 |
|
138 * This function capitalises the first letter of the |
|
139 * contactlist. |
|
140 * |
|
141 * |
|
142 * |
|
143 * @param aListname Descriptor(Listname) data to be converted. |
|
144 */ |
|
145 static HBufC* CapitalizeListNameL( const TDesC& aListname ); |
|
146 |
|
147 /** |
|
148 * UI CR ID: 101-39727 |
|
149 * This function returns ETrue if capitalization of Lists is enabled, |
|
150 * EFalse if disabled. |
|
151 * |
|
152 * The value is stored in the storage manager. |
|
153 * |
|
154 |
|
155 */ |
|
156 static TBool CapitalizingEnabled(); |
|
157 |
|
158 /** |
|
159 * UI CR ID: 101-39727 |
|
160 * This function capitalises the first letter of the |
|
161 * contactlistID. |
|
162 * |
|
163 * |
|
164 * |
|
165 * @param aListname Descriptor(Listname) data to be converted. |
|
166 */ |
|
167 static HBufC* CapitalizeListIdL( const TDesC& aId ); |
|
168 }; |
|
169 |
|
170 #endif // __CAUTILS_H__ |
|
171 |
|
172 // End of File |