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