Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gajim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
197
Issues
197
List
Boards
Labels
Service Desk
Milestones
Merge Requests
20
Merge Requests
20
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim
Commits
ccc06a04
Commit
ccc06a04
authored
Sep 18, 2018
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bad-whitespace pylint errors
parent
2acfcfd9
Changes
39
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
646 additions
and
646 deletions
+646
-646
gajim/advanced_configuration_window.py
gajim/advanced_configuration_window.py
+7
-7
gajim/common/app.py
gajim/common/app.py
+3
-3
gajim/common/config.py
gajim/common/config.py
+406
-403
gajim/common/connection.py
gajim/common/connection.py
+11
-11
gajim/common/connection_handlers_events.py
gajim/common/connection_handlers_events.py
+4
-8
gajim/common/events.py
gajim/common/events.py
+2
-2
gajim/common/helpers.py
gajim/common/helpers.py
+6
-6
gajim/common/logger.py
gajim/common/logger.py
+2
-2
gajim/common/logging_helpers.py
gajim/common/logging_helpers.py
+11
-10
gajim/common/proxy65_manager.py
gajim/common/proxy65_manager.py
+1
-1
gajim/common/rst_xhtml_generator.py
gajim/common/rst_xhtml_generator.py
+5
-5
gajim/common/socks5.py
gajim/common/socks5.py
+29
-28
gajim/common/zeroconf/client_zeroconf.py
gajim/common/zeroconf/client_zeroconf.py
+3
-3
gajim/common/zeroconf/connection_zeroconf.py
gajim/common/zeroconf/connection_zeroconf.py
+1
-1
gajim/common/zeroconf/roster_zeroconf.py
gajim/common/zeroconf/roster_zeroconf.py
+1
-1
gajim/common/zeroconf/zeroconf_avahi.py
gajim/common/zeroconf/zeroconf_avahi.py
+2
-2
gajim/common/zeroconf/zeroconf_avahi_const.py
gajim/common/zeroconf/zeroconf_avahi_const.py
+1
-1
gajim/config.py
gajim/config.py
+4
-4
gajim/conversation_textview.py
gajim/conversation_textview.py
+10
-11
gajim/dataforms_widget.py
gajim/dataforms_widget.py
+20
-21
gajim/dialogs.py
gajim/dialogs.py
+7
-7
gajim/disco.py
gajim/disco.py
+24
-24
gajim/filetransfers_window.py
gajim/filetransfers_window.py
+2
-2
gajim/gajim_remote.py
gajim/gajim_remote.py
+8
-8
gajim/groupchat_control.py
gajim/groupchat_control.py
+8
-8
gajim/gtk/history.py
gajim/gtk/history.py
+1
-1
gajim/gtk/preferences.py
gajim/gtk/preferences.py
+1
-1
gajim/gtk/single_message.py
gajim/gtk/single_message.py
+1
-1
gajim/gtkgui_helpers.py
gajim/gtkgui_helpers.py
+8
-8
gajim/gui_interface.py
gajim/gui_interface.py
+2
-2
gajim/gui_menu_builder.py
gajim/gui_menu_builder.py
+1
-1
gajim/htmltextview.py
gajim/htmltextview.py
+19
-19
gajim/message_textview.py
gajim/message_textview.py
+1
-1
gajim/message_window.py
gajim/message_window.py
+8
-7
gajim/plugins/gui.py
gajim/plugins/gui.py
+1
-1
gajim/plugins/helpers.py
gajim/plugins/helpers.py
+3
-3
gajim/plugins/pluginmanager.py
gajim/plugins/pluginmanager.py
+1
-1
gajim/roster_window.py
gajim/roster_window.py
+17
-17
gajim/vcard.py
gajim/vcard.py
+4
-4
No files found.
gajim/advanced_configuration_window.py
View file @
ccc06a04
...
...
@@ -96,14 +96,14 @@ def __init__(self, transient):
self
.
modelfilter
.
set_visible_func
(
self
.
visible_func
)
renderer_text
=
Gtk
.
CellRendererText
()
col
=
Gtk
.
TreeViewColumn
(
_
(
'Preference Name'
),
renderer_text
,
text
=
0
)
col
=
Gtk
.
TreeViewColumn
(
_
(
'Preference Name'
),
renderer_text
,
text
=
0
)
treeview
.
insert_column
(
col
,
-
1
)
col
.
set_resizable
(
True
)
renderer_text
=
Gtk
.
CellRendererText
()
renderer_text
.
connect
(
'edited'
,
self
.
on_config_edited
)
renderer_text
.
set_property
(
'ellipsize'
,
Pango
.
EllipsizeMode
.
END
)
col
=
Gtk
.
TreeViewColumn
(
_
(
'Value'
),
renderer_text
,
text
=
1
)
col
=
Gtk
.
TreeViewColumn
(
_
(
'Value'
),
renderer_text
,
text
=
1
)
treeview
.
insert_column
(
col
,
-
1
)
col
.
set_cell_data_func
(
renderer_text
,
self
.
cb_value_column_data
)
...
...
@@ -112,7 +112,7 @@ def __init__(self, transient):
col
.
props
.
sizing
=
Gtk
.
TreeViewColumnSizing
.
FIXED
renderer_text
=
Gtk
.
CellRendererText
()
col
=
Gtk
.
TreeViewColumn
(
_
(
'Type'
),
renderer_text
,
text
=
2
)
col
=
Gtk
.
TreeViewColumn
(
_
(
'Type'
),
renderer_text
,
text
=
2
)
treeview
.
insert_column
(
col
,
-
1
)
col
.
props
.
sizing
=
Gtk
.
TreeViewColumnSizing
.
FIXED
...
...
@@ -211,7 +211,7 @@ def check_for_restart(self):
self
.
restart_box
.
hide
()
for
opt
in
self
.
changed_opts
:
opt_path
=
opt
.
split
(
'
\n
'
)
if
len
(
opt_path
)
==
3
:
if
len
(
opt_path
)
==
3
:
restart
=
app
.
config
.
get_restart_per
(
opt_path
[
2
],
opt_path
[
1
],
opt_path
[
0
])
else
:
...
...
@@ -224,7 +224,7 @@ def check_for_restart(self):
def
on_config_edited
(
self
,
cell
,
path
,
text
):
# convert modelfilter path to model path
path
=
Gtk
.
TreePath
.
new_from_string
(
path
)
path
=
Gtk
.
TreePath
.
new_from_string
(
path
)
modelpath
=
self
.
modelfilter
.
convert_path_to_child_path
(
path
)
modelrow
=
self
.
model
[
modelpath
]
option
=
modelrow
[
0
]
...
...
@@ -253,7 +253,7 @@ def on_reset_button_clicked(self, widget):
# Check for GtkTreeIter
if
iter_
:
path
=
model
.
get_path
(
iter_
)
opt_path
=
self
.
get_option_path
(
model
,
iter_
)
opt_path
=
self
.
get_option_path
(
model
,
iter_
)
if
len
(
opt_path
)
==
1
:
default
=
app
.
config
.
get_default
(
opt_path
[
0
])
elif
len
(
opt_path
)
==
3
:
...
...
@@ -311,7 +311,7 @@ def fill_model(self, node=None, parent=None):
self
.
model
.
append
(
parent
,
[
name
,
value
,
type_
])
def
visible_func
(
self
,
model
,
treeiter
,
data
):
search_string
=
self
.
entry
.
get_text
().
lower
()
search_string
=
self
.
entry
.
get_text
().
lower
()
for
it
in
tree_model_pre_order
(
model
,
treeiter
):
if
model
[
it
][
Column
.
TYPE
]
!=
''
:
opt_path
=
self
.
get_option_path
(
model
,
it
)
...
...
gajim/common/app.py
View file @
ccc06a04
...
...
@@ -364,7 +364,7 @@ def get_number_of_accounts():
"""
return
len
(
connections
.
keys
())
def
get_number_of_connected_accounts
(
accounts_list
=
None
):
def
get_number_of_connected_accounts
(
accounts_list
=
None
):
"""
Returns the number of CONNECTED accounts. Uou can optionally pass an
accounts_list and if you do those will be checked, else all will be checked
...
...
@@ -456,7 +456,7 @@ def account_is_securely_connected(account):
return
False
return
con_types
.
get
(
account
)
in
(
'tls'
,
'ssl'
)
def
get_transport_name_from_jid
(
jid
,
use_config_setting
=
True
):
def
get_transport_name_from_jid
(
jid
,
use_config_setting
=
True
):
"""
Returns 'gg', 'irc' etc
...
...
@@ -517,7 +517,7 @@ def get_our_jids():
our_jids
.
append
(
get_jid_from_account
(
account
))
return
our_jids
def
get_hostname_from_account
(
account_name
,
use_srv
=
False
):
def
get_hostname_from_account
(
account_name
,
use_srv
=
False
):
"""
Returns hostname (if custom hostname is used, that is returned)
"""
...
...
gajim/common/config.py
View file @
ccc06a04
This diff is collapsed.
Click to expand it.
gajim/common/connection.py
View file @
ccc06a04
...
...
@@ -169,7 +169,7 @@ def test_gpg_passphrase(self, password):
return
'bad_pass'
return
'ok'
def
get_signed_msg
(
self
,
msg
,
callback
=
None
):
def
get_signed_msg
(
self
,
msg
,
callback
=
None
):
"""
Returns the signed message if possible or an empty string if gpg is not
used or None if waiting for passphrase
...
...
@@ -293,8 +293,8 @@ def _build_message_stanza(self, obj):
addresses
=
msg_iq
.
addChild
(
'addresses'
,
namespace
=
nbxmpp
.
NS_ADDRESS
)
for
j
in
obj
.
jid
:
addresses
.
addChild
(
'address'
,
attrs
=
{
'type'
:
'to'
,
'jid'
:
j
})
addresses
.
addChild
(
'address'
,
attrs
=
{
'type'
:
'to'
,
'jid'
:
j
})
else
:
iqs
=
[]
for
j
in
obj
.
jid
:
...
...
@@ -708,7 +708,7 @@ def disconnectedReconnCB(self):
def
_connection_lost
(
self
):
log
.
info
(
'_connection_lost'
)
self
.
disconnect
(
on_purpose
=
False
)
self
.
disconnect
(
on_purpose
=
False
)
if
self
.
removing_account
:
return
app
.
nec
.
push_incoming_event
(
ConnectionLostEvent
(
None
,
conn
=
self
,
...
...
@@ -746,7 +746,7 @@ def _on_register_result(result):
self
.
gpg
=
gpg
.
GnuPG
()
app
.
nec
.
push_incoming_event
(
AccountCreatedEvent
(
None
,
conn
=
self
,
account_info
=
self
.
new_account_info
))
account_info
=
self
.
new_account_info
))
self
.
new_account_info
=
None
self
.
new_account_form
=
None
if
self
.
connection
:
...
...
@@ -1062,7 +1062,7 @@ def log_hosttype_info(self, port):
log
.
info
(
msg
)
if
self
.
_proxy
:
msg
=
'>>>>>> '
if
self
.
_proxy
[
'type'
]
==
'bosh'
:
if
self
.
_proxy
[
'type'
]
==
'bosh'
:
msg
=
'%s over BOSH %s'
%
(
msg
,
self
.
_proxy
[
'bosh_uri'
])
if
self
.
_proxy
[
'type'
]
in
[
'http'
,
'socks5'
]
or
self
.
_proxy
[
'bosh_useproxy'
]:
msg
=
'%s over proxy %s:%s'
%
(
msg
,
self
.
_proxy
[
'host'
],
self
.
_proxy
[
'port'
])
...
...
@@ -1072,7 +1072,7 @@ def _connect_failure(self, con_type=None):
if
not
con_type
:
# we are not retrying, and not conecting
if
not
self
.
retrycount
and
self
.
connected
!=
0
:
self
.
disconnect
(
on_purpose
=
True
)
self
.
disconnect
(
on_purpose
=
True
)
if
self
.
_proxy
:
pritxt
=
_
(
'Could not connect to "%(host)s" via proxy "%(proxy)s"'
)
%
\
{
'host'
:
self
.
_hostname
,
'proxy'
:
self
.
_proxy
[
'host'
]}
...
...
@@ -1097,7 +1097,7 @@ def on_proxy_failure(self, reason):
log
.
error
(
'Connection to proxy failed: %s'
,
reason
)
self
.
time_to_reconnect
=
None
self
.
on_connect_failure
=
None
self
.
disconnect
(
on_purpose
=
True
)
self
.
disconnect
(
on_purpose
=
True
)
app
.
nec
.
push_incoming_event
(
ConnectionLostEvent
(
None
,
conn
=
self
,
title
=
_
(
'Connection to proxy failed'
),
msg
=
reason
))
...
...
@@ -1334,7 +1334,7 @@ def __on_auth(self, con, auth):
# Forget password, it's wrong
self
.
password
=
None
log
.
debug
(
"Couldn't authenticate to %s"
,
self
.
_hostname
)
self
.
disconnect
(
on_purpose
=
True
)
self
.
disconnect
(
on_purpose
=
True
)
app
.
nec
.
push_incoming_event
(
OurShowEvent
(
None
,
conn
=
self
,
show
=
'offline'
))
app
.
nec
.
push_incoming_event
(
InformationEvent
(
None
,
conn
=
self
,
...
...
@@ -1351,7 +1351,7 @@ def send_keepalive(self):
if
self
.
connection
:
self
.
connection
.
send
(
' '
)
def
send_invisible_presence
(
self
,
msg
,
signed
,
initial
=
False
):
def
send_invisible_presence
(
self
,
msg
,
signed
,
initial
=
False
):
if
not
app
.
account_is_connected
(
self
.
name
):
return
if
not
self
.
get_module
(
'PrivacyLists'
).
supported
:
...
...
@@ -1412,7 +1412,7 @@ def _continue_invisible(self, con, iq_obj, msg, signed, initial):
# Inform GUI we just signed in
app
.
nec
.
push_incoming_event
(
SignedInEvent
(
None
,
conn
=
self
))
def
get_signed_presence
(
self
,
msg
,
callback
=
None
):
def
get_signed_presence
(
self
,
msg
,
callback
=
None
):
if
app
.
config
.
get_per
(
'accounts'
,
self
.
name
,
'gpg_sign_presence'
):
return
self
.
get_signed_msg
(
msg
,
callback
)
return
''
...
...
gajim/common/connection_handlers_events.py
View file @
ccc06a04
...
...
@@ -842,8 +842,8 @@ def generate(self):
n
=
file_tag
.
getTag
(
'name'
)
n
=
n
.
getData
()
if
n
else
None
pjid
=
app
.
get_jid_without_resource
(
self
.
fjid
)
file_info
=
self
.
conn
.
get_file_info
(
pjid
,
hash_
=
h
,
name
=
n
,
account
=
self
.
conn
.
name
)
file_info
=
self
.
conn
.
get_file_info
(
pjid
,
hash_
=
h
,
name
=
n
,
account
=
self
.
conn
.
name
)
self
.
file_props
.
file_name
=
file_info
[
'file-name'
]
self
.
file_props
.
sender
=
self
.
conn
.
_ft_get_our_jid
()
self
.
file_props
.
receiver
=
self
.
fjid
...
...
@@ -1244,16 +1244,12 @@ def generate(self):
return
True
class
StanzaMessageOutgoingEvent
(
nec
.
NetworkOutgoingEvent
):
name
=
'stanza-message-outgoing'
name
=
'stanza-message-outgoing'
def
generate
(
self
):
return
True
class
GcStanzaMessageOutgoingEvent
(
nec
.
NetworkOutgoingEvent
):
name
=
'gc-stanza-message-outgoing'
name
=
'gc-stanza-message-outgoing'
def
generate
(
self
):
return
True
class
GcMessageOutgoingEvent
(
nec
.
NetworkOutgoingEvent
):
name
=
'gc-message-outgoing'
...
...
gajim/common/events.py
View file @
ccc06a04
...
...
@@ -61,7 +61,7 @@ def __init__(self, time_=None, show_in_roster=False, show_in_systray=True):
class
ChatEvent
(
Event
):
type_
=
'chat'
def
__init__
(
self
,
message
,
subject
,
kind
,
time_
,
encrypted
,
resource
,
def
__init__
(
self
,
message
,
subject
,
kind
,
time_
,
encrypted
,
resource
,
msg_log_id
,
correct_id
=
None
,
xhtml
=
None
,
session
=
None
,
form_node
=
None
,
displaymarking
=
None
,
sent_forwarded
=
False
,
show_in_roster
=
False
,
show_in_systray
=
True
,
additional_data
=
None
):
...
...
@@ -301,7 +301,7 @@ def change_jid(self, account, old_jid, new_jid):
def
get_nb_events
(
self
,
types
=
None
,
account
=
None
):
if
types
is
None
:
types
=
[]
return
self
.
_get_nb_events
(
types
=
types
,
account
=
account
)
return
self
.
_get_nb_events
(
types
=
types
,
account
=
account
)
def
get_events
(
self
,
account
,
jid
=
None
,
types
=
None
):
"""
...
...
gajim/common/helpers.py
View file @
ccc06a04
...
...
@@ -274,7 +274,7 @@ def temp_failure_retry(func, *args, **kwargs):
else
:
raise
def
get_uf_show
(
show
,
use_mnemonic
=
False
):
def
get_uf_show
(
show
,
use_mnemonic
=
False
):
"""
Return a userfriendly string for dnd/xa/chat and make all strings
translatable
...
...
@@ -361,7 +361,7 @@ def get_uf_ask(ask):
return
uf_ask
def
get_uf_role
(
role
,
plural
=
False
):
def
get_uf_role
(
role
,
plural
=
False
):
''' plural determines if you get Moderators or Moderator'''
if
role
==
'none'
:
role_name
=
Q_
(
'?Group Chat Contact Role:None'
)
...
...
@@ -516,7 +516,7 @@ def sanitize_filename(filename):
return
filename
def
reduce_chars_newlines
(
text
,
max_chars
=
0
,
max_lines
=
0
):
def
reduce_chars_newlines
(
text
,
max_chars
=
0
,
max_lines
=
0
):
"""
Cut the chars after 'max_chars' on each line and show only the first
'max_lines'
...
...
@@ -984,7 +984,7 @@ def get_notification_icon_tooltip_dict():
account_name
=
account
[
'name'
]
account
[
'event_lines'
]
=
[]
# Gather events per-account
pending_events
=
app
.
events
.
get_events
(
account
=
account_name
)
pending_events
=
app
.
events
.
get_events
(
account
=
account_name
)
messages
,
non_messages
,
total_messages
,
total_non_messages
=
{},
{},
0
,
0
for
jid
in
pending_events
:
for
event
in
pending_events
[
jid
]:
...
...
@@ -1028,7 +1028,7 @@ def get_notification_icon_tooltip_dict():
text
=
ngettext
(
'%d event pending'
,
'%d events pending'
,
total_non_messages
,
total_non_messages
,
total_non_messages
)
total_non_messages
,
total_non_messages
,
total_non_messages
)
account
[
'event_lines'
].
append
(
text
)
else
:
for
jid
in
non_messages
:
...
...
@@ -1194,7 +1194,7 @@ def prepare_and_validate_gpg_keyID(account, jid, keyID):
keyID
=
'UNKNOWN'
return
keyID
def
update_optional_features
(
account
=
None
):
def
update_optional_features
(
account
=
None
):
if
account
:
accounts
=
[
account
]
else
:
...
...
gajim/common/logger.py
View file @
ccc06a04
...
...
@@ -1010,9 +1010,9 @@ def iter_caps_data(self):
lang
=
data
[
i
+
2
]
name
=
data
[
i
+
3
]
identities
.
append
({
'category'
:
category
,
'type'
:
type_
,
'xml:lang'
:
lang
,
'name'
:
name
})
'xml:lang'
:
lang
,
'name'
:
name
})
i
+=
4
i
+=
1
i
+=
1
while
i
<
len
(
data
):
features
.
append
(
data
[
i
])
i
+=
1
...
...
gajim/common/logging_helpers.py
View file @
ccc06a04
...
...
@@ -71,6 +71,7 @@ def parseAndSetLogLevels(arg):
class
colors
:
# pylint: disable=C0326
NONE
=
chr
(
27
)
+
"[0m"
BLACk
=
chr
(
27
)
+
"[30m"
RED
=
chr
(
27
)
+
"[31m"
...
...
@@ -97,11 +98,11 @@ class FancyFormatter(logging.Formatter):
An eye-candy formatter with colors
"""
colors_mapping
=
{
'DEBUG'
:
colors
.
BLUE
,
'INFO'
:
colors
.
GREEN
,
'WARNING'
:
colors
.
BROWN
,
'ERROR'
:
colors
.
RED
,
'CRITICAL'
:
colors
.
BRIGHT_RED
,
'DEBUG'
:
colors
.
BLUE
,
'INFO'
:
colors
.
GREEN
,
'WARNING'
:
colors
.
BROWN
,
'ERROR'
:
colors
.
RED
,
'CRITICAL'
:
colors
.
BRIGHT_RED
,
}
def
__init__
(
self
,
fmt
,
datefmt
=
None
,
use_color
=
False
):
...
...
@@ -138,11 +139,11 @@ def init():
consoleloghandler
=
logging
.
StreamHandler
()
consoleloghandler
.
setFormatter
(
FancyFormatter
(
'%(asctime)s %(levelname)s %(name)s %(message)s'
,
'%x %H:%M:%S'
,
use_color
)
FancyFormatter
(
'%(asctime)s %(levelname)s %(name)s %(message)s'
,
'%x %H:%M:%S'
,
use_color
)
)
# fake the root logger so we have 'gajim' root name instead of 'root'
...
...
gajim/common/proxy65_manager.py
View file @
ccc06a04
...
...
@@ -141,7 +141,7 @@ def _on_connect_success(self):
iq
=
nbxmpp
.
Protocol
(
name
=
'iq'
,
to
=
self
.
jid
,
typ
=
'set'
)
query
=
iq
.
setTag
(
'query'
)
query
.
setNamespace
(
nbxmpp
.
NS_BYTESTREAM
)
query
.
setAttr
(
'sid'
,
self
.
sid
)
query
.
setAttr
(
'sid'
,
self
.
sid
)
activate
=
query
.
setTag
(
'activate'
)
activate
.
setData
(
'test@gajim.org/test2'
)
...
...
gajim/common/rst_xhtml_generator.py
View file @
ccc06a04
...
...
@@ -35,11 +35,11 @@ def pos_int_validator(text):
result
=
int
(
text
)
if
result
<
0
:
raise
ValueError
(
"Error: value '%(text)s' "
"must be a positive integer"
)
"must be a positive integer"
)
return
result
def
generate_uri_role
(
role_name
,
aliases
,
anchor_text
,
base_url
,
interpret_url
,
validator
):
def
generate_uri_role
(
role_name
,
aliases
,
anchor_text
,
base_url
,
interpret_url
,
validator
):
"""
Create and register a uri based "interpreted role"
...
...
@@ -58,13 +58,13 @@ def generate_uri_role( role_name, aliases, anchor_text, base_url,
should return the validated text, or raise ValueError
"""
def
uri_reference_role
(
role
,
rawtext
,
text
,
lineno
,
inliner
,
options
=
None
,
content
=
None
):
options
=
None
,
content
=
None
):
if
options
is
None
:
options
=
{}
try
:
valid_text
=
validator
(
text
)
except
ValueError
as
e
:
msg
=
inliner
.
reporter
.
error
(
e
.
message
%
dict
(
text
=
text
),
line
=
lineno
)
msg
=
inliner
.
reporter
.
error
(
e
.
message
%
dict
(
text
=
text
),
line
=
lineno
)
prb
=
inliner
.
problematic
(
rawtext
,
rawtext
,
msg
)
return
[
prb
],
[
msg
]
ref
=
base_url
+
interpret_url
%
valid_text
...
...
gajim/common/socks5.py
View file @
ccc06a04
...
...
@@ -24,19 +24,21 @@
import
os
import
time
import
platform
import
logging
from
errno
import
EWOULDBLOCK
from
errno
import
ENOBUFS
from
errno
import
EINTR
from
errno
import
EISCONN
from
errno
import
EINPROGRESS
from
errno
import
EAFNOSUPPORT
from
nbxmpp.idlequeue
import
IdleObject
import
OpenSSL
from
gajim.common.file_props
import
FilesProp
from
gajim.common
import
app
from
gajim.common
import
jingle_xtls
if
jingle_xtls
.
PYOPENSSL_PRESENT
:
import
OpenSSL
import
logging
log
=
logging
.
getLogger
(
'gajim.c.socks5'
)
MAX_BUFF_LEN
=
65536
# after foo seconds without activity label transfer as 'stalled'
...
...
@@ -159,8 +161,8 @@ def connect_to_hosts(self, account, transport_sid, on_success=None,
file_props
.
proxy_sender
=
streamhost
[
'target'
]
file_props
.
proxy_receiver
=
streamhost
[
'initiator'
]
socks5obj
=
Socks5SenderClient
(
self
.
idlequeue
,
idx
,
self
,
_sock
=
None
,
host
=
str
(
streamhost
[
'host'
]),
port
=
int
(
streamhost
[
'port'
]),
fingerprint
=
fp
,
self
,
_sock
=
None
,
host
=
str
(
streamhost
[
'host'
]),
port
=
int
(
streamhost
[
'port'
]),
fingerprint
=
fp
,
connected
=
False
,
file_props
=
file_props
,
initiator
=
streamhost
[
'initiator'
],
target
=
streamhost
[
'target'
])
...
...
@@ -342,7 +344,7 @@ def on_connection_accepted(self, sock, listener):
sock_hash
=
sock
.
__hash__
()
if
listener
.
file_props
.
type_
==
's'
and
\
not
self
.
isHashInSockObjs
(
self
.
senders
,
sock_hash
):
sockobj
=
Socks5SenderServer
(
self
.
idlequeue
,
sock_hash
,
self
,
sockobj
=
Socks5SenderServer
(
self
.
idlequeue
,
sock_hash
,
self
,
sock
[
0
],
sock
[
1
][
0
],
sock
[
1
][
1
],
fingerprint
=
None
,
file_props
=
listener
.
file_props
)
self
.
_add
(
sockobj
,
self
.
senders
,
listener
.
file_props
,
sock_hash
)
...
...
@@ -356,8 +358,8 @@ def on_connection_accepted(self, sock, listener):
sh
[
'port'
]
=
sock
[
1
][
1
]
sh
[
'initiator'
]
=
None
sh
[
'target'
]
=
None
sockobj
=
Socks5ReceiverServer
(
idlequeue
=
self
.
idlequeue
,
streamhost
=
sh
,
transport_sid
=
None
,
sockobj
=
Socks5ReceiverServer
(
idlequeue
=
self
.
idlequeue
,
streamhost
=
sh
,
transport_sid
=
None
,
file_props
=
listener
.
file_props
,
fingerprint
=
None
)
self
.
_add
(
sockobj
,
self
.
readers
,
listener
.
file_props
,
sock_hash
)
...
...
@@ -411,8 +413,8 @@ def remove_receiver(self, idx, do_disconnect=True, remove_all=False):
if
idx
!=
-
1
:
for
key
in
list
(
self
.
readers
.
keys
()):
if
idx
in
key
:
self
.
remove_receiver_by_key
(
key
,
do_disconnect
=
do_disconnect
)
self
.
remove_receiver_by_key
(
key
,
do_disconnect
=
do_disconnect
)
if
not
remove_all
:
break
...
...
@@ -528,8 +530,8 @@ def connect(self):
def
do_connect
(
self
):
try
:
self
.
_sock
.
connect
(
self
.
_server
)
self
.
_send
=
self
.
_sock
.
send
self
.
_recv
=
self
.
_sock
.
recv
self
.
_send
=
self
.
_sock
.
send
self
.
_recv
=
self
.
_sock
.
recv
except
(
OpenSSL
.
SSL
.
WantReadError
,
OpenSSL
.
SSL
.
WantWriteError
):
pass
except
Exception
as
ee
:
...
...
@@ -545,8 +547,8 @@ def do_connect(self):
return
None
# socket is already connected
self
.
_sock
.
setblocking
(
False
)
self
.
_send
=
self
.
_sock
.
send
self
.
_recv
=
self
.
_sock
.
recv
self
.
_send
=
self
.
_sock
.
send
self
.
_recv
=
self
.
_sock
.
recv
self
.
buff
=
''
self
.
connected
=
True
self
.
file_props
.
connected
=
True
...
...
@@ -855,7 +857,7 @@ def _get_connect_buff(self):
self
.
port
>>
8
,
self
.
port
&
0xff
)
return
buff
def
_get_request_buff
(
self
,
msg
,
command
=
0x01
):
def
_get_request_buff
(
self
,
msg
,
command
=
0x01
):
"""
Connect request by domain name, sid sha, instead of domain name (jep
0096)
...
...
@@ -931,7 +933,7 @@ class Socks5Sender(IdleObject):
Class for sending file to socket over socks5
"""
def
__init__
(
self
,
idlequeue
,
sock_hash
,
parent
,
_sock
,
host
=
None
,
port
=
None
,
fingerprint
=
None
,
connected
=
True
,
file_props
=
None
):
port
=
None
,
fingerprint
=
None
,
connected
=
True
,
file_props
=
None
):
self
.
fingerprint
=
fingerprint
self
.
queue_idx
=
sock_hash
self
.
queue
=
parent
...
...
@@ -1010,8 +1012,8 @@ def disconnect(self, cb=True):
class
Socks5Receiver
(
IdleObject
):
def
__init__
(
self
,
idlequeue
,
streamhost
,
sid
,
file_props
=
None
,
fingerprint
=
None
):
def
__init__
(
self
,
idlequeue
,
streamhost
,
sid
,
file_props
=
None
,
fingerprint
=
None
):
"""
fingerprint: fingerprint of certificates we shall use, set to None if
TLS connection not desired
...
...
@@ -1345,23 +1347,23 @@ def pollend(self):
class
Socks5SenderClient
(
Socks5Client
,
Socks5Sender
):
def
__init__
(
self
,
idlequeue
,
sock_hash
,
parent
,
_sock
,
host
=
None
,
port
=
None
,
fingerprint
=
None
,
connected
=
True
,
file_props
=
None
,
def
__init__
(
self
,
idlequeue
,
sock_hash
,
parent
,
_sock
,
host
=
None
,
port
=
None
,
fingerprint
=
None
,
connected
=
True
,
file_props
=
None
,
initiator
=
None
,
target
=
None
):
Socks5Client
.
__init__
(
self
,
idlequeue
,
host
,
port
,
initiator
,
target
,
file_props
.
transport_sid
)
Socks5Sender
.
__init__
(
self
,
idlequeue
,
sock_hash
,
parent
,
_sock
,
host
,
port
,
fingerprint
,
connected
,
file_props
)
Socks5Sender
.
__init__
(
self
,
idlequeue
,
sock_hash
,
parent
,
_sock
,
host
,
port
,
fingerprint
,
connected
,
file_props
)
class
Socks5SenderServer
(
Socks5Server
,
Socks5Sender
):
def
__init__
(
self
,
idlequeue
,
sock_hash
,
parent
,
_sock
,
host
=
None
,
port
=
None
,
fingerprint
=
None
,
connected
=
True
,
file_props
=
None
):
def
__init__
(
self
,
idlequeue
,
sock_hash
,
parent
,
_sock
,
host
=
None
,
port
=
None
,
fingerprint
=
None
,
connected
=
True
,
file_props
=
None
):
Socks5Server
.
__init__
(
self
,
idlequeue
,
host
,
port
,
None
,
None
,
file_props
.
transport_sid
)
Socks5Sender
.
__init__
(
self
,
idlequeue
,
sock_hash
,
parent
,
_sock
,
host
,
port
,
fingerprint
,
connected
,
file_props
)
Socks5Sender
.
__init__
(
self
,
idlequeue
,
sock_hash
,
parent
,
_sock
,
host
,
port
,
fingerprint
,
connected
,
file_props
)
class
Socks5ReceiverClient
(
Socks5Client
,
Socks5Receiver
):
...
...
@@ -1481,8 +1483,7 @@ def accept_conn(self):
"""
Accept a new incomming connection
"""
_sock
=
self
.
_serv
.
accept
()
_sock
=
self
.
_serv
.
accept
()
_sock
[
0
].
setblocking
(
False
)
self
.
connections
.
append
(
_sock
[
0
])
return
_sock
gajim/common/zeroconf/client_zeroconf.py
View file @
ccc06a04
...
...
@@ -315,7 +315,7 @@ def remove_timeout(self):
def
_register_handlers
(
self
):
self
.
_caller
.
peerhost
=
self
.
Connection
.
_sock
.
getsockname
()
self
.
RegisterHandler
(
'message'
,
lambda
conn
,
data
:
self
.
_caller
.
_messageCB
(
self
.
Server
,
conn
,
data
))
data
:
self
.
_caller
.
_messageCB
(
self
.
Server
,
conn
,
data
))
self
.
RegisterHandler
(
'iq'
,
self
.
_caller
.
_siSetCB
,
'set'
,
nbxmpp
.
NS_SI
)
self
.
RegisterHandler
(
'iq'
,
self
.
_caller
.
_siErrorCB
,
'error'
,
nbxmpp
.
NS_SI
)
...
...
@@ -522,7 +522,7 @@ def pollin(self):
self
.
pollend
()
# don't proccess result, cas it will raise error
return
elif
not
received
:
elif
not
received
:
if
errnum
!=
ssl
.
SSL_ERROR_EOF
:
# 8 EOF occurred in violation of protocol
self
.
pollend
()
...
...
@@ -716,7 +716,7 @@ def kill_all_connections(self):
connection
.
force_disconnect
()
def
add_connection
(
self
,
connection
,
ip
,
port
,
recipient
):
sock_hash
=
connection
.
sock_hash
sock_hash
=
connection
.
sock_hash
if
sock_hash
not
in
self
.
connections
:
self
.
connections
[
sock_hash
]
=
connection
self
.
ip_to_hash
[
ip
]
=
sock_hash
...
...
gajim/common/zeroconf/connection_zeroconf.py
View file @
ccc06a04
...
...
@@ -132,7 +132,7 @@ def _on_resolve_timeout(self):
for
key
in
diffs
:
self
.
roster
.
setItem
(
key
)
app
.
nec
.
push_incoming_event
(
NetworkEvent
(
'roster-info'
,
conn
=
self
,
jid
=
key
,
'roster-info'
,
conn
=
self
,
jid
=
key
,
nickname
=
self
.
roster
.
getName
(
key
),
sub
=
'both'
,
ask
=
'no'
,
groups
=
self
.
roster
.
getGroups
(
key
),
avatar_sha
=
None
))
...
...
gajim/common/zeroconf/roster_zeroconf.py
View file @
ccc06a04
...
...
@@ -62,7 +62,7 @@ def setItem(self, jid, name='', groups=''):
i
+=
1
txt
=
contact
[
Constant
.
TXT
]
self
.
_data
[
jid
]
=
{}
self
.
_data
[
jid
]
=
{}
self
.
_data
[
jid
][
'ask'
]
=
'none'
self
.
_data
[
jid
][
'subscription'
]
=
'both'
self
.
_data
[
jid
][
'groups'
]
=
[]
...
...
gajim/common/zeroconf/zeroconf_avahi.py
View file @
ccc06a04
...
...
@@ -77,7 +77,7 @@ def new_service_callback(self, interface, protocol, name, stype, domain,
return
# synchronous resolving
self
.
server
.
ResolveService
(
int
(
interface
),
int
(
protocol
),
name
,
stype
,
self
.
server
.
ResolveService
(
int
(
interface
),
int
(
protocol
),
name
,
stype
,
domain
,
Protocol
.
UNSPEC
,
dbus
.
UInt32
(
0
),
reply_handler
=
self
.
service_resolved_callback
,
error_handler
=
self
.
error_callback1
)
...
...
@@ -474,7 +474,7 @@ def get_contact(self, jid):
return
None
return
self
.
contacts
[
jid
]
def
update_txt
(
self
,
show
=
None
):
def
update_txt
(
self
,
show
=
None
):
if
show
:
self
.
txt
[
'status'
]
=
self
.
replace_show
(
show
)
...
...
gajim/common/zeroconf/zeroconf_avahi_const.py
View file @
ccc06a04
...
...
@@ -58,7 +58,7 @@ class DomainBrowser(IntEnum):
class
Protocol
(
IntEnum
):
UNSPEC
=
-
1
INET
=
0
INET6
=
1
INET6
=
1
class
Interface
(
IntEnum
):
...
...
gajim/config.py
View file @
ccc06a04
...
...
@@ -199,7 +199,7 @@ def on_proxies_treeview_cursor_changed(self, widget):
else
:
proxytype
=
app
.
config
.
get_per
(
'proxies'
,
proxy
,
'type'
)
self
.
show_bosh_fields
(
proxytype
==
'bosh'
)
self
.
show_bosh_fields
(
proxytype
==
'bosh'
)
self
.
proxyname_entry
.
set_editable
(
True
)
self
.
xml
.
get_object
(
'remove_proxy_button'
).
set_sensitive
(
True
)
...
...
@@ -254,7 +254,7 @@ def on_proxytype_combobox_changed(self, widget):
return