]> git.vomp.tv Git - vompclient.git/blob - tvmedia.cc
Fix leak in picture handling of osdvector, add static fallback pictures, some default...
[vompclient.git] / tvmedia.cc
1 /*
2     Copyright 2014 Marten Richter
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "tvmedia.h"
22 #include "movieinfo.h"
23 #include "seriesinfo.h"
24
25
26 TVMediaInfo::TVMediaInfo()
27 {
28         type=2; // movie or series
29         primary_id=0; //movie or series_id
30         secondary_id=0;  //0 or episode id
31         type_pict=-1; // 0 full info, 1 poster, 2 poster banner, 3 poster thumb
32         container=-1; // indices the dataelements with picture in movieinfo or seriesinfo
33         container_member=-1; // index into the container
34         primary_name="";
35         static_fallback = -1; // fallback if not available
36 }
37
38
39 TVMediaInfo::TVMediaInfo(const TVMediaInfo& info)
40 {
41         type=info.type; // movie or series
42         primary_id=info.primary_id; //movie or series_id
43         secondary_id=info.secondary_id;  //0 or episode id
44         type_pict=info.type_pict; // 0 full info, 1 poster, 2 poster banner, 3 poster thumb
45         container=info.container; // indices the dataelements with picture in movieinfo or seriesinfo
46         container_member=info.container_member; // index into the container
47         primary_name=info.primary_name;
48         static_fallback = info.static_fallback;
49
50 }
51
52 void TVMediaInfo::setMovieInfo(const MovieInfo * mi)
53 {
54         type=1; // movie or series
55         primary_id=mi->id; //movie or series_id
56         secondary_id=0;  //0 or episode id
57 }
58
59 void TVMediaInfo::setSeriesInfo(const SeriesInfo *  si)
60 {
61         type=0; // movie or series
62         primary_id=si->id; //movie or series_id
63         secondary_id=si->episode.episodeid;  //0 or episode id
64 }
65
66 void TVMediaInfo::setPosterThumb(const char* recname)
67 {
68         type=3;
69         primary_name=recname;
70 }
71
72 void TVMediaInfo::setStaticArtwork(int id)
73 {
74         type=4;
75         primary_id=id;
76 }
77
78 void TVMediaInfo::setStaticFallback(int id)
79 {
80         static_fallback=id;
81 }
82
83
84
85 void TVMediaInfo::setPosterThumb(int channel, int eventid)
86 {
87         type=5;
88         primary_id=channel;
89         secondary_id=eventid;
90 }
91
92 void TVMediaInfo::setChannelLogo(int channel)
93 {
94         type=6;
95         primary_id=channel;
96 }
97
98 bool operator<(const TVMediaInfo& rhs, const TVMediaInfo& lhs)
99 {
100         if (rhs.type==lhs.type) {
101                 if (rhs.primary_id==lhs.primary_id) {
102                         if (rhs.static_fallback==lhs.static_fallback) {
103                                 if (rhs.secondary_id==lhs.secondary_id) {
104                                         if (rhs.type_pict==lhs.type_pict) {
105                                                 if (rhs.container==lhs.container) {
106                                                         if (rhs.primary_name== lhs.primary_name) {
107                                                                 return rhs.container_member < lhs.container_member;
108                                                         } else {
109                                                                 return rhs.primary_name < lhs.primary_name;
110                                                         }
111                                                 } else {
112                                                         return rhs.container<lhs.container;
113                                                 }
114
115
116                                         } else {
117                                                 return rhs.type_pict<lhs.type_pict;
118                                         }
119
120                                 } else {
121                                         return rhs.secondary_id<lhs.secondary_id;
122                                 }
123                         } else {
124                                 return rhs.static_fallback<lhs.static_fallback;
125                         }
126
127                 } else {
128                         return rhs.primary_id<lhs.primary_id;
129                 }
130
131
132         } else {
133                 return rhs.type < lhs.type;
134         }
135 }
136
137 bool operator==(const TVMediaInfo& rhs, const TVMediaInfo& lhs)
138 {
139         return (rhs.type==lhs.type)  && (rhs.primary_id==lhs.primary_id) && (rhs.static_fallback==lhs.static_fallback)  &&
140              (rhs.secondary_id==lhs.secondary_id) && (rhs.type_pict==lhs.type_pict) &&
141                 (rhs.container==lhs.container)  && (rhs.primary_name== lhs.primary_name)
142                                                 && (rhs.container_member == lhs.container_member);
143 }