Enigma2 plugin to to play various online streams (mostly Latvian).

InfoBarGenerics.py 173KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123
  1. # -*- coding: utf-8 -*-
  2. from Components.ActionMap import ActionMap, HelpableActionMap, NumberActionMap
  3. from Components.Harddisk import harddiskmanager, findMountPoint
  4. from Components.Input import Input
  5. from Components.Label import Label
  6. from Components.MovieList import AUDIO_EXTENSIONS, MOVIE_EXTENSIONS, DVD_EXTENSIONS
  7. from Components.PluginComponent import plugins
  8. from Components.ServiceEventTracker import ServiceEventTracker
  9. from Components.Sources.Boolean import Boolean
  10. from Components.Sources.List import List
  11. from Components.config import config, configfile, ConfigBoolean, ConfigClock
  12. from Components.SystemInfo import SystemInfo
  13. from Components.UsageConfig import preferredInstantRecordPath, defaultMoviePath, preferredTimerPath, ConfigSelection
  14. from Components.VolumeControl import VolumeControl
  15. from Components.Pixmap import MovingPixmap, MultiPixmap
  16. from Components.Sources.StaticText import StaticText
  17. from Components.ScrollLabel import ScrollLabel
  18. from Plugins.Plugin import PluginDescriptor
  19. from Components.Timeshift import InfoBarTimeshift
  20. from Screens.Screen import Screen
  21. from Screens import ScreenSaver
  22. from Screens.ChannelSelection import ChannelSelection, PiPZapSelection, BouquetSelector, SilentBouquetSelector, EpgBouquetSelector, service_types_tv
  23. from Screens.ChoiceBox import ChoiceBox
  24. from Screens.Dish import Dish
  25. from Screens.EventView import EventViewEPGSelect, EventViewSimple
  26. from Screens.EpgSelection import EPGSelection
  27. from Screens.InputBox import InputBox
  28. from Screens.MessageBox import MessageBox
  29. from Screens.MinuteInput import MinuteInput
  30. from Screens.TimerSelection import TimerSelection
  31. from Screens.PictureInPicture import PictureInPicture
  32. from Screens.PVRState import PVRState, TimeshiftState
  33. from Screens.SubtitleDisplay import SubtitleDisplay
  34. from Screens.RdsDisplay import RdsInfoDisplay, RassInteractive
  35. from Screens.Standby import Standby, TryQuitMainloop
  36. from Screens.TimeDateInput import TimeDateInput
  37. from Screens.TimerEdit import TimerEditList
  38. from Screens.UnhandledKey import UnhandledKey
  39. from ServiceReference import ServiceReference, isPlayableForCur
  40. from RecordTimer import RecordTimer, RecordTimerEntry, parseEvent, AFTEREVENT, findSafeRecordPath
  41. from Screens.TimerEntry import TimerEntry as TimerEntry
  42. from Tools import Directories, Notifications
  43. from Tools.Directories import pathExists, fileExists, getRecordingFilename, copyfile, moveFiles, resolveFilename, SCOPE_TIMESHIFT, SCOPE_CURRENT_SKIN
  44. from Tools.KeyBindings import getKeyDescription
  45. from enigma import eTimer, eServiceCenter, eDVBServicePMTHandler, iServiceInformation, iPlayableService, eServiceReference, eEPGCache, eActionMap, eDVBVolumecontrol, getDesktop, quitMainloop
  46. from boxbranding import getBoxType, getMachineProcModel, getMachineBuild, getMachineBrand, getMachineName
  47. from time import time, localtime, strftime
  48. from bisect import insort
  49. from sys import maxint
  50. from keyids import KEYIDS
  51. from datetime import datetime
  52. import os, cPickle
  53. # hack alert!
  54. from Screens.Menu import MainMenu, Menu, mdom
  55. from Screens.Setup import Setup
  56. import Screens.Standby
  57. AUDIO = False
  58. seek_withjumps_muted = False
  59. jump_pts_adder = 0
  60. jump_last_pts = None
  61. jump_last_pos = None
  62. if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/CoolTVGuide/plugin.pyo"):
  63. COOLTVGUIDE = True
  64. else:
  65. COOLTVGUIDE = False
  66. def isStandardInfoBar(self):
  67. return self.__class__.__name__ == "InfoBar"
  68. def isMoviePlayerInfoBar(self):
  69. return self.__class__.__name__ == "MoviePlayer"
  70. def setResumePoint(session):
  71. global resumePointCache, resumePointCacheLast
  72. service = session.nav.getCurrentService()
  73. ref = session.nav.getCurrentlyPlayingServiceOrGroup()
  74. if (service is not None) and (ref is not None): # and (ref.type != 1):
  75. # ref type 1 has its own memory...
  76. seek = service.seek()
  77. if seek:
  78. pos = seek.getPlayPosition()
  79. if not pos[0]:
  80. key = ref.toString()
  81. lru = int(time())
  82. l = seek.getLength()
  83. if l:
  84. l = l[1]
  85. else:
  86. l = None
  87. resumePointCache[key] = [lru, pos[1], l]
  88. for k, v in resumePointCache.items():
  89. if v[0] < lru:
  90. candidate = k
  91. filepath = os.path.realpath(candidate.split(':')[-1])
  92. mountpoint = findMountPoint(filepath)
  93. if os.path.ismount(mountpoint) and not os.path.exists(filepath):
  94. del resumePointCache[candidate]
  95. saveResumePoints()
  96. def delResumePoint(ref):
  97. global resumePointCache, resumePointCacheLast
  98. try:
  99. del resumePointCache[ref.toString()]
  100. except KeyError:
  101. pass
  102. saveResumePoints()
  103. def getResumePoint(session):
  104. global resumePointCache
  105. ref = session.nav.getCurrentlyPlayingServiceOrGroup()
  106. if (ref is not None) and (ref.type != 1):
  107. try:
  108. entry = resumePointCache[ref.toString()]
  109. entry[0] = int(time()) # update LRU timestamp
  110. return entry[1]
  111. except KeyError:
  112. return None
  113. def saveResumePoints():
  114. global resumePointCache, resumePointCacheLast
  115. try:
  116. f = open('/etc/enigma2/resumepoints.pkl', 'wb')
  117. cPickle.dump(resumePointCache, f, cPickle.HIGHEST_PROTOCOL)
  118. f.close()
  119. except Exception, ex:
  120. print "[InfoBar] Failed to write resumepoints:", ex
  121. resumePointCacheLast = int(time())
  122. def loadResumePoints():
  123. try:
  124. file = open('/etc/enigma2/resumepoints.pkl', 'rb')
  125. PickleFile = cPickle.load(file)
  126. file.close()
  127. return PickleFile
  128. except Exception, ex:
  129. print "[InfoBar] Failed to load resumepoints:", ex
  130. return {}
  131. def updateresumePointCache():
  132. global resumePointCache
  133. resumePointCache = loadResumePoints()
  134. def ToggleVideo():
  135. mode = open("/proc/stb/video/policy").read()[:-1]
  136. print mode
  137. if mode == "letterbox":
  138. f = open("/proc/stb/video/policy", "w")
  139. f.write("panscan")
  140. f.close()
  141. elif mode == "panscan":
  142. f = open("/proc/stb/video/policy", "w")
  143. f.write("letterbox")
  144. f.close()
  145. else:
  146. # if current policy is not panscan or letterbox, set to panscan
  147. f = open("/proc/stb/video/policy", "w")
  148. f.write("panscan")
  149. f.close()
  150. resumePointCache = loadResumePoints()
  151. resumePointCacheLast = int(time())
  152. class InfoBarDish:
  153. def __init__(self):
  154. self.dishDialog = self.session.instantiateDialog(Dish)
  155. self.dishDialog.setAnimationMode(0)
  156. class InfoBarLongKeyDetection:
  157. def __init__(self):
  158. eActionMap.getInstance().bindAction('', -maxint -1, self.detection) #highest prio
  159. self.LongButtonPressed = False
  160. #this function is called on every keypress!
  161. def detection(self, key, flag):
  162. if flag == 3:
  163. self.LongButtonPressed = True
  164. elif flag == 0:
  165. self.LongButtonPressed = False
  166. class InfoBarUnhandledKey:
  167. def __init__(self):
  168. self.unhandledKeyDialog = self.session.instantiateDialog(UnhandledKey)
  169. self.unhandledKeyDialog.setAnimationMode(0)
  170. self.hideUnhandledKeySymbolTimer = eTimer()
  171. self.hideUnhandledKeySymbolTimer.callback.append(self.unhandledKeyDialog.hide)
  172. self.checkUnusedTimer = eTimer()
  173. self.checkUnusedTimer.callback.append(self.checkUnused)
  174. self.onLayoutFinish.append(self.unhandledKeyDialog.hide)
  175. eActionMap.getInstance().bindAction('', -maxint -1, self.actionA) #highest prio
  176. eActionMap.getInstance().bindAction('', maxint, self.actionB) #lowest prio
  177. self.flags = (1<<1)
  178. self.uflags = 0
  179. #this function is called on every keypress!
  180. def actionA(self, key, flag):
  181. try:
  182. print 'KEY: %s %s %s %s' % (key,flag,(key_name for key_name,value in KEYIDS.items() if value==key).next(),getKeyDescription(key)[0])
  183. except:
  184. try:
  185. print 'KEY: %s %s %s' % (key,flag,(key_name for key_name,value in KEYIDS.items() if value==key).next()) # inverse dictionary lookup in KEYIDS
  186. except:
  187. print 'KEY: %s %s' % (key,flag)
  188. self.unhandledKeyDialog.hide()
  189. if self.closeSIB(key) and self.secondInfoBarScreen and self.secondInfoBarScreen.shown:
  190. self.secondInfoBarScreen.hide()
  191. self.secondInfoBarWasShown = False
  192. if flag != 4:
  193. if self.flags & (1<<1):
  194. self.flags = self.uflags = 0
  195. self.flags |= (1<<flag)
  196. if flag == 1: # break
  197. self.checkUnusedTimer.start(0, True)
  198. return 0
  199. def closeSIB(self, key):
  200. if key >= 12 and key not in (114, 115, 352, 103, 108, 402, 403, 407, 412, 352, 358):
  201. return True
  202. else:
  203. return False
  204. #this function is only called when no other action has handled this key
  205. def actionB(self, key, flag):
  206. if flag != 4:
  207. self.uflags |= (1<<flag)
  208. def checkUnused(self):
  209. if self.flags == self.uflags:
  210. self.unhandledKeyDialog.show()
  211. self.hideUnhandledKeySymbolTimer.start(2000, True)
  212. class InfoBarScreenSaver:
  213. def __init__(self):
  214. self.onExecBegin.append(self.__onExecBegin)
  215. self.onExecEnd.append(self.__onExecEnd)
  216. self.screenSaverTimer = eTimer()
  217. self.screenSaverTimer.callback.append(self.screensaverTimeout)
  218. self.screensaver = self.session.instantiateDialog(ScreenSaver.Screensaver)
  219. self.onLayoutFinish.append(self.__layoutFinished)
  220. def __layoutFinished(self):
  221. self.screensaver.hide()
  222. def __onExecBegin(self):
  223. self.ScreenSaverTimerStart()
  224. def __onExecEnd(self):
  225. if self.screensaver.shown:
  226. self.screensaver.hide()
  227. eActionMap.getInstance().unbindAction('', self.keypressScreenSaver)
  228. self.screenSaverTimer.stop()
  229. def ScreenSaverTimerStart(self):
  230. time = int(config.usage.screen_saver.value)
  231. flag = self.seekstate[0]
  232. if not flag:
  233. ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  234. if ref and not (hasattr(self.session, "pipshown") and self.session.pipshown):
  235. ref = ref.toString().split(":")
  236. flag = ref[2] == "2" or os.path.splitext(ref[10])[1].lower() in AUDIO_EXTENSIONS
  237. if time and flag:
  238. self.screenSaverTimer.startLongTimer(time)
  239. else:
  240. self.screenSaverTimer.stop()
  241. def screensaverTimeout(self):
  242. if self.execing and not Screens.Standby.inStandby and not Screens.Standby.inTryQuitMainloop:
  243. self.hide()
  244. if hasattr(self, "pvrStateDialog"):
  245. try:
  246. self.pvrStateDialog.hide()
  247. except:
  248. pass
  249. self.screensaver.show()
  250. eActionMap.getInstance().bindAction('', -maxint - 1, self.keypressScreenSaver)
  251. def keypressScreenSaver(self, key, flag):
  252. if flag:
  253. self.screensaver.hide()
  254. self.show()
  255. self.ScreenSaverTimerStart()
  256. eActionMap.getInstance().unbindAction('', self.keypressScreenSaver)
  257. class SecondInfoBar(Screen):
  258. ADD_TIMER = 0
  259. REMOVE_TIMER = 1
  260. def __init__(self, session):
  261. Screen.__init__(self, session)
  262. if config.usage.show_second_infobar.value == "3":
  263. self.skinName = "SecondInfoBarECM"
  264. else:
  265. self.skinName = "SecondInfoBar"
  266. self["epg_description"] = ScrollLabel()
  267. self["FullDescription"] = ScrollLabel()
  268. self["channel"] = Label()
  269. self["key_red"] = Label()
  270. self["key_green"] = Label()
  271. self["key_yellow"] = Label()
  272. self["key_blue"] = Label()
  273. self["SecondInfoBar"] = ActionMap(["2ndInfobarActions"],
  274. {
  275. "pageUp": self.pageUp,
  276. "pageDown": self.pageDown,
  277. "prevPage": self.pageUp,
  278. "nextPage": self.pageDown,
  279. "prevEvent": self.prevEvent,
  280. "nextEvent": self.nextEvent,
  281. "timerAdd": self.timerAdd,
  282. "openSimilarList": self.openSimilarList,
  283. }, -1)
  284. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  285. {
  286. iPlayableService.evUpdatedEventInfo: self.getEvent
  287. })
  288. self.onShow.append(self.__Show)
  289. self.onHide.append(self.__Hide)
  290. def pageUp(self):
  291. self["epg_description"].pageUp()
  292. self["FullDescription"].pageUp()
  293. def pageDown(self):
  294. self["epg_description"].pageDown()
  295. self["FullDescription"].pageDown()
  296. def __Show(self):
  297. if config.plisettings.ColouredButtons.value:
  298. self["key_yellow"].setText(_("Search"))
  299. self["key_red"].setText(_("Similar"))
  300. self["key_blue"].setText(_("Extensions"))
  301. self["SecondInfoBar"].doBind()
  302. self.getEvent()
  303. def __Hide(self):
  304. if self["SecondInfoBar"].bound:
  305. self["SecondInfoBar"].doUnbind()
  306. def getEvent(self):
  307. self["epg_description"].setText("")
  308. self["FullDescription"].setText("")
  309. self["channel"].setText("")
  310. ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  311. self.getNowNext()
  312. epglist = self.epglist
  313. if not epglist:
  314. self.is_now_next = False
  315. epg = eEPGCache.getInstance()
  316. ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1)
  317. if ptr:
  318. epglist.append(ptr)
  319. ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1)
  320. if ptr:
  321. epglist.append(ptr)
  322. else:
  323. self.is_now_next = True
  324. if epglist:
  325. Event = self.epglist[0]
  326. Ref = ServiceReference(ref)
  327. callback = self.eventViewCallback
  328. self.cbFunc = callback
  329. self.currentService = Ref
  330. self.isRecording = (not Ref.ref.flags & eServiceReference.isGroup) and Ref.ref.getPath()
  331. self.event = Event
  332. self.key_green_choice = self.ADD_TIMER
  333. if self.isRecording:
  334. self["key_green"].setText("")
  335. else:
  336. self["key_green"].setText(_("Add timer"))
  337. self.setEvent(self.event)
  338. def getNowNext(self):
  339. epglist = [ ]
  340. service = self.session.nav.getCurrentService()
  341. info = service and service.info()
  342. ptr = info and info.getEvent(0)
  343. if ptr:
  344. epglist.append(ptr)
  345. ptr = info and info.getEvent(1)
  346. if ptr:
  347. epglist.append(ptr)
  348. self.epglist = epglist
  349. def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
  350. epglist = self.epglist
  351. if len(epglist) > 1:
  352. tmp = epglist[0]
  353. epglist[0] = epglist[1]
  354. epglist[1] = tmp
  355. setEvent(epglist[0])
  356. def prevEvent(self):
  357. if self.cbFunc is not None:
  358. self.cbFunc(self.setEvent, self.setService, -1)
  359. def nextEvent(self):
  360. if self.cbFunc is not None:
  361. self.cbFunc(self.setEvent, self.setService, +1)
  362. def removeTimer(self, timer):
  363. timer.afterEvent = AFTEREVENT.NONE
  364. self.session.nav.RecordTimer.removeEntry(timer)
  365. self["key_green"].setText(_("Add timer"))
  366. self.key_green_choice = self.ADD_TIMER
  367. def timerAdd(self):
  368. self.hide()
  369. self.secondInfoBarWasShown = False
  370. if self.isRecording:
  371. return
  372. event = self.event
  373. serviceref = self.currentService
  374. if event is None:
  375. return
  376. eventid = event.getEventId()
  377. refstr = serviceref.ref.toString()
  378. for timer in self.session.nav.RecordTimer.timer_list:
  379. if timer.eit == eventid and timer.service_ref.ref.toString() == refstr:
  380. cb_func = lambda ret : not ret or self.removeTimer(timer)
  381. self.session.openWithCallback(cb_func, MessageBox, _("Do you really want to delete %s?") % event.getEventName())
  382. break
  383. else:
  384. newEntry = RecordTimerEntry(self.currentService, checkOldTimers = True, dirname = preferredTimerPath(), *parseEvent(self.event))
  385. self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
  386. def finishedAdd(self, answer):
  387. # print "finished add"
  388. if answer[0]:
  389. entry = answer[1]
  390. simulTimerList = self.session.nav.RecordTimer.record(entry)
  391. if simulTimerList is not None:
  392. for x in simulTimerList:
  393. if x.setAutoincreaseEnd(entry):
  394. self.session.nav.RecordTimer.timeChanged(x)
  395. simulTimerList = self.session.nav.RecordTimer.record(entry)
  396. if simulTimerList is not None:
  397. if not entry.repeated and not config.recording.margin_before.value and not config.recording.margin_after.value and len(simulTimerList) > 1:
  398. change_time = False
  399. conflict_begin = simulTimerList[1].begin
  400. conflict_end = simulTimerList[1].end
  401. if conflict_begin == entry.end:
  402. entry.end -= 30
  403. change_time = True
  404. elif entry.begin == conflict_end:
  405. entry.begin += 30
  406. change_time = True
  407. if change_time:
  408. simulTimerList = self.session.nav.RecordTimer.record(entry)
  409. if simulTimerList is not None:
  410. self.session.openWithCallback(self.finishSanityCorrection, TimerSanityConflict, simulTimerList)
  411. self["key_green"].setText(_("Remove timer"))
  412. self.key_green_choice = self.REMOVE_TIMER
  413. else:
  414. self["key_green"].setText(_("Add timer"))
  415. self.key_green_choice = self.ADD_TIMER
  416. # print "Timeredit aborted"
  417. def finishSanityCorrection(self, answer):
  418. self.finishedAdd(answer)
  419. def setService(self, service):
  420. self.currentService=service
  421. if self.isRecording:
  422. self["channel"].setText(_("Recording"))
  423. else:
  424. name = self.currentService.getServiceName()
  425. if name is not None:
  426. self["channel"].setText(name)
  427. else:
  428. self["channel"].setText(_("unknown service"))
  429. def sort_func(self,x,y):
  430. if x[1] < y[1]:
  431. return -1
  432. elif x[1] == y[1]:
  433. return 0
  434. else:
  435. return 1
  436. def setEvent(self, event):
  437. if event is None:
  438. return
  439. self.event = event
  440. try:
  441. name = event.getEventName()
  442. self["channel"].setText(name)
  443. except:
  444. pass
  445. description = event.getShortDescription()
  446. extended = event.getExtendedDescription()
  447. if description and extended:
  448. description += '\n'
  449. text = description + extended
  450. self.setTitle(event.getEventName())
  451. self["epg_description"].setText(text)
  452. serviceref = self.currentService
  453. eventid = self.event.getEventId()
  454. refstr = serviceref.ref.toString()
  455. isRecordEvent = False
  456. for timer in self.session.nav.RecordTimer.timer_list:
  457. if timer.eit == eventid and timer.service_ref.ref.toString() == refstr:
  458. isRecordEvent = True
  459. break
  460. if isRecordEvent and self.key_green_choice != self.REMOVE_TIMER:
  461. self["key_green"].setText(_("Remove timer"))
  462. self.key_green_choice = self.REMOVE_TIMER
  463. elif not isRecordEvent and self.key_green_choice != self.ADD_TIMER:
  464. self["key_green"].setText(_("Add timer"))
  465. self.key_green_choice = self.ADD_TIMER
  466. def openSimilarList(self):
  467. id = self.event and self.event.getEventId()
  468. refstr = str(self.currentService)
  469. if id is not None:
  470. self.hide()
  471. self.secondInfoBarWasShown = False
  472. self.session.open(EPGSelection, refstr, None, id)
  473. class InfoBarShowHide(InfoBarScreenSaver):
  474. """ InfoBar show/hide control, accepts toggleShow and hide actions, might start
  475. fancy animations. """
  476. STATE_HIDDEN = 0
  477. STATE_HIDING = 1
  478. STATE_SHOWING = 2
  479. STATE_SHOWN = 3
  480. def __init__(self):
  481. self["ShowHideActions"] = ActionMap( ["InfobarShowHideActions"] ,
  482. {
  483. "LongOKPressed": self.toggleShowLong,
  484. "toggleShow": self.OkPressed,
  485. "hide": self.keyHide,
  486. }, 1) # lower prio to make it possible to override ok and cancel..
  487. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  488. {
  489. iPlayableService.evStart: self.serviceStarted,
  490. })
  491. InfoBarScreenSaver.__init__(self)
  492. self.__state = self.STATE_SHOWN
  493. self.__locked = 0
  494. self.hideTimer = eTimer()
  495. self.hideTimer.callback.append(self.doTimerHide)
  496. self.hideTimer.start(5000, True)
  497. self.onShow.append(self.__onShow)
  498. self.onHide.append(self.__onHide)
  499. self.onShowHideNotifiers = []
  500. self.standardInfoBar = False
  501. self.lastSecondInfoBar = 0
  502. self.lastResetAlpha = True
  503. self.secondInfoBarScreen = ""
  504. if isStandardInfoBar(self):
  505. self.SwitchSecondInfoBarScreen()
  506. self.onLayoutFinish.append(self.__layoutFinished)
  507. def __layoutFinished(self):
  508. if self.secondInfoBarScreen:
  509. self.secondInfoBarScreen.hide()
  510. self.standardInfoBar = True
  511. self.secondInfoBarWasShown = False
  512. self.EventViewIsShown = False
  513. try:
  514. if self.pvrStateDialog:
  515. pass
  516. except:
  517. self.pvrStateDialog = None
  518. def OkPressed(self):
  519. if config.usage.okbutton_mode.value == "0":
  520. self.toggleShow()
  521. elif config.usage.okbutton_mode.value == "1":
  522. try:
  523. self.openServiceList()
  524. except:
  525. self.toggleShow()
  526. elif config.usage.okbutton_mode.value == "2" and COOLTVGUIDE:
  527. self.showCoolInfoGuide()
  528. elif config.usage.okbutton_mode.value == "3" and COOLTVGUIDE:
  529. self.showCoolSingleGuide()
  530. elif config.usage.okbutton_mode.value == "4" and COOLTVGUIDE:
  531. if self.isInfo:
  532. self.showCoolTVGuide()
  533. elif config.usage.okbutton_mode.value == "5" and COOLTVGUIDE:
  534. self.showCoolEasyGuide()
  535. elif config.usage.okbutton_mode.value == "6" and COOLTVGUIDE:
  536. self.showCoolChannelGuide()
  537. def SwitchSecondInfoBarScreen(self):
  538. if self.lastSecondInfoBar == int(config.usage.show_second_infobar.value):
  539. return
  540. self.secondInfoBarScreen = self.session.instantiateDialog(SecondInfoBar)
  541. self.lastSecondInfoBar = int(config.usage.show_second_infobar.value)
  542. def LongOKPressed(self):
  543. if isinstance(self, InfoBarEPG):
  544. if config.plisettings.InfoBarEpg_mode.value == "1":
  545. self.openInfoBarEPG()
  546. def __onShow(self):
  547. self.__state = self.STATE_SHOWN
  548. for x in self.onShowHideNotifiers:
  549. x(True)
  550. self.startHideTimer()
  551. def doDimming(self):
  552. if config.usage.show_infobar_do_dimming.value:
  553. self.dimmed = self.dimmed-1
  554. else:
  555. self.dimmed = 0
  556. self.DimmingTimer.stop()
  557. self.doHide()
  558. def unDimming(self):
  559. self.unDimmingTimer.stop()
  560. self.doWriteAlpha(config.av.osd_alpha.value)
  561. def doWriteAlpha(self, value):
  562. if fileExists("/proc/stb/video/alpha"):
  563. f=open("/proc/stb/video/alpha","w")
  564. f.write("%i" % (value))
  565. f.close()
  566. if value == config.av.osd_alpha.value:
  567. self.lastResetAlpha = True
  568. else:
  569. self.lastResetAlpha = False
  570. def __onHide(self):
  571. self.__state = self.STATE_HIDDEN
  572. self.resetAlpha()
  573. for x in self.onShowHideNotifiers:
  574. x(False)
  575. def resetAlpha(self):
  576. if config.usage.show_infobar_do_dimming.value and self.lastResetAlpha is False:
  577. self.unDimmingTimer = eTimer()
  578. self.unDimmingTimer.callback.append(self.unDimming)
  579. self.unDimmingTimer.start(300, True)
  580. def keyHide(self):
  581. if self.__state == self.STATE_HIDDEN:
  582. ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  583. if ref:
  584. ref = ref.toString()
  585. else:
  586. ref = " "
  587. if config.plisettings.InfoBarEpg_mode.value == "2" and not ref[1:].startswith(":0:0:0:0:0:0:0:0:0:"):
  588. self.openInfoBarEPG()
  589. else:
  590. self.hide()
  591. if self.secondInfoBarScreen and self.secondInfoBarScreen.shown:
  592. self.secondInfoBarScreen.hide()
  593. self.secondInfoBarWasShown = False
  594. if self.session.pipshown and "popup" in config.usage.pip_hideOnExit.value:
  595. if config.usage.pip_hideOnExit.value == "popup":
  596. self.session.openWithCallback(self.hidePipOnExitCallback, MessageBox, _("Disable Picture in Picture"), simple=True)
  597. else:
  598. self.hidePipOnExitCallback(True)
  599. else:
  600. self.hide()
  601. if hasattr(self, "pvrStateDialog"):
  602. self.pvrStateDialog.hide()
  603. def hidePipOnExitCallback(self, answer):
  604. if answer:
  605. self.showPiP()
  606. def connectShowHideNotifier(self, fnc):
  607. if not fnc in self.onShowHideNotifiers:
  608. self.onShowHideNotifiers.append(fnc)
  609. def disconnectShowHideNotifier(self, fnc):
  610. if fnc in self.onShowHideNotifiers:
  611. self.onShowHideNotifiers.remove(fnc)
  612. def serviceStarted(self):
  613. if self.execing:
  614. if config.usage.show_infobar_on_zap.value:
  615. self.doShow()
  616. def startHideTimer(self):
  617. if self.__state == self.STATE_SHOWN and not self.__locked:
  618. self.hideTimer.stop()
  619. idx = config.usage.infobar_timeout.index
  620. if idx:
  621. self.hideTimer.start(idx*1000, True)
  622. elif (self.secondInfoBarScreen and self.secondInfoBarScreen.shown) or ((not config.usage.show_second_infobar.value or isMoviePlayerInfoBar(self)) and self.EventViewIsShown):
  623. self.hideTimer.stop()
  624. idx = config.usage.second_infobar_timeout.index
  625. if idx:
  626. self.hideTimer.start(idx*1000, True)
  627. elif hasattr(self, "pvrStateDialog"):
  628. self.hideTimer.stop()
  629. idx = config.usage.infobar_timeout.index
  630. if idx:
  631. self.hideTimer.start(idx*1000, True)
  632. def doShow(self):
  633. self.show()
  634. self.startHideTimer()
  635. def doTimerHide(self):
  636. self.hideTimer.stop()
  637. self.DimmingTimer = eTimer()
  638. self.DimmingTimer.callback.append(self.doDimming)
  639. self.DimmingTimer.start(300, True)
  640. self.dimmed = config.usage.show_infobar_dimming_speed.value
  641. def doHide(self):
  642. if self.__state != self.STATE_HIDDEN:
  643. if self.dimmed > 0:
  644. self.doWriteAlpha((config.av.osd_alpha.value*self.dimmed/config.usage.show_infobar_dimming_speed.value))
  645. self.DimmingTimer.start(5, True)
  646. else:
  647. self.DimmingTimer.stop()
  648. self.hide()
  649. elif self.__state == self.STATE_HIDDEN and self.secondInfoBarScreen and self.secondInfoBarScreen.shown:
  650. if self.dimmed > 0:
  651. self.doWriteAlpha((config.av.osd_alpha.value*self.dimmed/config.usage.show_infobar_dimming_speed.value))
  652. self.DimmingTimer.start(5, True)
  653. else:
  654. self.DimmingTimer.stop()
  655. self.secondInfoBarScreen.hide()
  656. self.secondInfoBarWasShown = False
  657. self.resetAlpha()
  658. elif self.__state == self.STATE_HIDDEN and self.EventViewIsShown:
  659. try:
  660. self.eventView.close()
  661. except:
  662. pass
  663. self.EventViewIsShown = False
  664. # elif hasattr(self, "pvrStateDialog"):
  665. # if self.dimmed > 0:
  666. # self.doWriteAlpha((config.av.osd_alpha.value*self.dimmed/config.usage.show_infobar_dimming_speed.value))
  667. # self.DimmingTimer.start(5, True)
  668. # else:
  669. # self.DimmingTimer.stop()
  670. # try:
  671. # self.pvrStateDialog.hide()
  672. # except:
  673. # pass
  674. def toggleShow(self):
  675. if not hasattr(self, "LongButtonPressed"):
  676. self.LongButtonPressed = False
  677. if not self.LongButtonPressed:
  678. if self.__state == self.STATE_HIDDEN:
  679. if not self.secondInfoBarWasShown or (config.usage.show_second_infobar.value == "1" and not self.EventViewIsShown):
  680. self.show()
  681. if self.secondInfoBarScreen:
  682. self.secondInfoBarScreen.hide()
  683. self.secondInfoBarWasShown = False
  684. self.EventViewIsShown = False
  685. elif self.secondInfoBarScreen and (config.usage.show_second_infobar.value == "2" or config.usage.show_second_infobar.value == "3") and not self.secondInfoBarScreen.shown:
  686. self.SwitchSecondInfoBarScreen()
  687. self.hide()
  688. self.secondInfoBarScreen.show()
  689. self.secondInfoBarWasShown = True
  690. self.startHideTimer()
  691. elif (config.usage.show_second_infobar.value == "1" or isMoviePlayerInfoBar(self)) and not self.EventViewIsShown:
  692. self.hide()
  693. try:
  694. self.openEventView()
  695. except:
  696. pass
  697. self.EventViewIsShown = True
  698. self.hideTimer.stop()
  699. elif isMoviePlayerInfoBar(self) and not self.EventViewIsShown and config.usage.show_second_infobar.value:
  700. self.hide()
  701. self.openEventView(True)
  702. self.EventViewIsShown = True
  703. self.startHideTimer()
  704. else:
  705. self.hide()
  706. if self.secondInfoBarScreen and self.secondInfoBarScreen.shown:
  707. self.secondInfoBarScreen.hide()
  708. elif self.EventViewIsShown:
  709. try:
  710. self.eventView.close()
  711. except:
  712. pass
  713. self.EventViewIsShown = False
  714. def toggleShowLong(self):
  715. try:
  716. if self.LongButtonPressed:
  717. if isinstance(self, InfoBarEPG):
  718. if config.plisettings.InfoBarEpg_mode.value == "1":
  719. self.openInfoBarEPG()
  720. except Exception, e:
  721. print "[InfoBarGenerics] 'toggleShowLong' failed:", e
  722. def lockShow(self):
  723. try:
  724. self.__locked += 1
  725. except:
  726. self.__locked = 0
  727. if self.execing:
  728. self.show()
  729. self.hideTimer.stop()
  730. def unlockShow(self):
  731. if config.usage.show_infobar_do_dimming.value and self.lastResetAlpha is False:
  732. self.doWriteAlpha(config.av.osd_alpha.value)
  733. try:
  734. self.__locked -= 1
  735. except:
  736. self.__locked = 0
  737. if self.__locked <0:
  738. self.__locked = 0
  739. if self.execing:
  740. self.startHideTimer()
  741. def openEventView(self, simple=False):
  742. try:
  743. if self.servicelist is None:
  744. return
  745. except:
  746. simple = True
  747. ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  748. self.getNowNext()
  749. epglist = self.epglist
  750. if not epglist:
  751. self.is_now_next = False
  752. epg = eEPGCache.getInstance()
  753. ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1)
  754. if ptr:
  755. epglist.append(ptr)
  756. ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1)
  757. if ptr:
  758. epglist.append(ptr)
  759. else:
  760. self.is_now_next = True
  761. if epglist:
  762. if not simple:
  763. self.eventView = self.session.openWithCallback(self.closed, EventViewEPGSelect, epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList)
  764. self.dlg_stack.append(self.eventView)
  765. else:
  766. self.eventView = self.session.openWithCallback(self.closed, EventViewSimple, epglist[0], ServiceReference(ref))
  767. self.dlg_stack = None
  768. def getNowNext(self):
  769. epglist = [ ]
  770. service = self.session.nav.getCurrentService()
  771. info = service and service.info()
  772. ptr = info and info.getEvent(0)
  773. if ptr:
  774. epglist.append(ptr)
  775. ptr = info and info.getEvent(1)
  776. if ptr:
  777. epglist.append(ptr)
  778. self.epglist = epglist
  779. def closed(self, ret=False):
  780. if not self.dlg_stack:
  781. return
  782. closedScreen = self.dlg_stack.pop()
  783. if self.eventView and closedScreen == self.eventView:
  784. self.eventView = None
  785. if ret == True or ret == 'close':
  786. dlgs=len(self.dlg_stack)
  787. if dlgs > 0:
  788. self.dlg_stack[dlgs-1].close(dlgs > 1)
  789. self.reopen(ret)
  790. def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
  791. epglist = self.epglist
  792. if len(epglist) > 1:
  793. tmp = epglist[0]
  794. epglist[0] = epglist[1]
  795. epglist[1] = tmp
  796. setEvent(epglist[0])
  797. def showCoolInfoGuide(self):
  798. if self.servicelist is None:
  799. return
  800. if COOLTVGUIDE:
  801. for plugin in plugins.getPlugins([PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
  802. if plugin.name == _("Cool Info Guide"):
  803. self.runPlugin(plugin)
  804. break
  805. else:
  806. self.session.open(MessageBox, _("The Cool TV Guide plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  807. def showCoolSingleGuide(self):
  808. if self.servicelist is None:
  809. return
  810. if COOLTVGUIDE:
  811. for plugin in plugins.getPlugins([PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
  812. if plugin.name == _("Cool Single Guide"):
  813. self.runPlugin(plugin)
  814. break
  815. else:
  816. self.session.open(MessageBox, _("The Cool TV Guide plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  817. def showCoolTVGuide(self):
  818. if self.servicelist is None:
  819. return
  820. if COOLTVGUIDE:
  821. for plugin in plugins.getPlugins([PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
  822. if plugin.name == _("Cool TV Guide"):
  823. self.runPlugin(plugin)
  824. break
  825. else:
  826. self.session.open(MessageBox, _("The Cool TV Guide plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  827. def showCoolEasyGuide(self):
  828. if self.servicelist is None:
  829. return
  830. if COOLTVGUIDE:
  831. for plugin in plugins.getPlugins([PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
  832. if plugin.name == _("Cool Easy Guide"):
  833. self.runPlugin(plugin)
  834. break
  835. else:
  836. self.session.open(MessageBox, _("The Cool TV Guide plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  837. def showCoolChannelGuide(self):
  838. if self.servicelist is None:
  839. return
  840. if COOLTVGUIDE:
  841. for plugin in plugins.getPlugins([PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
  842. if plugin.name == _("Cool Channel Guide"):
  843. self.runPlugin(plugin)
  844. break
  845. else:
  846. self.session.open(MessageBox, _("The Cool TV Guide plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  847. class BufferIndicator(Screen):
  848. def __init__(self, session):
  849. Screen.__init__(self, session)
  850. self["status"] = Label()
  851. self.mayShow = False
  852. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  853. {
  854. iPlayableService.evBuffering: self.bufferChanged,
  855. iPlayableService.evStart: self.__evStart,
  856. iPlayableService.evGstreamerPlayStarted: self.__evGstreamerPlayStarted,
  857. })
  858. def bufferChanged(self):
  859. if self.mayShow:
  860. service = self.session.nav.getCurrentService()
  861. info = service and service.info()
  862. if info:
  863. value = info.getInfo(iServiceInformation.sBuffer)
  864. if value and value != 100:
  865. self["status"].setText(_("Buffering %d%%") % value)
  866. if not self.shown:
  867. self.show()
  868. def __evStart(self):
  869. self.mayShow = True
  870. self.hide()
  871. def __evGstreamerPlayStarted(self):
  872. self.mayShow = False
  873. self.hide()
  874. class InfoBarBuffer():
  875. def __init__(self):
  876. self.bufferScreen = self.session.instantiateDialog(BufferIndicator)
  877. self.bufferScreen.hide()
  878. class NumberZap(Screen):
  879. def quit(self):
  880. self.Timer.stop()
  881. self.close()
  882. def keyOK(self):
  883. self.Timer.stop()
  884. self.close(self.service, self.bouquet)
  885. def handleServiceName(self):
  886. if self.searchNumber:
  887. self.service, self.bouquet = self.searchNumber(int(self["number"].getText()))
  888. self["servicename"].setText(ServiceReference(self.service).getServiceName())
  889. if not self.startBouquet:
  890. self.startBouquet = self.bouquet
  891. def keyBlue(self):
  892. self.Timer.start(3000, True)
  893. if self.searchNumber:
  894. if self.startBouquet == self.bouquet:
  895. self.service, self.bouquet = self.searchNumber(int(self["number"].getText()), firstBouquetOnly = True)
  896. else:
  897. self.service, self.bouquet = self.searchNumber(int(self["number"].getText()))
  898. self["servicename"].setText(ServiceReference(self.service).getServiceName())
  899. def keyNumberGlobal(self, number):
  900. if config.usage.numzaptimeoutmode.value is not "off":
  901. if config.usage.numzaptimeoutmode.value is "standard":
  902. self.Timer.start(1000, True)
  903. else:
  904. self.Timer.start(config.usage.numzaptimeout2.value, True)
  905. self.numberString += str(number)
  906. self["number"].setText(self.numberString)
  907. self["number_summary"].setText(self.numberString)
  908. self.field = self.numberString
  909. self.handleServiceName()
  910. self["service_summary"].setText(self["servicename"].getText())
  911. if len(self.numberString) >= int(config.usage.maxchannelnumlen.value):
  912. self.keyOK()
  913. def __init__(self, session, number, searchNumberFunction = None):
  914. Screen.__init__(self, session)
  915. self.onChangedEntry = [ ]
  916. self.numberString = str(number)
  917. self.field = str(number)
  918. self.searchNumber = searchNumberFunction
  919. self.startBouquet = None
  920. self["channel"] = Label(_("Channel:"))
  921. self["channel_summary"] = StaticText(_("Channel:"))
  922. self["number"] = Label(self.numberString)
  923. self["number_summary"] = StaticText(self.numberString)
  924. self["servicename"] = Label()
  925. self["service_summary"] = StaticText("")
  926. self.handleServiceName()
  927. self["service_summary"].setText(self["servicename"].getText())
  928. self["actions"] = NumberActionMap( [ "SetupActions", "ShortcutActions" ],
  929. {
  930. "cancel": self.quit,
  931. "ok": self.keyOK,
  932. "blue": self.keyBlue,
  933. "1": self.keyNumberGlobal,
  934. "2": self.keyNumberGlobal,
  935. "3": self.keyNumberGlobal,
  936. "4": self.keyNumberGlobal,
  937. "5": self.keyNumberGlobal,
  938. "6": self.keyNumberGlobal,
  939. "7": self.keyNumberGlobal,
  940. "8": self.keyNumberGlobal,
  941. "9": self.keyNumberGlobal,
  942. "0": self.keyNumberGlobal
  943. })
  944. self.Timer = eTimer()
  945. self.Timer.callback.append(self.keyOK)
  946. if config.usage.numzaptimeoutmode.value is not "off":
  947. if config.usage.numzaptimeoutmode.value is "standard":
  948. self.Timer.start(3000, True)
  949. else:
  950. self.Timer.start(config.usage.numzaptimeout1.value, True)
  951. class InfoBarNumberZap:
  952. """ Handles an initial number for NumberZapping """
  953. def __init__(self):
  954. self["NumberActions"] = NumberActionMap( [ "NumberActions"],
  955. {
  956. "1": self.keyNumberGlobal,
  957. "2": self.keyNumberGlobal,
  958. "3": self.keyNumberGlobal,
  959. "4": self.keyNumberGlobal,
  960. "5": self.keyNumberGlobal,
  961. "6": self.keyNumberGlobal,
  962. "7": self.keyNumberGlobal,
  963. "8": self.keyNumberGlobal,
  964. "9": self.keyNumberGlobal,
  965. "0": self.keyNumberGlobal,
  966. })
  967. def keyNumberGlobal(self, number):
  968. if self.pvrStateDialog.has_key("PTSSeekPointer") and self.timeshiftEnabled() and self.isSeekable():
  969. InfoBarTimeshiftState._mayShow(self)
  970. self.pvrStateDialog["PTSSeekPointer"].setPosition((self.pvrStateDialog["PTSSeekBack"].instance.size().width()-4)/2, self.pvrStateDialog["PTSSeekPointer"].position[1])
  971. if self.seekstate != self.SEEK_STATE_PLAY:
  972. self.setSeekState(self.SEEK_STATE_PLAY)
  973. self.ptsSeekPointerOK()
  974. return
  975. if self.pts_blockZap_timer.isActive():
  976. return
  977. # if self.save_current_timeshift and self.timeshiftEnabled():
  978. # InfoBarTimeshift.saveTimeshiftActions(self)
  979. # return
  980. if number == 0:
  981. if isinstance(self, InfoBarPiP) and self.pipHandles0Action():
  982. self.pipDoHandle0Action()
  983. elif len(self.servicelist.history) > 1 or config.usage.panicbutton.value:
  984. self.checkTimeshiftRunning(self.recallPrevService)
  985. else:
  986. if self.has_key("TimeshiftActions") and self.timeshiftEnabled():
  987. ts = self.getTimeshift()
  988. if ts and ts.isTimeshiftActive():
  989. return
  990. self.session.openWithCallback(self.numberEntered, NumberZap, number, self.searchNumber)
  991. def recallPrevService(self, reply):
  992. if reply:
  993. if config.usage.panicbutton.value:
  994. if self.session.pipshown:
  995. del self.session.pip
  996. self.session.pipshown = False
  997. self.servicelist.history_tv = []
  998. self.servicelist.history_radio = []
  999. self.servicelist.history = self.servicelist.history_tv
  1000. self.servicelist.history_pos = 0
  1001. self.servicelist2.history_tv = []
  1002. self.servicelist2.history_radio = []
  1003. self.servicelist2.history = self.servicelist.history_tv
  1004. self.servicelist2.history_pos = 0
  1005. if config.usage.multibouquet.value:
  1006. bqrootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
  1007. else:
  1008. self.service_types = service_types_tv
  1009. bqrootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'% self.service_types
  1010. serviceHandler = eServiceCenter.getInstance()
  1011. rootbouquet = eServiceReference(bqrootstr)
  1012. bouquet = eServiceReference(bqrootstr)
  1013. bouquetlist = serviceHandler.list(bouquet)
  1014. if not bouquetlist is None:
  1015. while True:
  1016. bouquet = bouquetlist.getNext()
  1017. if bouquet.flags & eServiceReference.isDirectory:
  1018. self.servicelist.clearPath()
  1019. self.servicelist.setRoot(bouquet)
  1020. servicelist = serviceHandler.list(bouquet)
  1021. if not servicelist is None:
  1022. serviceIterator = servicelist.getNext()
  1023. while serviceIterator.valid():
  1024. service, bouquet2 = self.searchNumber(config.usage.panicchannel.value)
  1025. if service == serviceIterator: break
  1026. serviceIterator = servicelist.getNext()
  1027. if serviceIterator.valid() and service == serviceIterator: break
  1028. self.servicelist.enterPath(rootbouquet)
  1029. self.servicelist.enterPath(bouquet)
  1030. self.servicelist.saveRoot()
  1031. self.servicelist2.enterPath(rootbouquet)
  1032. self.servicelist2.enterPath(bouquet)
  1033. self.servicelist2.saveRoot()
  1034. self.selectAndStartService(service, bouquet)
  1035. else:
  1036. self.servicelist.recallPrevService()
  1037. def numberEntered(self, service = None, bouquet = None):
  1038. if service:
  1039. self.selectAndStartService(service, bouquet)
  1040. def searchNumberHelper(self, serviceHandler, num, bouquet):
  1041. servicelist = serviceHandler.list(bouquet)
  1042. if servicelist:
  1043. serviceIterator = servicelist.getNext()
  1044. while serviceIterator.valid():
  1045. if num == serviceIterator.getChannelNum():
  1046. return serviceIterator
  1047. serviceIterator = servicelist.getNext()
  1048. return None
  1049. def searchNumber(self, number, firstBouquetOnly=False, bouquet=None):
  1050. bouquet = bouquet or self.servicelist.getRoot()
  1051. service = None
  1052. serviceHandler = eServiceCenter.getInstance()
  1053. if not firstBouquetOnly:
  1054. service = self.searchNumberHelper(serviceHandler, number, bouquet)
  1055. if config.usage.multibouquet.value and not service:
  1056. bouquet = self.servicelist.bouquet_root
  1057. bouquetlist = serviceHandler.list(bouquet)
  1058. if bouquetlist:
  1059. bouquet = bouquetlist.getNext()
  1060. while bouquet.valid():
  1061. if bouquet.flags & eServiceReference.isDirectory:
  1062. service = self.searchNumberHelper(serviceHandler, number, bouquet)
  1063. if service:
  1064. playable = not (service.flags & (eServiceReference.isMarker|eServiceReference.isDirectory)) or (service.flags & eServiceReference.isNumberedMarker)
  1065. if not playable:
  1066. service = None
  1067. break
  1068. if config.usage.alternative_number_mode.value or firstBouquetOnly:
  1069. break
  1070. bouquet = bouquetlist.getNext()
  1071. return service, bouquet
  1072. def selectAndStartService(self, service, bouquet):
  1073. if service:
  1074. if self.servicelist.getRoot() != bouquet: #already in correct bouquet?
  1075. self.servicelist.clearPath()
  1076. if self.servicelist.bouquet_root != bouquet:
  1077. self.servicelist.enterPath(self.servicelist.bouquet_root)
  1078. self.servicelist.enterPath(bouquet)
  1079. self.servicelist.setCurrentSelection(service) #select the service in servicelist
  1080. self.servicelist.zap(enable_pipzap = True)
  1081. self.servicelist.correctChannelNumber()
  1082. self.servicelist.startRoot = None
  1083. def zapToNumber(self, number):
  1084. service, bouquet = self.searchNumber(number)
  1085. self.selectAndStartService(service, bouquet)
  1086. config.misc.initialchannelselection = ConfigBoolean(default = True)
  1087. class InfoBarChannelSelection:
  1088. """ ChannelSelection - handles the channelSelection dialog and the initial
  1089. channelChange actions which open the channelSelection dialog """
  1090. def __init__(self):
  1091. #instantiate forever
  1092. self.servicelist = self.session.instantiateDialog(ChannelSelection)
  1093. self.servicelist2 = self.session.instantiateDialog(PiPZapSelection)
  1094. self.tscallback = None
  1095. if config.misc.initialchannelselection.value:
  1096. self.onShown.append(self.firstRun)
  1097. self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
  1098. {
  1099. "switchChannelUp": (self.UpPressed, _("Open service list and select previous channel")),
  1100. "switchChannelDown": (self.DownPressed, _("Open service list and select next channel")),
  1101. "switchChannelUpLong": (self.switchChannelUp, _("Open service list and select previous channel for PiP")),
  1102. "switchChannelDownLong": (self.switchChannelDown, _("Open service list and select next channel for PiP")),
  1103. "zapUp": (self.zapUp, _("Switch to previous channel")),
  1104. "zapDown": (self.zapDown, _("Switch next channel")),
  1105. "volumeUp": (self.volumeUp, _("change Volume up")),
  1106. "volumeDown": (self.volumeDown, _("change Volume down")),
  1107. "historyBack": (self.historyBack, _("Switch to previous channel in history")),
  1108. "historyNext": (self.historyNext, _("Switch to next channel in history")),
  1109. "openServiceList": (self.openServiceList, _("Open service list")),
  1110. "openSatellites": (self.openSatellites, _("Open satellites list")),
  1111. "openBouquets": (self.openBouquets, _("Open favourites list")),
  1112. "LeftPressed": self.LeftPressed,
  1113. "RightPressed": self.RightPressed,
  1114. "ChannelPlusPressed": self.ChannelPlusPressed,
  1115. "ChannelMinusPressed": self.ChannelMinusPressed,
  1116. "ChannelPlusPressedLong": self.ChannelPlusPressed,
  1117. "ChannelMinusPressedLong": self.ChannelMinusPressed,
  1118. })
  1119. def firstRun(self):
  1120. self.onShown.remove(self.firstRun)
  1121. config.misc.initialchannelselection.value = False
  1122. config.misc.initialchannelselection.save()
  1123. self.openServiceList()
  1124. def LeftPressed(self):
  1125. if config.plisettings.InfoBarEpg_mode.value == "3":
  1126. self.openInfoBarEPG()
  1127. else:
  1128. self.zapUp()
  1129. def RightPressed(self):
  1130. if config.plisettings.InfoBarEpg_mode.value == "3":
  1131. self.openInfoBarEPG()
  1132. else:
  1133. self.zapDown()
  1134. def UpPressed(self):
  1135. if config.usage.updownbutton_mode.value == "0":
  1136. self.zapDown()
  1137. elif config.usage.updownbutton_mode.value == "1":
  1138. self.switchChannelUp()
  1139. def DownPressed(self):
  1140. if config.usage.updownbutton_mode.value == "0":
  1141. self.zapUp()
  1142. elif config.usage.updownbutton_mode.value == "1":
  1143. self.switchChannelDown()
  1144. def ChannelPlusPressed(self):
  1145. if config.usage.channelbutton_mode.value == "0":
  1146. self.zapDown()
  1147. elif config.usage.channelbutton_mode.value == "1" or config.usage.channelbutton_mode.value == "3":
  1148. self.openServiceList()
  1149. elif config.usage.channelbutton_mode.value == "2":
  1150. self.serviceListType = "Norm"
  1151. self.servicelist.showFavourites()
  1152. self.session.execDialog(self.servicelist)
  1153. def ChannelMinusPressed(self):
  1154. if config.usage.channelbutton_mode.value == "0":
  1155. self.zapUp()
  1156. elif config.usage.channelbutton_mode.value == "1" or config.usage.channelbutton_mode.value == "3":
  1157. self.openServiceList()
  1158. elif config.usage.channelbutton_mode.value == "2":
  1159. self.serviceListType = "Norm"
  1160. self.servicelist.showFavourites()
  1161. self.session.execDialog(self.servicelist)
  1162. def showTvChannelList(self, zap=False):
  1163. self.servicelist.setModeTv()
  1164. if zap:
  1165. self.servicelist.zap()
  1166. if config.usage.show_servicelist.value:
  1167. self.session.execDialog(self.servicelist)
  1168. def showRadioChannelList(self, zap=False):
  1169. self.servicelist.setModeRadio()
  1170. if zap:
  1171. self.servicelist.zap()
  1172. if config.usage.show_servicelist.value:
  1173. self.session.execDialog(self.servicelist)
  1174. def historyBack(self):
  1175. if config.usage.historymode.value == "0":
  1176. self.servicelist.historyBack()
  1177. else:
  1178. self.servicelist.historyZap(-1)
  1179. def historyNext(self):
  1180. if config.usage.historymode.value == "0":
  1181. self.servicelist.historyNext()
  1182. else:
  1183. self.servicelist.historyZap(+1)
  1184. def switchChannelUp(self):
  1185. if not self.secondInfoBarScreen or not self.secondInfoBarScreen.shown:
  1186. self.keyHide()
  1187. if not self.LongButtonPressed or SystemInfo.get("NumVideoDecoders", 1) <= 1:
  1188. if not config.usage.show_bouquetalways.value:
  1189. if "keep" not in config.usage.servicelist_cursor_behavior.value:
  1190. self.servicelist.moveUp()
  1191. self.session.execDialog(self.servicelist)
  1192. else:
  1193. self.servicelist.showFavourites()
  1194. self.session.execDialog(self.servicelist)
  1195. elif self.LongButtonPressed:
  1196. if not config.usage.show_bouquetalways.value:
  1197. if "keep" not in config.usage.servicelist_cursor_behavior.value:
  1198. self.servicelist2.moveUp()
  1199. self.session.execDialog(self.servicelist2)
  1200. else:
  1201. self.servicelist2.showFavourites()
  1202. self.session.execDialog(self.servicelist2)
  1203. def switchChannelDown(self):
  1204. if not self.secondInfoBarScreen or not self.secondInfoBarScreen.shown:
  1205. self.keyHide()
  1206. if not self.LongButtonPressed or SystemInfo.get("NumVideoDecoders", 1) <= 1:
  1207. if not config.usage.show_bouquetalways.value:
  1208. if "keep" not in config.usage.servicelist_cursor_behavior.value:
  1209. self.servicelist.moveDown()
  1210. self.session.execDialog(self.servicelist)
  1211. else:
  1212. self.servicelist.showFavourites()
  1213. self.session.execDialog(self.servicelist)
  1214. elif self.LongButtonPressed:
  1215. if not config.usage.show_bouquetalways.value:
  1216. if "keep" not in config.usage.servicelist_cursor_behavior.value:
  1217. self.servicelist2.moveDown()
  1218. self.session.execDialog(self.servicelist2)
  1219. else:
  1220. self.servicelist2.showFavourites()
  1221. self.session.execDialog(self.servicelist2)
  1222. def openServiceList(self):
  1223. self.session.execDialog(self.servicelist)
  1224. def openServiceListPiP(self):
  1225. self.session.execDialog(self.servicelist2)
  1226. def openSatellites(self):
  1227. self.servicelist.showSatellites()
  1228. self.session.execDialog(self.servicelist)
  1229. def openBouquets(self):
  1230. self.servicelist.showFavourites()
  1231. self.session.execDialog(self.servicelist)
  1232. def zapUp(self):
  1233. if not self.LongButtonPressed or SystemInfo.get("NumVideoDecoders", 1) <= 1:
  1234. if self.pts_blockZap_timer.isActive():
  1235. return
  1236. self["SeekActionsPTS"].setEnabled(False)
  1237. if self.servicelist.inBouquet():
  1238. prev = self.servicelist.getCurrentSelection()
  1239. if prev:
  1240. prev = prev.toString()
  1241. while True:
  1242. if config.usage.quickzap_bouquet_change.value and self.servicelist.atBegin():
  1243. self.servicelist.prevBouquet()
  1244. self.servicelist.moveEnd()
  1245. else:
  1246. self.servicelist.moveUp()
  1247. cur = self.servicelist.getCurrentSelection()
  1248. if cur:
  1249. if self.servicelist.dopipzap:
  1250. isPlayable = self.session.pip.isPlayableForPipService(cur)
  1251. else:
  1252. isPlayable = isPlayableForCur(cur)
  1253. if cur and (cur.toString() == prev or isPlayable):
  1254. break
  1255. else:
  1256. self.servicelist.moveUp()
  1257. self.servicelist.zap(enable_pipzap = True)
  1258. elif self.LongButtonPressed:
  1259. if not hasattr(self.session, 'pip') and not self.session.pipshown:
  1260. self.session.open(MessageBox, _("Please open Picture in Picture first"), MessageBox.TYPE_ERROR)
  1261. return
  1262. from Screens.ChannelSelection import ChannelSelection
  1263. ChannelSelectionInstance = ChannelSelection.instance
  1264. ChannelSelectionInstance.dopipzap = True
  1265. if self.servicelist2.inBouquet():
  1266. prev = self.servicelist2.getCurrentSelection()
  1267. if prev:
  1268. prev = prev.toString()
  1269. while True:
  1270. if config.usage.quickzap_bouquet_change.value and self.servicelist2.atBegin():
  1271. self.servicelist2.prevBouquet()
  1272. self.servicelist2.moveEnd()
  1273. else:
  1274. self.servicelist2.moveUp()
  1275. cur = self.servicelist2.getCurrentSelection()
  1276. if cur:
  1277. if ChannelSelectionInstance.dopipzap:
  1278. isPlayable = self.session.pip.isPlayableForPipService(cur)
  1279. else:
  1280. isPlayable = isPlayableForCur(cur)
  1281. if cur and (cur.toString() == prev or isPlayable):
  1282. break
  1283. else:
  1284. self.servicelist2.moveUp()
  1285. self.servicelist2.zap(enable_pipzap = True)
  1286. ChannelSelectionInstance.dopipzap = False
  1287. if self.timeshiftEnabled() and self.isSeekable():
  1288. self["SeekActionsPTS"].setEnabled(True)
  1289. def zapDown(self):
  1290. if not self.LongButtonPressed or SystemInfo.get("NumVideoDecoders", 1) <= 1:
  1291. if self.pts_blockZap_timer.isActive():
  1292. return
  1293. self["SeekActionsPTS"].setEnabled(False)
  1294. if self.servicelist.inBouquet():
  1295. prev = self.servicelist.getCurrentSelection()
  1296. if prev:
  1297. prev = prev.toString()
  1298. while True:
  1299. if config.usage.quickzap_bouquet_change.value and self.servicelist.atEnd():
  1300. self.servicelist.nextBouquet()
  1301. self.servicelist.moveTop()
  1302. else:
  1303. self.servicelist.moveDown()
  1304. cur = self.servicelist.getCurrentSelection()
  1305. if cur:
  1306. if self.servicelist.dopipzap:
  1307. isPlayable = self.session.pip.isPlayableForPipService(cur)
  1308. else:
  1309. isPlayable = isPlayableForCur(cur)
  1310. if cur and (cur.toString() == prev or isPlayable):
  1311. break
  1312. else:
  1313. self.servicelist.moveDown()
  1314. self.servicelist.zap(enable_pipzap = True)
  1315. elif self.LongButtonPressed:
  1316. if not hasattr(self.session, 'pip') and not self.session.pipshown:
  1317. self.session.open(MessageBox, _("Please open Picture in Picture first"), MessageBox.TYPE_ERROR)
  1318. return
  1319. from Screens.ChannelSelection import ChannelSelection
  1320. ChannelSelectionInstance = ChannelSelection.instance
  1321. ChannelSelectionInstance.dopipzap = True
  1322. if self.servicelist2.inBouquet():
  1323. prev = self.servicelist2.getCurrentSelection()
  1324. if prev:
  1325. prev = prev.toString()
  1326. while True:
  1327. if config.usage.quickzap_bouquet_change.value and self.servicelist2.atEnd():
  1328. self.servicelist2.nextBouquet()
  1329. self.servicelist2.moveTop()
  1330. else:
  1331. self.servicelist2.moveDown()
  1332. cur = self.servicelist2.getCurrentSelection()
  1333. if cur:
  1334. if ChannelSelectionInstance.dopipzap:
  1335. isPlayable = self.session.pip.isPlayableForPipService(cur)
  1336. else:
  1337. isPlayable = isPlayableForCur(cur)
  1338. if cur and (cur.toString() == prev or isPlayable):
  1339. break
  1340. else:
  1341. self.servicelist2.moveDown()
  1342. self.servicelist2.zap(enable_pipzap = True)
  1343. ChannelSelectionInstance.dopipzap = False
  1344. if self.timeshiftEnabled() and self.isSeekable():
  1345. self["SeekActionsPTS"].setEnabled(True)
  1346. def volumeUp(self):
  1347. VolumeControl.instance.volUp()
  1348. def volumeDown(self):
  1349. VolumeControl.instance.volDown()
  1350. class InfoBarMenu:
  1351. """ Handles a menu action, to open the (main) menu """
  1352. def __init__(self):
  1353. self["MenuActions"] = HelpableActionMap(self, "InfobarMenuActions",
  1354. {
  1355. "mainMenu": (self.mainMenu, _("Enter main menu...")),
  1356. "showNetworkSetup": (self.showNetworkMounts, _("Show network mounts ...")),
  1357. "showSystemSetup": (self.showSystemMenu, _("Show network mounts ...")),
  1358. "showRFmod": (self.showRFSetup, _("Show RFmod setup...")),
  1359. "toggleAspectRatio": (self.toggleAspectRatio, _("Toggle aspect ratio...")),
  1360. })
  1361. self.session.infobar = None
  1362. def mainMenu(self):
  1363. # print "loading mainmenu XML..."
  1364. menu = mdom.getroot()
  1365. assert menu.tag == "menu", "root element in menu must be 'menu'!"
  1366. self.session.infobar = self
  1367. # so we can access the currently active infobar from screens opened from within the mainmenu
  1368. # at the moment used from the SubserviceSelection
  1369. self.session.openWithCallback(self.mainMenuClosed, MainMenu, menu)
  1370. def mainMenuClosed(self, *val):
  1371. self.session.infobar = None
  1372. def toggleAspectRatio(self):
  1373. ASPECT = [ "auto", "16:9", "4:3" ]
  1374. ASPECT_MSG = { "auto":"Auto", "16:9":"16:9", "4:3":"4:3" }
  1375. if config.av.aspect.value in ASPECT:
  1376. index = ASPECT.index(config.av.aspect.value)
  1377. config.av.aspect.value = ASPECT[(index+1)%3]
  1378. else:
  1379. config.av.aspect.value = "auto"
  1380. config.av.aspect.save()
  1381. self.session.open(MessageBox, _("AV aspect is %s." % ASPECT_MSG[config.av.aspect.value]), MessageBox.TYPE_INFO, timeout=5)
  1382. def showSystemMenu(self):
  1383. menulist = mdom.getroot().findall('menu')
  1384. for item in menulist:
  1385. if item.attrib['entryID'] == 'setup_selection':
  1386. menulist = item.findall('menu')
  1387. for item in menulist:
  1388. if item.attrib['entryID'] == 'system_selection':
  1389. menu = item
  1390. assert menu.tag == "menu", "root element in menu must be 'menu'!"
  1391. self.session.openWithCallback(self.mainMenuClosed, Menu, menu)
  1392. def showNetworkMounts(self):
  1393. menulist = mdom.getroot().findall('menu')
  1394. for item in menulist:
  1395. if item.attrib['entryID'] == 'setup_selection':
  1396. menulist = item.findall('menu')
  1397. for item in menulist:
  1398. if item.attrib['entryID'] == 'extended_selection':
  1399. menulist = item.findall('menu')
  1400. for item in menulist:
  1401. if item.attrib['entryID'] == 'network_menu':
  1402. menu = item
  1403. assert menu.tag == "menu", "root element in menu must be 'menu'!"
  1404. self.session.openWithCallback(self.mainMenuClosed, Menu, menu)
  1405. def showRFSetup(self):
  1406. if SystemInfo["RfModulator"]:
  1407. self.session.openWithCallback(self.mainMenuClosed, Setup, 'RFmod')
  1408. def mainMenuClosed(self, *val):
  1409. self.session.infobar = None
  1410. class InfoBarSimpleEventView:
  1411. """ Opens the Eventview for now/next """
  1412. def __init__(self):
  1413. self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
  1414. {
  1415. "showEventInfo": (self.openEventView, _("show event details")),
  1416. "InfoPressed": (self.openEventView, _("show event details")),
  1417. "showInfobarOrEpgWhenInfobarAlreadyVisible": self.showEventInfoWhenNotVisible,
  1418. })
  1419. def openEventView(self, simple=False):
  1420. if self.servicelist is None:
  1421. return
  1422. ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1423. self.getNowNext()
  1424. epglist = self.epglist
  1425. if not epglist:
  1426. self.is_now_next = False
  1427. epg = eEPGCache.getInstance()
  1428. ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1)
  1429. if ptr:
  1430. epglist.append(ptr)
  1431. ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1)
  1432. if ptr:
  1433. epglist.append(ptr)
  1434. else:
  1435. self.is_now_next = True
  1436. if epglist:
  1437. if not simple:
  1438. self.eventView = self.session.openWithCallback(self.closed, EventViewEPGSelect, epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList)
  1439. else:
  1440. self.eventView = self.session.openWithCallback(self.closed, EventViewSimple, epglist[0], ServiceReference(ref))
  1441. self.dlg_stack.append(self.eventView)
  1442. def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
  1443. epglist = self.epglist
  1444. if len(epglist) > 1:
  1445. tmp = epglist[0]
  1446. epglist[0] = epglist[1]
  1447. epglist[1] = tmp
  1448. setEvent(epglist[0])
  1449. def showEventInfoWhenNotVisible(self):
  1450. if self.shown:
  1451. self.openEventView()
  1452. else:
  1453. self.toggleShow()
  1454. return 1
  1455. class SimpleServicelist:
  1456. def __init__(self, services):
  1457. self.services = services
  1458. self.length = len(services)
  1459. self.current = 0
  1460. def selectService(self, service):
  1461. if not self.length:
  1462. self.current = -1
  1463. return False
  1464. else:
  1465. self.current = 0
  1466. while self.services[self.current].ref != service:
  1467. self.current += 1
  1468. if self.current >= self.length:
  1469. return False
  1470. return True
  1471. def nextService(self):
  1472. if not self.length:
  1473. return
  1474. if self.current+1 < self.length:
  1475. self.current += 1
  1476. else:
  1477. self.current = 0
  1478. def prevService(self):
  1479. if not self.length:
  1480. return
  1481. if self.current-1 > -1:
  1482. self.current -= 1
  1483. else:
  1484. self.current = self.length - 1
  1485. def currentService(self):
  1486. if not self.length or self.current >= self.length:
  1487. return None
  1488. return self.services[self.current]
  1489. class InfoBarEPG:
  1490. """ EPG - Opens an EPG list when the showEPGList action fires """
  1491. def __init__(self):
  1492. self.is_now_next = False
  1493. self.dlg_stack = []
  1494. self.bouquetSel = None
  1495. self.eventView = None
  1496. self.isInfo = None
  1497. self.epglist = []
  1498. self.defaultEPGType = self.getDefaultEPGtype()
  1499. self.defaultGuideType = self.getDefaultGuidetype()
  1500. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  1501. {
  1502. iPlayableService.evUpdatedEventInfo: self.__evEventInfoChanged,
  1503. })
  1504. self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
  1505. {
  1506. "RedPressed": (self.RedPressed, _("Show epg")),
  1507. "IPressed": (self.IPressed, _("show program information...")),
  1508. "InfoPressed": (self.InfoPressed, _("show program information...")),
  1509. "showEventInfoPlugin": (self.showEventInfoPlugins, _("List EPG functions...")),
  1510. "EPGPressed": (self.showDefaultEPG, _("show EPG...")),
  1511. "showEventGuidePlugin": (self.showEventGuidePlugins, _("List EPG functions...")),
  1512. "showInfobarOrEpgWhenInfobarAlreadyVisible": self.showEventInfoWhenNotVisible,
  1513. })
  1514. def getEPGPluginList(self):
  1515. pluginlist = [(p.name, boundFunction(self.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EVENTINFO)]
  1516. if pluginlist:
  1517. pluginlist.append((_("Event Info"), self.openEventView))
  1518. pluginlist.append((_("Graphical EPG"), self.openGraphEPG))
  1519. pluginlist.append((_("Infobar EPG"), self.openInfoBarEPG))
  1520. pluginlist.append((_("Multi EPG"), self.openMultiServiceEPG))
  1521. pluginlist.append((_("Show EPG for current channel..."), self.openSingleServiceEPG))
  1522. return pluginlist
  1523. def getDefaultEPGtype(self):
  1524. pluginlist = self.getEPGPluginList()
  1525. config.usage.defaultEPGType=ConfigSelection(default = "None", choices = pluginlist)
  1526. for plugin in pluginlist:
  1527. if plugin[0] == config.usage.defaultEPGType.value:
  1528. return plugin[1]
  1529. return None
  1530. def showEventInfoPlugins(self):
  1531. if isMoviePlayerInfoBar(self):
  1532. self.openEventView()
  1533. else:
  1534. pluginlist = self.getEPGPluginList()
  1535. if pluginlist:
  1536. # pluginlist.append((_("Select default EPG type..."), self.SelectDefaultInfoPlugin))
  1537. self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = pluginlist, skin_name = "EPGExtensionsList")
  1538. else:
  1539. self.openSingleServiceEPG()
  1540. def SelectDefaultInfoPlugin(self):
  1541. self.session.openWithCallback(self.DefaultInfoPluginChosen, ChoiceBox, title=_("Please select a default EPG type..."), list = self.getEPGPluginList(), skin_name = "EPGExtensionsList")
  1542. def DefaultInfoPluginChosen(self, answer):
  1543. if answer is not None:
  1544. self.defaultEPGType = answer[1]
  1545. config.usage.defaultEPGType.value = answer[0]
  1546. config.usage.defaultEPGType.save()
  1547. configfile.save()
  1548. def getDefaultGuidetype(self):
  1549. pluginlist = self.getEPGPluginList()
  1550. config.usage.defaultGuideType=ConfigSelection(default = "None", choices = pluginlist)
  1551. for plugin in pluginlist:
  1552. if plugin[0] == config.usage.defaultGuideType.value:
  1553. return plugin[1]
  1554. return None
  1555. def showEventGuidePlugins(self):
  1556. if isMoviePlayerInfoBar(self):
  1557. self.openEventView()
  1558. else:
  1559. pluginlist = self.getEPGPluginList()
  1560. if pluginlist:
  1561. pluginlist.append((_("Select default EPG type..."), self.SelectDefaultGuidePlugin))
  1562. self.session.openWithCallback(self.EventGuidePluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = pluginlist, skin_name = "EPGExtensionsList")
  1563. else:
  1564. self.openSingleServiceEPG()
  1565. def SelectDefaultGuidePlugin(self):
  1566. self.session.openWithCallback(self.DefaultGuidePluginChosen, ChoiceBox, title=_("Please select a default EPG type..."), list = self.getEPGPluginList(), skin_name = "EPGExtensionsList")
  1567. def DefaultGuidePluginChosen(self, answer):
  1568. if answer is not None:
  1569. self.defaultGuideType = answer[1]
  1570. config.usage.defaultGuideType.value = answer[0]
  1571. config.usage.defaultGuideType.save()
  1572. def EventGuidePluginChosen(self, answer):
  1573. if answer is not None:
  1574. answer[1]()
  1575. def runPlugin(self, plugin):
  1576. plugin(session = self.session, servicelist=self.servicelist)
  1577. def EventInfoPluginChosen(self, answer):
  1578. if answer is not None:
  1579. answer[1]()
  1580. def RedPressed(self):
  1581. if isStandardInfoBar(self) or isMoviePlayerInfoBar(self):
  1582. if config.usage.defaultEPGType.value != _("Graphical EPG") and config.usage.defaultEPGType.value != _("None"):
  1583. self.openGraphEPG()
  1584. else:
  1585. self.openSingleServiceEPG()
  1586. def InfoPressed(self):
  1587. if isStandardInfoBar(self) or isMoviePlayerInfoBar(self):
  1588. if config.plisettings.PLIINFO_mode.value == "eventview":
  1589. self.openEventView()
  1590. elif config.plisettings.PLIINFO_mode.value == "epgpress":
  1591. self.showDefaultEPG()
  1592. elif config.plisettings.PLIINFO_mode.value == "single":
  1593. self.openSingleServiceEPG()
  1594. elif config.plisettings.PLIINFO_mode.value == "coolinfoguide" and COOLTVGUIDE:
  1595. self.showCoolInfoGuide()
  1596. elif config.plisettings.PLIINFO_mode.value == "coolsingleguide" and COOLTVGUIDE:
  1597. self.showCoolSingleGuide()
  1598. elif config.plisettings.PLIINFO_mode.value == "cooltvguide" and COOLTVGUIDE:
  1599. if self.isInfo:
  1600. self.showCoolTVGuide()
  1601. else:
  1602. if config.plisettings.PLIINFO_mode.value != "infobar":
  1603. self.showDefaultEPG()
  1604. def IPressed(self):
  1605. if isStandardInfoBar(self) or isMoviePlayerInfoBar(self):
  1606. self.openEventView()
  1607. def EPGPressed(self):
  1608. if isStandardInfoBar(self) or isMoviePlayerInfoBar(self):
  1609. if config.plisettings.PLIEPG_mode.value == "pliepg":
  1610. self.openGraphEPG()
  1611. elif config.plisettings.PLIEPG_mode.value == "multi":
  1612. self.openMultiServiceEPG()
  1613. elif config.plisettings.PLIEPG_mode.value == "single":
  1614. self.openSingleServiceEPG()
  1615. elif config.plisettings.PLIEPG_mode.value == "merlinepgcenter":
  1616. self.openMerlinEPGCenter()
  1617. elif config.plisettings.PLIEPG_mode.value == "cooltvguide" and COOLTVGUIDE:
  1618. if self.isInfo:
  1619. self.showCoolTVGuide()
  1620. elif config.plisettings.PLIEPG_mode.value == "eventview":
  1621. self.openEventView()
  1622. else:
  1623. self.openSingleServiceEPG()
  1624. def showEventInfoWhenNotVisible(self):
  1625. if self.shown:
  1626. self.openEventView()
  1627. else:
  1628. self.toggleShow()
  1629. return 1
  1630. def zapToService(self, service, bouquet = None, preview = False, zapback = False):
  1631. if self.servicelist.startServiceRef is None:
  1632. self.servicelist.startServiceRef = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1633. self.servicelist.currentServiceRef = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1634. if service is not None:
  1635. if self.servicelist.getRoot() != bouquet: #already in correct bouquet?
  1636. self.servicelist.clearPath()
  1637. if self.servicelist.bouquet_root != bouquet:
  1638. self.servicelist.enterPath(self.servicelist.bouquet_root)
  1639. self.servicelist.enterPath(bouquet)
  1640. self.servicelist.setCurrentSelection(service) #select the service in servicelist
  1641. if not zapback or preview:
  1642. self.servicelist.zap(preview_zap = preview)
  1643. if (self.servicelist.dopipzap or zapback) and not preview:
  1644. self.servicelist.zapBack()
  1645. if not preview:
  1646. self.servicelist.startServiceRef = None
  1647. self.servicelist.startRoot = None
  1648. def getBouquetServices(self, bouquet):
  1649. services = []
  1650. servicelist = eServiceCenter.getInstance().list(bouquet)
  1651. if not servicelist is None:
  1652. while True:
  1653. service = servicelist.getNext()
  1654. if not service.valid(): #check if end of list
  1655. break
  1656. if service.flags & (eServiceReference.isDirectory | eServiceReference.isMarker): #ignore non playable services
  1657. continue
  1658. services.append(ServiceReference(service))
  1659. return services
  1660. def openBouquetEPG(self, bouquet = None, bouquets = None):
  1661. if bouquet:
  1662. self.StartBouquet = bouquet
  1663. self.dlg_stack.append(self.session.openWithCallback(self.closed, EPGSelection, zapFunc=self.zapToService, EPGtype=self.EPGtype, StartBouquet=self.StartBouquet, StartRef=self.StartRef, bouquets = bouquets))
  1664. def closed(self, ret=False):
  1665. if not self.dlg_stack:
  1666. return
  1667. closedScreen = self.dlg_stack.pop()
  1668. if self.bouquetSel and closedScreen == self.bouquetSel:
  1669. self.bouquetSel = None
  1670. elif self.eventView and closedScreen == self.eventView:
  1671. self.eventView = None
  1672. if ret == True or ret == 'close':
  1673. dlgs=len(self.dlg_stack)
  1674. if dlgs > 0:
  1675. self.dlg_stack[dlgs-1].close(dlgs > 1)
  1676. self.reopen(ret)
  1677. def MultiServiceEPG(self):
  1678. bouquets = self.servicelist.getBouquetList()
  1679. if bouquets is None:
  1680. cnt = 0
  1681. else:
  1682. cnt = len(bouquets)
  1683. if (self.EPGtype == "multi" and config.epgselection.multi_showbouquet.value) or (self.EPGtype == "graph" and config.epgselection.graph_showbouquet.value):
  1684. if cnt > 1: # show bouquet list
  1685. self.bouquetSel = self.session.openWithCallback(self.closed, EpgBouquetSelector, bouquets, self.openBouquetEPG, enableWrapAround=True)
  1686. self.dlg_stack.append(self.bouquetSel)
  1687. elif cnt == 1:
  1688. self.openBouquetEPG(bouquets=bouquets)
  1689. else:
  1690. self.openBouquetEPG(bouquets=bouquets)
  1691. def openMultiServiceEPG(self):
  1692. if self.servicelist is None:
  1693. return
  1694. self.EPGtype = "multi"
  1695. self.StartBouquet = self.servicelist.getRoot()
  1696. if isMoviePlayerInfoBar(self):
  1697. self.StartRef = self.lastservice
  1698. else:
  1699. self.StartRef = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1700. self.MultiServiceEPG()
  1701. def openGraphEPG(self, reopen=False):
  1702. if self.servicelist is None:
  1703. return
  1704. self.EPGtype = "graph"
  1705. if not reopen:
  1706. self.StartBouquet = self.servicelist.getRoot()
  1707. self.StartRef = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1708. self.MultiServiceEPG()
  1709. def openSingleServiceEPG(self, reopen=False):
  1710. if self.servicelist is None:
  1711. return
  1712. self.EPGtype = "enhanced"
  1713. self.SingleServiceEPG()
  1714. def openInfoBarEPG(self, reopen=False):
  1715. if self.servicelist is None:
  1716. return
  1717. if not reopen:
  1718. self.StartBouquet = self.servicelist.getRoot()
  1719. self.StartRef = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1720. if config.epgselection.infobar_type_mode.value == 'single':
  1721. self.EPGtype = "infobar"
  1722. self.SingleServiceEPG()
  1723. else:
  1724. self.EPGtype = "infobargraph"
  1725. self.MultiServiceEPG()
  1726. def showCoolTVGuide(self):
  1727. if self.servicelist is None:
  1728. return
  1729. if COOLTVGUIDE:
  1730. for plugin in plugins.getPlugins([PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
  1731. if plugin.name == _("Cool TV Guide"):
  1732. self.runPlugin(plugin)
  1733. break
  1734. else:
  1735. self.session.open(MessageBox, _("The Cool TV Guide plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  1736. def SingleServiceEPG(self):
  1737. self.StartBouquet = self.servicelist.getRoot()
  1738. self.StartRef = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1739. if isMoviePlayerInfoBar(self):
  1740. ref = self.lastservice
  1741. else:
  1742. ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1743. if ref:
  1744. services = self.getBouquetServices(self.StartBouquet)
  1745. self.serviceSel = SimpleServicelist(services)
  1746. if self.serviceSel.selectService(ref):
  1747. self.session.openWithCallback(self.SingleServiceEPGClosed,EPGSelection, self.servicelist, zapFunc=self.zapToService, serviceChangeCB = self.changeServiceCB, EPGtype=self.EPGtype, StartBouquet=self.StartBouquet, StartRef=self.StartRef)
  1748. else:
  1749. self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref)
  1750. def changeServiceCB(self, direction, epg):
  1751. if self.serviceSel:
  1752. if direction > 0:
  1753. self.serviceSel.nextService()
  1754. else:
  1755. self.serviceSel.prevService()
  1756. epg.setService(self.serviceSel.currentService())
  1757. def SingleServiceEPGClosed(self, ret=False):
  1758. self.serviceSel = None
  1759. self.reopen(ret)
  1760. def reopen(self, answer):
  1761. if answer == 'reopengraph':
  1762. self.openGraphEPG(True)
  1763. elif answer == 'reopeninfobargraph' or answer == 'reopeninfobar':
  1764. self.openInfoBarEPG(True)
  1765. elif answer == 'close' and isMoviePlayerInfoBar(self):
  1766. self.lastservice = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1767. self.close()
  1768. def openMerlinEPGCenter(self):
  1769. if self.servicelist is None:
  1770. return
  1771. if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPGCenter/plugin.pyo"):
  1772. for plugin in plugins.getPlugins([PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
  1773. if plugin.name == _("Merlin EPG Center"):
  1774. self.runPlugin(plugin)
  1775. break
  1776. else:
  1777. self.session.open(MessageBox, _("The Merlin EPG Center plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  1778. def showCoolInfoGuide(self):
  1779. if self.servicelist is None:
  1780. return
  1781. if COOLTVGUIDE:
  1782. for plugin in plugins.getPlugins([PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
  1783. if plugin.name == _("Cool Info Guide"):
  1784. self.runPlugin(plugin)
  1785. break
  1786. else:
  1787. self.session.open(MessageBox, _("The Cool TV Guide plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  1788. def showCoolSingleGuide(self):
  1789. if self.servicelist is None:
  1790. return
  1791. if COOLTVGUIDE:
  1792. for plugin in plugins.getPlugins([PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
  1793. if plugin.name == _("Cool Single Guide"):
  1794. self.runPlugin(plugin)
  1795. break
  1796. else:
  1797. self.session.open(MessageBox, _("The Cool TV Guide plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  1798. def openSimilarList(self, eventid, refstr):
  1799. self.session.open(EPGSelection, refstr, eventid=eventid)
  1800. def getNowNext(self):
  1801. epglist = [ ]
  1802. service = self.session.nav.getCurrentService()
  1803. info = service and service.info()
  1804. ptr = info and info.getEvent(0)
  1805. if ptr:
  1806. epglist.append(ptr)
  1807. ptr = info and info.getEvent(1)
  1808. if ptr:
  1809. epglist.append(ptr)
  1810. self.epglist = epglist
  1811. def __evEventInfoChanged(self):
  1812. self.isInfo = True
  1813. if self.is_now_next and len(self.dlg_stack) == 1:
  1814. self.getNowNext()
  1815. if self.eventView and self.epglist:
  1816. self.eventView.setEvent(self.epglist[0])
  1817. def showDefaultEPG(self):
  1818. if self.defaultEPGType is not None:
  1819. self.defaultEPGType()
  1820. return
  1821. self.EPGPressed()
  1822. def openEventView(self, simple=False):
  1823. if self.servicelist is None:
  1824. return
  1825. ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  1826. self.getNowNext()
  1827. epglist = self.epglist
  1828. if not epglist:
  1829. self.is_now_next = False
  1830. epg = eEPGCache.getInstance()
  1831. ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1)
  1832. if ptr:
  1833. epglist.append(ptr)
  1834. ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1)
  1835. if ptr:
  1836. epglist.append(ptr)
  1837. else:
  1838. self.is_now_next = True
  1839. if epglist:
  1840. if not simple:
  1841. self.eventView = self.session.openWithCallback(self.closed, EventViewEPGSelect, epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList)
  1842. else:
  1843. self.eventView = self.session.openWithCallback(self.closed, EventViewSimple, epglist[0], ServiceReference(ref))
  1844. self.dlg_stack.append(self.eventView)
  1845. def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
  1846. epglist = self.epglist
  1847. if len(epglist) > 1:
  1848. tmp = epglist[0]
  1849. epglist[0]=epglist[1]
  1850. epglist[1]=tmp
  1851. setEvent(epglist[0])
  1852. class InfoBarRdsDecoder:
  1853. """provides RDS and Rass support/display"""
  1854. def __init__(self):
  1855. self.rds_display = self.session.instantiateDialog(RdsInfoDisplay)
  1856. self.session.instantiateSummaryDialog(self.rds_display)
  1857. self.rds_display.setAnimationMode(0)
  1858. self.rass_interactive = None
  1859. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  1860. {
  1861. iPlayableService.evEnd: self.__serviceStopped,
  1862. iPlayableService.evUpdatedRassSlidePic: self.RassSlidePicChanged
  1863. })
  1864. self["RdsActions"] = ActionMap(["InfobarRdsActions"],
  1865. {
  1866. "startRassInteractive": self.startRassInteractive
  1867. },-1)
  1868. self["RdsActions"].setEnabled(False)
  1869. self.onLayoutFinish.append(self.rds_display.show)
  1870. self.rds_display.onRassInteractivePossibilityChanged.append(self.RassInteractivePossibilityChanged)
  1871. def RassInteractivePossibilityChanged(self, state):
  1872. self["RdsActions"].setEnabled(state)
  1873. def RassSlidePicChanged(self):
  1874. if not self.rass_interactive:
  1875. service = self.session.nav.getCurrentService()
  1876. decoder = service and service.rdsDecoder()
  1877. if decoder:
  1878. decoder.showRassSlidePicture()
  1879. def __serviceStopped(self):
  1880. if self.rass_interactive is not None:
  1881. rass_interactive = self.rass_interactive
  1882. self.rass_interactive = None
  1883. rass_interactive.close()
  1884. def startRassInteractive(self):
  1885. self.rds_display.hide()
  1886. self.rass_interactive = self.session.openWithCallback(self.RassInteractiveClosed, RassInteractive)
  1887. def RassInteractiveClosed(self, *val):
  1888. if self.rass_interactive is not None:
  1889. self.rass_interactive = None
  1890. self.RassSlidePicChanged()
  1891. self.rds_display.show()
  1892. class Seekbar(Screen):
  1893. def __init__(self, session, fwd):
  1894. Screen.__init__(self, session)
  1895. self.setTitle(_("Seek"))
  1896. self.session = session
  1897. self.fwd = fwd
  1898. self.percent = 0.0
  1899. self.length = None
  1900. service = session.nav.getCurrentService()
  1901. if service:
  1902. self.seek = service.seek()
  1903. if self.seek:
  1904. self.length = self.seek.getLength()
  1905. position = self.seek.getPlayPosition()
  1906. if self.length and position and int(self.length[1]) > 0:
  1907. if int(position[1]) > 0:
  1908. self.percent = float(position[1]) * 100.0 / float(self.length[1])
  1909. else:
  1910. self.close()
  1911. self["cursor"] = MovingPixmap()
  1912. self["time"] = Label()
  1913. self["actions"] = ActionMap(["WizardActions", "DirectionActions"], {"back": self.exit, "ok": self.keyOK, "left": self.keyLeft, "right": self.keyRight}, -1)
  1914. self.cursorTimer = eTimer()
  1915. self.cursorTimer.callback.append(self.updateCursor)
  1916. self.cursorTimer.start(200, False)
  1917. def updateCursor(self):
  1918. if self.length:
  1919. screenwidth = getDesktop(0).size().width()
  1920. if screenwidth and screenwidth == 1920:
  1921. x = 218 + int(4.05 * self.percent)
  1922. self["cursor"].moveTo(x, 23, 1)
  1923. else:
  1924. x = 145 + int(2.7 * self.percent)
  1925. self["cursor"].moveTo(x, 15, 1)
  1926. self["cursor"].startMoving()
  1927. pts = int(float(self.length[1]) / 100.0 * self.percent)
  1928. self["time"].setText("%d:%02d" % ((pts/60/90000), ((pts/90000)%60)))
  1929. def exit(self):
  1930. self.cursorTimer.stop()
  1931. self.close()
  1932. def keyOK(self):
  1933. if self.length:
  1934. self.seek.seekTo(int(float(self.length[1]) / 100.0 * self.percent))
  1935. self.exit()
  1936. def keyLeft(self):
  1937. self.percent -= float(config.seek.sensibility.value) / 10.0
  1938. if self.percent < 0.0:
  1939. self.percent = 0.0
  1940. def keyRight(self):
  1941. self.percent += float(config.seek.sensibility.value) / 10.0
  1942. if self.percent > 100.0:
  1943. self.percent = 100.0
  1944. def keyNumberGlobal(self, number):
  1945. sel = self["config"].getCurrent()[1]
  1946. if sel == self.positionEntry:
  1947. self.percent = float(number) * 10.0
  1948. else:
  1949. ConfigListScreen.keyNumberGlobal(self, number)
  1950. class InfoBarSeek:
  1951. """handles actions like seeking, pause"""
  1952. SEEK_STATE_PLAY = (0, 0, 0, ">")
  1953. SEEK_STATE_PAUSE = (1, 0, 0, "||")
  1954. SEEK_STATE_EOF = (1, 0, 0, "END")
  1955. def __init__(self, actionmap = "InfobarSeekActions"):
  1956. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  1957. {
  1958. iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged,
  1959. iPlayableService.evStart: self.__serviceStarted,
  1960. iPlayableService.evEOF: self.__evEOF,
  1961. iPlayableService.evSOF: self.__evSOF,
  1962. })
  1963. self.fast_winding_hint_message_showed = False
  1964. class InfoBarSeekActionMap(HelpableActionMap):
  1965. def __init__(self, screen, *args, **kwargs):
  1966. HelpableActionMap.__init__(self, screen, *args, **kwargs)
  1967. self.screen = screen
  1968. def action(self, contexts, action):
  1969. # print "action:", action
  1970. if action[:5] == "seek:":
  1971. time = int(action[5:])
  1972. self.screen.doSeekRelative(time * 90000)
  1973. return 1
  1974. elif action[:8] == "seekdef:":
  1975. key = int(action[8:])
  1976. time = (-config.seek.selfdefined_13.value, False, config.seek.selfdefined_13.value,
  1977. -config.seek.selfdefined_46.value, False, config.seek.selfdefined_46.value,
  1978. -config.seek.selfdefined_79.value, False, config.seek.selfdefined_79.value)[key-1]
  1979. self.screen.doSeekRelative(time * 90000)
  1980. return 1
  1981. else:
  1982. return HelpableActionMap.action(self, contexts, action)
  1983. self["SeekActions"] = InfoBarSeekActionMap(self, actionmap,
  1984. {
  1985. "playpauseService": (self.playpauseService, _("Pauze/Continue playback")),
  1986. "pauseService": (self.pauseService, _("Pause playback")),
  1987. "pauseServiceYellow": (self.pauseServiceYellow, _("Pause playback")),
  1988. "unPauseService": (self.unPauseService, _("Continue playback")),
  1989. "okButton": (self.okButton, _("Continue playback")),
  1990. "seekFwd": (self.seekFwd, _("Seek forward")),
  1991. "seekFwdManual": (self.seekFwdManual, _("Seek forward (enter time)")),
  1992. "seekBack": (self.seekBack, _("Seek backward")),
  1993. "seekBackManual": (self.seekBackManual, _("Seek backward (enter time)")),
  1994. "SeekbarFwd": self.seekFwdSeekbar,
  1995. "SeekbarBack": self.seekBackSeekbar
  1996. }, prio=-1) # give them a little more priority to win over color buttons
  1997. self["SeekActions"].setEnabled(False)
  1998. self["SeekActionsPTS"] = InfoBarSeekActionMap(self, "InfobarSeekActionsPTS",
  1999. {
  2000. "playpauseService": self.playpauseService,
  2001. "pauseService": (self.pauseService, _("Pause playback")),
  2002. "pauseServiceYellow": (self.pauseServiceYellow, _("Pause playback")),
  2003. "unPauseService": (self.unPauseService, _("Continue playback")),
  2004. "seekFwd": (self.seekFwd, _("skip forward")),
  2005. "seekFwdManual": (self.seekFwdManual, _("skip forward (enter time)")),
  2006. "seekBack": (self.seekBack, _("skip backward")),
  2007. "seekBackManual": (self.seekBackManual, _("skip backward (enter time)")),
  2008. }, prio=-1) # give them a little more priority to win over color buttons
  2009. self["SeekActionsPTS"].setEnabled(False)
  2010. self.activity = 0
  2011. self.activityTimer = eTimer()
  2012. self.activityTimer.callback.append(self.doActivityTimer)
  2013. self.seekstate = self.SEEK_STATE_PLAY
  2014. self.lastseekstate = self.SEEK_STATE_PLAY
  2015. self.seekAction = 0
  2016. self.LastseekAction = False
  2017. self.onPlayStateChanged = [ ]
  2018. self.lockedBecauseOfSkipping = False
  2019. self.__seekableStatusChanged()
  2020. def makeStateForward(self, n):
  2021. return 0, n, 0, ">> %dx" % n
  2022. def makeStateBackward(self, n):
  2023. return 0, -n, 0, "<< %dx" % n
  2024. def makeStateSlowMotion(self, n):
  2025. return 0, 0, n, "/%d" % n
  2026. def isStateForward(self, state):
  2027. return state[1] > 1
  2028. def isStateBackward(self, state):
  2029. return state[1] < 0
  2030. def isStateSlowMotion(self, state):
  2031. return state[1] == 0 and state[2] > 1
  2032. def getHigher(self, n, lst):
  2033. for x in lst:
  2034. if x > n:
  2035. return x
  2036. return False
  2037. def getLower(self, n, lst):
  2038. lst = lst[:]
  2039. lst.reverse()
  2040. for x in lst:
  2041. if x < n:
  2042. return x
  2043. return False
  2044. def showAfterSeek(self):
  2045. if isinstance(self, InfoBarShowHide):
  2046. self.doShow()
  2047. def up(self):
  2048. pass
  2049. def down(self):
  2050. pass
  2051. def getSeek(self):
  2052. service = self.session.nav.getCurrentService()
  2053. if service is None:
  2054. return None
  2055. seek = service.seek()
  2056. if seek is None or not seek.isCurrentlySeekable():
  2057. return None
  2058. return seek
  2059. def isSeekable(self):
  2060. if self.getSeek() is None or (isStandardInfoBar(self) and not self.timeshiftEnabled()):
  2061. return False
  2062. return True
  2063. def __seekableStatusChanged(self):
  2064. if isStandardInfoBar(self) and self.timeshiftEnabled():
  2065. pass
  2066. elif not self.isSeekable():
  2067. SystemInfo["SeekStatePlay"] = False
  2068. if os.path.exists("/proc/stb/lcd/symbol_hdd"):
  2069. f = open("/proc/stb/lcd/symbol_hdd", "w")
  2070. f.write("0")
  2071. f.close()
  2072. if os.path.exists("/proc/stb/lcd/symbol_hddprogress"):
  2073. f = open("/proc/stb/lcd/symbol_hddprogress", "w")
  2074. f.write("0")
  2075. f.close()
  2076. # print "not seekable, return to play"
  2077. self["SeekActions"].setEnabled(False)
  2078. self.setSeekState(self.SEEK_STATE_PLAY)
  2079. else:
  2080. # print "seekable"
  2081. self["SeekActions"].setEnabled(True)
  2082. self.activityTimer.start(int(config.seek.withjumps_repeat_ms.getValue()), False)
  2083. for c in self.onPlayStateChanged:
  2084. c(self.seekstate)
  2085. global seek_withjumps_muted
  2086. if seek_withjumps_muted and eDVBVolumecontrol.getInstance().isMuted():
  2087. print "STILL MUTED AFTER FFWD/FBACK !!!!!!!! so we unMute"
  2088. seek_withjumps_muted = False
  2089. eDVBVolumecontrol.getInstance().volumeUnMute()
  2090. def doActivityTimer(self):
  2091. if self.isSeekable():
  2092. self.activity += 16
  2093. hdd = 1
  2094. if self.activity >= 100:
  2095. self.activity = 0
  2096. if SystemInfo["FrontpanelDisplay"] and SystemInfo["Display"]:
  2097. if os.path.exists("/proc/stb/lcd/symbol_hdd"):
  2098. if config.lcd.hdd.value == "1":
  2099. file = open("/proc/stb/lcd/symbol_hdd", "w")
  2100. file.write('%d' % int(hdd))
  2101. file.close()
  2102. if os.path.exists("/proc/stb/lcd/symbol_hddprogress"):
  2103. if config.lcd.hdd.value == "1":
  2104. file = open("/proc/stb/lcd/symbol_hddprogress", "w")
  2105. file.write('%d' % int(self.activity))
  2106. file.close()
  2107. else:
  2108. self.activityTimer.stop()
  2109. self.activity = 0
  2110. hdd = 0
  2111. self.seekAction = 0
  2112. if os.path.exists("/proc/stb/lcd/symbol_hdd"):
  2113. file = open("/proc/stb/lcd/symbol_hdd", "w")
  2114. file.write('%d' % int(hdd))
  2115. file.close()
  2116. if os.path.exists("/proc/stb/lcd/symbol_hddprogress"):
  2117. file = open("/proc/stb/lcd/symbol_hddprogress", "w")
  2118. file.write('%d' % int(self.activity))
  2119. file.close()
  2120. if self.LastseekAction:
  2121. self.DoSeekAction()
  2122. def __serviceStarted(self):
  2123. self.fast_winding_hint_message_showed = False
  2124. self.setSeekState(self.SEEK_STATE_PLAY)
  2125. self.__seekableStatusChanged()
  2126. def setSeekState(self, state):
  2127. service = self.session.nav.getCurrentService()
  2128. if service is None:
  2129. return False
  2130. if not self.isSeekable():
  2131. if state not in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE):
  2132. state = self.SEEK_STATE_PLAY
  2133. pauseable = service.pause()
  2134. if pauseable is None:
  2135. # print "not pauseable."
  2136. state = self.SEEK_STATE_PLAY
  2137. self.seekstate = state
  2138. if pauseable is not None:
  2139. if self.seekstate[0] and self.seekstate[3] == '||':
  2140. # print "resolved to PAUSE"
  2141. self.activityTimer.stop()
  2142. pauseable.pause()
  2143. elif self.seekstate[0] and self.seekstate[3] == 'END':
  2144. # print "resolved to STOP"
  2145. self.activityTimer.stop()
  2146. elif self.seekstate[1]:
  2147. if not pauseable.setFastForward(self.seekstate[1]):
  2148. pass
  2149. # print "resolved to FAST FORWARD"
  2150. else:
  2151. self.seekstate = self.SEEK_STATE_PLAY
  2152. # print "FAST FORWARD not possible: resolved to PLAY"
  2153. elif self.seekstate[2]:
  2154. if not pauseable.setSlowMotion(self.seekstate[2]):
  2155. pass
  2156. # print "resolved to SLOW MOTION"
  2157. else:
  2158. self.seekstate = self.SEEK_STATE_PAUSE
  2159. # print "SLOW MOTION not possible: resolved to PAUSE"
  2160. else:
  2161. # print "resolved to PLAY"
  2162. self.activityTimer.start(int(config.seek.withjumps_repeat_ms.getValue()), False)
  2163. pauseable.unpause()
  2164. for c in self.onPlayStateChanged:
  2165. c(self.seekstate)
  2166. self.checkSkipShowHideLock()
  2167. if hasattr(self, "ScreenSaverTimerStart"):
  2168. self.ScreenSaverTimerStart()
  2169. return True
  2170. def okButton(self):
  2171. if self.seekstate == self.SEEK_STATE_PLAY:
  2172. return 0
  2173. elif self.seekstate == self.SEEK_STATE_PAUSE:
  2174. self.pauseService()
  2175. else:
  2176. self.unPauseService()
  2177. def playpauseService(self):
  2178. if self.seekAction <> 0:
  2179. self.seekAction = 0
  2180. self.doPause(False)
  2181. global seek_withjumps_muted
  2182. seek_withjumps_muted = False
  2183. return
  2184. if self.seekstate == self.SEEK_STATE_PLAY:
  2185. self.pauseService()
  2186. else:
  2187. if self.seekstate == self.SEEK_STATE_PAUSE:
  2188. if config.seek.on_pause.value == "play":
  2189. self.unPauseService()
  2190. elif config.seek.on_pause.value == "step":
  2191. self.doSeekRelative(1)
  2192. elif config.seek.on_pause.value == "last":
  2193. self.setSeekState(self.lastseekstate)
  2194. self.lastseekstate = self.SEEK_STATE_PLAY
  2195. else:
  2196. self.unPauseService()
  2197. def pauseService(self):
  2198. if self.seekstate != self.SEEK_STATE_EOF:
  2199. self.lastseekstate = self.seekstate
  2200. self.setSeekState(self.SEEK_STATE_PAUSE)
  2201. def pauseServiceYellow(self):
  2202. if config.plugins.infopanel_yellowkey.list.value == '0':
  2203. self.audioSelection()
  2204. elif config.plugins.infopanel_yellowkey.list.value == '2':
  2205. ToggleVideo()
  2206. else:
  2207. if self.seekstate != self.SEEK_STATE_EOF:
  2208. self.lastseekstate = self.seekstate
  2209. self.setSeekState(self.SEEK_STATE_PAUSE)
  2210. def unPauseService(self):
  2211. if self.seekstate == self.SEEK_STATE_PLAY:
  2212. #return 0 # if 'return 0', plays timeshift again from the beginning
  2213. return
  2214. self.setSeekState(self.SEEK_STATE_PLAY)
  2215. def doPause(self, pause):
  2216. if pause:
  2217. if not eDVBVolumecontrol.getInstance().isMuted():
  2218. eDVBVolumecontrol.getInstance().volumeMute()
  2219. else:
  2220. if eDVBVolumecontrol.getInstance().isMuted():
  2221. eDVBVolumecontrol.getInstance().volumeUnMute()
  2222. def doSeek(self, pts):
  2223. seekable = self.getSeek()
  2224. if seekable is None:
  2225. return
  2226. seekable.seekTo(pts)
  2227. def doSeekRelativeAvoidStall(self, pts):
  2228. global jump_pts_adder
  2229. global jump_last_pts
  2230. global jump_last_pos
  2231. seekable = self.getSeek()
  2232. #when config.seek.withjumps, avoid that jumps smaller than the time between I-frames result in hanging, by increasing pts when stalled
  2233. if seekable and config.seek.withjumps_avoid_zero.getValue():
  2234. position = seekable.getPlayPosition()
  2235. if jump_last_pos and jump_last_pts:
  2236. if (abs(position[1] - jump_last_pos[1]) < 100*90) and (pts == jump_last_pts): # stalled?
  2237. jump_pts_adder += pts
  2238. jump_last_pts = pts
  2239. pts += jump_pts_adder
  2240. else:
  2241. jump_pts_adder = 0
  2242. jump_last_pts = pts
  2243. else:
  2244. jump_last_pts = pts
  2245. jump_last_pos = position
  2246. self.doSeekRelative(pts)
  2247. def doSeekRelative(self, pts):
  2248. try:
  2249. if "<class 'Screens.InfoBar.InfoBar'>" in `self`:
  2250. if InfoBarTimeshift.timeshiftEnabled(self):
  2251. length = InfoBarTimeshift.ptsGetLength(self)
  2252. position = InfoBarTimeshift.ptsGetPosition(self)
  2253. if length is None or position is None:
  2254. return
  2255. if position + pts >= length:
  2256. InfoBarTimeshift.evEOF(self, position + pts - length)
  2257. return
  2258. elif position + pts < 0:
  2259. InfoBarTimeshift.evSOF(self, position + pts)
  2260. self.showAfterSeek()
  2261. return
  2262. except:
  2263. from sys import exc_info
  2264. print "[InfoBarGeneretics] error in 'def doSeekRelative'", exc_info()[:2]
  2265. seekable = self.getSeek()
  2266. if seekable is None or int(seekable.getLength()[1]) < 1:
  2267. return
  2268. prevstate = self.seekstate
  2269. if self.seekstate == self.SEEK_STATE_EOF:
  2270. if prevstate == self.SEEK_STATE_PAUSE:
  2271. self.setSeekState(self.SEEK_STATE_PAUSE)
  2272. else:
  2273. self.setSeekState(self.SEEK_STATE_PLAY)
  2274. seekable.seekRelative(pts<0 and -1 or 1, abs(pts))
  2275. if abs(pts) > 100 and config.usage.show_infobar_on_skip.value:
  2276. self.showAfterSeek()
  2277. def DoSeekAction(self):
  2278. if self.seekAction > int(config.seek.withjumps_after_ff_speed.getValue()):
  2279. self.doSeekRelativeAvoidStall(self.seekAction * long(config.seek.withjumps_forwards_ms.getValue()) * 90)
  2280. elif self.seekAction < 0:
  2281. self.doSeekRelativeAvoidStall(self.seekAction * long(config.seek.withjumps_backwards_ms.getValue()) * 90)
  2282. for c in self.onPlayStateChanged:
  2283. if self.seekAction > int(config.seek.withjumps_after_ff_speed.getValue()): # Forward
  2284. c((0, self.seekAction, 0, ">> %dx" % self.seekAction))
  2285. elif self.seekAction < 0: # Backward
  2286. c((0, self.seekAction, 0, "<< %dx" % abs(self.seekAction)))
  2287. if self.seekAction == 0:
  2288. self.LastseekAction = False
  2289. self.doPause(False)
  2290. global seek_withjumps_muted
  2291. seek_withjumps_muted = False
  2292. self.setSeekState(self.SEEK_STATE_PLAY)
  2293. def isServiceTypeTS(self):
  2294. ref = self.session.nav.getCurrentlyPlayingServiceReference()
  2295. isTS = False
  2296. if ref is not None:
  2297. servincetype = ServiceReference(ref).getType()
  2298. if servincetype == 1:
  2299. isTS = True
  2300. return isTS
  2301. def seekFwd(self):
  2302. if config.seek.withjumps.value and not self.isServiceTypeTS():
  2303. self.seekFwd_new()
  2304. else:
  2305. self.seekFwd_old()
  2306. def seekBack(self):
  2307. if config.seek.withjumps.value and not self.isServiceTypeTS():
  2308. self.seekBack_new()
  2309. else:
  2310. self.seekBack_old()
  2311. def seekFwd_new(self):
  2312. self.LastseekAction = True
  2313. self.doPause(True)
  2314. global seek_withjumps_muted
  2315. seek_withjumps_muted = True
  2316. if self.seekAction >= 0:
  2317. self.seekAction = self.getHigher(abs(self.seekAction), config.seek.speeds_forward.value) or config.seek.speeds_forward.value[-1]
  2318. else:
  2319. self.seekAction = -self.getLower(abs(self.seekAction), config.seek.speeds_backward.value)
  2320. if (self.seekAction > 1) and (self.seekAction <= int(config.seek.withjumps_after_ff_speed.getValue())): # use fastforward for the configured speeds
  2321. self.setSeekState(self.makeStateForward(self.seekAction))
  2322. elif self.seekAction > int(config.seek.withjumps_after_ff_speed.getValue()): # we first need to go the play state, to stop fastforward
  2323. self.setSeekState(self.SEEK_STATE_PLAY)
  2324. def seekBack_new(self):
  2325. self.LastseekAction = True
  2326. self.doPause(True)
  2327. global seek_withjumps_muted
  2328. seek_withjumps_muted = True
  2329. if self.seekAction <= 0:
  2330. self.seekAction = -self.getHigher(abs(self.seekAction), config.seek.speeds_backward.value) or -config.seek.speeds_backward.value[-1]
  2331. else:
  2332. self.seekAction = self.getLower(abs(self.seekAction), config.seek.speeds_forward.value)
  2333. if (self.seekAction > 1) and (self.seekAction <= int(config.seek.withjumps_after_ff_speed.getValue())): # use fastforward for the configured forwards speeds
  2334. self.setSeekState(self.makeStateForward(self.seekAction))
  2335. def seekFwd_old(self):
  2336. seek = self.getSeek()
  2337. if seek and not (seek.isCurrentlySeekable() & 2):
  2338. if not self.fast_winding_hint_message_showed and (seek.isCurrentlySeekable() & 1):
  2339. self.session.open(MessageBox, _("No fast winding possible yet.. but you can use the number buttons to skip forward/backward!"), MessageBox.TYPE_INFO, timeout=10)
  2340. self.fast_winding_hint_message_showed = True
  2341. return
  2342. return 0 # trade as unhandled action
  2343. if self.seekstate == self.SEEK_STATE_PLAY:
  2344. self.setSeekState(self.makeStateForward(int(config.seek.enter_forward.value)))
  2345. elif self.seekstate == self.SEEK_STATE_PAUSE:
  2346. if len(config.seek.speeds_slowmotion.value):
  2347. self.setSeekState(self.makeStateSlowMotion(config.seek.speeds_slowmotion.value[-1]))
  2348. else:
  2349. self.setSeekState(self.makeStateForward(int(config.seek.enter_forward.value)))
  2350. elif self.seekstate == self.SEEK_STATE_EOF:
  2351. pass
  2352. elif self.isStateForward(self.seekstate):
  2353. speed = self.seekstate[1]
  2354. if self.seekstate[2]:
  2355. speed /= self.seekstate[2]
  2356. speed = self.getHigher(speed, config.seek.speeds_forward.value) or config.seek.speeds_forward.value[-1]
  2357. self.setSeekState(self.makeStateForward(speed))
  2358. elif self.isStateBackward(self.seekstate):
  2359. speed = -self.seekstate[1]
  2360. if self.seekstate[2]:
  2361. speed /= self.seekstate[2]
  2362. speed = self.getLower(speed, config.seek.speeds_backward.value)
  2363. if speed:
  2364. self.setSeekState(self.makeStateBackward(speed))
  2365. else:
  2366. self.setSeekState(self.SEEK_STATE_PLAY)
  2367. elif self.isStateSlowMotion(self.seekstate):
  2368. speed = self.getLower(self.seekstate[2], config.seek.speeds_slowmotion.value) or config.seek.speeds_slowmotion.value[0]
  2369. self.setSeekState(self.makeStateSlowMotion(speed))
  2370. def seekBack_old(self):
  2371. seek = self.getSeek()
  2372. if seek and not (seek.isCurrentlySeekable() & 2):
  2373. if not self.fast_winding_hint_message_showed and (seek.isCurrentlySeekable() & 1):
  2374. self.session.open(MessageBox, _("No fast winding possible yet.. but you can use the number buttons to skip forward/backward!"), MessageBox.TYPE_INFO, timeout=10)
  2375. self.fast_winding_hint_message_showed = True
  2376. return
  2377. return 0 # trade as unhandled action
  2378. seekstate = self.seekstate
  2379. if seekstate == self.SEEK_STATE_PLAY:
  2380. self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
  2381. elif seekstate == self.SEEK_STATE_EOF:
  2382. self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
  2383. self.doSeekRelative(-6)
  2384. elif seekstate == self.SEEK_STATE_PAUSE:
  2385. self.doSeekRelative(-1)
  2386. elif self.isStateForward(seekstate):
  2387. speed = seekstate[1]
  2388. if seekstate[2]:
  2389. speed /= seekstate[2]
  2390. speed = self.getLower(speed, config.seek.speeds_forward.value)
  2391. if speed:
  2392. self.setSeekState(self.makeStateForward(speed))
  2393. else:
  2394. self.setSeekState(self.SEEK_STATE_PLAY)
  2395. elif self.isStateBackward(seekstate):
  2396. speed = -seekstate[1]
  2397. if seekstate[2]:
  2398. speed /= seekstate[2]
  2399. speed = self.getHigher(speed, config.seek.speeds_backward.value) or config.seek.speeds_backward.value[-1]
  2400. self.setSeekState(self.makeStateBackward(speed))
  2401. elif self.isStateSlowMotion(seekstate):
  2402. speed = self.getHigher(seekstate[2], config.seek.speeds_slowmotion.value)
  2403. if speed:
  2404. self.setSeekState(self.makeStateSlowMotion(speed))
  2405. else:
  2406. self.setSeekState(self.SEEK_STATE_PAUSE)
  2407. self.pts_lastseekspeed = self.seekstate[1]
  2408. def seekFwdManual(self, fwd=True):
  2409. if config.seek.baractivation.value == "leftright":
  2410. self.session.open(Seekbar, fwd)
  2411. else:
  2412. self.session.openWithCallback(self.fwdSeekTo, MinuteInput)
  2413. def seekBackManual(self, fwd=False):
  2414. if config.seek.baractivation.value == "leftright":
  2415. self.session.open(Seekbar, fwd)
  2416. else:
  2417. self.session.openWithCallback(self.rwdSeekTo, MinuteInput)
  2418. def seekFwdSeekbar(self, fwd=True):
  2419. if not config.seek.baractivation.value == "leftright":
  2420. self.session.open(Seekbar, fwd)
  2421. else:
  2422. self.session.openWithCallback(self.fwdSeekTo, MinuteInput)
  2423. def fwdSeekTo(self, minutes):
  2424. self.doSeekRelative(minutes * 60 * 90000)
  2425. def seekBackSeekbar(self, fwd=False):
  2426. if not config.seek.baractivation.value == "leftright":
  2427. self.session.open(Seekbar, fwd)
  2428. else:
  2429. self.session.openWithCallback(self.rwdSeekTo, MinuteInput)
  2430. def rwdSeekTo(self, minutes):
  2431. # print "rwdSeekTo"
  2432. self.doSeekRelative(-minutes * 60 * 90000)
  2433. def checkSkipShowHideLock(self):
  2434. if self.seekstate == self.SEEK_STATE_PLAY or self.seekstate == self.SEEK_STATE_EOF:
  2435. self.lockedBecauseOfSkipping = False
  2436. self.unlockShow()
  2437. else:
  2438. wantlock = self.seekstate != self.SEEK_STATE_PLAY
  2439. if config.usage.show_infobar_on_skip.value:
  2440. if self.lockedBecauseOfSkipping and not wantlock:
  2441. self.unlockShow()
  2442. self.lockedBecauseOfSkipping = False
  2443. if wantlock and not self.lockedBecauseOfSkipping:
  2444. self.lockShow()
  2445. self.lockedBecauseOfSkipping = True
  2446. def calcRemainingTime(self):
  2447. seekable = self.getSeek()
  2448. if seekable is not None:
  2449. len = seekable.getLength()
  2450. try:
  2451. tmp = self.cueGetEndCutPosition()
  2452. if tmp:
  2453. len = (False, tmp)
  2454. except:
  2455. pass
  2456. pos = seekable.getPlayPosition()
  2457. speednom = self.seekstate[1] or 1
  2458. speedden = self.seekstate[2] or 1
  2459. if not len[0] and not pos[0]:
  2460. if len[1] <= pos[1]:
  2461. return 0
  2462. time = (len[1] - pos[1])*speedden/(90*speednom)
  2463. return time
  2464. return False
  2465. def __evEOF(self):
  2466. if self.seekstate == self.SEEK_STATE_EOF:
  2467. return
  2468. global seek_withjumps_muted
  2469. if seek_withjumps_muted and eDVBVolumecontrol.getInstance().isMuted():
  2470. print "STILL MUTED AFTER FFWD/FBACK !!!!!!!! so we unMute"
  2471. seek_withjumps_muted = False
  2472. eDVBVolumecontrol.getInstance().volumeUnMute()
  2473. # if we are seeking forward, we try to end up ~1s before the end, and pause there.
  2474. seekstate = self.seekstate
  2475. if self.seekstate != self.SEEK_STATE_PAUSE:
  2476. self.setSeekState(self.SEEK_STATE_EOF)
  2477. if seekstate not in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE): # if we are seeking
  2478. seekable = self.getSeek()
  2479. if seekable is not None:
  2480. seekable.seekTo(-1)
  2481. self.doEofInternal(True)
  2482. if seekstate == self.SEEK_STATE_PLAY: # regular EOF
  2483. self.doEofInternal(True)
  2484. else:
  2485. self.doEofInternal(False)
  2486. def doEofInternal(self, playing):
  2487. pass # Defined in subclasses
  2488. def __evSOF(self):
  2489. self.setSeekState(self.SEEK_STATE_PLAY)
  2490. self.doSeek(0)
  2491. class InfoBarPVRState:
  2492. def __init__(self, screen=PVRState, force_show = False):
  2493. self.onChangedEntry = [ ]
  2494. self.onPlayStateChanged.append(self.__playStateChanged)
  2495. self.pvrStateDialog = self.session.instantiateDialog(screen)
  2496. self.pvrStateDialog.setAnimationMode(0)
  2497. self.onShow.append(self._mayShow)
  2498. self.onHide.append(self.pvrStateDialog.hide)
  2499. self.force_show = force_show
  2500. def createSummary(self):
  2501. return InfoBarMoviePlayerSummary
  2502. def _mayShow(self):
  2503. if self.has_key("state") and not config.usage.movieplayer_pvrstate.value:
  2504. self["state"].setText("")
  2505. self["statusicon"].setPixmapNum(6)
  2506. self["speed"].setText("")
  2507. if self.shown and self.seekstate != self.SEEK_STATE_EOF and not config.usage.movieplayer_pvrstate.value:
  2508. self.pvrStateDialog.show()
  2509. self.startHideTimer()
  2510. def __playStateChanged(self, state):
  2511. playstateString = state[3]
  2512. state_summary = playstateString
  2513. self.pvrStateDialog["state"].setText(playstateString)
  2514. if playstateString == '>':
  2515. self.pvrStateDialog["statusicon"].setPixmapNum(0)
  2516. self.pvrStateDialog["speed"].setText("")
  2517. speed_summary = self.pvrStateDialog["speed"].text
  2518. statusicon_summary = 0
  2519. if self.has_key("state") and config.usage.movieplayer_pvrstate.value:
  2520. self["state"].setText(playstateString)
  2521. self["statusicon"].setPixmapNum(0)
  2522. self["speed"].setText("")
  2523. elif playstateString == '||':
  2524. self.pvrStateDialog["statusicon"].setPixmapNum(1)
  2525. self.pvrStateDialog["speed"].setText("")
  2526. speed_summary = self.pvrStateDialog["speed"].text
  2527. statusicon_summary = 1
  2528. if self.has_key("state") and config.usage.movieplayer_pvrstate.value:
  2529. self["state"].setText(playstateString)
  2530. self["statusicon"].setPixmapNum(1)
  2531. self["speed"].setText("")
  2532. elif playstateString == 'END':
  2533. self.pvrStateDialog["statusicon"].setPixmapNum(2)
  2534. self.pvrStateDialog["speed"].setText("")
  2535. speed_summary = self.pvrStateDialog["speed"].text
  2536. statusicon_summary = 2
  2537. if self.has_key("state") and config.usage.movieplayer_pvrstate.value:
  2538. self["state"].setText(playstateString)
  2539. self["statusicon"].setPixmapNum(2)
  2540. self["speed"].setText("")
  2541. elif playstateString.startswith('>>'):
  2542. speed = state[3].split()
  2543. self.pvrStateDialog["statusicon"].setPixmapNum(3)
  2544. self.pvrStateDialog["speed"].setText(speed[1])
  2545. speed_summary = self.pvrStateDialog["speed"].text
  2546. statusicon_summary = 3
  2547. if self.has_key("state") and config.usage.movieplayer_pvrstate.value:
  2548. self["state"].setText(playstateString)
  2549. self["statusicon"].setPixmapNum(3)
  2550. self["speed"].setText(speed[1])
  2551. elif playstateString.startswith('<<'):
  2552. speed = state[3].split()
  2553. self.pvrStateDialog["statusicon"].setPixmapNum(4)
  2554. self.pvrStateDialog["speed"].setText(speed[1])
  2555. speed_summary = self.pvrStateDialog["speed"].text
  2556. statusicon_summary = 4
  2557. if self.has_key("state") and config.usage.movieplayer_pvrstate.value:
  2558. self["state"].setText(playstateString)
  2559. self["statusicon"].setPixmapNum(4)
  2560. self["speed"].setText(speed[1])
  2561. elif playstateString.startswith('/'):
  2562. self.pvrStateDialog["statusicon"].setPixmapNum(5)
  2563. self.pvrStateDialog["speed"].setText(playstateString)
  2564. speed_summary = self.pvrStateDialog["speed"].text
  2565. statusicon_summary = 5
  2566. if self.has_key("state") and config.usage.movieplayer_pvrstate.value:
  2567. self["state"].setText(playstateString)
  2568. self["statusicon"].setPixmapNum(5)
  2569. self["speed"].setText(playstateString)
  2570. for cb in self.onChangedEntry:
  2571. cb(state_summary, speed_summary, statusicon_summary)
  2572. # if we return into "PLAY" state, ensure that the dialog gets hidden if there will be no infobar displayed
  2573. if not config.usage.show_infobar_on_skip.value and self.seekstate == self.SEEK_STATE_PLAY and not self.force_show:
  2574. self.pvrStateDialog.hide()
  2575. else:
  2576. self._mayShow()
  2577. class InfoBarTimeshiftState(InfoBarPVRState):
  2578. def __init__(self):
  2579. InfoBarPVRState.__init__(self, screen=TimeshiftState, force_show = True)
  2580. self.onPlayStateChanged.append(self.__timeshiftEventName)
  2581. self.onHide.append(self.__hideTimeshiftState)
  2582. def _mayShow(self):
  2583. if self.shown and self.timeshiftEnabled() and self.isSeekable():
  2584. InfoBarTimeshift.ptsSeekPointerSetCurrentPos(self)
  2585. if config.timeshift.showinfobar.value:
  2586. self["TimeshiftSeekPointerActions"].setEnabled(True)
  2587. self.pvrStateDialog.show()
  2588. if not self.isSeekable():
  2589. self.startHideTimer()
  2590. def __hideTimeshiftState(self):
  2591. self["TimeshiftSeekPointerActions"].setEnabled(False)
  2592. self.pvrStateDialog.hide()
  2593. def __timeshiftEventName(self,state):
  2594. if self.timeshiftEnabled() and os.path.exists("%spts_livebuffer_%s.meta" % (config.usage.timeshift_path.value,self.pts_currplaying)):
  2595. readmetafile = open("%spts_livebuffer_%s.meta" % (config.usage.timeshift_path.value,self.pts_currplaying), "r")
  2596. servicerefname = readmetafile.readline()[0:-1]
  2597. eventname = readmetafile.readline()[0:-1]
  2598. readmetafile.close()
  2599. self.pvrStateDialog["eventname"].setText(eventname)
  2600. else:
  2601. self.pvrStateDialog["eventname"].setText("")
  2602. class InfoBarShowMovies:
  2603. # i don't really like this class.
  2604. # it calls a not further specified "movie list" on up/down/movieList,
  2605. # so this is not more than an action map
  2606. def __init__(self):
  2607. self["MovieListActions"] = HelpableActionMap(self, "InfobarMovieListActions",
  2608. {
  2609. "movieList": (self.showMovies, _("Open the movie list")),
  2610. "up": (self.up, _("Open the movie list")),
  2611. "down": (self.down, _("Open the movie list"))
  2612. })
  2613. from Screens.PiPSetup import PiPSetup
  2614. class InfoBarExtensions:
  2615. EXTENSION_SINGLE = 0
  2616. EXTENSION_LIST = 1
  2617. def __init__(self):
  2618. self.list = []
  2619. if config.plisettings.ColouredButtons.value:
  2620. self["InstantExtensionsActions"] = HelpableActionMap(self, "InfobarExtensions",
  2621. {
  2622. "extensions": (self.bluekey_ex, _("Show extensions...")),
  2623. "quickmenu": (self.bluekey_qm, _("Show quickmenu...")),
  2624. "showPluginBrowser": (self.showPluginBrowser, _("Show the plugin browser..")),
  2625. "showEventInfo": (self.SelectopenEventView, _("Show the infomation on current event.")),
  2626. "openTimerList": (self.showTimerList, _("Show the list of timers.")),
  2627. "openAutoTimerList": (self.showAutoTimerList, _("Show the list of AutoTimers.")),
  2628. "openEPGSearch": (self.showEPGSearch, _("Search the epg for current event.")),
  2629. "openIMDB": (self.showIMDB, _("Search IMDb for information about current event.")),
  2630. "showMediaPlayer": (self.showMediaPlayer, _("Show the media player...")),
  2631. "openDreamPlex": (self.showDreamPlex, _("Show the DreamPlex player...")),
  2632. }, 1) # lower priority
  2633. else:
  2634. self["InstantExtensionsActions"] = HelpableActionMap(self, "InfobarExtensions",
  2635. {
  2636. "extensions": (self.bluekey_ex, _("view extensions...")),
  2637. "quickmenu": (self.bluekey_qm, _("Show quickmenu...")),
  2638. "showPluginBrowser": (self.showPluginBrowser, _("Show the plugin browser..")),
  2639. "showDreamPlex": (self.showDreamPlex, _("Show the DreamPlex player...")),
  2640. "showEventInfo": (self.SelectopenEventView, _("Show the infomation on current event.")),
  2641. "showMediaPlayer": (self.showMediaPlayer, _("Show the media player...")),
  2642. }, 1) # lower priority
  2643. self.addExtension(extension = self.getLogManager, type = InfoBarExtensions.EXTENSION_LIST)
  2644. self.addExtension(extension = self.getOsd3DSetup, type = InfoBarExtensions.EXTENSION_LIST)
  2645. self.addExtension(extension = self.getCCcamInfo, type = InfoBarExtensions.EXTENSION_LIST)
  2646. self.addExtension(extension = self.getOScamInfo, type = InfoBarExtensions.EXTENSION_LIST)
  2647. self.addExtension(extension = self.getSoftcamPanel, type = InfoBarExtensions.EXTENSION_LIST)
  2648. if config.usage.show_restart_network_extensionslist.getValue() is True:
  2649. self.addExtension(extension = self.getRestartNetwork, type = InfoBarExtensions.EXTENSION_LIST)
  2650. for p in plugins.getPlugins(PluginDescriptor.WHERE_EXTENSIONSINGLE):
  2651. p(self)
  2652. def bluekey_qm(self):
  2653. if config.workaround.blueswitch.value == "1":
  2654. self.showExtensionSelection()
  2655. else:
  2656. self.quickmenuStart()
  2657. def bluekey_ex(self):
  2658. if config.workaround.blueswitch.value == "1":
  2659. self.quickmenuStart()
  2660. else:
  2661. self.showExtensionSelection()
  2662. def quickmenuStart(self):
  2663. try:
  2664. if not self.session.pipshown:
  2665. from Plugins.Extensions.Infopanel.QuickMenu import QuickMenu
  2666. self.session.open(QuickMenu)
  2667. else:
  2668. self.showExtensionSelection()
  2669. except:
  2670. print "[INFOBARGENERICS] QuickMenu: error pipshow, starting Quick Menu"
  2671. from Plugins.Extensions.Infopanel.QuickMenu import QuickMenu
  2672. self.session.open(QuickMenu)
  2673. def SelectopenEventView(self):
  2674. try:
  2675. self.openEventView()
  2676. except:
  2677. pass
  2678. def getLMname(self):
  2679. return _("Log Manager")
  2680. def getLogManager(self):
  2681. if config.logmanager.showinextensions.value:
  2682. return [((boundFunction(self.getLMname), boundFunction(self.openLogManager), lambda: True), None)]
  2683. else:
  2684. return []
  2685. def getSoftcamPanelname(self):
  2686. return _("Softcam-Panel")
  2687. def getSoftcamPanel(self):
  2688. if config.plugins.showinfopanelextensions.value:
  2689. return [((boundFunction(self.getSoftcamPanelname), boundFunction(self.openSoftcamPanel), lambda: True), None)]
  2690. else:
  2691. return []
  2692. def getRestartNetworkname(self):
  2693. return _("Restart Network")
  2694. def getRestartNetwork(self):
  2695. return [((boundFunction(self.getRestartNetworkname), boundFunction(self.openRestartNetwork), lambda: True), None)]
  2696. def get3DSetupname(self):
  2697. return _("OSD 3D Setup")
  2698. def getOsd3DSetup(self):
  2699. if config.osd.show3dextensions .value:
  2700. return [((boundFunction(self.get3DSetupname), boundFunction(self.open3DSetup), lambda: True), None)]
  2701. else:
  2702. return []
  2703. def getCCname(self):
  2704. return _("CCcam Info")
  2705. def getCCcamInfo(self):
  2706. if pathExists('/usr/bin/'):
  2707. softcams = os.listdir('/usr/bin/')
  2708. for softcam in softcams:
  2709. if softcam.lower().startswith('cccam') and config.cccaminfo.showInExtensions.value:
  2710. return [((boundFunction(self.getCCname), boundFunction(self.openCCcamInfo), lambda: True), None)] or []
  2711. else:
  2712. return []
  2713. def getOSname(self):
  2714. return _("OScam Info")
  2715. def getOScamInfo(self):
  2716. if pathExists('/usr/bin/'):
  2717. softcams = os.listdir('/usr/bin/')
  2718. for softcam in softcams:
  2719. if softcam.lower().startswith('oscam') and config.oscaminfo.showInExtensions.value:
  2720. return [((boundFunction(self.getOSname), boundFunction(self.openOScamInfo), lambda: True), None)] or []
  2721. else:
  2722. return []
  2723. def addExtension(self, extension, key = None, type = EXTENSION_SINGLE):
  2724. self.list.append((type, extension, key))
  2725. if config.usage.sort_extensionslist.value:
  2726. self.list.sort()
  2727. def updateExtension(self, extension, key = None):
  2728. self.extensionsList.append(extension)
  2729. if key is not None:
  2730. if self.extensionKeys.has_key(key):
  2731. key = None
  2732. if key is None:
  2733. for x in self.availableKeys:
  2734. if not self.extensionKeys.has_key(x):
  2735. key = x
  2736. break
  2737. if key is not None:
  2738. self.extensionKeys[key] = len(self.extensionsList) - 1
  2739. def updateExtensions(self):
  2740. self.extensionsList = []
  2741. self.availableKeys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue" ]
  2742. self.extensionKeys = {}
  2743. for x in self.list:
  2744. if x[0] == self.EXTENSION_SINGLE:
  2745. self.updateExtension(x[1], x[2])
  2746. else:
  2747. for y in x[1]():
  2748. self.updateExtension(y[0], y[1])
  2749. def showExtensionSelection(self):
  2750. self.updateExtensions()
  2751. extensionsList = self.extensionsList[:]
  2752. keys = []
  2753. list = []
  2754. colorlist = []
  2755. for x in self.availableKeys:
  2756. if self.extensionKeys.has_key(x):
  2757. entry = self.extensionKeys[x]
  2758. extension = self.extensionsList[entry]
  2759. if extension[2]():
  2760. name = str(extension[0]())
  2761. if self.availableKeys.index(x) < 10:
  2762. list.append((extension[0](), extension))
  2763. else:
  2764. colorlist.append((extension[0](), extension))
  2765. keys.append(x)
  2766. extensionsList.remove(extension)
  2767. else:
  2768. extensionsList.remove(extension)
  2769. if config.usage.sort_extensionslist.value:
  2770. list.sort()
  2771. for x in colorlist:
  2772. list.append(x)
  2773. list.extend([(x[0](), x) for x in extensionsList])
  2774. keys += [""] * len(extensionsList)
  2775. self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys, skin_name = "ExtensionsList")
  2776. def extensionCallback(self, answer):
  2777. if answer is not None:
  2778. answer[1][1]()
  2779. def showPluginBrowser(self):
  2780. from Screens.PluginBrowser import PluginBrowser
  2781. self.session.open(PluginBrowser)
  2782. def openCCcamInfo(self):
  2783. from Screens.CCcamInfo import CCcamInfoMain
  2784. self.session.open(CCcamInfoMain)
  2785. def openOScamInfo(self):
  2786. from Screens.OScamInfo import OscamInfoMenu
  2787. self.session.open(OscamInfoMenu)
  2788. def showTimerList(self):
  2789. self.session.open(TimerEditList)
  2790. def openLogManager(self):
  2791. from Screens.LogManager import LogManager
  2792. self.session.open(LogManager)
  2793. def open3DSetup(self):
  2794. from Screens.UserInterfacePositioner import OSD3DSetupScreen
  2795. self.session.open(OSD3DSetupScreen)
  2796. def openSoftcamPanel(self):
  2797. from Plugins.Extensions.Infopanel.SoftcamPanel import SoftcamPanel
  2798. self.session.open(SoftcamPanel)
  2799. def openRestartNetwork(self):
  2800. try:
  2801. from Plugins.Extensions.Infopanel.RestartNetwork import RestartNetwork
  2802. self.session.open(RestartNetwork)
  2803. except:
  2804. print'[INFOBARGENERICS] failed to restart network'
  2805. def showAutoTimerList(self):
  2806. if os.path.exists("/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer/plugin.pyo"):
  2807. from Plugins.Extensions.AutoTimer.plugin import main, autostart
  2808. from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
  2809. from Plugins.Extensions.AutoTimer.AutoPoller import AutoPoller
  2810. self.autopoller = AutoPoller()
  2811. self.autotimer = AutoTimer()
  2812. try:
  2813. self.autotimer.readXml()
  2814. except SyntaxError as se:
  2815. self.session.open(
  2816. MessageBox,
  2817. _("Your config file is not well-formed:\n%s") % (str(se)),
  2818. type = MessageBox.TYPE_ERROR,
  2819. timeout = 10
  2820. )
  2821. return
  2822. # Do not run in background while editing, this might screw things up
  2823. if self.autopoller is not None:
  2824. self.autopoller.stop()
  2825. from Plugins.Extensions.AutoTimer.AutoTimerOverview import AutoTimerOverview
  2826. self.session.openWithCallback(
  2827. self.editCallback,
  2828. AutoTimerOverview,
  2829. self.autotimer
  2830. )
  2831. else:
  2832. self.session.open(MessageBox, _("The AutoTimer plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  2833. def editCallback(self, session):
  2834. # XXX: canceling of GUI (Overview) won't affect config values which might have been changed - is this intended?
  2835. # Don't parse EPG if editing was canceled
  2836. if session is not None:
  2837. # Save xml
  2838. self.autotimer.writeXml()
  2839. # Poll EPGCache
  2840. self.autotimer.parseEPG()
  2841. # Start autopoller again if wanted
  2842. if config.plugins.autotimer.autopoll.value:
  2843. if self.autopoller is None:
  2844. from Plugins.Extensions.AutoTimer.AutoPoller import AutoPoller
  2845. self.autopoller = AutoPoller()
  2846. self.autopoller.start()
  2847. # Remove instance if not running in background
  2848. else:
  2849. self.autopoller = None
  2850. self.autotimer = None
  2851. def showEPGSearch(self):
  2852. from Plugins.Extensions.EPGSearch.EPGSearch import EPGSearch
  2853. s = self.session.nav.getCurrentService()
  2854. if s:
  2855. info = s.info()
  2856. event = info.getEvent(0) # 0 = now, 1 = next
  2857. if event:
  2858. name = event and event.getEventName() or ''
  2859. else:
  2860. name = self.session.nav.getCurrentlyPlayingServiceOrGroup().toString()
  2861. name = name.split('/')
  2862. name = name[-1]
  2863. name = name.replace('.',' ')
  2864. name = name.split('-')
  2865. name = name[0]
  2866. if name.endswith(' '):
  2867. name = name[:-1]
  2868. if name:
  2869. self.session.open(EPGSearch, name, False)
  2870. else:
  2871. self.session.open(EPGSearch)
  2872. else:
  2873. self.session.open(EPGSearch)
  2874. def showIMDB(self):
  2875. if os.path.exists("/usr/lib/enigma2/python/Plugins/Extensions/IMDb/plugin.pyo"):
  2876. from Plugins.Extensions.IMDb.plugin import IMDB
  2877. s = self.session.nav.getCurrentService()
  2878. if s:
  2879. info = s.info()
  2880. event = info.getEvent(0) # 0 = now, 1 = next
  2881. name = event and event.getEventName() or ''
  2882. self.session.open(IMDB, name)
  2883. else:
  2884. self.session.open(MessageBox, _("The IMDb plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  2885. def showMediaPlayer(self):
  2886. if isinstance(self, InfoBarExtensions):
  2887. if isinstance(self, InfoBar):
  2888. try: # falls es nicht installiert ist
  2889. from Plugins.Extensions.MediaPlayer.plugin import MediaPlayer
  2890. self.session.open(MediaPlayer)
  2891. no_plugin = False
  2892. except Exception, e:
  2893. self.session.open(MessageBox, _("The MediaPlayer plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  2894. def showDreamPlex(self):
  2895. if os.path.exists("/usr/lib/enigma2/python/Plugins/Extensions/DreamPlex/plugin.pyo"):
  2896. from Plugins.Extensions.DreamPlex.plugin import DPS_MainMenu
  2897. self.session.open(DPS_MainMenu)
  2898. else:
  2899. self.session.open(MessageBox, _("The DreamPlex plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
  2900. from Tools.BoundFunction import boundFunction
  2901. import inspect
  2902. # depends on InfoBarExtensions
  2903. class InfoBarPlugins:
  2904. def __init__(self):
  2905. self.addExtension(extension = self.getPluginList, type = InfoBarExtensions.EXTENSION_LIST)
  2906. def getPluginName(self, name):
  2907. return name
  2908. def getPluginList(self):
  2909. l = []
  2910. for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU):
  2911. args = inspect.getargspec(p.__call__)[0]
  2912. if len(args) == 1 or len(args) == 2 and isinstance(self, InfoBarChannelSelection):
  2913. l.append(((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None, p.name))
  2914. l.sort(key = lambda e: e[2]) # sort by name
  2915. return l
  2916. def runPlugin(self, plugin):
  2917. if isinstance(self, InfoBarChannelSelection):
  2918. plugin(session = self.session, servicelist = self.servicelist)
  2919. else:
  2920. plugin(session = self.session)
  2921. from Components.Task import job_manager
  2922. class InfoBarJobman:
  2923. def __init__(self):
  2924. self.addExtension(extension = self.getJobList, type = InfoBarExtensions.EXTENSION_LIST)
  2925. def getJobList(self):
  2926. if config.usage.jobtaksextensions.value:
  2927. return [((boundFunction(self.getJobName, job), boundFunction(self.showJobView, job), lambda: True), None) for job in job_manager.getPendingJobs()]
  2928. else:
  2929. return []
  2930. def getJobName(self, job):
  2931. return "%s: %s (%d%%)" % (job.getStatustext(), job.name, int(100*job.progress/float(job.end)))
  2932. def showJobView(self, job):
  2933. from Screens.TaskView import JobView
  2934. job_manager.in_background = False
  2935. self.session.openWithCallback(self.JobViewCB, JobView, job)
  2936. def JobViewCB(self, in_background):
  2937. job_manager.in_background = in_background
  2938. # depends on InfoBarExtensions
  2939. class InfoBarPiP:
  2940. def __init__(self):
  2941. try:
  2942. self.session.pipshown
  2943. except:
  2944. self.session.pipshown = False
  2945. self.lastPiPService = None
  2946. if SystemInfo["PIPAvailable"] and isinstance(self, InfoBarEPG):
  2947. self["PiPActions"] = HelpableActionMap(self, "InfobarPiPActions",
  2948. {
  2949. "activatePiP": (self.activePiP, self.activePiPName),
  2950. })
  2951. if self.allowPiP:
  2952. self.addExtension((self.getShowHideName, self.showPiP, lambda: True), "blue")
  2953. self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
  2954. self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
  2955. self.addExtension((self.getTogglePipzapName, self.togglePipzap, self.pipShown), "red")
  2956. else:
  2957. self.addExtension((self.getShowHideName, self.showPiP, self.pipShown), "blue")
  2958. self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
  2959. self.lastPiPServiceTimeoutTimer = eTimer()
  2960. self.lastPiPServiceTimeoutTimer.callback.append(self.clearLastPiPService)
  2961. def pipShown(self):
  2962. return self.session.pipshown
  2963. def pipHandles0Action(self):
  2964. return self.pipShown() and config.usage.pip_zero_button.value != "standard"
  2965. def getShowHideName(self):
  2966. if self.session.pipshown:
  2967. return _("Disable Picture in Picture")
  2968. else:
  2969. return _("Activate Picture in Picture")
  2970. def getSwapName(self):
  2971. return _("Swap services")
  2972. def getMoveName(self):
  2973. return _("Picture in Picture Setup")
  2974. def getTogglePipzapName(self):
  2975. slist = self.servicelist
  2976. if slist and slist.dopipzap:
  2977. return _("Zap focus to main screen")
  2978. return _("Zap focus to Picture in Picture")
  2979. def togglePipzap(self):
  2980. if not self.session.pipshown:
  2981. self.showPiP()
  2982. slist = self.servicelist
  2983. if slist and self.session.pipshown:
  2984. slist.togglePipzap()
  2985. if slist.dopipzap:
  2986. currentServicePath = slist.getCurrentServicePath()
  2987. self.servicelist.setCurrentServicePath(self.session.pip.servicePath, doZap=False)
  2988. self.session.pip.servicePath = currentServicePath
  2989. def showPiP(self):
  2990. self.lastPiPServiceTimeoutTimer.stop()
  2991. slist = self.servicelist
  2992. if self.session.pipshown:
  2993. if slist and slist.dopipzap:
  2994. self.togglePipzap()
  2995. if self.session.pipshown:
  2996. lastPiPServiceTimeout = int(config.usage.pip_last_service_timeout.value)
  2997. if lastPiPServiceTimeout >= 0:
  2998. self.lastPiPService = self.session.pip.getCurrentServiceReference()
  2999. if lastPiPServiceTimeout:
  3000. self.lastPiPServiceTimeoutTimer.startLongTimer(lastPiPServiceTimeout)
  3001. del self.session.pip
  3002. if SystemInfo["LCDMiniTV"]:
  3003. if config.lcd.modepip.value >= "1":
  3004. f = open("/proc/stb/lcd/mode", "w")
  3005. f.write(config.lcd.modeminitv.value)
  3006. f.close()
  3007. self.session.pipshown = False
  3008. if hasattr(self, "ScreenSaverTimerStart"):
  3009. self.ScreenSaverTimerStart()
  3010. else:
  3011. service = self.session.nav.getCurrentService()
  3012. info = service and service.info()
  3013. if info:
  3014. xres = str(info.getInfo(iServiceInformation.sVideoWidth))
  3015. if info and int(xres) <= 720 or getMachineBuild() != 'blackbox7405':
  3016. self.session.pip = self.session.instantiateDialog(PictureInPicture)
  3017. self.session.pip.setAnimationMode(0)
  3018. self.session.pip.show()
  3019. newservice = self.lastPiPService or self.session.nav.getCurrentlyPlayingServiceReference() or self.servicelist.servicelist.getCurrent()
  3020. if self.session.pip.playService(newservice):
  3021. self.session.pipshown = True
  3022. self.session.pip.servicePath = self.servicelist.getCurrentServicePath()
  3023. if SystemInfo["LCDMiniTVPiP"] and int(config.lcd.minitvpipmode.value) >= 1:
  3024. print '[LCDMiniTV] enable PIP'
  3025. f = open("/proc/stb/lcd/mode", "w")
  3026. f.write(config.lcd.minitvpipmode.value)
  3027. f.close()
  3028. f = open("/proc/stb/vmpeg/1/dst_width", "w")
  3029. f.write("0")
  3030. f.close()
  3031. f = open("/proc/stb/vmpeg/1/dst_height", "w")
  3032. f.write("0")
  3033. f.close()
  3034. f = open("/proc/stb/vmpeg/1/dst_apply", "w")
  3035. f.write("1")
  3036. f.close()
  3037. else:
  3038. newservice = self.session.nav.getCurrentlyPlayingServiceReference() or self.servicelist.servicelist.getCurrent()
  3039. if self.session.pip.playService(newservice):
  3040. self.session.pipshown = True
  3041. self.session.pip.servicePath = self.servicelist.getCurrentServicePath()
  3042. if SystemInfo["LCDMiniTVPiP"] and int(config.lcd.minitvpipmode.value) >= 1:
  3043. print '[LCDMiniTV] enable PIP'
  3044. f = open("/proc/stb/lcd/mode", "w")
  3045. f.write(config.lcd.modepip.value)
  3046. f.close()
  3047. f = open("/proc/stb/vmpeg/1/dst_width", "w")
  3048. f.write("0")
  3049. f.close()
  3050. f = open("/proc/stb/vmpeg/1/dst_height", "w")
  3051. f.write("0")
  3052. f.close()
  3053. f = open("/proc/stb/vmpeg/1/dst_apply", "w")
  3054. f.write("1")
  3055. f.close()
  3056. else:
  3057. self.lastPiPService = None
  3058. self.session.pipshown = False
  3059. del self.session.pip
  3060. elif info:
  3061. self.session.open(MessageBox, _("Your %s %s does not support PiP HD") % (getMachineBrand(), getMachineName()), type = MessageBox.TYPE_INFO,timeout = 5 )
  3062. else:
  3063. self.session.open(MessageBox, _("No active channel found."), type = MessageBox.TYPE_INFO,timeout = 5 )
  3064. if self.session.pipshown and hasattr(self, "screenSaverTimer"):
  3065. self.screenSaverTimer.stop()
  3066. def clearLastPiPService(self):
  3067. self.lastPiPService = None
  3068. def activePiP(self):
  3069. if self.servicelist and self.servicelist.dopipzap or not self.session.pipshown:
  3070. self.showPiP()
  3071. else:
  3072. self.togglePipzap()
  3073. def activePiPName(self):
  3074. if self.servicelist and self.servicelist.dopipzap:
  3075. return _("Disable Picture in Picture")
  3076. if self.session.pipshown:
  3077. return _("Zap focus to Picture in Picture")
  3078. else:
  3079. return _("Activate Picture in Picture")
  3080. def swapPiP(self):
  3081. if self.pipShown():
  3082. swapservice = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  3083. pipref = self.session.pip.getCurrentService()
  3084. if swapservice and pipref and pipref.toString() != swapservice.toString():
  3085. currentServicePath = self.servicelist.getCurrentServicePath()
  3086. currentBouquet = self.servicelist and self.servicelist.getRoot()
  3087. self.servicelist.setCurrentServicePath(self.session.pip.servicePath, doZap=False)
  3088. self.session.pip.playService(swapservice)
  3089. self.session.nav.stopService() # stop portal
  3090. self.session.nav.playService(pipref, checkParentalControl=False, adjust=False)
  3091. self.session.pip.servicePath = currentServicePath
  3092. self.session.pip.servicePath[1] = currentBouquet
  3093. if self.servicelist.dopipzap:
  3094. # This unfortunately won't work with subservices
  3095. self.servicelist.setCurrentSelection(self.session.pip.getCurrentService())
  3096. def movePiP(self):
  3097. if self.pipShown():
  3098. self.session.open(PiPSetup, pip = self.session.pip)
  3099. def pipDoHandle0Action(self):
  3100. use = config.usage.pip_zero_button.value
  3101. if "swap" == use:
  3102. self.swapPiP()
  3103. elif "swapstop" == use:
  3104. self.swapPiP()
  3105. self.showPiP()
  3106. elif "stop" == use:
  3107. self.showPiP()
  3108. class InfoBarINFOpanel:
  3109. """INFO-Panel - handles the infoPanel action"""
  3110. def __init__(self):
  3111. self["INFOpanelActions"] = HelpableActionMap(self, "InfoBarINFOpanel",
  3112. {
  3113. "infoPanel": (self.selectRedKeytask, _("INFO-Panel...")),
  3114. "softcamPanel": (self.softcamPanel, _("Softcam-Panel...")),
  3115. })
  3116. self.onHBBTVActivation = [ ]
  3117. self.onRedButtonActivation = [ ]
  3118. def selectRedKeytask(self):
  3119. isWEBBROWSER = None
  3120. isHBBTV = None
  3121. if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/WebBrowser/browser.pyo"):
  3122. isWEBBROWSER = True
  3123. if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/HbbTV/plugin.pyo"):
  3124. isHBBTV = True
  3125. if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/E3Opera/plugin.pyo"):
  3126. isHBBTV = True
  3127. if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/NXHbbTV/plugin.pyo"):
  3128. isHBBTV = True
  3129. if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/OpenOpera/plugin.pyo"):
  3130. isHBBTV = True
  3131. if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/WebkitHbbTV/plugin.pyo"):
  3132. isHBBTV = True
  3133. if isWEBBROWSER or isHBBTV:
  3134. service = self.session.nav.getCurrentService()
  3135. info = service and service.info()
  3136. if info and info.getInfoString(iServiceInformation.sHBBTVUrl) != "":
  3137. for x in self.onHBBTVActivation:
  3138. x()
  3139. elif config.plugins.infopanel_redpanel.selection.value == '0':
  3140. self.instantRecord()
  3141. else:
  3142. self.doRedKeyTask()
  3143. elif config.plugins.infopanel_redpanel.selection.value == '0':
  3144. self.instantRecord()
  3145. else:
  3146. self.doRedKeyTask()
  3147. def doRedKeyTask(self):
  3148. try:
  3149. if config.plugins.infopanel_redpanel.selection.value =='0':
  3150. self.instantRecord()
  3151. elif config.plugins.infopanel_redpanel.selection.value =='1':
  3152. from Plugins.Extensions.Infopanel.plugin import Infopanel
  3153. self.session.open(Infopanel, services = self.servicelist)
  3154. elif config.plugins.infopanel_redpanel.selection.value == '2':
  3155. self.session.open(TimerEditList)
  3156. elif config.plugins.infopanel_redpanel.selection.value == '3':
  3157. self.showMovies()
  3158. elif config.plugins.infopanel_redpanel.selection.value == '4':
  3159. self.StartsoftcamPanel()
  3160. else:
  3161. self.StartPlugin(config.plugins.infopanel_redpanel.selection.value)
  3162. except:
  3163. print "Error on RedKeyTask !!"
  3164. def softcamPanel(self):
  3165. try:
  3166. if config.plugins.infopanel_redpanel.selectionLong.value =='0':
  3167. self.instantRecord()
  3168. elif config.plugins.infopanel_redpanel.selectionLong.value =='1':
  3169. from Plugins.Extensions.Infopanel.plugin import Infopanel
  3170. self.session.open(Infopanel, services = self.servicelist)
  3171. elif config.plugins.infopanel_redpanel.selectionLong.value == '2':
  3172. self.session.open(TimerEditList)
  3173. elif config.plugins.infopanel_redpanel.selectionLong.value == '3':
  3174. self.showMovies()
  3175. elif config.plugins.infopanel_redpanel.selectionLong.value == '4':
  3176. self.StartsoftcamPanel()
  3177. else:
  3178. self.StartPlugin(config.plugins.infopanel_redpanel.selectionLong.value)
  3179. except:
  3180. print "Error on RedKeyTask Long!!"
  3181. def StartsoftcamPanel(self):
  3182. try:
  3183. from Plugins.Extensions.Infopanel.SoftcamPanel import SoftcamPanel
  3184. self.session.open(SoftcamPanel)
  3185. except:
  3186. pass
  3187. def StartPlugin(self, name):
  3188. pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
  3189. for p in pluginlist:
  3190. if p.name == name:
  3191. p(session=self.session)
  3192. break
  3193. class InfoBarQuickMenu:
  3194. def __init__(self):
  3195. self["QuickMenuActions"] = HelpableActionMap(self, "InfoBarQuickMenu",
  3196. {
  3197. "quickmenu": (self.bluekey_qm, _("Quick Menu...")),
  3198. })
  3199. def bluekey_qm(self):
  3200. if config.workaround.blueswitch.value == "1":
  3201. self.showExtensionSelection()
  3202. else:
  3203. self.quickmenuStart()
  3204. def quickmenuStart(self):
  3205. try:
  3206. if not self.session.pipshown:
  3207. from Plugins.Extensions.Infopanel.QuickMenu import QuickMenu
  3208. self.session.open(QuickMenu)
  3209. else:
  3210. self.showExtensionSelection()
  3211. except:
  3212. print "[INFOBARGENERICS] QuickMenu: error pipshow, starting Quick Menu"
  3213. from Plugins.Extensions.Infopanel.QuickMenu import QuickMenu
  3214. self.session.open(QuickMenu)
  3215. class InfoBarInstantRecord:
  3216. """Instant Record - handles the instantRecord action in order to
  3217. start/stop instant records"""
  3218. def __init__(self):
  3219. self["InstantRecordActions"] = HelpableActionMap(self, "InfobarInstantRecord",
  3220. {
  3221. "instantRecord": (self.instantRecord, _("Instant recording...")),
  3222. })
  3223. self.SelectedInstantServiceRef = None
  3224. if isStandardInfoBar(self):
  3225. self.recording = []
  3226. else:
  3227. from Screens.InfoBar import InfoBar
  3228. InfoBarInstance = InfoBar.instance
  3229. if InfoBarInstance:
  3230. self.recording = InfoBarInstance.recording
  3231. self.saveTimeshiftEventPopupActive = False
  3232. def stopCurrentRecording(self, entry = -1):
  3233. if entry is not None and entry != -1:
  3234. self.session.nav.RecordTimer.removeEntry(self.recording[entry])
  3235. self.recording.remove(self.recording[entry])
  3236. def getProgramInfoAndEvent(self, info, name):
  3237. info["serviceref"] = hasattr(self, "SelectedInstantServiceRef") and self.SelectedInstantServiceRef or self.session.nav.getCurrentlyPlayingServiceOrGroup()
  3238. # try to get event info
  3239. event = None
  3240. try:
  3241. epg = eEPGCache.getInstance()
  3242. event = epg.lookupEventTime(info["serviceref"], -1, 0)
  3243. if event is None:
  3244. if hasattr(self, "SelectedInstantServiceRef") and self.SelectedInstantServiceRef:
  3245. service_info = eServiceCenter.getInstance().info(self.SelectedInstantServiceRef)
  3246. event = service_info and service_info.getEvent(self.SelectedInstantServiceRef)
  3247. else:
  3248. service = self.session.nav.getCurrentService()
  3249. event = service and service.info().getEvent(0)
  3250. except:
  3251. pass
  3252. info["event"] = event
  3253. info["name"] = name
  3254. info["description"] = ""
  3255. info["eventid"] = None
  3256. if event is not None:
  3257. curEvent = parseEvent(event)
  3258. info["name"] = curEvent[2]
  3259. info["description"] = curEvent[3]
  3260. info["eventid"] = curEvent[4]
  3261. info["end"] = curEvent[1]
  3262. def startInstantRecording(self, limitEvent = False):
  3263. begin = int(time())
  3264. end = begin + 3600 # dummy
  3265. name = "instant record"
  3266. info = { }
  3267. self.getProgramInfoAndEvent(info, name)
  3268. serviceref = info["serviceref"]
  3269. event = info["event"]
  3270. if event is not None:
  3271. if limitEvent:
  3272. end = info["end"]
  3273. else:
  3274. if limitEvent:
  3275. self.session.open(MessageBox, _("No event info found, recording indefinitely."), MessageBox.TYPE_INFO)
  3276. if isinstance(serviceref, eServiceReference):
  3277. serviceref = ServiceReference(serviceref)
  3278. recording = RecordTimerEntry(serviceref, begin, end, info["name"], info["description"], info["eventid"], dirname = preferredInstantRecordPath())
  3279. recording.dontSave = True
  3280. if event is None or limitEvent == False:
  3281. recording.autoincrease = True
  3282. recording.setAutoincreaseEnd()
  3283. simulTimerList = self.session.nav.RecordTimer.record(recording)
  3284. if simulTimerList is None: # no conflict
  3285. recording.autoincrease = False
  3286. self.recording.append(recording)
  3287. else:
  3288. if len(simulTimerList) > 1: # with other recording
  3289. name = simulTimerList[1].name
  3290. name_date = ' '.join((name, strftime('%F %T', localtime(simulTimerList[1].begin))))
  3291. # print "[TIMER] conflicts with", name_date
  3292. recording.autoincrease = True # start with max available length, then increment
  3293. if recording.setAutoincreaseEnd():
  3294. self.session.nav.RecordTimer.record(recording)
  3295. self.recording.append(recording)
  3296. self.session.open(MessageBox, _("Record time limited due to conflicting timer %s") % name_date, MessageBox.TYPE_INFO)
  3297. else:
  3298. self.session.open(MessageBox, _("Could not record due to conflicting timer %s") % name, MessageBox.TYPE_INFO)
  3299. else:
  3300. self.session.open(MessageBox, _("Could not record due to invalid service %s") % serviceref, MessageBox.TYPE_INFO)
  3301. recording.autoincrease = False
  3302. def isInstantRecordRunning(self):
  3303. # print "self.recording:", self.recording
  3304. if self.recording:
  3305. for x in self.recording:
  3306. if x.isRunning():
  3307. return True
  3308. return False
  3309. def recordQuestionCallback(self, answer):
  3310. # print 'recordQuestionCallback'
  3311. # print "pre:\n", self.recording
  3312. # print 'test1'
  3313. if answer is None or answer[1] == "no":
  3314. # print 'test2'
  3315. self.saveTimeshiftEventPopupActive = False
  3316. return
  3317. list = []
  3318. recording = self.recording[:]
  3319. for x in recording:
  3320. if not x in self.session.nav.RecordTimer.timer_list:
  3321. self.recording.remove(x)
  3322. elif x.dontSave and x.isRunning():
  3323. list.append((x, False))
  3324. if answer[1] == "changeduration":
  3325. if len(self.recording) == 1:
  3326. self.changeDuration(0)
  3327. else:
  3328. self.session.openWithCallback(self.changeDuration, TimerSelection, list)
  3329. elif answer[1] == "changeendtime":
  3330. if len(self.recording) == 1:
  3331. self.setEndtime(0)
  3332. else:
  3333. self.session.openWithCallback(self.setEndtime, TimerSelection, list)
  3334. elif answer[1] == "timer":
  3335. import TimerEdit
  3336. self.session.open(TimerEdit.TimerEditList)
  3337. elif answer[1] == "stop":
  3338. self.session.openWithCallback(self.stopCurrentRecording, TimerSelection, list)
  3339. elif answer[1] in ( "indefinitely" , "manualduration", "manualendtime", "event"):
  3340. self.startInstantRecording(limitEvent = answer[1] in ("event", "manualendtime") or False)
  3341. if answer[1] == "manualduration":
  3342. self.changeDuration(len(self.recording)-1)
  3343. elif answer[1] == "manualendtime":
  3344. self.setEndtime(len(self.recording)-1)
  3345. elif answer[1] == "savetimeshift":
  3346. # print 'test1'
  3347. if self.isSeekable() and self.pts_eventcount != self.pts_currplaying:
  3348. # print 'test2'
  3349. InfoBarTimeshift.SaveTimeshift(self, timeshiftfile="pts_livebuffer_%s" % self.pts_currplaying)
  3350. else:
  3351. # print 'test3'
  3352. Notifications.AddNotification(MessageBox,_("Timeshift will get saved at end of event!"), MessageBox.TYPE_INFO, timeout=5)
  3353. self.save_current_timeshift = True
  3354. config.timeshift.isRecording.value = True
  3355. elif answer[1] == "savetimeshiftEvent":
  3356. # print 'test4'
  3357. InfoBarTimeshift.saveTimeshiftEventPopup(self)
  3358. elif answer[1].startswith("pts_livebuffer") is True:
  3359. # print 'test2'
  3360. InfoBarTimeshift.SaveTimeshift(self, timeshiftfile=answer[1])
  3361. if answer[1] != "savetimeshiftEvent":
  3362. self.saveTimeshiftEventPopupActive = False
  3363. def setEndtime(self, entry):
  3364. if entry is not None and entry >= 0:
  3365. self.selectedEntry = entry
  3366. self.endtime=ConfigClock(default = self.recording[self.selectedEntry].end)
  3367. dlg = self.session.openWithCallback(self.TimeDateInputClosed, TimeDateInput, self.endtime)
  3368. dlg.setTitle(_("Please change recording endtime"))
  3369. def TimeDateInputClosed(self, ret):
  3370. if len(ret) > 1:
  3371. if ret[0]:
  3372. # print "stopping recording at", strftime("%F %T", localtime(ret[1]))
  3373. if self.recording[self.selectedEntry].end != ret[1]:
  3374. self.recording[self.selectedEntry].autoincrease = False
  3375. self.recording[self.selectedEntry].end = ret[1]
  3376. #else:
  3377. # if self.recording[self.selectedEntry].end != int(time()):
  3378. # self.recording[self.selectedEntry].autoincrease = False
  3379. # self.recording[self.selectedEntry].end = int(time())
  3380. self.session.nav.RecordTimer.timeChanged(self.recording[self.selectedEntry])
  3381. def changeDuration(self, entry):
  3382. if entry is not None and entry >= 0:
  3383. self.selectedEntry = entry
  3384. self.session.openWithCallback(self.inputCallback, InputBox, title=_("How many minutes do you want to record?"), text="5 ", maxSize=True, type=Input.NUMBER)
  3385. def inputCallback(self, value):
  3386. # print "stopping recording after", int(value), "minutes."
  3387. entry = self.recording[self.selectedEntry]
  3388. if value is not None:
  3389. if int(value) != 0:
  3390. entry.autoincrease = False
  3391. entry.end = int(time()) + 60 * int(value)
  3392. #else:
  3393. # if entry.end != int(time()):
  3394. # entry.autoincrease = False
  3395. # entry.end = int(time())
  3396. self.session.nav.RecordTimer.timeChanged(entry)
  3397. def isTimerRecordRunning(self):
  3398. identical = timers = 0
  3399. for timer in self.session.nav.RecordTimer.timer_list:
  3400. if timer.isRunning() and not timer.justplay:
  3401. timers += 1
  3402. if self.recording:
  3403. for x in self.recording:
  3404. if x.isRunning() and x == timer:
  3405. identical += 1
  3406. return timers > identical
  3407. def instantRecord(self, serviceRef=None):
  3408. self.SelectedInstantServiceRef = serviceRef
  3409. pirr = preferredInstantRecordPath()
  3410. if not findSafeRecordPath(pirr) and not findSafeRecordPath(defaultMoviePath()):
  3411. if not pirr:
  3412. pirr = ""
  3413. self.session.open(MessageBox, _("Missing ") + "\n" + pirr +
  3414. "\n" + _("No HDD found or HDD not initialized!"), MessageBox.TYPE_ERROR)
  3415. return
  3416. if isStandardInfoBar(self):
  3417. common = ((_("Add recording (stop after current event)"), "event"),
  3418. (_("Add recording (indefinitely)"), "indefinitely"),
  3419. (_("Add recording (enter recording duration)"), "manualduration"),
  3420. (_("Add recording (enter recording endtime)"), "manualendtime"),)
  3421. timeshiftcommon = ((_("Timeshift save recording (stop after current event)"), "savetimeshift"),
  3422. (_("Timeshift save recording (Select event)"), "savetimeshiftEvent"),)
  3423. else:
  3424. common = ()
  3425. timeshiftcommon = ()
  3426. if self.isInstantRecordRunning():
  3427. title =_("A recording is currently running.\nWhat do you want to do?")
  3428. list = ((_("Stop recording"), "stop"),) + common + \
  3429. ((_("Change recording (duration)"), "changeduration"),
  3430. (_("Change recording (endtime)"), "changeendtime"),)
  3431. if self.isTimerRecordRunning():
  3432. list += ((_("Stop timer recording"), "timer"),)
  3433. else:
  3434. title=_("Start recording?")
  3435. list = common
  3436. if self.isTimerRecordRunning():
  3437. list += ((_("Stop timer recording"), "timer"),)
  3438. if isStandardInfoBar(self) and self.timeshiftEnabled():
  3439. list = list + timeshiftcommon
  3440. if isStandardInfoBar(self):
  3441. list = list + ((_("Do not record"), "no"),)
  3442. if list:
  3443. self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox,title=title,list=list)
  3444. else:
  3445. return 0
  3446. class InfoBarAudioSelection:
  3447. def __init__(self):
  3448. self["AudioSelectionAction"] = HelpableActionMap(self, "InfobarAudioSelectionActions",
  3449. {
  3450. "audioSelection": (self.audioSelection, _("Audio options...")),
  3451. "audio_key": (self.audio_key, _("Audio options...")),
  3452. "audioSelectionLong": (self.audioSelectionLong, _("Toggle Digital downmix...")),
  3453. })
  3454. def audioSelection(self):
  3455. if not hasattr(self, "LongButtonPressed"):
  3456. self.LongButtonPressed = False
  3457. if not self.LongButtonPressed:
  3458. if config.plugins.infopanel_yellowkey.list.value == '0':
  3459. from Screens.AudioSelection import AudioSelection
  3460. self.session.openWithCallback(self.audioSelected, AudioSelection, infobar=self)
  3461. elif config.plugins.infopanel_yellowkey.list.value == '2':
  3462. global AUDIO
  3463. AUDIO = True
  3464. ToggleVideo()
  3465. elif config.plugins.infopanel_yellowkey.list.value == '3':
  3466. self.startTeletext()
  3467. else:
  3468. try:
  3469. self.startTimeshift()
  3470. except:
  3471. pass
  3472. else:
  3473. if config.plugins.infopanel_yellowkey.listLong.value == '0':
  3474. from Screens.AudioSelection import AudioSelection
  3475. self.session.openWithCallback(self.audioSelected, AudioSelection, infobar=self)
  3476. elif config.plugins.infopanel_yellowkey.listLong.value == '2':
  3477. global AUDIO
  3478. AUDIO = True
  3479. ToggleVideo()
  3480. elif config.plugins.infopanel_yellowkey.listLong.value == '3':
  3481. self.startTeletext()
  3482. else:
  3483. try:
  3484. self.startTimeshift()
  3485. except:
  3486. pass
  3487. def audio_key(self):
  3488. from Screens.AudioSelection import AudioSelection
  3489. self.session.openWithCallback(self.audioSelected, AudioSelection, infobar=self)
  3490. def audioSelected(self, ret=None):
  3491. print "[infobar::audioSelected]", ret
  3492. def audioSelectionLong(self):
  3493. if SystemInfo["CanDownmixAC3"] and self.LongButtonPressed:
  3494. if config.av.downmix_ac3.value:
  3495. message = _("Dobly Digital downmix is now") + " " + _("disabled")
  3496. print '[Audio] Dobly Digital downmix is now disabled'
  3497. config.av.downmix_ac3.setValue(False)
  3498. else:
  3499. config.av.downmix_ac3.setValue(True)
  3500. message = _("Dobly Digital downmix is now") + " " + _("enabled")
  3501. print '[Audio] Dobly Digital downmix is now enabled'
  3502. Notifications.AddPopup(text = message, type = MessageBox.TYPE_INFO, timeout = 5, id = "DDdownmixToggle")
  3503. class InfoBarSubserviceSelection:
  3504. def __init__(self):
  3505. self["SubserviceSelectionAction"] = HelpableActionMap(self, "InfobarSubserviceSelectionActions",
  3506. {
  3507. "GreenPressed": (self.GreenPressed),
  3508. "subserviceSelection": (self.subserviceSelection),
  3509. })
  3510. self["SubserviceQuickzapAction"] = HelpableActionMap(self, "InfobarSubserviceQuickzapActions",
  3511. {
  3512. "nextSubservice": (self.nextSubservice, _("Switch to next sub service")),
  3513. "prevSubservice": (self.prevSubservice, _("Switch to previous sub service"))
  3514. }, -1)
  3515. self["SubserviceQuickzapAction"].setEnabled(False)
  3516. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  3517. {
  3518. iPlayableService.evUpdatedEventInfo: self.checkSubservicesAvail
  3519. })
  3520. self.onClose.append(self.__removeNotifications)
  3521. self.bsel = None
  3522. def GreenPressed(self):
  3523. if not config.plisettings.Subservice.value:
  3524. self.openTimerList()
  3525. else:
  3526. service = self.session.nav.getCurrentService()
  3527. subservices = service and service.subServices()
  3528. if not subservices or subservices.getNumberOfSubservices() == 0:
  3529. if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/CustomSubservices/plugin.pyo"):
  3530. serviceRef = self.session.nav.getCurrentlyPlayingServiceReference()
  3531. subservices = self.getAvailableSubservices(serviceRef)
  3532. if not subservices or len(subservices) == 0:
  3533. self.openPluginBrowser()
  3534. else:
  3535. self.subserviceSelection()
  3536. else:
  3537. self.openPluginBrowser()
  3538. else:
  3539. self.subserviceSelection()
  3540. def openPluginBrowser(self):
  3541. try:
  3542. from Screens.PluginBrowser import PluginBrowser
  3543. self.session.open(PluginBrowser)
  3544. except:
  3545. pass
  3546. def __removeNotifications(self):
  3547. self.session.nav.event.remove(self.checkSubservicesAvail)
  3548. def checkSubservicesAvail(self):
  3549. service = self.session.nav.getCurrentService()
  3550. subservices = service and service.subServices()
  3551. if not subservices or subservices.getNumberOfSubservices() == 0:
  3552. self["SubserviceQuickzapAction"].setEnabled(False)
  3553. def nextSubservice(self):
  3554. self.changeSubservice(+1)
  3555. def prevSubservice(self):
  3556. self.changeSubservice(-1)
  3557. def changeSubservice(self, direction):
  3558. service = self.session.nav.getCurrentService()
  3559. subservices = service and service.subServices()
  3560. n = subservices and subservices.getNumberOfSubservices()
  3561. if n and n > 0:
  3562. selection = -1
  3563. ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  3564. idx = 0
  3565. while idx < n:
  3566. if subservices.getSubservice(idx).toString() == ref.toString():
  3567. selection = idx
  3568. break
  3569. idx += 1
  3570. if selection != -1:
  3571. selection += direction
  3572. if selection >= n:
  3573. selection=0
  3574. elif selection < 0:
  3575. selection=n-1
  3576. newservice = subservices.getSubservice(selection)
  3577. if newservice.valid():
  3578. del subservices
  3579. del service
  3580. self.session.nav.playService(newservice, False)
  3581. def subserviceSelection(self):
  3582. service = self.session.nav.getCurrentService()
  3583. subservices = service and service.subServices()
  3584. self.bouquets = self.servicelist.getBouquetList()
  3585. n = subservices and subservices.getNumberOfSubservices()
  3586. selection = 0
  3587. if n and n > 0:
  3588. ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  3589. tlist = []
  3590. idx = 0
  3591. while idx < n:
  3592. i = subservices.getSubservice(idx)
  3593. if i.toString() == ref.toString():
  3594. selection = idx
  3595. tlist.append((i.getName(), i))
  3596. idx += 1
  3597. if self.bouquets and len(self.bouquets):
  3598. keys = ["red", "blue", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
  3599. if config.usage.multibouquet.value:
  3600. tlist = [(_("Quick zap"), "quickzap", service.subServices()), (_("Add to bouquet"), "CALLFUNC", self.addSubserviceToBouquetCallback), ("--", "")] + tlist
  3601. else:
  3602. tlist = [(_("Quick zap"), "quickzap", service.subServices()), (_("Add to favourites"), "CALLFUNC", self.addSubserviceToBouquetCallback), ("--", "")] + tlist
  3603. selection += 3
  3604. else:
  3605. tlist = [(_("Quick zap"), "quickzap", service.subServices()), ("--", "")] + tlist
  3606. keys = ["red", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
  3607. selection += 2
  3608. self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a sub service..."), list = tlist, selection = selection, keys = keys, skin_name = "SubserviceSelection")
  3609. def subserviceSelected(self, service):
  3610. del self.bouquets
  3611. if not service is None:
  3612. if isinstance(service[1], str):
  3613. if service[1] == "quickzap":
  3614. from Screens.SubservicesQuickzap import SubservicesQuickzap
  3615. self.session.open(SubservicesQuickzap, service[2])
  3616. else:
  3617. self["SubserviceQuickzapAction"].setEnabled(True)
  3618. self.session.nav.playService(service[1], False)
  3619. def addSubserviceToBouquetCallback(self, service):
  3620. if not service is None:
  3621. if len(service) > 1 and isinstance(service[1], eServiceReference):
  3622. self.selectedSubservice = service
  3623. if self.bouquets is None:
  3624. cnt = 0
  3625. else:
  3626. cnt = len(self.bouquets)
  3627. if cnt > 1: # show bouquet list
  3628. self.bsel = self.session.openWithCallback(self.bouquetSelClosed, BouquetSelector, self.bouquets, self.addSubserviceToBouquet)
  3629. elif cnt == 1: # add to only one existing bouquet
  3630. self.addSubserviceToBouquet(self.bouquets[0][1])
  3631. self.session.open(MessageBox, _("Service has been added to the favourites."), MessageBox.TYPE_INFO)
  3632. else:
  3633. self.session.open(MessageBox, _("Service cant been added to the favourites."), MessageBox.TYPE_INFO)
  3634. def bouquetSelClosed(self, confirmed):
  3635. self.bsel = None
  3636. del self.selectedSubservice
  3637. if confirmed:
  3638. self.session.open(MessageBox, _("Service has been added to the selected bouquet."), MessageBox.TYPE_INFO)
  3639. def addSubserviceToBouquet(self, dest):
  3640. self.servicelist.addServiceToBouquet(dest, self.selectedSubservice[1])
  3641. if self.bsel:
  3642. self.bsel.close(True)
  3643. else:
  3644. del self.selectedSubservice
  3645. def openTimerList(self):
  3646. self.session.open(TimerEditList)
  3647. class InfoBarRedButton:
  3648. def __init__(self):
  3649. self["RedButtonActions"] = HelpableActionMap(self, "InfobarRedButtonActions",
  3650. {
  3651. "activateRedButton": (self.activateRedButton, _("Red button...")),
  3652. })
  3653. self.onHBBTVActivation = [ ]
  3654. self.onRedButtonActivation = [ ]
  3655. def activateRedButton(self):
  3656. service = self.session.nav.getCurrentService()
  3657. info = service and service.info()
  3658. if info and info.getInfoString(iServiceInformation.sHBBTVUrl) != "":
  3659. for x in self.onHBBTVActivation:
  3660. x()
  3661. elif False: # TODO: other red button services
  3662. for x in self.onRedButtonActivation:
  3663. x()
  3664. class InfoBarTimerButton:
  3665. def __init__(self):
  3666. self["TimerButtonActions"] = HelpableActionMap(self, "InfobarTimerButtonActions",
  3667. {
  3668. "timerSelection": (self.timerSelection, _("Timer selection...")),
  3669. })
  3670. def timerSelection(self):
  3671. from Screens.TimerEdit import TimerEditList
  3672. self.session.open(TimerEditList)
  3673. class InfoBarAspectSelection:
  3674. STATE_HIDDEN = 0
  3675. STATE_ASPECT = 1
  3676. STATE_RESOLUTION = 2
  3677. def __init__(self):
  3678. self["AspectSelectionAction"] = HelpableActionMap(self, "InfobarAspectSelectionActions",
  3679. {
  3680. "aspectSelection": (self.ExGreen_toggleGreen, _("Aspect list...")),
  3681. })
  3682. self.__ExGreen_state = self.STATE_HIDDEN
  3683. def ExGreen_doAspect(self):
  3684. print "do self.STATE_ASPECT"
  3685. self.__ExGreen_state = self.STATE_ASPECT
  3686. self.aspectSelection()
  3687. def ExGreen_doResolution(self):
  3688. print "do self.STATE_RESOLUTION"
  3689. self.__ExGreen_state = self.STATE_RESOLUTION
  3690. self.resolutionSelection()
  3691. def ExGreen_doHide(self):
  3692. print "do self.STATE_HIDDEN"
  3693. self.__ExGreen_state = self.STATE_HIDDEN
  3694. def ExGreen_toggleGreen(self, arg=""):
  3695. print self.__ExGreen_state
  3696. if self.__ExGreen_state == self.STATE_HIDDEN:
  3697. print "self.STATE_HIDDEN"
  3698. self.ExGreen_doAspect()
  3699. elif self.__ExGreen_state == self.STATE_ASPECT:
  3700. print "self.STATE_ASPECT"
  3701. self.ExGreen_doResolution()
  3702. elif self.__ExGreen_state == self.STATE_RESOLUTION:
  3703. print "self.STATE_RESOLUTION"
  3704. self.ExGreen_doHide()
  3705. def aspectSelection(self):
  3706. selection = 0
  3707. tlist = []
  3708. tlist.append((_("Resolution"), "resolution"))
  3709. tlist.append(("--", ""))
  3710. try:
  3711. policy = open("/proc/stb/video/policy_choices").read()[:-1].rstrip()
  3712. except IOError:
  3713. print "couldn't read available policymodes."
  3714. policy_available = [ ]
  3715. return
  3716. policy_available = policy.split(' ')
  3717. for x in policy_available:
  3718. tlist.append((x[0].upper() + x[1:], _(x)))
  3719. mode = open("/proc/stb/video/policy").read()[:-1]
  3720. print mode
  3721. for x in range(len(tlist)):
  3722. if tlist[x][1] == mode:
  3723. selection = x
  3724. keys = ["green", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]
  3725. self.session.openWithCallback(self.aspectSelected, ChoiceBox, title=_("Please select an aspect ratio..."), list = tlist, selection = selection, keys = keys)
  3726. def aspectSelected(self, aspect):
  3727. if not aspect is None:
  3728. if isinstance(aspect[1], str):
  3729. if aspect[1] == "":
  3730. self.ExGreen_doHide()
  3731. elif aspect[1] == "resolution":
  3732. self.ExGreen_toggleGreen()
  3733. else:
  3734. if aspect[1] == "letterbox":
  3735. f = open("/proc/stb/video/policy", "w")
  3736. f.write("panscan")
  3737. f.close()
  3738. elif aspect[1] == "panscan":
  3739. f = open("/proc/stb/video/policy", "w")
  3740. f.write("letterbox")
  3741. f.close()
  3742. else:
  3743. f = open("/proc/stb/video/policy", "w")
  3744. f.write(aspect[1])
  3745. f.close()
  3746. self.ExGreen_doHide()
  3747. else:
  3748. self.ExGreen_doHide()
  3749. return
  3750. class InfoBarResolutionSelection:
  3751. def __init__(self):
  3752. return
  3753. def resolutionSelection(self):
  3754. f = open("/proc/stb/vmpeg/0/xres", "r")
  3755. xresString = f.read()
  3756. f.close()
  3757. f = open("/proc/stb/vmpeg/0/yres", "r")
  3758. yresString = f.read()
  3759. f.close()
  3760. if getBoxType().startswith('azbox'):
  3761. fpsString = '50000'
  3762. else:
  3763. try:
  3764. f = open("/proc/stb/vmpeg/0/framerate", "r")
  3765. fpsString = f.read()
  3766. f.close()
  3767. except:
  3768. print"[InfoBarResolutionSelection] Error open /proc/stb/vmpeg/0/framerate !!"
  3769. fpsString = '50000'
  3770. xres = int(xresString, 16)
  3771. yres = int(yresString, 16)
  3772. fps = int(fpsString)
  3773. fpsFloat = float(fps)
  3774. fpsFloat = fpsFloat/1000
  3775. # do we need a new sorting with this way here?
  3776. # or should we disable some choices?
  3777. choices = []
  3778. if os.path.exists("/proc/stb/video/videomode_choices"):
  3779. f = open("/proc/stb/video/videomode_choices")
  3780. values = f.readline().replace("\n", "").replace("pal ", "").replace("ntsc ", "").split(" ", -1)
  3781. for x in values:
  3782. entry = x.replace('i50', 'i@50hz').replace('i60', 'i@60hz').replace('p23', 'p@23.976hz').replace('p24', 'p@24hz').replace('p25', 'p@25hz').replace('p29', 'p@29hz').replace('p30', 'p@30hz').replace('p50', 'p@50hz'), x
  3783. choices.append(entry)
  3784. f.close()
  3785. selection = 0
  3786. tlist = []
  3787. tlist.append((_("Exit"), "exit"))
  3788. tlist.append((_("Auto(not available)"), "auto"))
  3789. tlist.append(("Video: " + str(xres) + "x" + str(yres) + "@" + str(fpsFloat) + "hz", ""))
  3790. tlist.append(("--", ""))
  3791. if choices != []:
  3792. for x in choices:
  3793. tlist.append(x)
  3794. keys = ["green", "yellow", "blue", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]
  3795. mode = open("/proc/stb/video/videomode").read()[:-1]
  3796. print mode
  3797. for x in range(len(tlist)):
  3798. if tlist[x][1] == mode:
  3799. selection = x
  3800. self.session.openWithCallback(self.ResolutionSelected, ChoiceBox, title=_("Please select a resolution..."), list = tlist, selection = selection, keys = keys)
  3801. def ResolutionSelected(self, Resolution):
  3802. if not Resolution is None:
  3803. if isinstance(Resolution[1], str):
  3804. if Resolution[1] == "exit" or Resolution[1] == "" or Resolution[1] == "auto":
  3805. self.ExGreen_toggleGreen()
  3806. if Resolution[1] != "auto":
  3807. f = open("/proc/stb/video/videomode", "w")
  3808. f.write(Resolution[1])
  3809. f.close()
  3810. #from enigma import gMainDC
  3811. #gMainDC.getInstance().setResolution(-1, -1)
  3812. self.ExGreen_doHide()
  3813. else:
  3814. self.ExGreen_doHide()
  3815. return
  3816. class InfoBarVmodeButton:
  3817. def __init__(self):
  3818. self["VmodeButtonActions"] = HelpableActionMap(self, "InfobarVmodeButtonActions",
  3819. {
  3820. "vmodeSelection": (self.vmodeSelection, _("Letterbox zoom")),
  3821. })
  3822. def vmodeSelection(self):
  3823. self.session.open(VideoMode)
  3824. class VideoMode(Screen):
  3825. def __init__(self,session):
  3826. Screen.__init__(self, session)
  3827. self["videomode"] = Label()
  3828. self["actions"] = NumberActionMap( [ "InfobarVmodeButtonActions" ],
  3829. {
  3830. "vmodeSelection": self.selectVMode
  3831. })
  3832. self.Timer = eTimer()
  3833. self.Timer.callback.append(self.quit)
  3834. self.selectVMode()
  3835. def selectVMode(self):
  3836. policy = config.av.policy_43
  3837. if self.isWideScreen():
  3838. policy = config.av.policy_169
  3839. idx = policy.choices.index(policy.value)
  3840. idx = (idx + 1) % len(policy.choices)
  3841. policy.value = policy.choices[idx]
  3842. self["videomode"].setText(policy.value)
  3843. self.Timer.start(1000, True)
  3844. def isWideScreen(self):
  3845. from Components.Converter.ServiceInfo import WIDESCREEN
  3846. service = self.session.nav.getCurrentService()
  3847. info = service and service.info()
  3848. return info.getInfo(iServiceInformation.sAspect) in WIDESCREEN
  3849. def quit(self):
  3850. self.Timer.stop()
  3851. self.close()
  3852. class InfoBarAdditionalInfo:
  3853. def __init__(self):
  3854. self["RecordingPossible"] = Boolean(fixed=harddiskmanager.HDDCount() > 0)
  3855. self["TimeshiftPossible"] = self["RecordingPossible"]
  3856. self["ExtensionsAvailable"] = Boolean(fixed=1)
  3857. # TODO: these properties should be queried from the input device keymap
  3858. self["ShowTimeshiftOnYellow"] = Boolean(fixed=0)
  3859. self["ShowAudioOnYellow"] = Boolean(fixed=0)
  3860. self["ShowRecordOnRed"] = Boolean(fixed=0)
  3861. class InfoBarNotifications:
  3862. def __init__(self):
  3863. self.onExecBegin.append(self.checkNotifications)
  3864. Notifications.notificationAdded.append(self.checkNotificationsIfExecing)
  3865. self.onClose.append(self.__removeNotification)
  3866. def __removeNotification(self):
  3867. Notifications.notificationAdded.remove(self.checkNotificationsIfExecing)
  3868. def checkNotificationsIfExecing(self):
  3869. if self.execing:
  3870. self.checkNotifications()
  3871. def checkNotifications(self):
  3872. notifications = Notifications.notifications
  3873. if notifications:
  3874. n = notifications[0]
  3875. del notifications[0]
  3876. cb = n[0]
  3877. if n[3].has_key("onSessionOpenCallback"):
  3878. n[3]["onSessionOpenCallback"]()
  3879. del n[3]["onSessionOpenCallback"]
  3880. if cb:
  3881. dlg = self.session.openWithCallback(cb, n[1], *n[2], **n[3])
  3882. elif not Notifications.current_notifications and n[4] == "ZapError":
  3883. if n[3].has_key("timeout"):
  3884. del n[3]["timeout"]
  3885. n[3]["enable_input"] = False
  3886. dlg = self.session.instantiateDialog(n[1], *n[2], **n[3])
  3887. self.hide()
  3888. dlg.show()
  3889. self.notificationDialog = dlg
  3890. eActionMap.getInstance().bindAction('', -maxint - 1, self.keypressNotification)
  3891. else:
  3892. dlg = self.session.open(n[1], *n[2], **n[3])
  3893. # remember that this notification is currently active
  3894. d = (n[4], dlg)
  3895. Notifications.current_notifications.append(d)
  3896. dlg.onClose.append(boundFunction(self.__notificationClosed, d))
  3897. def closeNotificationInstantiateDialog(self):
  3898. if hasattr(self, "notificationDialog"):
  3899. self.session.deleteDialog(self.notificationDialog)
  3900. del self.notificationDialog
  3901. eActionMap.getInstance().unbindAction('', self.keypressNotification)
  3902. def keypressNotification(self, key, flag):
  3903. if flag:
  3904. self.closeNotificationInstantiateDialog()
  3905. def __notificationClosed(self, d):
  3906. Notifications.current_notifications.remove(d)
  3907. class InfoBarServiceNotifications:
  3908. def __init__(self):
  3909. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  3910. {
  3911. iPlayableService.evEnd: self.serviceHasEnded
  3912. })
  3913. def serviceHasEnded(self):
  3914. # print "service end!"
  3915. try:
  3916. self.setSeekState(self.SEEK_STATE_PLAY)
  3917. except:
  3918. pass
  3919. class InfoBarCueSheetSupport:
  3920. CUT_TYPE_IN = 0
  3921. CUT_TYPE_OUT = 1
  3922. CUT_TYPE_MARK = 2
  3923. CUT_TYPE_LAST = 3
  3924. ENABLE_RESUME_SUPPORT = False
  3925. def __init__(self, actionmap = "InfobarCueSheetActions"):
  3926. self["CueSheetActions"] = HelpableActionMap(self, actionmap,
  3927. {
  3928. "jumpPreviousMark": (self.jumpPreviousMark, _("Jump to previous marked position")),
  3929. "jumpNextMark": (self.jumpNextMark, _("Jump to next marked position")),
  3930. "toggleMark": (self.toggleMark, _("Toggle a cut mark at the current position"))
  3931. }, prio=1)
  3932. self.cut_list = [ ]
  3933. self.is_closing = False
  3934. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  3935. {
  3936. iPlayableService.evStart: self.__serviceStarted,
  3937. iPlayableService.evCuesheetChanged: self.downloadCuesheet,
  3938. })
  3939. def __serviceStarted(self):
  3940. if self.is_closing:
  3941. return
  3942. # print "new service started! trying to download cuts!"
  3943. self.downloadCuesheet()
  3944. self.resume_point = None
  3945. if self.ENABLE_RESUME_SUPPORT:
  3946. for (pts, what) in self.cut_list:
  3947. if what == self.CUT_TYPE_LAST:
  3948. last = pts
  3949. break
  3950. else:
  3951. last = getResumePoint(self.session)
  3952. if last is None:
  3953. return
  3954. # only resume if at least 10 seconds ahead, or <10 seconds before the end.
  3955. seekable = self.__getSeekable()
  3956. if seekable is None:
  3957. return # Should not happen?
  3958. length = seekable.getLength() or (None,0)
  3959. # print "seekable.getLength() returns:", length
  3960. # Hmm, this implies we don't resume if the length is unknown...
  3961. if (last > 900000) and (not length[1] or (last < length[1] - 900000)):
  3962. self.resume_point = last
  3963. l = last / 90000
  3964. if "ask" in config.usage.on_movie_start.value or not length[1]:
  3965. Notifications.AddNotificationWithCallback(self.playLastCB, MessageBox, _("Do you want to resume this playback?") + "\n" + (_("Resume position at %s") % ("%d:%02d:%02d" % (l/3600, l%3600/60, l%60))), timeout=30, default="yes" in config.usage.on_movie_start.value)
  3966. elif config.usage.on_movie_start.value == "resume":
  3967. Notifications.AddNotificationWithCallback(self.playLastCB, MessageBox, _("Resuming playback"), timeout=2, type=MessageBox.TYPE_INFO)
  3968. def playLastCB(self, answer):
  3969. if answer == True and self.resume_point:
  3970. self.doSeek(self.resume_point)
  3971. self.hideAfterResume()
  3972. def hideAfterResume(self):
  3973. if isinstance(self, InfoBarShowHide):
  3974. self.hide()
  3975. def __getSeekable(self):
  3976. service = self.session.nav.getCurrentService()
  3977. if service is None:
  3978. return None
  3979. return service.seek()
  3980. def cueGetCurrentPosition(self):
  3981. seek = self.__getSeekable()
  3982. if seek is None:
  3983. return None
  3984. r = seek.getPlayPosition()
  3985. if r[0]:
  3986. return None
  3987. return long(r[1])
  3988. def cueGetEndCutPosition(self):
  3989. ret = False
  3990. isin = True
  3991. for cp in self.cut_list:
  3992. if cp[1] == self.CUT_TYPE_OUT:
  3993. if isin:
  3994. isin = False
  3995. ret = cp[0]
  3996. elif cp[1] == self.CUT_TYPE_IN:
  3997. isin = True
  3998. return ret
  3999. def jumpPreviousNextMark(self, cmp, start=False):
  4000. current_pos = self.cueGetCurrentPosition()
  4001. if current_pos is None:
  4002. return False
  4003. mark = self.getNearestCutPoint(current_pos, cmp=cmp, start=start)
  4004. if mark is not None:
  4005. pts = mark[0]
  4006. else:
  4007. return False
  4008. self.doSeek(pts)
  4009. return True
  4010. def jumpPreviousMark(self):
  4011. # we add 5 seconds, so if the play position is <5s after
  4012. # the mark, the mark before will be used
  4013. self.jumpPreviousNextMark(lambda x: -x-5*90000, start=True)
  4014. def jumpNextMark(self):
  4015. if not self.jumpPreviousNextMark(lambda x: x-90000):
  4016. self.doSeek(-1)
  4017. def getNearestCutPoint(self, pts, cmp=abs, start=False):
  4018. # can be optimized
  4019. beforecut = True
  4020. nearest = None
  4021. bestdiff = -1
  4022. instate = True
  4023. if start:
  4024. bestdiff = cmp(0 - pts)
  4025. if bestdiff >= 0:
  4026. nearest = [0, False]
  4027. for cp in self.cut_list:
  4028. if beforecut and cp[1] in (self.CUT_TYPE_IN, self.CUT_TYPE_OUT):
  4029. beforecut = False
  4030. if cp[1] == self.CUT_TYPE_IN: # Start is here, disregard previous marks
  4031. diff = cmp(cp[0] - pts)
  4032. if start and diff >= 0:
  4033. nearest = cp
  4034. bestdiff = diff
  4035. else:
  4036. nearest = None
  4037. bestdiff = -1
  4038. if cp[1] == self.CUT_TYPE_IN:
  4039. instate = True
  4040. elif cp[1] == self.CUT_TYPE_OUT:
  4041. instate = False
  4042. elif cp[1] in (self.CUT_TYPE_MARK, self.CUT_TYPE_LAST):
  4043. diff = cmp(cp[0] - pts)
  4044. if instate and diff >= 0 and (nearest is None or bestdiff > diff):
  4045. nearest = cp
  4046. bestdiff = diff
  4047. return nearest
  4048. def toggleMark(self, onlyremove=False, onlyadd=False, tolerance=5*90000, onlyreturn=False):
  4049. current_pos = self.cueGetCurrentPosition()
  4050. if current_pos is None:
  4051. # print "not seekable"
  4052. return
  4053. nearest_cutpoint = self.getNearestCutPoint(current_pos)
  4054. if nearest_cutpoint is not None and abs(nearest_cutpoint[0] - current_pos) < tolerance:
  4055. if onlyreturn:
  4056. return nearest_cutpoint
  4057. if not onlyadd:
  4058. self.removeMark(nearest_cutpoint)
  4059. elif not onlyremove and not onlyreturn:
  4060. self.addMark((current_pos, self.CUT_TYPE_MARK))
  4061. if onlyreturn:
  4062. return None
  4063. def addMark(self, point):
  4064. insort(self.cut_list, point)
  4065. self.uploadCuesheet()
  4066. self.showAfterCuesheetOperation()
  4067. def removeMark(self, point):
  4068. self.cut_list.remove(point)
  4069. self.uploadCuesheet()
  4070. self.showAfterCuesheetOperation()
  4071. def showAfterCuesheetOperation(self):
  4072. if isinstance(self, InfoBarShowHide):
  4073. self.doShow()
  4074. def __getCuesheet(self):
  4075. service = self.session.nav.getCurrentService()
  4076. if service is None:
  4077. return None
  4078. return service.cueSheet()
  4079. def uploadCuesheet(self):
  4080. cue = self.__getCuesheet()
  4081. if cue is None:
  4082. # print "upload failed, no cuesheet interface"
  4083. return
  4084. cue.setCutList(self.cut_list)
  4085. def downloadCuesheet(self):
  4086. cue = self.__getCuesheet()
  4087. if cue is None:
  4088. # print "download failed, no cuesheet interface"
  4089. self.cut_list = [ ]
  4090. else:
  4091. self.cut_list = cue.getCutList()
  4092. class InfoBarSummary(Screen):
  4093. skin = """
  4094. <screen position="0,0" size="132,64">
  4095. <widget source="global.CurrentTime" render="Label" position="62,46" size="82,18" font="Regular;16" >
  4096. <convert type="ClockToText">WithSeconds</convert>
  4097. </widget>
  4098. <widget source="session.RecordState" render="FixedLabel" text=" " position="62,46" size="82,18" zPosition="1" >
  4099. <convert type="ConfigEntryTest">config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean</convert>
  4100. <convert type="ConditionalShowHide">Blink</convert>
  4101. </widget>
  4102. <widget source="session.CurrentService" render="Label" position="6,4" size="120,42" font="Regular;18" >
  4103. <convert type="ServiceName">Name</convert>
  4104. </widget>
  4105. <widget source="session.Event_Now" render="Progress" position="6,46" size="46,18" borderWidth="1" >
  4106. <convert type="EventTime">Progress</convert>
  4107. </widget>
  4108. </screen>"""
  4109. # for picon: (path="piconlcd" will use LCD picons)
  4110. # <widget source="session.CurrentService" render="Picon" position="6,0" size="120,64" path="piconlcd" >
  4111. # <convert type="ServiceName">Reference</convert>
  4112. # </widget>
  4113. class InfoBarSummarySupport:
  4114. def __init__(self):
  4115. pass
  4116. def createSummary(self):
  4117. return InfoBarSummary
  4118. class InfoBarMoviePlayerSummary(Screen):
  4119. skin = """
  4120. <screen position="0,0" size="132,64">
  4121. <widget source="global.CurrentTime" render="Label" position="62,46" size="64,18" font="Regular;16" halign="right" >
  4122. <convert type="ClockToText">WithSeconds</convert>
  4123. </widget>
  4124. <widget source="session.RecordState" render="FixedLabel" text=" " position="62,46" size="64,18" zPosition="1" >
  4125. <convert type="ConfigEntryTest">config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean</convert>
  4126. <convert type="ConditionalShowHide">Blink</convert>
  4127. </widget>
  4128. <widget source="session.CurrentService" render="Label" position="6,4" size="120,42" font="Regular;18" >
  4129. <convert type="ServiceName">Name</convert>
  4130. </widget>
  4131. <widget source="session.CurrentService" render="Progress" position="6,46" size="56,18" borderWidth="1" >
  4132. <convert type="ServicePosition">Position</convert>
  4133. </widget>
  4134. </screen>"""
  4135. def __init__(self, session, parent):
  4136. Screen.__init__(self, session, parent = parent)
  4137. self["state_summary"] = StaticText("")
  4138. self["speed_summary"] = StaticText("")
  4139. self["statusicon_summary"] = MultiPixmap()
  4140. self.onShow.append(self.addWatcher)
  4141. self.onHide.append(self.removeWatcher)
  4142. def addWatcher(self):
  4143. self.parent.onChangedEntry.append(self.selectionChanged)
  4144. def removeWatcher(self):
  4145. self.parent.onChangedEntry.remove(self.selectionChanged)
  4146. def selectionChanged(self, state_summary, speed_summary, statusicon_summary):
  4147. self["state_summary"].setText(state_summary)
  4148. self["speed_summary"].setText(speed_summary)
  4149. self["statusicon_summary"].setPixmapNum(int(statusicon_summary))
  4150. class InfoBarMoviePlayerSummarySupport:
  4151. def __init__(self):
  4152. pass
  4153. def createSummary(self):
  4154. return InfoBarMoviePlayerSummary
  4155. class InfoBarTeletextPlugin:
  4156. def __init__(self):
  4157. self.teletext_plugin = None
  4158. for p in plugins.getPlugins(PluginDescriptor.WHERE_TELETEXT):
  4159. self.teletext_plugin = p
  4160. if self.teletext_plugin is not None:
  4161. self["TeletextActions"] = HelpableActionMap(self, "InfobarTeletextActions",
  4162. {
  4163. "startTeletext": (self.startTeletext, _("View teletext..."))
  4164. })
  4165. else:
  4166. print "no teletext plugin found!"
  4167. def startTeletext(self):
  4168. self.teletext_plugin and self.teletext_plugin(session=self.session, service=self.session.nav.getCurrentService())
  4169. class InfoBarSubtitleSupport(object):
  4170. def __init__(self):
  4171. object.__init__(self)
  4172. self["SubtitleSelectionAction"] = HelpableActionMap(self, "InfobarSubtitleSelectionActions",
  4173. {
  4174. "subtitleSelection": (self.subtitleSelection, _("Subtitle selection...")),
  4175. })
  4176. self.selected_subtitle = None
  4177. if isStandardInfoBar(self):
  4178. self.subtitle_window = self.session.instantiateDialog(SubtitleDisplay)
  4179. self.subtitle_window.setAnimationMode(0)
  4180. else:
  4181. from Screens.InfoBar import InfoBar
  4182. self.subtitle_window = InfoBar.instance.subtitle_window
  4183. self.subtitle_window.hide()
  4184. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  4185. {
  4186. iPlayableService.evStart: self.__serviceChanged,
  4187. iPlayableService.evEnd: self.__serviceChanged,
  4188. iPlayableService.evUpdatedInfo: self.__updatedInfo
  4189. })
  4190. def getCurrentServiceSubtitle(self):
  4191. service = self.session.nav.getCurrentService()
  4192. return service and service.subtitle()
  4193. def subtitleSelection(self):
  4194. service = self.session.nav.getCurrentService()
  4195. subtitle = service and service.subtitle()
  4196. subtitlelist = subtitle and subtitle.getSubtitleList()
  4197. if self.selected_subtitle or subtitlelist and len(subtitlelist)>0:
  4198. from Screens.AudioSelection import SubtitleSelection
  4199. self.session.open(SubtitleSelection, self)
  4200. else:
  4201. return 0
  4202. def __serviceChanged(self):
  4203. if self.selected_subtitle:
  4204. self.selected_subtitle = None
  4205. self.subtitle_window.hide()
  4206. def __updatedInfo(self):
  4207. if not self.selected_subtitle:
  4208. subtitle = self.getCurrentServiceSubtitle()
  4209. cachedsubtitle = subtitle.getCachedSubtitle()
  4210. if cachedsubtitle:
  4211. self.enableSubtitle(cachedsubtitle)
  4212. def enableSubtitle(self, selectedSubtitle):
  4213. subtitle = self.getCurrentServiceSubtitle()
  4214. self.selected_subtitle = selectedSubtitle
  4215. if subtitle and self.selected_subtitle:
  4216. subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
  4217. self.subtitle_window.show()
  4218. else:
  4219. if subtitle:
  4220. subtitle.disableSubtitles(self.subtitle_window.instance)
  4221. self.subtitle_window.hide()
  4222. def restartSubtitle(self):
  4223. if self.selected_subtitle:
  4224. self.enableSubtitle(self.selected_subtitle)
  4225. class InfoBarServiceErrorPopupSupport:
  4226. def __init__(self):
  4227. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  4228. {
  4229. iPlayableService.evTuneFailed: self.__tuneFailed,
  4230. iPlayableService.evTunedIn: self.__serviceStarted,
  4231. iPlayableService.evStart: self.__serviceStarted
  4232. })
  4233. self.__serviceStarted()
  4234. def __serviceStarted(self):
  4235. self.closeNotificationInstantiateDialog()
  4236. self.last_error = None
  4237. Notifications.RemovePopup(id = "ZapError")
  4238. def __tuneFailed(self):
  4239. if not config.usage.hide_zap_errors.value or not config.usage.remote_fallback_enabled.value:
  4240. service = self.session.nav.getCurrentService()
  4241. info = service and service.info()
  4242. error = info and info.getInfo(iServiceInformation.sDVBState)
  4243. if not config.usage.remote_fallback_enabled.value and (error == eDVBServicePMTHandler.eventMisconfiguration or error == eDVBServicePMTHandler.eventNoResources):
  4244. self.session.nav.currentlyPlayingServiceReference = None
  4245. self.session.nav.currentlyPlayingServiceOrGroup = None
  4246. if error == self.last_error:
  4247. error = None
  4248. else:
  4249. self.last_error = error
  4250. error = {
  4251. eDVBServicePMTHandler.eventNoResources: _("No free tuner!"),
  4252. eDVBServicePMTHandler.eventTuneFailed: _("Tune failed!"),
  4253. eDVBServicePMTHandler.eventNoPAT: _("No data on transponder!\n(Timeout reading PAT)"),
  4254. eDVBServicePMTHandler.eventNoPATEntry: _("Service not found!\n(SID not found in PAT)"),
  4255. eDVBServicePMTHandler.eventNoPMT: _("Service invalid!\n(Timeout reading PMT)"),
  4256. eDVBServicePMTHandler.eventNewProgramInfo: None,
  4257. eDVBServicePMTHandler.eventTuned: None,
  4258. eDVBServicePMTHandler.eventSOF: None,
  4259. eDVBServicePMTHandler.eventEOF: None,
  4260. eDVBServicePMTHandler.eventMisconfiguration: _("Service unavailable!\nCheck tuner configuration!"),
  4261. }.get(error) #this returns None when the key not exist in the dict
  4262. if error and not config.usage.hide_zap_errors.value:
  4263. self.closeNotificationInstantiateDialog()
  4264. if hasattr(self, "dishDialog") and not self.dishDialog.dishState():
  4265. Notifications.AddPopup(text = error, type = MessageBox.TYPE_ERROR, timeout = 5, id = "ZapError")
  4266. class InfoBarZoom:
  4267. def __init__(self):
  4268. self.zoomrate=0
  4269. self.zoomin=1
  4270. self["ZoomActions"] = HelpableActionMap(self, "InfobarZoomActions",
  4271. {
  4272. "ZoomInOut":(self.ZoomInOut, _("Zoom In/Out TV...")),
  4273. "ZoomOff":(self.ZoomOff, _("Zoom Off...")),
  4274. }, prio=2)
  4275. def ZoomInOut(self):
  4276. zoomval=0
  4277. if self.zoomrate > 3:
  4278. self.zoomin = 0
  4279. elif self.zoomrate < -9:
  4280. self.zoomin = 1
  4281. if self.zoomin == 1:
  4282. self.zoomrate += 1
  4283. else:
  4284. self.zoomrate -= 1
  4285. if self.zoomrate < 0:
  4286. zoomval=abs(self.zoomrate)+10
  4287. else:
  4288. zoomval=self.zoomrate
  4289. # print "zoomRate:", self.zoomrate
  4290. # print "zoomval:", zoomval
  4291. file = open("/proc/stb/vmpeg/0/zoomrate", "w")
  4292. file.write('%d' % int(zoomval))
  4293. file.close()
  4294. def ZoomOff(self):
  4295. self.zoomrate = 0
  4296. self.zoomin = 1
  4297. f = open("/proc/stb/vmpeg/0/zoomrate", "w")
  4298. f.write(str(0))
  4299. f.close()
  4300. class InfoBarHdmi:
  4301. def __init__(self):
  4302. self.hdmi_enabled = False
  4303. self.hdmi_enabled_full = False
  4304. self.hdmi_enabled_pip = False
  4305. if getMachineBuild() in ('inihdp', 'hd2400', 'dm7080', 'dm820'):
  4306. if not self.hdmi_enabled_full:
  4307. self.addExtension((self.getHDMIInFullScreen, self.HDMIInFull, lambda: True), "blue")
  4308. if not self.hdmi_enabled_pip:
  4309. self.addExtension((self.getHDMIInPiPScreen, self.HDMIInPiP, lambda: True), "green")
  4310. self["HDMIActions"] = HelpableActionMap(self, "InfobarHDMIActions",
  4311. {
  4312. "HDMIin":(self.HDMIIn, _("Switch to HDMI in mode")),
  4313. "HDMIinLong":(self.HDMIInLong, _("Switch to HDMI in mode")),
  4314. }, prio=2)
  4315. def HDMIInLong(self):
  4316. if self.LongButtonPressed:
  4317. if not hasattr(self.session, 'pip') and not self.session.pipshown:
  4318. self.session.pip = self.session.instantiateDialog(PictureInPicture)
  4319. self.session.pip.playService(eServiceReference('8192:0:1:0:0:0:0:0:0:0:'))
  4320. self.session.pip.show()
  4321. self.session.pipshown = True
  4322. else:
  4323. curref = self.session.pip.getCurrentService()
  4324. if curref and curref.type != 8192:
  4325. self.session.pip.playService(eServiceReference('8192:0:1:0:0:0:0:0:0:0:'))
  4326. else:
  4327. self.session.pipshown = False
  4328. del self.session.pip
  4329. def HDMIIn(self):
  4330. if not self.LongButtonPressed:
  4331. slist = self.servicelist
  4332. curref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  4333. if curref and curref.type != 8192:
  4334. self.session.nav.playService(eServiceReference('8192:0:1:0:0:0:0:0:0:0:'))
  4335. else:
  4336. self.session.nav.playService(slist.servicelist.getCurrent())
  4337. def getHDMIInFullScreen(self):
  4338. if not self.hdmi_enabled_full:
  4339. return _("Turn on HDMI-IN Full screen mode")
  4340. else:
  4341. return _("Turn off HDMI-IN Full screen mode")
  4342. def getHDMIInPiPScreen(self):
  4343. if not self.hdmi_enabled_pip:
  4344. return _("Turn on HDMI-IN PiP mode")
  4345. else:
  4346. return _("Turn off HDMI-IN PiP mode")
  4347. def HDMIInPiP(self):
  4348. if getMachineBuild() in ('dm7080', 'dm820'):
  4349. f=open("/proc/stb/hdmi-rx/0/hdmi_rx_monitor","r")
  4350. check=f.read()
  4351. f.close()
  4352. if check.startswith("off"):
  4353. f=open("/proc/stb/audio/hdmi_rx_monitor","w")
  4354. f.write("on")
  4355. f.close()
  4356. f=open("/proc/stb/hdmi-rx/0/hdmi_rx_monitor","w")
  4357. f.write("on")
  4358. f.close()
  4359. else:
  4360. f=open("/proc/stb/audio/hdmi_rx_monitor","w")
  4361. f.write("off")
  4362. f.close()
  4363. f=open("/proc/stb/hdmi-rx/0/hdmi_rx_monitor","w")
  4364. f.write("off")
  4365. f.close()
  4366. else:
  4367. if not hasattr(self.session, 'pip') and not self.session.pipshown:
  4368. self.hdmi_enabled_pip = True
  4369. self.session.pip = self.session.instantiateDialog(PictureInPicture)
  4370. self.session.pip.playService(eServiceReference('8192:0:1:0:0:0:0:0:0:0:'))
  4371. self.session.pip.show()
  4372. self.session.pipshown = True
  4373. self.session.pip.servicePath = self.servicelist.getCurrentServicePath()
  4374. else:
  4375. curref = self.session.pip.getCurrentService()
  4376. if curref and curref.type != 8192:
  4377. self.hdmi_enabled_pip = True
  4378. self.session.pip.playService(eServiceReference('8192:0:1:0:0:0:0:0:0:0:'))
  4379. self.session.pip.servicePath = self.servicelist.getCurrentServicePath()
  4380. else:
  4381. self.hdmi_enabled_pip = False
  4382. self.session.pipshown = False
  4383. del self.session.pip
  4384. def HDMIInFull(self):
  4385. if getMachineBuild() in ('dm7080', 'dm820'):
  4386. f=open("/proc/stb/hdmi-rx/0/hdmi_rx_monitor","r")
  4387. check=f.read()
  4388. f.close()
  4389. if check.startswith("off"):
  4390. f=open("/proc/stb/video/videomode","r")
  4391. self.oldvideomode=f.read()
  4392. f.close()
  4393. f=open("/proc/stb/video/videomode_50hz","r")
  4394. self.oldvideomode_50hz=f.read()
  4395. f.close()
  4396. f=open("/proc/stb/video/videomode_60hz","r")
  4397. self.oldvideomode_60hz=f.read()
  4398. f.close()
  4399. f=open("/proc/stb/video/videomode","w")
  4400. f.write("720p")
  4401. f.close()
  4402. f=open("/proc/stb/audio/hdmi_rx_monitor","w")
  4403. f.write("on")
  4404. f.close()
  4405. f=open("/proc/stb/hdmi-rx/0/hdmi_rx_monitor","w")
  4406. f.write("on")
  4407. f.close()
  4408. else:
  4409. f=open("/proc/stb/audio/hdmi_rx_monitor","w")
  4410. f.write("off")
  4411. f.close()
  4412. f=open("/proc/stb/hdmi-rx/0/hdmi_rx_monitor","w")
  4413. f.write("off")
  4414. f.close()
  4415. f=open("/proc/stb/video/videomode","w")
  4416. f.write(self.oldvideomode)
  4417. f.close()
  4418. f=open("/proc/stb/video/videomode_50hz","w")
  4419. f.write(self.oldvideomode_50hz)
  4420. f.close()
  4421. f=open("/proc/stb/video/videomode_60hz","w")
  4422. f.write(self.oldvideomode_60hz)
  4423. f.close()
  4424. else:
  4425. slist = self.servicelist
  4426. curref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
  4427. if curref and curref.type != 8192:
  4428. self.hdmi_enabled_full = True
  4429. self.session.nav.playService(eServiceReference('8192:0:1:0:0:0:0:0:0:0:'))
  4430. else:
  4431. self.hdmi_enabled_full = False
  4432. self.session.nav.playService(slist.servicelist.getCurrent())
  4433. class InfoBarSleepTimer:
  4434. def __init__(self):
  4435. self.sleepTimer = eTimer()
  4436. self.sleepStartTime = 0
  4437. self.sleepTimer.callback.append(self.sleepTimerTimeout)
  4438. def sleepTimerState(self):
  4439. if self.sleepTimer.isActive():
  4440. return (self.sleepStartTime - time()) / 60
  4441. return 0
  4442. def setSleepTimer(self, sleepTime, showMessage = True):
  4443. print "[InfoBarSleepTimer] set sleeptimer", sleepTime
  4444. if sleepTime:
  4445. m = abs(sleepTime / 60)
  4446. message = _("The sleep timer has been activated.") + "\n" + _("Delay:") + " " + _("%d minutes") % m
  4447. self.sleepTimer.startLongTimer(sleepTime)
  4448. self.sleepStartTime = time() + sleepTime
  4449. else:
  4450. message = _("The sleep timer has been disabled.")
  4451. self.sleepTimer.stop()
  4452. if showMessage:
  4453. Notifications.AddPopup(message, type = MessageBox.TYPE_INFO, timeout = 5)
  4454. def sleepTimerTimeout(self):
  4455. if config.usage.sleep_timer_action.value != "standby":
  4456. isRecordTime = abs(self.session.nav.RecordTimer.getNextRecordingTime() - time()) <= 900 or self.session.nav.RecordTimer.getStillRecording() or abs(self.session.nav.RecordTimer.getNextZapTime() - time()) <= 900
  4457. isPowerTime = abs(self.session.nav.PowerTimer.getNextPowerManagerTime() - time()) <= 900 or self.session.nav.PowerTimer.isProcessing(exceptTimer = 0)
  4458. if isRecordTime or isPowerTime:
  4459. self.setSleepTimer(1800, False)
  4460. if not Screens.Standby.inStandby:
  4461. message = _("A Recording, RecordTimer or PowerTimer is running or begins in 15 minutes.\nExtend sleep timer 30 minutes. Your %s %s\nwill shut down after Recording or Powertimer event. Get in Standby now?") % (getMachineBrand(), getMachineName())
  4462. self.session.openWithCallback(self.goStandby, MessageBox, message, MessageBox.TYPE_YESNO, timeout=180, default=True)
  4463. return
  4464. if not Screens.Standby.inStandby:
  4465. list = [ (_("Yes"), True),
  4466. (_("No"), False),
  4467. (_("Extend"), "extend") ]
  4468. if config.usage.sleep_timer_action.value == "standby":
  4469. message = _("A sleep timer wants to set your %s %s to standby.\nDo that now or set extend additional minutes?") % (getMachineBrand(), getMachineName())
  4470. else:
  4471. message = _("A sleep timer wants to shut down your %s %s.\nDo that now or set extend additional minutes?") % (getMachineBrand(), getMachineName())
  4472. self.session.openWithCallback(self.sleepTimerTimeoutCallback, MessageBox, message, timeout=180, simple=True, list=list, default=True)
  4473. else:
  4474. self.goStandby()
  4475. def sleepTimerTimeoutCallback(self, answer):
  4476. if answer == "extend":
  4477. from Screens.SleepTimerEdit import SleepTimerEdit
  4478. self.session.open(SleepTimerEdit)
  4479. elif answer:
  4480. self.goStandby()
  4481. else:
  4482. self.setSleepTimer(0)
  4483. def goStandby(self, answer = None):
  4484. if config.usage.sleep_timer_action.value == "standby" or answer:
  4485. if not Screens.Standby.inStandby:
  4486. print "[InfoBarSleepTimer] goto standby"
  4487. self.session.open(Screens.Standby.Standby)
  4488. elif answer is None:
  4489. if not Screens.Standby.inStandby:
  4490. if not Screens.Standby.inTryQuitMainloop:
  4491. print "[InfoBarSleepTimer] goto deep standby"
  4492. self.session.open(Screens.Standby.TryQuitMainloop, 1)
  4493. else:
  4494. print "[InfoBarSleepTimer] goto deep standby"
  4495. quitMainloop(1)
  4496. #########################################################################################
  4497. # for displayed power or record timer messages in foreground and for callback execution #
  4498. #########################################################################################
  4499. class InfoBarOpenOnTopHelper:
  4500. def __init__(self):
  4501. pass
  4502. def openInfoBarMessage(self, message, messageboxtyp, timeout=-1):
  4503. try:
  4504. self.session.open(MessageBox, message, messageboxtyp, timeout=timeout)
  4505. except Exception, e:
  4506. print "[InfoBarOpenMessage] Exception:", e
  4507. def openInfoBarMessageWithCallback(self, callback, message, messageboxtyp, timeout=-1, default=True):
  4508. try:
  4509. self.session.openWithCallback(callback, MessageBox, message, messageboxtyp, timeout=timeout, default=default)
  4510. except Exception, e:
  4511. print "[openInfoBarMessageWithCallback] Exception:", e
  4512. def openInfoBarSession(self, session, option=None):
  4513. try:
  4514. if option is None:
  4515. self.session.open(session)
  4516. else:
  4517. self.session.open(session, option)
  4518. except Exception, e:
  4519. print "[openInfoBarSession] Exception:", e
  4520. #########################################################################################