First fix for Urls + policyUpdate.
authorPolina Vyshnevska <PVyshnevska@luxoft.com>
Thu, 10 Apr 2014 06:19:35 +0000 (09:19 +0300)
committerJustin Dickow <jjdickow@gmail.com>
Wed, 9 Jul 2014 18:11:29 +0000 (14:11 -0400)
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
Conflicts:
src/components/HMI/ffw/BasicCommunicationRPC.js
src/components/interfaces/HMI_API.xml

src/components/HMI/ffw/BasicCommunicationRPC.js
src/components/application_manager/src/hmi_command_factory.cc
src/components/application_manager/src/message_helper.cc
src/components/application_manager/src/policies/policy_handler.cc
src/components/policy

index 365cc46..beef41b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2013, Ford Motor Company All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met: ·
  * Redistributions of source code must retain the above copyright notice, this
@@ -10,7 +10,7 @@
  * with the distribution. · Neither the name of the Ford Motor Company nor the
  * names of its contributors may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -45,7 +45,7 @@ FFW.BasicCommunication = FFW.RPCObserver
 
 
         onPutFileSubscribeRequestID: -1,
-allowSDLFunctionalityRequestID: -1,
+        allowSDLFunctionalityRequestID: -1,
 
         onSystemErrorSubscribeRequestID: -1,
         onStatusUpdateSubscribeRequestID: -1,
@@ -55,10 +55,10 @@ allowSDLFunctionalityRequestID: -1,
         onAppUnregisteredSubscribeRequestID: -1,
         onPlayToneSubscribeRequestID: -1,
         onSDLCloseSubscribeRequestID: -1,
-onSDLConsentNeededSubscribeRequestID: -1,
+        onSDLConsentNeededSubscribeRequestID: -1,
 
         onPutFileUnsubscribeRequestID: -1,
-onSystemErrorUnsubscribeRequestID: -1,
+        onSystemErrorUnsubscribeRequestID: -1,
         onStatusUpdateUnsubscribeRequestID: -1,
         onAppPermissionChangedUnsubscribeRequestID: -1,
         onFileRemovedUnsubscribeRequestID: -1,
@@ -66,7 +66,7 @@ onSystemErrorUnsubscribeRequestID: -1,
         onAppUnregisteredUnsubscribeRequestID: -1,
         onPlayToneUnsubscribeRequestID: -1,
         onSDLCloseUnsubscribeRequestID: -1,
-onSDLConsentNeededUnsubscribeRequestID: -1,
+        onSDLConsentNeededUnsubscribeRequestID: -1,
 
         // const
         onSystemErrorNotification: "SDL.OnSystemError",
@@ -78,7 +78,7 @@ onSDLConsentNeededUnsubscribeRequestID: -1,
         onAppUnregisteredNotification: "BasicCommunication.OnAppUnregistered",
         onPlayToneNotification: "BasicCommunication.PlayTone",
         onSDLCloseNotification: "BasicCommunication.OnSDLClose",
