Changeset 719

Show
Ignore:
Timestamp:
07/18/08 10:19:47 (5 months ago)
Author:
sylvain
Message:

Largely started to add pubsub support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oss/jlib/designer/ui/contacts.ui

    r714 r719  
    1313   <string>Form</string> 
    1414  </property> 
    15   <widget class="QTreeView" name="contacts" > 
    16    <property name="geometry" > 
    17     <rect> 
    18      <x>4</x> 
    19      <y>4</y> 
    20      <width>316</width> 
    21      <height>408</height> 
    22     </rect> 
    23    </property> 
    24    <property name="dragEnabled" > 
    25     <bool>true</bool> 
    26    </property> 
    27    <property name="dragDropMode" > 
    28     <enum>QAbstractItemView::InternalMove</enum> 
    29    </property> 
    30    <property name="alternatingRowColors" > 
    31     <bool>true</bool> 
    32    </property> 
    33   </widget> 
     15  <layout class="QVBoxLayout" name="verticalLayout" > 
     16   <item> 
     17    <widget class="QTreeView" name="contacts" > 
     18     <property name="dragEnabled" > 
     19      <bool>true</bool> 
     20     </property> 
     21     <property name="dragDropMode" > 
     22      <enum>QAbstractItemView::InternalMove</enum> 
     23     </property> 
     24     <property name="alternatingRowColors" > 
     25      <bool>true</bool> 
     26     </property> 
     27    </widget> 
     28   </item> 
     29  </layout> 
    3430 </widget> 
    3531 <resources/> 
  • oss/jlib/examples/basic/client.py

    r718 r719  
    66from jlib.gui.chat import jlibChatWidget 
    77from jlib.gui.contact import jlibContactWidget 
    8 from jlib.core.chat import jlibChat, jlibChatComponent 
     8from jlib.gui.pubsub.node import jlibPubSubNodeWidget 
     9from jlib.gui.pubsub.affiliation import jlibPubSubAffiliationWidget 
     10from jlib.gui.pubsub.subscription import jlibPubSubSubscriptionWidget 
     11from jlib.gui.pubsub.feature import jlibPubSubFeatureWidget 
     12from jlib.core.pubsub import jlibSubscriptionDiscoveryModel, \ 
     13     jlibFeatureDiscoveryModel, jlibAffiliationDiscoveryModel 
    914 
    1015from clientui import Ui_MainWindow 
     
    2328 
    2429        self.openedChats = [] 
     30        self.connection = None 
    2531 
    26         self.connection = None 
    27         self.contactUi = jlibContactWidget(parent=self.stackedWidget) 
    28         self.stackedWidget.addWidget(self.contactUi) 
     32        self.toolBox.setItemText(0, "Contacts") 
     33        self.contactUi = jlibContactWidget(parent=self.page) 
    2934        QtCore.QObject.connect(self.contactUi, QtCore.SIGNAL("contactClicked(PyQt_PyObject)"), 
    3035                               self.openChat) 
     36         
     37        self.toolBox.setItemText(1, "Subscriptions") 
     38        self.subsUi = jlibPubSubSubscriptionWidget(parent=self.page_2) 
     39         
     40        self.toolBox.setItemText(2, "Features") 
     41        self.featsUi = jlibPubSubFeatureWidget(parent=self.page_3) 
     42 
     43        self.toolBox.setItemText(3, "Affiliations") 
     44        self.affsUi = jlibPubSubAffiliationWidget(parent=self.page_5) 
     45         
     46        self.toolBox.setItemText(4, "Nodes") 
     47        self.nodesUi = jlibPubSubNodeWidget(parent=self.page_4) 
    3148 
    3249    def start(self): 
     
    3451                               self.clientReady) 
    3552        self.connection.emit(QtCore.SIGNAL("activateChat()")) 
     53        self.connection.emit(QtCore.SIGNAL("activatePubSub(PyQt_PyObject)"), u'pubsub.localhost') 
    3654        self.connection.emit(QtCore.SIGNAL("registerLinkages(PyQt_PyObject)"), self.contactUi.contact) 
    3755        self.connection.emit(QtCore.SIGNAL("registerLinkages(PyQt_PyObject)"), self.contactUi.presence) 
     
    6280        QtCore.QObject.connect(self.connection.qobj.chat, QtCore.SIGNAL("receivedMessage(PyQt_PyObject)"),  
    6381                               self.messageReceived) 
     82        self.nodesUi.setPubSub(self.connection.qobj.pubsubnode) 
     83     
     84        disco = self.connection.qobj.discovery 
     85         
     86        QtCore.QObject.connect(disco, QtCore.SIGNAL("receivedSubscriptions(PyQt_PyObject)"), 
     87                               self.setSubscriptionsModel) 
     88        disco.emit(QtCore.SIGNAL("discoverSubscriptions()")) 
     89         
     90        QtCore.QObject.connect(disco, QtCore.SIGNAL("receivedFeatures(PyQt_PyObject)"), 
     91                               self.setFeaturesModel) 
     92        disco.emit(QtCore.SIGNAL("discoverFeatures()")) 
     93         
     94        QtCore.QObject.connect(disco, QtCore.SIGNAL("receivedAffiliations(PyQt_PyObject)"), 
     95                               self.setAffiliationsModel) 
     96        disco.emit(QtCore.SIGNAL("discoverAffiliations()")) 
     97 
     98    def setSubscriptionsModel(self, subscriptions): 
     99        model = jlibSubscriptionDiscoveryModel(parent=self.connection.qobj.discovery) 
     100        model.setSubscriptions(subscriptions) 
     101        self.subsUi.setModel(model) 
     102 
     103    def setFeaturesModel(self, features): 
     104        model = jlibFeatureDiscoveryModel(parent=self.connection.qobj.discovery) 
     105        model.setFeatures(features) 
     106        self.featsUi.setModel(model) 
     107 
     108    def setAffiliationsModel(self, affiliations): 
     109        model = jlibAffiliationDiscoveryModel(parent=self.connection.qobj.discovery) 
     110        model.setAffiliations(affiliations) 
     111        self.affsUi.setModel(model) 
    64112 
    65113    def messageReceived(self, message): 
  • oss/jlib/examples/basic/clientui.py

    r709 r719  
    11# -*- coding: utf-8 -*- 
    22 
    3 # Form implementation generated from reading ui file 'mainwindow.ui' 
     3# Form implementation generated from reading ui file '..\..\examples\basic\mainwindow.ui' 
    44# 
    5 # Created: Sun Jul  6 13:16:18 2008 
    6 #      by: PyQt4 UI code generator 4.3.3 
     5# Created: Fri Jul 18 16:54:03 2008 
     6#      by: PyQt4 UI code generator 4.4.2 
    77# 
    88# WARNING! All changes made in this file will be lost! 
     
    1313    def setupUi(self, MainWindow): 
    1414        MainWindow.setObjectName("MainWindow") 
    15         MainWindow.resize(QtCore.QSize(QtCore.QRect(0,0,800,600).size()).expandedTo(MainWindow.minimumSizeHint())) 
    16  
     15        MainWindow.resize(800,600) 
    1716        self.centralwidget = QtGui.QWidget(MainWindow) 
     17        self.centralwidget.setGeometry(QtCore.QRect(0,19,800,562)) 
    1818        self.centralwidget.setObjectName("centralwidget") 
    19  
    20         self.hboxlayout = QtGui.QHBoxLayout(self.centralwidget) 
    21         self.hboxlayout.setObjectName("hboxlayout") 
    22  
     19        self.horizontalLayout = QtGui.QHBoxLayout(self.centralwidget) 
     20        self.horizontalLayout.setObjectName("horizontalLayout") 
    2321        self.splitter = QtGui.QSplitter(self.centralwidget) 
    2422        self.splitter.setOrientation(QtCore.Qt.Horizontal) 
    2523        self.splitter.setObjectName("splitter") 
    26  
    27         self.stackedWidget = QtGui.QStackedWidget(self.splitter) 
    28         self.stackedWidget.setObjectName("stackedWidget") 
    29  
     24        self.toolBox = QtGui.QToolBox(self.splitter) 
     25        self.toolBox.setObjectName("toolBox") 
    3026        self.page = QtGui.QWidget() 
     27        self.page.setGeometry(QtCore.QRect(0,0,172,414)) 
    3128        self.page.setObjectName("page") 
    32         self.stackedWidget.addWidget(self.page) 
    33  
     29        self.toolBox.addItem(self.page,"") 
    3430        self.page_2 = QtGui.QWidget() 
     31        self.page_2.setGeometry(QtCore.QRect(0,0,172,414)) 
    3532        self.page_2.setObjectName("page_2") 
    36         self.stackedWidget.addWidget(self.page_2) 
    37  
     33        self.toolBox.addItem(self.page_2,"") 
     34        self.page_3 = QtGui.QWidget() 
     35        self.page_3.setObjectName("page_3") 
     36        self.toolBox.addItem(self.page_3,"") 
     37        self.page_5 = QtGui.QWidget() 
     38        self.page_5.setObjectName("page_5") 
     39        self.toolBox.addItem(self.page_5,"") 
     40        self.page_4 = QtGui.QWidget() 
     41        self.page_4.setObjectName("page_4") 
     42        self.toolBox.addItem(self.page_4,"") 
    3843        self.tabWidget = QtGui.QTabWidget(self.splitter) 
    3944        self.tabWidget.setObjectName("tabWidget") 
    40  
    4145        self.tab = QtGui.QWidget() 
     46        self.tab.setGeometry(QtCore.QRect(0,0,584,520)) 
    4247        self.tab.setObjectName("tab") 
    4348        self.tabWidget.addTab(self.tab,"") 
    44         self.hboxlayout.addWidget(self.splitter) 
     49        self.horizontalLayout.addWidget(self.splitter) 
    4550        MainWindow.setCentralWidget(self.centralwidget) 
    46  
    4751        self.menubar = QtGui.QMenuBar(MainWindow) 
    48         self.menubar.setGeometry(QtCore.QRect(0,0,800,27)) 
     52        self.menubar.setGeometry(QtCore.QRect(0,0,800,19)) 
    4953        self.menubar.setObjectName("menubar") 
    50  
    5154        self.menuJabber = QtGui.QMenu(self.menubar) 
    5255        self.menuJabber.setObjectName("menuJabber") 
    53  
    5456        self.menuConnection = QtGui.QMenu(self.menuJabber) 
    5557        self.menuConnection.setObjectName("menuConnection") 
    5658        MainWindow.setMenuBar(self.menubar) 
    57  
    5859        self.statusbar = QtGui.QStatusBar(MainWindow) 
     60        self.statusbar.setGeometry(QtCore.QRect(0,581,800,19)) 
    5961        self.statusbar.setObjectName("statusbar") 
    6062        MainWindow.setStatusBar(self.statusbar) 
    61  
    6263        self.actionSettings = QtGui.QAction(MainWindow) 
    6364        self.actionSettings.setObjectName("actionSettings") 
    64  
    6565        self.actionStart = QtGui.QAction(MainWindow) 
    6666        self.actionStart.setObjectName("actionStart") 
    67  
    6867        self.actionStop = QtGui.QAction(MainWindow) 
    6968        self.actionStop.setObjectName("actionStop") 
    70  
    7169        self.actionQuit = QtGui.QAction(MainWindow) 
    7270        self.actionQuit.setObjectName("actionQuit") 
     
    8179 
    8280        self.retranslateUi(MainWindow) 
     81        self.toolBox.setCurrentIndex(3) 
    8382        self.tabWidget.setCurrentIndex(0) 
    8483        QtCore.QMetaObject.connectSlotsByName(MainWindow) 
     
    8685    def retranslateUi(self, MainWindow): 
    8786        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) 
     87        self.toolBox.setItemText(self.toolBox.indexOf(self.page), QtGui.QApplication.translate("MainWindow", "Page 1", None, QtGui.QApplication.UnicodeUTF8)) 
     88        self.toolBox.setItemText(self.toolBox.indexOf(self.page_2), QtGui.QApplication.translate("MainWindow", "Page 2", None, QtGui.QApplication.UnicodeUTF8)) 
     89        self.toolBox.setItemText(self.toolBox.indexOf(self.page_3), QtGui.QApplication.translate("MainWindow", "Page", None, QtGui.QApplication.UnicodeUTF8)) 
     90        self.toolBox.setItemText(self.toolBox.indexOf(self.page_5), QtGui.QApplication.translate("MainWindow", "Page", None, QtGui.QApplication.UnicodeUTF8)) 
     91        self.toolBox.setItemText(self.toolBox.indexOf(self.page_4), QtGui.QApplication.translate("MainWindow", "Page", None, QtGui.QApplication.UnicodeUTF8)) 
    8892        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("MainWindow", "Tab 1", None, QtGui.QApplication.UnicodeUTF8)) 
    8993        self.menuJabber.setTitle(QtGui.QApplication.translate("MainWindow", "Jabber", None, QtGui.QApplication.UnicodeUTF8)) 
     
    9498        self.actionQuit.setText(QtGui.QApplication.translate("MainWindow", "Quit", None, QtGui.QApplication.UnicodeUTF8)) 
    9599 
    96  
    97  
    98 if __name__ == "__main__": 
    99     import sys 
    100     app = QtGui.QApplication(sys.argv) 
    101     MainWindow = QtGui.QMainWindow() 
    102     ui = Ui_MainWindow() 
    103     ui.setupUi(MainWindow) 
    104     MainWindow.show() 
    105     sys.exit(app.exec_()) 
  • oss/jlib/examples/basic/mainwindow.ui

    r709 r719  
    1414  </property> 
    1515  <widget class="QWidget" name="centralwidget" > 
    16    <layout class="QHBoxLayout" > 
     16   <property name="geometry" > 
     17    <rect> 
     18     <x>0</x> 
     19     <y>19</y> 
     20     <width>800</width> 
     21     <height>562</height> 
     22    </rect> 
     23   </property> 
     24   <layout class="QHBoxLayout" name="horizontalLayout" > 
    1725    <item> 
    1826     <widget class="QSplitter" name="splitter" > 
     
    2028       <enum>Qt::Horizontal</enum> 
    2129      </property> 
    22       <widget class="QStackedWidget" name="stackedWidget" > 
    23        <widget class="QWidget" name="page" /> 
    24        <widget class="QWidget" name="page_2" /> 
     30      <widget class="QToolBox" name="toolBox" > 
     31       <property name="currentIndex" > 
     32        <number>3</number> 
     33       </property> 
     34       <widget class="QWidget" name="page" > 
     35        <property name="geometry" > 
     36         <rect> 
     37          <x>0</x> 
     38          <y>0</y> 
     39          <width>172</width> 
     40          <height>414</height> 
     41         </rect> 
     42        </property> 
     43        <attribute name="label" > 
     44         <string>Page 1</string> 
     45        </attribute> 
     46       </widget> 
     47       <widget class="QWidget" name="page_2" > 
     48        <property name="geometry" > 
     49         <rect> 
     50          <x>0</x> 
     51          <y>0</y> 
     52          <width>172</width> 
     53          <height>414</height> 
     54         </rect> 
     55        </property> 
     56        <attribute name="label" > 
     57         <string>Page 2</string> 
     58        </attribute> 
     59       </widget> 
     60       <widget class="QWidget" name="page_3" > 
     61        <attribute name="label" > 
     62         <string>Page</string> 
     63        </attribute> 
     64       </widget> 
     65       <widget class="QWidget" name="page_5" > 
     66        <attribute name="label" > 
     67         <string>Page</string> 
     68        </attribute> 
     69       </widget> 
     70       <widget class="QWidget" name="page_4" > 
     71        <attribute name="label" > 
     72         <string>Page</string> 
     73        </attribute> 
     74       </widget> 
    2575      </widget> 
    2676      <widget class="QTabWidget" name="tabWidget" > 
     
    2979       </property> 
    3080       <widget class="QWidget" name="tab" > 
     81        <property name="geometry" > 
     82         <rect> 
     83          <x>0</x> 
     84          <y>0</y> 
     85          <width>584</width> 
     86          <height>520</height> 
     87         </rect> 
     88        </property> 
    3189        <attribute name="title" > 
    3290         <string>Tab 1</string> 
     
    44102     <y>0</y> 
    45103     <width>800</width> 
    46      <height>27</height> 
     104     <height>19</height> 
    47105    </rect> 
    48106   </property> 
     
    66124   <addaction name="menuJabber" /> 
    67125  </widget> 
    68   <widget class="QStatusBar" name="statusbar" /> 
     126  <widget class="QStatusBar" name="statusbar" > 
     127   <property name="geometry" > 
     128    <rect> 
     129     <x>0</x> 
     130     <y>581</y> 
     131     <width>800</width> 
     132     <height>19</height> 
     133    </rect> 
     134   </property> 
     135  </widget> 
    69136  <action name="actionSettings" > 
    70137   <property name="text" > 
  • oss/jlib/jlib/core/connection.py

    r718 r719  
    1717from bridge import Element as E 
    1818from bridge.common import XMPP_CLIENT_NS, XMPP_ROSTER_NS, \ 
    19     XMPP_LAST_NS, XMPP_DISCO_INFO_NS, XMPP_IBR_NS 
     19    XMPP_LAST_NS, XMPP_DISCO_INFO_NS, XMPP_IBR_NS, \ 
     20    XMPP_DISCO_ITEMS_NS, XMPP_PUBSUB_NS, XMPP_PUBSUB_EVENT_NS,\ 
     21    XMPP_PUBSUB_OWNER_NS 
    2022 
    2123from PyQt4 import QtCore 
     
    2325from jlib.core.qaxon import QAxonObject 
    2426from jlib.core.chat import jlibChat, jlibChatComponent 
     27from jlib.core.pubsub import jlibPubSubDiscovery, jlibPubSubDiscoveryComponent,\ 
     28     jlibPubSubNode, jlibPubSubNodeComponent 
    2529 
    2630__all__ = ['jlibConnection', 'jlibConnectionComponent'] 
     
    3438                               self.registerComponents) 
    3539        QtCore.QObject.connect(self, QtCore.SIGNAL("activateChat()"), self.enableChat) 
     40        QtCore.QObject.connect(self, QtCore.SIGNAL("activatePubSub(PyQt_PyObject)"), 
     41                               self.enablePubSub) 
    3642 
    3743    def start(self): 
     
    4955        components, linkages = self.chat.getLinkages() 
    5056        self.registerComponents(components, linkages) 
    51          
    52     def messageReceived(self, message): 
    53         print message 
    54  
     57 
     58    def enablePubSub(self, pubsub_service): 
     59        self.discovery = jlibPubSubDiscovery() 
     60        self.discovery.setComponent(jlibPubSubDiscoveryComponent(pubsub_service)) 
     61        components, linkages = self.discovery.getLinkages() 
     62        self.registerComponents(components, linkages) 
     63 
     64        self.pubsubnode = jlibPubSubNode() 
     65        self.pubsubnode.setComponent(jlibPubSubNodeComponent(pubsub_service)) 
     66        components, linkages = self.pubsubnode.getLinkages() 
     67        self.registerComponents(components, linkages) 
     68                
    5569class jlibConnectionComponent(component): 
    5670    Inboxes = {"inbox"      : "", 
     
    8195        self.register = register 
    8296        self.graph = None 
     97 
     98        ClientStream.Outboxes["%s.query" % XMPP_IBR_NS] = "Registration" 
     99        ClientStream.Outboxes["%s.query" % XMPP_LAST_NS] = "Activity" 
     100        ClientStream.Outboxes["%s.query" % XMPP_DISCO_INFO_NS] = "Discovery" 
     101        ClientStream.Outboxes["%s.query" % XMPP_DISCO_ITEMS_NS] = "PubSub Discovery of Nodes" 
     102        ClientStream.Outboxes["%s.subscribe" % XMPP_PUBSUB_NS] = "Pubsub subscription handler" 
     103        ClientStream.Outboxes["%s.unsubscribe" % XMPP_PUBSUB_NS] = "Pubsub unsubscription handler" 
     104        ClientStream.Outboxes["%s.subscriptions" % XMPP_PUBSUB_NS] = "Pubsub subscriptions handler" 
     105        ClientStream.Outboxes["%s.affiliations" % XMPP_PUBSUB_NS] = "Pubsub affiliations handler" 
     106        ClientStream.Outboxes["%s.create" % XMPP_PUBSUB_NS] = "Pubsub node creation handler" 
     107        ClientStream.Outboxes["%s.purge" % XMPP_PUBSUB_OWNER_NS] = "Pubsub node purge handler" 
     108        ClientStream.Outboxes["%s.delete" % XMPP_PUBSUB_OWNER_NS] = "Pubsub node delete handler" 
     109        ClientStream.Outboxes["%s.publish" % XMPP_PUBSUB_NS] = "Pubsub item publication handler" 
     110        ClientStream.Outboxes["%s.retract" % XMPP_PUBSUB_NS] = "Pubsub item deletion handler" 
     111        ClientStream.Outboxes["%s.x" % XMPP_PUBSUB_EVENT_NS] = "" 
     112        ClientStream.Outboxes["%s.event" % XMPP_PUBSUB_EVENT_NS] = "" 
    83113 
    84114        self.client = ClientStream(self.jid, self.passwordLookup, use_tls=self.usetls) 
  • oss/jlib/jlib/core/contact.py

    r715 r719  
    1  # -*- coding: utf-8 -*- 
     1# -*- coding: utf-8 -*- 
    22from Axon.Component import component 
    33from Axon.Ipc import shutdownMicroprocess, producerFinished 
  • oss/jlib/jlib/gui/connection.py

    r718 r719  
    1919                               self.registerLinkages) 
    2020        QtCore.QObject.connect(self, QtCore.SIGNAL("activateChat()"), self.enableChat) 
     21        QtCore.QObject.connect(self, QtCore.SIGNAL("activatePubSub(PyQt_PyObject)"), 
     22                               self.enablePubSub) 
    2123 
    2224    def accepted(self): 
     
    3941    def enableChat(self): 
    4042        self.qobj.emit(QtCore.SIGNAL("activateChat()")) 
     43 
     44    def enablePubSub(self, pubsub_service): 
     45        self.qobj.emit(QtCore.SIGNAL("activatePubSub(PyQt_PyObject)"), pubsub_service) 
    4146         
    4247    def registerLinkages(self, qobj): 
  • oss/jlib/jlib/gui/contact.py

    r718 r719  
    1919 
    2020        self.contacts.contextMenuEvent = self.contextMenuEvent 
    21         self.contacts.dragEnterEvent = self.dragEnterEvent 
    22         self.contacts.dropEvent = self.dropEvent 
     21        #self.contacts.dragEnterEvent = self.dragEnterEvent 
     22        #self.contacts.dropEvent = self.dropEvent 
    2323 
    2424        self.contact = jlibContact(parent=self) 
  • oss/jlib/jlib/gui/contactui.py

    r714 r719  
    33# Form implementation generated from reading ui file 'contacts.ui' 
    44# 
    5 # Created: Thu Jul 10 17:31:17 2008 
     5# Created: Fri Jul 18 15:32:41 2008 
    66#      by: PyQt4 UI code generator 4.4.2 
    77# 
     
    1414        jlibContacts.setObjectName("jlibContacts") 
    1515        jlibContacts.resize(324,416) 
     16        self.verticalLayout = QtGui.QVBoxLayout(jlibContacts) 
     17        self.verticalLayout.setObjectName("verticalLayout") 
    1618        self.contacts = QtGui.QTreeView(jlibContacts) 
    17         self.contacts.setGeometry(QtCore.QRect(4,4,316,408)) 
    1819        self.contacts.setDragEnabled(True) 
    1920        self.contacts.setDragDropMode(QtGui.QAbstractItemView.InternalMove) 
    2021        self.contacts.setAlternatingRowColors(True) 
    2122        self.contacts.setObjectName("contacts") 
     23        self.verticalLayout.addWidget(self.contacts) 
    2224 
    2325        self.retranslateUi(jlibContacts) 
  • oss/jlib/setup.py

    r709 r719  
    1313      url = "http://trac.defuze.org/wiki/jlib", 
    1414      download_url = "http://www.defuze.org/oss/jlib/", 
    15       packages = ["jlib", "jlib.core", "jlib.gui"], 
     15      packages = ["jlib", "jlib.core", "jlib.gui", "jlib.gui.pubsub"], 
    1616      platforms = ["any"], 
    1717      license = 'BSD',