示例#1
0
    def show_unread(self, rssid):
        t = Template()
        t.load(os.path.join(Globals.workpath, 'plugins/rssreader/unread_message.py'), 'python')

        RssDb.init(Globals.rss_dbfile)

        feed = RssDb.Feed.get(rssid)
        data = RssDb.Data.select(RssDb.and_(RssDb.Data.c.feed_id==rssid, RssDb.Data.c.read==False), order_by=[RssDb.desc(RssDb.Data.c.pubDate)])
        x = dict4ini.DictIni()
        x.html.chanel_title = feed.title
        x.html.chanel_url = feed.link
        x.html.chanel_image_url = feed.imagelink
        x.html.newsletter = []
        for i in data:
            v = dict4ini.DictIni()
            v.title = i.title
            v.link = i.link
            v.description = i.description
            v.date = i.pubDate.strftime("%Y-%m-%d %H:%M:%S")
            v.comments = i.comments
            v.comments_gif = ('file:///' + os.path.join(Globals.workpath, 'plugins/rssreader/comments.png').replace(':', '|')).replace('\\', '/')
            x.html.newsletter.append(v)

        text = t.value('html', x.dict(), encoding='utf-8')
        filename = os.path.join(tempfile.gettempdir(), 'rssreader.html')
        file(filename, 'w').write(text)

        self.publisher.sendMessage('change_html', filename)
示例#2
0
 def add_feed(self):
     dialog = [
         ('string', 'caption', tr('Caption'), tr('Feed Caption:'), None),
         ('string', 'url', tr('New Feed URL'), tr('Feed URL:'), None),
     ]
     from modules.EasyGuider import EasyDialog
     easy = EasyDialog.EasyDialog(self.sharewin, tr('Add Feed'), dialog)
     values = None
     if easy.ShowModal() == wx.ID_OK:
         values = easy.GetValue()
     easy.Destroy()
     if values:
         #add feed to db
         item, node = self.sharewin.get_cur_node()
         RssDb.init(Globals.rss_dbfile)
         f = RssDb.Feed(category_id=node['data']['id'],
                        title=values["caption"],
                        link=values['url'])
         f.commit()
         data = {
             'type': 'rss',
             'level': 'feed',
             'caption': values["caption"],
             'data': {
                 'url': values['url'],
                 'homeurl': '',
                 'save': False,
                 'id': f.id
             }
         }
         obj = self.sharewin.addnode(item, data=data)
         self.add_feed_ids(node['data']['id'], f.id, obj)
示例#3
0
    def import_opml(self, filename):
        RssDb.init(Globals.rss_dbfile)

        import OPML
        opml = OPML.parse(filename)
        for o in opml.outlines:
            c = RssDb.Category.get_by(title=o['title'])
            if not c:
                c = RssDb.Category(o['title'])
                c.commit()
            for i in o.children:
                f = RssDb.Feed.get_by(category_id=c.id, link=i['xmlUrl'])
                if f:
                    f.title = i['title']
                    f.homelink = i.get('htmlUrl', '')
                    f.description = i.get('description', '')
                    f.commit()
                else:
                    c.feeds.append(
                        RssDb.Feed(title=i['title'],
                                   link=i['xmlUrl'],
                                   homelink=i.get('htmlUrl', ''),
                                   imagelink='',
                                   description=i.get('description', '')))
        RssDb.objectstore.commit()
        item, node = self.sharewin.get_cur_node()
        self.sharewin.reset_cur_item()
示例#4
0
 def startup(self, item):
     sharewin = self.parent
     RssDb.init(Globals.rss_dbfile)
     categories = RssDb.Category.select()
     sharewin.tree.Freeze()
     for i in categories:
         data = {'type':'rss', 'level':'category', 'caption':i.title, 'data':{'save':False, 'id':i.id}}
         root = sharewin.addnode(item, data=data)
         self.add_category_ids(i.id, root)
         for f in RssDb.Feed.select(RssDb.Feed.c.category_id==i.id, order_by=[RssDb.Feed.c.title]):
             number = RssDb.Data.un_read_count(f.id)
             if number:
                 caption = u"(%d)%s" % (number, f.title)
             else:
                 caption = f.title
             data = {'type':'rss', 'level':'feed', 'caption':caption, 'data':{'url':f.link, 'homeurl':f.homelink, 'save':False, 'id':f.id}}
             obj = sharewin.addnode(root, data=data)
             self.add_feed_ids(i.id, f.id, obj)
             if number:
                 sharewin.tree.SetItemBold(obj, True)
         sharewin.tree.Expand(root)
     sharewin.tree.Thaw()
     if categories:
         wx.CallAfter(sharewin.tree.Expand, item)
         if Globals.mainframe.pref.rss_start:
             mc = Casing.MultiCasing()
             for item in self.feeds.values():
                 d = self.get_casting(item)
                 mc.append(d)
             mc.start_sync_thread()
示例#5
0
    def add_category(self):
        dialog = [
            ('string', 'caption', tr('New Category'), tr('Category Name:'),
             None),
        ]
        from modules.EasyGuider import EasyDialog
        easy = EasyDialog.EasyDialog(self.sharewin, tr('Input'), dialog)
        values = None
        if easy.ShowModal() == wx.ID_OK:
            values = easy.GetValue()
        easy.Destroy()
        if values:
            #add category to db
            import RssDb
            RssDb.init(Globals.rss_dbfile)
            category = RssDb.Category(title=values["caption"])
            category.save()

            data = {
                'type': 'rss',
                'level': 'category',
                'caption': values['caption'],
                'data': {
                    'save': False,
                    'id': category.id
                }
            }
            root, node = self.sharewin.get_cur_node()
            obj = self.sharewin.addnode(root, data=data)
            self.add_category_ids(category.id, obj)
示例#6
0
    def OnChanged(self, event):
        t = Template()
        t.load(os.path.join(Globals.workpath, 'plugins/rssreader/single_message.txt'), 'text')

        RssDb.init(Globals.rss_dbfile)

        item = event.GetIndex()
        index = self.list.GetItemData(item)
        data = RssDb.Data.get_by(guid=self.guids[index])
        v = {}
        v["title"] = data.title
        v["link"] = data.link
        v["description"] = data.description
        v["date"] = data.pubDate.strftime("%Y-%m-%d %H:%M:%S")
        v["comments"] = data.comments
        v["comments_gif"] = ('file:///' + os.path.join(Globals.workpath, 'plugins/rssreader/comments.png').replace(':', '|')).replace('\\', '/')

        text = t.value('text', v, encoding='utf-8')
        filename = os.path.join(tempfile.gettempdir(), 'rssreader.html')
        file(filename, 'w').write(text)

        self.publisher.sendMessage('change_html', filename)

        #cal read status
        def check_and_update(self=self, index=item):
            if self.list.GetFirstSelected() == index:
                wx.CallAfter(self.OnCheck, index, True)
        t = threading.Timer(Globals.mainframe.pref.rss_read_time, check_and_update)
        t.start()
示例#7
0
    def set_all_read(self, item):
        node = self.sharewin.get_node(item)
        rssid = node['data']['id']
        RssDb.init(Globals.rss_dbfile)

        RssDb.Data.set_read(rssid)

        self.refresh_feed_unread(rssid)
示例#8
0
    def set_all_read(self, item):
        node = self.sharewin.get_node(item)
        rssid = node['data']['id']
        RssDb.init(Globals.rss_dbfile)

        RssDb.Data.set_read(rssid)

        self.refresh_feed_unread(rssid)
示例#9
0
    def OnCheck(self, index, checkflag):
        RssDb.init(Globals.rss_dbfile)

        data = RssDb.Data.get_by(guid=self.guids[index])
        data.read = checkflag
        data.save()
        self.list.setFlag(index, checkflag)

        self.publisher.sendMessage('rss_unread_changed', {'rssid':data.feed_id, 'flag':checkflag})
示例#10
0
 def load_from_db(self, rssid):
     RssDb.init(Globals.rss_dbfile)
     from modules.Debug import error
     error.info('load_from_db'+str(rssid))
     self.data = []
     feed = RssDb.Feed.get(rssid)
     for i, data in enumerate(RssDb.Data.get_posts(feed.id)):
         self.data.append(([data.title, data.pubDate.strftime("%Y-%m-%d %H:%M:%S")], data.read))
         self.guids[i] = data.guid
     self.title = feed.title
     editctrl = Globals.mainframe.editctrl
     wx.CallAfter(editctrl.showPageTitle, self)
     wx.CallAfter(editctrl.showTitle, self)
