620 #ifndef TRM_MESSAGES_H_
621 #define TRM_MESSAGES_H_
627 #include "Activity.h"
628 #include "TunerReservation.h"
629 #include "ResponseStatus.h"
637 Notification = 0x1400,
644 static const char *klassName(
void) {
return Klass::kMessageBase; }
646 const std::string & getClassName(
void)
const
651 const MessageType & getType(
void)
const
656 const std::string & getUUID(
void)
const
661 virtual void print(
void)
const
663 std::cout <<
"[OBJ][" << klassName() <<
"] className = " << className << std::endl;
667 MessageBase(
const std::string &className, MessageType type,
const std::string &uuid)
668 : className(className), type(type), uuid(uuid) {}
672 std::string className;
681 static const char *klassName(
void) {
return Klass::kNoResponse; }
693 static const char *klassName(
void) {
return Klass::kRequestBase; }
695 RequestBase(
const std::string &className,
const std::string &uuid,
const std::string &device)
696 :
MessageBase(className, Request, uuid), device(device)
700 RequestBase(
const std::string &className,
const std::string &uuid)
701 :
MessageBase(className, Request, uuid), device(
"")
705 virtual void print(
void)
const
707 MessageBase::print();
708 std::cout <<
"[OBJ][" << klassName() <<
"] uuid = " << getUUID() << std::endl;
710 std::cout <<
"[OBJ][" << klassName() <<
"] device = " << getDevice() << std::endl;
714 const std::string &getDevice(
void)
const {
729 static const char *klassName(
void) {
return Klass::kResponseBase; }
732 const std::string & uuid,
747 virtual void print(
void)
const
749 MessageBase::print();
762 static const char *klassName(
void) {
return Klass::kNotificationBase; }
769 virtual void print(
void)
const
771 MessageBase::print();
772 std::cout <<
"[OBJ][" << klassName() <<
"] uuid = " << getUUID() << std::endl;
781 static const char *klassName(
void) {
return Klass::kSimpleTRMRequest; }
783 virtual void print(
void)
const
785 RequestBase::print();
786 if (!reservationToken.empty())
787 std::cout <<
"[OBJ][" << klassName() <<
"]reservationToken = " << reservationToken<< std::endl;
790 const std::string & getReservationToken(
void)
const
792 return reservationToken;
796 SimpleTRMRequest(
const std::string &className,
const std::string &uuid,
const std::string &device,
const std::string & reservationToken)
798 reservationToken(reservationToken)
802 SimpleTRMRequest(
const std::string &className,
const std::string &uuid,
const std::string & reservationToken)
804 reservationToken(reservationToken)
814 std::string reservationToken;
820 static const char *klassName(
void) {
return Klass::kSimpleTRMResponse; }
822 virtual void print(
void)
const
824 ResponseBase::print();
825 if (!reservationToken.empty())
826 std::cout <<
"reservationToken = " << reservationToken<< std::endl;
829 const std::string & getReservationToken(
void)
const
831 return reservationToken;
836 const ResponseStatus &status,
const std::string & reservationToken)
838 reservationToken(reservationToken)
847 std::string reservationToken;
861 typedef std::list<TunerReservation> ReservationCT;
862 typedef std::list<TunerReservation> ConflictCT;
865 static const char *klassName(
void) {
return Klass::kReserveTunerResponse; }
868 :
ResponseBase(klassName(), uuid, ResponseStatus::kOk) {}
874 tunerReservation(tunerReservation)
880 const ConflictCT &conflicts = ConflictCT ())
894 return tunerReservation;
905 this->tunerReservation = tunerReservation;
936 conflicts.push_back(reservation);
947 ResponseBase::print();
948 if (conflicts.size() == 0) {
949 tunerReservation.print();
952 ConflictCT::const_iterator itm;
953 for (itm = conflicts.begin(); itm != conflicts.end(); itm++) {
961 ConflictCT conflicts;
977 static const char *klassName(
void) {
return Klass::kReserveTuner; }
982 ReserveTuner(
const std::string &uuid,
const std::string &device,
const TunerReservation &tunerReservation,
const std::string &resurrect =
"false")
983 :
RequestBase(klassName(), uuid, device), tunerReservation(tunerReservation),resurrect(resurrect)
991 virtual void print(
void)
const
993 RequestBase::print();
994 tunerReservation.print();
1008 return tunerReservation;
1022 return tunerReservation;
1039 std::string resurrect;
1049 static const char *klassName(
void) {
return Klass::kReleaseTunerReservationResponse; }
1056 const std::string &reservationToken,
1057 const bool &released)
1100 static const char *klassName(
void) {
return Klass::kReleaseTunerReservation; }
1105 ReleaseTunerReservation(
const std::string &uuid,
const std::string &device,
const std::string & reservationToken)
1121 static const char *klassName(
void) {
return Klass::kValidateTunerReservationResponse; }
1128 const std::string &reservationToken,
1174 static const char *klassName(
void) {
return Klass::kValidateTunerReservation; }
1180 const std::string &device,
1181 const std::string &reservationToken)
1197 static const char *klassName(
void) {
return Klass::kCancelRecordingResponse; }
1205 const std::string &reservationToken,
1206 const bool &canceled)
1247 static const char *klassName(
void) {
return Klass::kCancelRecording; }
1252 CancelRecording(
const std::string &uuid,
const std::string & reservationToken)
1268 static const char *klassName(
void) {
return Klass::kCancelLiveResponse; }
1270 CancelLiveResponse(
const std::string &uuid =
"",
const std::string &reservationToken =
"")
1272 canceled(
false), serviceLocator()
1277 const std::string &reservationToken,
1278 const std::string &serviceLocator,
1279 const bool &canceled)
1281 canceled(canceled), serviceLocator(serviceLocator)
1308 return serviceLocator;
1318 this->serviceLocator = serviceLocator;
1323 std::string serviceLocator;
1340 static const char *klassName(
void) {
return Klass::kCancelLive; }
1345 CancelLive(
const std::string &uuid,
const std::string & serviceLocator,
const std::string & reservationToken =
"")
1346 :
SimpleTRMRequest(klassName(), uuid, reservationToken), serviceLocator(serviceLocator)
1357 return serviceLocator;
1367 this->serviceLocator = serviceLocator;
1371 std::string serviceLocator;
1381 static const char *klassName(
void) {
return Klass::kGetAllTunerIdsResponse; }
1388 const std::list<std::string> & tunerIds = std::list<std::string>())
1409 tunerIds.push_back(tid);
1418 tunerIds.insert(tunerIds.end(), tid.begin(), tid.end());
1421 void print(
void)
const {
1422 SimpleTRMResponse::print();
1423 std::list<std::string>::const_iterator it;
1424 for (it = tunerIds.begin(); it != tunerIds.end(); it++) {
1425 std::cout <<
"[OBJ][" << klassName() <<
"]tunerId = " << *it << std::endl;
1428 ~GetAllTunerIdsResponse(
void){}
1431 std::list<std::string> tunerIds;
1445 static const char *klassName(
void) {
return Klass::kGetAllTunerIds; }
1450 GetAllTunerIds(
const std::string &uuid,
const std::string &device=
"")
1465 DetailedTunerState(
const std::string &state=
"Free",
const std::string &serviceLocator=
"")
1466 : state(state), serviceLocator(serviceLocator), reservedDeviceId(
"") {
1483 return serviceLocator;
1490 const std::map<std::string, std::string> &
getOwners(
void)
const {
1504 return reservedDeviceId;
1512 this->reservedDeviceId = reservedDeviceId;
1522 void setState(
const std::string &state,
const std::string &serviceLocator=
"") {
1523 this->state = state;
1524 this->serviceLocator = serviceLocator;
1534 owners[activity] = device;
1537 void print(
const std::string &prefix=
"")
const {
1538 std::cout << prefix <<
"[detailedStates][state] = " << state << std::endl;
1539 std::cout << prefix <<
"[detailedStates][serviceLocator] = " << serviceLocator << std::endl;
1540 std::map<std::string, std::string>::const_iterator owners_it = owners.begin();
1541 for (owners_it = owners.begin(); owners_it != owners.end(); owners_it++) {
1542 std::cout << prefix <<
"[detailedState][activity] = " << owners_it->first << std::endl;
1543 std::cout << prefix <<
"[detailedState][detice] = " << owners_it->second << std::endl;
1547 friend class GetAllTunerStatesResponse;
1548 friend class NotifyTunerStatesUpdate;
1549 friend std::ostream & operator << (std::ostream &, DetailedTunerState
const &);
1552 std::string serviceLocator;
1553 std::map<std::string, std::string> owners;
1554 std::string reservedDeviceId;
1566 static const char *klassName(
void) {
return Klass::kGetAllTunerStatesResponse; }
1573 const std::map<std::string, std::string> & tunerStates = std::map<std::string, std::string>())
1575 tunerStates(tunerStates), tunerDetailedStates()
1596 tunerStates[tid] = state;
1603 SimpleTRMResponse::print();
1605 std::map<std::string, std::string>::const_iterator it;
1606 for (it = tunerStates.begin(); it != tunerStates.end(); it++) {
1607 std::cout <<
"[OBJ][" << klassName() <<
"]" << it->first <<
" = " << it->second << std::endl;
1611 std::map<std::string, DetailedTunerState>::const_iterator it;
1612 for (it = tunerDetailedStates.begin(); it != tunerDetailedStates.end(); it++) {
1613 std::string prefix = std::string(
"[OBJ][") + klassName() +
"][detailedStates][" + it->first +
"] = ";
1614 it->second.print(prefix);
1622 const std::map<std::string, DetailedTunerState> & getTunerDetailedStates(
void)
const {
1623 return tunerDetailedStates;
1634 void addTunerState(
const std::string &tid,
const std::string &state,
const std::string &serviceLocator,
const std::string &reservedDeviceId) {
1635 tunerStates[tid] = state;
1636 tunerDetailedStates[tid].state = state;
1637 tunerDetailedStates[tid].serviceLocator = serviceLocator;
1638 tunerDetailedStates[tid].reservedDeviceId = reservedDeviceId;
1648 void addTunerOwner(
const std::string &tid,
const std::string &activity,
const std::string &device) {
1649 tunerDetailedStates[tid].owners[activity] = device;
1653 std::map<std::string, std::string> tunerStates;
1654 std::map<std::string, DetailedTunerState> tunerDetailedStates;
1674 static const char *klassName(
void) {
return Klass::kGetAllTunerStates; }
1695 static const char *klassName(
void) {
return Klass::kGetAllReservationsResponse; }
1702 const std::map<std::string, std::list<TunerReservation> > & reservations = std::map<std::string, std::list<TunerReservation> > ())
1704 reservations(reservations)
1708 const std::map<std::string, std::list<TunerReservation> > & getAllReservations(
void)
const {
1709 return reservations;
1712 void addTunerReservation(
const std::string &tid,
const TunerReservation &reservation) {
1713 reservations[tid].push_back(reservation);
1719 std::map<std::string, std::list<TunerReservation> > reservations;
1733 static const char *klassName(
void) {
return Klass::kGetAllReservations; }
1740 filterDevice(filterDevice)
1742 filters[
"device"] = filterDevice;
1745 GetAllReservations(
const std::string &uuid,
const std::map<std::string, std::string> &filters)
1747 filterDevice(filterDevice), filters(filters)
1751 const std::string getFilterDevice(
void)
const {
1752 return filterDevice;
1755 void setFilterDevice(
const std::string &filterDevice) {
1756 this->filterDevice = filterDevice;
1757 filters[
"device"] = filterDevice;
1760 const std::string getFilter(
const std::string filterId)
const {
1761 std::map<std::string, std::string>::const_iterator it = filters.find(filterId);
1762 return it == filters.end() ?
"" : it->second;
1765 void addFilter(
const std::string &filterId,
const std::string &filterValue) {
1766 filters[filterId] = filterValue;
1769 const std::map<std::string, std::string> getFilters(
void)
const {
1775 std::string filterDevice;
1776 std::map<std::string, std::string> filters;
1786 static const char *klassName(
void) {
return Klass::kGetVersionResponse; }
1793 const std::string &version)
1799 const std::string getVersion(
void)
const {
1803 void setVersion(
const std::string &version) {
1804 this->version = version;
1807 void print(
void)
const {
1808 SimpleTRMResponse::print();
1814 std::string version;
1826 static const char *klassName(
void) {
return Klass::kGetVersion; }
1831 GetVersion(
const std::string &uuid,
const std::string &device=
"")
1848 static const char *klassName(
void) {
return Klass::kNotifyTunerReservationRelease; }
1855 reservationToken(reservationToken), reason(reason)
1865 return reservationToken;
1881 std::string reservationToken;
1895 static const char *klassName(
void) {
return Klass::kNotifyTunerReservationUpdate; }
1902 updatedReservation(updatedReservation)
1912 return updatedReservation;
1922 return updatedReservation;
1932 this->updatedReservation = tunerReservation;
1937 TunerReservation updatedReservation;
1948 typedef std::list<TunerReservation> ConflictCT;
1950 static const char *klassName(
void) {
return Klass::kNotifyTunerReservationConflicts; }
1957 requestedReservation(requestedReservation), conflicts(conflicts)
1962 requestedReservation(existingLiveReservation) {
1963 addConflict(conflictingRecordReservation);
1973 return requestedReservation;
1983 return requestedReservation;
1993 this->requestedReservation = tunerReservation;
2020 conflicts.push_back(reservation);
2026 TunerReservation requestedReservation;
2027 ConflictCT conflicts;
2040 static const char *klassName(
void) {
return Klass::kNotifyTunerStatesUpdate; }
2055 tunerDetailedStates[tid] = detailedState;
2065 return tunerDetailedStates;
2069 std::map<std::string, DetailedTunerState> tunerDetailedStates;
2079 static const char *klassName(
void) {
return Klass::kNotifyTunerPretune; }
2086 serviceLocator(serviceLocator)
2089 const std::string & getServiceLocator(
void)
const
2091 return serviceLocator;
2096 std::string serviceLocator;
2104 static const char *klassName(
void) {
return Klass::kNotifyClientConnectionEvent; }
2109 NotifyClientConnectionEvent(
const std::string &uuid,
const std::string &eventName,
const std::string &clientIP, uint64_t timeStamp)
2111 eventName(eventName),clientIP(clientIP),timeStamp(timeStamp)
2114 const std::string & getEventName(
void)
const
2119 const std::string & getClientIP(
void)
const
2124 const uint64_t getEventTimeStamp(
void)
const
2132 std::string eventName;
2133 std::string clientIP;
2143 typedef std::list<NotifyClientConnectionEvent> ConnectionEventList;
2145 static const char *klassName(
void) {
return Klass::kGetTRMConnectionEvents; }
2152 const ConnectionEventList &conEventList = ConnectionEventList())
2154 conEventList(conEventList)
2158 const ConnectionEventList & getConEvents(
void)
const {
2159 return conEventList;
2162 ConnectionEventList & getConEvents(
void) {
2163 return conEventList;
2167 conEventList.push_back(event);
2173 ConnectionEventList conEventList;
2182 static const char *klassName(
void) {
return Klass::kGetAllConnectedDeviceIdsResponse; }
2189 const std::list<std::string> & conDeviceIDs = std::list<std::string>())
2191 conDeviceIDs(conDeviceIDs)
2195 const std::list<std::string> & getDeviceIds(
void)
const {
2196 return conDeviceIDs;
2199 void addDeviceId(
const std::string &deviceId) {
2200 conDeviceIDs.push_back(deviceId);
2203 void addDeviceId(
const std::list<std::string> &deviceId) {
2204 conDeviceIDs.insert(conDeviceIDs.end(), deviceId.begin(), deviceId.end());
2207 void print(
void)
const {
2208 SimpleTRMResponse::print();
2209 std::list<std::string>::const_iterator it;
2210 for (it = conDeviceIDs.begin(); it != conDeviceIDs.end(); it++) {
2211 std::cout <<
"[OBJ][" << klassName() <<
"]conDeviceIDs = " << *it << std::endl;
2217 std::list<std::string> conDeviceIDs;
2224 std::string deviceId;
2225 std::string authToken;
2230 std::string deviceId;
2231 std::string partnerId;
2236 static const char *klassName(
void) {
return Klass::kUpdateTunerActivityStatusResponse; }
2240 void print(
void)
const {
2241 std::cout<<
"UpdateTunerActivityStatusResponse "<< std::endl;
2249 static const char *klassName(
void) {
return Klass::kUpdateTunerActivityStatus; }
2251 UpdateTunerActivityStatus(
const std::string &UUID,
const std::string &device,
const std::string & activityStatus,
const std::string & lastActivityTimeStamp,
const std::string & lastActivityAction):
RequestBase( klassName(), UUID, device),activityStatus(activityStatus),lastActivityTimeStamp(lastActivityTimeStamp),lastActivityAction(lastActivityAction){}
2253 const std::string &getTunerActivityStatus(
void)
const {
2254 return activityStatus;
2256 const std::string &getLastActivityTimeStamp(
void)
const {
2257 return lastActivityTimeStamp;
2259 const std::string &getLastActivityAction(
void)
const {
2260 return lastActivityAction;
2262 void print(
void)
const {
2263 std::cout<<
"TRM Message UpdateTunerActivityStatus"<< std::endl;
2264 std::cout<<
"[OBJ] tunerActivityStatus: "<<getTunerActivityStatus() <<std::endl;
2265 std::cout<<
"[OBJ] lastActivityTimeStamp: "<<getLastActivityTimeStamp() <<std::endl;
2266 std::cout<<
"[OBJ] lastActivityAction: "<<getLastActivityAction() <<std::endl;
2272 std::string activityStatus;
2273 std::string lastActivityTimeStamp;
2274 std::string lastActivityAction;