|
1 /* |
|
2 * Copyright (c) 2003-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 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "apmstd.h" |
|
20 #include "importfile.h" |
|
21 #include "agentinfo.h" |
|
22 #include "agentinterface.h" |
|
23 #include "agentfactory.h" |
|
24 #include "caferr.h" |
|
25 |
|
26 using namespace ContentAccess; |
|
27 |
|
28 CImportFile* CImportFile::NewL(TUid aAgentUid, const TDesC8& aMimeType, const CMetaDataArray& aMetaData, const TDesC& aOutputDirectory, const TDesC& aSuggestedFileName) |
|
29 { |
|
30 CImportFile* self = new (ELeave) CImportFile(); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(aAgentUid, aMimeType, aMetaData, aOutputDirectory, aSuggestedFileName); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 void CImportFile::ConstructL(TUid aAgentUid, const TDesC8& aMimeType, const CMetaDataArray& aMetaData, const TDesC& aOutputDirectory, const TDesC& aSuggestedFileName) |
|
38 { |
|
39 // increment the reference count for the agent, so ECOM does not unload the agent |
|
40 iAgentFactory = CAgentFactory::NewL(aAgentUid); |
|
41 |
|
42 // Create a CAgentSupplier instance for the import |
|
43 iAgentImportFile = iAgentFactory->CreateImporterL(aMimeType, aMetaData, aOutputDirectory, aSuggestedFileName); |
|
44 } |
|
45 |
|
46 CImportFile* CImportFile::NewL(TUid aAgentUid, const TDesC8& aMimeType, const CMetaDataArray& aMetaData) |
|
47 { |
|
48 CImportFile* self = new (ELeave) CImportFile(); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(aAgentUid, aMimeType, aMetaData); |
|
51 CleanupStack::Pop(self); |
|
52 return self; |
|
53 } |
|
54 |
|
55 void CImportFile::ConstructL(TUid aAgentUid, const TDesC8& aMimeType, const CMetaDataArray& aMetaData) |
|
56 { |
|
57 // increment the reference count for the agent, so ECOM does not unload the agent |
|
58 iAgentFactory = CAgentFactory::NewL(aAgentUid); |
|
59 |
|
60 // Create a CAgentSupplier instance for the import |
|
61 iAgentImportFile = iAgentFactory->CreateImporterL(aMimeType, aMetaData); |
|
62 } |
|
63 |
|
64 CImportFile ::CImportFile() |
|
65 { |
|
66 } |
|
67 |
|
68 CImportFile ::~CImportFile() |
|
69 { |
|
70 delete iAgentImportFile; |
|
71 |
|
72 // Finished with Agent session, may unload the agent DLL |
|
73 delete iAgentFactory; |
|
74 REComSession::FinalClose(); |
|
75 } |
|
76 |
|
77 EXPORT_C TInt CImportFile::WriteData(const TDesC8& aData) |
|
78 { |
|
79 return iAgentImportFile->WriteData(aData); |
|
80 } |
|
81 |
|
82 EXPORT_C void CImportFile::WriteData(const TDesC8& aData, TRequestStatus &aStatus) |
|
83 { |
|
84 iAgentImportFile->WriteData(aData,aStatus); |
|
85 } |
|
86 |
|
87 EXPORT_C TInt CImportFile::WriteDataComplete() |
|
88 { |
|
89 // Tell the agent we are finished |
|
90 return iAgentImportFile->WriteDataComplete(); |
|
91 } |
|
92 |
|
93 EXPORT_C void CImportFile::WriteDataComplete(TRequestStatus &aStatus) |
|
94 { |
|
95 // Tell the agent we are finished |
|
96 iAgentImportFile->WriteDataComplete(aStatus); |
|
97 } |
|
98 |
|
99 EXPORT_C TInt CImportFile::OutputFileCountL() const |
|
100 { |
|
101 return iAgentImportFile->OutputFileCountL(); |
|
102 } |
|
103 |
|
104 EXPORT_C CSupplierOutputFile& CImportFile::OutputFileL(TInt aIndex) const |
|
105 { |
|
106 return iAgentImportFile->OutputFileL(aIndex); |
|
107 } |
|
108 |
|
109 EXPORT_C TImportStatus CImportFile::GetImportStatus() const |
|
110 { |
|
111 return iAgentImportFile->GetImportStatus(); |
|
112 } |
|
113 |
|
114 EXPORT_C TInt CImportFile::GetSuggestedOutputFileExtension(TDes& aFileExtension) |
|
115 { |
|
116 return iAgentImportFile->GetSuggestedOutputFileExtension(aFileExtension); |
|
117 } |
|
118 |
|
119 EXPORT_C TInt CImportFile::GetSuggestedOutputFileName(TDes& aFileName) |
|
120 { |
|
121 return iAgentImportFile->GetSuggestedOutputFileName(aFileName); |
|
122 } |
|
123 |
|
124 EXPORT_C TInt CImportFile::ContinueWithNewOutputFile(RFile& aFile, const TDesC& aFileName) |
|
125 { |
|
126 return iAgentImportFile->ContinueWithNewOutputFile(aFile, aFileName); |
|
127 } |
|
128 |
|
129 EXPORT_C void CImportFile::ContinueWithNewOutputFile(RFile& aFile, const TDesC& aFileName, TRequestStatus& aStatus) |
|
130 { |
|
131 iAgentImportFile->ContinueWithNewOutputFile(aFile, aFileName, aStatus); |
|
132 } |
|
133 |
|
134 EXPORT_C void CImportFile::Cancel() |
|
135 { |
|
136 iAgentImportFile->Cancel(); |
|
137 } |
|
138 |
|
139 EXPORT_C TBool CImportFile::ContentMimeTypeL(TDes8& aContentMime) |
|
140 { |
|
141 return iAgentImportFile->ContentMimeTypeL(aContentMime); |
|
142 } |