4 ## Copyright (C) 2006 Yann Leboulanger <asterix AT lagaule.org>
5 ## Tomasz Melcer <liori AT exroot.org>
7 ## This file is part of Gajim.
9 ## Gajim is free software; you can redistribute it and/or modify
10 ## it under the terms of the GNU General Public License as published
11 ## by the Free Software Foundation; version 3 only.
13 ## Gajim is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ## GNU General Public License for more details.
18 ## You should have received a copy of the GNU General Public License
19 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
22 '''Window to create new post for discussion groups service.'''
24 from common
import gajim
, xmpp
27 class GroupsPostWindow
:
28 def __init__(self
, account
, servicejid
, groupid
):
29 '''Open new 'create post' window to create message for groupid on servicejid service.'''
30 assert isinstance(servicejid
, basestring
)
31 assert isinstance(groupid
, basestring
)
33 self
.account
= account
34 self
.servicejid
= servicejid
35 self
.groupid
= groupid
37 self
.xml
= gtkgui_helpers
.get_glade('groups_post_window.glade')
38 self
.window
= self
.xml
.get_widget('groups_post_window')
39 for name
in ('from_entry', 'subject_entry', 'contents_textview'):
40 self
.__dict
__[name
] = self
.xml
.get_widget(name
)
42 self
.xml
.signal_autoconnect(self
)
43 self
.window
.show_all()
45 def on_cancel_button_clicked(self
, w
):
49 def on_send_button_clicked(self
, w
):
50 '''Gather info from widgets and send it as a message.'''
51 # constructing item to publish... that's atom:entry element
52 item
= xmpp
.Node('entry', {'xmlns':'http://www.w3.org/2005/Atom'})
53 author
= item
.addChild('author')
54 author
.addChild('name', {}, [self
.from_entry
.get_text()])
55 item
.addChild('generator', {}, ['Gajim'])
56 item
.addChild('title', {}, [self
.subject_entry
.get_text()])
57 item
.addChild('id', {}, ['0'])
59 buf
= self
.contents_textview
.get_buffer()
60 item
.addChild('content', {}, [buf
.get_text(buf
.get_start_iter(), buf
.get_end_iter())])
63 gajim
.connections
[self
.account
].send_pb_publish(self
.servicejid
, self
.groupid
, item
, '0')