# The group of contacts for whom you receive presence
'subscribe': AllContactsListChannel,
# The group of contacts who may receive your presence
- 'publish': AllContactsListChannel,
+ 'publish': None,
# A group of contacts who are on the publish list but are temporarily
# disallowed from receiving your presence
# This doesn't make sense to support
'deny': DenyContactsListChannel,
# On protocols where the user's contacts are stored, this contact list
# contains all stored contacts regardless of subscription status.
- 'stored': AllContactsListChannel,
+ 'stored': None,
}
'State': self.get_state,
"ContentType": self.get_content_type,
"Filename": self.get_filename,
- "Size": self.get_state,
+ "Size": self.get_size,
"Description": self.get_description,
"AvailableSocketTypes": self.get_available_socket_types,
"TransferredBytes": self.get_transferred_bytes,
"InitialOffset": self.get_initial_offset,
},
)
+ self._add_immutables({
+ 'Filename': dbus_interface,
+ 'Size': dbus_interface,
+ })
# grab a snapshot of the log so that we are always in a consistent
# state between calls
self._log = "".join(logLines)
self._transferredBytes = 0
- self._state = telepathy.constants.FILE_TRANSFER_STATE_PENDING
- self.FileTransferStateChanged(
- self._state,
- telepathy.constants.FILE_TRANSFER_STATE_CHANGE_REASON_NONE,
+ self._state = 0
+ self.set_state(
+ telepathy.constants.FILE_TRANSFER_STATE_PENDING,
+ telepathy.constants.FILE_TRANSFER_STATE_CHANGE_REASON_REQUESTED,
)
def get_state(self):
return self._state
+ def set_state(self, state, reason):
+ if self._state == state:
+ return
+ self._state = state
+
+ self.FileTransferStateChanged(
+ self._state,
+ reason,
+ )
+
def get_content_type(self):
return "application/octet-stream"
def close(self):
_moduleLogger.debug("Closing log")
+ if self._state != telepathy.FILE_TRANSFER_STATE_COMPLETED:
+ self.set_state(
+ telepathy.FILE_TRANSFER_STATE_CANCELLED,
+ telepathy.FILE_TRANSFER_STATE_CHANGE_REASON_LOCAL_STOPPED
+ )
+
if self.__socket is not None:
self.__socket.close()
+
tp.ChannelTypeFileTransfer.Close(self)
self.remove_from_connection()
subscribeHandle = self.get_handle_by_name(telepathy.HANDLE_TYPE_LIST, "subscribe")
subscribeProps = self.generate_props(telepathy.CHANNEL_TYPE_CONTACT_LIST, subscribeHandle, False)
self.__channelManager.channel_for_props(subscribeProps, signal=True)
- publishHandle = self.get_handle_by_name(telepathy.HANDLE_TYPE_LIST, "publish")
- publishProps = self.generate_props(telepathy.CHANNEL_TYPE_CONTACT_LIST, publishHandle, False)
- self.__channelManager.channel_for_props(publishProps, signal=True)
except Exception:
_moduleLogger.exception("Setup failed")
self.disconnect(telepathy.CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED)