Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Weblate
gajim
Commits
3b5cabac
Commit
3b5cabac
authored
13 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
coding standards
parent
5142ebd6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/xmpp/protocol.py
+7
-7
7 additions, 7 deletions
src/common/xmpp/protocol.py
src/gui_interface.py
+12
-10
12 additions, 10 deletions
src/gui_interface.py
with
19 additions
and
17 deletions
src/common/xmpp/protocol.py
+
7
−
7
View file @
3b5cabac
...
...
@@ -1066,7 +1066,7 @@ class Hashes(Node):
instead of doing it all over the place in Gajim.
"""
hl
=
None
hash
=
None
hash
_
=
None
# file_string can be a string or a file
if
type
(
file_string
)
==
str
:
# if it is a string
if
algo
==
'
md5
'
:
...
...
@@ -1083,7 +1083,7 @@ class Hashes(Node):
raise
Exception
(
'
Hash algorithm not supported
'
)
else
:
hl
.
update
(
file_string
)
hash
=
hl
.
hexdigest
()
hash
_
=
hl
.
hexdigest
()
else
:
# if it is a file
if
algo
==
'
md5
'
:
...
...
@@ -1101,25 +1101,25 @@ class Hashes(Node):
else
:
for
line
in
file_string
:
hl
.
update
(
line
)
hash
=
hl
.
hexdigest
()
hash
_
=
hl
.
hexdigest
()
return
hash
return
hash
_
def
addHash
(
self
,
hash
,
algo
):
def
addHash
(
self
,
hash
_
,
algo
):
"""
More than one hash can be added. Although it is permitted, it should
not be done for big files because it could slow down Gajim.
"""
attrs
=
{}
attrs
[
'
algo
'
]
=
algo
self
.
addChild
(
'
hash
'
,
attrs
,
[
hash
])
self
.
addChild
(
'
hash
'
,
attrs
,
[
hash
_
])
class
Acks
(
Node
):
"""
Acknowledgement elements for Stream Management
"""
def
__init__
(
self
,
nsp
=
NS_STREAM_MGMT
):
Node
.
__init__
(
self
,
None
,
{},
[],
None
,
None
,
False
,
None
)
Node
.
__init__
(
self
,
None
,
{},
[],
None
,
None
,
False
,
None
)
self
.
setNamespace
(
nsp
)
def
buildAnswer
(
self
,
handled
):
...
...
This diff is collapsed.
Click to expand it.
src/gui_interface.py
+
12
−
10
View file @
3b5cabac
...
...
@@ -909,18 +909,20 @@ class Interface:
self
.
last_ftwindow_update
=
time
.
time
()
self
.
instances
[
'
file_transfers
'
].
set_progress
(
file_props
[
'
type
'
],
file_props
[
'
sid
'
],
file_props
[
'
received-len
'
])
def
__compare_hashes
(
self
,
account
,
file_props
):
session
=
gajim
.
connections
[
account
].
get_jingle_session
(
jid
=
None
,
sid
=
file_props
[
'
session-sid
'
])
sid
=
file_props
[
'
session-sid
'
])
h
=
Hashes
()
try
:
file
=
open
(
file_props
[
'
file-name
'
],
'
r
'
)
file
_
=
open
(
file_props
[
'
file-name
'
],
'
r
'
)
except
:
return
hash
=
h
.
calculateHash
(
session
.
hash_algo
,
file
)
hash_
=
h
.
calculateHash
(
session
.
hash_algo
,
file_
)
file_
.
close
()
# If the hash we received and the hash of the file are the same,
# then the file is not corrupt
if
session
.
file_hash
==
hash
:
if
session
.
file_hash
==
hash
_
:
print
"
they are te same
"
# End jingle session
if
session
:
...
...
@@ -930,18 +932,18 @@ class Interface:
ft
=
self
.
instances
[
'
file_transfers
'
]
if
file_props
[
'
error
'
]
==
0
:
ft
.
set_progress
(
file_props
[
'
type
'
],
file_props
[
'
sid
'
],
file_props
[
'
received-len
'
])
file_props
[
'
received-len
'
])
else
:
ft
.
set_status
(
file_props
[
'
type
'
],
file_props
[
'
sid
'
],
'
stop
'
)
if
'
stalled
'
in
file_props
and
file_props
[
'
stalled
'
]
or
\
'
paused
'
in
file_props
and
file_props
[
'
paused
'
]:
'
paused
'
in
file_props
and
file_props
[
'
paused
'
]:
return
if
file_props
[
'
type
'
]
==
'
r
'
:
# we receive a file
jid
=
unicode
(
file_props
[
'
sender
'
])
# Compare hashes in a new thread
self
.
hashThread
=
Thread
(
target
=
self
.
__compare_hashes
,
args
=
(
account
,
file_props
))
self
.
hashThread
=
Thread
(
target
=
self
.
__compare_hashes
,
args
=
(
account
,
file_props
))
self
.
hashThread
.
start
()
gajim
.
socks5queue
.
remove_receiver
(
file_props
[
'
sid
'
],
True
,
True
)
else
:
# we send a file
...
...
@@ -969,7 +971,7 @@ class Interface:
elif
file_props
[
'
error
'
]
in
(
-
1
,
-
6
):
msg_type
=
'
file-stopped
'
event_type
=
_
(
'
File Transfer Stopped
'
)
if
event_type
==
''
:
# FIXME: ugly workaround (this can happen Gajim sent, Gaim recvs)
# this should never happen but it does. see process_result() in
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment