Skip to content

Commit

Permalink
Integrate CustomString
Browse files Browse the repository at this point in the history
Related-issues: APPLINK-12612

Integrate CustomString
Integrete CustomString to application, commands, application manager.

Related-issues: APPLINK-12612

Fix incorrect convertion of method ConvertPathForURL

Related-issues: APPLINK-12612

Fix comments after review

Related-issues: APPLINK-12612

Fix comments of review

Related-issues: APPLINK-12612

Fix comments after review

Related-issues: APPLINK-12612

Fix comments after review.

Related-issues: APPLINK-12612

Integrate CustomString to our test.

Fixed problem with policy tests after using custom string:
Explicitly specified user type "CustomString" in order to use CustomString in PolicyListener Mock
Fixed problem with linking "CustomString" to resumption tests.
Fixed comment after review in custom_string_test.cc
Related-issues: APPLINK-15906

Integrated CustomString to security.

Related-issues: APPLINK-12694

Fix comments after review.

Related-issues: APPLINK-12694

Fixed comment after review

Related-issues: APPLINK-12694

Fixed comments after review

Related-issues: APPLINK-15906

Resolve build issues after rebase

Fix build with tests
  • Loading branch information
dtrunov authored and LuxoftAKutsan committed Jan 20, 2016
1 parent 36d96ee commit 9dbc649
Show file tree
Hide file tree
Showing 51 changed files with 2,439 additions and 2,317 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ namespace application_manager {
namespace mobile_api = mobile_apis;

namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;

namespace custom_str = utils::custom_string;

typedef int32_t ErrorCode;

class UsageStatistics;
Expand Down Expand Up @@ -452,7 +455,7 @@ class Application : public virtual InitialApplicationData,
virtual void set_hmi_application_id(uint32_t hmi_app_id) = 0;
virtual uint32_t hmi_app_id() const = 0;
virtual uint32_t app_id() const = 0;
virtual const std::string& name() const = 0;
virtual const custom_str::CustomString& name() const = 0;
/**
* @brief Sets application folder name, which is used for storing of related
* files, e.g. icons
Expand Down Expand Up @@ -500,7 +503,7 @@ class Application : public virtual InitialApplicationData,
*/
virtual bool tts_properties_in_full() = 0;
virtual void set_version(const Version& version) = 0;
virtual void set_name(const std::string& name) = 0;
virtual void set_name(const custom_str::CustomString& name) = 0;
virtual void set_is_media_application(bool is_media) = 0;
virtual void increment_put_file_in_none_count() = 0;
virtual void increment_delete_file_in_none_count() = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "utils/timer_thread.h"
#include "utils/lock.h"
#include "utils/atomic_object.h"
#include "utils/custom_string.h"

namespace usage_statistics {

Expand All @@ -60,14 +61,15 @@ using namespace utils;
using namespace timer;

namespace mobile_api = mobile_apis;
namespace custom_str = custom_string;

class ApplicationImpl : public virtual InitialApplicationDataImpl,
public virtual DynamicApplicationDataImpl {
public:
ApplicationImpl(
uint32_t application_id,
const std::string& mobile_app_id,
const std::string& app_name,
const custom_str::CustomString& app_name,
utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager);

~ApplicationImpl();
Expand Down Expand Up @@ -118,7 +120,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
void set_hmi_application_id(uint32_t hmi_app_id);
inline uint32_t hmi_app_id() const;
inline uint32_t app_id() const;
const std::string& name() const;
const custom_str::CustomString& name() const;
void set_folder_name(const std::string& folder_name) OVERRIDE;
const std::string folder_name() const;
bool is_media_application() const;
Expand All @@ -138,7 +140,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
void set_tts_properties_in_full(bool active);
bool tts_properties_in_full();
void set_version(const Version& ver);
void set_name(const std::string& name);
void set_name(const custom_str::CustomString& name);
void set_is_media_application(bool is_media);
void increment_put_file_in_none_count();
void increment_delete_file_in_none_count();
Expand Down Expand Up @@ -303,7 +305,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
uint32_t grammar_id_;

Version version_;
std::string app_name_;
custom_str::CustomString app_name_;
uint32_t hmi_app_id_;
uint32_t app_id_;
smart_objects::SmartObject* active_message_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ namespace application_manager {
namespace mobile_api = mobile_apis;
using namespace utils;
using namespace timer;
namespace custom_str = custom_string;

class ApplicationManagerImpl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,14 @@ namespace commands {
namespace NsSmart = NsSmartDeviceLink::NsSmartObjects;

class CommandRequestImpl : public CommandImpl,
public event_engine::EventObserver {
public event_engine::EventObserver {
public:

enum RequestState {
kAwaitingHMIResponse = 0,
kTimedOut,
kCompleted
};
enum RequestState { kAwaitingHMIResponse = 0, kTimedOut, kCompleted };

explicit CommandRequestImpl(const MessageSharedPtr& message);
virtual ~CommandRequestImpl();
virtual bool CheckPermissions();
virtual bool Init();
virtual bool Init();
virtual bool CleanUp();
virtual void Run();

Expand Down Expand Up @@ -99,7 +94,7 @@ class CommandRequestImpl : public CommandImpl,
* @param allow_empty_string if true methods allow empty sting
* @return true if success otherwise return false
*/
bool CheckSyntax(std::string str, bool allow_empty_line = false);
bool CheckSyntax(const std::string& str, bool allow_empty_line = false);

/*
* @brief Sends HMI request
Expand All @@ -110,8 +105,8 @@ class CommandRequestImpl : public CommandImpl,
* @return hmi correlation id
*/
uint32_t SendHMIRequest(const hmi_apis::FunctionID::eType& function_id,
const smart_objects::SmartObject* msg_params = NULL,
bool use_events = false);
const smart_objects::SmartObject* msg_params = NULL,
bool use_events = false);

/*
* @brief Creates HMI request
Expand All @@ -131,8 +126,7 @@ class CommandRequestImpl : public CommandImpl,
mobile_apis::Result::eType GetMobileResultCode(
const hmi_apis::Common_Result::eType& hmi_code) const;

protected:

protected:
/**
* @brief Checks message permissions and parameters according to policy table
* permissions
Expand Down Expand Up @@ -161,14 +155,13 @@ class CommandRequestImpl : public CommandImpl,
bool HasDisallowedParams() const;

protected:
RequestState current_state_;
sync_primitives::Lock state_lock_;
CommandParametersPermissions parameters_permissions_;
RequestState current_state_;
sync_primitives::Lock state_lock_;
CommandParametersPermissions parameters_permissions_;

private:
DISALLOW_COPY_AND_ASSIGN(CommandRequestImpl);


/**
* @brief Adds param to disallowed parameters enumeration
* @param info string with disallowed params enumeration
Expand All @@ -181,7 +174,8 @@ class CommandRequestImpl : public CommandImpl,
* @brief Adds disallowed parameters to response info
* @param response Response message, which info should be extended
*/
void AddDisallowedParametersToInfo(smart_objects::SmartObject& response) const;
void AddDisallowedParametersToInfo(
smart_objects::SmartObject& response) const;
};

} // namespace commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@
#include "application_manager/commands/command_request_impl.h"
#include "application_manager/commands/pending.h"
#include "utils/macro.h"
#include "utils/custom_string.h"

namespace application_manager {

namespace commands {

namespace custom_str = utils::custom_string;

/**
* @brief ChangeRegistrationRequest command class
**/
class ChangeRegistrationRequest : public CommandRequestImpl {
class ChangeRegistrationRequest : public CommandRequestImpl {
public:
/**
* @brief ChangeRegistrationRequest class constructor
Expand Down Expand Up @@ -107,9 +110,9 @@ class ChangeRegistrationRequest : public CommandRequestImpl {
*
* @return true if all of result codes is success
*/
bool AllHmiResponsesSuccess(const hmi_apis::Common_Result::eType ui,
const hmi_apis::Common_Result::eType vr,
const hmi_apis::Common_Result::eType tts);
bool AllHmiResponsesSuccess(const hmi_apis::Common_Result::eType ui,
const hmi_apis::Common_Result::eType vr,
const hmi_apis::Common_Result::eType tts);

/**
* @brief Checks change_registration params(ttsName, appname,
Expand All @@ -118,49 +121,49 @@ class ChangeRegistrationRequest : public CommandRequestImpl {
* @return true if command contains \t\n \\t \\n of whitespace otherwise
* returns false.
*/
bool IsWhiteSpaceExist();

/**
* @brief Check parameters (name, vr) for
* coincidence with already known parameters of registered applications
*
* @return SUCCESS if there is no coincidence of app.name/VR synonyms,
* otherwise appropriate error code returns
*/
mobile_apis::Result::eType CheckCoincidence();

/**
* @brief Checks if requested name is allowed by policy
* @param app_name Application name
* @return true, if allowed, otherwise - false
*/
bool IsNicknameAllowed(const std::string& app_name) const;

/**
* @brief Predicate for using with CheckCoincidence method to compare with VR synonym SO
*
* @return TRUE if there is coincidence of VR, otherwise FALSE
*/
struct CoincidencePredicateVR {
explicit CoincidencePredicateVR(const std::string &newItem)
:newItem_(newItem)
{};

bool operator()(smart_objects::SmartObject obj) {
const std::string vr_synonym = obj.asString();
return !(strcasecmp(vr_synonym.c_str(), newItem_.c_str()));
};

const std::string &newItem_;
};

Pending pending_requests_;

hmi_apis::Common_Result::eType ui_result_;
hmi_apis::Common_Result::eType vr_result_;
hmi_apis::Common_Result::eType tts_result_;

DISALLOW_COPY_AND_ASSIGN(ChangeRegistrationRequest);
bool IsWhiteSpaceExist();

/**
* @brief Check parameters (name, vr) for
* coincidence with already known parameters of registered applications
*
* @return SUCCESS if there is no coincidence of app.name/VR synonyms,
* otherwise appropriate error code returns
*/
mobile_apis::Result::eType CheckCoincidence();

/**
* @brief Checks if requested name is allowed by policy
* @param app_name Application name
* @return true, if allowed, otherwise - false
*/
bool IsNicknameAllowed(const custom_str::CustomString& app_name) const;

/**
* @brief Predicate for using with CheckCoincidence method to compare with VR
* synonym SO
*
* @return TRUE if there is coincidence of VR, otherwise FALSE
*/
struct CoincidencePredicateVR {
explicit CoincidencePredicateVR(const custom_str::CustomString& newItem)
: newItem_(newItem){};

bool operator()(const smart_objects::SmartObject& obj) const {
const custom_str::CustomString& vr_synonym = obj.asCustomString();
return newItem_.CompareIgnoreCase(vr_synonym);
};

const custom_str::CustomString& newItem_;
};

Pending pending_requests_;

hmi_apis::Common_Result::eType ui_result_;
hmi_apis::Common_Result::eType vr_result_;
hmi_apis::Common_Result::eType tts_result_;

DISALLOW_COPY_AND_ASSIGN(ChangeRegistrationRequest);
};

} // namespace commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <string.h>
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
#include "utils/custom_string.h"

namespace policy {
struct DeviceInfo;
Expand All @@ -48,6 +49,8 @@ class Application;

namespace commands {

namespace custom_str = utils::custom_string;

/**
* @brief Register app interface request command class
**/
Expand Down Expand Up @@ -99,22 +102,21 @@ class RegisterAppInterfaceRequest : public CommandRequestImpl {
mobile_apis::Result::eType CheckCoincidence();

/*
* @brief Predicate for using with CheckCoincidence method to compare with VR synonym SO
* @brief Predicate for using with CheckCoincidence method to compare with VR
* synonym SO
*
* return TRUE if there is coincidence of VR, otherwise FALSE
*/
struct CoincidencePredicateVR {
explicit CoincidencePredicateVR(const std::string &newItem)
:newItem_(newItem)
{};

bool operator()(smart_objects::SmartObject obj) {
const std::string vr_synonym = obj.asString();
return !(strcasecmp(vr_synonym.c_str(), newItem_.c_str()));
};
explicit CoincidencePredicateVR(const custom_str::CustomString& newItem)
: newItem_(newItem){};

const std::string &newItem_;
bool operator()(const smart_objects::SmartObject& obj) {
const custom_str::CustomString& vr_synonym = obj.asCustomString();
return newItem_.CompareIgnoreCase(vr_synonym);
};
const custom_str::CustomString& newItem_;
};

/**
* @brief Check request parameters against policy table data
Expand Down Expand Up @@ -152,11 +154,10 @@ class RegisterAppInterfaceRequest : public CommandRequestImpl {
*/
void SendSubscribeCustomButtonNotification();

private:
private:
std::string response_info_;
mobile_apis::Result::eType result_checking_app_hmi_type_;


DISALLOW_COPY_AND_ASSIGN(RegisterAppInterfaceRequest);
};

Expand Down
Loading

0 comments on commit 9dbc649

Please sign in to comment.