connection_zeroconf.py 18.8 KB
Newer Older
1
##	common/zeroconf/connection_zeroconf.py
sb's avatar
sb committed
2 3 4 5 6 7
##
## Contributors for this file:
##	- Yann Le Boulanger <asterix@lagaule.org>
##	- Nikos Kouremenos <nkour@jabber.org>
##	- Dimitur Kirov <dkirov@gmail.com>
##	- Travis Shirk <travis@pobox.com>
8
##  - Stefan Bethge <stefan@lanpartei.de>
sb's avatar
sb committed
9 10 11
##
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
##                         Vincent Hanquez <tab@snarc.org>
12
## Copyright (C) 2006 Yann Le Boulanger <asterix@lagaule.org>
sb's avatar
sb committed
13 14 15 16 17
##                    Vincent Hanquez <tab@snarc.org>
##                    Nikos Kouremenos <nkour@jabber.org>
##                    Dimitur Kirov <dkirov@gmail.com>
##                    Travis Shirk <travis@pobox.com>
##                    Norman Rasmussen <norman@rasmussen.co.za>
18
##                    Stefan Bethge <stefan@lanpartei.de>
sb's avatar
sb committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
##
## 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 os
import random
random.seed()

import signal
if os.name != 'nt':
	signal.signal(signal.SIGPIPE, signal.SIG_DFL)
38
import getpass
sb's avatar
sb committed
39
import gobject
40
import notify
sb's avatar
sb committed
41

sb's avatar
sb committed
42 43 44
from common import helpers
from common import gajim
from common import GnuPG
sb's avatar
sb committed
45 46 47
from common.zeroconf import zeroconf
from common.zeroconf import connection_handlers_zeroconf
from common.zeroconf import client_zeroconf
sb's avatar
sb committed
48
from connection_handlers_zeroconf import *
49

sb's avatar
sb committed
50 51 52 53 54 55
USE_GPG = GnuPG.USE_GPG

class ConnectionZeroconf(ConnectionHandlersZeroconf):
	'''Connection class'''
	def __init__(self, name):
		ConnectionHandlersZeroconf.__init__(self)
56 57
		# system username
		self.username = None
sb's avatar
sb committed
58 59
		self.name = name
		self.connected = 0 # offline
sb's avatar
sb committed
60
		self.connection = None
sb's avatar
sb committed
61
		self.gpg = None
sb's avatar
sb committed
62
		self.is_zeroconf = True
sb's avatar
sb committed
63 64
		self.status = ''
		self.old_show = ''
sb's avatar
sb committed
65 66 67 68 69
	
		self.call_resolve_timeout = False
		
		#self.time_to_reconnect = None
		#self.new_account_info = None
70
		self.bookmarks = []
sb's avatar
sb committed
71

72
		#we don't need a password, but must be non-empty
73
		self.password = 'zeroconf'
74

75 76 77 78 79
		#XXX use that somewhere
		self.autoconnect = False
		self.sync_with_global_status = True
		self.no_log_for = False

sb's avatar
sb committed
80 81 82 83 84 85 86 87 88 89 90 91
		# Do we continue connection when we get roster (send presence,get vcard...)
		self.continue_connect_info = None
		if USE_GPG:
			self.gpg = GnuPG.GnuPG()
			gajim.config.set('usegpg', True)
		else:
			gajim.config.set('usegpg', False)
		
		self.on_connect_success = None
		self.on_connect_failure = None
		self.retrycount = 0
		self.jids_for_auto_auth = [] # list of jid to auto-authorize
92
		self.get_config_values_or_default()
93
		self.zeroconf = zeroconf.Zeroconf(self._on_new_service,
94 95
			self._on_remove_service, self._on_name_conflictCB, 
			self._on_disconnected, self.username, self.host, self.port)
96 97
		self.muc_jid = {} # jid of muc server for each transport type
		self.vcard_supported = False
98

99 100 101 102 103
	def _on_name_conflictCB(self, alt_name):
		self.disconnect()
		self.dispatch('STATUS', 'offline')
		self.dispatch('ZC_NAME_CONFLICT', alt_name)

104 105 106
	def get_config_values_or_default(self):
		''' get name, host, port from config, or 
		create zeroconf account with default values'''
107

108 109
		if not self.username:
			self.username = unicode(getpass.getuser())
110
			gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name', self.username)
111
		else:
112 113 114
			self.username = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name')

		if not gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name'):
115
			print 'Creating zeroconf account'
116 117 118 119 120 121
			gajim.config.add_per('accounts', gajim.ZEROCONF_ACC_NAME)
			gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'autoconnect', True)
			gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'no_log_for', '')
			gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'password', 'zeroconf')
			gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'sync_with_global_status', True)

122
			#XXX make sure host is US-ASCII
sb's avatar
sb committed
123
			self.host = unicode(socket.gethostname())
124
			gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'hostname', self.host)
125
			gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port', 5298)
126
			gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'is_zeroconf', True)
127 128 129 130 131 132 133 134 135
		self.host = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'hostname')
		self.port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port')
		self.autoconnect = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'autoconnect')
		self.sync_with_global_status = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'sync_with_global_status')
		self.no_log_for = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'no_log_for')
		self.first = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name')
		self.last = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name')
		self.jabber_id = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id')
		self.email = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email')
sb's avatar
sb committed
136
	# END __init__
137

sb's avatar
sb committed
138 139 140 141 142 143 144 145 146 147
	def put_event(self, ev):
		if gajim.handlers.has_key(ev[0]):
			gajim.handlers[ev[0]](self.name, ev[1])

	def dispatch(self, event, data):
		'''always passes account name as first param'''
		self.put_event((event, data))

	def _reconnect(self):
		gajim.log.debug('reconnect')
148

sb's avatar
sb committed
149
		signed = self.get_signed_msg(self.status)
sb's avatar
sb committed
150 151
			
	def quit(self, kill_core):
152
	
sb's avatar
sb committed
153
		if kill_core and self.connected > 1:
sb's avatar
sb committed
154
			self.disconnect()
sb's avatar
sb committed
155
	
sb's avatar
sb committed
156 157 158
	def disable_account(self):
		self.disconnect()

sb's avatar
sb committed
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
	def test_gpg_passphrase(self, password):
		self.gpg.passphrase = password
		keyID = gajim.config.get_per('accounts', self.name, 'keyid')
		signed = self.gpg.sign('test', keyID)
		self.gpg.password = None
		return signed != 'BAD_PASSPHRASE'

	def get_signed_msg(self, msg):
		signed = ''
		keyID = gajim.config.get_per('accounts', self.name, 'keyid')
		if keyID and USE_GPG:
			use_gpg_agent = gajim.config.get('use_gpg_agent')
			if self.connected < 2 and self.gpg.passphrase is None and \
				not use_gpg_agent:
				# We didn't set a passphrase
				self.dispatch('ERROR', (_('OpenPGP passphrase was not given'),
					#%s is the account name here
					_('You will be connected to %s without OpenPGP.') % self.name))
			elif self.gpg.passphrase is not None or use_gpg_agent:
				signed = self.gpg.sign(msg, keyID)
				if signed == 'BAD_PASSPHRASE':
					signed = ''
					if self.connected < 2:
						self.dispatch('BAD_PASSPHRASE', ())
		return signed
184

sb's avatar
sb committed
185 186 187
	def _on_resolve_timeout(self):
		if self.connected:
			self.zeroconf.resolve_all()
sb's avatar
sb committed
188 189
			diffs = self.roster.getDiffs()
			for key in diffs:
190
				self.roster.setItem(key)
191
				self.dispatch('NOTIFY', (key, self.roster.getStatus(key), self.roster.getMessage(key), 'local', 0, None, 0))
sb's avatar
sb committed
192 193 194
		return self.call_resolve_timeout

	# callbacks called from zeroconf	
195
	def _on_new_service(self,jid):
196
		self.roster.setItem(jid)
197 198
		self.dispatch('ROSTER_INFO', (jid, self.roster.getName(jid), 'both', 'no', self.roster.getGroups(jid)))
		self.dispatch('NOTIFY', (jid, self.roster.getStatus(jid), self.roster.getMessage(jid), 'local', 0, None, 0))
199
	
200
	def _on_remove_service(self, jid):
201
		self.roster.delItem(jid)
sb's avatar
sb committed
202 203
		# 'NOTIFY' (account, (jid, status, status message, resource, priority,
		# keyID, timestamp))
204
		self.dispatch('NOTIFY', (jid, 'offline', '', 'local', 0, None, 0))
sb's avatar
sb committed
205

206 207 208 209 210 211 212 213
	def _on_disconnected(self):
		self.disconnect()
		self.dispatch('STATUS', 'offline')
		self.dispatch('CONNECTION_LOST',
			(_('Connection with account "%s" has been lost') % self.name,
			_('To continue sending and receiving messages, you will need to reconnect.')))
		self.status = 'offline'

sb's avatar
sb committed
214 215 216 217 218 219 220 221 222 223 224 225
	def connect(self, data = None, show = 'online', msg = ''):
		self.get_config_values_or_default()

		self.zeroconf.txt['status'] = show
		self.zeroconf.txt['msg'] = msg
		self.zeroconf.txt['1st'] = self.first
		self.zeroconf.txt['last'] = self.last
		self.zeroconf.txt['jid'] = self.jabber_id
		self.zeroconf.txt['email'] = self.email
		self.zeroconf.username = self.username
		self.zeroconf.host = self.host
		self.zeroconf.port = self.port
226

227
		if self.zeroconf.connect():
dkirov's avatar
dkirov committed
228 229 230 231
			if not self.connection:
				self.connection = client_zeroconf.ClientZeroconf(self.zeroconf, self)
			else:
				self.zeroconf.announce()
232 233 234 235 236
			self.roster = self.connection.getRoster()
			self.dispatch('ROSTER', self.roster)

			#display contacts already detected and resolved
			for jid in self.roster.keys():
237 238
				self.dispatch('ROSTER_INFO', (jid, self.roster.getName(jid), 'both', 'no', self.roster.getGroups(jid)))
				self.dispatch('NOTIFY', (jid, self.roster.getStatus(jid), self.roster.getMessage(jid), 'local', 0, None, 0))
239 240 241 242 243

			self.connected = STATUS_LIST.index(show)

			# refresh all contacts data every second
			self.call_resolve_timeout = True
244
			gobject.timeout_add(10000, self._on_resolve_timeout)
245
		else:
sb's avatar
sb committed
246 247
			self.dispatch('STATUS', 'offline')
			self.status = 'offline'
248 249 250 251 252

	def disconnect(self, on_purpose = False):
		self.connected = 0
		self.time_to_reconnect = None
		if self.connection:
dkirov's avatar
dkirov committed
253 254
			if self.connection.listener:
				self.connection.listener.disconnect()
255 256 257 258 259
			self.connection = None
			# stop calling the timeout
			self.call_resolve_timeout = False
			self.zeroconf.disconnect()

260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
	def reconnect(self, new_port, use_tls):
		txt = {}
		txt['1st'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name')
		txt['last'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name')
		txt['jid'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id')
		txt['email'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email')
		txt2 = {}
		for key, val in txt.iteritems():
			if val != '':
				txt2[key] = val

		port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port')

		if new_port or use_tls:
			self.connection.kill_all_connections()
			self.connection.listener.disconnect()
			self.connection.start_listener(port)

		self.zeroconf.remove_announce()
		self.zeroconf.txt = txt2
		self.zeroconf.port = port
dkirov's avatar
dkirov committed
281
		self.zeroconf.username = self.username
282
		self.zeroconf.announce()
sb's avatar
sb committed
283

sb's avatar
sb committed
284 285 286
	def change_status(self, show, msg, sync = False, auto = False):
		if not show in STATUS_LIST:
			return -1
sb's avatar
sb committed
287
		self.status = show
288

289 290
		check = True		#to check for errors from zeroconf

sb's avatar
sb committed
291
		# 'connect'
sb's avatar
sb committed
292
		if show != 'offline' and not self.connected:
sb's avatar
sb committed
293
			self.connect(None, show, msg)
294
			if show != 'invisible':
295
					check = self.zeroconf.announce()
296 297
			else:
					self.connected = STATUS_LIST.index(show)
sb's avatar
sb committed
298

sb's avatar
sb committed
299
		# 'disconnect'
sb's avatar
sb committed
300
		elif show == 'offline' and self.connected:
sb's avatar
sb committed
301
			self.disconnect()
302
			self.dispatch('STATUS', 'offline')
303
			
304
		# update status
sb's avatar
sb committed
305 306 307 308
		elif show != 'offline' and self.connected:
			was_invisible = self.connected == STATUS_LIST.index('invisible')
			self.connected = STATUS_LIST.index(show)
			if show == 'invisible':
309 310 311 312
				check = check and self.zeroconf.remove_announce()
			elif was_invisible:
				check = check and self.zeroconf.announce()
			if self.connection and not show == 'invisible':
313 314
				txt = {}
				txt['status'] = show
315
				txt['msg'] = msg
316 317
				check = check and self.zeroconf.update_txt(txt)

318
		#stay offline when zeroconf does something wrong
319 320 321
		if check:
			self.dispatch('STATUS', show)
		else:
322
			# show notification that avahi, or system bus is down	
323
			self.dispatch('STATUS', 'offline')
sb's avatar
sb committed
324
			self.status = 'offline'
325 326 327 328 329
			self.dispatch('CONNECTION_LOST',
				(_('Could not change status of account "%s"') % self.name,
				_('Please check if avahi-daemon is running.')))
			
			
sb's avatar
sb committed
330 331 332 333 334

	def get_status(self):
		return STATUS_LIST[self.connected]

	def send_message(self, jid, msg, keyID, type = 'chat', subject='',
335 336
	chatstate = None, msg_id = None, composing_jep = None, resource = None, 
	user_nick = None):
337 338
		fjid = jid

sb's avatar
sb committed
339 340 341 342
		if not self.connection:
			return
		if not msg and chatstate is None:
			return
343
		
sb's avatar
sb committed
344 345 346 347 348 349 350 351 352 353 354
		msgtxt = msg
		msgenc = ''
		if keyID and USE_GPG:
			#encrypt
			msgenc = self.gpg.encrypt(msg, [keyID])
			if msgenc:
				msgtxt = '[This message is encrypted]'
				lang = os.getenv('LANG')
				if lang is not None or lang != 'en': # we're not english
					msgtxt = _('[This message is encrypted]') +\
						' ([This message is encrypted])' # one  in locale and one en
355 356

		
sb's avatar
sb committed
357 358
		if type == 'chat':
			msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, typ = type)
359
			
sb's avatar
sb committed
360 361 362 363 364 365 366
		else:
			if subject:
				msg_iq = common.xmpp.Message(to = fjid, body = msgtxt,
					typ = 'normal', subject = subject)
			else:
				msg_iq = common.xmpp.Message(to = fjid, body = msgtxt,
					typ = 'normal')
367

sb's avatar
sb committed
368 369
		if msgenc:
			msg_iq.setTag(common.xmpp.NS_ENCRYPTED + ' x').setData(msgenc)
370
		
sb's avatar
sb committed
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
		# chatstates - if peer supports jep85 or jep22, send chatstates
		# please note that the only valid tag inside a message containing a <body>
		# tag is the active event
		if chatstate is not None:
			if composing_jep == 'JEP-0085' or not composing_jep:
				# JEP-0085
				msg_iq.setTag(chatstate, namespace = common.xmpp.NS_CHATSTATES)
			if composing_jep == 'JEP-0022' or not composing_jep:
				# JEP-0022
				chatstate_node = msg_iq.setTag('x', namespace = common.xmpp.NS_EVENT)
				if not msgtxt: # when no <body>, add <id>
					if not msg_id: # avoid putting 'None' in <id> tag
						msg_id = ''
					chatstate_node.setTagData('id', msg_id)
				# when msgtxt, requests JEP-0022 composing notification
				if chatstate is 'composing' or msgtxt: 
					chatstate_node.addChild(name = 'composing') 
388 389
		
		self.connection.send(msg_iq)
sb's avatar
sb committed
390 391 392 393 394 395 396 397 398 399 400 401
		no_log_for = gajim.config.get_per('accounts', self.name, 'no_log_for')
		ji = gajim.get_jid_without_resource(jid)
		if self.name not in no_log_for and ji not in no_log_for:
			log_msg = msg
			if subject:
				log_msg = _('Subject: %s\n%s') % (subject, msg)
			if log_msg:
				if type == 'chat':
					kind = 'chat_msg_sent'
				else:
					kind = 'single_msg_sent'
				gajim.logger.write(kind, jid, log_msg)
402
		#~ self.zeroconf.send_message(jid, msgtxt, type)
403
		
sb's avatar
sb committed
404
		self.dispatch('MSGSENT', (jid, msg, keyID))
405
		
sb's avatar
sb committed
406
	def send_stanza(self, stanza):
407
		# send a stanza untouched
408
		print 'connection_zeroconf.py: send_stanza'
sb's avatar
sb committed
409 410
		if not self.connection:
			return
411
		#self.connection.send(stanza)
412
		pass
sb's avatar
sb committed
413 414
	
	def ack_subscribed(self, jid):
415
		gajim.log.debug('This should not happen (ack_subscribed)')
sb's avatar
sb committed
416 417

	def ack_unsubscribed(self, jid):
418
		gajim.log.debug('This should not happen (ack_unsubscribed)')
sb's avatar
sb committed
419 420 421

	def request_subscription(self, jid, msg = '', name = '', groups = [],
	auto_auth = False):
422
		gajim.log.debug('This should not happen (request_subscription)')
sb's avatar
sb committed
423 424

	def send_authorization(self, jid):
425
		gajim.log.debug('This should not happen (send_authorization)')
sb's avatar
sb committed
426 427

	def refuse_authorization(self, jid):
428
		gajim.log.debug('This should not happen (refuse_authorization)')
sb's avatar
sb committed
429 430

	def unsubscribe(self, jid, remove_auth = True):
431
		gajim.log.debug('This should not happen (unsubscribe)')
sb's avatar
sb committed
432 433

	def unsubscribe_agent(self, agent):
434
		gajim.log.debug('This should not happen (unsubscribe_agent)')
sb's avatar
sb committed
435

436
	def update_contact(self, jid, name, groups):	
sb's avatar
sb committed
437 438 439 440 441
		if self.connection:
			self.connection.getRoster().setItem(jid = jid, name = name,
				groups = groups)
	
	def new_account(self, name, config, sync = False):
442
		gajim.log.debug('This should not happen (new_account)')
sb's avatar
sb committed
443 444

	def _on_new_account(self, con = None, con_type = None):
445
		gajim.log.debug('This should not happen (_on_new_account)')
sb's avatar
sb committed
446 447 448 449 450

	def account_changed(self, new_name):
		self.name = new_name

	def request_last_status_time(self, jid, resource):
451 452
		gajim.log.debug('This should not happen (request_last_status_time)')
		
sb's avatar
sb committed
453
	def request_os_info(self, jid, resource):
454
		'''
sb's avatar
sb committed
455 456 457 458 459 460 461 462
		if not self.connection:
			return
		to_whom_jid = jid
		if resource:
			to_whom_jid += '/' + resource
		iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\
			common.xmpp.NS_VERSION)
		self.connection.send(iq)
463 464
		'''
		pass
sb's avatar
sb committed
465 466

	def get_settings(self):
467
		gajim.log.debug('This should not happen (get_settings)')
sb's avatar
sb committed
468 469

	def get_bookmarks(self):
470
		gajim.log.debug('This should not happen (get_bookmarks)')
471
		
sb's avatar
sb committed
472
	def store_bookmarks(self):
473
		gajim.log.debug('This should not happen (store_bookmarks)')
dkirov's avatar
dkirov committed
474
		
sb's avatar
sb committed
475
	def get_metacontacts(self):
476
		gajim.log.debug('This should not happen (get_metacontacts)')
dkirov's avatar
dkirov committed
477
		
sb's avatar
sb committed
478
	def send_agent_status(self, agent, ptype):
479
		gajim.log.debug('This should not happen (send_agent_status)')
sb's avatar
sb committed
480 481

	def join_gc(self, nick, room, server, password):
482
		gajim.log.debug('This should not happen (join_gc)')
483
		
sb's avatar
sb committed
484
	def send_gc_message(self, jid, msg):
485
		gajim.log.debug('This should not happen (send_gc_message)')
486
		
sb's avatar
sb committed
487
	def send_gc_subject(self, jid, subject):
488
		gajim.log.debug('This should not happen (send_gc_subject)')
489
		
sb's avatar
sb committed
490
	def request_gc_config(self, room_jid):
491
		gajim.log.debug('This should not happen (request_gc_config)')
dkirov's avatar
dkirov committed
492
		
sb's avatar
sb committed
493
	def change_gc_nick(self, room_jid, nick):
494
		gajim.log.debug('This should not happen (change_gc_nick)')
495
		
sb's avatar
sb committed
496
	def send_gc_status(self, nick, jid, show, status):
497
		gajim.log.debug('This should not happen (send_gc_status)')
498
		
sb's avatar
sb committed
499
	def gc_set_role(self, room_jid, nick, role, reason = ''):
500
		gajim.log.debug('This should not happen (gc_set_role)')
501
		
sb's avatar
sb committed
502
	def gc_set_affiliation(self, room_jid, jid, affiliation, reason = ''):
503
		gajim.log.debug('This should not happen (gc_set_affiliation)')
504
		
sb's avatar
sb committed
505
	def send_gc_affiliation_list(self, room_jid, list):
506
		gajim.log.debug('This should not happen (send_gc_affiliation_list)')
507
		
sb's avatar
sb committed
508
	def get_affiliation_list(self, room_jid, affiliation):
509
		gajim.log.debug('This should not happen (get_affiliation_list)')
510
		
sb's avatar
sb committed
511
	def send_gc_config(self, room_jid, config):
512
		gajim.log.debug('This should not happen (send_gc_config)')
513
		
sb's avatar
sb committed
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
	def gpg_passphrase(self, passphrase):
		if USE_GPG:
			use_gpg_agent = gajim.config.get('use_gpg_agent')
			if use_gpg_agent:
				self.gpg.passphrase = None
			else:
				self.gpg.passphrase = passphrase

	def ask_gpg_keys(self):
		if USE_GPG:
			keys = self.gpg.get_keys()
			return keys
		return None

	def ask_gpg_secrete_keys(self):
		if USE_GPG:
			keys = self.gpg.get_secret_keys()
			return keys
		return None

	def change_password(self, password):
		if not self.connection:
			return
537
		'''
sb's avatar
sb committed
538 539 540 541 542 543 544
		hostname = gajim.config.get_per('accounts', self.name, 'hostname')
		username = gajim.config.get_per('accounts', self.name, 'name')
		iq = common.xmpp.Iq(typ = 'set', to = hostname)
		q = iq.setTag(common.xmpp.NS_REGISTER + ' query')
		q.setTagData('username',username)
		q.setTagData('password',password)
		self.connection.send(iq)
545 546 547
		'''
		pass
		
sb's avatar
sb committed
548
	def unregister_account(self, on_remove_success):
549
		gajim.log.debug('This should not happen (unregister_account)')
550
		
sb's avatar
sb committed
551
	def send_invite(self, room, to, reason=''):
552
		gajim.log.debug('This should not happen (send_invite)')
553
		
sb's avatar
sb committed
554 555
	def send_keepalive(self):
		# nothing received for the last foo seconds (60 secs by default)
556
		pass
557
		
558 559 560 561 562 563 564
	def _event_dispatcher(self, realm, event, data):
		if realm == '':
			if event == common.xmpp.transports.DATA_RECEIVED:
				self.dispatch('STANZA_ARRIVED', unicode(data, errors = 'ignore'))
			elif event == common.xmpp.transports.DATA_SENT:
				self.dispatch('STANZA_SENT', unicode(data))

sb's avatar
sb committed
565
# END ConnectionZeroconf