improve subscription request message, ability to save it. Fixes #2176
This commit is contained in:
parent
d8c3e6f39f
commit
ebf9407c5d
5 changed files with 81 additions and 24 deletions
|
@ -44,6 +44,7 @@
|
||||||
<object class="GtkComboBox" id="account_combobox">
|
<object class="GtkComboBox" id="account_combobox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="model">liststore3</property>
|
<property name="model">liststore3</property>
|
||||||
|
<signal name="changed" handler="on_account_combobox_changed"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext3"/>
|
<object class="GtkCellRendererText" id="cellrenderertext3"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -256,6 +257,19 @@
|
||||||
<property name="position">5</property>
|
<property name="position">5</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="save_message_checkbutton">
|
||||||
|
<property name="label" translatable="yes">_Save subscription message</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">6</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkHBox" id="register_hbox">
|
<object class="GtkHBox" id="register_hbox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -293,7 +307,7 @@ proceed.</property>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">6</property>
|
<property name="position">7</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -306,7 +320,7 @@ to add a contact from this protocol.</property>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="position">7</property>
|
<property name="position">8</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -352,7 +366,7 @@ to add a contact from this protocol.</property>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="position">8</property>
|
<property name="position">9</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -365,6 +365,7 @@ class Config:
|
||||||
'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')],
|
'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')],
|
||||||
'send_idle_time': [ opt_bool, True ],
|
'send_idle_time': [ opt_bool, True ],
|
||||||
'roster_version': [opt_str, ''],
|
'roster_version': [opt_str, ''],
|
||||||
|
'subscription_request_msg': [opt_str, '', _('Message that is sent to contacts you want to add')],
|
||||||
}, {}),
|
}, {}),
|
||||||
'statusmsg': ({
|
'statusmsg': ({
|
||||||
'message': [ opt_str, '' ],
|
'message': [ opt_str, '' ],
|
||||||
|
|
|
@ -41,6 +41,7 @@ import hashlib
|
||||||
import caps_cache
|
import caps_cache
|
||||||
|
|
||||||
from encodings.punycode import punycode_encode
|
from encodings.punycode import punycode_encode
|
||||||
|
from string import Template
|
||||||
|
|
||||||
from i18n import Q_
|
from i18n import Q_
|
||||||
from i18n import ngettext
|
from i18n import ngettext
|
||||||
|
@ -1329,4 +1330,27 @@ def group_is_blocked(account, group):
|
||||||
return ((group in gajim.connections[account].blocked_groups) or \
|
return ((group in gajim.connections[account].blocked_groups) or \
|
||||||
gajim.connections[account].blocked_all)
|
gajim.connections[account].blocked_all)
|
||||||
|
|
||||||
|
def get_subscription_request_msg(account=None):
|
||||||
|
s = gajim.config.get_per('accounts', account, 'subscription_request_msg')
|
||||||
|
if s:
|
||||||
|
return s
|
||||||
|
s = _('I would like to add you to my contact list.')
|
||||||
|
if account:
|
||||||
|
s = _('Hello, I am $name.') + ' ' + s
|
||||||
|
our_jid = gajim.get_jid_from_account(account)
|
||||||
|
vcard = gajim.connections[account].get_cached_vcard(our_jid)
|
||||||
|
name = ''
|
||||||
|
if 'N' in vcard:
|
||||||
|
if 'GIVEN' in vcard['N'] and 'FAMILY' in vcard['N']:
|
||||||
|
name = vcard['N']['GIVEN'] + ' ' + vcard['N']['FAMILY']
|
||||||
|
if not name:
|
||||||
|
if 'FN' in vcard:
|
||||||
|
name = vcard['FN']
|
||||||
|
nick = gajim.nicks[account]
|
||||||
|
if name and nick:
|
||||||
|
name += ' (%s)' % nick
|
||||||
|
elif nick:
|
||||||
|
name = nick
|
||||||
|
s = Template(s).safe_substitute({'name': name})
|
||||||
|
return s
|
||||||
# vim: se ts=3:
|
# vim: se ts=3:
|
||||||
|
|
|
@ -862,15 +862,16 @@ class AddNewContactWindow:
|
||||||
for w in ('account_combobox', 'account_hbox', 'account_label',
|
for w in ('account_combobox', 'account_hbox', 'account_label',
|
||||||
'uid_label', 'uid_entry', 'protocol_combobox', 'protocol_jid_combobox',
|
'uid_label', 'uid_entry', 'protocol_combobox', 'protocol_jid_combobox',
|
||||||
'protocol_hbox', 'nickname_entry', 'message_scrolledwindow',
|
'protocol_hbox', 'nickname_entry', 'message_scrolledwindow',
|
||||||
'register_hbox', 'subscription_table', 'add_button',
|
'save_message_checkbutton', 'register_hbox', 'subscription_table',
|
||||||
'message_textview', 'connected_label', 'group_comboboxentry',
|
'add_button', 'message_textview', 'connected_label',
|
||||||
'auto_authorize_checkbutton'):
|
'group_comboboxentry', 'auto_authorize_checkbutton'):
|
||||||
self.__dict__[w] = self.xml.get_object(w)
|
self.__dict__[w] = self.xml.get_object(w)
|
||||||
if account and len(gajim.connections) >= 2:
|
if account and len(gajim.connections) >= 2:
|
||||||
prompt_text = \
|
prompt_text = \
|
||||||
_('Please fill in the data of the contact you want to add in account %s') % account
|
_('Please fill in the data of the contact you want to add in account %s') % account
|
||||||
else:
|
else:
|
||||||
prompt_text = _('Please fill in the data of the contact you want to add')
|
prompt_text = \
|
||||||
|
_('Please fill in the data of the contact you want to add')
|
||||||
self.xml.get_object('prompt_label').set_text(prompt_text)
|
self.xml.get_object('prompt_label').set_text(prompt_text)
|
||||||
self.agents = {'jabber': []}
|
self.agents = {'jabber': []}
|
||||||
# types to which we are not subscribed but account has an agent for it
|
# types to which we are not subscribed but account has an agent for it
|
||||||
|
@ -990,6 +991,11 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
|
||||||
self.account_combobox.set_model(liststore)
|
self.account_combobox.set_model(liststore)
|
||||||
self.account_combobox.set_active(0)
|
self.account_combobox.set_active(0)
|
||||||
|
|
||||||
|
if self.account:
|
||||||
|
message_buffer = self.message_textview.get_buffer()
|
||||||
|
message_buffer.set_text(helpers.get_subscription_request_msg(
|
||||||
|
self.account))
|
||||||
|
|
||||||
def on_add_new_contact_window_destroy(self, widget):
|
def on_add_new_contact_window_destroy(self, widget):
|
||||||
if self.account:
|
if self.account:
|
||||||
location = gajim.interface.instances[self.account]
|
location = gajim.interface.instances[self.account]
|
||||||
|
@ -1066,6 +1072,9 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
|
||||||
start_iter = message_buffer.get_start_iter()
|
start_iter = message_buffer.get_start_iter()
|
||||||
end_iter = message_buffer.get_end_iter()
|
end_iter = message_buffer.get_end_iter()
|
||||||
message = message_buffer.get_text(start_iter, end_iter).decode('utf-8')
|
message = message_buffer.get_text(start_iter, end_iter).decode('utf-8')
|
||||||
|
if self.save_message_checkbutton.get_active():
|
||||||
|
gajim.config.set_per('accounts', self.account,
|
||||||
|
'subscription_request_msg', message)
|
||||||
else:
|
else:
|
||||||
message= ''
|
message= ''
|
||||||
group = self.group_comboboxentry.child.get_text().decode('utf-8')
|
group = self.group_comboboxentry.child.get_text().decode('utf-8')
|
||||||
|
@ -1077,6 +1086,13 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
|
||||||
groups=groups, nickname=nickname, auto_auth=auto_auth)
|
groups=groups, nickname=nickname, auto_auth=auto_auth)
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
|
def on_account_combobox_changed(self, widget):
|
||||||
|
model = widget.get_model()
|
||||||
|
iter_ = widget.get_active_iter()
|
||||||
|
account = model[iter_][0]
|
||||||
|
message_buffer = self.message_textview.get_buffer()
|
||||||
|
message_buffer.set_text(helpers.get_subscription_request_msg(account))
|
||||||
|
|
||||||
def on_protocol_combobox_changed(self, widget):
|
def on_protocol_combobox_changed(self, widget):
|
||||||
model = widget.get_model()
|
model = widget.get_model()
|
||||||
iter_ = widget.get_active_iter()
|
iter_ = widget.get_active_iter()
|
||||||
|
@ -1097,8 +1113,10 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
|
||||||
self.uid_label.set_text(_('User ID:'))
|
self.uid_label.set_text(_('User ID:'))
|
||||||
if type_ == 'jabber':
|
if type_ == 'jabber':
|
||||||
self.message_scrolledwindow.show()
|
self.message_scrolledwindow.show()
|
||||||
|
self.save_message_checkbutton.show()
|
||||||
else:
|
else:
|
||||||
self.message_scrolledwindow.hide()
|
self.message_scrolledwindow.hide()
|
||||||
|
self.save_message_checkbutton.hide()
|
||||||
if type_ in self.available_types:
|
if type_ in self.available_types:
|
||||||
self.register_hbox.show()
|
self.register_hbox.show()
|
||||||
self.auto_authorize_checkbutton.hide()
|
self.auto_authorize_checkbutton.hide()
|
||||||
|
|
Loading…
Add table
Reference in a new issue