|
1 /* |
|
2 * Copyright (c) 2004-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 using System; |
|
19 using System.IO; |
|
20 using System.Collections.Generic; |
|
21 using System.Text; |
|
22 using System.Threading; |
|
23 using SymbianStructuresLib.CodeSegments; |
|
24 using SymbianStructuresLib.Debug.Code; |
|
25 using SymbianStructuresLib.Debug.Code.Interfaces; |
|
26 using SymbianCodeLib.SourceManagement.Source; |
|
27 using SymbianCodeLib.SourceManagement.Provisioning; |
|
28 using SymbianUtils; |
|
29 using SymbianUtils.Tracer; |
|
30 using SymbianUtils.FileTypes; |
|
31 using SymbianImageLib.Common.Image; |
|
32 using SymbianImageLib.Common.Content; |
|
33 using CLPluginImg.Source; |
|
34 using CLPluginImg.Provider; |
|
35 |
|
36 namespace CLPluginImg.Reader |
|
37 { |
|
38 internal class ImgReader : DisposableObject |
|
39 { |
|
40 #region Constructors |
|
41 public ImgReader( ImgSource aSource, ITracer aTracer ) |
|
42 { |
|
43 iSource = aSource; |
|
44 iImageContent = aSource.ImageContent; |
|
45 iImageContent.DecompressionEvent += new SIContent.DecompressionEventHandler( ImageContent_PreparationEvent ); |
|
46 } |
|
47 #endregion |
|
48 |
|
49 #region API |
|
50 public void Read( TSynchronicity aSynchronicity ) |
|
51 { |
|
52 iImageContent.PrepareContent( aSynchronicity ); |
|
53 } |
|
54 #endregion |
|
55 |
|
56 #region Properties |
|
57 protected CodeCollection Collection |
|
58 { |
|
59 get |
|
60 { |
|
61 SymbianUtils.SymDebug.SymDebugger.Assert( iSource.Count == 1 ); |
|
62 return iSource[ 0 ]; |
|
63 } |
|
64 } |
|
65 #endregion |
|
66 |
|
67 #region Event handlers |
|
68 private void ImageContent_PreparationEvent( SIContent.TDecompressionEvent aEvent, SIContent aFile, object aData ) |
|
69 { |
|
70 switch ( aEvent ) |
|
71 { |
|
72 case SIContent.TDecompressionEvent.EEventDecompressionStarting: |
|
73 iSource.ReportEvent( CodeSource.TEvent.EReadingStarted ); |
|
74 break; |
|
75 case SIContent.TDecompressionEvent.EEventDecompressionProgress: |
|
76 iSource.ReportEvent( CodeSource.TEvent.EReadingProgress,( aData != null && aData is Int32 ) ? (int) aData : 0 ); |
|
77 break; |
|
78 case SIContent.TDecompressionEvent.EEventDecompressionComplete: |
|
79 OnComplete(); |
|
80 break; |
|
81 } |
|
82 } |
|
83 #endregion |
|
84 |
|
85 #region Internal methods |
|
86 private void OnComplete() |
|
87 { |
|
88 iSource.ReportEvent( CodeSource.TEvent.EReadingComplete ); |
|
89 this.Dispose(); |
|
90 } |
|
91 #endregion |
|
92 |
|
93 #region From DisposableObject |
|
94 protected override void CleanupManagedResources() |
|
95 { |
|
96 try |
|
97 { |
|
98 base.CleanupManagedResources(); |
|
99 } |
|
100 finally |
|
101 { |
|
102 iImageContent.DecompressionEvent -= new SIContent.DecompressionEventHandler( ImageContent_PreparationEvent ); |
|
103 } |
|
104 } |
|
105 #endregion |
|
106 |
|
107 #region Data members |
|
108 private readonly CodeSource iSource; |
|
109 private readonly SIContent iImageContent; |
|
110 #endregion |
|
111 } |
|
112 } |