60
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2009 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: glximagereader.cpp
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <apgcli.h>
|
|
20 |
#include <glxtracer.h>
|
|
21 |
#include <glxlog.h>
|
|
22 |
#include <glxpanic.h>
|
|
23 |
|
|
24 |
//for DRM
|
|
25 |
#include <caf/content.h>
|
|
26 |
#include <caf/attributeset.h>
|
|
27 |
#include <DRMHelper.h>
|
|
28 |
|
|
29 |
#include "glximagereader.h"
|
|
30 |
|
|
31 |
const TInt KDefaultFrameCount = 1;
|
|
32 |
|
|
33 |
// ---------------------------------------------------------
|
|
34 |
// CGlxImageReader::NewL
|
|
35 |
// ---------------------------------------------------------
|
|
36 |
//
|
|
37 |
CGlxImageReader* CGlxImageReader::NewL()
|
|
38 |
{
|
|
39 |
TRACER("CGlxImageReader::NewL");
|
|
40 |
|
|
41 |
CGlxImageReader* self = CGlxImageReader::NewLC();
|
|
42 |
CleanupStack::Pop(self);
|
|
43 |
return self;
|
|
44 |
}
|
|
45 |
|
|
46 |
// ---------------------------------------------------------
|
|
47 |
// CGlxImageReader::NewLC
|
|
48 |
// ---------------------------------------------------------
|
|
49 |
//
|
|
50 |
CGlxImageReader* CGlxImageReader::NewLC()
|
|
51 |
{
|
|
52 |
TRACER("CGlxImageReader::NewLC");
|
|
53 |
|
|
54 |
CGlxImageReader* self = new(ELeave) CGlxImageReader();
|
|
55 |
CleanupStack::PushL(self);
|
|
56 |
self->ConstructL();
|
|
57 |
return self;
|
|
58 |
}
|
|
59 |
|
|
60 |
// ---------------------------------------------------------
|
|
61 |
// CGlxImageReader::CGlxImageReader
|
|
62 |
// ---------------------------------------------------------
|
|
63 |
//
|
|
64 |
CGlxImageReader::CGlxImageReader()
|
|
65 |
{
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------
|
|
69 |
// CGlxImageReader::~CGlxImageReader
|
|
70 |
// ---------------------------------------------------------
|
|
71 |
//
|
|
72 |
CGlxImageReader::~CGlxImageReader()
|
|
73 |
{
|
|
74 |
TRACER("CGlxImageReader::~");
|
|
75 |
if(iImageDecoder)
|
|
76 |
{
|
|
77 |
delete iImageDecoder;
|
|
78 |
}
|
|
79 |
|
|
80 |
if(iImgViewerMgr)
|
|
81 |
{
|
|
82 |
iImgViewerMgr->DeleteInstance();
|
|
83 |
}
|
|
84 |
}
|
|
85 |
|
|
86 |
// ---------------------------------------------------------
|
|
87 |
// CGlxImageReader::ConstructL
|
|
88 |
// ---------------------------------------------------------
|
|
89 |
//
|
|
90 |
void CGlxImageReader::ConstructL()
|
|
91 |
{
|
|
92 |
TRACER("CGlxImageReader::ConstructL");
|
|
93 |
|
|
94 |
iImgViewerMgr = CGlxImageViewerManager::InstanceL();
|
|
95 |
if (!iImgViewerMgr)
|
|
96 |
{
|
|
97 |
return;
|
|
98 |
}
|
|
99 |
|
|
100 |
TInt errInImage = KErrNone;
|
|
101 |
if (iImgViewerMgr->IsPrivate())
|
|
102 |
{
|
|
103 |
if ( &(iImgViewerMgr->ImageFileHandle()) )
|
|
104 |
{
|
|
105 |
TRAP(errInImage,iImageDecoder = CImageDecoder::FileNewL(iImgViewerMgr->ImageFileHandle(), ContentAccess::EPeek));
|
|
106 |
GLX_DEBUG2("CGlxImageReader::ConstructL() FH:errInImage=%d", errInImage);
|
|
107 |
}
|
|
108 |
}
|
|
109 |
else
|
|
110 |
{
|
|
111 |
if ( iImgViewerMgr->ImageUri() )
|
|
112 |
{
|
|
113 |
TRAP(errInImage,iImageDecoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(), iImgViewerMgr->ImageUri()->Des()));
|
|
114 |
GLX_DEBUG2("CGlxImageReader::ConstructL() FN:errInImage=%d", errInImage);
|
|
115 |
}
|
|
116 |
}
|
|
117 |
|
|
118 |
if (errInImage != KErrNone)
|
|
119 |
{
|
|
120 |
GLX_DEBUG2("CGlxImageReader::ConstructL() LEAVE(%d)", errInImage);
|
|
121 |
User::Leave(errInImage);
|
|
122 |
}
|
|
123 |
}
|
|
124 |
|
|
125 |
// ---------------------------------------------------------
|
|
126 |
// CGlxImageReader::GetDRMRightsL
|
|
127 |
// ---------------------------------------------------------
|
|
128 |
//
|
|
129 |
TInt CGlxImageReader::GetDRMRightsL(TInt aAttribute)
|
|
130 |
{
|
|
131 |
TRACER("CGlxImageReader::GetDRMRightsL");
|
|
132 |
|
|
133 |
TInt value = KErrNone;
|
|
134 |
TInt error = KErrNone;
|
|
135 |
CContent* content = NULL;
|
|
136 |
if(iImgViewerMgr->IsPrivate())
|
|
137 |
{
|
|
138 |
if ( &(iImgViewerMgr->ImageFileHandle()) )
|
|
139 |
{
|
|
140 |
content = CContent::NewLC(iImgViewerMgr->ImageFileHandle());
|
|
141 |
}
|
|
142 |
}
|
|
143 |
else
|
|
144 |
{
|
|
145 |
if ( iImgViewerMgr->ImageUri() )
|
|
146 |
{
|
|
147 |
content = CContent::NewLC(iImgViewerMgr->ImageUri()->Des());
|
|
148 |
}
|
|
149 |
}
|
|
150 |
__ASSERT_ALWAYS(content, Panic(EGlxPanicNullPointer));
|
|
151 |
error = content->GetAttribute(aAttribute, value);
|
|
152 |
CleanupStack::PopAndDestroy( content );
|
|
153 |
|
|
154 |
if(error != KErrNone)
|
|
155 |
{
|
|
156 |
switch ( aAttribute )
|
|
157 |
{
|
|
158 |
case ContentAccess::EIsProtected :
|
|
159 |
value = ETrue;
|
|
160 |
break;
|
|
161 |
case ContentAccess::ECanView :
|
|
162 |
value = EFalse;
|
|
163 |
break;
|
|
164 |
default:
|
|
165 |
value = EFalse;
|
|
166 |
}
|
|
167 |
}
|
|
168 |
GLX_DEBUG2("CGlxImageReader::GetDRMRightsL error =%d", error);
|
|
169 |
GLX_DEBUG2("CGlxImageReader::GetDRMRightsL value=%d", value);
|
|
170 |
return value;
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------
|
|
174 |
// CGlxImageReader::GetFrameCount
|
|
175 |
// ---------------------------------------------------------
|
|
176 |
//
|
|
177 |
TInt CGlxImageReader::GetFrameCount()
|
|
178 |
{
|
|
179 |
TRACER("CGlxImageReader::GetFrameCount");
|
|
180 |
TInt frameCount = KDefaultFrameCount;
|
|
181 |
if (iImageDecoder)
|
|
182 |
{
|
|
183 |
frameCount = iImageDecoder->FrameCount();
|
|
184 |
}
|
|
185 |
GLX_DEBUG2("CGlxImageReader::GetFrameCount frameCount=%d", frameCount);
|
|
186 |
return frameCount;
|
|
187 |
}
|
|
188 |
|
|
189 |
// ---------------------------------------------------------
|
|
190 |
// CGlxImageReader::GetDimensions
|
|
191 |
// ---------------------------------------------------------
|
|
192 |
//
|
|
193 |
TSize CGlxImageReader::GetDimensions()
|
|
194 |
{
|
|
195 |
TRACER("CGlxImageReader::GetDimensions");
|
|
196 |
TSize size = TSize();
|
|
197 |
if (iImageDecoder)
|
|
198 |
{
|
|
199 |
size = iImageDecoder->FrameInfo().iOverallSizeInPixels;
|
|
200 |
}
|
|
201 |
GLX_DEBUG3("CGlxImageReader::GetImageSize() size w(%d) h(%d)",
|
|
202 |
size.iWidth, size.iHeight);
|
|
203 |
return size;
|
|
204 |
}
|