|
1 /* |
|
2 * Copyright (c) 2004-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 "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 <centralrepository.h> |
|
20 |
|
21 #include "imageprintprivatecrkeys.h" |
|
22 #include "cimageprintengine.h" |
|
23 #include "ciffactory.h" |
|
24 #include "crealfactory.h" |
|
25 #include "clog.h" |
|
26 #include "mprintsettings.h" |
|
27 |
|
28 // CONSTRUCTION |
|
29 EXPORT_C CImagePrintEngine* CImagePrintEngine::NewL( |
|
30 CDesCArrayFlat* aImageFiles ) |
|
31 { |
|
32 CImagePrintEngine* self = CImagePrintEngine::NewLC( aImageFiles ); |
|
33 CleanupStack::Pop(); // self |
|
34 |
|
35 return self; |
|
36 } |
|
37 |
|
38 EXPORT_C CImagePrintEngine* CImagePrintEngine::NewLC( |
|
39 CDesCArrayFlat* aImageFiles ) |
|
40 { |
|
41 CImagePrintEngine* self = new ( ELeave ) CImagePrintEngine; |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL( aImageFiles ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // Destructor (virtual by CBase) |
|
48 CImagePrintEngine::~CImagePrintEngine() |
|
49 { |
|
50 delete iIFFactory; |
|
51 delete iFiles; |
|
52 iFileArray.ResetAndDestroy(); |
|
53 iFileArray.Close(); |
|
54 delete iCRSession; |
|
55 } |
|
56 |
|
57 // Default constructor |
|
58 CImagePrintEngine::CImagePrintEngine() |
|
59 { |
|
60 } |
|
61 |
|
62 // Second phase construct |
|
63 void CImagePrintEngine::ConstructL( |
|
64 CDesCArrayFlat* aImageFiles ) |
|
65 { |
|
66 CleanupStack::PushL( aImageFiles ); |
|
67 iIFFactory = CRealFactory::NewL( this ); |
|
68 CleanupStack::Pop( aImageFiles ); |
|
69 SetImageArrayL( aImageFiles ); |
|
70 |
|
71 iCRSession = CRepository::NewL( KCRUidImagePrint ); |
|
72 } |
|
73 |
|
74 // Returns the reference to interface factory |
|
75 EXPORT_C CIFFactory& CImagePrintEngine::InterfaceFactory() |
|
76 { |
|
77 return *iIFFactory; |
|
78 } |
|
79 |
|
80 // Initializes the image array |
|
81 EXPORT_C void CImagePrintEngine::SetImageArrayL( |
|
82 CDesCArrayFlat* aArray ) |
|
83 { |
|
84 delete iFiles; |
|
85 iFiles = aArray; |
|
86 |
|
87 if ( iFiles ) |
|
88 { |
|
89 iFileArray.ResetAndDestroy(); |
|
90 TInt i( 0 ); |
|
91 TInt num( iFiles->Count() ); |
|
92 for ( i = 0; i < num; i++ ) |
|
93 { |
|
94 TFileName* tf = CreateFileNameL(); |
|
95 CleanupStack::PushL( tf ); |
|
96 *tf = iFiles->MdcaPoint( i ); |
|
97 User::LeaveIfError( iFileArray.Append( tf ) ); |
|
98 CleanupStack::Pop( tf ); |
|
99 } |
|
100 |
|
101 MPrintSettings* settings = |
|
102 static_cast<CRealFactory*>( iIFFactory )->SettingsIF(); |
|
103 RArray<TInt> numberOfCopiesArray; |
|
104 CleanupClosePushL( numberOfCopiesArray ); |
|
105 for( TInt i=0; i < iFiles->Count(); ++i ) |
|
106 { |
|
107 numberOfCopiesArray.Append( 1 ); |
|
108 } |
|
109 if( settings ) |
|
110 { |
|
111 settings->SetNumberOfCopiesL( numberOfCopiesArray ); |
|
112 } |
|
113 CleanupStack::PopAndDestroy(); // numberOfCopiesArray |
|
114 } |
|
115 } |
|
116 |
|
117 // Returns file array to be passed to server |
|
118 EXPORT_C RPointerArray<TDesC>& CImagePrintEngine::FileArray() |
|
119 { |
|
120 return iFileArray; |
|
121 } |
|
122 |
|
123 // Creates new TFileName for file array |
|
124 TFileName* CImagePrintEngine::CreateFileNameL() |
|
125 { |
|
126 TFileName* fileName = 0; |
|
127 fileName = new (ELeave) TFileName; |
|
128 User::LeaveIfNull( fileName ); |
|
129 return fileName; |
|
130 } |
|
131 |
|
132 // Restarts Image Print engine |
|
133 EXPORT_C void CImagePrintEngine::RestartEngine() |
|
134 { |
|
135 iIFFactory->RestartEngine(); |
|
136 } |
|
137 |
|
138 // End of File |