31 // ----------------------------------------------------------------------------- |
31 // ----------------------------------------------------------------------------- |
32 // CMcsCacheHandler::NewL |
32 // CMcsCacheHandler::NewL |
33 // Two-phased constructor. |
33 // Two-phased constructor. |
34 // ----------------------------------------------------------------------------- |
34 // ----------------------------------------------------------------------------- |
35 // |
35 // |
36 EXPORT_C CMcsCacheHandler* CMcsCacheHandler::NewL( |
36 EXPORT_C CMcsCacheHandler* CMcsCacheHandler::NewL( |
37 CMenuEng& aEng, |
37 CMenuEng& aEng, |
38 CMenuSrvEngUtils& aUtils ) |
38 CMenuSrvEngUtils& aUtils ) |
39 { |
39 { |
40 CMcsCacheHandler* self = new( ELeave ) CMcsCacheHandler( aEng, aUtils ); |
40 CMcsCacheHandler* self = new( ELeave ) CMcsCacheHandler( aEng, aUtils ); |
41 CleanupStack::PushL( self ); |
41 CleanupStack::PushL( self ); |
42 self->ConstructL(); |
42 self->ConstructL(); |
43 CleanupStack::Pop( self ); |
43 CleanupStack::Pop( self ); |
44 return self; |
44 return self; |
45 } |
45 } |
46 |
46 |
47 // ----------------------------------------------------------------------------- |
47 // ----------------------------------------------------------------------------- |
48 // Destructor |
48 // Destructor |
49 // ----------------------------------------------------------------------------- |
49 // ----------------------------------------------------------------------------- |
50 CMcsCacheHandler::~CMcsCacheHandler() |
50 CMcsCacheHandler::~CMcsCacheHandler() |
51 { |
51 { |
52 iAttrCache.ResetAndDestroy(); |
52 iAttrCache.ResetAndDestroy(); |
56 // CMcsCacheHandler::CMcsCacheHandler |
56 // CMcsCacheHandler::CMcsCacheHandler |
57 // C++ default constructor can NOT contain any code, that |
57 // C++ default constructor can NOT contain any code, that |
58 // might leave. |
58 // might leave. |
59 // ----------------------------------------------------------------------------- |
59 // ----------------------------------------------------------------------------- |
60 // |
60 // |
61 CMcsCacheHandler::CMcsCacheHandler( |
61 CMcsCacheHandler::CMcsCacheHandler( |
62 CMenuEng& aEng, |
62 CMenuEng& aEng, |
63 CMenuSrvEngUtils& aUtils ): iEng( aEng ), iUtils( aUtils ) |
63 CMenuSrvEngUtils& aUtils ): iEng( aEng ), iUtils( aUtils ) |
64 { |
64 { |
65 } |
65 } |
66 |
66 |
73 { |
73 { |
74 } |
74 } |
75 |
75 |
76 // ----------------------------------------------------------------------------- |
76 // ----------------------------------------------------------------------------- |
77 // ----------------------------------------------------------------------------- |
77 // ----------------------------------------------------------------------------- |
78 // |
78 // |
79 void CMcsCacheHandler::HandleRemoveId( TInt aId ) |
79 void CMcsCacheHandler::HandleRemoveId( TInt aId ) |
80 { |
80 { |
81 iAttrCache.RemoveId( aId ); |
81 iAttrCache.RemoveId( aId ); |
82 } |
82 } |
83 |
83 |
84 // ----------------------------------------------------------------------------- |
84 // ----------------------------------------------------------------------------- |
85 // ----------------------------------------------------------------------------- |
85 // ----------------------------------------------------------------------------- |
86 // |
86 // |
87 void CMcsCacheHandler::HandleRemoveAttribute( TInt aId, const TDesC& aAttrName ) |
87 void CMcsCacheHandler::HandleRemoveAttribute( TInt aId, const TDesC& aAttrName ) |
88 { |
88 { |
89 iAttrCache.RemoveAttribute(aId, aAttrName); |
89 iAttrCache.RemoveAttribute(aId, aAttrName); |
90 } |
90 } |
91 |
91 |
92 // ----------------------------------------------------------------------------- |
92 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
94 // |
94 // |
95 void CMcsCacheHandler::EngineEvents( TInt aEvents ) |
95 void CMcsCacheHandler::EngineEvents( TInt aEvents ) |
96 { |
96 { |
97 if( aEvents & RMenuNotifier::EItemsAddedRemoved ) |
97 if( aEvents & RMenuNotifier::EItemsAddedRemoved ) |
98 { |
98 { |
99 RemoveNotExistItems(); |
99 RemoveNotExistItems(); |
100 } |
100 } |
101 if( aEvents & RMenuNotifier::EItemAttributeChanged ) |
101 if( aEvents & RMenuNotifier::EItemAttributeChanged ) |
102 { |
102 { |
103 TRAP_IGNORE(RemoveItemsWithChangedAttributesL()); |
103 TRAP_IGNORE( RemoveItemsWithChangedAttributesL() ); |
104 } |
104 } |
105 } |
105 } |
106 |
106 |
107 // --------------------------------------------------------- |
107 // --------------------------------------------------------- |
108 // RMenuSrvAttrArray::RemoveId |
108 // RMenuSrvAttrArray::RemoveId |
116 TBool exist; |
116 TBool exist; |
117 |
117 |
118 TInt id = iAttrCache[i]->Id(); |
118 TInt id = iAttrCache[i]->Id(); |
119 TPtrC name = iAttrCache[i]->Name(); |
119 TPtrC name = iAttrCache[i]->Name(); |
120 TPtrC valueCache = iAttrCache[i]->Value(); |
120 TPtrC valueCache = iAttrCache[i]->Value(); |
121 |
121 |
122 TPtrC valueXml(KNullDesC); |
122 TPtrC valueXml(KNullDesC); |
123 |
123 |
124 exist = iEng.ObjectL(id).FindAttribute( name, valueXml, dummy ); |
124 exist = iEng.ObjectL(id).FindAttribute( name, valueXml, dummy ); |
125 if( exist && valueXml != valueCache ) |
125 if( exist && valueXml != valueCache ) |
126 { |
126 { |
127 iAttrCache.RemoveAttribute( id, name ); |
127 iAttrCache.RemoveAttribute( id, name ); |
128 i--; |
128 i--; |