|
1 /* |
|
2 * Copyright (c) 2010 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: This provides utility for loading a BT device name without |
|
15 * localised to a string to be shown in GUI. |
|
16 * |
|
17 */ |
|
18 #include <StringLoader.h> |
|
19 |
|
20 class BluetoothUiUtil |
|
21 { |
|
22 public: |
|
23 |
|
24 /* |
|
25 * Gets the starting position of a key whose pattern matches |
|
26 * '%'{(0)*|<n>}<aKey> where 0 and <n> is the decimal value |
|
27 * of the specified position and <aKey> is the symbol of the key, |
|
28 * either 'U' or 'N'. |
|
29 * |
|
30 * For example, if the specified position of a number key |
|
31 * is 0, both "%N" and "%0N" match, |
|
32 * but "%1N" doesn't. If the position n is greater than 0, |
|
33 * only "%<n>N" matches. |
|
34 * @param aDes the descriptor where a key parameter will be searched. |
|
35 * @param aKey the specified key, 'U' or 'N' |
|
36 * @param aKeyPos the position of the key. position starts from 0. |
|
37 * @param aKeyLength the length of the key at return if the key exists. |
|
38 * @return the start position of the key in aDes. KErrNotFound if the key |
|
39 * is not available. |
|
40 */ |
|
41 inline static TInt GetSubstringKeyPos( const TDes& aDes, const TDesC& aKey, |
|
42 TInt aKeyPos, TInt& aKeyLength ); |
|
43 |
|
44 /* |
|
45 * Gets the starting position of a string key whose pattern matches |
|
46 * '%'{(0)*|<n>}'U' where 0 and <n> is the decimal value |
|
47 * of the specified position. |
|
48 * |
|
49 * For example, if the specified position is 0, both "%U" and "%0U" match, |
|
50 * but "%1U" doesn't. If the position n is greater than 0, |
|
51 * only "%<n>U" matches. |
|
52 * @param aDes the descriptor in which a string key will be searched. |
|
53 * @param aKeyPos the position of the string key. position starts from 0. |
|
54 * @param aKeyLength the length of the string key at return if the key exists. |
|
55 * @return the start position of the string key in aDes. KErrNotFound if the key |
|
56 * is not available. |
|
57 */ |
|
58 inline static TInt GetStringSubstringKeyPos( const TDes& aDes, TInt aKeyPos, TInt& aKeyLength ); |
|
59 |
|
60 /* |
|
61 * Add a substring to the specified RBuf descriptor. |
|
62 * ( Replace "%<n>U" at the specified position withe the given string. |
|
63 * @param aBuf the RBuf descriptor in which a "%<n>U" will be replaced. |
|
64 * @param aSub the substring that will replace a "%<n>U". |
|
65 * @param aSubPos the position of the "%U" to be replaced. Position starts from 0. |
|
66 */ |
|
67 inline static void AddSubstringL( RBuf& aBuf, const TDesC& aSub, TInt aSubPos); |
|
68 |
|
69 /* |
|
70 * Load a string specified by the given resource ID, |
|
71 * remove substrings that match "[" and ends with "]" and finally |
|
72 * replace the "%U" or "%<n>U" at the specified position with the |
|
73 * given substring. |
|
74 * |
|
75 * This function is intended for adding a Bluetooth device name to a UI |
|
76 * string but without localizing this name. |
|
77 * |
|
78 * (Using StringLoader will get the device name localized in some variants. |
|
79 * This is a workaround to tackle the unwanted localization.) |
|
80 * |
|
81 * @param aBuf the RBuf descriptor in which a "%<n>U" will be replaced. |
|
82 * @param aSub the substring that will replace a "%<n>U". |
|
83 * @param aSubPos the position of the "%U" to be replaced. Position starts from 0. |
|
84 */ |
|
85 inline static void LoadResourceAndSubstringL(RBuf& aBuf, |
|
86 TInt aResourceId, const TDesC& aSub, TInt aSubPos ); |
|
87 }; |
|
88 |
|
89 #include "bluetoothuiutil.inl" |
|
90 |
|
91 // End of File |
|
92 |