javaruntimes/midp/runtime/src.s60/platformrequesthandler.cpp
branchRCL_3
changeset 83 26b2b12093af
parent 60 6c158198356e
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <memory>
    19 #include <memory>
    20 
    20 
    21 #ifndef RD_JAVA_S60_RELEASE_10_1_ONWARDS
    21 #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS
       
    22 #include <SchemeHandler.h>
       
    23 #else
    22 #include <schemehandler.h>
    24 #include <schemehandler.h>
    23 #endif
    25 #endif
    24 
    26 
    25 #include <apgcli.h>               // for RApaLsSession
    27 #include <apgcli.h>               // for RApaLsSession
    26 #include <apacmdln.h>
    28 #include <apacmdln.h>
    64  * mms:, cti:, javaapp: and localapp:
    66  * mms:, cti:, javaapp: and localapp:
    65  */
    67  */
    66 void PlatformRequestHandler::handleUri(const std::wstring& aUri)
    68 void PlatformRequestHandler::handleUri(const std::wstring& aUri)
    67 {
    69 {
    68     JELOG2(EJavaRuntime);
    70     JELOG2(EJavaRuntime);
    69     TRAPD(err, launchAppL(aUri));
    71     TRAPD(err,launchAppL(aUri););
    70     if (err != KErrNone)
    72     if (err != KErrNone)
    71     {
    73     {
    72         ELOG1(EJavaRuntime, "ERROR!!! PlatformRequestHandler::handleUri() %d",
    74         ELOG1(EJavaRuntime, "ERROR!!! PlatformRequestHandler::handleUri() %d",
    73               err);
    75               err);
    74         if (KErrNotFound == err)
    76         if (KErrNotFound == err)
    75         {
    77         {
    76             if ((aUri.find(L"localapp:jam/launch?") == 0) ||
    78             if ((aUri.find(L"localapp:jam/launch?") == 0) ||
    77                 (aUri.find(L"localapp://jam/launch?") == 0) ||
    79                     (aUri.find(L"localapp://jam/launch?") == 0) ||
    78                 (aUri.find(L"javaapp:") == 0))
    80                     (aUri.find(L"javaapp:") == 0))
    79             {
    81             {
    80                 // The URI is supported but the MIDlet specified by the URI
    82                 // The URI is supported but the MIDlet specified by the URI
    81                 // does not exist.
    83                 // does not exist.
    82                 throw ExceptionBase(PlatformRequestInterface::UNEXPECTED_ERROR,
    84                 throw ExceptionBase(PlatformRequestInterface::UNEXPECTED_ERROR,
    83                                     "Cannot start Java application",__FILE__,__FUNCTION__,__LINE__);
    85                                     "Cannot start Java application",__FILE__,__FUNCTION__,__LINE__);
   108     {
   110     {
   109         launchNativeAppL(aUri);
   111         launchNativeAppL(aUri);
   110     }
   112     }
   111     else
   113     else
   112     {
   114     {
   113 #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS
       
   114         std::wstring uri;
       
   115         std::wstring okScheme(L"javaapp:");
       
   116         if (aUri.find(L"localapp:jam/launch?") == 0)
       
   117         {
       
   118             // Remove the scheme not supported by the devices in 10.1 from the
       
   119             // beginning, replace it with okScheme that is supported
       
   120             uri = okScheme;
       
   121             uri += aUri.substr(20);  // 20 == wstrlen(L"localapp:jam/launch?")
       
   122         }
       
   123         else if (aUri.find(L"localapp://jam/launch?") == 0)
       
   124         {
       
   125             uri = okScheme;
       
   126             uri += aUri.substr(22);  // 22 == wstrlen(L"localapp://jam/launch?")
       
   127         }
       
   128         else if (aUri.find(L"javaapp://") == 0)
       
   129         {
       
   130             // TODO: after QtHighway has been fixed to that
       
   131             // it can recognize "javaapp://" scheme, remove this.
       
   132             // At 2010wk26 it recognizes only "javaapp:"
       
   133             uri = okScheme;
       
   134             uri += aUri.substr(10);  // 10 == wstrlen(L"javaapp://")
       
   135         }
       
   136         else
       
   137         {
       
   138             uri = aUri;
       
   139         }
       
   140         LOG1(EJavaRuntime, EInfo, "Platform request. Converted uri: %S", uri.c_str());
       
   141 
       
   142         TPtrC ptr((const TUint16 *)uri.c_str(), uri.length());
       
   143         // Start javaqtrequest.exe so that url is command line argument.
       
   144         // javaqtrequest is a Qt application that will use Qt Highway API
       
   145         // to send the url request to correct XQServiceProvider
       
   146         _LIT(KJavaQtRequestExe, "javaqtrequest.exe");
       
   147         RProcess rProcess;
       
   148         TInt err = rProcess.Create(KJavaQtRequestExe, ptr);
       
   149         if (KErrNone != err)
       
   150         {
       
   151             ELOG1(EJavaRuntime,
       
   152                 "PlatformRequestHandler: launchAppL: Starting javaqtrequest.exe failed, err %d",
       
   153                 err);
       
   154             User::Leave(err);
       
   155         }
       
   156 
       
   157         // Wait until javaqtrequest exits
       
   158         TRequestStatus status;
       
   159         rProcess.Logon(status);
       
   160         rProcess.Resume();
       
   161         User::WaitForRequest(status);
       
   162 
       
   163         // Check the exit code of javaqtrequest
       
   164         err = status.Int();
       
   165         rProcess.Close();
       
   166         if (err != KErrNone)
       
   167         {
       
   168             ELOG1(EJavaRuntime,
       
   169                 "PlatformRequestHandler: launchAppL: javaqtrequest.exe exited with err %d",
       
   170                 err);
       
   171             User::Leave(err);
       
   172         }
       
   173 #else
       
   174         TPtrC ptr((const TUint16 *)aUri.c_str(), aUri.length());
   115         TPtrC ptr((const TUint16 *)aUri.c_str(), aUri.length());
   175         std::auto_ptr<CSchemeHandler> schemeHandler(CSchemeHandler::NewL(ptr));
   116         std::auto_ptr<CSchemeHandler> schemeHandler(CSchemeHandler::NewL(ptr));
   176         schemeHandler->HandleUrlStandaloneL(); // Process Uri in standalone mode.
   117         schemeHandler->HandleUrlStandaloneL(); // Process Uri in standalone mode.
   177 #endif
       
   178     }
   118     }
   179 }
   119 }
   180 
   120 
   181 /**
   121 /**
   182  *
   122  *