91 // --------------------------------------------------------- |
94 // --------------------------------------------------------- |
92 // |
95 // |
93 void CGlxImageReader::ConstructL() |
96 void CGlxImageReader::ConstructL() |
94 { |
97 { |
95 TRACER("CGlxImageReader::ConstructL"); |
98 TRACER("CGlxImageReader::ConstructL"); |
96 |
99 |
97 CActiveScheduler::Add(this); |
100 CActiveScheduler::Add(this); |
98 iIsLaunchedFromFMngr = EFalse; |
101 iIsLaunchedFromFMngr = EFalse; |
99 |
102 |
100 iImgViewerMgr = CGlxImageViewerManager::InstanceL(); |
103 iImgViewerMgr = CGlxImageViewerManager::InstanceL(); |
101 if (iImgViewerMgr && iImgViewerMgr->IsPrivate()) |
104 if (!iImgViewerMgr) |
102 { |
105 { |
103 iIsLaunchedFromFMngr = ETrue; |
106 return; |
104 } |
107 } |
105 |
108 |
|
109 if (iImgViewerMgr->IsPrivate()) |
|
110 { |
|
111 iIsLaunchedFromFMngr = ETrue; |
|
112 } |
|
113 |
106 TInt errInImage = KErrNone; |
114 TInt errInImage = KErrNone; |
107 if (iIsLaunchedFromFMngr) |
115 if (iIsLaunchedFromFMngr) |
108 { |
116 { |
109 // TODO type cast handle to RFile |
117 // TODO type cast handle to RFile |
110 TRAP(errInImage,iImageDecoder = CImageDecoder::FileNewL(iImgViewerMgr->ImageFileHandle(), ContentAccess::EPeek)); |
118 TRAP(errInImage,iImageDecoder = CImageDecoder::FileNewL(iImgViewerMgr->ImageFileHandle(), ContentAccess::EPeek)); |
112 else |
120 else |
113 { |
121 { |
114 TRAP(errInImage,iImageDecoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(), iImgViewerMgr->ImageUri()->Des())); |
122 TRAP(errInImage,iImageDecoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(), iImgViewerMgr->ImageUri()->Des())); |
115 } |
123 } |
116 |
124 |
117 if(errInImage != KErrNone) |
125 if (errInImage != KErrNone) |
118 { |
126 { |
119 User::Leave(errInImage); |
127 User::Leave(errInImage); |
120 } |
128 } |
121 iFrame = new(ELeave)CFbsBitmap(); |
129 iFrame = new (ELeave) CFbsBitmap(); |
122 iFrame->Create(iImageDecoder->FrameInfo(0).iOverallSizeInPixels,iImageDecoder->FrameInfo(0).iFrameDisplayMode); |
130 iFrame->Create(iImageDecoder->FrameInfo(0).iOverallSizeInPixels, |
123 iImageDecoder->Convert(&iStatus,*iFrame,0); |
131 iImageDecoder->FrameInfo(0).iFrameDisplayMode); |
|
132 iImageDecoder->Convert(&iStatus, *iFrame, 0); |
|
133 |
124 SetActive(); |
134 SetActive(); |
125 } |
135 } |
126 |
136 |
127 |
137 |
128 // --------------------------------------------------------- |
138 // --------------------------------------------------------- |
141 // |
151 // |
142 void CGlxImageReader::RunL() |
152 void CGlxImageReader::RunL() |
143 { |
153 { |
144 TRACER("CGlxImageReader::RunL"); |
154 TRACER("CGlxImageReader::RunL"); |
145 |
155 |
146 const TSize sz = iFrame->SizeInPixels(); |
156 TSize size = TSize(); |
147 iNotify.ImageReadyL(iStatus.Int(),sz); |
157 TInt reqStatus = iStatus.Int(); |
148 } |
158 if (reqStatus == KErrNone && iFrame) |
149 // --------------------------------------------------------- |
159 { |
150 // CGlxImageReader::HasDRMRightsL |
160 size = iFrame->SizeInPixels(); |
151 // --------------------------------------------------------- |
161 } |
152 // |
162 GLX_DEBUG2("CGlxImageReader::RunL() reqStatus=%d", reqStatus); |
153 TBool CGlxImageReader::HasDRMRightsL() |
163 iNotify.ImageReadyL(reqStatus, size); |
154 { |
164 } |
155 TRACER("Entering CGlxImageReader::HasDRMRightsL"); |
165 // --------------------------------------------------------- |
156 |
166 // CGlxImageReader::GetDRMRightsL |
157 RAttributeSet attributeSet; |
167 // --------------------------------------------------------- |
158 CleanupClosePushL(attributeSet); |
168 // |
159 attributeSet.AddL(ECanView); |
169 TInt CGlxImageReader::GetDRMRightsL(TInt aAttribute) |
160 attributeSet.AddL(EIsProtected); |
170 { |
161 CContent* content; |
171 TRACER("CGlxImageReader::GetDRMRightsL"); |
|
172 |
|
173 TInt value = KErrNone; |
|
174 TInt error = KErrNone; |
|
175 CContent* content = NULL; |
162 if(iIsLaunchedFromFMngr) |
176 if(iIsLaunchedFromFMngr) |
163 { |
177 { |
164 content = CContent::NewL(iImgViewerMgr->ImageFileHandle()); |
178 content = CContent::NewLC(iImgViewerMgr->ImageFileHandle()); |
165 } |
179 } |
166 else |
180 else |
167 { |
181 { |
168 content = CContent::NewL(iImgViewerMgr->ImageUri()->Des()); |
182 content = CContent::NewLC(iImgViewerMgr->ImageUri()->Des()); |
169 } |
183 } |
170 |
184 |
171 // Retrieve the attributes from the agent |
185 __ASSERT_ALWAYS(content, Panic(EGlxPanicNullPointer)); |
172 User::LeaveIfError(content->GetAttributeSet(attributeSet)); |
186 error = content->GetAttribute(aAttribute, value); |
173 TInt rights = ERightsNone; |
187 CleanupStack::PopAndDestroy( content ); |
174 TBool drmProtected = EFalse; |
188 GLX_DEBUG2("CGlxImageReader::GetDRMRightsL value=%d", value); |
175 attributeSet.GetValue(EIsProtected,drmProtected); |
189 if(error != KErrNone) |
176 if(!drmProtected) |
190 { |
177 { |
191 switch ( aAttribute ) |
178 CleanupStack::PopAndDestroy(&attributeSet); |
192 { |
179 delete content; |
193 case ContentAccess::EIsProtected : |
180 content = NULL; |
194 value = ETrue; |
181 return EFalse; |
195 break; |
182 } |
196 case ContentAccess::ECanView : |
183 attributeSet.GetValue(ECanView,rights); |
197 value = EFalse; |
184 CleanupStack::PopAndDestroy(&attributeSet); |
198 break; |
185 |
199 default: |
186 if(content) |
200 value = EFalse; |
187 { |
201 } |
188 delete content; |
202 } |
189 content = NULL; |
203 return value; |
190 } |
204 } |
191 |
|
192 if(rights) |
|
193 { |
|
194 return ETrue; |
|
195 } |
|
196 return EFalse; |
|
197 } |
|