xtalk (1.3-15.1) direct (non packaging) changes

Summary

 README    |    4 +--
 Talk.py   |   76 +++++++++++++++++++++++++++++++++++---------------------------
 finger.py |    4 +--
 talkd.py  |   29 ++++++++++++-----------
 xtalk.1   |   27 ++++++++++++++++++++++
 5 files changed, 90 insertions(+), 50 deletions(-)

    
download this patch

Patch contents

--- xtalk-1.3.orig/Talk.py
+++ xtalk-1.3/Talk.py
@@ -29,7 +29,7 @@
 
 from Tkinter import *
 from ScrolledText import ScrolledText
-import TalkdInter, string, regex, errno
+import TalkdInter, string, re, errno
 
 versionMajor = 1
 versionMinor = 3
@@ -41,7 +41,7 @@
     # used to raise exceptions
     error = 'TalkError'
     
-    def __init__(self, parent=None, addr):
+    def __init__(self, parent=None, addr=None):
 	self.sock = None
 	self.afterId = None
 	self.servSock = None
@@ -51,12 +51,12 @@
 	self.pack(fill=BOTH, expand=TRUE)
 
 	self.makeControls()
-	self.makeEntry()
 	self.makeEdits()
-	self.entry.var.set(addr)
+	self.buttons.var.set(addr)
 	self.status = Label(self, relief=SUNKEN)
 	self.status.pack(side=TOP, fill=X, expand=FALSE)
-	self.entry.address.focus()
+	self.buttons.address.focus()
+        
     
     ##### callback functions
     def quit(self):
@@ -65,13 +65,13 @@
 
     def connect(self, event=None):
 	try:
-	    address = self.parseAddress(self.entry.var.get())
+	    address = self.parseAddress(self.buttons.var.get())
 	except Talk.error, msg:
 	    self.status['text'] = msg
 	    return
 
 	# Disable "connect" event handler, enable disconnect
-	self.entry.address.unbind('<Return>')
+	self.buttons.address.unbind('<Return>')
 	self.buttons.connect.config(state=DISABLED)
 	self.buttons.disconnect.config(state=NORMAL)
 	
@@ -103,17 +103,15 @@
 					 command=self.disconnect,
 					 state=DISABLED)
 	self.buttons.disconnect.pack(side=LEFT, padx=2, pady=2)
-
-    def makeEntry(self):
-	self.entry = Frame(self, relief=RAISED)
-	self.entry.pack(side=TOP, fill=X)
-	self.entry.lab = Label(self.entry, text='Address')
-	self.entry.lab.pack(side=LEFT)
-	self.entry.var = StringVar()
-
-	self.entry.address = Entry(self.entry, textvariable=self.entry.var)
-	self.entry.address.pack(side=LEFT, fill=X, expand=TRUE)
-	self.entry.address.bind('<Return>', self.connect)
+
+	self.buttons.lab = Label(self.buttons, text='Address')
+	self.buttons.lab.pack(side=LEFT)
+	self.buttons.var = StringVar()
+
+	self.buttons.address = Entry(self.buttons, textvariable=self.buttons.var)
+	self.buttons.address.pack(side=LEFT, fill=X, expand=TRUE)
+	self.buttons.address.bind('<Return>', self.connect)
+
 
     def makeEdits(self):
 	self.edit = Frame(self, relief=RAISED)
@@ -138,14 +136,28 @@
  	# parses a an address as entered by a user, and returns a
  	# tuple (remote-host, remote-user, remote-tty) or raises a
  	# Talk.error exception if there's an error in address.	
