From 4447ec9406317a6b2795cc7231f087111a639039 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Sat, 1 Apr 2006 12:26:10 +0000
Subject: [PATCH] disable DND when account if offline. Fixes #1754

---
 src/roster_window.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/roster_window.py b/src/roster_window.py
index 3ea3fba3ff..b257f025df 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -2989,6 +2989,11 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
 		iter_dest = model.get_iter(path_dest)
 		type_dest = model[iter_dest][C_TYPE].decode('utf-8')
 		jid_dest = model[iter_dest][C_JID].decode('utf-8')
+		account = model[iter_dest][C_ACCOUNT].decode('utf-8')
+
+		# if account is not connected, do nothing
+		if gajim.connections[account].connected < 2:
+			return
 
 		if info == self.TARGET_TYPE_URI_LIST:
 			# User dropped a file on the roster
@@ -2996,7 +3001,6 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
 				return
 			if type_dest != 'contact':
 				return
-			account = model[iter_dest][C_ACCOUNT].decode('utf-8')
 			c_dest = gajim.contacts.get_contact_with_highest_priority(account,
 				jid_dest)
 			uri = data.strip()
@@ -3018,11 +3022,9 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
 			return
 		if type_source != 'contact': # source is not a contact
 			return
-		account = model[iter_source][C_ACCOUNT].decode('utf-8')
-		if type_dest == 'contact':
-			dest_account = model[iter_dest][C_ACCOUNT].decode('utf-8')
-			if account != dest_account: # dropped on a contact from another account
-				return
+		source_account = model[iter_source][C_ACCOUNT].decode('utf-8')
+		if account != source_account: # dropped in another account
+			return
 		it = iter_source
 		while model[it][C_TYPE] == 'contact':
 			it = model.iter_parent(it)
-- 
GitLab