'Return an indication of whether the given book represented by its db id
is on the currently connected device. It returns a 5 element list. The
first three elements represent memory locations main, carda, and cardb,
and are true if the book is identifiably in that memory. The fourth
is a count of how many instances of the book were found across all
the memory locations. The fifth is a set of paths to the
matching books on the device.'

def book_on_device(self, id, reset=False):

    loc = [None, None, None, 0, set([])]
    if reset:
        self.book_db_id_cache = None
        self.book_db_id_counts = None
        self.book_db_uuid_path_map = None
        return
    if ((not self.device_manager.is_device_connected) or (not hasattr(self, 'db_book_uuid_cache'))):
        return loc
    if (self.book_db_id_cache is None):
        self.book_db_id_cache = []
        self.book_db_id_counts = {}
        self.book_db_uuid_path_map = {}
        for (i, l) in enumerate(self.booklists()):
            self.book_db_id_cache.append(set())
            for book in l:
                db_id = getattr(book, 'application_id', None)
                if (db_id is not None):
                    self.book_db_id_cache[i].add(db_id)
                    if (db_id not in self.book_db_uuid_path_map):
                        self.book_db_uuid_path_map[db_id] = set()
                    if getattr(book, 'lpath', False):
                        self.book_db_uuid_path_map[db_id].add(book.lpath)
                    c = self.book_db_id_counts.get(db_id, 0)
                    self.book_db_id_counts[db_id] = (c + 1)
    for (i, l) in enumerate(self.booklists()):
        if (id in self.book_db_id_cache[i]):
            loc[i] = True
            loc[3] = self.book_db_id_counts.get(id, 0)
            loc[4] |= self.book_db_uuid_path_map[id]
    return loc
