merge do_caps() and do_backends() into do() (optional keyword params 'backends' and 'caps')
This commit is contained in:
parent
5d33778986
commit
fc4badf88e
13 changed files with 53 additions and 103 deletions
|
|
@ -46,7 +46,7 @@ class Chatoob(ConsoleApplication):
|
|||
|
||||
@ConsoleApplication.command('list online contacts')
|
||||
def command_list(self):
|
||||
for backend, contact in self.weboob.do_caps(ICapContact, 'iter_contacts', status=Contact.STATUS_ONLINE):
|
||||
for backend, contact in self.weboob.do('iter_contacts', status=Contact.STATUS_ONLINE, caps=ICapContact):
|
||||
self.format(contact, backend.name)
|
||||
|
||||
@ConsoleApplication.command('get messages')
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class HaveSex(PromptApplication):
|
|||
_id, backend_name = self.parse_id(id)
|
||||
|
||||
found = 0
|
||||
for backend, profile in self.weboob.do_backends(backend_name, 'get_profile', _id):
|
||||
for backend, profile in self.weboob.do('get_profile', _id, backends=backend_name):
|
||||
if profile:
|
||||
print profile.get_profile_text().encode('utf-8')
|
||||
found = 1
|
||||
|
|
|
|||
|
|
@ -74,10 +74,7 @@ class MessagesManager(QWidget):
|
|||
|
||||
self.process = QtDo(self.weboob, self._gotMessage)
|
||||
|
||||
if self.backend:
|
||||
self.process.do_backends(self.backend.name, command)
|
||||
else:
|
||||
self.process.do_caps(ICapMessages, command)
|
||||
self.process.do(self.backend.name, command, backends=self.backend, caps=ICapMessages)
|
||||
|
||||
def _gotMessage(self, backend, message):
|
||||
if message is None:
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class ContactThread(QWidget):
|
|||
command = 'iter_messages'
|
||||
|
||||
self.process_msg = QtDo(self.weboob, self.gotMessage)
|
||||
self.process_msg.do_backends(self.contact.backend, command, thread=self.contact.id)
|
||||
self.process_msg.do(command, thread=self.contact.id, backends=self.contact.backend)
|
||||
|
||||
def gotMessage(self, backend, message):
|
||||
if not message:
|
||||
|
|
@ -101,7 +101,7 @@ class ContactThread(QWidget):
|
|||
self.ui.textEdit.setEnabled(False)
|
||||
self.ui.sendButton.setEnabled(False)
|
||||
self.process_reply = QtDo(self.weboob, self._postReply_cb, self._postReply_eb)
|
||||
self.process_reply.do_backends(self.contact.backend, 'post_reply', self.contact.id, 0, '', text)
|
||||
self.process_reply.do('post_reply', self.contact.id, 0, '', text, backends=self.contact.backend)
|
||||
|
||||
def _postReply_cb(self, backend, ignored):
|
||||
self.ui.textEdit.clear()
|
||||
|
|
@ -128,6 +128,8 @@ class ContactProfile(QWidget):
|
|||
self.contact = contact
|
||||
|
||||
self.ui.nicknameLabel.setText('<h1>%s</h1>' % contact.name)
|
||||
self.ui.statusLabel.setText('%s' % contact.status_msg)
|
||||
self.ui.descriptionEdit.setText('<h1>Description</h1><p>%s</p>' % contact.summary)
|
||||
|
||||
class IGroup(object):
|
||||
def __init__(self, weboob, id, name):
|
||||
|
|
@ -148,7 +150,7 @@ class MetaGroup(IGroup):
|
|||
status = Contact.STATUS_ALL
|
||||
|
||||
self.process = QtDo(self.weboob, lambda b, d: self.cb(cb, b, d))
|
||||
self.process.do_caps(ICapContact, 'iter_contacts', status)
|
||||
self.process.do('iter_contacts', status, caps=ICapContact)
|
||||
|
||||
def cb(self, cb, backend, contact):
|
||||
if contact:
|
||||
|
|
@ -233,6 +235,9 @@ class ContactsWidget(QWidget):
|
|||
|
||||
self.contact = current.data(Qt.UserRole).toPyObject()
|
||||
|
||||
if not self.contact:
|
||||
return
|
||||
|
||||
self.ui.tabWidget.addTab(ContactProfile(self.weboob, self.contact), self.tr('Profile'))
|
||||
if self.contact.backend.has_caps(ICapMessages):
|
||||
self.ui.tabWidget.addTab(ContactThread(self.weboob, self.contact), self.tr('Messages'))
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class MainWindow(QtMainWindow):
|
|||
self.ui.tabWidget.addTab(MessagesManager(self.weboob), self.tr('Messages'))
|
||||
self.ui.tabWidget.addTab(ContactsWidget(self.weboob), self.tr('Contacts'))
|
||||
self.ui.tabWidget.addTab(QWidget(), self.tr('Calendar'))
|
||||
self.ui.tabWidget.addTab(QWidget(), self.tr('Optimizations'))
|
||||
|
||||
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
|
||||
self.connect(self.ui.tabWidget, SIGNAL('currentChanged(int)'), self.tabChanged)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
from __future__ import with_statement
|
||||
|
||||
from PyQt4.QtGui import QWidget, QHBoxLayout, QVBoxLayout, QFrame, QLabel, QImage, QPixmap
|
||||
from PyQt4.QtCore import SIGNAL
|
||||
|
||||
from weboob.capabilities.dating import StatusField
|
||||
from weboob.tools.application.qt import QtDo
|
||||
|
|
@ -60,7 +59,7 @@ class Account(QFrame):
|
|||
self.process = QtDo(self.weboob, self.updateStats_cb)
|
||||
self.process.body = u''
|
||||
self.process.in_p = False
|
||||
self.process.do_backends(self.backend, 'get_status')
|
||||
self.process.do('get_status', backends=self.backend)
|
||||
|
||||
def updateStats_cb(self, backend, field):
|
||||
if not field:
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_3">
|
||||
<widget class="QFrame" name="headFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<widget class="QFrame" name="bodyFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
|
|
@ -87,7 +87,11 @@
|
|||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
<widget class="QTextEdit" name="descriptionEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
|||
|
|
@ -80,10 +80,7 @@ class MainWindow(QtMainWindow):
|
|||
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
|
||||
|
||||
self.process = QtDo(self.weboob, self.addVideo)
|
||||
if backend_name:
|
||||
self.process.do_backends(backend_name, 'iter_search_results', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True)
|
||||
else:
|
||||
self.process.do('iter_search_results', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True)
|
||||
self.process.do('iter_search_results', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True, backends=backend_name)
|
||||
|
||||
def addVideo(self, backend, video):
|
||||
if not backend:
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Weboorrents(ConsoleApplication):
|
|||
_id, backend_name = self.parse_id(id)
|
||||
|
||||
found = 0
|
||||
for backend, torrent in self.weboob.do_backends(backend_name, 'get_torrent', _id):
|
||||
for backend, torrent in self.weboob.do('get_torrent', _id, backends=backend_name):
|
||||
if torrent:
|
||||
self.format(torrent, backend.name)
|
||||
found = 1
|
||||
|
|
@ -52,7 +52,7 @@ class Weboorrents(ConsoleApplication):
|
|||
def command_getfile(self, id, dest):
|
||||
_id, backend_name = self.parse_id(id)
|
||||
|
||||
for backend, buf in self.weboob.do_backends(backend_name, 'get_torrent_file', _id):
|
||||
for backend, buf in self.weboob.do('get_torrent_file', _id, backends=backend_name):
|
||||
if buf:
|
||||
if dest == '-':
|
||||
print buf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue