smsListConfiguration.h
1 #pragma once
2 
3 #include "../../../../../LIBRARIES/UTILS/src/files/configuration.h"
4 #include "../../../../../LIBRARIES/UTILS/src/dpyError.h"
5 #include "../include/sms.h"
6 
7 #include <list>
8 #include <map>
9 
10 #ifdef TESTING
11 #include "gtest/gtest.h"
12 #endif
13 
20 {
21 private:
23 
24  static SmsListConfiguration *instance;
25  static const std::string mConfigurationFilePath;
26  std::map<std::string, std::list<boost::shared_ptr<Sms>>> mSourceToSmsListMap;
27 
28 protected:
29 
36  virtual bool readConfiguration(boost::system::error_code &ec, std::string path = mConfigurationFilePath);
37 
44  virtual bool writeConfiguration(boost::system::error_code &ec, std::string path = mConfigurationFilePath);
45 
52  virtual bool writeDefaultConfiguration(boost::system::error_code &ec, std::string path = mConfigurationFilePath);
53 
54 public:
55 
61 
62  int getSmsCounter();
63  bool getSmsById(boost::system::error_code &ec, const std::string& smsid, boost::shared_ptr<Sms>& sms);
64  void getStoredSmsList(std::map<std::string, std::list<boost::shared_ptr<Sms>>>& sourcesmsList);
65  bool saveSmsInList(boost::system::error_code& ec, const std::string& sourceId, const boost::shared_ptr<Sms> sms);
66  bool deleteSmsFromList(boost::system::error_code& ec, const std::string& sourceId, const boost::shared_ptr<Sms> sms);
67  bool parseConfiguration(boost::system::error_code &ec, const char* configuration);
68 
69 #ifdef TESTING
70 public:
71  FRIEND_TEST(smsInfo_and_Property_Handlers,sms_back_to_number_no_number);
72  FRIEND_TEST(smsListConfiguration_test,parse_configuration_ok);
73  FRIEND_TEST(smsListConfiguration_test,Get_sms_counter);
74  FRIEND_TEST(smsListConfiguration_test,list_sms_one_sms);
75 
76  FRIEND_TEST(smsListConfiguration_test,Missing_json_header_1);
77  FRIEND_TEST(smsList_advanced_test,sms_added_to_sms_list);
78 
79  FRIEND_TEST(Create_sms_Tests,New_sms_created_locally);
80  FRIEND_TEST(Create_sms_Tests,New_sms_received_externally);
81  FRIEND_TEST(Create_sms_Tests,Sms_notified_to_observer);
82 
83  FRIEND_TEST(Modem_commands_handlers_Tests,Received_modem_sms_no_DPY_OK);
84  FRIEND_TEST(Modem_commands_handlers_Tests,Received_modem_sms_emtpy_list);
85  FRIEND_TEST(Modem_commands_handlers_Tests,Received_modem_sms);
86  FRIEND_TEST(Modem_commands_handlers_Tests,Received_modem_two_sms);
87 #endif
88 };
virtual bool writeConfiguration(boost::system::error_code &ec, std::string path=mConfigurationFilePath)
Writes the service configuration.
virtual bool writeDefaultConfiguration(boost::system::error_code &ec, std::string path=mConfigurationFilePath)
virtual bool readConfiguration(boost::system::error_code &ec, std::string path=mConfigurationFilePath)
Reads the service configuration.
Parent abstract class aimed to provide an interface for class children to manage the configuration fi...
Definition: configuration.h:43
static SmsListConfiguration * getInstance()
Obtain singleton instance.
Manages SMS service configuration files.
Definition: smsListConfiguration.h:19