示例#11
0
 def startup(self, item):
     sharewin = self.parent
     RssDb.init(Globals.rss_dbfile)
     categories = RssDb.Category.select()
     sharewin.tree.Freeze()
     for i in categories:
         data = {
             'type': 'rss',
             'level': 'category',
             'caption': i.title,
             'data': {
                 'save': False,
                 'id': i.id
             }
         }
         root = sharewin.addnode(item, data=data)
         self.add_category_ids(i.id, root)
         for f in RssDb.Feed.select(RssDb.Feed.c.category_id == i.id,
                                    order_by=[RssDb.Feed.c.title]):
             number = RssDb.Data.un_read_count(f.id)
             if number:
                 caption = u"(%d)%s" % (number, f.title)
             else:
                 caption = f.title
             data = {
                 'type': 'rss',
                 'level': 'feed',
                 'caption': caption,
                 'data': {
                     'url': f.link,
                     'homeurl': f.homelink,
                     'save': False,
                     'id': f.id
                 }
             }
             obj = sharewin.addnode(root, data=data)
             self.add_feed_ids(i.id, f.id, obj)
             if number:
                 sharewin.tree.SetItemBold(obj, True)
         sharewin.tree.Expand(root)
     sharewin.tree.Thaw()
     if categories:
         wx.CallAfter(sharewin.tree.Expand, item)
         if Globals.mainframe.pref.rss_start:
             mc = Casing.MultiCasing()
             for item in self.feeds.values():
                 d = self.get_casting(item)
                 mc.append(d)
             mc.start_sync_thread()
示例#12
0
 def delete(self, node):
     if node.get('type', '') == 'rss':
         if node.get('level', '') == 'root':
             return True
         elif node.get('level', '') == 'category':
             cate_id = node['data']['id']
             RssDb.init(Globals.rss_dbfile)
             RssDb.Category.delete_id(cate_id)
             self.del_category_ids(cate_id)
             return True
         elif node.get('level', '') == 'feed':
             RssDb.init(Globals.rss_dbfile)
             rssid = node['data']['id']
             feed = RssDb.Feed.get(rssid)
             cate_id = feed.category_id
             RssDb.Feed.delete_id(rssid)
             self.del_feed_ids(cate_id, rssid)
             return True
示例#13
0
    def refresh_feed_unread(self, rssid):
        RssDb.init(Globals.rss_dbfile)

        feed = RssDb.Feed.get(rssid)
        number = RssDb.Data.un_read_count(rssid)
        if number:
            caption = u"(%d)%s" % (number, feed.title)
        else:
            caption = feed.title
        item = self.feeds[rssid]
        node = self.sharewin.get_node(item)
        node['caption'] = caption

        self.sharewin.tree.SetItemText(item, caption)
        if number:
            self.sharewin.tree.SetItemBold(item, True)
        else:
            self.sharewin.tree.SetItemBold(item, False)
示例#14
0
 def delete(self, node):
     if node.get('type', '') == 'rss':
         if node.get('level', '') == 'root':
             return True
         elif node.get('level', '') == 'category':
             cate_id = node['data']['id']
             RssDb.init(Globals.rss_dbfile)
             RssDb.Category.delete_id(cate_id)
             self.del_category_ids(cate_id)
             return True
         elif node.get('level', '') == 'feed':
             RssDb.init(Globals.rss_dbfile)
             rssid = node['data']['id']
             feed = RssDb.Feed.get(rssid)
             cate_id = feed.category_id
             RssDb.Feed.delete_id(rssid)
             self.del_feed_ids(cate_id, rssid)
             return True
示例#15
0
    def refresh_feed_unread(self, rssid):
        RssDb.init(Globals.rss_dbfile)

        feed = RssDb.Feed.get(rssid)
        number = RssDb.Data.un_read_count(rssid)
        if number:
            caption = u"(%d)%s" % (number, feed.title)
        else:
            caption = feed.title
        item = self.feeds[rssid]
        node = self.sharewin.get_node(item)
        node['caption'] = caption

        self.sharewin.tree.SetItemText(item, caption)
        if number:
            self.sharewin.tree.SetItemBold(item, True)
        else:
            self.sharewin.tree.SetItemBold(item, False)
示例#16
0
    def feed(self, rssid, text):
        RssDb.init(Globals.rss_dbfile)

        #        b = r.match(text)
        #        if b:
        #            text = text[b.end():]
        #            encoding = b.groups()[0]
        #            if encoding.lower() == 'gb2312':
        #                encoding = 'gbk'
        #            text = unicode(text, encoding).encode('utf-8')
        d = feedparser.parse(text)
        new = 0
        RssDb.objectstore.begin()
        feed = RssDb.Feed.get(rssid)
        for i in d.entries:
            if not i.has_key('modified_parsed'):
                date = datetime.datetime.now()
            else:
                date = datetime.datetime(*i.modified_parsed[:-2])
            if not i.has_key('comments'):
                i.comments = ''
            if not i.has_key('guid'):
                i.guid = i.link
            data = RssDb.Data.get_by(feed_id=rssid, guid=i.guid)
            if data:
                if i.title != data.title or i.description != data.description:
                    data.title = i.title
                    data.description = i.description
                    data.pubDate = date
                    data.read = False
                    new += 1
            else:
                data = RssDb.Data(guid=i.guid,
                                  title=i.title,
                                  comments=i.comments,
                                  description=i.description,
                                  link=i.link,
                                  pubDate=date,
                                  read=False,
                                  feed_id=rssid)
                new += 1
        RssDb.objectstore.commit()
        if Globals.mainframe.pref.rss_auto_dig:
            self.parse_feed(feed, d.feed)
示例#17
0
 def add_feed(self):
     dialog = [
     ('string', 'caption', tr('Caption'), tr('Feed Caption:'), None),
     ('string', 'url', tr('New Feed URL'), tr('Feed URL:'), None),
     ]
     from modules.EasyGuider import EasyDialog
     easy = EasyDialog.EasyDialog(self.sharewin, tr('Add Feed'), dialog)
     values = None
     if easy.ShowModal() == wx.ID_OK:
         values = easy.GetValue()
     easy.Destroy()
     if values:
         #add feed to db
         item, node = self.sharewin.get_cur_node()
         RssDb.init(Globals.rss_dbfile)
         f = RssDb.Feed(category_id=node['data']['id'], title=values["caption"], link=values['url'])
         f.commit()
         data = {'type':'rss', 'level':'feed', 'caption':values["caption"], 'data':{'url':values['url'], 'homeurl':'', 'save':False, 'id':f.id}}
         obj = self.sharewin.addnode(item, data=data)
         self.add_feed_ids(node['data']['id'], f.id, obj)
示例#18
0
    def add_category(self):
        dialog = [
        ('string', 'caption', tr('New Category'), tr('Category Name:'), None),
        ]
        from modules.EasyGuider import EasyDialog
        easy = EasyDialog.EasyDialog(self.sharewin, tr('Input'), dialog)
        values = None
        if easy.ShowModal() == wx.ID_OK:
            values = easy.GetValue()
        easy.Destroy()
        if values:
            #add category to db
            import RssDb
            RssDb.init(Globals.rss_dbfile)
            category = RssDb.Category(title=values["caption"])
            category.save()

            data = {'type':'rss', 'level':'category', 'caption':values['caption'], 'data':{'save':False, 'id':category.id}}
            root, node = self.sharewin.get_cur_node()
            obj = self.sharewin.addnode(root, data=data)
            self.add_category_ids(category.id, obj)
示例#19
0
    def import_opml(self, filename):
        RssDb.init(Globals.rss_dbfile)

        import OPML
        opml = OPML.parse(filename)
        for o in opml.outlines:
            c = RssDb.Category.get_by(title=o['title'])
            if not c:
                c = RssDb.Category(o['title'])
                c.commit()
            for i in o.children:
                f = RssDb.Feed.get_by(category_id=c.id, link=i['xmlUrl'])
                if f:
                    f.title = i['title']
                    f.homelink = i.get('htmlUrl', '')
                    f.description = i.get('description', '')
                    f.commit()
                else:
                    c.feeds.append(RssDb.Feed(title=i['title'], link=i['xmlUrl'], homelink=i.get('htmlUrl', ''), imagelink='', description=i.get('description', '')))
        RssDb.objectstore.commit()
        item, node = self.sharewin.get_cur_node()
        self.sharewin.reset_cur_item()
