95 // CVIMPSTStorageManager::NewL |
92 // CVIMPSTStorageManager::NewL |
96 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
97 // |
94 // |
98 CVIMPSTStorageManager* CVIMPSTStorageManager::NewL() |
95 CVIMPSTStorageManager* CVIMPSTStorageManager::NewL() |
99 { |
96 { |
100 TRACE( T_LIT("CVIMPSTStorageManager::NewL() begin") ); |
97 TRACER_AUTO; |
101 //creates the instance |
98 //creates the instance |
102 CVIMPSTStorageManager* self = new( ELeave ) CVIMPSTStorageManager; |
99 CVIMPSTStorageManager* self = new( ELeave ) CVIMPSTStorageManager; |
103 CleanupStack::PushL( self ); |
100 CleanupStack::PushL( self ); |
104 self->ConstructL(); |
101 self->ConstructL(); |
105 CleanupStack::Pop( self ); |
102 CleanupStack::Pop( self ); |
106 TRACE( T_LIT("CVIMPSTStorageManager::NewL() end") ); |
|
107 return self; |
103 return self; |
108 } |
104 } |
109 |
105 |
110 // ----------------------------------------------------------------------------- |
106 // ----------------------------------------------------------------------------- |
111 // CVIMPSTStorageManager::ConstructL |
107 // CVIMPSTStorageManager::ConstructL |
112 // Two-phased constructor. |
108 // Two-phased constructor. |
113 // ----------------------------------------------------------------------------- |
109 // ----------------------------------------------------------------------------- |
114 // |
110 // |
115 void CVIMPSTStorageManager::ConstructL() |
111 void CVIMPSTStorageManager::ConstructL() |
116 { |
112 { |
117 TRACE( T_LIT("CVIMPSTStorageManager::ConstructL() begin") ); |
113 TRACER_AUTO; |
118 TRACE( T_LIT("CVIMPSTStorageManager::ConstructL() end") ); |
|
119 } |
114 } |
120 |
115 |
121 |
116 |
122 // ----------------------------------------------------------------------------- |
117 // ----------------------------------------------------------------------------- |
123 // CVIMPSTStorageManager::~CVIMPSTStorageManager |
118 // CVIMPSTStorageManager::~CVIMPSTStorageManager |
124 // ----------------------------------------------------------------------------- |
119 // ----------------------------------------------------------------------------- |
125 // |
120 // |
126 CVIMPSTStorageManager::~CVIMPSTStorageManager() |
121 CVIMPSTStorageManager::~CVIMPSTStorageManager() |
127 { |
122 { |
128 TRACE( T_LIT("CVIMPSTStorageManager::~CVIMPSTStorageManager() begin") ); |
123 TRACER_AUTO; |
129 //release all the existing views |
124 //release all the existing views |
130 iServiceViewList.ResetAndDestroy(); |
125 iServiceViewList.ResetAndDestroy(); |
131 TRACE( T_LIT("CVIMPSTStorageManager::~CVIMPSTStorageManager() end") ); |
|
132 } |
126 } |
133 |
127 |
134 // ----------------------------------------------------------------------------- |
128 // ----------------------------------------------------------------------------- |
135 // CVIMPSTStorageManager::CreateServiceViewL |
129 // CVIMPSTStorageManager::CreateServiceViewL |
136 // ----------------------------------------------------------------------------- |
130 // ----------------------------------------------------------------------------- |
137 // |
131 // |
138 CVIMPSTStorageServiceView* CVIMPSTStorageManager::CreateServiceViewL( TUint32 aServiceId, |
132 CVIMPSTStorageServiceView* CVIMPSTStorageManager::CreateServiceViewL( TUint32 aServiceId, |
139 const TDesC& aStoreName, |
133 const TDesC& aStoreName, |
140 const TDesC& aServiceName ) |
134 const TDesC& aServiceName ) |
141 { |
135 { |
142 TRACE( T_LIT("CVIMPSTStorageManager::CreateServiceViewL() begin") ); |
136 TRACER_AUTO; |
143 //creates a new view based on the service id. |
137 //creates a new view based on the service id. |
144 TInt index = KErrNotFound; |
138 TInt index = KErrNotFound; |
145 CVIMPSTStorageServiceView* serviceView = NULL; |
139 CVIMPSTStorageServiceView* serviceView = NULL; |
146 |
140 |
147 //check if the view already exists in the viewlist |
141 //check if the view already exists in the viewlist |
148 index = FindServiceView(aServiceId); |
142 index = FindServiceView(aServiceId); |
149 if( KErrNotFound == index ) |
143 if( KErrNotFound == index ) |
150 { |
144 { |
151 TRACE( T_LIT("CVIMPSTStorageManager::CreateServiceViewL() service does not exit") ); |
145 TRACE( "service does not exit" ); |
152 // service view is not found |
146 // service view is not found |
153 // check if store name is valid create a service view for aServiceId |
147 // check if store name is valid create a service view for aServiceId |
154 if( aStoreName.Length() ) |
148 if( aStoreName.Length() ) |
155 { |
149 { |
156 TRACE( T_LIT("CVIMPSTStorageManager::CreateServiceViewL() store name is valid") ); |
150 TRACE(" store name is valid" ); |
157 serviceView = CVIMPSTStorageServiceView::NewL(aServiceId, |
151 serviceView = CVIMPSTStorageServiceView::NewL(aServiceId, |
158 aStoreName, aServiceName); |
152 aStoreName, aServiceName); |
159 iServiceViewList.Append(serviceView); |
153 iServiceViewList.Append(serviceView); |
160 TRACE( T_LIT("CVIMPSTStorageManager::CreateServiceViewL() new view created for serviceId = %d"),aServiceId ); |
154 TRACE( "new view created for serviceId = %d",aServiceId ); |
161 } |
155 } |
162 // if store name is not valid ,return NULL |
156 // if store name is not valid ,return NULL |
163 } |
157 } |
164 else |
158 else |
165 { |
159 { |
166 TRACE( T_LIT("CVIMPSTStorageManager::CreateServiceViewL() service already exist = %d"),aServiceId ); |
160 TRACE( " service already exist = %d",aServiceId ); |
167 serviceView = iServiceViewList[ FindServiceView(aServiceId)]; |
161 serviceView = iServiceViewList[ FindServiceView(aServiceId)]; |
168 } |
162 } |
169 //return the extisting view from the viewlist |
163 //return the extisting view from the viewlist |
170 TRACE( T_LIT("CVIMPSTStorageManager::CreateServiceViewL() end") ); |
|
171 return serviceView; |
164 return serviceView; |
172 } |
165 } |
173 // ----------------------------------------------------------------------------- |
166 // ----------------------------------------------------------------------------- |
174 // CVIMPSTStorageManager::FindServiceView |
167 // CVIMPSTStorageManager::FindServiceView |
175 // ----------------------------------------------------------------------------- |
168 // ----------------------------------------------------------------------------- |
176 // |
169 // |
177 TInt CVIMPSTStorageManager::FindServiceView( TUint32 aServiceId) |
170 TInt CVIMPSTStorageManager::FindServiceView( TUint32 aServiceId) |
178 { |
171 { |
179 TRACE( T_LIT("CVIMPSTStorageManager::FindServiceView() begin") ); |
172 TRACER_AUTO; |
180 //search whether the view exists in the view list. |
173 //search whether the view exists in the view list. |
181 TInt index = KErrNotFound; |
174 TInt index = KErrNotFound; |
182 TInt count = iServiceViewList.Count(); |
175 TInt count = iServiceViewList.Count(); |
183 for(TInt i = 0; i < count; i++ ) |
176 for(TInt i = 0; i < count; i++ ) |
184 { |
177 { |
185 if( aServiceId == iServiceViewList[ i ]->GetServiceId() ) |
178 if( aServiceId == iServiceViewList[ i ]->GetServiceId() ) |
186 { |
179 { |
187 TRACE( T_LIT("CVIMPSTStorageManager::FindServiceView() aServiceId found = %d") ,aServiceId ); |
180 TRACE( "aServiceId found = %d" ,aServiceId ); |
188 index = i; |
181 index = i; |
189 break; |
182 break; |
190 } |
183 } |
191 } |
184 } |
192 TRACE( T_LIT("CVIMPSTStorageManager::FindServiceView() end") ); |
|
193 return index; |
185 return index; |
194 } |
186 } |
195 |
187 |
196 |
188 |
197 // ----------------------------------------------------------------------------- |
189 // ----------------------------------------------------------------------------- |
198 // CVIMPSTStorageManager::RemoveServiceView |
190 // CVIMPSTStorageManager::RemoveServiceView |
199 // ----------------------------------------------------------------------------- |
191 // ----------------------------------------------------------------------------- |
200 // |
192 // |
201 void CVIMPSTStorageManager::RemoveServiceView( TUint32 aServiceId) |
193 void CVIMPSTStorageManager::RemoveServiceView( TUint32 aServiceId) |
202 { |
194 { |
203 TRACE( T_LIT("CVIMPSTStorageManager::RemoveServiceView() begin") ); |
195 TRACER_AUTO; |
204 //searches and removes the view from the view list. |
196 //searches and removes the view from the view list. |
205 TInt index = FindServiceView(aServiceId); |
197 TInt index = FindServiceView(aServiceId); |
206 if( index >= 0 ) |
198 if( index >= 0 ) |
207 { |
199 { |
208 TRACE( T_LIT("CVIMPSTStorageManager::RemoveServiceView() aServiceId found = %d") ,aServiceId ); |
200 TRACE( "aServiceId found = %d" ,aServiceId ); |
209 //view exists, so delete and remove the same |
201 //view exists, so delete and remove the same |
210 CVIMPSTStorageServiceView* serviceView = iServiceViewList[ index ]; |
202 CVIMPSTStorageServiceView* serviceView = iServiceViewList[ index ]; |
211 iServiceViewList.Remove( index ); |
203 iServiceViewList.Remove( index ); |
212 delete serviceView; |
204 delete serviceView; |
213 iServiceViewList.Compress(); |
205 iServiceViewList.Compress(); |
214 } |
206 } |
215 TRACE( T_LIT("CVIMPSTStorageManager::RemoveServiceView() end") ); |
|
216 } |
207 } |
217 |
208 |
218 // End of File |
209 // End of File |