-	rx = regex.compile("\(^[^ \t@]+\)\(@\([^ \t@]+\)\)?\([ \t]+\(\w+\)\)?$")
-	if rx.match(string.strip(addr)) > 0:
-	    ruser, rhost, rtty = rx.group(1, 3, 5)
-	    if not rhost:
-		rhost = 'localhost'
-	    if not rtty:
-		rtty = ''
-	    return (rhost, ruser, rtty)
+	#rx = re.compile("\(^[^ \t@]+\)\(@\([^ \t@]+\)\)?\([ \t]+\(\w+\)\)?$")
+	ruatty = string.split(addr)
+	rua = ruatty[0]
+	if len(ruatty)>1:
+	    rtty = ruatty[1]
+	else:
+	    rtty = ''
+	#if rx.match(string.strip(addr)) > 0:
+	#    ruser, rhost, rtty = rx.group(1, 3, 5)
+	#    if not rhost:
+	#	rhost = 'localhost'
+	#    if not rtty:
+	#	rtty = ''
+	#    return (rhost, ruser, rtty)
+	ruh = string.split(rua, '@')
+	ruser = ruh[0]
+	if len(ruh)>1:
+	    rhost = ruh[1]
+	else:
+	    rhost = 'localhost'
+        if ruser:
+            return (rhost, ruser, rtty)
 	else:
 	    raise Talk.error, "Bad address format given."
 
@@ -161,11 +173,11 @@
 		pass
 	    self.talkd = None
 	if self.servSock:
-	    tkinter.deletefilehandler(self.servSock)
+	    self.tk.deletefilehandler(self.servSock)
 	    self.servSock.close()
 	    self.servSock = None
 	if self.sock:
-	    tkinter.deletefilehandler(self.sock)
+	    self.tk.deletefilehandler(self.sock)
 	    self.edit.local.config(state=DISABLED)
 	    self.edit.local.unbind('<Key>')
 	    
@@ -177,7 +189,7 @@
 	    self.sock = None
 	    
 	# enable "connect" event handler, disable disconnect
-	self.entry.address.bind('<Return>', self.connect)
+	self.buttons.address.bind('<Return>', self.connect)
 	self.buttons.connect.config(state=NORMAL)
 	self.buttons.disconnect.config(state=DISABLED)
 
@@ -218,7 +230,7 @@
 	self.status['text'] = "Ringing remote party..."
 	self.numTries = 1
 
