Beispiel #1
0
 def update(self):
     q = '''SELECT subscriptions.id, subscriptions.url, subscriptions.title,
                   labels.id, labels.name
            FROM subscriptions
            LEFT JOIN labels_fk ON labels_fk.item_id = subscriptions.id
            LEFT JOIN labels ON labels.id=labels_fk.label_id'''
     sqlite.execute(q).connect('finished', self.on_update_data)
Beispiel #2
0
    def update(self):
        self.set_sort_column_id(-2, Gtk.SortType.DESCENDING) # Unsorted
        self.handler_block(self.row_ch_handler)

        query = '''SELECT I.id, I.title, summary, href, time/1000000, unread,
                   starred, S.url, S.title, S.id, label_id FROM items AS I
                   LEFT JOIN subscriptions AS S ON S.id=I.subscription
                   LEFT JOIN labels_fk AS L ON L.item_id=S.id
                   ORDER BY time DESC'''
        sqlite.execute(query).connect('finished', self.on_update_content)
Beispiel #3
0
 def on_changed(self, path, itr):
     row = self[itr]
     if row[Col.FORCE_VISIBLE] == True:
         self.forced.add(row[Col.ID])
     query = '''UPDATE items SET unread=?, starred=? WHERE id=?'''
     sqlite.execute(query, (row[Col.UNREAD], row[Col.STARRED],
                                  row[Col.ID],))
     self.add_flag(row[0], StateIds.READ, not row[Col.UNREAD])
     self.add_flag(row[0], StateIds.KEPT_UNREAD, row[Col.UNREAD])
     self.add_flag(row[0], StateIds.STARRED, row[Col.STARRED])
     sqlite.commit()
Beispiel #4
0
    def sync(self):
        if self.sync_status > 0:
            logger.error('Flags are already being synchronized')
            return False
        self.sync_status = 0
        query = 'SELECT item_id, id FROM flags WHERE flag=? AND remove=?'

        for flag, st in itertools.product(StateIds, [True, False]):
            self.sync_status += 1
            sqlite.execute(query, (flag, st)).connect('finished', self.on_data,
                                                      (flag, st))
Beispiel #5
0
    def dump_garbage(self):
        """ Remove all items (and contents) marked with to_delete flag """
        query = 'SELECT id FROM items WHERE to_delete=1'

        def callback(job, success):
            for item_id, in job.result:
                fpath = os.path.join(CONTENT_PATH, str(item_id))
                if os.path.isfile(fpath):
                    os.remove(fpath)

        sqlite.execute(query).connect('finished', callback)
        sqlite.execute('DELETE FROM items WHERE to_delete=1')
Beispiel #6
0
    def sync(self):
        if self.sync_status.get('synchronizing', False):
            logger.error('IDs are already being synchronized')
            return False
        self.sync_status['synchronizing'] = True

        item_limit = settings.settings['cache-items']
        for name, state in self.states.items():
            getargs = state + [('n', item_limit)]
            url = api_method('stream/items/ids', getargs)
            msg = self.auth.message('GET', url)
            session.queue_message(msg, self.on_response, name)
        # Initially mark everything as deletable and unflag all items.
        # Laten in process items that are still important will be unmarked
        # and reflagged again.
        query = 'UPDATE items SET to_delete=1, unread=0, starred=0, to_sync=0'
        sqlite.execute(query)
Beispiel #7
0
    def sync(self):
        if self.sync_status > 0:
            logger.warning('Items are already being synchronized')
            return
        self.sync_status = 0
        logger.debug('Synchronizing items')
        self.dump_garbage()

        job = sqlite.execute('SELECT id FROM items WHERE to_sync=1')
        job.connect('finished', self.on_sync_ids)
Beispiel #8
0
 def add_flag(self, item_id, flag, value):
     query = '''INSERT OR REPLACE INTO flags(item_id, flag, remove, id)
                VALUES (:id, :flag, :remove,
                (SELECT id FROM flags WHERE item_id=:id AND flag=:flag))'''
     sqlite.execute(query, {'id': item_id, 'flag': flag,
                                  'remove': not value})
Beispiel #9
0
 def sync(self):
     query = 'SELECT url FROM subscriptions'
     sqlite.execute(query).connect('finished', self.on_site_uris)