-onSDLConsentNeededNotification: "SDL.OnSDLConsentNeeded",
+        onSDLConsentNeededNotification: "SDL.OnSDLConsentNeeded",
 
         /**
          * init object
@@ -116,7 +116,7 @@ onSDLConsentNeededNotification: "SDL.OnSDLConsentNeeded",
             // subscribe to notifications
             this.onPutFileSubscribeRequestID = this.client
                 .subscribeToNotification(this.onPutFileNotification);
-this.onSystemErrorSubscribeRequestID = this.client
+            this.onSystemErrorSubscribeRequestID = this.client
                 .subscribeToNotification(this.onSystemErrorNotification);
             this.onStatusUpdateSubscribeRequestID = this.client
                 .subscribeToNotification(this.onStatusUpdateNotification);
@@ -132,7 +132,7 @@ this.onSystemErrorSubscribeRequestID = this.client
                 .subscribeToNotification(this.onPlayToneNotification);
             this.onSDLCloseSubscribeRequestID = this.client
                 .subscribeToNotification(this.onSDLCloseNotification);
-this.onSDLConsentNeededSubscribeRequestID = this.client
+            this.onSDLConsentNeededSubscribeRequestID = this.client
                 .subscribeToNotification(this.onSDLConsentNeededNotification);
 
         },
@@ -149,7 +149,7 @@ this.onSDLConsentNeededSubscribeRequestID = this.client
 
             this.onPutFileUnsubscribeRequestID = this.client
                 .unsubscribeFromNotification(this.onPutFileNotification);
-this.onSystemErrorUnsubscribeRequestID = this.client
+            this.onSystemErrorUnsubscribeRequestID = this.client
                 .unsubscribeFromNotification(this.onSystemErrorNotification);
             this.onStatusUpdateUnsubscribeRequestID = this.client
                 .unsubscribeFromNotification(this.onStatusUpdateNotification);
@@ -165,7 +165,7 @@ this.onSystemErrorUnsubscribeRequestID = this.client
                 .unsubscribeFromNotification(this.onPlayToneUpdatedNotification);
             this.onSDLCloseUnsubscribeRequestID = this.client
                 .unsubscribeFromNotification(this.onSDLCloseNotification);
-this.onSDLConsentNeededUnsubscribeRequestID = this.client
+            this.onSDLConsentNeededUnsubscribeRequestID = this.client
                 .unsubscribeFromNotification(this.onSDLConsentNeededNotification);
         },
 
@@ -274,6 +274,8 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
             if (response.result.method == "SDL.GetURLS") {
 
                 SDL.SDLModel.set('policyURLs', response.result.urls);
+
+                this.OnSystemRequest("PROPRIETARY", response.result.urls[0].policyAppId, SDL.SettingsController.policyUpdateFile, response.result.urls[0].url);
             }
         },
 
@@ -313,6 +315,8 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
 
             if (notification.method == this.onStatusUpdateNotification) {
 
+                //SDL.PopUp.popupActivate(notification.status);
+
                 SDL.TTSPopUp.ActivateTTS(notification.params.status);
             }
 
@@ -384,6 +388,11 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
                         request.method);
                 }
                 if (request.method == "BasicCommunication.SystemRequest") {
+
+                    this.OnReceivedPolicyUpdate(SDL.SettingsController.policyUpdateFile);
+
+                    SDL.SettingsController.policyUpdateFile = null;
+
                     this.sendBCResult(SDL.SDLModel.resultCode["SUCCESS"],
                         request.id,
                         request.method);
@@ -421,6 +430,12 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
                     //TO DO
                     //popUp activation
                 }
+                if (request.method == "BasicCommunication.PolicyUpdate") {
+                    SDL.SettingsController.policyUpdateFile = request.params.file;
+                    this.GetURLS(7); //Service type for policies
+
+                    this.sendBCResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method);
+                }
             }
         },
 
@@ -455,9 +470,9 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
         /**
          * Send request if application was activated
          *
-         * @param {Number} appID
+         * @param {Number} type
          */
