65
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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 |
* Browser app document
|
|
16 |
*
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
#include "BrowserAppDocument.h"
|
|
21 |
#include "BrowserAppUi.h"
|
|
22 |
#include <favouritesitem.h>
|
|
23 |
#include <brctlinterface.h>
|
|
24 |
#include "CommonConstants.h"
|
|
25 |
|
|
26 |
CBrowserAppDocument::CBrowserAppDocument(CEikApplication& aApp): CAknDocument(aApp)
|
|
27 |
{
|
|
28 |
iFolderToOpen = KFavouritesRootUid;
|
|
29 |
}
|
|
30 |
|
|
31 |
CBrowserAppDocument::~CBrowserAppDocument()
|
|
32 |
{
|
|
33 |
if ( iUrlToOpen )
|
|
34 |
{
|
|
35 |
delete iUrlToOpen;
|
|
36 |
iUrlToOpen = NULL;
|
|
37 |
}
|
|
38 |
}
|
|
39 |
|
|
40 |
CEikAppUi* CBrowserAppDocument::CreateAppUiL()
|
|
41 |
{
|
|
42 |
return new (ELeave) CBrowserAppUi;
|
|
43 |
}
|
|
44 |
|
|
45 |
TInt CBrowserAppDocument::GetFolderToOpen() const
|
|
46 |
{
|
|
47 |
return iFolderToOpen;
|
|
48 |
}
|
|
49 |
|
|
50 |
HBufC* CBrowserAppDocument::GetUrlToOpen() const
|
|
51 |
{
|
|
52 |
return iUrlToOpen;
|
|
53 |
}
|
|
54 |
|
|
55 |
MDownloadedContentHandler *CBrowserAppDocument::GetDownloadedContentHandler() const
|
|
56 |
{
|
|
57 |
return iDownloadedContentHandler;
|
|
58 |
}
|
|
59 |
|
|
60 |
CFileStore* CBrowserAppDocument::OpenFileL(TBool /*aDoOpen*/, const TDesC& aFileName, RFs& /*aFs*/)
|
|
61 |
{
|
|
62 |
TInt len = aFileName.Length();
|
|
63 |
delete iUrlToOpen;
|
|
64 |
iUrlToOpen = NULL;
|
|
65 |
iUrlToOpen = HBufC::NewL(len);
|
|
66 |
*iUrlToOpen = aFileName;
|
|
67 |
HBufC8 *url8 = HBufC8::NewL(len);
|
|
68 |
|
|
69 |
url8->Des().Copy( aFileName );
|
|
70 |
//STATIC_CAST(CBrowserAppUi*, iAppUi)->FetchL(*iUrlToOpen);
|
|
71 |
STATIC_CAST(CBrowserAppUi*, iAppUi)->ParseAndProcessParametersL( url8->Des() );
|
|
72 |
delete url8;
|
|
73 |
return NULL;
|
|
74 |
}
|
|
75 |
|
|
76 |
// From CAknDocument
|
|
77 |
void CBrowserAppDocument::OpenFileL( CFileStore*& aFileStore, RFile& aFile )
|
|
78 |
{
|
|
79 |
CBrowserAppUi* appUi = STATIC_CAST(CBrowserAppUi*, iAppUi);
|
|
80 |
appUi->InitBrowserL();
|
|
81 |
|
|
82 |
TBuf<KMaxDataTypeLength> dataTypeDes;
|
|
83 |
|
|
84 |
// See if Browser UI should handle this open file or not
|
|
85 |
if(appUi->RecognizeUiFileL(aFile, dataTypeDes))
|
|
86 |
{
|
|
87 |
// confirm the filehandling with the user,
|
|
88 |
// retrieving filename from the RFILE
|
|
89 |
TFileName fileName;
|
|
90 |
User::LeaveIfError(aFile.Name(fileName));
|
|
91 |
if(appUi->ConfirmUiHandlingL(fileName, dataTypeDes))
|
|
92 |
{
|
|
93 |
// need to copy file to a temp file, then pass off to Feeds
|
|
94 |
// prepend the path to the fileName
|
|
95 |
TFileName filePath = _L("c:\\system\\temp\\");
|
|
96 |
filePath.Append(fileName);
|
|
97 |
appUi->CopyUiRFileToFileL(aFile,filePath);
|
|
98 |
|
|
99 |
// Pass off to appUi to set up views, etc.
|
|
100 |
appUi->HandleUiFileL(filePath, dataTypeDes);
|
|
101 |
}
|
|
102 |
else
|
|
103 |
{
|
|
104 |
appUi->HandleCommandL( EWmlCmdCloseBrowser );
|
|
105 |
}
|
|
106 |
}
|
|
107 |
else
|
|
108 |
{
|
|
109 |
// send to content view
|
|
110 |
appUi->WaitCVInit();
|
|
111 |
appUi->SetLastActiveViewId( KUidBrowserContentViewId );
|
|
112 |
// view activation and bringing the browser to foreground are two
|
|
113 |
// distinct actions.
|
|
114 |
appUi->ActivateLocalViewL( KUidBrowserContentViewId );
|
|
115 |
appUi->HandleForegroundEventL( ETrue );
|
|
116 |
|
|
117 |
TFileName fileName;
|
|
118 |
User::LeaveIfError( aFile.FullName( fileName ) );
|
|
119 |
if ( fileName.Find( KMailerStoreUid ) != KErrNotFound )
|
|
120 |
{
|
|
121 |
appUi->CopyUiRFileToFileL( aFile,KAttachment() );
|
|
122 |
appUi->BrCtlInterface().LoadFileL( KAttachment() );
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
appUi->BrCtlInterface().LoadFileL( aFile );
|
|
127 |
}
|
|
128 |
|
|
129 |
}
|
|
130 |
aFileStore = 0;
|
|
131 |
aFile.Close();
|
|
132 |
}
|
|
133 |
|
|
134 |
TBrowserOverriddenSettings* CBrowserAppDocument::GetOverriddenSettings()
|
|
135 |
{
|
|
136 |
return iOverriddenSettings;
|
|
137 |
}
|