Show
Ignore:
Timestamp:
08/31/07 18:28:31 (15 months ago)
Author:
asterix
Message:

[elghinn] fix entity time support (xep 90 and 202)

Location:
branches/gajim_0.11.1/src/common
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/gajim_0.11.1/src/common/connection_handlers.py

    r8669 r8672  
    1919 
    2020import os 
    21 import time 
    2221import base64 
    2322import sha 
     
    2524import sys 
    2625 
    27 from time import localtime, strftime, gmtime 
     26from time import (altzone, daylight, gmtime, localtime, mktime, strftime, 
     27                  strptime, time as time_time, timezone, tzname) 
    2828from calendar import timegm 
    2929 
     
    397397        def _ResultCB(self, con, iq_obj): 
    398398                gajim.log.debug('_ResultCB') 
    399                 # if we want to respect jep-0065 we have to check for proxy 
     399                # if we want to respect xep-0065 we have to check for proxy 
    400400                # activation result in any result iq 
    401401                real_id = unicode(iq_obj.getAttr('id')) 
     
    571571        ''' hold xmpppy handlers and public methods for discover services''' 
    572572        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, 
    574574                name, node, action is optional.''' 
    575575                self._discover(common.xmpp.NS_DISCO_ITEMS, jid, node, id_prefix) 
    576576 
    577577        def discoverInfo(self, jid, node = None, id_prefix = None): 
    578                 '''According to JEP-0030: 
     578                '''According to XEP-0030: 
    579579                        For identity: category, type is mandatory, name is optional. 
    580580                        For feature: var is mandatory''' 
     
    723723                                q.addChild('feature', attrs = {'var': common.xmpp.NS_XHTML_IM}) 
    724724 
     725                        if node is None: 
     726                                q.addChild('feature', attrs = {'var': common.xmpp.NS_TIME_REVISED}) 
     727 
    725728                        if q.getChildren(): 
    726729                                self.connection.send(iq) 
     
    734737        def _DiscoverInfoCB(self, con, iq_obj): 
    735738                gajim.log.debug('DiscoverInfoCB') 
    736                 # According to JEP-0030: 
     739                # According to XEP-0030: 
    737740                # For identity: category, type is mandatory, name is optional. 
    738741                # For feature: var is mandatory 
     
    800803         
    801804        def add_caps(self, p): 
    802                 ''' advertise our capabilities in presence stanza (jep-0115)''' 
     805                ''' advertise our capabilities in presence stanza (xep-0115)''' 
    803806                c = p.setTag('c', namespace = common.xmpp.NS_CAPS) 
    804807                c.setAttr('node', 'http://gajim.org/caps') 
     
    10091012                        if iq_obj.getType() == 'result': 
    10101013                                # Metacontact tags 
    1011                                 # http://www.jabber.org/jeps/jep-XXXX.html 
     1014                                # http://www.xmpp.org/extensions/xep-0209.html 
    10121015                                meta_list = {} 
    10131016                                query = iq_obj.getTag('query') 
     
    11801183        def _PrivateCB(self, con, iq_obj): 
    11811184                ''' 
    1182                 Private Data (JEP 048 and 049) 
     1185                Private Data (XEP 048 and 049) 
    11831186                ''' 
    11841187                gajim.log.debug('PrivateCB') 
     
    11891192                        if ns == 'storage:bookmarks': 
    11901193                                # Bookmarked URLs and Conferences 
    1191                                 # http://www.jabber.org/jeps/jep-0048.html 
     1194                                # http://www.xmpp.org/extensions/xep-0048.html 
    11921195                                confs = storage.getTags('conference') 
    11931196                                for conf in confs: 
     
    12101213                        elif ns == 'gajim:prefs': 
    12111214                                # Preferences data 
    1212                                 # http://www.jabber.org/jeps/jep-0049.html 
     1215                                # http://www.xmpp.org/extensions/xep-0049.html 
    12131216                                #TODO: implement this 
    12141217                                pass 
     
    12301233                        if ns == 'storage:metacontacts': 
    12311234                                self.metacontacts_supported = False 
    1232                                 # Private XML Storage (JEP49) is not supported by server 
     1235                                # Private XML Storage (XEP49) is not supported by server 
    12331236                                # Continue connecting 
    12341237                                self.connection.initRoster() 
     
    13031306                iq_obj = iq_obj.buildReply('result') 
    13041307                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())) 
    13081311                self.connection.send(iq_obj) 
    13091312                raise common.xmpp.NodeProcessed 
     
    13121315                gajim.log.debug('TimeRevisedCB') 
    13131316                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)) 
    13171323                self.connection.send(iq_obj) 
    13181324                raise common.xmpp.NodeProcessed 
     
    13761382                subject = msg.getSubject() # if not there, it's None 
    13771383                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)) 
    13801386                frm = helpers.get_full_jid_from_iq(msg) 
    13811387                jid = helpers.get_jid_from_iq(msg) 
     
    13971403                delayed = msg.getTag('x', namespace = common.xmpp.NS_DELAY) != None 
    13981404                msg_id = None 
    1399                 composing_jep = None 
     1405                composing_xep = None 
    14001406                # FIXME: Msn transport (CMSN1.2.1 and PyMSN0.10) do NOT RECOMMENDED 
    14011407                # invitation 
    1402                 # stanza (MUC JEP) remove in 2007, as we do not do NOT RECOMMENDED 
     1408                # stanza (MUC XEP) remove in 2007, as we do not do NOT RECOMMENDED 
    14031409                xtags = msg.getTags('x') 
    14041410                for xtag in xtags: 
     
    14091415                # chatstates - look for chatstate tags in a message if not delayed 
    14101416                if not delayed: 
    1411                         composing_jep = False 
     1417                        composing_xep = False 
    14121418                        children = msg.getChildren() 
    14131419                        for child in children: 
    14141420                                if child.getNamespace() == 'http://jabber.org/protocol/chatstates': 
    14151421                                        chatstate = child.getName() 
    1416                                         composing_jep = 'JEP-0085' 
     1422                                        composing_xep = 'XEP-0085' 
    14171423                                        break 
    1418                         # No JEP-0085 support, fallback to JEP-0022 
     1424                        # No XEP-0085 support, fallback to XEP-0022 
    14191425                        if not chatstate: 
    14201426                                chatstate_child = msg.getTag('x', namespace = common.xmpp.NS_EVENT) 
    14211427                                if chatstate_child: 
    14221428                                        chatstate = 'active' 
    1423                                         composing_jep = 'JEP-0022' 
     1429                                        composing_xep = 'XEP-0022' 
    14241430                                        if not msgtxt and chatstate_child.getTag('composing'): 
    14251431                                                chatstate = 'composing' 
    1426                 # JEP-0172 User Nickname 
     1432                # XEP-0172 User Nickname 
    14271433                user_nick = msg.getTagData('nick') 
    14281434                if not user_nick: 
     
    14661472                                        return 
    14671473                                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)))\ 
    14691475                                <= self.last_history_line[jid] and msgtxt: 
    14701476                                        try: 
     
    15031509                        mtype = treat_as 
    15041510                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)) 
    15061512        # END messageCB 
    15071513 
     
    15571563                sigTag = None 
    15581564                avatar_sha = None 
    1559                 # JEP-0172 User Nickname 
     1565                # XEP-0172 User Nickname 
    15601566                user_nick = prs.getTagData('nick') 
    15611567                if not user_nick: 
     
    15741580                                contact_nickname = x.getTagData('nickname') 
    15751581                        elif namespace == common.xmpp.NS_DELAY: 
    1576                                 # JEP-0091 
     1582                                # XEP-0091 
    15771583                                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)) 
    15801586                        if namespace == 'http://delx.cjb.net/protocol/roster-subsync': 
    15811587                                # see http://trac.gajim.org/ticket/326 
     
    17121718                                if not self.subscribed_events.has_key(jid_stripped): 
    17131719                                        self.subscribed_events[jid_stripped] = [] 
    1714                                 self.subscribed_events[jid_stripped].append(time.time()) 
     1720                                self.subscribed_events[jid_stripped].append(time_time()) 
    17151721                                block = False 
    17161722                                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: 
    17181724                                                block = True 
    17191725                                        self.subscribed_events[jid_stripped] = self.subscribed_events[jid_stripped][1:] 
     
    17321738                        if not self.subscribed_events.has_key(jid_stripped): 
    17331739                                self.subscribed_events[jid_stripped] = [] 
    1734                         self.subscribed_events[jid_stripped].append(time.time()) 
     1740                        self.subscribed_events[jid_stripped].append(time_time()) 
    17351741                        block = False 
    17361742                        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: 
    17381744                                        block = True 
    17391745                                self.subscribed_events[jid_stripped] = self.subscribed_events[jid_stripped][1:] 
  • branches/gajim_0.11.1/src/common/connection.py

    r8669 r8672  
    728728                        else: 
    729729                                # Encryption failed, do not send message 
    730                                 tim = time.localtime() 
     730                                tim = localtime() 
    731731                                self.dispatch('MSGNOTSENT', (jid, error, msgtxt, tim)) 
    732732                                return 3 
     
    10991099                # Save the time we quit to avoid duplicate logs AND be faster than  
    11001100                # get that date from DB 
    1101                 self.last_history_line[jid] = time.time() 
     1101                self.last_history_line[jid] = time_time() 
    11021102 
    11031103        def gc_set_role(self, room_jid, nick, role, reason = ''): 
  • branches/gajim_0.11.1/src/common/xmpp/protocol.py

    r7940 r8672  
    2222from simplexml import Node,NodeBuilder,ustr 
    2323import time 
    24 NS_ACTIVITY     ='http://jabber.org/protocol/activity'                  # JEP-0108 
    25 NS_ADDRESS      ='http://jabber.org/protocol/address'                   # JEP-0033 
     24NS_ACTIVITY     ='http://jabber.org/protocol/activity'                  # XEP-0108 
     25NS_ADDRESS      ='http://jabber.org/protocol/address'                   # XEP-0033 
    2626NS_AGENTS       ='jabber:iq:agents' 
    2727NS_AMP          ='http://jabber.org/protocol/amp' 
     
    3030NS_BIND         ='urn:ietf:params:xml:ns:xmpp-bind' 
    3131NS_BROWSE       ='jabber:iq:browse' 
    32 NS_BYTESTREAM   ='http://jabber.org/protocol/bytestreams'               # JEP-0065 
    33 NS_CAPS         ='http://jabber.org/protocol/caps'                      # JEP-0115 
    34 NS_CHATSTATES   ='http://jabber.org/protocol/chatstates'                # JEP-0085 
     32NS_BYTESTREAM   ='http://jabber.org/protocol/bytestreams'               # XEP-0065 
     33NS_CAPS         ='http://jabber.org/protocol/caps'                      # XEP-0115 
     34NS_CHATSTATES   ='http://jabber.org/protocol/chatstates'                # XEP-0085 
    3535NS_CLIENT       ='jabber:client' 
    3636NS_COMMANDS     ='http://jabber.org/protocol/commands' 
    3737NS_COMPONENT_ACCEPT='jabber:component:accept' 
    3838NS_COMPONENT_1  ='http://jabberd.jabberstudio.org/ns/component/1.0' 
    39 NS_COMPRESS     ='http://jabber.org/protocol/compress'                  # JEP-0138 
     39NS_COMPRESS     ='http://jabber.org/protocol/compress'                  # XEP-0138 
    4040NS_CONFERENCE   ='jabber:x:conference' 
    41 NS_DATA         ='jabber:x:data'                                        # JEP-0004 
     41NS_DATA         ='jabber:x:data'                                        # XEP-0004 
    4242NS_DELAY        ='jabber:x:delay' 
    4343NS_DIALBACK     ='jabber:server:dialback' 
     
    4545NS_DISCO_INFO   =NS_DISCO+'#info' 
    4646NS_DISCO_ITEMS  =NS_DISCO+'#items' 
    47 NS_ENCRYPTED    ='jabber:x:encrypted'                                   # JEP-0027 
    48 NS_EVENT        ='jabber:x:event'                                       # JEP-0022 
     47NS_ENCRYPTED    ='jabber:x:encrypted'                                   # XEP-0027 
     48NS_EVENT        ='jabber:x:event'                                       # XEP-0022 
    4949NS_FEATURE      ='http://jabber.org/protocol/feature-neg'   
    50 NS_FILE         ='http://jabber.org/protocol/si/profile/file-transfer'  # JEP-0096 
    51 NS_GEOLOC       ='http://jabber.org/protocol/geoloc'                    # JEP-0080 
     50NS_FILE         ='http://jabber.org/protocol/si/profile/file-transfer'  # XEP-0096 
     51NS_GEOLOC       ='http://jabber.org/protocol/geoloc'                    # XEP-0080 
    5252NS_GROUPCHAT    ='gc-1.0' 
    53 NS_HTTP_AUTH    ='http://jabber.org/protocol/http-auth'         # JEP-0070 
    54 NS_HTTP_BIND    ='http://jabber.org/protocol/httpbind'                  # JEP-0124 
     53NS_HTTP_AUTH    ='http://jabber.org/protocol/http-auth'                 # XEP-0070 
     54NS_HTTP_BIND    ='http://jabber.org/protocol/httpbind'                  # XEP-0124 
    5555NS_IBB          ='http://jabber.org/protocol/ibb' 
    5656NS_INVISIBLE    ='presence-invisible'                                   # Jabberd2 
     
    5858NS_LAST         ='jabber:iq:last' 
    5959NS_MESSAGE      ='message'                                              # Jabberd2 
    60 NS_MOOD         ='http://jabber.org/protocol/mood'                      # JEP-0107 
     60NS_MOOD         ='http://jabber.org/protocol/mood'                      # XEP-0107 
    6161NS_MUC          ='http://jabber.org/protocol/muc' 
    6262NS_MUC_USER     =NS_MUC+'#user' 
    6363NS_MUC_ADMIN    =NS_MUC+'#admin' 
    6464NS_MUC_OWNER    =NS_MUC+'#owner' 
    65 NS_NICK         ='http://jabber.org/protocol/nick'                      # JEP-0172 
    66 NS_OFFLINE      ='http://www.jabber.org/jeps/jep-0030.html'             # JEP-0013 
    67 NS_PHYSLOC      ='http://jabber.org/protocol/physloc'                   # JEP-0112 
     65NS_NICK         ='http://jabber.org/protocol/nick'                      # XEP-0172 
     66NS_OFFLINE      ='http://www.jabber.org/jeps/jep-0030.html'             # XEP-0013 
     67NS_PHYSLOC      ='http://jabber.org/protocol/physloc'                   # XEP-0112 
    6868NS_PRESENCE     ='presence'                                             # Jabberd2 
    6969NS_PRIVACY      ='jabber:iq:privacy' 
    7070NS_PRIVATE      ='jabber:iq:private' 
    71 NS_PROFILE      ='http://jabber.org/protocol/profile'                   # JEP-0154 
    72 NS_PUBSUB       ='http://jabber.org/protocol/pubsub'                    # JEP-0060 
     71NS_PROFILE      ='http://jabber.org/protocol/profile'                   # XEP-0154 
     72NS_PUBSUB       ='http://jabber.org/protocol/pubsub'                    # XEP-0060 
    7373NS_REGISTER     ='jabber:iq:register' 
    7474NS_ROSTER       ='jabber:iq:roster' 
    75 NS_ROSTERX      ='http://jabber.org/protocol/rosterx'                   # JEP-0144 
    76 NS_RPC          ='jabber:iq:rpc'                                        # JEP-0009 
     75NS_ROSTERX      ='http://jabber.org/protocol/rosterx'                   # XEP-0144 
     76NS_RPC          ='jabber:iq:rpc'                                        # XEP-0009 
    7777NS_SASL         ='urn:ietf:params:xml:ns:xmpp-sasl' 
    7878NS_SEARCH       ='jabber:iq:search' 
    7979NS_SERVER       ='jabber:server' 
    8080NS_SESSION      ='urn:ietf:params:xml:ns:xmpp-session' 
    81 NS_SI           ='http://jabber.org/protocol/si'                        # JEP-0096 
    82 NS_SI_PUB       ='http://jabber.org/protocol/sipub'                     # JEP-0137 
    83 NS_SIGNED       ='jabber:x:signed'                                      # JEP-0027 
     81NS_SI           ='http://jabber.org/protocol/si'                        # XEP-0096 
     82NS_SI_PUB       ='http://jabber.org/protocol/sipub'                     # XEP-0137 
     83NS_SIGNED       ='jabber:x:signed'                                      # XEP-0027 
    8484NS_STANZAS      ='urn:ietf:params:xml:ns:xmpp-stanzas' 
    8585NS_STREAM       ='http://affinix.com/jabber/stream' 
    8686NS_STREAMS      ='http://etherx.jabber.org/streams' 
    87 NS_TIME         ='jabber:iq:time'                                       # JEP-0900 
    88 NS_TIME_REVISED ='http://www.xmpp.org/extensions/xep-0202.html#ns'      # JEP-0202 
     87NS_TIME         ='jabber:iq:time'                                       # XEP-0900 
     88NS_TIME_REVISED ='urn:xmpp:time'                                        # XEP-0202 
    8989NS_TLS          ='urn:ietf:params:xml:ns:xmpp-tls' 
    9090NS_VACATION     ='http://jabber.org/protocol/vacation' 
     
    9595NS_VERSION      ='jabber:iq:version' 
    9696NS_PING         ='urn:xmpp:ping'                                        # XEP-0199 
    97 NS_WAITINGLIST  ='http://jabber.org/protocol/waitinglist'               # JEP-0130 
    98 NS_XHTML_IM     ='http://jabber.org/protocol/xhtml-im'                  # JEP-0071 
     97NS_WAITINGLIST  ='http://jabber.org/protocol/waitinglist'               # XEP-0130 
     98NS_XHTML_IM     ='http://jabber.org/protocol/xhtml-im'                  # XEP-0071 
    9999NS_XHTML        = 'http://www.w3.org/1999/xhtml'                        #  " 
    100 NS_DATA_LAYOUT  ='http://jabber.org/protocol/xdata-layout'              # JEP-0141 
    101 NS_DATA_VALIDATE='http://jabber.org/protocol/xdata-validate'            # JEP-0122 
     100NS_DATA_LAYOUT  ='http://jabber.org/protocol/xdata-layout'              # XEP-0141 
     101NS_DATA_VALIDATE='http://jabber.org/protocol/xdata-validate'            # XEP-0122 
    102102NS_XMPP_STREAMS ='urn:ietf:params:xml:ns:xmpp-streams' 
    103103 
     
    423423 
    424424    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). 
    426426            The parameter is the "inner html" to the body.""" 
    427427        try: 
     
    591591class DataField(Node): 
    592592    """ 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)  
    594594        then you will need to work with instances of this class. """ 
    595595    def __init__(self,name=None,value=None,typ=None,required=0,desc=None,options=[],node=None): 
     
    668668class DataForm(Node): 
    669669    """ DataForm class. Used for manipulating dataforms in XMPP. 
    670         Relevant JEPs: 0004, 0068, 0122. 
     670        Relevant XEPs: 0004, 0068, 0122. 
    671671        Can be used in disco, pub-sub and many other applications.""" 
    672672    def __init__(self, typ=None, data=[], title=None, node=None):