|
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: smiley utility class |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_SMILEYMODEL_H |
|
19 #define C_SMILEYMODEL_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <e32std.h> |
|
23 |
|
24 class CSmileyIcon; |
|
25 class CSmileyIconRecord; |
|
26 |
|
27 typedef TBuf<16> TSmileyString; |
|
28 |
|
29 class TImageInfo |
|
30 { |
|
31 public: |
|
32 TImageInfo(); |
|
33 void Reset(); |
|
34 |
|
35 public: // data |
|
36 TUint16 iCode; |
|
37 TUint iBmpId; |
|
38 TUint iMaskId; |
|
39 TBool iIsAnimation; |
|
40 TUint iStaticBmpId; |
|
41 TUint iStaticMaskId; |
|
42 }; |
|
43 |
|
44 NONSHARABLE_CLASS( CSmileyInfo ) : public CBase |
|
45 { |
|
46 public: |
|
47 CSmileyInfo(); |
|
48 ~CSmileyInfo(); |
|
49 void Reset(); |
|
50 void SetSmileyText( const TDesC& aText ); |
|
51 |
|
52 public: // data |
|
53 TImageInfo iImageInfo; |
|
54 RArray<TSmileyString> iStrArray; |
|
55 }; |
|
56 |
|
57 /** |
|
58 * class for reading and interpreting infomation stored in CenRep |
|
59 * |
|
60 * @lib ?library |
|
61 * @since S60 v5.0 |
|
62 */ |
|
63 NONSHARABLE_CLASS( CSmileyModel ) : public CBase |
|
64 { |
|
65 public: //constant definition |
|
66 static const TUint16 KInvalidIndex = 0xffff; |
|
67 |
|
68 private: // internal class declaration |
|
69 class TStrNode |
|
70 { |
|
71 public: |
|
72 TStrNode(); |
|
73 public: // data |
|
74 TUint16 iCode; |
|
75 TUint16 iSibling; |
|
76 TUint16 iChild; |
|
77 TUint16 iParent; |
|
78 }; |
|
79 |
|
80 class TLinkToImage |
|
81 { |
|
82 public: |
|
83 TLinkToImage(); |
|
84 |
|
85 public: // data |
|
86 TUint8 iStrLength; |
|
87 TUint16 iStrNode; |
|
88 TUint16 iImageIndex; |
|
89 }; |
|
90 |
|
91 public: |
|
92 // constructor |
|
93 CSmileyModel(); |
|
94 |
|
95 ~CSmileyModel(); |
|
96 // new functions |
|
97 HBufC* SupportedCodesL(); |
|
98 |
|
99 void GetImageInfo( TImageInfo& aInfo, HBufC** aFileName ); |
|
100 void SetSmileyIconFileL( const TDesC& aIconFileName ); |
|
101 void AddSimleyL( CSmileyInfo& aInfo ); |
|
102 void Reset(); |
|
103 |
|
104 //void PrintSmileyInfoL(); |
|
105 |
|
106 TBool IsFinalNode( TInt aIndex ); |
|
107 TInt TryFindMatchNode( const TDesC& aText, TInt aStartPos ); |
|
108 TInt SmileyStringLength( TInt aNodeIndex ); |
|
109 TText SmileyCode( TInt aNodeIndex ); |
|
110 void ReplaceTextWithCodes( TDes& aText, TInt aDocPos, TInt aNodeIndex ); |
|
111 |
|
112 private: |
|
113 TInt AddLinkAndImageInfoL( CSmileyInfo& aInfo, TInt aStrIndex ); |
|
114 void AddStringL( CSmileyInfo& aInfo, TInt aLinkIndex, TInt aStrIndex ); |
|
115 |
|
116 TInt AddStrNodeL( TInt aIndex, TStrNode& aNode ); |
|
117 TInt FindInSibling( TInt& aIndex, TText aCode ); |
|
118 TInt FindInChild( TInt& aIndex, TText aCode ); |
|
119 |
|
120 |
|
121 private: // data |
|
122 RArray<TStrNode> iStrArray; |
|
123 RArray<TLinkToImage> iLinkArray; |
|
124 RArray<TImageInfo> iImageInfoArray; |
|
125 HBufC* iFileName; |
|
126 }; |
|
127 |
|
128 #endif C_SMILEYMODEL_H |