Beispiel #1
0
 def browse(self, preview=False):
     # Only return content if preview is True
     if preview:
         return [
             PicasaPrivateAreaContainer(_('Private Area'),
                                        menu=self.menu,
                                        parent=self),
             PicasaPublicAreaContainer(_('Public Area'),
                                       menu=self.menu,
                                       parent=self)
         ]
     # Preview is False, this mean the item is entred
     win = LoadingWindow()
     win.show()
     # Check network connection
     try:
         from wynetwork import wynetwork as wn
         gateway = wn.NetDevices().getDeviceInfos(
             wn.NetConfigurations().getActiveConfigurationInfos()
             ['interface'])['gateway']
     except:
         gateway = '0.0.0.0'
     if gateway == '0.0.0.0':
         MessageWindow(text=_('Please configure connection'),
                       title=_('Not connected'),
                       button=False).show(timeout=5)
         win.hide()
         return None
     # Network is connected, we can start playing
     # We need to be logged to access public albums
     # So ask the user to define a valid user in private area if not already done
     if PicasaGData.email is None or PicasaGData.password is None:
         # Try to log with private users
         for username in PicasaConfig().GetPrivateUsers():
             try:
                 PicasaGData.ClientLogin(
                     username,
                     PicasaConfig().GetPrivatePassword(username))
                 break
             except:
                 pass
         else:
             MessageWindow(text=_(
                 'Please define a valid user in private area\nThis is needed in order to access all features of PicasaWeb'
             ),
                           title=_('No private user defined'),
                           button=False).show(timeout=10)
     self._items = [
         PicasaPrivateAreaContainer(_('Private Area'),
                                    menu=self.menu,
                                    parent=self),
         PicasaPublicAreaContainer(_('Public Area'),
                                   menu=self.menu,
                                   parent=self)
     ]
     win.hide()
     return self._items
Beispiel #2
0
    def browse(self, preview=False):
        win = LoadingWindow()
        win.show()
        if not self._items:

            def _validate_password(kb):
                self.password = kb._text
                kb.hide()
                try:
                    PicasaGData.ClientLogin(self.email, self.password)
                except:
                    MessageWindow(text=_('Invalid email or password'),
                                  title=_('Picasa Error'),
                                  button=False).show(timeout=5)
                    kb.hide()
                    return None
                PicasaConfig().AddPrivateUser(self.email, self.password)
                userfeed = PicasaGData.GetUserFeed(user='******')
                new_user = PicasaPrivateUserContainer(
                    name=userfeed.nickname.text,
                    username=self.email,
                    menu=self.menu,
                    parent=self,
                    thumbnail=userfeed.thumbnail.text)
                self._items.append(new_user)
                self.menu.get_item_list('main_list').append(new_user)
                return None

            def _validate_email(kb):
                self.email = kb._text
                kb.hide()
                kb = KeyboardWindow(_('Enter password'),
                                    text=self.password,
                                    confirm_action=_validate_password)
                kb.show()
                return None

            def _add_user():
                kb = KeyboardWindow(_('Enter email'),
                                    text=self.email,
                                    confirm_action=_validate_email)
                kb.show()
                return None

            self._items = [
                ActionItem(_('Add Users') + '...',
                           type_='exe',
                           action=_add_user)
            ]
            for username in PicasaConfig().GetPrivateUsers():
                userfeed = PicasaGData.GetUserFeed(user=username)
                self._items.append(
                    PicasaPrivateUserContainer(
                        name=userfeed.nickname.text,
                        username=username,
                        menu=self.menu,
                        parent=self,
                        thumbnail=userfeed.thumbnail.text))
        win.hide()
        return self._items
Beispiel #3
0
def execute_del_picasa_public_user(context):
    item = context['selected']
    PicasaConfig().DelPublicUser(item.username)
    context['parent']._items = None
    pygui_globs['menustack'].back_to_menu(context['menu'])
    context['menu'].reload_func()
    return None
Beispiel #4
0
 def __init__(self, name, username, parent=None, **kw):
     ImageItem.__init__(self, name, type_='image', **kw)
     MediaItem.__init__(self, name, type_='dir', **kw)
     self.parent = parent
     self._content = None
     self.email = username
     self.password = PicasaConfig().GetPrivatePassword(self.email)
     return None
Beispiel #5
0
    def browse(self, preview=False):
        win = LoadingWindow()
        win.show()
        if not self._items:

            def _validate(kb):
                self.pattern = kb._text
                try:
                    userfeed = PicasaGData.GetUserFeed(user=self.pattern)
                except GooglePhotosException:
                    MessageWindow(
                        text=_('User does not exist in Picasa database'),
                        title=_('Picasa Error'),
                        button=False).show(timeout=5)
                    kb.hide()
                    return None
                PicasaConfig().AddPublicUser(self.pattern)
                new_user = PicasaPublicUserContainer(
                    name=userfeed.nickname.text,
                    username=self.pattern,
                    menu=self.menu,
                    parent=self,
                    thumbnail=userfeed.thumbnail.text)
                self._items.append(new_user)
                kb.hide()
                self.menu.get_item_list('main_list').append(new_user)
                return None

            def _search():
                kb = KeyboardWindow(_('User name'),
                                    text=self.pattern,
                                    confirm_action=_validate)
                kb.show()
                return None

            self._items = [
                ActionItem(_('Search Users') + '...',
                           type_='exe',
                           action=_search)
            ]
            for username in PicasaConfig().GetPublicUsers():
                userfeed = PicasaGData.GetUserFeed(user=username)
                self._items.append(
                    PicasaPublicUserContainer(
                        name=userfeed.nickname.text,
                        username=username,
                        menu=self.menu,
                        parent=self,
                        thumbnail=userfeed.thumbnail.text))
        win.hide()
        return self._items
Beispiel #6
0
 def _validate(kb):
     self.pattern = kb._text
     try:
         userfeed = PicasaGData.GetUserFeed(user=self.pattern)
     except GooglePhotosException:
         MessageWindow(
             text=_('User does not exist in Picasa database'),
             title=_('Picasa Error'),
             button=False).show(timeout=5)
         kb.hide()
         return None
     PicasaConfig().AddPublicUser(self.pattern)
     new_user = PicasaPublicUserContainer(
         name=userfeed.nickname.text,
         username=self.pattern,
         menu=self.menu,
         parent=self,
         thumbnail=userfeed.thumbnail.text)
     self._items.append(new_user)
     kb.hide()
     self.menu.get_item_list('main_list').append(new_user)
     return None
Beispiel #7
0
 def _validate_password(kb):
     self.password = kb._text
     kb.hide()
     try:
         PicasaGData.ClientLogin(self.email, self.password)
     except:
         MessageWindow(text=_('Invalid email or password'),
                       title=_('Picasa Error'),
                       button=False).show(timeout=5)
         kb.hide()
         return None
     PicasaConfig().AddPrivateUser(self.email, self.password)
     userfeed = PicasaGData.GetUserFeed(user='******')
     new_user = PicasaPrivateUserContainer(
         name=userfeed.nickname.text,
         username=self.email,
         menu=self.menu,
         parent=self,
         thumbnail=userfeed.thumbnail.text)
     self._items.append(new_user)
     self.menu.get_item_list('main_list').append(new_user)
     return None