##############################################################################
#                        2011 E2OpenPlugins                                  #
#                                                                            #
#  This file is open source software; you can redistribute it and/or modify  #
#     it under the terms of the GNU General Public License version 2 as      #
#               published by the Free Software Foundation.                   #
#                                                                            #
##############################################################################
from base import BaseController
from models.movies import getMovieList
from models.timers import getTimers
from models.services import getBouquets, getChannels, getChannelEpg

class MobileController(BaseController):
	def __init__(self, session, path = ""):
		BaseController.__init__(self, path)
		self.session = session

	def P_index(self, request):
		return {}

	def P_control(self, request):
		return {}
		
	def P_screenshot(self, request):
		return {}

	def P_bouquets(self, request):
		stype = "tv"
		if "stype" in request.args.keys():
			stype = request.args["stype"][0]
		return getBouquets(stype)

	def P_channels(self, request):
		stype = "tv"
		idbouquet = "ALL"
		if "stype" in request.args.keys():
			stype = request.args["stype"][0]
		if "id" in request.args.keys():
			idbouquet = request.args["id"][0]
		return getChannels(idbouquet, stype)

	def P_channelinfo(self, request):
		channelinfo = {}
		channelepg = {}
		if "sref" in request.args.keys():
			channelepg = getChannelEpg(request.args["sref"][0])
			
		return { "channelinfo": channelepg["events"][0], "channelepg": channelepg["events"] }

	def P_satfinder(self, request):
		return {}

	def P_timerlist(self, request):
		return getTimers(self.session)
		
	def P_movies(self, request):
		if "dirname" in request.args.keys():
			movies = getMovieList(request.args["dirname"][0])
		else:
			movies = getMovieList()
		return movies
		
	def P_about(self, request):
		return {}