|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Implements Midlet handler class for document handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <apgtask.h> |
|
20 #include <eikenv.h> |
|
21 #include <eikappui.h> |
|
22 #include <vwsdef.h> |
|
23 #include <e32math.h> |
|
24 #include <EikProc.h> // CEikProcess |
|
25 #include <EikDoc.h> // CEikDocument |
|
26 #include <EikEnv.h> // CEikEnv |
|
27 #include <UriUtils.h> |
|
28 #include <f32file.h> |
|
29 #include <s32file.h> |
|
30 #include <AiwGenericParam.h> |
|
31 |
|
32 #include "DocMidletHandler.h" |
|
33 #include "DocSaver.h" // CDocAsyncSaver |
|
34 |
|
35 // The UID for Java MIDlets |
|
36 const TInt KUidJavaMidpAppValue = 0x100096C5; |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // Constructor |
|
40 // --------------------------------------------------------- |
|
41 CDocMidletHandler::CDocMidletHandler( |
|
42 const TDataType& aDataType, |
|
43 const TUid& aUid, |
|
44 CDocumentHandler* aDocDispatcher) : |
|
45 CDocDefaultHandler( aDataType, aUid, aDocDispatcher, EDocOpenAndSave ) |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // void CDocMidletHandler::ConstructL(..) |
|
51 // Epoc constructor. |
|
52 // --------------------------------------------------------- |
|
53 void CDocMidletHandler::ConstructL() |
|
54 { |
|
55 BaseConstructL(); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // CDocMidletHandler::~CDocMidletHandler() |
|
60 // Destructor |
|
61 // --------------------------------------------------------- |
|
62 CDocMidletHandler::~CDocMidletHandler() |
|
63 { |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CDocMidletHandler* CDocMidletHandler::NewL(..) |
|
68 // Returns a contructed CDocMidletHandler object |
|
69 // --------------------------------------------------------- |
|
70 CDocMidletHandler* CDocMidletHandler::NewL( |
|
71 const TDataType& aDataType, |
|
72 const TUid& aUid, |
|
73 CDocumentHandler* aDocDispatcher) |
|
74 { |
|
75 CDocMidletHandler* self = CDocMidletHandler::NewLC( aDataType, |
|
76 aUid, aDocDispatcher ); |
|
77 CleanupStack::Pop(); // self |
|
78 return self; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CDocMidletHandler* CDocMidletHandler::NewLC(..) |
|
83 // Returns a contructed CDocMidletHandler object. Leaves |
|
84 // the object in the cleanup stack. |
|
85 // --------------------------------------------------------- |
|
86 CDocMidletHandler* CDocMidletHandler::NewLC( |
|
87 const TDataType& aDataType, |
|
88 const TUid& aUid, |
|
89 CDocumentHandler* aDocDispatcher) |
|
90 { |
|
91 CDocMidletHandler * self = |
|
92 new( ELeave ) CDocMidletHandler( aDataType, aUid, |
|
93 aDocDispatcher ); |
|
94 CleanupStack::PushL( self ); |
|
95 self->ConstructL( ); |
|
96 return self; |
|
97 } |
|
98 |
|
99 TInt CDocMidletHandler::OpenFileEmbeddedL(RFile& aFileHandle) |
|
100 { |
|
101 // Midlets cannot be launched as embedded, so just call OpenFileL() |
|
102 // here for now. |
|
103 return OpenFileL(aFileHandle); |
|
104 } |
|
105 |
|
106 TInt CDocMidletHandler::OpenFileL(RFile& /*aFileHandle*/) |
|
107 { |
|
108 // TODO: This type of application launching is not supported on release 3.0 |
|
109 // Do we need still support midlets? |
|
110 return KErrNotSupported; |
|
111 } |
|
112 |
|
113 |
|
114 TBool CDocMidletHandler::IsMidlet(const TUid& aUid) |
|
115 { |
|
116 // Find out if given UID belongs to a Java Midlet |
|
117 TBool isMidlet = EFalse; |
|
118 |
|
119 RApaLsSession appArcSession; |
|
120 TInt error = appArcSession.Connect(); |
|
121 if (error == KErrNone) |
|
122 { |
|
123 TApaAppInfo aInfo; |
|
124 appArcSession.GetAppInfo(aInfo, aUid); |
|
125 #ifdef _DEBUG |
|
126 RDebug::Print(_L("DocumentHandler: CDocMidletHandler::IsMidlet: Checking possible Midlet app = ")); |
|
127 RDebug::Print(aInfo.iFullName); |
|
128 #endif |
|
129 |
|
130 RFs fs; |
|
131 TInt connectError = fs.Connect(); |
|
132 if (connectError == KErrNone) |
|
133 { |
|
134 TEntry entry; |
|
135 TInt readError = fs.Entry(aInfo.iFullName,entry); // Check if file exists, and get uid |
|
136 if (readError == KErrNone) |
|
137 { |
|
138 TUid uid = TUid::Uid(KUidJavaMidpAppValue); |
|
139 if (entry.iType[1] == uid) |
|
140 { |
|
141 isMidlet = ETrue; |
|
142 #ifdef _DEBUG |
|
143 RDebug::Print(_L("DocumentHandler: CDocMidletHandler::IsMidlet: App is a Midlet app !")); |
|
144 #endif |
|
145 } |
|
146 } |
|
147 fs.Close(); |
|
148 } |
|
149 else |
|
150 { |
|
151 #ifdef _DEBUG |
|
152 RDebug::Print(_L("DocumentHandler: CDocMidletHandler::IsMidlet: connect fs error: %d"), connectError); |
|
153 #endif |
|
154 } |
|
155 |
|
156 appArcSession.Close(); |
|
157 } |
|
158 |
|
159 return isMidlet; |
|
160 } |
|
161 |
|
162 // End of File |