webXMPP

Check-in [7ff7888f34]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bringup, actual notification delivery
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:7ff7888f34461f1e238e1435dfb19ad02f288ffa78fc19173b6cbaceb8195e10
User & Date: vandyswa@gmail.com 2017-06-29 18:09:49
Context
2017-06-29
18:29
Initial markups, actual phone notifications check-in: cea9e18da0 user: vandyswa@gmail.com tags: master, trunk
18:09
Bringup, actual notification delivery check-in: 7ff7888f34 user: vandyswa@gmail.com tags: master, trunk
2017-06-28
21:00
Bring up initial message notification get check-in: 4dd13877ea user: vandyswa@gmail.com tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to notified.py.

41
42
43
44
45
46
47

48
49
50
51
52
53
54
...
150
151
152
153
154
155
156
157





158
159
160
161
162
163
164
...
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#  that it's an XMPP message from Joe.  At detail 0, you
#  would only see that there were new events, but no other
#  detail.
#
# TBD: roster & presence.
#
import sys, json, time, os

import notify2
import pong
import pdb

# For DBus sniffing
import dbus, dbus.exceptions, dbus.mainloop.glib
import threading
................................................................................
    f = open(os.getenv("HOME") + "/.config/notify.json", "r")
    d = json.loads(f.read())
    f.close()
    cfg = DictOb(d)

# New notifications contained in this packet
def notify(pak):
    raise Exception("Notification: TBD")






# Endless execution, notification client
def run():
    global cfg, gen

    # Get a wrapper for our pong network connection
    conn = pong.Client(cfg.server, cfg.port, cfg.user, cfg.password)
................................................................................

        # Failure
        if resp is None:
            time.sleep(pong.WAITNET)
            continue

        # Nothing happened
        pdb.set_trace()
        if resp.inner["gen"] == gen:
            continue

        # New messages
        notify(resp)
        gen = resp["gen"]

if __name__ == "__main__":
    load_cfg()

    # No arg, just be a service daemon
    if len(sys.argv) == 1:
        run()







>







 







|
>
>
>
>
>







 







<





|







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
...
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
...
207
208
209
210
211
212
213

214
215
216
217
218
219
220
221
222
223
224
225
226
#  that it's an XMPP message from Joe.  At detail 0, you
#  would only see that there were new events, but no other
#  detail.
#
# TBD: roster & presence.
#
import sys, json, time, os
w = sys.stdout.write
import notify2
import pong
import pdb

# For DBus sniffing
import dbus, dbus.exceptions, dbus.mainloop.glib
import threading
................................................................................
    f = open(os.getenv("HOME") + "/.config/notify.json", "r")
    d = json.loads(f.read())
    f.close()
    cfg = DictOb(d)

# New notifications contained in this packet
def notify(pak):
    global gen, w

    inner = pak.inner
    w("Notification: gen %d -> %d\n" % (gen, inner["gen"]))
    for tup in inner["msgs"]:
        w("%r\n" % (tup,))

# Endless execution, notification client
def run():
    global cfg, gen

    # Get a wrapper for our pong network connection
    conn = pong.Client(cfg.server, cfg.port, cfg.user, cfg.password)
................................................................................

        # Failure
        if resp is None:
            time.sleep(pong.WAITNET)
            continue

        # Nothing happened

        if resp.inner["gen"] == gen:
            continue

        # New messages
        notify(resp)
        gen = resp.inner["gen"]

if __name__ == "__main__":
    load_cfg()

    # No arg, just be a service daemon
    if len(sys.argv) == 1:
        run()

Changes to udp.py.

57
58
59
60
61
62
63
64

65
66
67
68
69
70
71
..
98
99
100
101
102
103
104

105
106
107




108
109
110
111
112
113
114
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
	self.handler = handler
	self.user = user
	self.pak = pak

    # We've been kicked awake, either from timeout or due
    #  to new notifications.  Send back a response.
    def release(self):
	log(" resolve PONG to " + self.user.name)

	self.handler.notifications(self.user, self.pak)
	# We're all done
	self.handler = self.user = self.pak = None

class UDP(object):
    def __init__(self, cfg, approot):
	global TIMEOUT, accounts
................................................................................

    # Generate an answer packet with any new notifications
    def _notifications(self, user, inpak):
	det = inpak.inner["detail"]
	nmsg = inpak.inner["nmsg"]
	msgs = []
	resp = {"gen": user.gen, "msgs": msgs}

	for tup in user.msgs:
	    if len(msgs) > nmsg:
		break





	    # Assemble specified amount of detail
	    body = []
	    if det > 0:
		# Direction
		body.append(tup[1])
	    if det > 1:
................................................................................
		body.append(tup[2])
	    if det > 2:
		body.append(tup[3])
	    msgs.append(body)

	# Build reply packet around this inner message,
	#  and send
	pdb.set_trace()
	outpak = self.conn.pong(inpak, "got", resp)
	self.conn.reply(inpak, outpak)

    def notifications(self, user, pak):
	try:
	    self._notifications(user, pak)
	except:







|
>







 







>



>
>
>
>







 







<







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
..
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
122
123
124
125
126
127
128

129
130
131
132
133
134
135
	self.handler = handler
	self.user = user
	self.pak = pak

    # We've been kicked awake, either from timeout or due
    #  to new notifications.  Send back a response.
    def release(self):
	log(" resolve PONG to %s %r" %
	    (self.user.name, self.pak.who))
	self.handler.notifications(self.user, self.pak)
	# We're all done
	self.handler = self.user = self.pak = None

class UDP(object):
    def __init__(self, cfg, approot):
	global TIMEOUT, accounts
................................................................................

    # Generate an answer packet with any new notifications
    def _notifications(self, user, inpak):
	det = inpak.inner["detail"]
	nmsg = inpak.inner["nmsg"]
	msgs = []
	resp = {"gen": user.gen, "msgs": msgs}
	gen = inpak.inner["gen"]
	for tup in user.msgs:
	    if len(msgs) > nmsg:
		break

	    # Already seen?
	    if tup[0] < gen:
		continue

	    # Assemble specified amount of detail
	    body = []
	    if det > 0:
		# Direction
		body.append(tup[1])
	    if det > 1:
................................................................................
		body.append(tup[2])
	    if det > 2:
		body.append(tup[3])
	    msgs.append(body)

	# Build reply packet around this inner message,
	#  and send

	outpak = self.conn.pong(inpak, "got", resp)
	self.conn.reply(inpak, outpak)

    def notifications(self, user, pak):
	try:
	    self._notifications(user, pak)
	except: