changeset 01038a1fc5ea in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=01038a1fc5ea
description: Path xml sending working. TODO: Get more elegant method

diffstat:

 src/common/connection.py |  29 +++++++++++++++++++++++++++++
 src/whiteboardwidget.py  |  36 ++++++++++++++++++++++++++----------
 2 files changed, 55 insertions(+), 10 deletions(-)

diffs (98 lines):

diff -r 3b92e2716889 -r 01038a1fc5ea src/common/connection.py
--- a/src/common/connection.py  Wed Jul 08 00:00:57 2009 -0700
+++ b/src/common/connection.py  Wed Jul 08 05:02:03 2009 -0700
@@ -1960,6 +1960,35 @@
                sxe.addChild(name='connect')
 
                self.connection.send(message)
+               
+       def send_whiteboard_node(self, jid, sid, items, rids):
+               # takes int rid and dict items and sends it as a node
+               # sends new item
+               
+               message = common.xmpp.Node(node="<message to='%s' 
xmlns='jabber:client'/>"
+                  % jid)
+               sxe = message.addChild(name='sxe', attrs={'session':sid},
+                       namespace='urn:xmpp:tmp:sxe')
+               
+               for x in rids:
+                       if items[x]['type'] == 'element':
+                               parent = x
+                               attrs = {'rid':x,
+                                        'name':items[x]['data'][0].getName(),
+                                        'type':items[x]['type']}
+                               sxe.addChild(name='new', attrs=attrs)
+                       if items[x]['type'] == 'attr':
+                               attr_name = items[x]['data']
+                               chdata = 
items[parent]['data'][0].getAttr(attr_name)
+                               attrs = {'rid':x,
+                                        'name':attr_name,
+                                        'type':items[x]['type'],
+                                        'chdata':chdata,
+                                        'parent':parent}
+                               sxe.addChild(name='new', attrs=attrs)
+               self.connection.send(message)
+       
+       
 
 # END Connection
 
diff -r 3b92e2716889 -r 01038a1fc5ea src/whiteboardwidget.py
--- a/src/whiteboardwidget.py   Wed Jul 08 00:00:57 2009 -0700
+++ b/src/whiteboardwidget.py   Wed Jul 08 05:02:03 2009 -0700
@@ -135,12 +135,15 @@
                node.setAttr('stroke-width', str(line_width))
                node.setAttr('stroke', 'black')
                self.g.addChild(node=node)
+               
+               rids = self.session.generate_rids(4)
+               self.items[rids[0]] = {'type':'element', 'data':[node, 
goocanvas_obj]}
+               self.items[rids[1]] = {'type':'attr', 'data':'d', 'parent':node}
+               self.items[rids[2]] = {'type':'attr', 'data':'stroke-width', 
'parent':node}
+               self.items[rids[3]] = {'type':'attr', 'data':'stroke', 
'parent':node}
+               
+               self.session.send_items(self.items, rids)
 
-               self.items[self.session.rid()] = {'type':'element', data:[node, 
goocanvas_obj]}
-               self.items[self.session.rid()] = {'type':'attr', 'data':'d', 
'parent':node}
-               self.items[self.session.rid()] = {'type':'attr', 'data':'d', 
'parent':node}
-               self.items[self.session.rid()] = {'type':'attr', 'data':'d', 
'parent':node}
-               
        def print_xml(self):
                file = open('whiteboardtest.svg','w')
                file.writelines(str(self.svg, True))
@@ -160,16 +163,29 @@
                else:
                        self.sid = sid
 
-       def rid(self):
-               rid = str(self.last_rid)
-               self.last_rid += 1
-               return rid
+       def generate_rids(self, x):
+               # generates x number of rids and returns in list
+               
+               rids = []
+               for x in range(x):
+                       rids.append(str(self.last_rid))
+                       self.last_rid += 1
+               return rids
 
        def connect(self):
                # connect to the message
                gajim.connections[self.account].send_whiteboard_connect(
                        self.contact.get_full_jid(), self.sid)
-       
+               
+       def send_items(self, items, rids):
+               # recieves dict items and a list of rids of items to send
+               # TODO: is there a less clumsy way that doesn't involve passing
+               # whole list
+               
+               gajim.connections[self.account].send_whiteboard_node(
+                       self.contact.get_full_jid(), self.sid, items, rids
+               )
+               
        def encode(self, xml):
                # encodes it sendable string
                return 'data:text/xml,' + urllib.quote(xml)
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to