1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
22 #include <apmstd.h> |
22 #include <apmstd.h> |
23 #include <e32cmn.h> |
23 #include <e32cmn.h> |
24 #include <e32property.h> |
24 #include <e32property.h> |
25 #include <charconv.h> |
25 #include <charconv.h> |
26 #include <data_caging_path_literals.hrh> |
26 #include <data_caging_path_literals.hrh> |
|
27 #include <usiferror.h> |
27 |
28 |
28 #include "comms.h" |
29 #include "comms.h" |
29 #include "commsmessage.h" |
30 #include "commsmessage.h" |
30 #include "commsclientendpoint.h" |
31 #include "commsclientendpoint.h" |
31 #include "javasifplugin.h" |
32 #include "javasifplugin.h" |
41 using namespace java::util; |
42 using namespace java::util; |
42 using namespace java::comms; |
43 using namespace java::comms; |
43 |
44 |
44 _LIT(KPrivateDataCage, "\\private\\"); |
45 _LIT(KPrivateDataCage, "\\private\\"); |
45 _LIT(KInboxDataCage, "\\private\\1000484b\\"); |
46 _LIT(KInboxDataCage, "\\private\\1000484b\\"); |
|
47 _LIT(KJavaInstallerProcess, "Installer"); |
46 _LIT(KJavaInstallerDataCage, "\\private\\102033e6\\"); |
48 _LIT(KJavaInstallerDataCage, "\\private\\102033e6\\"); |
47 _LIT(KJavaInstallerTmp, "\\private\\102033E6\\installer\\tmp\\"); |
49 _LIT(KJavaInstallerTmp, "\\private\\102033E6\\installer\\tmp\\"); |
48 _LIT(KAnyExtension, ".*"); |
50 _LIT(KAnyExtension, ".*"); |
|
51 |
|
52 // Java Installer is executed with same Uid as Java Runtime |
|
53 _LIT_SECURE_ID(KJavaInstallerSecureID, KJavaMidpSecureId); |
|
54 |
49 |
55 |
50 |
56 |
51 // ============================ MEMBER FUNCTIONS =============================== |
57 // ============================ MEMBER FUNCTIONS =============================== |
52 |
58 |
53 CJavaSifPlugin* CJavaSifPlugin::NewL() |
59 CJavaSifPlugin* CJavaSifPlugin::NewL() |
120 RFile& aFileHandle, |
126 RFile& aFileHandle, |
121 const TSecurityContext& /* aSecurityContext */, |
127 const TSecurityContext& /* aSecurityContext */, |
122 CComponentInfo& aComponentInfo, |
128 CComponentInfo& aComponentInfo, |
123 TRequestStatus& aStatus) |
129 TRequestStatus& aStatus) |
124 { |
130 { |
|
131 if (ExitIfJavaInstallerRunning(aStatus)) |
|
132 { |
|
133 return; |
|
134 } |
|
135 |
125 RProcess rJavaInstaller; |
136 RProcess rJavaInstaller; |
126 TFileName fileName; |
137 TFileName fileName; |
127 TBuf<1536> commandLine; |
138 TBuf<1536> commandLine; |
128 |
139 |
129 // Build command line used to pass all necessary info to Java Installer |
140 // Build command line used to pass all necessary info to Java Installer |
271 const TSecurityContext& aSecurityContext, |
282 const TSecurityContext& aSecurityContext, |
272 const COpaqueNamedParams& aArguments, |
283 const COpaqueNamedParams& aArguments, |
273 COpaqueNamedParams& aResults, |
284 COpaqueNamedParams& aResults, |
274 TRequestStatus& aStatus) |
285 TRequestStatus& aStatus) |
275 { |
286 { |
|
287 if (ExitIfJavaInstallerRunning(aResults, aStatus)) |
|
288 { |
|
289 return; |
|
290 } |
|
291 |
276 RProcess rJavaInstaller; |
292 RProcess rJavaInstaller; |
277 TFileName fileName; |
293 TFileName fileName; |
278 // Max two path names and some options -> 1536 is enough |
294 // Max two path names and some options -> 1536 is enough |
279 TBuf<1536> commandLine; |
295 TBuf<1536> commandLine; |
280 |
296 |
368 { |
384 { |
369 commandLine.Append(_L(" -upgrade=no")); |
385 commandLine.Append(_L(" -upgrade=no")); |
370 } |
386 } |
371 // AskUser is not supported |
387 // AskUser is not supported |
372 } |
388 } |
|
389 |
|
390 |
|
391 // TODO: activate this code block when KSifInParam_UpgradeData has been |
|
392 // defined in sifcommon.h |
|
393 /* |
|
394 // KSifInParam_UpgradeData Yes/No/AskUser -> -upgrade_data=yes|no |
|
395 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_UpgradeData, intValue)); |
|
396 if (paramFound) |
|
397 { |
|
398 if (intValue == 0) // Yes |
|
399 { |
|
400 commandLine.Append(_L(" -upgrade_data=yes")); |
|
401 } |
|
402 else if (intValue == 1) // No |
|
403 { |
|
404 commandLine.Append(_L(" -upgrade_data=no")); |
|
405 } |
|
406 // AskUser is not supported |
|
407 } |
|
408 */ |
373 |
409 |
374 // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no |
410 // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no |
375 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUntrusted, intValue)); |
411 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUntrusted, intValue)); |
376 if (paramFound) |
412 if (paramFound) |
377 { |
413 { |
569 |
605 |
570 void CJavaSifPlugin::Uninstall( |
606 void CJavaSifPlugin::Uninstall( |
571 TComponentId aComponentId, |
607 TComponentId aComponentId, |
572 const TSecurityContext& aSecurityContext, |
608 const TSecurityContext& aSecurityContext, |
573 const COpaqueNamedParams& aArguments, |
609 const COpaqueNamedParams& aArguments, |
574 COpaqueNamedParams& /* aResults */, |
610 COpaqueNamedParams& aResults, |
575 TRequestStatus& aStatus) |
611 TRequestStatus& aStatus) |
576 { |
612 { |
|
613 if (ExitIfJavaInstallerRunning(aResults, aStatus)) |
|
614 { |
|
615 return; |
|
616 } |
|
617 |
577 RProcess rJavaInstaller; |
618 RProcess rJavaInstaller; |
578 TFileName fileName; |
619 TFileName fileName; |
579 // Max one uid and some options -> 256 is enough |
620 // Max one uid and some options -> 256 is enough |
580 TBuf<256> commandLine; |
621 TBuf<256> commandLine; |
581 |
622 |
793 } |
834 } |
794 |
835 |
795 return; |
836 return; |
796 } |
837 } |
797 |
838 |
|
839 TBool CJavaSifPlugin::ExitIfJavaInstallerRunning( |
|
840 COpaqueNamedParams& aResults, |
|
841 TRequestStatus& aStatus) |
|
842 { |
|
843 // If Java Installer is already running, set error category EInstallerBusy etc |
|
844 // to aResults and return |
|
845 |
|
846 TInt err(KErrNone); |
|
847 RProcess proc; |
|
848 TFindProcess finder(KJavaInstallerProcess); |
|
849 TFullName procName; |
|
850 |
|
851 // Java Installer process SID is 0x102033E6 and name is "Installer" |
|
852 while (finder.Next(procName) == KErrNone) |
|
853 { |
|
854 if (proc.Open(finder) != KErrNone) |
|
855 { |
|
856 continue; |
|
857 } |
|
858 if (proc.SecureId() == KJavaInstallerSecureID) |
|
859 { |
|
860 if (proc.ExitType() == EExitPending) |
|
861 { |
|
862 // Java Installer process is already running |
|
863 proc.Close(); |
|
864 |
|
865 // return error information |
|
866 TRAP(err, aResults.AddIntL(KSifOutParam_ErrCategory, EInstallerBusy)); |
|
867 if (KErrNone != err) |
|
868 { |
|
869 ELOG1(EJavaInstaller, |
|
870 "CJavaSifPlugin::ExitIfJavaInstallerRunning aResults.AddIntL " |
|
871 "ErrCategory err %d", err); |
|
872 } |
|
873 |
|
874 TRAP(err, aResults.AddIntL(KSifOutParam_ErrCode, KErrInUse)); |
|
875 if (KErrNone != err) |
|
876 { |
|
877 ELOG1(EJavaInstaller, |
|
878 "CJavaSifPlugin::ExitIfJavaInstallerRunning aResults.AddIntL " |
|
879 "ErrCode err %d", err); |
|
880 } |
|
881 |
|
882 TRAP(err, aResults.AddIntL(KSifOutParam_ExtendedErrCode, 0)); |
|
883 if (KErrNone != err) |
|
884 { |
|
885 ELOG1(EJavaInstaller, |
|
886 "CJavaSifPlugin::ExitIfJavaInstallerRunning aResults.AddIntL " |
|
887 "ExtendedErrCode err %d", err); |
|
888 } |
|
889 |
|
890 // TODO: return also localized error message from usif |
|
891 // common localization file after the localized strings are available |
|
892 |
|
893 TRequestStatus *statusPtr(&aStatus); |
|
894 User::RequestComplete(statusPtr, KErrInUse); |
|
895 return ETrue; |
|
896 } |
|
897 } |
|
898 proc.Close(); |
|
899 } |
|
900 |
|
901 return EFalse; |
|
902 } |
|
903 |
|
904 |
|
905 TBool CJavaSifPlugin::ExitIfJavaInstallerRunning(TRequestStatus& aStatus) |
|
906 { |
|
907 // If Java Installer is already running, set aStatus to KErrInUse |
|
908 // and return ETrue |
|
909 |
|
910 RProcess proc; |
|
911 TFindProcess finder(KJavaInstallerProcess); |
|
912 TFullName procName; |
|
913 |
|
914 // Java Installer process SID is 0x102033E6 and name is "Installer" |
|
915 while (finder.Next(procName) == KErrNone) |
|
916 { |
|
917 if (proc.Open(finder) != KErrNone) |
|
918 { |
|
919 continue; |
|
920 } |
|
921 if (proc.SecureId() == KJavaInstallerSecureID) |
|
922 { |
|
923 if (proc.ExitType() == EExitPending) |
|
924 { |
|
925 // Java Installer process is already running |
|
926 proc.Close(); |
|
927 |
|
928 // return error information |
|
929 TRequestStatus *statusPtr(&aStatus); |
|
930 User::RequestComplete(statusPtr, KErrInUse); |
|
931 return ETrue; |
|
932 } |
|
933 } |
|
934 proc.Close(); |
|
935 } |
|
936 |
|
937 return EFalse; |
|
938 } |
|
939 |
798 // End of File |
940 // End of File |