def __select(self, query): r = Dcop.call("collection query \"SELECT %s\"" % query.replace('"', '\\"')) r = r.split("\n") nargs = len(query.split("FROM")[0].split(",")) self.__results = [ ] while len(r) > 0: a = [ ] for i in range(nargs): a.append(r.pop(0)) self.__results.append(a)
def __select(self, query): # FIXME: this needs to be converted to python-dcop, but I'm having some # encoding problems: it seems that query with non-ASCII characters just # don't work; see using-python-dcop branch # This is bug #105084 # http://bugs.kde.org/show_bug.cgi?id=105084 r = Dcop.call("collection query \"SELECT %s\"" % query.replace('"', '\\"')) r = r.split("\n") nargs = len(query.split("FROM")[0].split(",")) self.__results = [ ] while len(r) > 0: a = [ ] for i in range(nargs): a.append(r.pop(0)) self.__results.append(a)
def __init__(self, state): self.__running = True; self.__player = Player() self.__state = state Dcop.call("player enableRandomMode false")
def next(self): Dcop.call("player next")
def playMedia(self, url): Dcop.call("playlist playMedia \"%s\"" % url.encode('utf-8'))
def stop(self): self.updateStatus() if self.__status != self.Stopped: # Awful trick Dcop.call("player pause") Dcop.call("player stop")
def prev(self): Dcop.call("player prev")
def play(self): self.updateStatus() if self.__status != self.Playing: Dcop.call("player play")
def playPause(self): self.updateStatus() if self.__status != self.Stopped: Dcop.call("player playPause")
def updateStatus(self): self.__status = int(Dcop.call("player status"))
def index(self): return int(Dcop.call("playlist getActiveIndex"))
def update(self): return Dcop.call("playlist saveCurrentPlaylist")
def clear(self): Dcop.call("playlist clearPlaylist")
def __add(self, url): Dcop.call("playlist addMedia \"%s\"" % url)