|
1 /* |
|
2 * Copyright (c) 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 "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: Implementation of Scheme handler interface implementation |
|
15 * for localapp://jam/launch scheme |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <escapeutils.h> |
|
23 #include <apgcli.h> |
|
24 #include <eikproc.h> |
|
25 #include <apacmdln.h> |
|
26 #include <e32const.h> |
|
27 #include <flogger.h> |
|
28 |
|
29 #include "javaapphandler.h" |
|
30 |
|
31 using namespace java; |
|
32 |
|
33 namespace java |
|
34 { |
|
35 |
|
36 namespace javaapphandler |
|
37 { |
|
38 |
|
39 // ================= CONSTANTS ======================= |
|
40 |
|
41 _LIT(KJavaLogDir, "java\\full"); |
|
42 _LIT(KJavaLogFile, "JavaUtils.log"); |
|
43 |
|
44 // ================= MACROS ======================= |
|
45 |
|
46 // Define logging macros here to remove dependencies to Java 2.0 libraries. |
|
47 #define LOG(str) { TBuf8<1024> f((const TUint8 *)str); RFileLogger::Write(KJavaLogDir, KJavaLogFile, EFileLoggingModeAppend, f); } |
|
48 #define LOG1(str, a) { TBuf8<1024> f((const TUint8 *)str); RFileLogger::WriteFormat(KJavaLogDir, KJavaLogFile, EFileLoggingModeAppend, f, a); } |
|
49 #define LOG1WSTR(str, wstr) { TBuf8<1024> f((const TUint8 *)str); RFileLogger::Write(KJavaLogDir, KJavaLogFile, EFileLoggingModeAppend, f); TBuf16<KLogBufferSize> w((const TUint16 *)wstr); RFileLogger::Write(KJavaLogDir, KJavaLogFile, EFileLoggingModeAppend, w); } |
|
50 |
|
51 // ================= MEMBER FUNCTIONS ======================= |
|
52 |
|
53 |
|
54 // --------------------------------------------------------- |
|
55 // CJavaAppHandler::CJavaAppHandler() |
|
56 // --------------------------------------------------------- |
|
57 // |
|
58 CJavaAppHandler::CJavaAppHandler() |
|
59 : CSchemeHandler() |
|
60 { |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CJavaAppHandler::ConstructL() |
|
65 // --------------------------------------------------------- |
|
66 // |
|
67 void CJavaAppHandler::ConstructL(const TDesC& aUrl) |
|
68 { |
|
69 mParsedUrl = aUrl.AllocL(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CJavaAppHandler::Observer() |
|
74 // --------------------------------------------------------- |
|
75 // |
|
76 |
|
77 void CJavaAppHandler::Observer(MAknServerAppExitObserver* /* aSchemeDoc */) |
|
78 { |
|
79 // do nothing |
|
80 } |
|
81 |
|
82 // ================= MEMBER FUNCTIONS ======================= |
|
83 |
|
84 // --------------------------------------------------------- |
|
85 // CJavaAppHandler::NewL() |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 CJavaAppHandler* CJavaAppHandler::NewL(const TDesC& aUrl) |
|
89 { |
|
90 CJavaAppHandler* self=new(ELeave) CJavaAppHandler(); |
|
91 CleanupStack::PushL(self); |
|
92 self->ConstructL(aUrl); |
|
93 CleanupStack::Pop(self); |
|
94 |
|
95 return self; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CJavaAppHandler::~CJavaAppHandler() |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 CJavaAppHandler::~CJavaAppHandler() |
|
103 { |
|
104 delete mParsedUrl; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // CJavaAppHandler::HandleUrlEmbeddedL() |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 void CJavaAppHandler::HandleUrlEmbeddedL() |
|
112 { |
|
113 HandleUrlStandaloneL(); |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CJavaAppHandler::HandleUrlStandaloneL() |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 void CJavaAppHandler::HandleUrlStandaloneL() |
|
121 { |
|
122 |
|
123 |
|
124 // Start javalauncher.exe and pass the Url to it |
|
125 _LIT(KJavaLauncherExe, "javalauncher.exe"); |
|
126 RProcess rProcess; |
|
127 |
|
128 // start |
|
129 TInt err = rProcess.Create(KJavaLauncherExe, *mParsedUrl); |
|
130 if (KErrNone == err) |
|
131 { |
|
132 // This call will wait until javalauncher exits (or panics) |
|
133 TRequestStatus status; |
|
134 rProcess.Logon(status); |
|
135 rProcess.Resume(); |
|
136 |
|
137 // now wait until javalauncher exits |
|
138 User::WaitForRequest(status); |
|
139 err = status.Int(); |
|
140 if (err != KErrNone) |
|
141 { |
|
142 LOG1("javaapphandler: javalauncher exited with error %d", err); |
|
143 } |
|
144 } |
|
145 else |
|
146 { |
|
147 LOG1("javaapphandler: Cannot create javalauncher process, error %d", err); |
|
148 } |
|
149 |
|
150 // free resources before returning |
|
151 rProcess.Close(); |
|
152 |
|
153 if (KErrNone != err) |
|
154 { |
|
155 #ifndef _DEBUG |
|
156 // Make sure Url is logged always if an error has happened |
|
157 TBuf<255> logBuf = mParsedUrl->Left(250); |
|
158 LOG1WSTR("javaapphandler: command line starts with : %s", (TUint16 *)(logBuf.PtrZ())); |
|
159 #endif |
|
160 User::Leave(err); |
|
161 } |
|
162 } |
|
163 |
|
164 } // namespace javaapphandler |
|
165 } // namespace java |