Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow activities to pass file transfers without shell notification #621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/jarabe/model/filetransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ def _new_channels_cb(connection, channels):
if props[CHANNEL + '.ChannelType'] == CHANNEL_TYPE_FILE_TRANSFER and \
not props[CHANNEL + '.Requested']:

mime = props[CHANNEL_TYPE_FILE_TRANSFER + '.ContentType']
if mime == 'x-sugar/from-activity':
continue

logging.debug('__new_channels_cb %r', object_path)

incoming_file_transfer = IncomingFileTransfer(connection,
Expand Down Expand Up @@ -287,11 +291,20 @@ def _got_dispatch_operation_cb(**kwargs):
channel_type = channel_properties[CHANNEL + '.ChannelType']
handle_type = channel_properties[CHANNEL + '.TargetHandleType']

if handle_type == CONNECTION_HANDLE_TYPE_CONTACT and \
channel_type == CHANNEL_TYPE_FILE_TRANSFER:
if handle_type != CONNECTION_HANDLE_TYPE_CONTACT or \
channel_type != CHANNEL_TYPE_FILE_TRANSFER:
return

mime_type = channel_properties[CHANNEL_TYPE_FILE_TRANSFER + '.ContentType']
filename = channel_properties[CHANNEL_TYPE_FILE_TRANSFER + '.Filename']

bus = dbus.Bus()
operation = bus.get_object(CHANNEL_DISPATCHER, dispatch_operation_path)
if mime_type == 'x-sugar/from-activity':
# The requested activity client is in the file name
operation.HandleWith(str(filename))
else:
# We must claim our file transfers so that empathy doesn't get it
bus = dbus.Bus()
operation = bus.get_object(CHANNEL_DISPATCHER, dispatch_operation_path)
operation.Claim()


Expand Down