2004-05-15 18:52:07 +02:00
|
|
|
## plugins/dialogs.py
|
2004-05-15 18:50:38 +02:00
|
|
|
##
|
|
|
|
## Gajim Team:
|
2005-01-07 22:52:38 +01:00
|
|
|
## - Yann Le Boulanger <asterix@lagaule.org>
|
2004-06-18 11:25:15 +02:00
|
|
|
## - Vincent Hanquez <tab@snarc.org>
|
2005-03-03 23:14:50 +01:00
|
|
|
## - Nikos Kouremenos <nkour@jabber.org>
|
2004-05-15 18:50:38 +02:00
|
|
|
##
|
2005-01-07 22:52:38 +01:00
|
|
|
## Copyright (C) 2003-2005 Gajim Team
|
2004-05-15 18:50:38 +02:00
|
|
|
##
|
|
|
|
## This program is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published
|
|
|
|
## by the Free Software Foundation; version 2 only.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
|
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
2005-03-01 14:46:22 +01:00
|
|
|
import gtk.glade
|
|
|
|
import gobject
|
2004-11-15 10:51:30 +01:00
|
|
|
import string
|
2004-05-17 01:47:14 +02:00
|
|
|
from common import i18n
|
|
|
|
_ = i18n._
|
|
|
|
APP = i18n.APP
|
|
|
|
gtk.glade.bindtextdomain (APP, i18n.DIR)
|
|
|
|
gtk.glade.textdomain (APP)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-02 11:23:27 +01:00
|
|
|
import gtkgui
|
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
|
|
|
|
|
|
|
|
|
2005-03-02 14:04:47 +01:00
|
|
|
class vcard_information_window:
|
2004-05-15 18:50:38 +02:00
|
|
|
"""Class for user's information window"""
|
2005-03-01 16:56:02 +01:00
|
|
|
def on_user_information_window_destroy(self, widget=None):
|
2004-05-15 18:50:38 +02:00
|
|
|
"""close window"""
|
2005-03-01 23:52:22 +01:00
|
|
|
del self.plugin.windows[self.account]['infos'][self.jid]
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 16:56:02 +01:00
|
|
|
def on_close_button_clicked(self, widget):
|
2004-05-15 18:50:38 +02:00
|
|
|
"""Save user's informations and update the roster on the Jabber server"""
|
2005-03-01 23:52:22 +01:00
|
|
|
if self.vcard:
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
return
|
2004-05-15 18:50:38 +02:00
|
|
|
#update user.name if it's not ""
|
2005-03-01 16:56:02 +01:00
|
|
|
name_entry = self.xml.get_widget('nickname_entry')
|
|
|
|
new_name = name_entry.get_text()
|
|
|
|
if new_name != self.user.name and new_name != '':
|
|
|
|
self.user.name = new_name
|
2004-05-25 19:24:48 +02:00
|
|
|
for i in self.plugin.roster.get_user_iter(self.user.jid, self.account):
|
2005-03-01 16:56:02 +01:00
|
|
|
self.plugin.roster.tree.get_model().set_value(i, 1, new_name)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin.send('UPDUSER', self.account, (self.user.jid, \
|
|
|
|
self.user.name, self.user.groups))
|
2004-11-15 10:51:30 +01:00
|
|
|
#log history ?
|
2005-03-01 16:56:02 +01:00
|
|
|
account_info = self.plugin.accounts[self.account]
|
2004-11-15 10:51:30 +01:00
|
|
|
oldlog = 1
|
|
|
|
no_log_for = []
|
2005-03-01 16:56:02 +01:00
|
|
|
if account_info.has_key('no_log_for'):
|
|
|
|
no_log_for = account_info['no_log_for'].split()
|
2004-11-15 10:51:30 +01:00
|
|
|
if self.user.jid in no_log_for:
|
|
|
|
oldlog = 0
|
2005-03-01 16:56:02 +01:00
|
|
|
log = self.xml.get_widget('log_checkbutton').get_active()
|
2004-11-15 10:51:30 +01:00
|
|
|
if not log and not self.user.jid in no_log_for:
|
|
|
|
no_log_for.append(self.user.jid)
|
|
|
|
if log and self.user.jid in no_log_for:
|
|
|
|
no_log_for.remove(self.user.jid)
|
|
|
|
if oldlog != log:
|
2005-03-01 16:56:02 +01:00
|
|
|
account_info['no_log_for'] = string.join(no_log_for, ' ')
|
|
|
|
self.plugin.accounts[self.account] = account_info
|
2004-11-15 10:51:30 +01:00
|
|
|
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
|
|
|
|
'Gtkgui'))
|
2004-05-15 18:50:38 +02:00
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def set_value(self, entry_name, value):
|
|
|
|
try:
|
|
|
|
self.xml.get_widget(entry_name).set_text(value)
|
|
|
|
except AttributeError, e:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def set_values(self, vcard):
|
|
|
|
for i in vcard.keys():
|
|
|
|
if type(vcard[i]) == type({}):
|
|
|
|
for j in vcard[i].keys():
|
2005-03-01 16:56:02 +01:00
|
|
|
self.set_value(i+'_'+j+'_entry', vcard[i][j])
|
2004-05-15 18:50:38 +02:00
|
|
|
else:
|
|
|
|
if i == 'DESC':
|
2005-03-01 16:56:02 +01:00
|
|
|
self.xml.get_widget('DESC_textview').get_buffer().\
|
2004-05-15 18:50:38 +02:00
|
|
|
set_text(vcard[i], 0)
|
|
|
|
else:
|
2005-03-01 16:56:02 +01:00
|
|
|
self.set_value(i+'_entry', vcard[i])
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 23:52:22 +01:00
|
|
|
def fill_jabber_page(self):
|
|
|
|
self.xml.get_widget('nickname_label').set_text(self.user.name)
|
|
|
|
self.xml.get_widget('jid_label').set_text(self.user.jid)
|
|
|
|
self.xml.get_widget('subscription_label').set_text(self.user.sub)
|
|
|
|
if self.user.ask:
|
|
|
|
self.xml.get_widget('ask_label').set_text(self.user.ask)
|
2004-11-18 18:15:15 +01:00
|
|
|
else:
|
2005-03-01 16:56:02 +01:00
|
|
|
self.xml.get_widget('ask_label').set_text('None')
|
2005-03-01 23:52:22 +01:00
|
|
|
self.xml.get_widget('nickname_entry').set_text(self.user.name)
|
|
|
|
account_info = self.plugin.accounts[self.account]
|
2004-11-15 10:51:30 +01:00
|
|
|
log = 1
|
2005-03-01 16:56:02 +01:00
|
|
|
if account_info.has_key('no_log_for'):
|
2005-03-01 23:52:22 +01:00
|
|
|
if self.user.jid in account_info['no_log_for'].split(' '):
|
2004-11-15 10:51:30 +01:00
|
|
|
log = 0
|
2005-03-01 16:56:02 +01:00
|
|
|
self.xml.get_widget('log_checkbutton').set_active(log)
|
2005-03-01 23:52:22 +01:00
|
|
|
resources = self.user.resource + ' (' + str(self.user.priority) + ')'
|
|
|
|
if not self.user.status:
|
2005-03-02 11:47:41 +01:00
|
|
|
self.user.status = ''
|
2005-03-01 23:52:22 +01:00
|
|
|
stats = self.user.show + ' : ' + self.user.status
|
|
|
|
for u in self.plugin.roster.contacts[self.account][self.user.jid]:
|
|
|
|
if u.resource != self.user.resource:
|
2004-06-09 22:40:52 +02:00
|
|
|
resources += '\n' + u.resource + ' (' + str(u.priority) + ')'
|
2004-06-02 03:56:16 +02:00
|
|
|
if not u.status:
|
|
|
|
u.status = ''
|
|
|
|
stats += '\n' + u.show + ' : ' + u.status
|
2005-03-01 16:56:02 +01:00
|
|
|
self.xml.get_widget('resource_label').set_text(resources)
|
|
|
|
self.xml.get_widget('status_label').set_text(stats)
|
2005-03-02 12:46:51 +01:00
|
|
|
self.plugin.send('ASK_VCARD', self.account, self.user.jid)
|
2005-03-01 23:52:22 +01:00
|
|
|
|
|
|
|
def add_to_vcard(self, vcard, entry, txt):
|
|
|
|
"""Add an information to the vCard dictionary"""
|
|
|
|
entries = string.split(entry, '_')
|
|
|
|
loc = vcard
|
|
|
|
while len(entries) > 1:
|
|
|
|
if not loc.has_key(entries[0]):
|
|
|
|
loc[entries[0]] = {}
|
|
|
|
loc = loc[entries[0]]
|
|
|
|
del entries[0]
|
|
|
|
loc[entries[0]] = txt
|
|
|
|
return vcard
|
|
|
|
|
|
|
|
def make_vcard(self):
|
|
|
|
"""make the vCard dictionary"""
|
|
|
|
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',\
|
|
|
|
'ADR_STREET', 'ADR_EXTADR', 'ADR_LOCALITY', 'ADR_REGION', 'ADR_PCODE',\
|
|
|
|
'ADR_CTRY', 'ORG_ORGNAME', 'ORG_ORGUNIT', 'TITLE', 'ROLE']
|
|
|
|
vcard = {}
|
|
|
|
for e in entries:
|
|
|
|
txt = self.xml.get_widget(e+'_entry').get_text()
|
|
|
|
if txt != '':
|
|
|
|
vcard = self.add_to_vcard(vcard, e, txt)
|
|
|
|
buffer = self.xml.get_widget('DESC_textview').get_buffer()
|
|
|
|
start_iter = buffer.get_start_iter()
|
|
|
|
end_iter = buffer.get_end_iter()
|
|
|
|
txt = buffer.get_text(start_iter, end_iter, 0)
|
|
|
|
if txt != '':
|
|
|
|
vcard['DESC'] = txt
|
|
|
|
return vcard
|
|
|
|
|
|
|
|
def on_publish_button_clicked(self, widget):
|
|
|
|
if not self.plugin.connected[self.account]:
|
|
|
|
warning_dialog(_("You must be connected to publish your informations"))
|
|
|
|
return
|
|
|
|
vcard = self.make_vcard()
|
|
|
|
nick = ''
|
|
|
|
if vcard.has_key('NICKNAME'):
|
|
|
|
nick = vcard['NICKNAME']
|
|
|
|
if nick == '':
|
|
|
|
nick = self.plugin.accounts[self.account]['name']
|
|
|
|
self.plugin.nicks[self.account] = nick
|
|
|
|
self.plugin.send('VCARD', self.account, vcard)
|
|
|
|
|
|
|
|
def on_retrieve_button_clicked(self, widget):
|
|
|
|
if self.plugin.connected[self.account]:
|
|
|
|
self.plugin.send('ASK_VCARD', self.account, self.jid)
|
|
|
|
else:
|
|
|
|
warning_dialog(_('You must be connected to get your informations'))
|
|
|
|
|
|
|
|
def change_to_vcard(self):
|
|
|
|
self.xml.get_widget('information_notebook').remove_page(0)
|
|
|
|
self.xml.get_widget('nickname_label').set_text('Personal details')
|
|
|
|
information_hbuttonbox = self.xml.get_widget('information_hbuttonbox')
|
|
|
|
#publish button
|
|
|
|
button = gtk.Button(stock=gtk.STOCK_GOTO_TOP)
|
|
|
|
button.get_children()[0].get_children()[0].get_children()[1].\
|
|
|
|
set_text('Publish')
|
|
|
|
button.connect('clicked', self.on_publish_button_clicked)
|
|
|
|
button.show_all()
|
|
|
|
information_hbuttonbox.pack_start(button)
|
|
|
|
#retrieve button
|
|
|
|
button = gtk.Button(stock=gtk.STOCK_GOTO_BOTTOM)
|
|
|
|
button.get_children()[0].get_children()[0].get_children()[1].\
|
|
|
|
set_text('Retrieve')
|
|
|
|
button.connect('clicked', self.on_retrieve_button_clicked)
|
|
|
|
button.show_all()
|
|
|
|
information_hbuttonbox.pack_start(button)
|
|
|
|
#close button at the end
|
|
|
|
button = self.xml.get_widget('close_button')
|
|
|
|
information_hbuttonbox.reorder_child(button, 2)
|
|
|
|
|
|
|
|
#the user variable is the jid if vcard is true
|
|
|
|
def __init__(self, user, plugin, account, vcard=False):
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard_information_window', APP)
|
|
|
|
self.window = self.xml.get_widget('vcard_information_window')
|
|
|
|
self.plugin = plugin
|
|
|
|
self.user = user #don't use it is vcard is true
|
|
|
|
self.account = account
|
|
|
|
self.vcard = vcard
|
|
|
|
|
|
|
|
if vcard:
|
|
|
|
self.jid = user
|
|
|
|
self.change_to_vcard()
|
|
|
|
else:
|
|
|
|
self.jid = user.jid
|
|
|
|
self.fill_jabber_page()
|
|
|
|
|
2005-03-01 16:56:02 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
2004-10-07 16:43:59 +02:00
|
|
|
|
2005-03-02 13:38:33 +01:00
|
|
|
class passphrase_dialog:
|
|
|
|
"""Class for passphrase_dialog"""
|
2004-10-07 16:43:59 +02:00
|
|
|
def run(self):
|
2005-03-02 13:38:33 +01:00
|
|
|
"""Wait for OK button to be pressed and return passphrase/password"""
|
2005-03-02 11:46:12 +01:00
|
|
|
rep = self.window.run()
|
2004-10-07 16:43:59 +02:00
|
|
|
if rep == gtk.RESPONSE_OK:
|
2005-03-02 11:46:12 +01:00
|
|
|
passphrase = self.passphrase_entry.get_text()
|
2004-10-07 16:43:59 +02:00
|
|
|
else:
|
2005-03-02 11:46:12 +01:00
|
|
|
passphrase = -1
|
|
|
|
save_passphrase_checkbutton = self.xml.\
|
|
|
|
get_widget('save_passphrase_checkbutton')
|
|
|
|
self.window.destroy()
|
|
|
|
return passphrase, save_passphrase_checkbutton.get_active()
|
2004-10-07 16:43:59 +02:00
|
|
|
|
2005-03-02 11:46:12 +01:00
|
|
|
def on_passphrase_dialog_key_press_event(self, widget, event):
|
2004-10-07 16:43:59 +02:00
|
|
|
if event.keyval == gtk.keysyms.Return:
|
2004-12-02 01:00:57 +01:00
|
|
|
if self.autoconnect:
|
2005-03-02 11:46:12 +01:00
|
|
|
self.on_ok_button_clicked(widget)
|
2004-12-02 01:00:57 +01:00
|
|
|
else:
|
2005-03-02 11:46:12 +01:00
|
|
|
self.window.response(gtk.RESPONSE_OK)
|
2004-12-02 01:00:57 +01:00
|
|
|
|
2005-03-02 13:38:33 +01:00
|
|
|
def on_ok_button_clicked(self, widget):
|
2004-12-02 01:00:57 +01:00
|
|
|
if self.autoconnect:
|
2005-03-02 11:46:12 +01:00
|
|
|
self.passphrase = self.passphrase_entry.get_text()
|
2004-12-02 01:00:57 +01:00
|
|
|
gtk.main_quit()
|
2004-10-07 16:43:59 +02:00
|
|
|
|
2005-03-02 13:38:33 +01:00
|
|
|
def on_cancel_button_clicked(self, widget):
|
2004-12-02 01:00:57 +01:00
|
|
|
if self.autoconnect:
|
|
|
|
gtk.main_quit()
|
|
|
|
|
|
|
|
def get_pass(self):
|
|
|
|
self.autoconnect = 0
|
2005-03-02 11:46:12 +01:00
|
|
|
save_passphrase_checkbutton = self.xml.\
|
|
|
|
get_widget('save_passphrase_checkbutton')
|
|
|
|
self.window.destroy()
|
|
|
|
return self.passphrase, save_passphrase_checkbutton.get_active()
|
2004-12-02 01:00:57 +01:00
|
|
|
|
2005-03-02 11:46:12 +01:00
|
|
|
def on_passphrase_dialog_destroy(self, widget=None):
|
2004-12-02 01:00:57 +01:00
|
|
|
"""close window"""
|
|
|
|
if self.autoconnect:
|
|
|
|
gtk.main_quit()
|
|
|
|
|
2005-03-02 13:38:33 +01:00
|
|
|
def __init__(self, labeltext, checkbuttontext, autoconnect=0):
|
2005-03-02 11:46:12 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'passphrase_dialog', APP)
|
|
|
|
self.window = self.xml.get_widget('passphrase_dialog')
|
|
|
|
self.passphrase_entry = self.xml.get_widget('passphrase_entry')
|
|
|
|
self.passphrase = -1
|
2004-12-02 01:00:57 +01:00
|
|
|
self.autoconnect = autoconnect
|
2005-03-02 13:38:33 +01:00
|
|
|
self.xml.get_widget('message_label').set_text(labeltext)
|
|
|
|
self.xml.get_widget('save_passphrase_checkbutton').set_label(checkbuttontext)
|
2005-03-02 11:46:12 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-02 14:04:47 +01:00
|
|
|
class choose_gpg_key_dialog:
|
2004-10-10 20:44:38 +02:00
|
|
|
"""Class for Away Message Window"""
|
|
|
|
def run(self):
|
|
|
|
"""Wait for Ok button to be pressed and return the selected key"""
|
2005-03-02 12:46:51 +01:00
|
|
|
rep = self.window.run()
|
2004-10-10 20:44:38 +02:00
|
|
|
if rep == gtk.RESPONSE_OK:
|
2005-03-02 12:46:51 +01:00
|
|
|
selection = self.keys_treeview.get_selection()
|
2004-10-10 20:44:38 +02:00
|
|
|
(model, iter) = selection.get_selected()
|
|
|
|
keyID = [model.get_value(iter, 0), model.get_value(iter, 1)]
|
|
|
|
else:
|
|
|
|
keyID = -1
|
2005-03-02 12:46:51 +01:00
|
|
|
self.window.destroy()
|
2004-10-10 20:44:38 +02:00
|
|
|
return keyID
|
|
|
|
|
|
|
|
def fill_tree(self, list):
|
2005-03-02 12:46:51 +01:00
|
|
|
model = self.keys_treeview.get_model()
|
2004-10-10 20:44:38 +02:00
|
|
|
for keyID in list.keys():
|
|
|
|
model.append((keyID, list[keyID]))
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
#list : {keyID: userName, ...}
|
2005-03-02 12:46:51 +01:00
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'choose_gpg_key_dialog', APP)
|
|
|
|
self.window = xml.get_widget('choose_gpg_key_dialog')
|
|
|
|
self.keys_treeview = xml.get_widget('keys_treeview')
|
2004-10-10 20:44:38 +02:00
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
2005-03-02 12:46:51 +01:00
|
|
|
self.keys_treeview.set_model(model)
|
2004-10-10 20:44:38 +02:00
|
|
|
#columns
|
|
|
|
renderer = gtk.CellRendererText()
|
2005-03-02 12:46:51 +01:00
|
|
|
self.keys_treeview.insert_column_with_attributes(-1, _('KeyID'), \
|
|
|
|
renderer, text=0)
|
2004-10-10 20:44:38 +02:00
|
|
|
renderer = gtk.CellRendererText()
|
2005-03-02 12:46:51 +01:00
|
|
|
self.keys_treeview.insert_column_with_attributes(-1, _('User name'), \
|
|
|
|
renderer, text=1)
|
2004-10-10 20:44:38 +02:00
|
|
|
|
2005-03-02 13:46:37 +01:00
|
|
|
class away_message_dialog:
|
|
|
|
"""Class for away_message_dialogWindow"""
|
2004-05-15 18:50:38 +02:00
|
|
|
def run(self):
|
|
|
|
"""Wait for Ok button to be pressed and return away messsage"""
|
2005-03-02 13:46:37 +01:00
|
|
|
rep = self.window.run()
|
2004-05-15 18:50:38 +02:00
|
|
|
if rep == gtk.RESPONSE_OK:
|
2005-03-02 13:46:37 +01:00
|
|
|
beg, end = self.message_buffer.get_bounds()
|
|
|
|
message = self.message_buffer.get_text(beg, end, 0)
|
|
|
|
self.plugin.config['last_msg'] = message
|
2004-05-15 18:50:38 +02:00
|
|
|
else:
|
2005-03-02 13:46:37 +01:00
|
|
|
message = -1
|
|
|
|
self.window.destroy()
|
|
|
|
return message
|
2004-10-26 00:02:16 +02:00
|
|
|
|
2005-03-02 13:46:37 +01:00
|
|
|
def on_message_comboboxentry_changed(self, widget, data=None):
|
2004-10-26 00:02:16 +02:00
|
|
|
model = widget.get_model()
|
|
|
|
active = widget.get_active()
|
|
|
|
if active < 0:
|
|
|
|
return None
|
|
|
|
name = model[active][0]
|
2005-03-02 13:46:37 +01:00
|
|
|
self.message_buffer.set_text(self.values[name])
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-02 13:46:37 +01:00
|
|
|
def on_away_message_dialog_key_press_event(self, widget, event):
|
2005-01-08 15:40:08 +01:00
|
|
|
if event.keyval == gtk.keysyms.Return:
|
|
|
|
if (event.state & gtk.gdk.CONTROL_MASK):
|
2005-03-02 13:46:37 +01:00
|
|
|
self.window.response(gtk.RESPONSE_OK)
|
2005-01-08 15:40:08 +01:00
|
|
|
|
2004-10-26 00:02:16 +02:00
|
|
|
def __init__(self, plugin):
|
2005-03-02 13:46:37 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'away_message_dialog', APP)
|
2005-03-02 14:47:42 +01:00
|
|
|
self.window = self.xml.get_widget('away_message_dialog')
|
2004-10-26 00:02:16 +02:00
|
|
|
self.plugin = plugin
|
2005-03-02 13:46:37 +01:00
|
|
|
message_textview = self.xml.get_widget('message_textview')
|
|
|
|
self.message_buffer = message_textview.get_buffer()
|
|
|
|
self.message_buffer.set_text(self.plugin.config['last_msg'])
|
2004-10-26 00:02:16 +02:00
|
|
|
self.values = {'':''}
|
|
|
|
i = 0
|
|
|
|
while self.plugin.config.has_key('msg%s_name' % i):
|
|
|
|
self.values[self.plugin.config['msg%s_name' % i]] = \
|
|
|
|
self.plugin.config['msg%s' % i]
|
|
|
|
i += 1
|
|
|
|
liststore = gtk.ListStore(str, str)
|
2005-03-02 13:46:37 +01:00
|
|
|
message_comboboxentry = self.xml.get_widget('message_comboboxentry')
|
|
|
|
message_comboboxentry.set_model(liststore)
|
|
|
|
message_comboboxentry.set_text_column(0)
|
2004-10-26 00:02:16 +02:00
|
|
|
for val in self.values.keys():
|
2005-03-02 13:46:37 +01:00
|
|
|
message_comboboxentry.append_text(val)
|
|
|
|
self.xml.signal_autoconnect(self)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-02 00:48:05 +01:00
|
|
|
class add_contact_window:
|
|
|
|
"""Class for add_contact_window"""
|
2005-03-01 00:44:52 +01:00
|
|
|
def on_cancel_button_clicked(self, widget):
|
2004-05-15 18:50:38 +02:00
|
|
|
"""When Cancel button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def on_subscribe_button_clicked(self, widget):
|
2004-05-15 18:50:38 +02:00
|
|
|
"""When Subscribe button is clicked"""
|
2005-03-01 00:44:52 +01:00
|
|
|
jid = self.xml.get_widget('jid_entry').get_text()
|
|
|
|
nickname = self.xml.get_widget('nickname_entry').get_text()
|
|
|
|
if not jid:
|
2004-11-18 20:22:33 +01:00
|
|
|
return
|
2005-03-01 00:44:52 +01:00
|
|
|
if jid.find('@') < 0:
|
2005-03-01 20:02:51 +01:00
|
|
|
warning_dialog(_("The contact's name must be something like login@hostname"))
|
2004-11-18 20:22:33 +01:00
|
|
|
return
|
2005-03-01 00:44:52 +01:00
|
|
|
message_buffer = self.xml.get_widget('message_textview').get_buffer()
|
|
|
|
start_iter = message_buffer.get_start_iter()
|
|
|
|
end_iter = message_buffer.get_end_iter()
|
|
|
|
message = message_buffer.get_text(start_iter, end_iter, 0)
|
|
|
|
self.plugin.roster.req_sub(self, jid, message, self.account, nickname)
|
|
|
|
if self.xml.get_widget('auto_authorize_checkbutton').get_active():
|
|
|
|
self.plugin.send('AUTH', self.account, jid)
|
2004-05-15 18:50:38 +02:00
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def fill_jid(self):
|
|
|
|
agent_combobox = self.xml.get_widget('agent_combobox')
|
|
|
|
model = agent_combobox.get_model()
|
|
|
|
index = agent_combobox.get_active()
|
|
|
|
jid = self.xml.get_widget('uid_entry').get_text()
|
2005-02-04 08:58:40 +01:00
|
|
|
if index > 0:
|
2005-03-01 00:44:52 +01:00
|
|
|
jid = jid.replace('@', '%')
|
2005-02-03 23:21:55 +01:00
|
|
|
agent = model[index][1]
|
|
|
|
if agent:
|
2005-03-01 00:44:52 +01:00
|
|
|
jid += '@' + agent
|
|
|
|
self.xml.get_widget('jid_entry').set_text(jid)
|
2005-02-03 23:21:55 +01:00
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def on_agent_combobox_changed(self, widget):
|
|
|
|
self.fill_jid()
|
2005-02-03 23:21:55 +01:00
|
|
|
|
|
|
|
def guess_agent(self):
|
2005-03-01 00:44:52 +01:00
|
|
|
uid = self.xml.get_widget('uid_entry').get_text()
|
|
|
|
agent_combobox = self.xml.get_widget('agent_combobox')
|
|
|
|
model = agent_combobox.get_model()
|
2005-02-03 23:21:55 +01:00
|
|
|
|
|
|
|
#If login contains only numbers, it's probably an ICQ number
|
|
|
|
try:
|
2005-03-01 00:44:52 +01:00
|
|
|
string.atoi(uid)
|
2005-02-03 23:21:55 +01:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if 'ICQ' in self.agents:
|
2005-03-01 00:44:52 +01:00
|
|
|
agent_combobox.set_active(self.agents.index('ICQ'))
|
2005-02-03 23:21:55 +01:00
|
|
|
return
|
2005-03-01 00:44:52 +01:00
|
|
|
agent_combobox.set_active(0)
|
2005-02-04 08:58:40 +01:00
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def set_nickname(self):
|
|
|
|
uid = self.xml.get_widget('uid_entry').get_text()
|
|
|
|
nickname = self.xml.get_widget('nickname_entry').get_text()
|
|
|
|
if nickname == self.old_uid_value:
|
|
|
|
self.xml.get_widget('nickname_entry').set_text(uid.split('@')[0])
|
2005-02-03 23:21:55 +01:00
|
|
|
|
2005-03-01 00:44:52 +01:00
|
|
|
def on_uid_entry_changed(self, widget):
|
2005-02-04 08:58:40 +01:00
|
|
|
self.guess_agent()
|
2005-03-01 00:44:52 +01:00
|
|
|
self.set_nickname()
|
|
|
|
self.fill_jid()
|
|
|
|
uid = self.xml.get_widget('uid_entry').get_text()
|
|
|
|
self.old_uid_value = uid.split('@')[0]
|
2005-02-03 23:21:55 +01:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
def __init__(self, plugin, account, jid=None):
|
2005-02-07 23:23:27 +01:00
|
|
|
if not plugin.connected[account]:
|
2005-03-01 20:02:51 +01:00
|
|
|
warning_dialog(_('You must be connected to add a contact'))
|
2005-02-07 23:23:27 +01:00
|
|
|
return
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
2005-03-02 00:48:05 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'add_contact_window', APP)
|
|
|
|
self.window = self.xml.get_widget('add_contact_window')
|
2005-03-01 00:44:52 +01:00
|
|
|
self.old_uid_value = ''
|
2005-02-03 23:21:55 +01:00
|
|
|
liststore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
|
|
|
liststore.append(['Jabber', ''])
|
|
|
|
self.agents = ['Jabber']
|
|
|
|
jid_agents = []
|
|
|
|
for j in self.plugin.roster.contacts[account]:
|
|
|
|
user = self.plugin.roster.contacts[account][j][0]
|
|
|
|
if 'Agents' in user.groups:
|
|
|
|
jid_agents.append(j)
|
|
|
|
for a in jid_agents:
|
2005-03-01 00:44:52 +01:00
|
|
|
if a.find('aim') > -1:
|
|
|
|
name = 'AIM'
|
|
|
|
elif a.find('icq') > -1:
|
|
|
|
name = 'ICQ'
|
|
|
|
elif a.find('msn') > -1:
|
|
|
|
name = 'MSN'
|
|
|
|
elif a.find('yahoo') > -1:
|
|
|
|
name = 'Yahoo!'
|
2005-02-03 23:21:55 +01:00
|
|
|
else:
|
|
|
|
name = a
|
|
|
|
iter = liststore.append([name, a])
|
|
|
|
self.agents.append(name)
|
2005-03-01 00:44:52 +01:00
|
|
|
agent_combobox = self.xml.get_widget('agent_combobox')
|
|
|
|
agent_combobox.set_model(liststore)
|
|
|
|
agent_combobox.set_active(0)
|
|
|
|
self.fill_jid()
|
2004-05-15 18:50:38 +02:00
|
|
|
if jid:
|
2005-03-01 00:44:52 +01:00
|
|
|
self.xml.get_widget('jid_entry').set_text(jid)
|
|
|
|
jid_splited = jid.split('@')
|
2005-03-03 14:45:12 +01:00
|
|
|
self.xml.get_widget('login_entry').set_text(jid_splited[0])
|
2005-03-01 00:44:52 +01:00
|
|
|
if jid_splited[1] in jid_agents:
|
|
|
|
agent_combobox.set_active(jid_agents.index(jid_splited[1])+1)
|
|
|
|
self.xml.signal_autoconnect(self)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-02 19:38:27 +01:00
|
|
|
class about_window: #FIXME REWRITE: (nk) pygtk2.6 has a built-in window for that
|
2004-05-15 18:50:38 +02:00
|
|
|
"""Class for about window"""
|
|
|
|
def delete_event(self, widget):
|
|
|
|
"""close window"""
|
2005-03-02 19:38:27 +01:00
|
|
|
del self.plugin.windows['about'] # remove us from open windows
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def on_close(self, widget):
|
|
|
|
"""When Close button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def __init__(self, plugin):
|
2005-02-28 18:50:10 +01:00
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'about_window', APP)
|
|
|
|
self.window = xml.get_widget('about_window')
|
2005-03-02 19:38:27 +01:00
|
|
|
xml.get_widget('logo_image').set_from_file('plugins/gtkgui/pixmaps/logo.png')
|
2005-03-02 14:52:43 +01:00
|
|
|
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin = plugin
|
|
|
|
xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
|
|
|
xml.signal_connect('on_close_clicked', self.on_close)
|
2005-03-02 19:38:27 +01:00
|
|
|
|
|
|
|
self.plugin.windows['about'] = self # add us to open windows
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 20:02:51 +01:00
|
|
|
class confirm_dialog:
|
|
|
|
"""Class for confirmation dialog"""
|
|
|
|
def get_response(self):
|
|
|
|
response = self.dialog.run()
|
|
|
|
self.dialog.destroy()
|
2005-03-01 19:36:13 +01:00
|
|
|
return response
|
2004-05-15 18:50:38 +02:00
|
|
|
|
|
|
|
def __init__(self, label):
|
2005-03-01 20:02:51 +01:00
|
|
|
self.dialog = gtk.MessageDialog(None,\
|
2005-03-01 19:36:13 +01:00
|
|
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
|
|
|
|
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, label)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 20:02:51 +01:00
|
|
|
class warning_dialog:
|
|
|
|
"""Class for warning dialog"""
|
2005-03-03 23:15:45 +01:00
|
|
|
def on_response(self, dialog, response_id):
|
|
|
|
dialog.destroy()
|
|
|
|
|
2005-03-01 20:02:51 +01:00
|
|
|
def __init__(self, label):
|
2005-03-03 16:27:37 +01:00
|
|
|
dialog = gtk.MessageDialog(None,\
|
2005-03-01 20:02:51 +01:00
|
|
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
|
|
|
|
gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE, label)
|
2005-03-03 23:15:45 +01:00
|
|
|
dialog.connect('response', self.on_response)
|
|
|
|
dialog.show()
|
2005-03-03 16:27:37 +01:00
|
|
|
|
|
|
|
class information_dialog:
|
|
|
|
"""Class for information dialog"""
|
2005-03-03 23:15:45 +01:00
|
|
|
def on_response(self, dialog, response_id):
|
|
|
|
dialog.destroy()
|
|
|
|
|
2005-03-03 16:27:37 +01:00
|
|
|
def __init__(self, label):
|
|
|
|
dialog = gtk.MessageDialog(None,\
|
|
|
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
|
|
|
|
gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, label)
|
2005-03-03 23:15:45 +01:00
|
|
|
dialog.connect('response', self.on_response)
|
|
|
|
dialog.show()
|
2005-03-03 16:27:37 +01:00
|
|
|
|
|
|
|
class error_dialog:
|
|
|
|
"""Class for error dialog"""
|
2005-03-03 23:15:45 +01:00
|
|
|
def on_response(self, dialog, response_id):
|
|
|
|
dialog.destroy()
|
|
|
|
|
2005-03-03 16:27:37 +01:00
|
|
|
def __init__(self, label):
|
|
|
|
dialog = gtk.MessageDialog(None,\
|
|
|
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
|
|
|
|
gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, label)
|
2005-03-03 23:15:45 +01:00
|
|
|
dialog.connect('response', self.on_response)
|
|
|
|
dialog.show()
|
2005-03-01 20:02:51 +01:00
|
|
|
|
2005-03-02 14:04:47 +01:00
|
|
|
class subscription_request_window:
|
2004-05-15 18:50:38 +02:00
|
|
|
"""Class for authorization window :
|
|
|
|
window that appears when a user wants to add us to his/her roster"""
|
2005-03-01 15:02:32 +01:00
|
|
|
def on_close_button_clicked(self, widget):
|
2004-05-15 18:50:38 +02:00
|
|
|
"""When Close button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
2005-03-01 15:02:32 +01:00
|
|
|
def on_authorize_button_clicked(self, widget):
|
2004-05-15 18:50:38 +02:00
|
|
|
"""Accept the request"""
|
|
|
|
self.plugin.send('AUTH', self.account, self.jid)
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
if not self.plugin.roster.contacts[self.account].has_key(self.jid):
|
2005-03-02 14:04:47 +01:00
|
|
|
add_contact_window(self.plugin, self.account, self.jid)
|
2004-05-15 18:50:38 +02:00
|
|
|
|
2005-03-01 15:02:32 +01:00
|
|
|
def on_deny_button_clicked(self, widget):
|
2004-05-15 18:50:38 +02:00
|
|
|
"""refuse the request"""
|
|
|
|
self.plugin.send('DENY', self.account, self.jid)
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
2005-03-01 15:02:32 +01:00
|
|
|
def __init__(self, plugin, jid, text, account):
|
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'subscription_request_window', APP)
|
2004-05-15 18:50:38 +02:00
|
|
|
self.plugin = plugin
|
|
|
|
self.jid = jid
|
|
|
|
self.account = account
|
2005-03-01 15:02:32 +01:00
|
|
|
xml.get_widget('from_label').set_text(\
|
|
|
|
_('Subscription request from %s') % self.jid)
|
|
|
|
xml.get_widget('message_textview').get_buffer().set_text(text)
|
|
|
|
xml.signal_autoconnect(self)
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-03-02 13:32:44 +01:00
|
|
|
class join_groupchat_window:
|
|
|
|
def on_join_groupchat_window_destroy(self, widget):
|
2005-03-02 00:48:05 +01:00
|
|
|
"""close window"""
|
2005-03-02 19:38:27 +01:00
|
|
|
del self.plugin.windows['join_gc'] # remove us from open windows
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-03-02 13:32:44 +01:00
|
|
|
def on_close_button_clicked(self, widget):
|
2005-03-02 00:48:05 +01:00
|
|
|
"""When Cancel button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
2005-03-02 13:32:44 +01:00
|
|
|
def on_join_button_clicked(self, widget):
|
2005-03-02 00:48:05 +01:00
|
|
|
"""When Join button is clicked"""
|
2005-03-02 13:32:44 +01:00
|
|
|
nickname = self.xml.get_widget('nickname_entry').get_text()
|
|
|
|
room = self.xml.get_widget('room_entry').get_text()
|
|
|
|
server = self.xml.get_widget('server_entry').get_text()
|
|
|
|
password = self.xml.get_widget('passwrd_entry').get_text()
|
2005-03-02 00:48:05 +01:00
|
|
|
jid = '%s@%s' % (room, server)
|
2005-03-02 13:32:44 +01:00
|
|
|
self.plugin.windows[self.account]['gc'][jid] = gtkgui.gc(jid, nickname,\
|
2005-03-02 00:48:05 +01:00
|
|
|
self.plugin, self.account)
|
|
|
|
#TODO: verify entries
|
2005-03-02 13:32:44 +01:00
|
|
|
self.plugin.send('GC_JOIN', self.account, (nickname, room, server, \
|
|
|
|
password))
|
2005-03-02 00:48:05 +01:00
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
|
|
|
def __init__(self, plugin, account, server='', room = ''):
|
|
|
|
if not plugin.connected[account]:
|
2005-03-02 14:42:33 +01:00
|
|
|
warning_dialog(_('You must be connected to join a group chat on this server'))
|
2005-03-02 00:48:05 +01:00
|
|
|
return
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
2005-03-02 13:32:44 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'join_groupchat_window', APP)
|
|
|
|
self.window = self.xml.get_widget('join_groupchat_window')
|
|
|
|
self.xml.get_widget('server_entry').set_text(server)
|
|
|
|
self.xml.get_widget('room_entry').set_text(room)
|
|
|
|
self.xml.get_widget('nickname_entry').\
|
|
|
|
set_text(self.plugin.nicks[self.account])
|
|
|
|
self.xml.signal_autoconnect(self)
|
2005-03-02 19:38:27 +01:00
|
|
|
self.plugin.windows['join_gc'] = self # now add us to open windows
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-03-03 23:14:50 +01:00
|
|
|
class New_message_window:
|
2005-03-02 19:38:27 +01:00
|
|
|
def on_delete_event(self, widget):
|
2005-03-02 00:48:05 +01:00
|
|
|
"""close window"""
|
2005-03-02 19:38:27 +01:00
|
|
|
del self.plugin.windows['new_msg']
|
2005-03-02 00:48:05 +01:00
|
|
|
|
2005-03-02 19:38:27 +01:00
|
|
|
def on_cancel_button_clicked(self, widget):
|
2005-03-02 00:48:05 +01:00
|
|
|
"""When Cancel button is clicked"""
|
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
2005-03-02 19:38:27 +01:00
|
|
|
def on_chat_button_clicked(self, widget):
|
|
|
|
"""When Chat button is clicked"""
|
2005-03-03 23:14:50 +01:00
|
|
|
jid = self.jid_entry.get_text()
|
2005-03-03 18:14:37 +01:00
|
|
|
# use User class, new_chat expects it that way
|
2005-03-03 23:14:50 +01:00
|
|
|
if not self.plugin.roster.contacts[self.account].has_key(jid):
|
|
|
|
user = gtkgui.User(jid, jid, ['not in the roster'], \
|
|
|
|
'not in the roster', 'not in the roster', 'none', None, '', 0, '')
|
|
|
|
self.plugin.roster.contacts[self.account][jid] = [user]
|
|
|
|
self.plugin.roster.add_user_to_roster(user.jid, self.account)
|
|
|
|
else:
|
2005-03-03 23:28:13 +01:00
|
|
|
user = self.plugin.roster.contacts[self.account][jid][0]
|
|
|
|
if self.plugin.windows[self.account]['chats'].has_key(jid):
|
|
|
|
self.plugin.windows[self.account]['chats'][jid].active_tab(jid)
|
|
|
|
else:
|
|
|
|
self.plugin.roster.new_chat(user, self.account)
|
2005-03-02 00:48:05 +01:00
|
|
|
widget.get_toplevel().destroy()
|
|
|
|
|
2005-03-02 19:38:27 +01:00
|
|
|
def __init__(self, plugin, account):
|
2005-03-02 00:48:05 +01:00
|
|
|
if not plugin.connected[account]:
|
2005-03-02 19:38:27 +01:00
|
|
|
warning_dialog(_('You must be connected to send a message to a contact'))
|
2005-03-02 00:48:05 +01:00
|
|
|
return
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
2005-03-02 19:38:27 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'new_message_window', APP)
|
|
|
|
self.window = self.xml.get_widget('new_message_window')
|
2005-03-03 23:14:50 +01:00
|
|
|
self.jid_entry = self.xml.get_widget('jid_entry')
|
|
|
|
self.jid_entry.set_activates_default(True)
|
2005-03-02 19:38:27 +01:00
|
|
|
self.xml.signal_autoconnect(self)
|
|
|
|
self.plugin.windows['new_message'] = self # now add us to open windows
|
2005-03-04 14:10:00 +01:00
|
|
|
|
|
|
|
class Change_password_dialog:
|
|
|
|
def run(self):
|
|
|
|
"""Wait for Ok button to be pressed and return away messsage"""
|
|
|
|
end = False
|
|
|
|
while not end:
|
|
|
|
rep = self.dialog.run()
|
|
|
|
if rep == gtk.RESPONSE_OK:
|
|
|
|
password1 = self.password1_entry.get_text()
|
|
|
|
if not password1:
|
|
|
|
warning_dialog(_('Your password cannot be empty'))
|
|
|
|
continue
|
|
|
|
password2 = self.password2_entry.get_text()
|
|
|
|
if password1 != password2:
|
|
|
|
warning_dialog(_('Your passwords are not the same'))
|
|
|
|
continue
|
|
|
|
message = password1
|
|
|
|
else:
|
|
|
|
message = -1
|
|
|
|
end = True
|
|
|
|
self.dialog.destroy()
|
|
|
|
return message
|
|
|
|
|
|
|
|
def __init__(self, plugin, account):
|
|
|
|
if not plugin.connected[account]:
|
|
|
|
warning_dialog(_('You must be connected to change your password'))
|
|
|
|
return
|
|
|
|
self.plugin = plugin
|
|
|
|
self.account = account
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_password_dialog', APP)
|
|
|
|
self.dialog = self.xml.get_widget('change_password_dialog')
|
|
|
|
self.password1_entry = self.xml.get_widget('password1_entry')
|
|
|
|
self.password2_entry = self.xml.get_widget('password2_entry')
|
|
|
|
self.password1_entry.set_activates_default(True)
|