1 /* |
|
2 * Copyright (c) 2007-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: A class which show message to ui |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "cimcvapprichtextcontainercache.h" |
|
20 |
|
21 // ----------------------------------------------------------------------------- |
|
22 // CIMCVAppRichTextContainerCache::NewL |
|
23 // ----------------------------------------------------------------------------- |
|
24 // |
|
25 CIMCVAppRichTextContainerCache* CIMCVAppRichTextContainerCache::NewL() |
|
26 { |
|
27 CIMCVAppRichTextContainerCache* self = new( ELeave) CIMCVAppRichTextContainerCache(); |
|
28 return self; |
|
29 } |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CIMCVAppRichTextContainerCache::CIMCVAppRichTextContainerCache |
|
33 // Default constructor |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CIMCVAppRichTextContainerCache::CIMCVAppRichTextContainerCache() |
|
37 { |
|
38 |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CIMCVAppRichTextContainerCache::~CIMCVAppRichTextContainerCache |
|
43 // Destructor |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CIMCVAppRichTextContainerCache::~CIMCVAppRichTextContainerCache() |
|
47 { |
|
48 //destroy all the objects in the cache |
|
49 iRTContainerCache.ResetAndDestroy(); |
|
50 |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CIMCVAppRichTextContainerCache::UpdateSkinTextColorL |
|
55 // This is called when the skin text color is changed, and it is applied to all the containers. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CIMCVAppRichTextContainerCache::UpdateSkinTextColorL () |
|
59 { |
|
60 TInt count = iRTContainerCache.Count(); |
|
61 for(TInt i=0;i<count;i++) |
|
62 { |
|
63 iRTContainerCache [i]->UpdateSkinnedTextColourL(); |
|
64 } |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CIMCVAppRichTextContainerCache::StoreContainer |
|
70 // Used to store the container to the cache |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CIMCVAppRichTextContainerCache::StoreContainer(CIMCVAppRichTextContainer *aContainer) |
|
74 { |
|
75 if( aContainer ) |
|
76 { |
|
77 TInt count = iRTContainerCache.Count(); |
|
78 for(TInt i=0;i<count;i++) |
|
79 { |
|
80 if( ( aContainer->ServiceId() == iRTContainerCache[i]->ServiceId() ) && |
|
81 ( KErrNone == iRTContainerCache[i]->GetPrimaryKey().Compare( aContainer->GetPrimaryKey() ) ) ) |
|
82 { |
|
83 //if found, no need to store |
|
84 return; |
|
85 } |
|
86 } |
|
87 //container is not in the cache so append it |
|
88 iRTContainerCache.Append(aContainer); |
|
89 } |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CIMCVAppRichTextContainerCache::LoadContainer |
|
94 // Used to find the container in the cache |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CIMCVAppRichTextContainer* CIMCVAppRichTextContainerCache::LoadContainer(TInt aServiceId, const TDesC& aPrimaryKey) |
|
98 { |
|
99 TInt count = iRTContainerCache.Count(); |
|
100 for(TInt i=0;i<count;i++) |
|
101 { |
|
102 if( ( aServiceId == iRTContainerCache[i]->ServiceId() ) && |
|
103 ( KErrNone == iRTContainerCache[i]->GetPrimaryKey().Compare(aPrimaryKey) ) ) |
|
104 { |
|
105 //if found returns the pointer to the container |
|
106 return iRTContainerCache[i]; |
|
107 } |
|
108 } |
|
109 return NULL; //if not found return NULL |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CIMCVAppRichTextContainerCache::DeleteContainer |
|
114 // Used to delete the container in the cache |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CIMCVAppRichTextContainerCache::DeleteContainer(const TDesC& aPrimaryKey, TInt aServiceId ) |
|
118 { |
|
119 TInt count = iRTContainerCache.Count(); |
|
120 for(TInt i=0;i<count;i++) |
|
121 { |
|
122 if( ( aServiceId == iRTContainerCache[i]->ServiceId() ) && |
|
123 ( KErrNone == iRTContainerCache[i]->GetPrimaryKey().Compare(aPrimaryKey) ) ) |
|
124 { |
|
125 //if found delete the container and remove the element from the array |
|
126 delete iRTContainerCache[i]; |
|
127 iRTContainerCache.Remove(i); |
|
128 break; |
|
129 } |
|
130 } |
|
131 } |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CIMCVAppRichTextContainerCache::DeleteAllServiceContainer |
|
134 // Used to delete the container in the cache |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CIMCVAppRichTextContainerCache::DeleteAllServiceContainer(TInt aServiceId ) |
|
138 { |
|
139 for(TInt index=0; index<iRTContainerCache.Count(); index++) |
|
140 { |
|
141 if( aServiceId == iRTContainerCache[index]->ServiceId() ) |
|
142 { |
|
143 //if found delete the container and remove the element from the array |
|
144 delete iRTContainerCache[index]; |
|
145 iRTContainerCache.Remove(index); |
|
146 iRTContainerCache.Compress(); |
|
147 index=index-1;// start from same index again |
|
148 } |
|
149 } |
|
150 } |
|
151 |
|
152 // end of file |
|
153 |
|
154 |
|