1 #include <channelinfo.h>
2 #include <lib/base/i18n.h>
3 #include <lib/system/init.h>
4 #include <lib/system/init_num.h>
5 #include <lib/gui/eskin.h>
6 #include <lib/gdi/font.h>
7 #include <lib/dvb/epgcache.h>
8 #include <lib/dvb/dvbservice.h>
9 #include <lib/dvb/frontend.h>
10 #include <lib/system/info.h>
13 #include <epgwindow.h>
15 eChannelInfo::eChannelInfo( eWidget
* parent
, const char *deco
)
16 :eDecoWidget(parent
, 0, deco
),
17 ctime(this), cname(this), copos(this), cdescr(this),
18 cdolby(this), cstereo(this),
19 cformat(this), cscrambled(this), eit(0)
21 foregroundColor
=eSkin::getActive()->queryColor("eStatusBar.foreground");
22 backgroundColor
=eSkin::getActive()->queryColor("eStatusBar.background");
23 gFont fn
= eSkin::getActive()->queryFont("eChannelInfo");
26 cdescr
.setForegroundColor( foregroundColor
);
27 cdescr
.setBackgroundColor( backgroundColor
);
28 cdescr
.setFlags(RS_WRAP
);
32 copos
.setAlign( eTextPara::dirRight
);
33 copos
.setForegroundColor( foregroundColor
);
34 copos
.setBackgroundColor( backgroundColor
);
35 copos
.setFlags( RS_FADE
);
38 cname
.setForegroundColor( foregroundColor
);
39 cname
.setBackgroundColor( backgroundColor
);
40 cname
.setFlags( RS_FADE
);
43 ctime
.setForegroundColor( foregroundColor
);
44 ctime
.setBackgroundColor( backgroundColor
);
45 ctime
.setFlags( RS_FADE
);
47 gPixmap
*pm
=eSkin::getActive()->queryImage("sselect_dolby");
49 cdolby
.pixmap_position
= ePoint(0,0);
52 pm
= eSkin::getActive()->queryImage("sselect_stereo");
53 cstereo
.setPixmap(pm
);
54 cstereo
.pixmap_position
= ePoint(0,0);
57 pm
= eSkin::getActive()->queryImage("sselect_format");
58 cformat
.setPixmap(pm
);
59 cformat
.pixmap_position
= ePoint(0,0);
62 pm
= eSkin::getActive()->queryImage("sselect_crypt");
63 cscrambled
.setPixmap(pm
);
64 cscrambled
.pixmap_position
= ePoint(0,0);
68 const char *eChannelInfo::genresTableShort
[256] =
70 /* 0x0 undefined */ NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
71 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
73 /* 0x1 Movie */ _("Movie"),("Thriller"),_("Adventure"),_("SciFi"),_("Comedy"),
74 _("Soap"),_("Romance"),_("Serious"),_("Adult"),
75 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
77 /* 0x2 News */ _("News"),_("Weather"),_("Magazine"),_("Documentary"),_("Discussion"),
78 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
81 /* 0x3 Show */ _("Show"),_("Game Show"),_("Variety"),_("Talk"),
82 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
85 /* 0x4 Sports */ _("Sports"),_("Special Event"),_("Sports Mag."),_("Football"),_("Tennis"),_("Team Sports"),
86 _("Athletics"),_("Motor Sports"),_("Water Sports"),_("Winter Sports"),_("Equestrian"),
90 /* 0x5 Children */ _("Children"),_("Pre-School"),_("Age 6-14"),_("Age 10-16"),_("School"),
92 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
95 /* 0x6 Music */ _("Music"),_("Rock/Pop"),_("Classical"),_("Folk"),_("Jazz"),_("Musical"),_("Ballet"),
96 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
99 /* 0x7 Culture */ _("Culture"),_("Perf. Arts"),_("Fine Arts"),_("Religion"),_("Pop. Arts"),_("Literature"),
100 _("Film"),_("Experimental"),_("Press"),_("New Media"),_("Art Mag."),_("Fashion"),
103 /* 0x8 Social */ _("Social"),_("Soc. Mag."),_("Economics"),_("Remark. People"),
104 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
107 /* 0x9 Education */ _("Education"),_("Nature"),_("Technology"),_("Medicine"),_("Expeditions"),_("Spiritual"),
108 _("Further Ed."),_("Languages"),
109 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
111 /* 0xa Leisure */ _("Hobbies"),_("Travel"),_("Handicraft"),_("Motoring"),_("Fitness"),_("Cooking"),
112 _("Shopping"),_("Gardening"),
113 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
115 /* 0xb Special */ _("Orig. Lang."),_("B&W"),_("Unpublished"),_("Live"),
116 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
119 /* 0xc reserved */ NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
120 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
122 /* 0xd reserved */ NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
123 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
125 /* 0xe reserved */ NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
126 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
128 /* 0xf user defined */ NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,
129 NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
,NULL
132 void eChannelInfo::ParseEITInfo(EITEvent
*e
)
134 name
=descr
=genre
=starttime
="";
140 tm
*stime
=localtime(&e
->start_time
);
141 starttime
.sprintf("%02d:%02d", stime
->tm_hour
, stime
->tm_min
);
142 int show_current_remaining
=1;
143 eConfig::getInstance()->getKey("/ezap/osd/showCurrentRemaining", show_current_remaining
);
144 if (show_current_remaining
)
146 time_t now
= time(0) + eDVB::getInstance()->time_difference
;
147 int duration
= e
->duration
- (now
- e
->start_time
);
148 if ( duration
> e
->duration
)
149 duration
= e
->duration
;
150 else if ( duration
< 0 )
152 t
.sprintf(" (+%dmin)", (int)(duration
/60));
155 t
.sprintf(" (%dmin)", (int)(e
->duration
/60));
158 if (e
->free_CA_mode
)
159 cflags
|= cflagScrambled
;
162 led
.getLocalData(e
, &name
, &descr
, 0);
164 for (ePtrList
<Descriptor
>::iterator
d(e
->descriptor
); d
!= e
->descriptor
.end(); ++d
)
166 Descriptor
*descriptor
=*d
;
167 if (descriptor
->Tag()==DESCR_COMPONENT
)
169 ComponentDescriptor
*cd
=(ComponentDescriptor
*)descriptor
;
171 if( cd
->stream_content
== 2 && cd
->component_type
== 5)
172 cflags
|= cflagDolby
;
173 else if( cd
->stream_content
== 2 && cd
->component_type
== 3)
174 cflags
|= cflagStereo
;
175 else if( cd
->stream_content
== 1 && (cd
->component_type
== 2 || cd
->component_type
== 3) )
178 else if(descriptor
->Tag()==DESCR_CONTENT
)
180 ContentDescriptor
*cod
=(ContentDescriptor
*)descriptor
;
182 for(ePtrList
<descr_content_entry_struct
>::iterator
ce(cod
->contentList
.begin()); ce
!= cod
->contentList
.end(); ++ce
)
184 if(genresTableShort
[ce
->content_nibble_level_1
*16+ce
->content_nibble_level_2
])
186 /* if ( !genre.length() )
187 genre+=_("GENRE: ");*/
188 genre
+= gettext( genresTableShort
[ce
->content_nibble_level_1
*16+ce
->content_nibble_level_2
] );
194 if(!t
.isNull()) name
+= t
;
196 cname
.setText( name
);
203 cdescr
.setText( descr
);
204 ctime
.setText( starttime
);
207 n
= LayoutIcon(&cdolby
, (cflags
& cflagDolby
), n
);
208 n
= LayoutIcon(&cstereo
, (cflags
& cflagStereo
), n
);
209 n
= LayoutIcon(&cformat
, (cflags
& cflagWide
), n
);
210 n
= LayoutIcon(&cscrambled
, (cflags
& cflagScrambled
), n
);
213 void eChannelInfo::closeEIT()
219 void eChannelInfo::getServiceInfo( const eServiceReferenceDVB
& service
)
225 // eService *service=eServiceInterface::getInstance()->addRef(service);
227 if (!service
.path
.size())
230 cname
.setFlags(RS_FADE
);
231 cname
.resize( eSize( clientrect
.width()/8*7-4, clientrect
.height()/3) );
232 int opos
=service
.getDVBNamespace().get()>>16;
233 if ( eSystemInfo::getInstance()->getFEType() == eSystemInfo::feSatellite
)
234 copos
.setText(eString().sprintf("%d.%d\xC2\xB0%c", abs(opos
/ 10), abs(opos
% 10), opos
>0?'E':'W') );
236 e
= eEPGCache::getInstance()->lookupEvent(service
);
237 if (e
) // data is in cache...
242 else // we parse the eit...
244 cname
.setText(_("no data for this service avail"));
245 eDVBServiceController
*sapi
=eDVB::getInstance()->getServiceAPI();
248 eServiceReferenceDVB
&ref
= sapi
->service
;
250 int type
= ((service
.getTransportStreamID()==ref
.getTransportStreamID())
251 && (service
.getOriginalNetworkID()==ref
.getOriginalNetworkID())) ? EIT::tsActual
:EIT::tsOther
;
253 eit
= new EIT( EIT::typeNowNext
, service
.getServiceID().get(), type
);
254 CONNECT( eit
->tableReady
, eChannelInfo::EITready
);
261 cname
.setFlags(RS_WRAP
);
262 cname
.resize( eSize( clientrect
.width()/8*7-4, clientrect
.height() ));
263 // should be moved to eService
264 int filelength
=service
.getFileLength();
267 eString filename
=service
.path
;
270 while (!stat64((filename
+ (slice
? eString().sprintf(".%03d", slice
) : eString(""))).c_str(), &s
))
272 filelength
+=s
.st_size
/1024;
276 int i
= service
.path
.rfind("/");
279 size
.sprintf(_("\nFilesize: %d MB"), filelength
/1024);
280 cname
.setText(eString(_("Filename: "))+service
.path
.mid( i
, service
.path
.length()-i
)+size
);
284 void eChannelInfo::EITready( int err
)
286 // eDebug("Channelinfo eit ready: %d", err);
287 if (eit
->ready
&& !eit
->error
)
289 if ( eit
->events
.size() )
290 ParseEITInfo(eit
->events
.begin());
292 else if ( err
== -ETIMEDOUT
)
296 void eChannelInfo::update( const eServiceReferenceDVB
& service
)
301 getServiceInfo(current
);
305 void eChannelInfo::clear()
317 int eChannelInfo::LayoutIcon(eLabel
*icon
, int doit
, int num
)
346 icon
->move(ePoint(x
,y
));
355 void eChannelInfo::redrawWidget(gPainter
*target
, const eRect
& where
)
358 deco
.drawDecoration(target
, ePoint(width(), height()));
360 target
->line( ePoint(clientrect
.left() + clientrect
.width()/8 + 1, clientrect
.top()),ePoint(clientrect
.left() + clientrect
.width()/8 + 1,clientrect
.bottom()-1));
363 int eChannelInfo::eventHandler(const eWidgetEvent
&event
)
367 case eWidgetEvent::changedSize
:
372 int dx
=clientrect
.width()/8;
373 int dy
=clientrect
.height()/3;
374 ctime
.move( ePoint(0,0) );
375 ctime
.resize( eSize(dx
, 36 ));
377 cname
.move( ePoint( dx
+ 4, 0 ) );
379 cdescr
.move( ePoint(dx
+ 4, dy
) );
380 cdescr
.resize( eSize( clientrect
.width() - (dx
*2 + 4), dy
+dy
) );
382 copos
.move( ePoint( clientrect
.width() - (dx
+4), dy
+dy
) );
383 copos
.resize( eSize(dx
+ 4, dy
) );
385 cdolby
.resize( eSize(25,15) );
386 cstereo
.resize( eSize(25,15) );
387 cformat
.resize( eSize(25,15) );
388 cscrambled
.resize( eSize(25,15) );
396 return eDecoWidget::eventHandler(event
);
399 static eWidget
*create_eChannelInfo(eWidget
*parent
)
401 return new eChannelInfo(parent
);
404 class eChannelInfoSkinInit
407 eChannelInfoSkinInit()
409 eSkin::addWidgetCreator("eChannelInfo", create_eChannelInfo
);
411 ~eChannelInfoSkinInit()
413 eSkin::removeWidgetCreator("eChannelInfo", create_eChannelInfo
);
417 eAutoInitP0
<eChannelInfoSkinInit
> init_eChannelInfoSkinInit(eAutoInitNumbers::guiobject
, "eChannelInfo");