Exemplo n.º 1
0
    def send_file(self, account, contact, file_path, file_desc=''):
        """
        Start the real transfer(upload) of the file
        """
        if gtkgui_helpers.file_is_locked(file_path):
            pritext = _('Gajim cannot access this file')
            sextext = _('This file is being used by another process.')
            dialogs.ErrorDialog(pritext, sextext)
            return

        if isinstance(contact, str):
            if contact.find('/') == -1:
                return
            (jid, resource) = contact.split('/', 1)
            contact = gajim.contacts.create_contact(jid=jid, account=account,
                resource=resource)
        file_name = os.path.split(file_path)[1]
        file_props = self.get_send_file_props(account, contact,
                        file_path, file_name, file_desc)
        if file_props is None:
            return False
        if contact.supports(NS_JINGLE_FILE_TRANSFER):
            log.info("contact %s supports jingle file transfer"%(contact.get_full_jid()))
            gajim.connections[account].start_file_transfer(contact.get_full_jid(),
                                                           file_props)
            self.add_transfer(account, contact, file_props)
        else:
            log.info("contact does not support jingle file transfer")
            gajim.connections[account].send_file_request(file_props)
            self.add_transfer(account, contact, file_props)
        return True
Exemplo n.º 2
0
    def send_file(self, account, contact, file_path, file_desc=''):
        """
        Start the real transfer(upload) of the file
        """
        if gtkgui_helpers.file_is_locked(file_path):
            pritext = _('Gajim can not read this file')
            sextext = _('Another process is using this file.')
            dialogs.ErrorDialog(pritext, sextext)
            return

        if isinstance(contact, str):
            if contact.find('/') == -1:
                return
            (jid, resource) = contact.split('/', 1)
            contact = gajim.contacts.create_contact(jid=jid, account=account,
                resource=resource)
        file_name = os.path.split(file_path)[1]
        file_props = self.get_send_file_props(account, contact,
                        file_path, file_name, file_desc)
        if file_props is None:
            return False
        if contact.supports(NS_JINGLE_FILE_TRANSFER):
            log.info("contact %s supports jingle file transfer"%(contact.get_full_jid()))
            gajim.connections[account].start_file_transfer(contact.get_full_jid(),
                                                           file_props)
            self.add_transfer(account, contact, file_props)
        else:
            log.info("contact does not support jingle file transfer")
            gajim.connections[account].send_file_request(file_props)
            self.add_transfer(account, contact, file_props)
        return True
Exemplo n.º 3
0
	def send_file(self, account, contact, file_path):
		''' start the real transfer(upload) of the file '''
		if gtkgui_helpers.file_is_locked(file_path):
			pritext = _('Gajim cannot access this file')
			sextext = _('This file is being used by another process.')
			dialogs.ErrorDialog(pritext, sextext).get_response()
			return
		
		if isinstance(contact, str):
			if contact.find('/') == -1:
				return
			(jid, resource) = contact.split('/', 1)
			contact = gajim.Contact(jid = jid, resource = resource)
		(file_dir, file_name) = os.path.split(file_path)
		file_props = self.get_send_file_props(account, contact, 
				file_path, file_name)
		if file_props is None:
			return False
		self.add_transfer(account, contact, file_props)
		gajim.connections[account].send_file_request(file_props)
		return True
Exemplo n.º 4
0
	def send_file(self, account, contact, file_path, file_desc=''):
		''' start the real transfer(upload) of the file '''
		if gtkgui_helpers.file_is_locked(file_path):
			pritext = _('Gajim cannot access this file')
			sextext = _('This file is being used by another process.')
			dialogs.ErrorDialog(pritext, sextext)
			return

		if isinstance(contact, str):
			if contact.find('/') == -1:
				return
			(jid, resource) = contact.split('/', 1)
			contact = gajim.contacts.create_contact(jid=jid, resource=resource)
		(file_dir, file_name) = os.path.split(file_path)
		file_props = self.get_send_file_props(account, contact, 
				file_path, file_name, file_desc)
		if file_props is None:
			return False
		self.add_transfer(account, contact, file_props)
		gajim.connections[account].send_file_request(file_props)
		return True