114
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "mcsdrmobservermanager.h"
|
|
20 |
#include "mcsdrmobserver.h"
|
|
21 |
#include "menusrvengutils.h"
|
|
22 |
#include <apaid.h>
|
|
23 |
#include <DRMEvent.h>
|
|
24 |
|
|
25 |
|
|
26 |
// ---------------------------------------------------------------------------
|
|
27 |
// destructor
|
|
28 |
// ---------------------------------------------------------------------------
|
|
29 |
RMcsDrmObserverManager::~RMcsDrmObserverManager()
|
|
30 |
{
|
|
31 |
}
|
|
32 |
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
// destructor
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
void RMcsDrmObserverManager::Close()
|
|
37 |
{
|
|
38 |
iObservers.ResetAndDestroy();
|
|
39 |
}
|
|
40 |
|
|
41 |
|
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
// default constructor
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
RMcsDrmObserverManager::RMcsDrmObserverManager( CMenuSrvEngUtils& aUtils ):
|
|
46 |
iUtils( aUtils )
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
void RMcsDrmObserverManager::AddL( CMcsDrmObserver* aObserver )
|
|
54 |
{
|
|
55 |
User::LeaveIfError( iObservers.Append( aObserver ) );
|
|
56 |
}
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
void RMcsDrmObserverManager::Remove( CMcsDrmObserver* aObserver )
|
|
62 |
{
|
|
63 |
TInt ptrIndex( iObservers.Find( aObserver ) );
|
|
64 |
if ( KErrNotFound != ptrIndex )
|
|
65 |
{
|
|
66 |
delete aObserver;
|
|
67 |
iObservers.Remove( ptrIndex );
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
void RMcsDrmObserverManager::RemoveMissingObservers(
|
|
75 |
const RArray<TUid>& aDrmProtectedArray )
|
|
76 |
{
|
|
77 |
TInt index = 0;
|
|
78 |
while (index < iObservers.Count() )
|
|
79 |
{
|
|
80 |
if ( aDrmProtectedArray.Find( iObservers[index]->Uid() ) == KErrNotFound )
|
|
81 |
{
|
|
82 |
delete iObservers[index];
|
|
83 |
iObservers.Remove( index );
|
|
84 |
}
|
|
85 |
else
|
|
86 |
{
|
|
87 |
index++;
|
|
88 |
}
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
TInt RMcsDrmObserverManager::FindUid( TUid aUid )
|
|
96 |
{
|
|
97 |
TInt ret( KErrNotFound );
|
|
98 |
for (TInt i = 0; i < iObservers.Count(); i++)
|
|
99 |
{
|
|
100 |
if (iObservers[i]->Uid() == aUid)
|
|
101 |
{
|
|
102 |
ret = i;
|
|
103 |
break;
|
|
104 |
}
|
|
105 |
}
|
|
106 |
return ret;
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
void RMcsDrmObserverManager::CreateObserversL(
|
|
113 |
const RArray<TUid>& aDrmArray,
|
|
114 |
TDRMEventType aMask,
|
|
115 |
MMcsDrmObserver& aObserver )
|
|
116 |
{
|
|
117 |
for (TInt i = 0; i < aDrmArray.Count(); i++)
|
|
118 |
{
|
|
119 |
if (FindUid(aDrmArray[i]) == KErrNotFound)
|
|
120 |
{
|
|
121 |
CMcsDrmObserver* observer= NULL;
|
|
122 |
if ( iUtils.IsMiddlet( aDrmArray[i] ) )
|
|
123 |
{
|
|
124 |
TBuf<KMaxFileName> contentId;
|
|
125 |
iUtils.GetJavaContentIdL( aDrmArray[i], contentId );
|
|
126 |
|
|
127 |
observer = CMcsDrmObserver::NewL(aObserver, contentId,
|
|
128 |
aDrmArray[i], aMask);
|
|
129 |
|
|
130 |
TInt err = iObservers.Append(observer);
|
|
131 |
if( err != KErrNone)
|
|
132 |
{
|
|
133 |
delete observer;
|
|
134 |
User::Leave( err );
|
|
135 |
}
|
|
136 |
}
|
|
137 |
}
|
|
138 |
}
|
|
139 |
}
|
|
140 |
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
void RMcsDrmObserverManager::CreateObserversL(
|
|
145 |
const RArray<TUid>& aDrmProtectedArray,
|
|
146 |
MMcsDrmObserver& aObserver )
|
|
147 |
{
|
|
148 |
CreateObserversL(aDrmProtectedArray, KEventModify,
|
|
149 |
aObserver);
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
void RMcsDrmObserverManager::RefreshObserverL(
|
|
156 |
const RArray<TUid>& aDrmProtectedArray,
|
|
157 |
TUid aUid,
|
|
158 |
MMcsDrmObserver& aObserver )
|
|
159 |
{
|
|
160 |
TInt index = FindUid( aUid );
|
|
161 |
if ( index != KErrNotFound )
|
|
162 |
{
|
|
163 |
delete iObservers[index];
|
|
164 |
iObservers.Remove( index );
|
|
165 |
CreateObserversL(aDrmProtectedArray, KEventModify,
|
|
166 |
aObserver);
|
|
167 |
}
|
|
168 |
|
|
169 |
}
|