simSource.h
1 #pragma once
2 
3 #include "smsSource.h"
4 
5 #include <string>
6 #include <boost/shared_ptr.hpp>
7 #include <boost/make_shared.hpp>
8 #include "../../../../../SERVICES/MODEM/api/src/modemApiPrivate.h"
9 #include "../../../../../LIBRARIES/UTILS/src/dpyError.h"
10 
11 #ifdef TESTING
12 #include "gtest/gtest.h"
13 #endif
14 
19 class SimSource : public SmsSource
20 {
21 private:
22  std::string mModemId;
23  ModemManagerPrivate& mModem;
30  void modem_availability_handler(bool available);
31 
38  void getSourceStatusHandler(boost::system::error_code ec, std::string simid, dpyModem::CallSourceStatus callSourceStatus);
39 
47  void createSms(const std::string& remoteId,const std::string& content,const dpySms::SmsDirection& dir,const struct tm creationDate, boost::shared_ptr<Sms>& sms);
48 
54  void smsListHandler(boost::system::error_code ec, const std::map<std::string, dpyModem::s_SMSInfo>& smsInfoList);
55 
56 
64  void smsEventsHandler(boost::system::error_code ec, std::string simid, std::string smsidmodem, dpyModem::SmsEvent event);
65 
66  bool isValidPhoneNumber(const std::string& number);
67  bool isValidSmsContent(const std::string& content);
68 
69 public:
76  SimSource(const std::string &id, ModemManagerPrivate &modem, const std::string &modemid);
80  virtual ~SimSource();
81 
85  void start();
89  void stop();
90 
98  boost::system::error_code sendSms(const std::string& destination, const std::string& content, std::string& smsid);
99 
105  boost::system::error_code deleteSms(const std::string& smsid);
106 
107 #ifdef TESTING
108 public:
109  FRIEND_TEST(Create_sms_Tests,New_sms_created_locally);
110  FRIEND_TEST(Create_sms_Tests,New_sms_received_externally);
111  FRIEND_TEST(Create_sms_Tests,Sms_notified_to_observer);
112 
113  FRIEND_TEST(Modem_commands_handlers_Tests,Received_modem_sms_no_DPY_OK);
114  FRIEND_TEST(Modem_commands_handlers_Tests,Received_modem_sms_emtpy_list);
115  FRIEND_TEST(Modem_commands_handlers_Tests,Received_modem_sms);
116  FRIEND_TEST(Modem_commands_handlers_Tests,Received_modem_two_sms);
117 
118  FRIEND_TEST(Send_sms_modem_Tests,sendSmsModemNotAvailable);
119  FRIEND_TEST(Send_sms_modem_Tests,sendSmsInvalidContent_not_min_size);
120  FRIEND_TEST(Send_sms_modem_Tests,sendSmsInvalidContent_oversized_size);
121  FRIEND_TEST(Send_sms_modem_Tests,sendSmsInvalidPhoneNumber);
122 
123  FRIEND_TEST(Send_sms_modem_Tests,sendSmsValidContent_max_size);
124  FRIEND_TEST(Send_sms_modem_Tests,sendSmsValidContent_min_size);
125  FRIEND_TEST(Send_sms_modem_Tests,sendSmsCorrectly_format_1);
126  FRIEND_TEST(Send_sms_modem_Tests,sendSmsCorrectly_format_2);
127 
128 #endif //TESTING
129 };
void stop()
Stop Source operations.
Sms Source interface including service logic.
Definition: smsSource.h:14
SmsEvent
Defines the possible sms notifications that a sim can report.
Definition: iSim.h:79
boost::system::error_code deleteSms(const std::string &smsid)
Delete a specific sms from the sms list.
Sim Source interface which interacts with the modem.
Definition: simSource.h:19
virtual ~SimSource()
Destructor.
void start()
Start Source operations.
boost::system::error_code sendSms(const std::string &destination, const std::string &content, std::string &smsid)
Sends a sms to a specified phone number.
Allows to interact with a modem from inside the Deepsy.
Definition: modemApiPrivate.h:88
CallSourceStatus
Defines the possible status that a voice call source can report regarding calls.
Definition: iSim.h:110
SimSource(const std::string &id, ModemManagerPrivate &modem, const std::string &modemid)
Constructor.