48 // --------------------------------------------------------------------------- |
48 // --------------------------------------------------------------------------- |
49 // |
49 // |
50 void CVcxMyVideosMdsAlbums::ConstructL() |
50 void CVcxMyVideosMdsAlbums::ConstructL() |
51 { |
51 { |
52 GetSchemaDefinitionsL(); |
52 GetSchemaDefinitionsL(); |
53 CActiveScheduler::Add( this ); |
53 SetObservingL(); |
54 |
54 CActiveScheduler::Add( this ); |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Two-Phase Constructor |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CVcxMyVideosMdsAlbums* CVcxMyVideosMdsAlbums::NewL( CVcxMyVideosMdsDb& aMdsDb, |
|
62 MVcxMyVideosMdsAlbumsObserver* aObserver ) |
|
63 { |
|
64 CVcxMyVideosMdsAlbums* self = new(ELeave) CVcxMyVideosMdsAlbums( aMdsDb, aObserver ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Destructor |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CVcxMyVideosMdsAlbums::~CVcxMyVideosMdsAlbums() |
|
76 { |
|
77 CancelQueries(); |
|
78 delete iAlbumQuery; |
|
79 delete iVideoQuery; |
|
80 delete iRelationQuery; |
|
81 iItemArray.Close(); |
|
82 iResultBuffer.Close(); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CVcxMyVideosMdsAlbums::CancelQueries |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 void CVcxMyVideosMdsAlbums::CancelQueries( CVcxMyVideosMdsDb::TRequestType aType ) |
|
90 { |
|
91 MPX_DEBUG1("CVcxMyVideosMdsAlbums::CancelQueries() start"); |
|
92 |
|
93 if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbums ) |
|
94 { |
|
95 if ( iAlbumQuery ) |
|
96 { |
|
97 iAlbumQuery->Cancel(); |
|
98 } |
|
99 } |
|
100 |
|
101 if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentIds ) |
|
102 { |
|
103 if ( iRelationQuery ) |
|
104 { |
|
105 iRelationQuery->Cancel(); |
|
106 } |
|
107 } |
|
108 |
|
109 if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentVideos ) |
|
110 { |
|
111 if ( iVideoQuery ) |
|
112 { |
|
113 iVideoQuery->Cancel(); |
|
114 } |
|
115 } |
|
116 |
|
117 if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EAddVideosToAlbum |
|
118 || aType == CVcxMyVideosMdsDb::ERemoveRelations |
|
119 || aType == CVcxMyVideosMdsDb::ERemoveAlbums ) |
|
120 { |
|
121 |
|
122 // MDS does not offer cancel for these |
|
123 //Cancel(); |
|
124 } |
|
125 |
|
126 MPX_DEBUG1("CVcxMyVideosMdsAlbums::CancelQueries() exit"); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // From CActive |
|
131 // CVcxMyVideosMdsAlbums::DoCancel |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 void CVcxMyVideosMdsAlbums::DoCancel() |
|
135 { |
|
136 MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoCancel() start"); |
|
137 |
|
138 // MDS does not offer way to cancel these async requests |
|
139 |
|
140 MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoCancel() exit"); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CVcxMyVideosMdsAlbums::SetObservingL |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CVcxMyVideosMdsAlbums::SetObservingL() |
|
148 { |
55 if ( iObserver ) |
149 if ( iObserver ) |
56 { |
150 { |
57 //ENotifyAdd and ENotifyModify are not supported |
151 //ENotifyAdd and ENotifyModify are not supported |
58 iMdsDb.MdsSessionL().AddRelationItemObserverL( *this, NULL, |
152 iMdsDb.MdsSessionL().AddRelationItemObserverL( *this, NULL, |
59 ENotifyRemove, iMdsDb.iNamespaceDef ); |
153 ENotifyRemove, iMdsDb.iNamespaceDef ); |
64 // the add operation instead. This way we don't receive |
158 // the add operation instead. This way we don't receive |
65 // add events if someone else adds videos to our albums |
159 // add events if someone else adds videos to our albums |
66 // but the performance is the best possible. |
160 // but the performance is the best possible. |
67 iMdsDb.MdsSessionL().AddRelationObserverL( *this, NULL, |
161 iMdsDb.MdsSessionL().AddRelationObserverL( *this, NULL, |
68 ENotifyAdd | ENotifyModify | ENotifyRemove ); |
162 ENotifyAdd | ENotifyModify | ENotifyRemove ); |
69 #endif |
163 #endif |
70 } |
164 } |
71 |
|
72 //TODO: do we need this? |
|
73 //iMdsDb.MdsSessionL().AddRelationPresentObserverL(); |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Two-Phase Constructor |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 CVcxMyVideosMdsAlbums* CVcxMyVideosMdsAlbums::NewL( CVcxMyVideosMdsDb& aMdsDb, |
|
81 MVcxMyVideosMdsAlbumsObserver* aObserver ) |
|
82 { |
|
83 CVcxMyVideosMdsAlbums* self = new(ELeave) CVcxMyVideosMdsAlbums( aMdsDb, aObserver ); |
|
84 CleanupStack::PushL( self ); |
|
85 self->ConstructL(); |
|
86 CleanupStack::Pop( self ); |
|
87 return self; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // Destructor |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 CVcxMyVideosMdsAlbums::~CVcxMyVideosMdsAlbums() |
|
95 { |
|
96 CancelQueries(); |
|
97 delete iAlbumQuery; |
|
98 delete iVideoQuery; |
|
99 delete iRelationQuery; |
|
100 iItemArray.Close(); |
|
101 iResultBuffer.Close(); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CVcxMyVideosMdsAlbums::CancelQueries |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CVcxMyVideosMdsAlbums::CancelQueries( CVcxMyVideosMdsDb::TRequestType aType ) |
|
109 { |
|
110 MPX_DEBUG1("CVcxMyVideosMdsAlbums::CancelQueries() start"); |
|
111 |
|
112 if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbums ) |
|
113 { |
|
114 if ( iAlbumQuery ) |
|
115 { |
|
116 iAlbumQuery->Cancel(); |
|
117 } |
|
118 } |
|
119 |
|
120 if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentIds ) |
|
121 { |
|
122 if ( iRelationQuery ) |
|
123 { |
|
124 iRelationQuery->Cancel(); |
|
125 } |
|
126 } |
|
127 |
|
128 if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentVideos ) |
|
129 { |
|
130 if ( iVideoQuery ) |
|
131 { |
|
132 iVideoQuery->Cancel(); |
|
133 } |
|
134 } |
|
135 |
|
136 if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EAddVideosToAlbum |
|
137 || aType == CVcxMyVideosMdsDb::ERemoveRelations |
|
138 || aType == CVcxMyVideosMdsDb::ERemoveAlbums ) |
|
139 { |
|
140 |
|
141 // MDS does not offer cancel for these |
|
142 //Cancel(); |
|
143 } |
|
144 |
|
145 MPX_DEBUG1("CVcxMyVideosMdsAlbums::CancelQueries() exit"); |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // From CActive |
|
150 // CVcxMyVideosMdsAlbums::DoCancel |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void CVcxMyVideosMdsAlbums::DoCancel() |
|
154 { |
|
155 MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoCancel() start"); |
|
156 |
|
157 // MDS does not offer way to cancel these async requests |
|
158 |
|
159 MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoCancel() exit"); |
|
160 } |
165 } |
161 |
166 |
162 // --------------------------------------------------------------------------- |
167 // --------------------------------------------------------------------------- |
163 // CVcxMyVideosMdsAlbums::GetAlbumsL |
168 // CVcxMyVideosMdsAlbums::GetAlbumsL |
164 // --------------------------------------------------------------------------- |
169 // --------------------------------------------------------------------------- |