Ejemplo n.º 1
0
	def __init__(self, master, wizard, vars):
		Tkinter.Frame.__init__(self, master)
		self.wizard = wizard
		self.vars = vars
		self.title = 'Enter User ID'
		self.gale_user = Tkinter.StringVar()
		user = pygale.gale_user()
		self.gale_user.set(user)
		self.grid_propagate(0)
		self.grid_rowconfigure(0, weight = 1)
		self.grid_rowconfigure(1, weight = 1)
		self.grid_columnconfigure(0, weight = 1)
		self.label = Tkinter.Label(self, wraplength = 310, anchor = 'nw', justify = 'left', text = "Gale user id\n\nEnter your Gale id.  This id identifies you to other Gale users.  You must have a valid public/private key pair for this id.")
		self.entry = Tkinter.Entry(self, textvariable = self.gale_user)
Ejemplo n.º 2
0
 def __init__(self, master, wizard, vars):
     Tkinter.Frame.__init__(self, master)
     self.wizard = wizard
     self.vars = vars
     self.title = 'Enter User ID'
     self.gale_user = Tkinter.StringVar()
     user = pygale.gale_user()
     self.gale_user.set(user)
     self.grid_propagate(0)
     self.grid_rowconfigure(0, weight=1)
     self.grid_rowconfigure(1, weight=1)
     self.grid_columnconfigure(0, weight=1)
     self.label = Tkinter.Label(
         self,
         wraplength=310,
         anchor='nw',
         justify='left',
         text=
         "Gale user id\n\nEnter your Gale id.  This id identifies you to other Gale users.  You must have a valid public/private key pair for this id."
     )
     self.entry = Tkinter.Entry(self, textvariable=self.gale_user)
Ejemplo n.º 3
0
def on_connect(host, conn, sub, quiet):
	print_msg('Connected to %s' % host)

	if not quiet:
		sender = gale_env.get('GALE_FROM', 'Unknown sender')
		pygale.notify_in('in.present', conn, fullname=sender)
		pygale.notify_out('out.disconnected', conn, fullname=sender)

	# Subscribe to a list of locations
	# Add in our location if not there
	myid = pygale.gale_user()
	if myid not in sub:
		sub.append(myid)
	bad, good = conn.sub_to(sub)
	if bad:
		for b in bad:
			print_msg('Unable to find location %s' % b)
	if not good:
		print_msg('No locations found')
		sys.exit(-1)
	else:
		for g in good:
			print_msg('Subscribed to %s' % g)
Ejemplo n.º 4
0
def sendpuff(locs, keywords):
	# Look up locations
	ret = pygale.lookup_all_locations(locs)
	send_locs = []
	bad_locs = []
	encr_recipients = []
	for (loc, recps) in ret:
		if recps is None:
			bad_locs.append(loc)
		else:
			send_locs.append(loc)
			encr_recipients = encr_recipients + recps
	if bad_locs:
		print 'Error: no valid recipients'
		sys.exit(-1)
	if '' in encr_recipients:
		# null key
		encr_recipients = []
	
	# Print the header
	bolded_locs = map(prettypuff.bold_location, send_locs)
	header = 'To: %s' % string.join(bolded_locs, ' ')
	if keywords:
		bolded_keywords = map(prettypuff.bold_keyword, keywords)
		bolded_keywords = map(lambda x: '/' + x, bolded_keywords)
		header = header + ' ' + string.join(bolded_keywords, ' ')
	print header
	print '(End your message with EOF or a solitary dot.)'

	# Get the puff text
	pufftext = enter_puff()

	# Construct puff
	signer = pygale.gale_user()
	puff = pygale.Puff()
	gfrom = gale_env.get('GALE_NAME',
		gale_env.get('GALE_FROM', 'PyGale user'))
	puff.set_loc(string.join(locs, ' '))
	puff.set_text('message/sender', gfrom)
	puff.set_time('id/time', int(time.time()))
	puff.set_text('id/class', 'gsend.py/%s' % version.VERSION)
	puff.set_text('id/instance', pygale.getinstance())
	if RETURN_RECEIPT:
		puff.set_text('question.receipt', signer)
	if keywords:
		for keyw in keywords:
			puff.set_text('message.keyword', keyw)
	puff.set_text('message/body', pufftext)

	# Sign
	ret = puff.sign_message(signer)
	if ret is None:
		# unable to sign
		signed_puff = puff
	else:
		signed_puff = ret

	# Encrypt
	if encr_recipients:
		ret = signed_puff.encrypt_message(encr_recipients)
		if ret is None:
			# unable to encrypt
			encrypted_puff = signed_puff
		else:
			encrypted_puff = ret
	else:
		encrypted_puff = signed_puff
	
	# Create gale connection
	c = pygale.GaleClient()
	if not DONT_SEND:
		c.connect()
		c.transmit_puff(encrypted_puff)
		print 'Message sent.'
	else:
		print `c.swizzle_puff(encrypted_puff)`
		print 'Message NOT sent.'