sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "apmstd.h"
|
sl@0
|
20 |
#include <caf/importfile.h>
|
sl@0
|
21 |
#include "agentinfo.h"
|
sl@0
|
22 |
#include <caf/agentinterface.h>
|
sl@0
|
23 |
#include <caf/agentfactory.h>
|
sl@0
|
24 |
#include <caf/caferr.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
using namespace ContentAccess;
|
sl@0
|
27 |
|
sl@0
|
28 |
CImportFile* CImportFile::NewL(TUid aAgentUid, const TDesC8& aMimeType, const CMetaDataArray& aMetaData, const TDesC& aOutputDirectory, const TDesC& aSuggestedFileName)
|
sl@0
|
29 |
{
|
sl@0
|
30 |
CImportFile* self = new (ELeave) CImportFile();
|
sl@0
|
31 |
CleanupStack::PushL(self);
|
sl@0
|
32 |
self->ConstructL(aAgentUid, aMimeType, aMetaData, aOutputDirectory, aSuggestedFileName);
|
sl@0
|
33 |
CleanupStack::Pop(self);
|
sl@0
|
34 |
return self;
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
void CImportFile::ConstructL(TUid aAgentUid, const TDesC8& aMimeType, const CMetaDataArray& aMetaData, const TDesC& aOutputDirectory, const TDesC& aSuggestedFileName)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
// increment the reference count for the agent, so ECOM does not unload the agent
|
sl@0
|
40 |
iAgentFactory = CAgentFactory::NewL(aAgentUid);
|
sl@0
|
41 |
|
sl@0
|
42 |
// Create a CAgentSupplier instance for the import
|
sl@0
|
43 |
iAgentImportFile = iAgentFactory->CreateImporterL(aMimeType, aMetaData, aOutputDirectory, aSuggestedFileName);
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
CImportFile* CImportFile::NewL(TUid aAgentUid, const TDesC8& aMimeType, const CMetaDataArray& aMetaData)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
CImportFile* self = new (ELeave) CImportFile();
|
sl@0
|
49 |
CleanupStack::PushL(self);
|
sl@0
|
50 |
self->ConstructL(aAgentUid, aMimeType, aMetaData);
|
sl@0
|
51 |
CleanupStack::Pop(self);
|
sl@0
|
52 |
return self;
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
void CImportFile::ConstructL(TUid aAgentUid, const TDesC8& aMimeType, const CMetaDataArray& aMetaData)
|
sl@0
|
56 |
{
|
sl@0
|
57 |
// increment the reference count for the agent, so ECOM does not unload the agent
|
sl@0
|
58 |
iAgentFactory = CAgentFactory::NewL(aAgentUid);
|
sl@0
|
59 |
|
sl@0
|
60 |
// Create a CAgentSupplier instance for the import
|
sl@0
|
61 |
iAgentImportFile = iAgentFactory->CreateImporterL(aMimeType, aMetaData);
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
CImportFile ::CImportFile()
|
sl@0
|
65 |
{
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
CImportFile ::~CImportFile()
|
sl@0
|
69 |
{
|
sl@0
|
70 |
delete iAgentImportFile;
|
sl@0
|
71 |
|
sl@0
|
72 |
// Finished with Agent session, may unload the agent DLL
|
sl@0
|
73 |
delete iAgentFactory;
|
sl@0
|
74 |
REComSession::FinalClose();
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
EXPORT_C TInt CImportFile::WriteData(const TDesC8& aData)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
return iAgentImportFile->WriteData(aData);
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
EXPORT_C void CImportFile::WriteData(const TDesC8& aData, TRequestStatus &aStatus)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
iAgentImportFile->WriteData(aData,aStatus);
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
EXPORT_C TInt CImportFile::WriteDataComplete()
|
sl@0
|
88 |
{
|
sl@0
|
89 |
// Tell the agent we are finished
|
sl@0
|
90 |
return iAgentImportFile->WriteDataComplete();
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
EXPORT_C void CImportFile::WriteDataComplete(TRequestStatus &aStatus)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
// Tell the agent we are finished
|
sl@0
|
96 |
iAgentImportFile->WriteDataComplete(aStatus);
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
EXPORT_C TInt CImportFile::OutputFileCountL() const
|
sl@0
|
100 |
{
|
sl@0
|
101 |
return iAgentImportFile->OutputFileCountL();
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
EXPORT_C CSupplierOutputFile& CImportFile::OutputFileL(TInt aIndex) const
|
sl@0
|
105 |
{
|
sl@0
|
106 |
return iAgentImportFile->OutputFileL(aIndex);
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
EXPORT_C TImportStatus CImportFile::GetImportStatus() const
|
sl@0
|
110 |
{
|
sl@0
|
111 |
return iAgentImportFile->GetImportStatus();
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
EXPORT_C TInt CImportFile::GetSuggestedOutputFileExtension(TDes& aFileExtension)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
return iAgentImportFile->GetSuggestedOutputFileExtension(aFileExtension);
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
EXPORT_C TInt CImportFile::GetSuggestedOutputFileName(TDes& aFileName)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
return iAgentImportFile->GetSuggestedOutputFileName(aFileName);
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
EXPORT_C TInt CImportFile::ContinueWithNewOutputFile(RFile& aFile, const TDesC& aFileName)
|
sl@0
|
125 |
{
|
sl@0
|
126 |
return iAgentImportFile->ContinueWithNewOutputFile(aFile, aFileName);
|
sl@0
|
127 |
}
|
sl@0
|
128 |
|
sl@0
|
129 |
EXPORT_C void CImportFile::ContinueWithNewOutputFile(RFile& aFile, const TDesC& aFileName, TRequestStatus& aStatus)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
iAgentImportFile->ContinueWithNewOutputFile(aFile, aFileName, aStatus);
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
EXPORT_C void CImportFile::Cancel()
|
sl@0
|
135 |
{
|
sl@0
|
136 |
iAgentImportFile->Cancel();
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
EXPORT_C TBool CImportFile::ContentMimeTypeL(TDes8& aContentMime)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
return iAgentImportFile->ContentMimeTypeL(aContentMime);
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|