|
1 /* |
|
2 * Copyright (c) 2006-2007 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 the License "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: Scheduled download scheduler.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #include <ipvideo/CCseScheduledProgram.h> |
|
21 #include <ipvideo/CCseSchedulerAPI.h> |
|
22 #include "IptvDebug.h" |
|
23 #include <e32math.h> |
|
24 #include <s32mem.h> |
|
25 |
|
26 #include "iptvvodscheduleddownloadscheduler.h" |
|
27 #include "iptvvodscheduleddownloadactivescheduler.h" |
|
28 #include "CIptvServiceManager.h" |
|
29 #include "CIptvSmEvent.h" |
|
30 |
|
31 const TInt KNoDelay = 0; |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CIptvVODScheduledDownloadScheduler::CIptvVODScheduledDownloadScheduler |
|
35 // C++ default constructor can NOT contain any code, that |
|
36 // might leave. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CIptvVODScheduledDownloadScheduler::CIptvVODScheduledDownloadScheduler( |
|
40 CIptvServiceManager& aServiceManager ) : iServiceManager( aServiceManager ) |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CIptvVODScheduledDownloadScheduler::ConstructL |
|
46 // Symbian 2nd phase constructor can leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CIptvVODScheduledDownloadScheduler::ConstructL() |
|
50 { |
|
51 User::LeaveIfError( iServiceManager.RegisterObserver( this ) ); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CIptvVODScheduledDownloadScheduler::NewL |
|
56 // Two-phased constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CIptvVODScheduledDownloadScheduler* CIptvVODScheduledDownloadScheduler::NewL( |
|
60 CIptvServiceManager& aServiceManager ) |
|
61 { |
|
62 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvVODScheduledDownloadScheduler::NewL()"); |
|
63 |
|
64 CIptvVODScheduledDownloadScheduler* self = |
|
65 new( ELeave ) CIptvVODScheduledDownloadScheduler( aServiceManager ); |
|
66 |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop( self ); |
|
70 |
|
71 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvVODScheduledDownloadScheduler::NewL()"); |
|
72 |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // Destructor |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CIptvVODScheduledDownloadScheduler::~CIptvVODScheduledDownloadScheduler() |
|
81 { |
|
82 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvVODScheduledDownloadScheduler::~CIptvVODScheduledDownloadScheduler()"); |
|
83 |
|
84 iServiceManager.DeRegisterObserver( this ); |
|
85 |
|
86 for (TInt i = 0; i < iActiveSchedulers.Count(); i++) |
|
87 { |
|
88 iActiveSchedulers[i]->Cancel(); |
|
89 } |
|
90 |
|
91 iActiveSchedulers.ResetAndDestroy(); |
|
92 |
|
93 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvVODScheduledDownloadScheduler::~CIptvVODScheduledDownloadScheduler()"); |
|
94 } |
|
95 |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CIptvVODScheduledDownloadScheduler::HandleSmEvent |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CIptvVODScheduledDownloadScheduler::HandleSmEvent( CIptvSmEvent& aEvent ) |
|
102 { |
|
103 TRAP_IGNORE( HandleSmEventL( aEvent ) ); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CIptvVODScheduledDownloadScheduler::HandleSmEventL |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CIptvVODScheduledDownloadScheduler::HandleSmEventL( |
|
111 CIptvSmEvent& aEvent ) |
|
112 { |
|
113 IPTVLOGSTRING2_HIGH_LEVEL(">>> CIptvVODScheduledDownloadScheduler::HandleSmEvent(), event: %d", aEvent.iEvent); |
|
114 |
|
115 switch (aEvent.iEvent) |
|
116 { |
|
117 case CIptvSmEvent::EServiceAdded: |
|
118 case CIptvSmEvent::EServiceScheduleModified: |
|
119 { |
|
120 // Only reschedule if there is a service |
|
121 if (aEvent.iService) |
|
122 { |
|
123 // Create, add and activate scheduler object |
|
124 CIptvVODScheduledDownloadActiveScheduler* active = |
|
125 CIptvVODScheduledDownloadActiveScheduler::NewL( |
|
126 *this, |
|
127 aEvent.iServiceId, |
|
128 (TIptvVodScheduleConnectionCondition) |
|
129 aEvent.iService->ScheduleDlNetwork(), |
|
130 aEvent.iService->ScheduleDlTime(), |
|
131 aEvent.iService->ScheduleDlType()); |
|
132 active->After( TTimeIntervalMicroSeconds32( KNoDelay ) ); |
|
133 |
|
134 // The scheduling object will remove itself from the list |
|
135 CleanupStack::PushL( active ); |
|
136 iActiveSchedulers.AppendL( active ); |
|
137 CleanupStack::Pop( active ); |
|
138 } |
|
139 } |
|
140 break; |
|
141 |
|
142 case CIptvSmEvent::EServiceDeleted: |
|
143 { |
|
144 // Create, add and activate scheduler object |
|
145 // The settings cause all schedules to be deleted |
|
146 CIptvVODScheduledDownloadActiveScheduler* active = |
|
147 CIptvVODScheduledDownloadActiveScheduler::NewL( |
|
148 *this, |
|
149 aEvent.iServiceId, |
|
150 EManual, |
|
151 ENoSchedule, |
|
152 ENoDownload); |
|
153 active->After( TTimeIntervalMicroSeconds32( KNoDelay ) ); |
|
154 |
|
155 // The scheduling object will remove itself from the list |
|
156 CleanupStack::PushL( active ); |
|
157 iActiveSchedulers.AppendL( active ); |
|
158 CleanupStack::Pop( active ); |
|
159 } |
|
160 break; |
|
161 |
|
162 default: |
|
163 break; |
|
164 } |
|
165 |
|
166 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvVODScheduledDownloadScheduler::HandleSmEvent()"); |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CIptvVODScheduledDownloadScheduler::RemoveActive |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CIptvVODScheduledDownloadScheduler::RemoveActive( |
|
174 CIptvVODScheduledDownloadActiveScheduler* aActive ) |
|
175 { |
|
176 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvVODScheduledDownloadScheduler::RemoveActive()"); |
|
177 |
|
178 TInt index = iActiveSchedulers.Find( aActive ); |
|
179 if (index != KErrNotFound) |
|
180 { |
|
181 iActiveSchedulers.Remove( index ); |
|
182 } |
|
183 |
|
184 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvVODScheduledDownloadScheduler::RemoveActive()"); |
|
185 } |
|
186 |
|
187 // End of File |