Welcome to mirror list, hosted at ThFree Co, Russian Federation.

groups.py « src - dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c8f0c549274195f7299b67c0f4c64a160d8f26d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''Window to create new post for discussion groups service.'''

import gtk

from common import gajim, xmpp
import gtkgui_helpers

class GroupsPostWindow:
	def __init__(self, account, servicejid, groupid):
		'''Open new 'create post' window to create message for groupid on servicejid service.'''
		assert isinstance(servicejid, basestring)
		assert isinstance(groupid, basestring)

		self.account = account
		self.servicejid = servicejid
		self.groupid = groupid

		self.xml = gtkgui_helpers.get_glade('groups_post_window.glade')
		self.window = self.xml.get_widget('groups_post_window')
		for name in ('from_entry', 'subject_entry', 'contents_textview'):
			self.__dict__[name] = self.xml.get_widget(name)

		self.xml.signal_autoconnect(self)
		self.window.show_all()

	def on_cancel_button_clicked(self, w):
		'''Close window.'''
		self.window.destroy()

	def on_send_button_clicked(self, w):
		'''Gather info from widgets and send it as a message.'''
		# constructing item to publish... that's atom:entry element
		item = xmpp.Node('entry', {'xmlns':'http://www.w3.org/2005/Atom'})
		author = item.addChild('author')
		author.addChild('name', {}, [self.from_entry.get_text()])
		item.addChild('generator', {}, ['Gajim'])
		item.addChild('title', {}, [self.subject_entry.get_text()])
		item.addChild('id', {}, ['0'])

		buffer = self.contents_textview.get_buffer()
		item.addChild('content', {}, [buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter())])

		# publish it to node
		gajim.connections[self.account].send_pb_publish(self.servicejid, self.groupid, item, '0')

		# close the window
		self.window.destroy()

# vim: se ts=3: