def onMenuChanged(self, item):
    obj = item[-1]
    items = {
          #'Update': dreamclass.format_date(obj['updated_on']),
          _('Description'): obj['description'],
          _('Approved'): str(obj['approved']),
          }

    self.DescriptionToText(items)      
  def action(self, actiontype):

    if actiontype == "delete":
      if self.is_selected() is False: return      
      self.session.openWithCallback(self.delete, MessageBox, _("Do you want delete this item?"), MessageBox.TYPE_YESNO)   
      
    if actiontype == "add":
      self.session.openWithCallback(self.add, FileUpload.MainMenu, "test")           

    if actiontype == "edit":
      if self.is_selected() is False: return      
      self.session.openWithCallback(self.edit, MessageBox, _("Do you want upload this item?"), MessageBox.TYPE_YESNO)    
      
    if actiontype == "download":
      if self.is_selected() is False: return      
      self.session.openWithCallback(self.download, MessageBox, _("Do you want download this item?"), MessageBox.TYPE_YESNO)        
      
    if actiontype == "upload":
      if self.is_selected() is False: return      
      self.session.openWithCallback(self.upload, MessageBox, _("Do you want upload this item?"), MessageBox.TYPE_YESNO)        
 def __init__(self, session, args=None):
   Screen.__init__(self, session)
   ConfigListScreen.__init__(self, [])    
   self.args = args
       
   self["key_red"] = StaticText(_("Cancel"))
   self["key_green"] = StaticText(_("OK"))
   # SKIN Compat HACK!
   self["key_yellow"] = StaticText("")
   # EO SKIN Compat HACK!
   self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
   {
     "red": self.cancel,
     "green": self.__SaveValues,
     "save": self.__SaveValues,
     "cancel": self.cancel,
     "ok": self.__SaveValues,
   }, -2)
       
   self.build()
   self.run()    
 def ActionDownload(self, result):
   if result is False or self.Id() is None: return
   
   try:
     zip = boxwrapper.GetConfigDir('bouquets.zip')      
     Request().ChannellistDownload(self.Id(), zip)
     dreamclass.Uncompress(zip, True)
             
     self.session.openWithCallback(self.restart, MessageBox, _("Restart to reload new channelllist?"), MessageBox.TYPE_YESNO)
     self.SetMessage('Download ok')
   except Exception as e:
     self.SetMessage(str(e))
  def buildlist(self):
    
    fid = self.args
    print fid
    ret = Request().FileDetails(fid).GetList()

    fields = [
       {'name': 'comment', 'field': ConfigText(fixed_size = False), 'text': 'Comment', 'value': str(ret['comment'])},
      ]
 
    list = []
    for field in fields:
      field['field'].setValue(ret[field['name']])
      list.append(getConfigListEntry(_(field['text']), field['field'], field['name']))
      
    return list
  def buildlist(self):
    
    cid = self.args
    ret = Request().ChannellistDetails(cid).GetList()

    fields = [
       {'name': 'name', 'field': ConfigText(fixed_size = False), 'text': 'Name', 'value': str(ret['name'])},
       {'name': 'comment', 'field': ConfigText(fixed_size = False), 'text': 'Comment', 'value': str(ret['comment'])},
       #{'name': 'friends', 'field': ConfigText() , 'text': 'Friends', 'value': dreamclass.str2bool(ret['home'])},       
      ]
 
    list = []
    for field in fields:
      field['field'].setValue(ret[field['name']])
      list.append(getConfigListEntry(_(field['text']), field['field'], field['name']))
      
    return list
 def no_access(self):
     self.SetMessage(_('no access'))
 def is_selected(self):
   if self.Id() is None:
     self.SetMessage(_('Please select one item'))
     return False
   
   return True
 def ActionHelperUpload(self):
   if self.is_selected() is False: return
   self.session.openWithCallback(self.ActionUpload, MessageBox, _("Upload and overwrite this list?"), MessageBox.TYPE_YESNO)   
 def ActionHelperDelete(self):
   if self.is_selected() is False: return
   self.session.openWithCallback(self.ActionDelete, MessageBox, _("Do you want delete this item?"), MessageBox.TYPE_YESNO)   
 def ActionHelperDownload(self):
   if self.is_selected() is False: return
   self.session.openWithCallback(self.ActionDownload, MessageBox, _("Download and overwrite current local channellist?"), MessageBox.TYPE_YESNO)            
 def ActionHelperAdd(self):
   self.session.openWithCallback(self.ActionCreate, InputBox, title=_("Please enter a name for the new channellist"), text=" " * 20, maxSize=20, type=Input.TEXT)
 def ActionHelperAdd(self):
   self.session.openWithCallback(self.AddFriendCallback, InputBox, title=_("Please enter Username or Mail of friend account"), text=" " * 55, maxSize=55, type=Input.TEXT)