diff options
Diffstat (limited to 'SDL_Core/src/components/AppMgr/include')
24 files changed, 3626 insertions, 0 deletions
diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/AppChoiceSets.h b/SDL_Core/src/components/AppMgr/include/AppMgr/AppChoiceSets.h new file mode 100644 index 000000000..ef3aa6419 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/AppChoiceSets.h @@ -0,0 +1,156 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPCHOICESETS_H +#define APPCHOICESETS_H + +#include "JSONHandler/SDLRPCObjects/V1/Choice.h" +#include "JSONHandler/SDLRPCObjects/V2/Choice.h" +#include <vector> +#include <string> +#include <map> + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + /** + * \brief interaction choice sets protocol v1 + */ + typedef std::vector<NsSmartDeviceLinkRPC::Choice> ChoiceSetV1; + + /** + * \brief interaction choice sets protocol v2 + */ + typedef std::vector<NsSmartDeviceLinkRPCV2::Choice> ChoiceSetV2; + + /** + * \brief interaction choice sets + */ + struct ChoiceSetGeneric + { + ChoiceSetV1 choiceSetV1; + ChoiceSetV2 choiceSetV2; + ChoiceSetGeneric(); + ChoiceSetGeneric(const ChoiceSetGeneric&src); + const ChoiceSetGeneric& operator= (const ChoiceSetGeneric&); + ~ChoiceSetGeneric(); + }; + + /** + * \brief mapping of interaction choice set id to choice set item vector + */ + typedef std::pair<unsigned int, ChoiceSetGeneric> ChoiceSetItem; + + /** + * \brief mapping of interaction choice set id to choice set item vector + */ + typedef std::map<unsigned int, ChoiceSetGeneric> ChoiceSetItems; + + /** + * \brief AppChoiceSets acts as a mapping between interaction choice set ids and respective choice sets + */ + class AppChoiceSets + { + public: + + /** + * \brief Default class constructor + */ + AppChoiceSets(); + + /** + * \brief Default class destructor + */ + ~AppChoiceSets(); + + /** + * \brief add an interaction choice set item to a mapping + * \param choiceSetId interaction choice set id + * \param choiceSet interaction choice set + */ + void addItem(const unsigned int& choiceSetId, const ChoiceSetV1& choiceSet); + + /** + * \brief add an interaction choice set item to a mapping + * \param choiceSetId interaction choice set id + * \param choiceSet interaction choice set + */ + void addItem(const unsigned int& choiceSetId, const ChoiceSetV2& choiceSet); + + /** + * \brief remove an interaction choice set from a mapping + * \param choiceSetId interaction choice set id + */ + void removeItem(const unsigned int& choiceSetId); + + /** + * \brief find a mapped choice set item + * \param choiceSetId interaction choice set id + * \return a mapped choice set item + */ + const ChoiceSetGeneric *findItem(const unsigned int& choiceSetId); + + /** + * \brief gets all interaction choice set items + * \return interaction choice set items + */ + ChoiceSetItems getAllChoiceSets() const; + + /** + * \brief get count of interaction choice sets + * \return interaction choice sets count + */ + size_t size() const; + + /** + * \brief cleans all the items + */ + void clear(); + + private: + + /** + * \brief Copy constructor + */ + AppChoiceSets(const AppChoiceSets&); + + ChoiceSetItems mChoiceSets; + static log4cplus::Logger mLogger; + }; + +} + +#endif // APPCHOICESETS_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/AppMenus.h b/SDL_Core/src/components/AppMgr/include/AppMgr/AppMenus.h new file mode 100644 index 000000000..9c4f98e88 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/AppMenus.h @@ -0,0 +1,129 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPMENUS_H +#define APPMENUS_H + +#include <map> +#include <string> + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + /** + * \brief mapping of menu item name to menu item position + */ + typedef std::pair<std::string, const unsigned int*> MenuValue; + + /** + * \brief mapping of menu item id to the combination of menu item name and menu item position + */ + typedef std::pair<unsigned int, MenuValue> MenuItem; + + /** + * \brief mapping of menu item id to the combination of menu item name and menu item position + */ + typedef std::map<unsigned int, MenuValue> MenuItems; + + /** + * \brief AppMenus acts as a mapping between menu items id and respective item names with position + */ + class AppMenus + { + public: + + /** + * \brief Default class constructor + */ + AppMenus(); + + /** + * \brief Default class destructor + */ + ~AppMenus(); + + /** + * \brief add a menu item to a mapping + * \param menuId menu id + * \param menuName menu item name + * \param position menu item position within the parent menu + */ + void addItem(const unsigned int& menuId, const std::string& menuName, const unsigned int* position); + + /** + * \brief remove a menu item from a mapping + * \param menuId menu id + */ + void removeItem(const unsigned int& menuId); + + /** + * \brief find a menu item from a mapping + * \param menuId menu id + * \return a menu item from a mapping + */ + const MenuValue* findItem(const unsigned int& menuId); + + /** + * \brief gets all menu items + * \return menu items + */ + MenuItems getAllMenuItems() const; + + /** + * \brief get count of commands + * \return commands count + */ + size_t size() const; + + /** + * \brief cleans all the items + */ + void clear(); + + private: + + /** + * \brief Copy constructor + */ + AppMenus(const AppMenus&); + + MenuItems mMenuItems; + static log4cplus::Logger mLogger; + }; + +} + +#endif // APPMENUS_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/AppMgr.h b/SDL_Core/src/components/AppMgr/include/AppMgr/AppMgr.h new file mode 100644 index 000000000..767223ede --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/AppMgr.h @@ -0,0 +1,159 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPMGR_H +#define APPMGR_H + +#include "JSONHandler/IRPCMessagesObserver.h" +#include "JSONHandler/IRPC2CommandsObserver.h" +#include "ConnectionHandler/IConnectionHandlerObserver.hpp" + +class JSONHandler; +class SDLRPCMessage; +class JSONRPC2Handler; + +namespace log4cplus +{ + class Logger; +} + +namespace NsRPC2Communication +{ + class RPC2Command; +} + +namespace NsConnectionHandler +{ + class IDevicesDiscoveryStarter; +} + +namespace NsAppManager +{ + class AppMgrRegistry; + class AppMgrCore; + class AppFactory; + + /** + * \brief a main app manager class which acts like container for other classes + */ + class AppMgr: public IRPCMessagesObserver, public IRPC2CommandsObserver, public NsConnectionHandler::IConnectionHandlerObserver + { + public: + + /** + * \brief Returning class instance + * \return class instance + */ + static AppMgr& getInstance(); + + /** + * \brief callback to proceed received mobile message + * \param message the received message + * \param connectionKey key of a connection associated with application that sent the message + */ + virtual void onMessageReceivedCallback( NsSmartDeviceLinkRPC::SDLRPCMessage * message, int connectionKey ); + + /** + * \brief callback to proceed received RPC2 command + * \param command the received command + */ + virtual void onCommandReceivedCallback( NsRPC2Communication::RPC2Command * command ); + + /** + * \brief Available devices list updated. + * + * Called when device scanning initiated with scanForNewDevices + * is completed. + * + * \param deviceList New list of available devices. + **/ + virtual void onDeviceListUpdated(const NsConnectionHandler::tDeviceList & deviceList); + + /** + * \brief callback which is called upon session starting + * \param deviceHandle + * \param sessionKey + */ + virtual void onSessionStartedCallback(NsConnectionHandler::tDeviceHandle deviceHandle, int sessionKey, int firstSessionKey); + + /** + * \brief callback which is called upon session ending + * \param sessionKey + */ + virtual void onSessionEndedCallback(int sessionKey, int firstSessionKey); + + /** + * \brief Sets Json mobile handler instance + * \param handler Json mobile handler + */ + void setJsonHandler(JSONHandler* handler); + + /** + * \brief Sets Json RPC2 handler instance + * \param handler Json RPC2 handler + */ + void setJsonRPC2Handler(JSONRPC2Handler* handler); + + /** + * \brief Sets connection handler instance + * \param handler connection handler + */ + void setConnectionHandler(NsConnectionHandler::IDevicesDiscoveryStarter *handler); + + /** + * \brief method to execute threads. + */ + void executeThreads(); + + private: + + /** + * \brief Default class destructor + */ + virtual ~AppMgr(); + + /** + * \brief Copy constructor + */ + AppMgr(const AppMgr&); + + /** + * \brief Default class constructor + */ + AppMgr(); + + static log4cplus::Logger mLogger; + }; + +} // namespace NsAppManager + +#endif // APPMGR_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/AppMgrCore.h b/SDL_Core/src/components/AppMgr/include/AppMgr/AppMgrCore.h new file mode 100644 index 000000000..909e6d77b --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/AppMgrCore.h @@ -0,0 +1,382 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPMGR_H_ +#define APPMGR_H_ + +#include <string> +#include "AppMgr/Application.h" +#include "AppMgr/ButtonMapping.h" +#include "AppMgr/VehicleDataMapping.h" +#include "AppMgr/CapabilitesContainer.h" +#include "AppMgr/SyncPManager.h" +#include "AppMgr/DeviceList.h" +#include "AppMgr/DeviceHandler.h" +#include "JSONHandler/SDLRPCObjects/V2/DisplayCapabilities.h" +#include "JSONHandler/SDLRPCObjects/V2/OnDriverDistraction.h" +#include "JSONHandler/RPC2Objects/NsRPC2Communication/Buttons/OnButtonEvent.h" +#include "JSONHandler/RPC2Objects/NsRPC2Communication/Buttons/OnButtonPress.h" +#include "JSONHandler/SDLRPCObjects/V2/VehicleType.h" +#include "JSONHandler/SDLRPCObjects/V1/Language.h" +#include "JSONHandler/SDLRPCObjects/V2/Language.h" +#include "AppMgr/MessageChaining.hpp" +#include "AppMgr/DeviceStorage.hpp" + +namespace NsSmartDeviceLinkRPC +{ + class SDLRPCMessage; +} +class JSONHandler; +class JSONRPC2Handler; + +namespace NsSmartDeviceLinkRPC +{ + class RegisterAppInterface_request; + class OnDriverDistraction; + class SDLRPCRequest; +} + +namespace NsRPC2Communication +{ + class RPC2Command; +} + +namespace log4cplus +{ + class Logger; +} + +namespace NsConnectionHandler +{ + class IDevicesDiscoveryStarter; +} + +namespace NsAppManager +{ + class RegistryItem; + template< class QueueType > + class AppMgrCoreQueue; + + /** + * \brief a connection between a mobile RPC message and a session + */ + typedef std::pair<NsSmartDeviceLinkRPC::SDLRPCMessage*, int> Message; + + /** + * \brief a list of device names + */ + typedef std::vector<std::string> DeviceNamesList; + + /** + *\brief Map of messages between mobile app and hmi + */ + typedef std::map<int, MessageChaining*> MessageChains; + + /** + * \brief Core app manager class which acts as a core for application manager + */ + class AppMgrCore + { + friend class SubscribeButtonCmd; + public: + + /** + * \brief Default class destructor + */ + virtual ~AppMgrCore(); + + /** + * \brief Returning class instance + * \return class instance + */ + static AppMgrCore& getInstance(); + + /** + * \brief push mobile RPC message to a queue + * \param message a message to be pushed + */ + void pushMobileRPCMessage(NsSmartDeviceLinkRPC::SDLRPCMessage * message , int appId); + + /** + * \brief push HMI RPC2 message to a queue + * \param message a message to be pushed + */ + void pushRPC2CommunicationMessage( NsRPC2Communication::RPC2Command * message ); + + /** + * \brief method to execute threads. + */ + void executeThreads(); + + /** + * \brief set Json mobile handler + * \param handler a handler instance + */ + void setJsonHandler(JSONHandler* handler); + + /** + * \brief get Json mobile handler + * \return JSONHandler instance + */ + JSONHandler* getJsonHandler( ) const; + + /** + * \brief set Json RPC2 handler + * \param handler a handler instance + */ + void setJsonRPC2Handler(JSONRPC2Handler* handler); + + /** + * \brief get Json RPC2 handler + * \return JSONRPC2Handler instance + */ + JSONRPC2Handler* getJsonRPC2Handler( ) const; + + /** + * \brief Sets connection handler instance + * \param handler connection handler + */ + void setConnectionHandler(NsConnectionHandler::IDevicesDiscoveryStarter* handler); + + /** + * \brief Gets connection handler instance + * \return connection handler + */ + NsConnectionHandler::IDevicesDiscoveryStarter* getConnectionHandler( ) const; + + /** + * \brief set device list + * \param deviceList device list + */ + void setDeviceList( const NsConnectionHandler::tDeviceList& deviceList ); + + /** + * \brief get device list + * \return device list + */ + const NsConnectionHandler::tDeviceList& getDeviceList() const; + + /** + * \brief add a device to a mapping + * \param sessionKey session/connection key + * \param device device handler + */ + void addDevice( const NsConnectionHandler::tDeviceHandle &device, + const int &sessionKey, int firstSessionKey ); + + /** + * \brief remove a device from a mapping + * \param sessionKey session/connection key + */ + void removeDevice(const int &sessionKey, int firstSessionKey); + + bool getAudioPassThruFlag() const; + void setAudioPassThruFlag(bool flag); + + //const MessageMapping& getMessageMapping() const; + + /** + * \brief retrieve an application instance from the RegistryItrem instance checking for non-null values + * \param item a RegistryItem from which to retrieve an app pointer + * \return Application instance retrieved from item + */ + Application* getApplicationFromItemCheckNotNull( const RegistryItem* item ) const; + + /** + * \brief Sends notification to Mobile Application about changes in its HMI status + * ie in system context/hmi level/audio streaming state. + * \param application Mobile app to be notified about changes + */ + void sendHMINotificationToMobile( Application * application ); + + /** + * \brief Activates app and deactivates others. + * \param app Application to be activated. + * \return bool Success of operation + */ + bool performActivitiesForActivatingApp( Application * app ); + + Application * getItem( int applicationId ); + + private: + + /** + * \brief Default class constructor + */ + AppMgrCore(); + + /** + * \brief Copy constructor + */ + AppMgrCore(const AppMgrCore&); + + /** + * \brief mobile RPC message handler + * \param mesage a message to be handled + * \param pThis a pointer to AppMgrCore class instance + */ + static void handleMobileRPCMessage(Message message, void* pThis); + + /** + * \brief push HMI RPC2 message to a queue + * \param msg a message to be pushed + * \param pThis a pointer to AppMgrCore class instance + */ + static void handleBusRPCMessageIncoming( NsRPC2Communication::RPC2Command* msg, void* pThis ); + + /** + * \brief Register an application + * \param request a RegisterAppInterface request which is the source for application fields initial values + * \param connectionID id of the connection which will be associated with the application + * \param sessionID an id of the session which will be associated with the application + * \return A instance of RegistryItem created for application + */ + const Application* registerApplication(NsSmartDeviceLinkRPC::SDLRPCMessage *request , int sessionKey); + + /** + * \brief unregister an application associated with the given session + * \param connectionID an id of the connection asociated with the application to be unregistered + * \param sessionID an id of the session asociated with the application to be unregistered + */ + void unregisterApplication(int appId); + + /** + * \brief Remove all app components from HMI + * \param currentApp app which components to be removed + * \param connectionID connection id + * \param sessionID session id + */ + void removeAppFromHmi(Application* currentApp, int appId); + + /** + * \brief serialize a string value to the text file + * \param fileName name of the file to serialize to + * \param value a value to serialize + * \return bool success of an operation - true or false + */ + bool serializeToFile(const std::string& fileName, const std::string &value) const; + + /** + * \brief Sends notification to mobile app about button event. + * \param app Application to receive notification + * \param object Notification received from HMI. + */ + void sendButtonEvent( Application * app, NsRPC2Communication::Buttons::OnButtonEvent * object ); + + /** + * \brief Send notification to mobile app about button press event + * \param app Application to receive notification + * \param object Notification received from HMI. + */ + void sendButtonPress( Application * app, NsRPC2Communication::Buttons::OnButtonPress * object ); + + /** + * \brief Remove message from message chain between mobile app and hmi. + * If counter == 0 then remove message completely. + * \param chain Iterator in message map + * \return bool True if chain was deleted otherwise false + */ + bool decreaseMessageChain(const MessageChains::iterator & chain); + + /** + * \brief Inserts message chain + * \param chain Pointer to @MessageChain + * \param connectionKey Id of connection for Mobile side + * \param correlationID Correlation id for response for Mobile side + * \return @MessageChaining* pointer to result chain + */ + MessageChaining * addChain(MessageChaining * chain, int connectionKey, unsigned int correlationID); + + void differenceBetweenLists( const NsConnectionHandler::tDeviceList &deviceList ); + + Application * getActiveItem(); + + Application * getApplicationByCommand(const unsigned int &cmdId, int appId); + + bool activateApp( Application * appToBeActivated ); + + AppMgrCoreQueue<Message>* mQueueRPCSmartDeviceLinkObjectsIncoming; + AppMgrCoreQueue<NsRPC2Communication::RPC2Command*>* mQueueRPCBusObjectsIncoming; + + //CapabilitiesContainer<NsSmartDeviceLinkRPC::ButtonCapabilities> mButtonCapabilitiesV1; + CapabilitiesContainer<NsSmartDeviceLinkRPCV2::ButtonCapabilities> mButtonCapabilitiesV2; + NsSmartDeviceLinkRPC::DisplayCapabilities mDisplayCapabilitiesV1; + NsSmartDeviceLinkRPCV2::DisplayCapabilities mDisplayCapabilitiesV2; + NsSmartDeviceLinkRPCV2::PresetBankCapabilities mPresetBankCapabilities; + //CapabilitiesContainer<NsSmartDeviceLinkRPC::HmiZoneCapabilities> mHmiZoneCapabilitiesV1; + CapabilitiesContainer<NsSmartDeviceLinkRPCV2::HmiZoneCapabilities> mHmiZoneCapabilitiesV2; + //CapabilitiesContainer<NsSmartDeviceLinkRPC::VrCapabilities> mVrCapabilitiesV1; + //CapabilitiesContainer<NsSmartDeviceLinkRPC::SpeechCapabilities> mSpeechCapabilitiesV1; + CapabilitiesContainer<NsSmartDeviceLinkRPCV2::VrCapabilities> mVrCapabilitiesV2; + CapabilitiesContainer<NsSmartDeviceLinkRPCV2::SpeechCapabilities> mSpeechCapabilitiesV2; + CapabilitiesContainer<NsSmartDeviceLinkRPCV2::SoftButtonCapabilities> mSoftButtonCapabilities; + ButtonMapping mButtonsMapping; + VehicleDataMapping mVehicleDataMapping; + //MessageMapping mMessageMapping; + //RequestMapping mRequestMapping; + //DeviceList mDeviceList; + DeviceHandler mDeviceHandler; + + MessageChains mMessageChaining; + + NsSmartDeviceLinkRPC::OnDriverDistraction* mDriverDistractionV1; + NsSmartDeviceLinkRPCV2::OnDriverDistraction* mDriverDistractionV2; + + NsSmartDeviceLinkRPC::Language mUiLanguageV1; + NsSmartDeviceLinkRPC::Language mVrLanguageV1; + NsSmartDeviceLinkRPC::Language mTtsLanguageV1; + NsSmartDeviceLinkRPCV2::Language mUiLanguageV2; + NsSmartDeviceLinkRPCV2::Language mVrLanguageV2; + NsSmartDeviceLinkRPCV2::Language mTtsLanguageV2; + std::vector<NsSmartDeviceLinkRPCV2::Language> mUISupportedLanguages; + std::vector<NsSmartDeviceLinkRPCV2::Language> mVRSupportedLanguages; + std::vector<NsSmartDeviceLinkRPCV2::Language> mTTSSupportedLanguages; + + NsSmartDeviceLinkRPCV2::VehicleType mVehicleType; + bool mAudioPassThruFlag; + int mPerformInteractionFlag; + int mHMIStartupFlag; + + std::map<int, int> menuMapping; // map<request_id, menu_id> + + SyncPManager mSyncPManager; + + static log4cplus::Logger mLogger; + + std::map<int, Application*> mApplications; + std::map<int, DeviceStorage> mDevices; + //NsConnectionHandler::tDeviceList mDevices; + }; + +} // namespace NsAppManager + +#endif /* APPMGR_H_ */ diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/AppMgrCoreQueues.h b/SDL_Core/src/components/AppMgr/include/AppMgr/AppMgrCoreQueues.h new file mode 100644 index 000000000..477a72d75 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/AppMgrCoreQueues.h @@ -0,0 +1,115 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPMGRCOREQUEUES_H +#define APPMGRCOREQUEUES_H + +#include "system.h" +#include <queue> +#include <string> +#include <map> + +namespace log4cplus +{ + class Logger; +} + +namespace NsRPC2Communication +{ + class RPC2Command; +} + +namespace NsAppManager +{ + + /** + * \brief AppMgrCore queue acts as a container for various messages that need to be parsed/handled in different threads + * \class QueueType type of queue elements + */ + template< class QueueType > + class AppMgrCoreQueue + { + public: + /** + * \brief Callback function + * \param QueueType type of queue elements + * \param pThis pointer to an instance of the class the callback is being called of + */ + typedef void (*HandlerCallback)( QueueType, void* ); + + /** + * \brief Class constructor + * \param cbFn callback function for a handler thread + * \param pThis pointer to an instance of the class the cbFn is being called of + */ + AppMgrCoreQueue(HandlerCallback cbFn, void *pThis); + + /** + * \brief Default destructor + */ + virtual ~AppMgrCoreQueue(); + + /** + * \brief execute inner threads + */ + void executeThreads(); + + /** + * \brief push a message to a queue + * \param message a message being pushed + */ + void pushMessage(QueueType message); + + private: + + /** + * \brief Default copy constructor + */ + AppMgrCoreQueue( const AppMgrCoreQueue& ); + + /** + * \brief handle a queue + * \param pThis a pointer to an instance of the class the callback function is being called of + */ + void* handleQueue(void* pThis); + + std::queue< QueueType > mQueue; + System::Mutex mMtx; + System::BinarySemaphore mBinarySemaphore; + System::Thread* mThread; + HandlerCallback mCallbackFn; + static log4cplus::Logger mLogger; + }; + +} + +#endif // APPMGRCOREQUEUES_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/AppPolicy.h b/SDL_Core/src/components/AppMgr/include/AppMgr/AppPolicy.h new file mode 100644 index 000000000..9458c037c --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/AppPolicy.h @@ -0,0 +1,89 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPPOLICY_H_ +#define APPPOLICY_H_ + +#include <string> + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + + /** + * \brief AppPolicy acts as application behaviour modifier according to some rule + */ + class AppPolicy + { + public: + + /** + * \brief Class constructor + * \param policy text representation + */ + AppPolicy( const std::string& policy ); + + /** + * \brief Default class destructor + */ + ~AppPolicy( ); + + /** + * \brief comparison operator + * \return comparison result + */ + bool operator<(const AppPolicy& item2) const; + + /** + * \brief gets application policy text representation + * \return application policy test representation + */ + const std::string& getPolicyHash() const; + + private: + + /** + * \brief Default class copy constructor + */ + AppPolicy( const AppPolicy& ); + + const std::string mPolicy; + static log4cplus::Logger mLogger; + }; + +} // namespace NsAppManager + +#endif /* APPPOLICY_H_ */ diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/Application.h b/SDL_Core/src/components/AppMgr/include/AppMgr/Application.h new file mode 100644 index 000000000..9ca9c2a9e --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/Application.h @@ -0,0 +1,356 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPLICATION_H_ +#define APPLICATION_H_ + +#include "AppMgr/MenuMapping.h" +#include "AppMgr/CommandMapping.h" +#include "AppMgr/AppMenus.h" +#include "JSONHandler/SDLRPCObjects/V2/AudioStreamingState.h" +#include "JSONHandler/SDLRPCObjects/V2/SystemContext.h" +#include "JSONHandler/SDLRPCObjects/V2/HMILevel.h" +#include "JSONHandler/SDLRPCObjects/V1/AudioStreamingState.h" +#include "JSONHandler/SDLRPCObjects/V1/SystemContext.h" +#include "JSONHandler/SDLRPCObjects/V1/HMILevel.h" +#include <string> +#include <vector> +#include <tuple> +#include <map> +#include <list> +#include <cstddef> + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + /** + * \brief An application unique id - combination of connection id and session id + */ + typedef int ApplicationUniqueID; + + /** + * \brief An application session keys + */ + typedef std::list<int> SessionKeys; + + /** + * \brief class Application acts as a metaphor for every mobile application being registered on HMI + */ + class Application + { + public: + + /** + * \brief Class constructor + * \param name application name + * \param appId application id + * \param protocolVersion protocol version + */ + Application(const std::string& name, int appId, unsigned int protocolVersion); + + /** + * \brief Default class destructor + */ + virtual ~Application( ); + + /** + * \brief operator == + * \param item the item to compare with + * \return comparison result + */ + bool operator==(const Application& item) const; + + /** + * \brief Set application NGN media screen app name + * \param value application NGN media screen app name + */ + void setNgnMediaScreenAppName(const std::string& value); + + /** + * \brief Set application voice recognition synonyms + * \param value application voice recognition synonyms + */ + void setVrSynonyms(const std::vector<std::string>& value); + + /** + * \brief Set if the application is a media application + * \param value is the application a media application + */ + void setIsMediaApplication(bool value); + + /** + * \brief retrieve application NGN media screen application name + * \return application NGN media screen application name + */ + const std::string& getNgnMediaScreenAppName( ) const; + + /** + * \brief retrieve application voice-recognition synonyms + * \return application voice-recognition synonyms + */ + const std::vector<std::string>& getVrSynonyms( ) const; + + /** + * \brief retrieve is the application a media application + * \return is the application a media application + */ + bool getIsMediaApplication( ) const; + + /** + * \brief retrieve application protocol version + * \return application protocol version + */ + const unsigned int& getProtocolVersion() const; + + /** + * \brief retrieve application name + * \return application name + */ + const std::string& getName() const; + + /** + * \brief retrieve application ID + * \return application ID + */ + const int& getAppID( ) const; + + /** + * \brief add a command to a menu + * \param commandId command id + * \param menuId menu id + */ + void addMenuCommand(const unsigned int &commandId, const unsigned int &menuId ); + + /** + * \brief remove a command from a menu(s) + * \param commandId command id + */ + void removeMenuCommand(const unsigned int& commandId); + + /** + * \brief find commands within a menu + * \param menuId menu id + * \return commands residing within the given menu + */ + MenuCommands findMenuCommands(const unsigned int &menuId) const; + + /** + * \brief add a menu item to the application + * \param menuId menu id + * \param menuName menu item name + * \param position menu item position within the parent menu + */ + void addMenu(const unsigned int &menuId, const std::string& menuName, const unsigned int* position=0); + + /** + * \brief remove a menu item from the application + * \param menuId menu id + */ + void removeMenu(const unsigned int& menuId); + + /** + * \brief find a menu item from a mapping + * \param menuId menu id + * \return a menu item from a mapping + */ + const MenuValue* findMenu(const unsigned int& menuId); + + /** + * \brief gets all application menus + * \return application menus + */ + MenuItems getAllMenus() const; + + /** + * \brief get count of items + * \return items count + */ + size_t getMenusCount() const; + + /** + * \brief get count of items + * \return items count + */ + size_t getMenuCommandsCount() const; + + /** + * \brief add a command to an application + * \param commandId command id + * \param type command type + * \param params VR or UI params supplied with the AddCommand request + */ + void addCommand(unsigned int commandId, CommandType type , CommandParams params); + + /** + * \brief remove a command from application + * \param commandId command id + * \param type a type of a command + */ + void removeCommand(unsigned int commandId, CommandType type); + + /** + * \brief finds commands in application + * \param commandId command id + * \return command list + */ + Commands findCommands(unsigned int commandId) const; + + /** + * \brief gets all application commands + * \return application commands + */ + Commands getAllCommands() const; + + /** + * \brief get count of items + * \return items count + */ + size_t getCommandsCount() const; + + /** + * \brief retrieve types associated with command id in current application + * \param commandId command id to search for types + * \return input container of command types to be filled with result + */ + CommandTypes getCommandTypes(unsigned int commandId) const; + + /** + * \brief get count of unresponsed requests associated with the given command id + * \param cmdId id of command we need to count unresponded requests for + * \return unresponded requests count + */ + unsigned int getUnrespondedRequestCount(const unsigned int& cmdId) const; + + /** + * \brief increment count of unresponsed requests associated with the given command id + * \param cmdId id of command we need to increment unresponded request count for + * \return unresponded requests count after the operation + */ + unsigned int incrementUnrespondedRequestCount(const unsigned int& cmdId); + + /** + * \brief decrement count of unresponsed requests associated with the given command id + * \param cmdId id of command we need to decrement unresponded request count for + * \return unresponded requests count after the operation + */ + unsigned int decrementUnrespondedRequestCount(const unsigned int& cmdId); + + /** + * \brief add session key to a list of session keys + * \param sessionKey session key + */ + void addSessionKey(const int& sessionKey); + + /** + * \brief remove session key from a list of session keys + * \param sessionKey session key + */ + void removeSessionKey(const int& sessionKey); + + /** + * \brief set application system context + * \param application system context + */ + virtual void setSystemContext( NsSmartDeviceLinkRPCV2::SystemContext value ); + + /** + * \brief retrieve application system context + * \return application system context + */ + virtual const NsSmartDeviceLinkRPCV2::SystemContext& getSystemContext() const; + + /** + * \brief Set application audio streaming state + * \param streamingState audio streaming state of application + */ + virtual void setApplicationAudioStreamingState( const NsSmartDeviceLinkRPCV2::AudioStreamingState& hmiLevel ); + + /** + * \brief retreive application audio streaming state + * \return application audio streaming state + */ + virtual const NsSmartDeviceLinkRPCV2::AudioStreamingState& getApplicationAudioStreamingState( ) const; + + /** + * \brief Set application HMI status level + * \param hmiLevel HMI status level of application + */ + virtual void setApplicationHMIStatusLevel( const NsSmartDeviceLinkRPCV2::HMILevel::HMILevelInternal& hmiLevel ); + + /** + * \brief retrieve aplication HMI status level + * \return HMI status level of application + */ + virtual const NsSmartDeviceLinkRPCV2::HMILevel::HMILevelInternal& getApplicationHMIStatusLevel( ) const; + + void addPersistentFile(const std::string& file); + void removePersistentFile(const std::string& file); + bool isPersistentFile(const std::string& file); + + int getDeviceHandle() const; + void setDeviceHandle(int deviceHandle); + + + protected: + static log4cplus::Logger mLogger; + + /** + * \brief Copy constructor + */ + Application(const Application& ); + + const std::string mName; + const unsigned int mProtocolVersion; + const int mAppID; + SessionKeys mSessionKeys; + std::string mNgnMediaScreenAppName; + std::vector<std::string> mVrSynonyms; + std::vector<std::string> persistentFiles; + bool m_bIsMediaApplication; + MenuMapping mMenuMapping; + CommandMapping mCommandMapping; + AppMenus mMenus; + + NsSmartDeviceLinkRPCV2::SystemContext mSystemContext; + NsSmartDeviceLinkRPCV2::AudioStreamingState mAudioStreamingState; + NsSmartDeviceLinkRPCV2::HMILevel::HMILevelInternal mHMIStatusLevel; + + int mDeviceHandle; + }; + +} // namespace NsAppManager + +#endif /* APPLICATION_H_ */ diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/Application_v1.h b/SDL_Core/src/components/AppMgr/include/AppMgr/Application_v1.h new file mode 100644 index 000000000..018fb755a --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/Application_v1.h @@ -0,0 +1,161 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPLICATION_V1_H +#define APPLICATION_V1_H + +#include "AppMgr/Application.h" +#include "AppMgr/AppChoiceSets.h" +#include "JSONHandler/SDLRPCObjects/V1/Language.h" +#include "JSONHandler/SDLRPCObjects/V1/SyncMsgVersion.h" + +namespace NsAppManager +{ + /** + * \brief class Application acts as a metaphor for every mobile application of protocol v1 being registered on HMI + */ + class Application_v1 : public Application + { + public: + + /** + * \brief Class constructor + * \param name application name + * \param appId application id + */ + Application_v1(const std::string& name, int appId); + + /** + * \brief Default class destructor + */ + virtual ~Application_v1( ); + + /** + * \brief Set application usage of vehicle data + * \param value does the application use vehicle data + */ + void setUsesVehicleData(bool value); + + /** + * \brief retrieve does the application use vehicle data + * \return does the application use vehicle data + */ + bool getUsesVehicleData( ) const; + + /** + * \brief Set application desired languuage + * \param value application desired language + */ + void setLanguageDesired(NsSmartDeviceLinkRPC::Language value); + + /** + * \brief retrieve application desired language + * \return application desired language + */ + const NsSmartDeviceLinkRPC::Language& getLanguageDesired( ) const; + + /** + * \brief Set application HMI desired display language + * \param value application HMI desired display language + */ + void setHMIDisplayLanguageDesired( NsSmartDeviceLinkRPC::Language value ); + + /** + * \brief retrieve application HMI desired display language + * \return application HMI desired display language + */ + const NsSmartDeviceLinkRPC::Language& getHMIDisplayLanguageDesired( ) const; + + + + /** + * \brief Set application sync message version + * \param value application sync message version + */ + void setSyncMsgVersion(NsSmartDeviceLinkRPC::SyncMsgVersion value); + + /** + * \brief retrieve application sync message version + * \return application sync msg version + */ + const NsSmartDeviceLinkRPC::SyncMsgVersion& getSyncMsgVersion( ) const; + + /** + * \brief add an interaction choice set item to the application + * \param choiceSetId interaction choice set id + * \param choiceSet interaction choice set + */ + void addChoiceSet(const unsigned int& choiceSetId, const ChoiceSetV1& choiceSet); + + /** + * \brief remove an interaction choice set from the application + * \param choiceSetId interaction choice set id + */ + void removeChoiceSet(const unsigned int& choiceSetId); + + /** + * \brief gets all interaction choice set items + * \return interaction choice set items + */ + ChoiceSetItems getAllChoiceSets() const; + + /** + * \brief get count of interaction choice sets + * \return interaction choice sets count + */ + size_t getChoiceSetsCount() const; + + /** + * \brief find a mapped choice set item + * \param choiceSetId interaction choice set id + * \return a mapped choice set item + */ + const ChoiceSetV1 *findChoiceSet(const unsigned int& choiceSetId); + + private: + + /** + * \brief Copy constructor + */ + Application_v1(const Application_v1& ); + + NsSmartDeviceLinkRPC::Language mLanguageDesired; + + NsSmartDeviceLinkRPC::Language mHMIDisplayLanguageDesired; + + NsSmartDeviceLinkRPC::SyncMsgVersion mSyncMsgVersion; + AppChoiceSets mChoiceSets; + bool m_bUsesVehicleData; + }; +} + +#endif // APPLICATION_V1_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/Application_v2.h b/SDL_Core/src/components/AppMgr/include/AppMgr/Application_v2.h new file mode 100644 index 000000000..384503b47 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/Application_v2.h @@ -0,0 +1,187 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPLICATION_V2_H +#define APPLICATION_V2_H + +#include "AppMgr/Application.h" +#include "AppMgr/AppChoiceSets.h" + +#include "JSONHandler/SDLRPCObjects/V2/Language.h" +#include "JSONHandler/SDLRPCObjects/V2/AppType.h" +#include "JSONHandler/SDLRPCObjects/V2/SyncMsgVersion.h" +#include "JSONHandler/SDLRPCObjects/V2/TTSChunk.h" + +namespace NsAppManager +{ + /** + * \brief Application types + */ + typedef std::vector<NsSmartDeviceLinkRPCV2::AppType> AppTypes; + + /** + * \brief TTS name + */ + typedef std::vector<NsSmartDeviceLinkRPCV2::TTSChunk> TTSName; + + /** + * \brief class Application acts as a metaphor for every mobile application of protocol v2 being registered on HMI + */ + class Application_v2 : public Application + { + public: + + /** + * \brief Class constructor + * \param name application name + * \param appId application id + */ + Application_v2(const std::string& name, int appid ); + + /** + * \brief Default class destructor + */ + virtual ~Application_v2( ); + + /** + * \brief Set application desired languuage + * \param value application desired language + */ + void setLanguageDesired(NsSmartDeviceLinkRPCV2::Language value); + + /** + * \brief retrieve application desired language + * \return application desired language + */ + const NsSmartDeviceLinkRPCV2::Language& getLanguageDesired( ) const; + + /** + * \brief Set application HMI desired display language + * \param value application HMI desired display language + */ + void setHMIDisplayLanguageDesired( NsSmartDeviceLinkRPCV2::Language value ); + + /** + * \brief retrieve application HMI desired display language + * \return application HMI desired display language + */ + const NsSmartDeviceLinkRPCV2::Language& getHMIDisplayLanguageDesired( ) const; + + /** + * \brief Set application type + * \param appType application type + */ + void setAppType(const AppTypes& appType); + + /** + * \brief retreive application type + * \param appId application type + */ + const AppTypes& getAppType() const; + + /** + * \brief Set application sync message version + * \param value application sync message version + */ + void setSyncMsgVersion(NsSmartDeviceLinkRPCV2::SyncMsgVersion value); + + /** + * \brief retrieve application sync message version + * \return application sync msg version + */ + const NsSmartDeviceLinkRPCV2::SyncMsgVersion& getSyncMsgVersion( ) const; + + /** + * \brief Set application text-to-speech name + * \param value application text-to-speech name + */ + void setTtsName(const TTSName& value); + + /** + * \brief retrieve application text-to-speech name + * \return application text-to-speech name + */ + const TTSName& getTtsName( ) const; + + /** + * \brief add an interaction choice set item to the application + * \param choiceSetId interaction choice set id + * \param choiceSet interaction choice set + */ + void addChoiceSet(const unsigned int& choiceSetId, const ChoiceSetV2& choiceSet); + + /** + * \brief remove an interaction choice set from the application + * \param choiceSetId interaction choice set id + */ + void removeChoiceSet(const unsigned int& choiceSetId); + + /** + * \brief gets all interaction choice set items + * \return interaction choice set items + */ + ChoiceSetItems getAllChoiceSets() const; + + /** + * \brief get count of interaction choice sets + * \return interaction choice sets count + */ + size_t getChoiceSetsCount() const; + + /** + * \brief find a mapped choice set item + * \param choiceSetId interaction choice set id + * \return a mapped choice set item + */ + const ChoiceSetV2 *findChoiceSet(const unsigned int& choiceSetId); + + private: + + /** + * \brief Copy constructor + */ + Application_v2(const Application_v2& ); + + NsSmartDeviceLinkRPCV2::Language mLanguageDesired; + + NsSmartDeviceLinkRPCV2::Language mHMIDisplayLanguageDesired; + + NsSmartDeviceLinkRPCV2::SyncMsgVersion mSyncMsgVersion; + + // std::string mAppID; + AppTypes mAppType; + AppChoiceSets mChoiceSets; + TTSName mTtsName; + }; +} + +#endif // APPLICATION_V2_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/AutoActivateIdMapping.h b/SDL_Core/src/components/AppMgr/include/AppMgr/AutoActivateIdMapping.h new file mode 100644 index 000000000..a8a0778d5 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/AutoActivateIdMapping.h @@ -0,0 +1,128 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef AUTOACTIVATEIDMAPPING_H +#define AUTOACTIVATEIDMAPPING_H + +#include <string> +#include <map> + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + + /** + * \brief a mapping between application and its auto-activate id (application name is a key) + */ + typedef std::map<std::string, std::string> AutoActivateIDs; + + /** + * \brief an element of a mapping between application and its auto-activate id (application name is a key) + */ + typedef std::pair<std::string, std::string> AutoActivateID; + + /** + * \brief AutoActivateIdMapping acts as a mapping of auto-activate ids to names of registered applications + * \brief An autoActivateId is being assigned automatically to a newly-registered app name + */ + class AutoActivateIdMapping + { + public: + + /** + * \brief Default class constructor + */ + AutoActivateIdMapping(); + + /** + * \brief Default class destructor + */ + ~AutoActivateIdMapping(); + + /** + * \brief add an application to a mapping + * \param appName application to be added to mapping + * \return auto-activate id assigned to an application + */ + std::string addApplicationName( const std::string& appName ); + + /** + * \brief remove an application from a mapping + * \param appName application to remove all associated ids from mapping + */ + void removeApplicationName( const std::string& appName ); + + /** + * \brief find an auto-activate id subscribed to message + * \param name application name + * \return auto-activate id + */ + std::string findAutoActivateIdAssignedToName(const std::string& name) const; + + /** + * \brief remove all mappings + */ + void clear(); + + private: + + /** + * \brief Copy constructor + */ + AutoActivateIdMapping(const AutoActivateIdMapping&); + + /** + * \brief add an id and an application to a mapping + * \param appName application name + * \param id auto-activate id + */ + void addId( const std::string& appName, const std::string& id ); + + /** + * \brief remove an auto-activate id from a mapping + * \param id auto-activate id + */ + void removeId(const std::string& id); + + AutoActivateIDs mAutoActivateIds; + unsigned long mLastAutoActivateId; + + static log4cplus::Logger mLogger; + }; + +} + +#endif // AUTOACTIVATEIDMAPPING_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/ButtonMapping.h b/SDL_Core/src/components/AppMgr/include/AppMgr/ButtonMapping.h new file mode 100644 index 000000000..69d8af1af --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/ButtonMapping.h @@ -0,0 +1,142 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef BUTTONMAPPING_H +#define BUTTONMAPPING_H + +#include <map> +#include "JSONHandler/SDLRPCObjects/V1/ButtonName.h" +#include "JSONHandler/SDLRPCObjects/V2/ButtonName.h" +#include "AppMgr/Application.h" + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + + class Application; + + /** + * \brief Comparer acts as a comparer that allows to create std::map with NsSmartDeviceLinkRPC::ButtonName as a key + */ + struct Comparer { + bool operator() (const NsSmartDeviceLinkRPCV2::ButtonName &b1, const NsSmartDeviceLinkRPCV2::ButtonName &b2) const; + }; + + /** + * \brief a button_name-registered-app map + */ + typedef std::multimap<NsSmartDeviceLinkRPCV2::ButtonName, Application*, Comparer> ButtonMap; + + /** + * \brief a button_name-registered-app map item + */ + typedef std::pair<NsSmartDeviceLinkRPCV2::ButtonName, Application*> ButtonMapItem; + + /** + *\brief Iterators of beginning and end of result range + */ + typedef std::pair<ButtonMap::const_iterator, ButtonMap::const_iterator> ResultRange; + + /** + * \brief ButtonMapping acts as a mapping of buttons to registered application which subscribes to them + */ + class ButtonMapping + { + public: + + /** + * \brief Default class constructor + */ + ButtonMapping(); + + /** + * \brief Default class destructor + */ + ~ButtonMapping(); + + /** + * \brief add a button to a mapping + * \param buttonName button name + * \param app application to map a button to + */ + void addButton( const NsSmartDeviceLinkRPCV2::ButtonName& buttonName, Application* app ); + + /** + * \brief remove a button from a mapping + * \param buttonName button name + */ + void removeButton(const NsSmartDeviceLinkRPCV2::ButtonName& buttonName, Application * item); + + /** + * \brief remove an application from a mapping + * \param app application to remove all associated buttons from mapping + */ + void removeItem( Application* app ); + + /** + * \brief cleans all the mapping + */ + void clear( ); + + /** + * \brief find a registry item subscribed to button + * \param btnName button name + * \return Application instance + */ + Application *findRegistryItemSubscribedToButton(const NsSmartDeviceLinkRPCV2::ButtonName &btnName) const; + + /** + * \brief Find all apps subscribed to button + * \param btnName Button name + * \return @ResultRange Results range + */ + ResultRange findSubscribedToButton(const NsSmartDeviceLinkRPCV2::ButtonName &btnName) const; + + bool exist(const NsSmartDeviceLinkRPCV2::ButtonName& buttonName, Application* item); + private: + + /** + * \brief Copy constructor + */ + ButtonMapping(const ButtonMapping&); + + ButtonMap mButtonsMapping; + static log4cplus::Logger mLogger; + }; + +} + +#endif // BUTTONMAPPING_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/CapabilitesContainer.h b/SDL_Core/src/components/AppMgr/include/AppMgr/CapabilitesContainer.h new file mode 100644 index 000000000..31f1d52a9 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/CapabilitesContainer.h @@ -0,0 +1,110 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef CAPABILITESCONTAINER_H +#define CAPABILITESCONTAINER_H + +#include <vector> + +namespace log4cplus +{ + class Logger; +} + +#include "JSONHandler/RPC2Objects/NsRPC2Communication/Buttons/GetCapabilitiesResponse.h" +#include "JSONHandler/RPC2Objects/NsRPC2Communication/UI/GetCapabilitiesResponse.h" +#include "JSONHandler/RPC2Objects/NsRPC2Communication/VR/GetCapabilitiesResponse.h" +#include "JSONHandler/RPC2Objects/NsRPC2Communication/TTS/GetCapabilitiesResponse.h" +#include "JSONHandler/SDLRPCObjects/V2/PresetBankCapabilities.h" +#include "JSONHandler/SDLRPCObjects/V1/SpeechCapabilities.h" +#include "JSONHandler/SDLRPCObjects/V1/VrCapabilities.h" +#include "JSONHandler/SDLRPCObjects/V1/HmiZoneCapabilities.h" +#include "JSONHandler/SDLRPCObjects/V1/ButtonCapabilities.h" +#include "JSONHandler/SDLRPCObjects/V1/DisplayCapabilities.h" + +namespace NsAppManager +{ + + /** + * \brief CapabilitiesContainer acts as container of button capabilities + */ + template<class DeviceCapabilities> + class CapabilitiesContainer + { + public: + + /** + * \brief Capabilities container + */ + typedef std::vector<DeviceCapabilities> Capabilities; + + /** + * \brief Default class constructor + */ + CapabilitiesContainer(); + + /** + * \brief Default class destructor + */ + ~CapabilitiesContainer(); + + /** + * \brief set capabilities + * \param caps capabilities + */ + void set(const Capabilities& caps ); + + /** + * \brief get capabilities + * \return capabilities + */ + const Capabilities& get() const; + + /** + * \brief clearing underlying container + */ + void clear(); + + private: + + /** + * \brief Default class copy constructor + */ + CapabilitiesContainer(const CapabilitiesContainer&); + + Capabilities mCapabilities; + static log4cplus::Logger mLogger; + }; + +} + +#endif // CAPABILITESCONTAINER_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/CommandMapping.h b/SDL_Core/src/components/AppMgr/include/AppMgr/CommandMapping.h new file mode 100644 index 000000000..039736775 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/CommandMapping.h @@ -0,0 +1,318 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef COMMANDMAPPING_H +#define COMMANDMAPPING_H + +#include <map> +#include <tuple> +#include <vector> +#include <set> +#include <cstddef> +#include "JSONHandler/SDLRPCObjects/V1/MenuParams.h" +#include "JSONHandler/SDLRPCObjects/V2/MenuParams.h" + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + + class RegistryItem; + class Application; + + /** + * \brief CommandType acts as command type enum representation that allows iterating over types in cycle and using types in comparison + */ + class CommandType + { + public: + + /** + * \brief command types + */ + typedef enum + { + UNDEFINED = -1, + UI = 0, + FIRST = UI, + VR = 1, + TTS = 2, + LAST = TTS + } Type; + + /** + * \brief Default constructor + */ + CommandType(); + + /** + * \brief Copy constructor + */ + CommandType(const CommandType& src); + + /** + * \brief Class constructor + * \param type command type to create a class with + */ + CommandType(const Type& type); + + /** + * \brief comparison operator + * \param type of a command to compare with + * \return comparison result + */ + bool operator==(const Type& type) const; + + /** + * \brief comparison operator + * \param type of a command to compare with + * \return comparison result + */ + bool operator==(const CommandType& type) const; + + /** + * \brief comparison operator + * \param type of a command to compare with + * \return comparison result + */ + bool operator<(const Type& type) const; + + /** + * \brief comparison operator + * \param type of a command to compare with + * \return comparison result + */ + bool operator<(const CommandType& type) const; + + /** + * \brief comparison operator + * \param type of a command to compare with + * \return comparison result + */ + bool operator>(const Type& type) const; + + /** + * \brief comparison operator + * \param type of a command to compare with + * \return comparison result + */ + bool operator>(const CommandType& type) const; + + /** + * \brief comparison operator + * \param type of a command to compare with + * \return comparison result + */ + bool operator!=(const Type& type) const; + + /** + * \brief comparison operator + * \param type of a command to compare with + * \return comparison result + */ + bool operator!=(const CommandType& type) const; + + /** + * \brief pre-increment operator + * \return incremented value + */ + CommandType& operator++ (); + + /** + * \brief post-increment operator + * \return incremented value + */ + CommandType operator++ (int); + + /** + * \brief get command type + * \return command type + */ + const Type& getType() const; + + private: + Type mType; + }; + + /** + * \brief Acts as a wrapper of command UI or VR params + */ + union CommandParams + { + const NsSmartDeviceLinkRPCV2::MenuParams* menuParamsV2; + const NsSmartDeviceLinkRPC::MenuParams* menuParams; + const std::vector<std::string>* vrCommands; + }; + + /** + * \brief mapping of command id to specific command type + */ + typedef std::tuple<unsigned int, CommandType> CommandBase; + + /** + * \brief mapping of command base to params + */ + typedef std::pair<CommandBase, CommandParams> Command; + + /** + * \brief command types associated with command + */ + typedef std::vector<CommandType> CommandTypes; + + /** + * \brief commands vector + */ + typedef std::map<CommandBase, CommandParams> Commands; + + /** + * \brief command_id-to-request_number map (command id is a key); + */ + typedef std::map<unsigned int, unsigned int> RequestsAwaitingResponse; + + /** + * \brief command_id-to-request_number map item (command id is a key); + */ + typedef std::pair<unsigned int, unsigned int> RequestAwaitingResponse; + + /** + * \brief CommandMapping acts as a mapping of command to const NsSmartDeviceLinkRPC::MenuParams that are contained in some of them + */ + class CommandMapping + { + public: + + /** + * \brief Default class constructor + */ + CommandMapping(); + + /** + * \brief Default class destructor + */ + ~CommandMapping(); + + /** + * \brief add a command to a mapping + * \param commandId command id + * \param type command type + * \param params VR or UI params supplied with the AddCommand request + */ + void addCommand(unsigned int commandId, const CommandType &type , CommandParams params); + + /** + * \brief remove a command from a mapping + * \param commandId command id + * \param type a type of a command + */ + void removeCommand(unsigned int commandId, const CommandType &type); + + /** + * \brief finds commands in mapping + * \param commandId command id + * \return true if found, false if not + */ + bool findCommand(unsigned int commandId, const CommandType &type) const; + + /** + * \brief finds commands in mapping + * \param commandId command id + * \return commands list + */ + Commands findCommands(unsigned int commandId) const; + + /** + * \brief gets all commands + * \return commands + */ + Commands getAllCommands() const; + + /** + * \brief retrieve types associated with command id in current mapping + * \param commandId command id to search for types + * \return input container of command types to be filled with result + */ + CommandTypes getTypes(unsigned int commandId) const; + + /** + * \brief get count of commands + * \return commands count + */ + size_t size() const; + + /** + * \brief get count of unresponsed requests associated with the given command id + * \param cmdId id of command we need to count unresponded requests for + * \return unresponded requests count + */ + unsigned int getUnrespondedRequestCount(const unsigned int& cmdId) const; + + /** + * \brief increment count of unresponsed requests associated with the given command id + * \param cmdId id of command we need to increment unresponded request count for + * \return unresponded requests count after the operation + */ + unsigned int incrementUnrespondedRequestCount(const unsigned int& cmdId); + + /** + * \brief decrement count of unresponsed requests associated with the given command id + * \param cmdId id of command we need to decrement unresponded request count for + * \return unresponded requests count after the operation + */ + unsigned int decrementUnrespondedRequestCount(const unsigned int& cmdId); + + /** + * \brief cleans all the items + */ + void clear( ); + + /** + * \brief cleans all the requests awaiting response + */ + void clearUnrespondedRequests( ); + + private: + + /** + * \brief Copy constructor + */ + CommandMapping(const CommandMapping&); + Commands mCommands; + RequestsAwaitingResponse mRequestsPerCommand; + static log4cplus::Logger mLogger; + }; + +} + +#endif // COMMANDMAPPING_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/ConnectionHandler.h b/SDL_Core/src/components/AppMgr/include/AppMgr/ConnectionHandler.h new file mode 100644 index 000000000..8cc2bcc3a --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/ConnectionHandler.h @@ -0,0 +1,105 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef APPCONNECTIONHANDLER_H +#define APPCONNECTIONHANDLER_H + + +namespace NsConnectionHandler +{ + class IDevicesDiscoveryStarter; + typedef int tDeviceHandle; +} + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + /** + * \brief ConnectionHandler acts as wrapper for connection handler + */ + class ConnectionHandler + { + public: + /** + * \brief Returning class instance + * \return class instance + */ + static ConnectionHandler &getInstance(); + + /** + * \brief Sets connection handler instance + * \param handler connection handler + */ + void setConnectionHandler(NsConnectionHandler::IDevicesDiscoveryStarter *handler); + + /** + * \brief Gets connection handler instance + * \return connection handler + */ + NsConnectionHandler::IDevicesDiscoveryStarter *getConnectionHandler( ) const; + + /** + * \brief Start device discovery + */ + void startDevicesDiscovery(); + + /** + * \brief Connect to device specified in params + * \param deviceHandle device handle + */ + void connectToDevice( NsConnectionHandler::tDeviceHandle deviceHandle ); + + void startTransportManager(); + + private: + + /** + * \brief Default class constructor + */ + ConnectionHandler(); + + /** + * \brief Copy constructor + */ + ConnectionHandler(const ConnectionHandler&); + + NsConnectionHandler::IDevicesDiscoveryStarter* mConnectionHandler; + static log4cplus::Logger mLogger; + }; + +} + +#endif // APPCONNECTIONHANDLER_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/DeviceHandler.h b/SDL_Core/src/components/AppMgr/include/AppMgr/DeviceHandler.h new file mode 100644 index 000000000..7c15f742d --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/DeviceHandler.h @@ -0,0 +1,121 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef DEVICEHANDLER_H +#define DEVICEHANDLER_H + +#include "ConnectionHandler/CDevice.hpp" + +#include <map> + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + /** + * \brief session-to-device map + */ + typedef std::map<int, NsConnectionHandler::tDeviceHandle> DeviceMap; + + /** + * \brief session-to-device map + */ + typedef std::pair<int, NsConnectionHandler::tDeviceHandle> DeviceMapItem; + + class DeviceHandler + { + public: + + /** + * \brief Default class constructor + */ + DeviceHandler(); + + /** + * \brief Default class destructor + */ + ~DeviceHandler(); + + /** + * \brief add a device to a mapping + * \param sessionKey session/connection key + * \param device device handler + */ + void addDevice( const int& sessionKey, const NsConnectionHandler::tDeviceHandle& device ); + + /** + * \brief remove a device from a mapping + * \param sessionKey session/connection key + */ + void removeDevice(const int& sessionKey); + + /** + * \brief remove an application from a mapping + * \param device device to remove all associated sessions from mapping + */ + void removeSession( const NsConnectionHandler::tDeviceHandle& device ); + + /** + * \brief find a device subscribed to sesssion + * \param sessionKey session/connection key + * \return device handler + */ + NsConnectionHandler::tDeviceHandle findDeviceAssignedToSession(const int& sessionKey) const; + + /** + * \brief cleans session mapping + */ + void clear( ); + + /** + * \brief get count of items + * \return items count + */ + size_t size() const; + + private: + + /** + * \brief Copy constructor + */ + DeviceHandler(const DeviceHandler&); + + DeviceMap mDeviceMapping; + static log4cplus::Logger mLogger; + }; + +} + +#endif // DEVICEHANDLER_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/DeviceList.h b/SDL_Core/src/components/AppMgr/include/AppMgr/DeviceList.h new file mode 100644 index 000000000..7327a0ea2 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/DeviceList.h @@ -0,0 +1,106 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef DEVICELIST_H +#define DEVICELIST_H + +#include "ConnectionHandler/CDevice.hpp" + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + /** + * \brief DeviceList acts as a device list + */ + class DeviceList + { + public: + + /** + * \brief Default class constructor + */ + DeviceList(); + + /** + * \brief Default class destructor + */ + ~DeviceList(); + + /** + * \brief set device list + * \param deviceList device list + */ + void setDeviceList( const NsConnectionHandler::tDeviceList& deviceList ); + + /** + * \brief get device list + * \return device list + */ + const NsConnectionHandler::tDeviceList& getDeviceList() const; + + /** + * \brief get count of items + * \return items count + */ + size_t size() const; + + /** + * \brief find device associated with the given handle + * \param handle device handle + * \return device associated with the given handle + */ + const NsConnectionHandler::CDevice *findDeviceByHandle(const NsConnectionHandler::tDeviceHandle& handle) const; + + /** + * \brief find device associated with the given name + * \param name device name + * \return device associated with the given name + */ + const NsConnectionHandler::CDevice *findDeviceByName(const std::string& name) const; + + private: + + /** + * \brief Copy constructor + */ + DeviceList(const DeviceList&); + + NsConnectionHandler::tDeviceList mDeviceList; + static log4cplus::Logger mLogger; + }; +} + +#endif // DEVICELIST_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/DeviceStorage.hpp b/SDL_Core/src/components/AppMgr/include/AppMgr/DeviceStorage.hpp new file mode 100644 index 000000000..f1152106a --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/DeviceStorage.hpp @@ -0,0 +1,64 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef DEVICESTORAGE_CLASS +#define DEVICESTORAGE_CLASS + +#include <string> +#include <set> + +namespace NsAppManager +{ + class DeviceStorage + { + public: + DeviceStorage(int deviceHandle, const std::string & deviceName); + ~DeviceStorage(); + + void setAppId( int appId ); + int getAppId() const; + int getDeviceHandle() const; + const std::string & getUserFriendlyName() const; + void addConnectionKey(int connectionKey); + bool hasConnectionKey(int connectionKey); + void removeConnectionKey(int connectionKey); + const std::set<int> & getConnectionKeys() const; + + private: + int mDeviceHandle; + std::string mUserFriendlyName; + int mApplicationOnDeviceID; + std::set<int> mConnectionKeys; + }; +} + +#endif // DEVICESTORAGE_CLASS diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/HMIHandler.h b/SDL_Core/src/components/AppMgr/include/AppMgr/HMIHandler.h new file mode 100644 index 000000000..6d5643b27 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/HMIHandler.h @@ -0,0 +1,122 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef HMIHANDLER_H +#define HMIHANDLER_H + +class JSONRPC2Handler; + +namespace NsRPC2Communication +{ + class RPC2Notification; + class RPC2Response; + class RPC2Request; +} + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + + /** + * \brief HMIHandler acts as wrapper for JSON RPC2 handler + */ + class HMIHandler + { + public: + + /** + * \brief Returning class instance + * \return class instance + */ + static HMIHandler &getInstance(); + + /** + * \brief set handler ready state + * \param ready ready state + */ + void setReadyState(bool ready); + + /** + * \brief send notification via associated handler + * \param command notification to send + */ + void sendNotification( const NsRPC2Communication::RPC2Notification * command ); + + /** + * \brief send response via associated handler + * \param command response to send + */ + void sendResponse( const NsRPC2Communication::RPC2Response * command ); + + /** + * \brief send request via associated handler + * \param command request to send + */ + void sendRequest( const NsRPC2Communication::RPC2Request * command ); + + /** + * \brief set Json RPC2 handler + * \param handler Json RPC2 handler instance + */ + void setJsonRPC2Handler(JSONRPC2Handler* handler); + + /** + * \brief get Json RPC2 handler + * \return Json RPC2 handler instance + */ + JSONRPC2Handler* getJsonRPC2Handler( ) const; + + private: + + /** + * \brief Default class constructor + */ + HMIHandler(); + + /** + * \brief Copy constructor + */ + HMIHandler(const HMIHandler&); + + bool m_bHMIReady; + JSONRPC2Handler* mJSONRPC2Handler; + + static log4cplus::Logger mLogger; + }; + +} + +#endif // HMIHANDLER_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/MenuMapping.h b/SDL_Core/src/components/AppMgr/include/AppMgr/MenuMapping.h new file mode 100644 index 000000000..a412dc031 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/MenuMapping.h @@ -0,0 +1,136 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef MENUMAPPING_H +#define MENUMAPPING_H + +#include <map> +#include <vector> +#include <cstddef> + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + + /** + * \brief command-to-menu map (command id is a key: multiple commands can reside within a single menu) + */ + typedef std::map<unsigned int, unsigned int> MenuMap; + + /** + * \brief command-to-menu map item (command id is a key: multiple commands can reside within a single menu) + */ + typedef std::pair<unsigned int, unsigned int> MenuMapItem; + + /** + * \brief commands residing within the same menu + */ + typedef std::vector<unsigned int> MenuCommands; + + /** + * \brief MenuMapping acts as a mapping of command to registsred application that subscribed to them + */ + class MenuMapping + { + public: + /** + * \brief Default class constructor + */ + MenuMapping(); + + /** + * \brief Default class destructor + */ + ~MenuMapping(); + + /** + * \brief add a command to a mapping + * \param commandId command id + * \param menuId menu id + */ + void addCommand(const unsigned int &commandId, const unsigned int &menuId ); + + /** + * \brief remove a command from a mapping + * \param commandId command id + */ + void removeCommand(const unsigned int& commandId); + + /** + * \brief get count of items + * \return items count + */ + size_t size() const; + + /** + * \brief remove an application from a mapping + * \param menuId id of a menu to remove all commands mapping from + */ + void removeMenu(const unsigned int &menuId ); + + /** + * \brief find a registry item subscribed to command + * \param commandId command id + * \return id of menu where a command resides + */ + unsigned int findMenuAssignedToCommand(const unsigned int &commandId) const; + + /** + * \brief find commands within a menu + * \param menuId menu id + * \return commands residing within the given menu + */ + MenuCommands findCommandsAssignedToMenu(const unsigned int &menuId) const; + + /** + * \brief cleans menu mapping + */ + void clear( ); + + private: + + /** + * \brief Copy constructor + */ + MenuMapping(const MenuMapping&); + + MenuMap mMenuMapping; + static log4cplus::Logger mLogger; + }; + +} + +#endif // MENUMAPPING_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/MessageChaining.hpp b/SDL_Core/src/components/AppMgr/include/AppMgr/MessageChaining.hpp new file mode 100644 index 000000000..6006f0b6b --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/MessageChaining.hpp @@ -0,0 +1,53 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef MESSAGE_CHAINING_CLASS +#define MESSAGE_CHAINING_CLASS + +namespace NsAppManager +{ + class MessageChaining + { + public: + MessageChaining(int connectionKey, + unsigned int correlationID); + ~MessageChaining(); + + unsigned int correlationID; + int connectionKey; + bool success; + //unsigned int rpcMessageId; + int counter; + }; +} + +#endif diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/MobileHandler.h b/SDL_Core/src/components/AppMgr/include/AppMgr/MobileHandler.h new file mode 100644 index 000000000..9489f4120 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/MobileHandler.h @@ -0,0 +1,101 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef MOBILEHANDLER_H +#define MOBILEHANDLER_H + +class JSONHandler; + +namespace log4cplus +{ + class Logger; +} + +namespace NsSmartDeviceLinkRPC +{ + class SDLRPCMessage; +} + +namespace NsAppManager +{ + + /** + * \brief MobileHandler acts as wrapper for mobile JSON handler + */ + class MobileHandler + { + public: + + /** + * \brief Returning class instance + * \return class instance + */ + static MobileHandler &getInstance(); + + /** + * \brief send a message via associated handler + * \param message message to send + */ + void sendRPCMessage(const NsSmartDeviceLinkRPC::SDLRPCMessage * message, int appId ); + + /** + * \brief set mobile Json handler + * \param handler mobile Json handler instance + */ + void setJsonHandler(JSONHandler* handler); + + /** + * \brief get mobile Json handler + * \return mobile Json handler instance + */ + JSONHandler* getJsonHandler( ) const; + + private: + + /** + * \brief Default class constructor + */ + MobileHandler(); + + /** + * \brief Copy constructor + */ + MobileHandler(const MobileHandler&); + + JSONHandler* mJSONHandler; + + static log4cplus::Logger mLogger; + }; + +} + +#endif // MOBILEHANDLER_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/RegistryItem.h b/SDL_Core/src/components/AppMgr/include/AppMgr/RegistryItem.h new file mode 100644 index 000000000..172b1466d --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/RegistryItem.h @@ -0,0 +1,129 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef REGISTRYITEM_H_ +#define REGISTRYITEM_H_ + +#include "Application.h" +#include "AppPolicy.h" +#include <set> +#include <string> + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + + /** + * \brief RegistryItem acts as a wrapper for registered application in AppMgrRegistry + */ + class RegistryItem + { + public: + typedef std::set<AppPolicy*> Policies; + + /** + * \brief Class constructor + * \param app application to register + */ + RegistryItem(Application *app ); + + /** + * \brief Default class destructor + */ + virtual ~RegistryItem( ); + + /** + * \brief operator == + * \param item the item to compare with + * \return comparison result + */ + bool operator==(const RegistryItem& item) const; + + /** + * \brief register application policy + * \param hash policy text representation + * \return app policy instance + */ + const AppPolicy* registerPolicy( const std::string& hash ); + + /** + * \brief unregister application policy + * \param policy policy to be unregistered + */ + void unregisterPolicy( AppPolicy* policy ); + + /** + * \brief get associated application + * \return asssociated application + */ + Application *getApplication() const; + + /** + * \brief comparison operator + * \param item2 item to compare with + * \return comparison result + */ + bool operator<(const RegistryItem& item2) const; + + /** + * \brief get application policies + * \param app application to get policies for + * \return app policy set + */ + Policies getApplicationPolicies(const Application* app) const; + + /** + * \brief get application policies + * \param app name of an application to get policies for + * \return app policy set + */ + Policies getApplicationPolicies(const std::string& app) const; + + private: + + /** + * \brief Copy constructor + */ + RegistryItem( const RegistryItem& ); + + Policies mAppPolicies; + Application* mApplication; + static log4cplus::Logger mLogger; + }; + +} // namespace NsAppManager + +#endif /* REGISTRYITEM_H_ */ diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/SyncPManager.h b/SDL_Core/src/components/AppMgr/include/AppMgr/SyncPManager.h new file mode 100644 index 000000000..92c030812 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/SyncPManager.h @@ -0,0 +1,128 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef SYNCPMANAGER_H +#define SYNCPMANAGER_H + +#include <vector> +#include <string> +#include "LoggerHelper.hpp" + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + +/** + * \brief SyncPManager acts as a handler of PData for EncodedSyncPData and OnEncodedSyncPData + */ +class SyncPManager +{ +public: + + /** + * \brief vector of base64-encoded strings + */ + typedef std::vector<std::string> PData; + + /** + * \brief vector of raw strings + */ + typedef std::vector<std::string> RawData; + + /** + * \brief Default class constructor + */ + SyncPManager(); + + /** + * \brief Default class destructor + */ + ~SyncPManager(); + + /** + * \brief set base64-encoded PData + * \param data vector of strings of base64-encoded information + */ + void setPData(const PData& data, const std::string &appName, const int &methodId); + + /** + * \brief get base64-encoded PData + * \return vector of strings of base64-encoded information + */ + const PData& getPData() const; + + /** + * \brief set raw string data + * \param data vector of strings + */ + void setRawData(const RawData& data); + + /** + * \brief set raw string data + * \return vector of strings + */ + RawData getRawData() const; + +private: + + /** + * \brief Copy constructor + */ + SyncPManager(const SyncPManager&); + + /** + * \brief serialize a string vector to the text file + * \param fileName name of the file to serialize to + * \param value a value to serialize + * \return success of an operation - true or false + */ + bool serializeToFile(const std::string& fileName, const PData &value) const; + + /** + * \brief deserialize a string vector from the text file + * \param fileName name of the file to deserialize from + * \param value a value to deserialize + * \return success of an operation - true or false + */ + bool deserializeFromFile(const std::string &fileName, PData &value); + + PData mPData; + static log4cplus::Logger mLogger; +}; + +} + +#endif // SYNCPMANAGER_H diff --git a/SDL_Core/src/components/AppMgr/include/AppMgr/VehicleDataMapping.h b/SDL_Core/src/components/AppMgr/include/AppMgr/VehicleDataMapping.h new file mode 100644 index 000000000..b17cca9f3 --- /dev/null +++ b/SDL_Core/src/components/AppMgr/include/AppMgr/VehicleDataMapping.h @@ -0,0 +1,129 @@ +// +// 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 +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided 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 +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef VEHICLEDATAMAPPING_H +#define VEHICLEDATAMAPPING_H + +#include <map> +#include <vector> +#include "JSONHandler/SDLRPCObjects/V2/VehicleDataType.h" + +namespace log4cplus +{ + class Logger; +} + +namespace NsAppManager +{ + + class Application; + + /** + * \brief a VehicleData-registered-app map + */ + typedef std::multimap<NsSmartDeviceLinkRPCV2::VehicleDataType::VehicleDataTypeInternal, Application*> VehicleDataMap; + + /** + * \brief a VehicleData-registered-app map iterator + */ + typedef std::multimap<NsSmartDeviceLinkRPCV2::VehicleDataType::VehicleDataTypeInternal, Application*>::iterator VehicleDataMapIterator; + + /** + * \brief a VehicleData-registered-app map item + */ + typedef std::pair<NsSmartDeviceLinkRPCV2::VehicleDataType::VehicleDataTypeInternal, Application*> VehicleDataMapItem; + + /** + * \brief VehicleDataMapping acts as a mapping of VehicleData to registered application which subscribes to them + */ + class VehicleDataMapping + { + public: + + /** + * \brief Default class constructor + */ + VehicleDataMapping(); + + /** + * \brief Default class destructor + */ + ~VehicleDataMapping(); + + /** + * \brief add a VehicleData to a mapping + * \param vehicleDataName button name + * \param app application to map a button to + * \return false if such subscribe already exists. + */ + bool addVehicleDataMapping(const NsSmartDeviceLinkRPCV2::VehicleDataType& vehicleDataName, Application* app); + + /** + * \brief remove a VehicleData from a mapping + * \param vehicleDataName button name + * \return false if no such subscribe found. + */ + bool removeVehicleDataMapping(const NsSmartDeviceLinkRPCV2::VehicleDataType& vehicleDataName, Application* app); + + /** + * \brief remove an application from a mapping + * \param app application to remove all associated buttons from mapping + */ + void removeItem(Application* app); + + /** + * \brief cleans all the mapping + */ + void clear(); + + /** + * \brief find a registry item subscribed to VehicleData + * \param vehicleData VehicleDataTypeInternal value + * \param result reference to empty vector to store results. + * \return count of subscribers + */ + int findRegistryItemsSubscribedToVehicleData(const NsSmartDeviceLinkRPCV2::VehicleDataType& vehicleDataName, std::vector<Application*>& result); + + private: + + /** + * \brief Copy constructor + */ + VehicleDataMapping(const VehicleDataMapping&); + + VehicleDataMap mVehicleDataMapping; + static log4cplus::Logger mLogger; + }; + +} + +#endif // VEHICLEDATAMAPPING_H |