示例#20
0
    def feed(self, rssid, text):
        RssDb.init(Globals.rss_dbfile)

#        b = r.match(text)
#        if b:
#            text = text[b.end():]
#            encoding = b.groups()[0]
#            if encoding.lower() == 'gb2312':
#                encoding = 'gbk'
#            text = unicode(text, encoding).encode('utf-8')
        d = feedparser.parse(text)
        new = 0
        RssDb.objectstore.begin()
        feed = RssDb.Feed.get(rssid)
        for i in d.entries:
            if not i.has_key('modified_parsed'):
                date = datetime.datetime.now()
            else:
                date = datetime.datetime(*i.modified_parsed[:-2])
            if not i.has_key('comments'):
                i.comments = ''
            if not i.has_key('guid'):
                i.guid = i.link
            data = RssDb.Data.get_by(feed_id=rssid, guid=i.guid)
            if data:
                if i.title!= data.title or i.description!=data.description:
                    data.title = i.title
                    data.description=i.description
                    data.pubDate=date
                    data.read=False
                    new += 1
            else:
                data = RssDb.Data(guid=i.guid, title=i.title, comments=i.comments,
                    description=i.description, link=i.link, pubDate=date, read=False, feed_id=rssid)
                new += 1
        RssDb.objectstore.commit()
        if Globals.mainframe.pref.rss_auto_dig:
            self.parse_feed(feed, d.feed)
示例#21
0
    def export_opml(self, filename):
        RssDb.init(Globals.rss_dbfile)

        import OPML
        opml = OPML.OPML()
        outlines = OPML.OutlineList()
        for c in RssDb.Category.select():
            o = OPML.Outline()
            o['title'] = c.title
            outlines.add_outline(o)
            for f in c.feeds:
                d = OPML.Outline()
                d['description'] = f.description
                d['xmlUrl'] = f.link
                d['homeUrl'] = f.homelink
                d['title'] = f.title
                d['text'] = f.title
                d['version'] = 'RSS'
                d['type'] = 'rss'
                outlines.add_outline(d)
                outlines.close_outline()
            outlines.close_outline()
        opml.outlines = outlines.roots()
        opml.output(file(filename, "wb"))
示例#22
0
    def export_opml(self, filename):
        RssDb.init(Globals.rss_dbfile)

        import OPML
        opml = OPML.OPML()
        outlines = OPML.OutlineList()
        for c in RssDb.Category.select():
            o = OPML.Outline()
            o['title'] = c.title
            outlines.add_outline(o)
            for f in c.feeds:
                d = OPML.Outline()
                d['description'] = f.description
                d['xmlUrl'] = f.link
                d['homeUrl'] = f.homelink
                d['title'] = f.title
                d['text'] = f.title
                d['version'] = 'RSS'
                d['type'] = 'rss'
                outlines.add_outline(d)
                outlines.close_outline()
            outlines.close_outline()
        opml.outlines = outlines.roots()
        opml.output(file(filename, "wb"))
