Changeset 8672 for branches/gajim_0.11.1/src/common
- Timestamp:
- 08/31/07 18:28:31 (15 months ago)
- Location:
- branches/gajim_0.11.1/src/common
- Files:
-
- 3 modified
-
connection_handlers.py (modified) (23 diffs)
-
connection.py (modified) (2 diffs)
-
xmpp/protocol.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/gajim_0.11.1/src/common/connection_handlers.py
r8669 r8672 19 19 20 20 import os 21 import time22 21 import base64 23 22 import sha … … 25 24 import sys 26 25 27 from time import localtime, strftime, gmtime 26 from time import (altzone, daylight, gmtime, localtime, mktime, strftime, 27 strptime, time as time_time, timezone, tzname) 28 28 from calendar import timegm 29 29 … … 397 397 def _ResultCB(self, con, iq_obj): 398 398 gajim.log.debug('_ResultCB') 399 # if we want to respect jep-0065 we have to check for proxy399 # if we want to respect xep-0065 we have to check for proxy 400 400 # activation result in any result iq 401 401 real_id = unicode(iq_obj.getAttr('id')) … … 571 571 ''' hold xmpppy handlers and public methods for discover services''' 572 572 def discoverItems(self, jid, node = None, id_prefix = None): 573 '''According to JEP-0030: jid is mandatory,573 '''According to XEP-0030: jid is mandatory, 574 574 name, node, action is optional.''' 575 575 self._discover(common.xmpp.NS_DISCO_ITEMS, jid, node, id_prefix) 576 576 577 577 def discoverInfo(self, jid, node = None, id_prefix = None): 578 '''According to JEP-0030:578 '''According to XEP-0030: 579 579 For identity: category, type is mandatory, name is optional. 580 580 For feature: var is mandatory''' … … 723 723 q.addChild('feature', attrs = {'var': common.xmpp.NS_XHTML_IM}) 724 724 725 if node is None: 726 q.addChild('feature', attrs = {'var': common.xmpp.NS_TIME_REVISED}) 727 725 728 if q.getChildren(): 726 729 self.connection.send(iq) … … 734 737 def _DiscoverInfoCB(self, con, iq_obj): 735 738 gajim.log.debug('DiscoverInfoCB') 736 # According to JEP-0030:739 # According to XEP-0030: 737 740 # For identity: category, type is mandatory, name is optional. 738 741 # For feature: var is mandatory … … 800 803 801 804 def add_caps(self, p): 802 ''' advertise our capabilities in presence stanza ( jep-0115)'''805 ''' advertise our capabilities in presence stanza (xep-0115)''' 803 806 c = p.setTag('c', namespace = common.xmpp.NS_CAPS) 804 807 c.setAttr('node', 'http://gajim.org/caps') … … 1009 1012 if iq_obj.getType() == 'result': 1010 1013 # Metacontact tags 1011 # http://www. jabber.org/jeps/jep-XXXX.html1014 # http://www.xmpp.org/extensions/xep-0209.html 1012 1015 meta_list = {} 1013 1016 query = iq_obj.getTag('query') … … 1180 1183 def _PrivateCB(self, con, iq_obj): 1181 1184 ''' 1182 Private Data ( JEP 048 and 049)1185 Private Data (XEP 048 and 049) 1183 1186 ''' 1184 1187 gajim.log.debug('PrivateCB') … … 1189 1192 if ns == 'storage:bookmarks': 1190 1193 # Bookmarked URLs and Conferences 1191 # http://www. jabber.org/jeps/jep-0048.html1194 # http://www.xmpp.org/extensions/xep-0048.html 1192 1195 confs = storage.getTags('conference') 1193 1196 for conf in confs: … … 1210 1213 elif ns == 'gajim:prefs': 1211 1214 # Preferences data 1212 # http://www. jabber.org/jeps/jep-0049.html1215 # http://www.xmpp.org/extensions/xep-0049.html 1213 1216 #TODO: implement this 1214 1217 pass … … 1230 1233 if ns == 'storage:metacontacts': 1231 1234 self.metacontacts_supported = False 1232 # Private XML Storage ( JEP49) is not supported by server1235 # Private XML Storage (XEP49) is not supported by server 1233 1236 # Continue connecting 1234 1237 self.connection.initRoster() … … 1303 1306 iq_obj = iq_obj.buildReply('result') 1304 1307 qp = iq_obj.getTag('query') 1305 qp.setTagData('utc', strftime( "%Y%m%dT%T", gmtime()))1306 qp.setTagData('tz', strftime("%Z", gmtime()))1307 qp.setTagData('display', strftime( "%c", localtime()))1308 qp.setTagData('utc', strftime('%Y%m%dT%T', gmtime())) 1309 qp.setTagData('tz', tzname[daylight]) 1310 qp.setTagData('display', strftime('%c', localtime())) 1308 1311 self.connection.send(iq_obj) 1309 1312 raise common.xmpp.NodeProcessed … … 1312 1315 gajim.log.debug('TimeRevisedCB') 1313 1316 iq_obj = iq_obj.buildReply('result') 1314 qp = iq_obj.setTag('time') 1315 qp.setTagData('utc', strftime("%Y-%m-%dT%TZ", gmtime())) 1316 qp.setTagData('tzo', "%+03d:00"% (-time.timezone/(60*60))) 1317 qp = iq_obj.setTag('time', 1318 namespace=common.xmpp.NS_TIME_REVISED) 1319 qp.setTagData('utc', strftime('%Y-%m-%dT%TZ', gmtime())) 1320 zone = -(timezone, altzone)[daylight] / 60 1321 tzo = (zone / 60, abs(zone % 60)) 1322 qp.setTagData('tzo', '%+03d:%02d' % (tzo)) 1317 1323 self.connection.send(iq_obj) 1318 1324 raise common.xmpp.NodeProcessed … … 1376 1382 subject = msg.getSubject() # if not there, it's None 1377 1383 tim = msg.getTimestamp() 1378 tim = time.strptime(tim, '%Y%m%dT%H:%M:%S')1379 tim = time.localtime(timegm(tim))1384 tim = strptime(tim, '%Y%m%dT%H:%M:%S') 1385 tim = localtime(timegm(tim)) 1380 1386 frm = helpers.get_full_jid_from_iq(msg) 1381 1387 jid = helpers.get_jid_from_iq(msg) … … 1397 1403 delayed = msg.getTag('x', namespace = common.xmpp.NS_DELAY) != None 1398 1404 msg_id = None 1399 composing_ jep = None1405 composing_xep = None 1400 1406 # FIXME: Msn transport (CMSN1.2.1 and PyMSN0.10) do NOT RECOMMENDED 1401 1407 # invitation 1402 # stanza (MUC JEP) remove in 2007, as we do not do NOT RECOMMENDED1408 # stanza (MUC XEP) remove in 2007, as we do not do NOT RECOMMENDED 1403 1409 xtags = msg.getTags('x') 1404 1410 for xtag in xtags: … … 1409 1415 # chatstates - look for chatstate tags in a message if not delayed 1410 1416 if not delayed: 1411 composing_ jep = False1417 composing_xep = False 1412 1418 children = msg.getChildren() 1413 1419 for child in children: 1414 1420 if child.getNamespace() == 'http://jabber.org/protocol/chatstates': 1415 1421 chatstate = child.getName() 1416 composing_ jep = 'JEP-0085'1422 composing_xep = 'XEP-0085' 1417 1423 break 1418 # No JEP-0085 support, fallback to JEP-00221424 # No XEP-0085 support, fallback to XEP-0022 1419 1425 if not chatstate: 1420 1426 chatstate_child = msg.getTag('x', namespace = common.xmpp.NS_EVENT) 1421 1427 if chatstate_child: 1422 1428 chatstate = 'active' 1423 composing_ jep = 'JEP-0022'1429 composing_xep = 'XEP-0022' 1424 1430 if not msgtxt and chatstate_child.getTag('composing'): 1425 1431 chatstate = 'composing' 1426 # JEP-0172 User Nickname1432 # XEP-0172 User Nickname 1427 1433 user_nick = msg.getTagData('nick') 1428 1434 if not user_nick: … … 1466 1472 return 1467 1473 self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml)) 1468 if self.name not in no_log_for and not int(float( time.mktime(tim)))\1474 if self.name not in no_log_for and not int(float(mktime(tim)))\ 1469 1475 <= self.last_history_line[jid] and msgtxt: 1470 1476 try: … … 1503 1509 mtype = treat_as 1504 1510 self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype, 1505 subject, chatstate, msg_id, composing_ jep, user_nick, msghtml))1511 subject, chatstate, msg_id, composing_xep, user_nick, msghtml)) 1506 1512 # END messageCB 1507 1513 … … 1557 1563 sigTag = None 1558 1564 avatar_sha = None 1559 # JEP-0172 User Nickname1565 # XEP-0172 User Nickname 1560 1566 user_nick = prs.getTagData('nick') 1561 1567 if not user_nick: … … 1574 1580 contact_nickname = x.getTagData('nickname') 1575 1581 elif namespace == common.xmpp.NS_DELAY: 1576 # JEP-00911582 # XEP-0091 1577 1583 tim = prs.getTimestamp() 1578 tim = time.strptime(tim, '%Y%m%dT%H:%M:%S')1579 timestamp = time.localtime(timegm(tim))1584 tim = strptime(tim, '%Y%m%dT%H:%M:%S') 1585 timestamp = localtime(timegm(tim)) 1580 1586 if namespace == 'http://delx.cjb.net/protocol/roster-subsync': 1581 1587 # see http://trac.gajim.org/ticket/326 … … 1712 1718 if not self.subscribed_events.has_key(jid_stripped): 1713 1719 self.subscribed_events[jid_stripped] = [] 1714 self.subscribed_events[jid_stripped].append(time .time())1720 self.subscribed_events[jid_stripped].append(time_time()) 1715 1721 block = False 1716 1722 if len(self.subscribed_events[jid_stripped]) > 5: 1717 if time .time() - self.subscribed_events[jid_stripped][0] < 5:1723 if time_time() - self.subscribed_events[jid_stripped][0] < 5: 1718 1724 block = True 1719 1725 self.subscribed_events[jid_stripped] = self.subscribed_events[jid_stripped][1:] … … 1732 1738 if not self.subscribed_events.has_key(jid_stripped): 1733 1739 self.subscribed_events[jid_stripped] = [] 1734 self.subscribed_events[jid_stripped].append(time .time())1740 self.subscribed_events[jid_stripped].append(time_time()) 1735 1741 block = False 1736 1742 if len(self.subscribed_events[jid_stripped]) > 5: 1737 if time .time() - self.subscribed_events[jid_stripped][0] < 5:1743 if time_time() - self.subscribed_events[jid_stripped][0] < 5: 1738 1744 block = True 1739 1745 self.subscribed_events[jid_stripped] = self.subscribed_events[jid_stripped][1:] -
branches/gajim_0.11.1/src/common/connection.py
r8669 r8672 728 728 else: 729 729 # Encryption failed, do not send message 730 tim = time.localtime()730 tim = localtime() 731 731 self.dispatch('MSGNOTSENT', (jid, error, msgtxt, tim)) 732 732 return 3 … … 1099 1099 # Save the time we quit to avoid duplicate logs AND be faster than 1100 1100 # get that date from DB 1101 self.last_history_line[jid] = time .time()1101 self.last_history_line[jid] = time_time() 1102 1102 1103 1103 def gc_set_role(self, room_jid, nick, role, reason = ''): -
branches/gajim_0.11.1/src/common/xmpp/protocol.py
r7940 r8672 22 22 from simplexml import Node,NodeBuilder,ustr 23 23 import time 24 NS_ACTIVITY ='http://jabber.org/protocol/activity' # JEP-010825 NS_ADDRESS ='http://jabber.org/protocol/address' # JEP-003324 NS_ACTIVITY ='http://jabber.org/protocol/activity' # XEP-0108 25 NS_ADDRESS ='http://jabber.org/protocol/address' # XEP-0033 26 26 NS_AGENTS ='jabber:iq:agents' 27 27 NS_AMP ='http://jabber.org/protocol/amp' … … 30 30 NS_BIND ='urn:ietf:params:xml:ns:xmpp-bind' 31 31 NS_BROWSE ='jabber:iq:browse' 32 NS_BYTESTREAM ='http://jabber.org/protocol/bytestreams' # JEP-006533 NS_CAPS ='http://jabber.org/protocol/caps' # JEP-011534 NS_CHATSTATES ='http://jabber.org/protocol/chatstates' # JEP-008532 NS_BYTESTREAM ='http://jabber.org/protocol/bytestreams' # XEP-0065 33 NS_CAPS ='http://jabber.org/protocol/caps' # XEP-0115 34 NS_CHATSTATES ='http://jabber.org/protocol/chatstates' # XEP-0085 35 35 NS_CLIENT ='jabber:client' 36 36 NS_COMMANDS ='http://jabber.org/protocol/commands' 37 37 NS_COMPONENT_ACCEPT='jabber:component:accept' 38 38 NS_COMPONENT_1 ='http://jabberd.jabberstudio.org/ns/component/1.0' 39 NS_COMPRESS ='http://jabber.org/protocol/compress' # JEP-013839 NS_COMPRESS ='http://jabber.org/protocol/compress' # XEP-0138 40 40 NS_CONFERENCE ='jabber:x:conference' 41 NS_DATA ='jabber:x:data' # JEP-000441 NS_DATA ='jabber:x:data' # XEP-0004 42 42 NS_DELAY ='jabber:x:delay' 43 43 NS_DIALBACK ='jabber:server:dialback' … … 45 45 NS_DISCO_INFO =NS_DISCO+'#info' 46 46 NS_DISCO_ITEMS =NS_DISCO+'#items' 47 NS_ENCRYPTED ='jabber:x:encrypted' # JEP-002748 NS_EVENT ='jabber:x:event' # JEP-002247 NS_ENCRYPTED ='jabber:x:encrypted' # XEP-0027 48 NS_EVENT ='jabber:x:event' # XEP-0022 49 49 NS_FEATURE ='http://jabber.org/protocol/feature-neg' 50 NS_FILE ='http://jabber.org/protocol/si/profile/file-transfer' # JEP-009651 NS_GEOLOC ='http://jabber.org/protocol/geoloc' # JEP-008050 NS_FILE ='http://jabber.org/protocol/si/profile/file-transfer' # XEP-0096 51 NS_GEOLOC ='http://jabber.org/protocol/geoloc' # XEP-0080 52 52 NS_GROUPCHAT ='gc-1.0' 53 NS_HTTP_AUTH ='http://jabber.org/protocol/http-auth' # JEP-007054 NS_HTTP_BIND ='http://jabber.org/protocol/httpbind' # JEP-012453 NS_HTTP_AUTH ='http://jabber.org/protocol/http-auth' # XEP-0070 54 NS_HTTP_BIND ='http://jabber.org/protocol/httpbind' # XEP-0124 55 55 NS_IBB ='http://jabber.org/protocol/ibb' 56 56 NS_INVISIBLE ='presence-invisible' # Jabberd2 … … 58 58 NS_LAST ='jabber:iq:last' 59 59 NS_MESSAGE ='message' # Jabberd2 60 NS_MOOD ='http://jabber.org/protocol/mood' # JEP-010760 NS_MOOD ='http://jabber.org/protocol/mood' # XEP-0107 61 61 NS_MUC ='http://jabber.org/protocol/muc' 62 62 NS_MUC_USER =NS_MUC+'#user' 63 63 NS_MUC_ADMIN =NS_MUC+'#admin' 64 64 NS_MUC_OWNER =NS_MUC+'#owner' 65 NS_NICK ='http://jabber.org/protocol/nick' # JEP-017266 NS_OFFLINE ='http://www.jabber.org/jeps/jep-0030.html' # JEP-001367 NS_PHYSLOC ='http://jabber.org/protocol/physloc' # JEP-011265 NS_NICK ='http://jabber.org/protocol/nick' # XEP-0172 66 NS_OFFLINE ='http://www.jabber.org/jeps/jep-0030.html' # XEP-0013 67 NS_PHYSLOC ='http://jabber.org/protocol/physloc' # XEP-0112 68 68 NS_PRESENCE ='presence' # Jabberd2 69 69 NS_PRIVACY ='jabber:iq:privacy' 70 70 NS_PRIVATE ='jabber:iq:private' 71 NS_PROFILE ='http://jabber.org/protocol/profile' # JEP-015472 NS_PUBSUB ='http://jabber.org/protocol/pubsub' # JEP-006071 NS_PROFILE ='http://jabber.org/protocol/profile' # XEP-0154 72 NS_PUBSUB ='http://jabber.org/protocol/pubsub' # XEP-0060 73 73 NS_REGISTER ='jabber:iq:register' 74 74 NS_ROSTER ='jabber:iq:roster' 75 NS_ROSTERX ='http://jabber.org/protocol/rosterx' # JEP-014476 NS_RPC ='jabber:iq:rpc' # JEP-000975 NS_ROSTERX ='http://jabber.org/protocol/rosterx' # XEP-0144 76 NS_RPC ='jabber:iq:rpc' # XEP-0009 77 77 NS_SASL ='urn:ietf:params:xml:ns:xmpp-sasl' 78 78 NS_SEARCH ='jabber:iq:search' 79 79 NS_SERVER ='jabber:server' 80 80 NS_SESSION ='urn:ietf:params:xml:ns:xmpp-session' 81 NS_SI ='http://jabber.org/protocol/si' # JEP-009682 NS_SI_PUB ='http://jabber.org/protocol/sipub' # JEP-013783 NS_SIGNED ='jabber:x:signed' # JEP-002781 NS_SI ='http://jabber.org/protocol/si' # XEP-0096 82 NS_SI_PUB ='http://jabber.org/protocol/sipub' # XEP-0137 83 NS_SIGNED ='jabber:x:signed' # XEP-0027 84 84 NS_STANZAS ='urn:ietf:params:xml:ns:xmpp-stanzas' 85 85 NS_STREAM ='http://affinix.com/jabber/stream' 86 86 NS_STREAMS ='http://etherx.jabber.org/streams' 87 NS_TIME ='jabber:iq:time' # JEP-090088 NS_TIME_REVISED =' http://www.xmpp.org/extensions/xep-0202.html#ns' # JEP-020287 NS_TIME ='jabber:iq:time' # XEP-0900 88 NS_TIME_REVISED ='urn:xmpp:time' # XEP-0202 89 89 NS_TLS ='urn:ietf:params:xml:ns:xmpp-tls' 90 90 NS_VACATION ='http://jabber.org/protocol/vacation' … … 95 95 NS_VERSION ='jabber:iq:version' 96 96 NS_PING ='urn:xmpp:ping' # XEP-0199 97 NS_WAITINGLIST ='http://jabber.org/protocol/waitinglist' # JEP-013098 NS_XHTML_IM ='http://jabber.org/protocol/xhtml-im' # JEP-007197 NS_WAITINGLIST ='http://jabber.org/protocol/waitinglist' # XEP-0130 98 NS_XHTML_IM ='http://jabber.org/protocol/xhtml-im' # XEP-0071 99 99 NS_XHTML = 'http://www.w3.org/1999/xhtml' # " 100 NS_DATA_LAYOUT ='http://jabber.org/protocol/xdata-layout' # JEP-0141101 NS_DATA_VALIDATE='http://jabber.org/protocol/xdata-validate' # JEP-0122100 NS_DATA_LAYOUT ='http://jabber.org/protocol/xdata-layout' # XEP-0141 101 NS_DATA_VALIDATE='http://jabber.org/protocol/xdata-validate' # XEP-0122 102 102 NS_XMPP_STREAMS ='urn:ietf:params:xml:ns:xmpp-streams' 103 103 … … 423 423 424 424 def setXHTML(self,val,xmllang=None): 425 """ Sets the xhtml text of the message ( JEP-0071).425 """ Sets the xhtml text of the message (XEP-0071). 426 426 The parameter is the "inner html" to the body.""" 427 427 try: … … 591 591 class DataField(Node): 592 592 """ This class is used in the DataForm class to describe the single data item. 593 If you are working with jabber:x:data ( JEP-0004, JEP-0068, JEP-0122)593 If you are working with jabber:x:data (XEP-0004, XEP-0068, XEP-0122) 594 594 then you will need to work with instances of this class. """ 595 595 def __init__(self,name=None,value=None,typ=None,required=0,desc=None,options=[],node=None): … … 668 668 class DataForm(Node): 669 669 """ DataForm class. Used for manipulating dataforms in XMPP. 670 Relevant JEPs: 0004, 0068, 0122.670 Relevant XEPs: 0004, 0068, 0122. 671 671 Can be used in disco, pub-sub and many other applications.""" 672 672 def __init__(self, typ=None, data=[], title=None, node=None):