-	tkinter.createfilehandler(self.servSock, tkinter.READABLE,
+	self.tk.createfilehandler(self.servSock, tkinter.READABLE,
 				  self.acceptConnection)
 	
 	# announce again after 30 seconds
@@ -239,7 +251,7 @@
     def acceptConnection(self, file, mask):
 	acc = self.servSock.accept()
 	self.status['text'] = "Accepted connection from " + `acc[1]`
-	tkinter.deletefilehandler(self.servSock)
+	self.tk.deletefilehandler(self.servSock)
 	self.sock = acc[0]
 	self.servSock.close()
 	self.servSock = None
@@ -270,7 +282,7 @@
 	    
 	self.editChars = self.sock.recv(3)
 	
-	tkinter.createfilehandler(self.sock, tkinter.READABLE,
+	self.tk.createfilehandler(self.sock, tkinter.READABLE,
 				  self.handleRemoteInput)
 	self.sock.setblocking(0)
 
--- xtalk-1.3.orig/xtalk.1
+++ xtalk-1.3/xtalk.1
@@ -0,0 +1,27 @@
+.TH XTALK 1
+.SH NAME
+xtalk \- X Window System BSD compatible talk client, written in Python.
+.SH SYNOPSIS
+.B xtalk
+.BI [user[@address[\ tty]]
+.SH DESCRIPTION
+
+When started, xtalk won't actually try to connect until you click on the
+"Connect" button in the program.  xtalk accepts addresses in the same
+format as the regular BSD talk program.  From in the program you can
+enter the address in the "Address" entry.  At any point during a talk
+session, clicking on "Disconnect" disconnects the session.
+
+The format of a talk address is as follows.  To talk to a user on the
+same host, just use "username" as the address.  To talk to a user on another
+host, use "username@hostname" as the address.  If the user is logged in several
+times, you can specify which tty to "page" them on by saying "username tty" or
+"username@hostname tty".
+
+.SH AUTHOR
+Adam P. Jenkins (adampjenkins@yahoo.com)
+.SH "SEE ALSO"
+.BR talk "(1)
+.SH BUGS
+From user point of view, it seems that his own text in the window is editable,
+whereas in fact it is not.
--- xtalk-1.3.orig/talkd.py
+++ xtalk-1.3/talkd.py
@@ -20,7 +20,7 @@
 
 # Implements the C structures for talking to a talk daemon
 
-import struct, regex, regsub, socket, string
+import struct, re, socket, string
 
 # This modules defines classes necessary to communicate with a talk
 # daemon.  The talk daemon requires communication via binary data
@@ -86,27 +86,27 @@
 BADCTLADDR = 8
 
 def htons(n):
-    return struct.pack('bb', n >> 8, n & 0xff)
-
+    return struct.pack('BB', n >> 8, n & 0xff)
+
 def htonl(n):
-    return struct.pack('4b', n >> 24, n >> 16, n >> 8, n & 0xff)
+    return struct.pack('!l', n)
 
 def htonb(n):
-    return struct.pack('b', n)
+    return struct.pack('B', n)
 
 def ntohs(n):
-    hi, low = struct.unpack('bb', n)
+    hi, low = struct.unpack('BB', n)
     return ((hi & 0xff) << 8) + (low & 0xff)
 
 def ntohl(n):
-    tmp = struct.unpack('4b', n)
+    tmp = struct.unpack('4B', n)
     return (((tmp[0] & 0xff) << 24) +
 	    ((tmp[1] & 0xff) << 16) +
 	    ((tmp[2] & 0xff) << 8) +
 	    (tmp[3] & 0xff))
 
 def ntohb(n):
-    tmp = struct.unpack('b', n)
+    tmp = struct.unpack('B', n)
     return (tmp[0] & 0xff)
 
 
@@ -123,18 +123,19 @@
 	# make sure address is in numbers-dots notation
 	addr = socket.gethostbyname(self.address)
 	# break it up into components
-	addr = regsub.split(addr, '\.')
+	#addr = regsub.split(addr, '\.')
+        addr = string.split(addr, '.')
 	# and convert them to numbers
 	addr = map(string.atoi, addr)
 
 	return (htons(self.family) + htons(self.port) +
-		struct.pack('4b8x', addr[0], addr[1], addr[2], addr[3]))
+		struct.pack('4B8x', addr[0], addr[1], addr[2], addr[3]))
 
     def fromCStruct(self, str):
 	self.family = ntohs(str[0:2])
 	self.port = ntohs(str[2:4])
 
-	addr = struct.unpack('bbbb', str[4:8])
+	addr = struct.unpack('BBBB', str[4:8])
 	addr = map(lambda x: x & 0xff, addr)
 	self.address = '%d.%d.%d.%d' % (addr[0], addr[1], addr[2], addr[3])
 
@@ -165,9 +166,9 @@
 	self.addr.fromCStruct(str[8:24])
 	self.ctlAddr.fromCStruct(str[24:40])
 	self.pid = ntohl(str[40:44])
-	self.localName = regsub.sub('\0*$', '', str[44:56])
-	self.remoteName = regsub.sub('\0*$', '', str[56:68])
-	self.remoteTTY = regsub.sub('\0*$', '', str[68:84])
+	self.localName = re.sub('\0*$', '', str[44:56])
+	self.remoteName = re.sub('\0*$', '', str[56:68])
+	self.remoteTTY = re.sub('\0*$', '', str[68:84])
 	
 
 class CTL_RESPONSE:
--- xtalk-1.3.orig/finger.py
+++ xtalk-1.3/finger.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import regex, socket, sys
+import re, socket, sys
 from Tkinter import *
 
 error = "fingerError"
@@ -15,7 +15,7 @@
     return fp.read()
 
 def parseQuery(query):
-    rx = regex.compile("^\([^ \t@]+\)?\(@\([^ \t]+\)\)?$")
+    rx = re.compile("^\([^ \t@]+\)?\(@\([^ \t]+\)\)?$")
     if rx.match(query) > 0:
 	user, host = rx.group(1, 3)
 	if not user: user = ""
--- xtalk-1.3.orig/README
+++ xtalk-1.3/README
@@ -1,11 +1,11 @@
-What: X-Windows BSD compatible talk client, written in Python.
+What: X Window System BSD compatible talk client, written in Python.
 
 Author: Adam P. Jenkins <adampjenkins@yahoo.com>
 
 Requirements: 
   Python 1.4, 
   Tkinter package, 
-  X-Windows.  
+  X Window System.
   I suppose you could use it in Windows if Tkinter is ported to it, but
 xtalk also uses Unix socket calls, and I don't know if those are
 portable.