示例#23
0
def on_menu(win, menu_id):
    if hasattr(
            win,
            'IDPM_RSS_ADD_CATEGORY') and menu_id == win.IDPM_RSS_ADD_CATEGORY:
        klass = win.get_cur_class()
        if klass:
            klass.add_category()
    elif hasattr(win,
                 'IDPM_RSS_ADD_FEED') and menu_id == win.IDPM_RSS_ADD_FEED:
        klass = win.get_cur_class()
        if klass:
            klass.add_feed()
    elif hasattr(win,
                 'IDPM_RSS_FRESH_FEED') and menu_id == win.IDPM_RSS_FRESH_FEED:
        v = win.get_cur_node()
        if v:
            item, node = v
            klass = win.get_class(node)
            if klass:
                klass.fresh_feed(item)
    elif hasattr(win, 'IDPM_RSS_FRESH_CATEGORY'
                 ) and menu_id == win.IDPM_RSS_FRESH_CATEGORY:
        v = win.get_cur_node()
        if v:
            item, node = v
            klass = win.get_class(node)
            if klass:
                klass.fresh_category(item)
    elif hasattr(win,
                 'IDPM_RSS_MAKE_READ') and menu_id == win.IDPM_RSS_MAKE_READ:
        v = win.get_cur_node()
        if v:
            item, node = v
            klass = win.get_class(node)
            if klass:
                klass.set_all_read(item)
                klass.change_feed(item)
    elif hasattr(win,
                 'IDPM_RSS_DELETEALL') and menu_id == win.IDPM_RSS_DELETEALL:
        v = win.get_cur_node()
        if v:
            item, node = v
            klass = win.get_class(node)
            if klass:
                klass.delete_all_posts(item)
                klass.change_feed(item)
                klass.refresh_feed_unread(node['data']['id'])
    elif hasattr(win, 'IDPM_RSS_IMPORT') and menu_id == win.IDPM_RSS_IMPORT:
        dlg = wx.FileDialog(win,
                            tr("Choose a OPML filename"),
                            wildcard='*.opml',
                            style=wx.OPEN | wx.FILE_MUST_EXIST | wx.CHANGE_DIR)
        filename = None
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
        dlg.Destroy()
        if filename:
            klass = win.get_cur_class()
            if klass:
                import common
                common.setmessage(Globals.mainframe, tr('Parsing OPML...'))
                klass.import_opml(dlg.GetFilename())
    elif hasattr(win, 'IDPM_RSS_EXPORT') and menu_id == win.IDPM_RSS_EXPORT:
        dlg = wx.FileDialog(win,
                            tr("Choose a OPML filename"),
                            wildcard='*.opml',
                            style=wx.SAVE | wx.CHANGE_DIR)
        filename = None
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
        dlg.Destroy()
        if filename:
            klass = win.get_cur_class()
            if klass:
                import common
                common.setmessage(Globals.mainframe, tr('Saving OPML...'))
                klass.export_opml(dlg.GetFilename())
    elif hasattr(win,
                 'IDPM_RSS_STOP_FEED') and menu_id == win.IDPM_RSS_STOP_FEED:
        klass = win.get_cur_class()
        item, node = win.get_cur_node()
        if klass:
            klass.stop_feed(item)
    elif hasattr(win, 'IDPM_RSS_STOP_CATEGORY'
                 ) and menu_id == win.IDPM_RSS_STOP_CATEGORY:
        klass = win.get_cur_class()
        item, node = win.get_cur_node()
        if klass:
            klass.stop_category(item)
    elif hasattr(win,
                 'IDPM_RSS_RECREATE') and menu_id == win.IDPM_RSS_RECREATE:
        ret = wx.MessageBox(tr(
            "Do you really want to re-create the rss database?\nAll data in it will be lost!"
        ),
                            tr("Confirm"),
                            style=wx.YES_NO)
        if ret == wx.YES:
            import RssDb
            RssDb.init(Globals.rss_dbfile, create=True)
            item, node = win.get_cur_node()
            win.reset_cur_item()
            import common
            common.showmessage(win,
                               tr("Rss database is created successfully!"))
    elif hasattr(win, 'IDPM_RSS_CATE_PROPERTY'
                 ) and menu_id == win.IDPM_RSS_CATE_PROPERTY:
        item, node = win.get_cur_node()
        klass = win.get_cur_class()
        if klass:
            klass.cate_properties(item)
    elif hasattr(win, 'IDPM_RSS_FEED_PROPERTY'
                 ) and menu_id == win.IDPM_RSS_FEED_PROPERTY:
        item, node = win.get_cur_node()
        klass = win.get_cur_class()
        if klass:
            klass.feed_properties(item)
示例#24
0
    def delete_all_posts(self, item):
        node = self.sharewin.get_node(item)
        rssid = node['data']['id']
        RssDb.init(Globals.rss_dbfile)

        RssDb.Data.delete_posts(rssid)
示例#25
0
    def delete_all_posts(self, item):
        node = self.sharewin.get_node(item)
        rssid = node['data']['id']
        RssDb.init(Globals.rss_dbfile)

        RssDb.Data.delete_posts(rssid)
