Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Support more subtleties of XMPP presence; "type" field basically means you're offline. Seem to be tracking Jane/Amri along with the n910's XMPP stack behavior. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | master | trunk |
Files: | files | file ages | folders |
SHA3-256: | 6e2093a529779eaa5d3d0078ba9023db |
User & Date: | ajv-899-334-8894@vsta.org 2018-03-13 03:59:48 |
Context
2018-03-13
| ||
04:00 | Some debug support tooling for presence data structures check-in: 5bf9f900bf user: ajv-899-334-8894@vsta.org tags: master, trunk | |
03:59 | Support more subtleties of XMPP presence; "type" field basically means you're offline. Seem to be tracking Jane/Amri along with the n910's XMPP stack behavior. check-in: 6e2093a529 user: ajv-899-334-8894@vsta.org tags: master, trunk | |
02:29 | Blacklist in its own file, update from it on demand. check-in: 93ec53def7 user: ajv-899-334-8894@vsta.org tags: master, trunk | |
Changes
Changes to acct_xmpp.py.
1 2 3 4 5 6 7 8 9 10 11 12 .. 53 54 55 56 57 58 59 60 61 62 63 64 65 66 .. 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# # user.py # User state # import sys, os, xmpp, time from chore.utils import toascii # Build an account name from a JID node def aname(jid): u = toascii(jid.node) d = toascii(jid.domain) return "%s@%s" % (u, d) ................................................................................ # and exit() def stop(self, tid): self.stopping = True # Update to presence status of somebody def presence(self, conn, presence): user = self.user # Decode who sent to us # Note it can be somebody we haven't heard about; presence # can arrive before our roster request is fulfilled. # XMPP is a beast. n = presence.attrs.get("from") if not n: ................................................................................ return sender = n.node senddom = n.domain if (not sender) or (not senddom): return who = sender + "@" + senddom # Decode status (i.e., "show") update sys.stderr.write("presence: %s\n" % (who,)) anystat = bool(presence.kids) for kid in presence.kids: # Decode initial part of data d0 = None if len(kid.data) > 0: d0 = toascii(kid.data[0]) if not isinstance(d0, str): d0 = None # Away status kn = toascii(kid.name) sys.stderr.write("%s %s\n" % (kn, d0)) if kn == "priority": # If they're actually online, this'll show anystat = True if kn == "show": if d0 is None: continue if user.status.get(who, "NEW") != d0: sys.stderr.write(" updated %d\n" % (user.rgen,)) user.status[who] = d0 user.rgen += 1 break # TBD, "status" is a descriptive string # If "show" didn't break the loop, they're available else: if anystat: newstat = "xa" else: newstat = "offline" if newstat != user.status.get(who, "NEW"): sys.stderr.write("no show, updating to assume %s %d\n" % (newstat, user.rgen)) user.rgen += 1 user.status[who] = newstat # Update our presence |
| > > > > > > > > > > > > > > > > > > > > > > > > < < < < < | < < |
1 2 3 4 5 6 7 8 9 10 11 12 .. 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 .. 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# # user.py # User state # import sys, os, xmpp, time, cPickle from chore.utils import toascii # Build an account name from a JID node def aname(jid): u = toascii(jid.node) d = toascii(jid.domain) return "%s@%s" % (u, d) ................................................................................ # and exit() def stop(self, tid): self.stopping = True # Update to presence status of somebody def presence(self, conn, presence): user = self.user # Debug, log so we can break out all the stupid XMPP cases if True: f = open("/tmp/xmpp_presence.log", "a") cPickle.dump(presence, f) f.write("\n\n") f.close() # Decode who sent to us # Note it can be somebody we haven't heard about; presence # can arrive before our roster request is fulfilled. # XMPP is a beast. n = presence.attrs.get("from") if not n: ................................................................................ return sender = n.node senddom = n.domain if (not sender) or (not senddom): return who = sender + "@" + senddom # If they have a type, it's most likely "unavailable" # and indicates somebody on our configured roster who # is not online attrs = presence.attrs if "type" in attrs: if attrs["type"] != "unavailable": sys.stderr.write("Status type not 'unavailable': %s\n" % (attrs["type"],)) newstat = "offline" if user.status.get(who, "NEW") != newstat: sys.stderr.write("%s offline\n" % (who,)) user.status[who] = newstat user.rgen += 1 return # Without that, they should be online # Decode status (i.e., "show") update sys.stderr.write("presence: %s\n" % (who,)) for kid in presence.kids: # Decode initial part of data d0 = None if len(kid.data) > 0: d0 = toascii(kid.data[0]) if not isinstance(d0, str): d0 = None # Away status kn = toascii(kid.name) sys.stderr.write("%s %s\n" % (kn, d0)) if kn == "show": if d0 is None: continue if user.status.get(who, "NEW") != d0: sys.stderr.write(" updated %d\n" % (user.rgen,)) user.status[who] = d0 user.rgen += 1 break # TBD, "status" is a descriptive string # If "show" didn't break the loop, they're available else: newstat = "available" if newstat != user.status.get(who, "NEW"): sys.stderr.write("no show, updating to assume %s %d\n" % (newstat, user.rgen)) user.rgen += 1 user.status[who] = newstat # Update our presence |