-        GetURLS: function(appID) {
+        GetURLS: function(type) {
 
             Em.Logger.log("FFW.SDL.GetURLS: Request from HMI!");
 
@@ -467,10 +482,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
                 "id": this.client.generateId(),
                 "method": "SDL.GetURLS",
                 "params": {
-                    "service": {
-                        "servicyType": "servicyType",
-                        "policyAppId": "policyAppId"
-                    }
+                    "service": type
                 }
             };
             this.client.send(JSONMessage);
@@ -568,7 +580,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
 
         /**
          * send response from onRPCRequest
-         * 
+         *
          * @param {Number}
          *            resultCode
          * @param {Number}
@@ -650,6 +662,28 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
             this.client.send(JSONMessage);
         },
 
+
+        /**
+         * Notification of decrypted policy table available
+         *
+         * @param {String} policyfile
+         */
+        OnReceivedPolicyUpdate: function(policyfile) {
+
+            Em.Logger.log("FFW.SDL.OnReceivedPolicyUpdate");
+
+            // send repsonse
+            var JSONMessage = {
+                "jsonrpc": "2.0",
+                "method": "SDL.OnReceivedPolicyUpdate",
+                "params": {
+                    "policyfile": policyfile
+                }
+            };
+
+            this.client.send(JSONMessage);
+        },
+
         /**
          * Notifies if functionality was changed
          *
@@ -662,14 +696,14 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
          */
         OnAppPermissionConsent: function(consentedFunctions, source, appID) {
 
-            Em.Logger.log("FFW.BasicCommunication.OnAppPermissionConsent");
+            Em.Logger.log("FFW.SDL.OnAppPermissionConsent");
 
             // send repsonse
             var JSONMessage = {
                 "jsonrpc": "2.0",
-                "method": "BasicCommunication.OnAppPermissionConsent",
+                "method": "SDL.OnAppPermissionConsent",
                 "params": {
-                    "consentedFunctions": allowed,
+                    "consentedFunctions": consentedFunctions,
                     "source": source
                 }
             };
@@ -683,7 +717,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
 
         /**
          * send response from onRPCRequest
-         * 
+         *
          * @param {Number}
          *            id
          * @param {String}
@@ -742,7 +776,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
 
         /**
          * Send request if application was activated
-         * 
+         *
          * @param {number} appID
          */
         OnAppActivated: function(appID) {
@@ -821,7 +855,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
         /**
          * Invoked by UI component when user switches to any functionality which
          * is not other mobile application.
-         * 
+         *
          * @params {String}
          * @params {Number}
          */
@@ -861,7 +895,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
 
         /**
          * Used by HMI when User chooses to exit application.
-         * 
+         *
          * @params {Number}
          */
         ExitApplication: function(appID) {
@@ -882,7 +916,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
 
         /**
          * Sent by HMI to SDL to close all registered applications.
-         * 
+         *
          * @params {String}
          */
         ExitAllApplications: function(reason) {
@@ -904,7 +938,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
         /**
          * Response with params of the last one supports mixing audio (ie
          * recording TTS command and playing audio).
-         * 
+         *
          * @params {Number}
          */
         MixingAudioSupported: function(attenuatedSupported) {
@@ -928,7 +962,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
         /**
          * Response with Results by user/HMI allowing SDL functionality or
          * disallowing access to all mobile apps.
-         * 
+         *
          * @params {Number}
          */
         AllowAllApps: function(allowed) {
@@ -951,7 +985,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
 
         /**
          * Response with result of allowed application
-         * 
+         *
          * @params {Number}
          */
         AllowApp: function(request) {
@@ -985,7 +1019,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
 
         /**
          * Notifies if device was choosed
-         * 
+         *
          * @param {String}
          *            deviceName
          * @param {Number}
@@ -1011,7 +1045,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
 
         /**
          * Send error response from onRPCRequest
-         * 
+         *
          * @param {Number}
          *            resultCode
          * @param {Number}
@@ -1044,7 +1078,7 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
         /**
          * Initiated by HMI.
          */
-        OnSystemRequest: function(type) {
+        OnSystemRequest: function(type, appID, fileName, utl) {
 
             Em.Logger.log("FFW.BasicCommunication.OnSystemRequest");
 
@@ -1060,8 +1094,8 @@ this.onSDLConsentNeededUnsubscribeRequestID = this.client
                     "offset": 1000,
                     "length": 10000,
                     "timeout": 500,
-                    "fileName": document.location.pathname.replace("index.html", "IVSU/PROPRIETARY_REQUEST"),
-                    "appID": SDL.SDLAppController.model ? SDL.SDLAppController.model.appID.toString() : "default"
+                    "fileName": fileName ? fileName : document.location.pathname.replace("index.html", "IVSU/PROPRIETARY_REQUEST"),
+                    "appID": SDL.SDLAppController.model ? SDL.SDLAppController.model.appID : null
                 }
             };
             this.client.send(JSONMessage);
index 51b3e51..d45baf6 100644 (file)
@@ -324,7 +324,7 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
       }
       break;
     }
-    case hmi_apis::FunctionID::SDL_PolicyUpdate: {
+    case hmi_apis::FunctionID::BasicCommunication_PolicyUpdate: {
       if (is_response) {
         command.reset(new commands::SDLPolicyUpdateResponse(message));
       } else {
index 0fb26cb..f59ae15 100644 (file)
@@ -171,58 +171,58 @@ static VehicleInfo_Requests ivi_subrequests[] = {
 #endif // #ifdef HMI_DBUS_API
 
 std::string MessageHelper::CommonLanguageToString(
-    hmi_apis::Common_Language::eType language) {
+  hmi_apis::Common_Language::eType language) {
   switch (language) {
-  case hmi_apis::Common_Language::EN_US:
-    return "en-us";
-  case hmi_apis::Common_Language::ES_MX:
-    return "es-mx";
-  case hmi_apis::Common_Language::FR_CA:
-    return "fr-ca";
-  case hmi_apis::Common_Language::DE_DE:
-    return "de-de";
-  case hmi_apis::Common_Language::ES_ES:
-    return "es-es";
-  case hmi_apis::Common_Language::EN_GB:
-    return "en-gb";
-  case hmi_apis::Common_Language::RU_RU:
-    return "ru-ru";
-  case hmi_apis::Common_Language::TR_TR:
-    return "tr-tr";
-  case hmi_apis::Common_Language::PL_PL:
-    return "pl-pl";
-  case hmi_apis::Common_Language::FR_FR:
-    return "fr-fr";
-  case hmi_apis::Common_Language::IT_IT:
-    return "it-it";
-  case hmi_apis::Common_Language::SV_SE:
-    return "sv-se";
-  case hmi_apis::Common_Language::PT_PT:
-    return "pt-pt";
-  case hmi_apis::Common_Language::NL_NL:
-    return "nl-nl";
-  case hmi_apis::Common_Language::EN_AU:
-    return "en-au";
-  case hmi_apis::Common_Language::ZH_CN:
-    return "zh-cn";
-  case hmi_apis::Common_Language::ZH_TW:
-    return "zh-tw";
-  case hmi_apis::Common_Language::JA_JP:
-    return "ja-jp";
-  case hmi_apis::Common_Language::AR_SA:
-    return "as-sa";
-  case hmi_apis::Common_Language::KO_KR:
-    return "ko-kr";
-  case hmi_apis::Common_Language::PT_BR:
-    return "pt-br";
-  case hmi_apis::Common_Language::CS_CZ:
-    return "cs-cz";
-  case hmi_apis::Common_Language::DA_DK:
-    return "da-dk";
-  case hmi_apis::Common_Language::NO_NO:
-    return "no-no";
-  default:
-    return "";
+    case hmi_apis::Common_Language::EN_US:
+      return "en-us";
+    case hmi_apis::Common_Language::ES_MX:
+      return "es-mx";
+    case hmi_apis::Common_Language::FR_CA:
+      return "fr-ca";
+    case hmi_apis::Common_Language::DE_DE:
+      return "de-de";
+    case hmi_apis::Common_Language::ES_ES:
+      return "es-es";
+    case hmi_apis::Common_Language::EN_GB:
+      return "en-gb";
+    case hmi_apis::Common_Language::RU_RU:
+      return "ru-ru";
+    case hmi_apis::Common_Language::TR_TR:
+      return "tr-tr";
+    case hmi_apis::Common_Language::PL_PL:
+      return "pl-pl";
+    case hmi_apis::Common_Language::FR_FR:
+      return "fr-fr";
+    case hmi_apis::Common_Language::IT_IT:
+      return "it-it";
+    case hmi_apis::Common_Language::SV_SE:
+      return "sv-se";
+    case hmi_apis::Common_Language::PT_PT:
+      return "pt-pt";
+    case hmi_apis::Common_Language::NL_NL:
+      return "nl-nl";
+    case hmi_apis::Common_Language::EN_AU:
+      return "en-au";
+    case hmi_apis::Common_Language::ZH_CN:
+      return "zh-cn";
+    case hmi_apis::Common_Language::ZH_TW:
+      return "zh-tw";
+    case hmi_apis::Common_Language::JA_JP:
+      return "ja-jp";
+    case hmi_apis::Common_Language::AR_SA:
+      return "as-sa";
+    case hmi_apis::Common_Language::KO_KR:
+      return "ko-kr";
+    case hmi_apis::Common_Language::PT_BR:
+      return "pt-br";
+    case hmi_apis::Common_Language::CS_CZ:
+      return "cs-cz";
+    case hmi_apis::Common_Language::DA_DK:
+      return "da-dk";
+    case hmi_apis::Common_Language::NO_NO:
+      return "no-no";
+    default:
+      return "";
   }
 }
 
@@ -1308,7 +1308,8 @@ void MessageHelper::SendPolicyUpdate(
   smart_objects::SmartObject* message = new smart_objects::SmartObject(
     smart_objects::SmartType_Map);
   smart_objects::SmartObject& object = *message;
-  object[strings::params][strings::function_id] = hmi_apis::FunctionID::SDL_PolicyUpdate;
+  object[strings::params][strings::function_id] =
+    hmi_apis::FunctionID::BasicCommunication_PolicyUpdate;
   object[strings::params][strings::message_type] = MessageType::kRequest;
   object[strings::params][strings::correlation_id] =
     ApplicationManagerImpl::instance()->GetNextHMICorrelationID();
index f20ef96..c775377 100644 (file)
@@ -80,8 +80,8 @@ PolicyManager* PolicyHandler::LoadPolicyLibrary(const std::string& path) {
     policy_manager_ = CreateManager();
     policy_manager_->set_listener(this);
 #if defined (EXTENDED_POLICY)
-    exchange_handler_ = new PTExchangeHandlerImpl(this);
-    //exchange_handler_ = new PTExchangeHandlerExt(this);
+    //exchange_handler_ = new PTExchangeHandlerImpl(this);
+    exchange_handler_ = new PTExchangeHandlerExt(this);
 #else
     exchange_handler_ = new PTExchangeHandlerImpl(this);
 #endif
@@ -591,6 +591,12 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key,
   permissions.isSDLAllowed = true;
 #endif
 
+  if (permissions.isSDLAllowed &&
+      PolicyTableStatus::StatusUpdateRequired == policy_manager_->GetPolicyTableStatus()) {
+    printf("\n\t\t\t\t\tUpdate is requried\n");
+    StartPTExchange();
+  }
+
   application_manager::MessageHelper::SendActivateAppResponse(permissions,
       correlation_id);
   policy_manager_->RemovePendingPermissionChanges(policy_app_id);
index a39fc98..9642144 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a39fc98a0f29a115834c6acdad7288824e4b2e78
+Subproject commit 96421443794ee47efcbfc808627f769f39467a05