示例#26
0
def on_menu(win, menu_id):
    if hasattr(win, 'IDPM_RSS_ADD_CATEGORY') and menu_id == win.IDPM_RSS_ADD_CATEGORY:
        klass = win.get_cur_class()
        if klass:
            klass.add_category()
    elif hasattr(win, 'IDPM_RSS_ADD_FEED') and menu_id == win.IDPM_RSS_ADD_FEED:
        klass = win.get_cur_class()
        if klass:
            klass.add_feed()
    elif hasattr(win, 'IDPM_RSS_FRESH_FEED') and menu_id == win.IDPM_RSS_FRESH_FEED:
        v = win.get_cur_node()
        if v:
            item, node = v
            klass = win.get_class(node)
            if klass:
                klass.fresh_feed(item)
    elif hasattr(win, 'IDPM_RSS_FRESH_CATEGORY') and menu_id == win.IDPM_RSS_FRESH_CATEGORY:
        v = win.get_cur_node()
        if v:
            item, node = v
            klass = win.get_class(node)
            if klass:
                klass.fresh_category(item)
    elif hasattr(win, 'IDPM_RSS_MAKE_READ') and menu_id == win.IDPM_RSS_MAKE_READ:
        v = win.get_cur_node()
        if v:
            item, node = v
            klass = win.get_class(node)
            if klass:
                klass.set_all_read(item)
                klass.change_feed(item)
    elif hasattr(win, 'IDPM_RSS_DELETEALL') and menu_id == win.IDPM_RSS_DELETEALL:
        v = win.get_cur_node()
        if v:
            item, node = v
            klass = win.get_class(node)
            if klass:
                klass.delete_all_posts(item)
                klass.change_feed(item)
                klass.refresh_feed_unread(node['data']['id'])
    elif hasattr(win, 'IDPM_RSS_IMPORT') and menu_id == win.IDPM_RSS_IMPORT:
        dlg = wx.FileDialog(win, tr("Choose a OPML filename"), wildcard='*.opml', style=wx.OPEN|wx.FILE_MUST_EXIST|wx.CHANGE_DIR)
        filename = None
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
        dlg.Destroy()
        if filename:
            klass = win.get_cur_class()
            if klass:
                import common
                common.setmessage(Globals.mainframe, tr('Parsing OPML...'))
                klass.import_opml(dlg.GetFilename())
    elif hasattr(win, 'IDPM_RSS_EXPORT') and menu_id == win.IDPM_RSS_EXPORT:
        dlg = wx.FileDialog(win, tr("Choose a OPML filename"), wildcard='*.opml', style=wx.SAVE|wx.CHANGE_DIR)
        filename = None
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
        dlg.Destroy()
        if filename:
            klass = win.get_cur_class()
            if klass:
                import common
                common.setmessage(Globals.mainframe, tr('Saving OPML...'))
                klass.export_opml(dlg.GetFilename())
    elif hasattr(win, 'IDPM_RSS_STOP_FEED') and menu_id == win.IDPM_RSS_STOP_FEED:
        klass = win.get_cur_class()
        item, node = win.get_cur_node()
        if klass:
            klass.stop_feed(item)
    elif hasattr(win, 'IDPM_RSS_STOP_CATEGORY') and menu_id == win.IDPM_RSS_STOP_CATEGORY:
        klass = win.get_cur_class()
        item, node = win.get_cur_node()
        if klass:
            klass.stop_category(item)
    elif hasattr(win, 'IDPM_RSS_RECREATE') and menu_id == win.IDPM_RSS_RECREATE:
        ret = wx.MessageBox(tr("Do you really want to re-create the rss database?\nAll data in it will be lost!"), tr("Confirm"),
            style=wx.YES_NO)
        if ret == wx.YES:
            import RssDb
            RssDb.init(Globals.rss_dbfile, create=True)
            item, node = win.get_cur_node()
            win.reset_cur_item()
            import common
            common.showmessage(win, tr("Rss database is created successfully!"))
    elif hasattr(win, 'IDPM_RSS_CATE_PROPERTY') and menu_id == win.IDPM_RSS_CATE_PROPERTY:
        item, node = win.get_cur_node()
        klass = win.get_cur_class()
        if klass:
            klass.cate_properties(item)
    elif hasattr(win, 'IDPM_RSS_FEED_PROPERTY') and menu_id == win.IDPM_RSS_FEED_PROPERTY:
        item, node = win.get_cur_node()
        klass = win.get_cur_class()
        if klass:
            klass.feed_properties(item)