src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java
/**
     * Sends the given file through the currently selected chat transport by
     * using the given fileComponent to visualize the transfer process in the
     * chat conversation panel.
     *
     * @param file the file to send
     * @param fileComponent the file component to use for visualization
     */
Sends the given file through the currently selected chat transport by
using the given fileComponent to visualize the transfer process in the
chat conversation panel.

@param file the file to send
@param fileComponent the file component to use for visualization
Sends the given file through the currently selected chat transport by using the given fileComponent to visualize the transfer process in the chat conversation panel . @param file the file to send @param fileComponent the file component to use for visualization
public void sendFile(   final File file,
                            final SendFileConversationComponent fileComponent)
    {
        final ChatTransport sendFileTransport
            = this.findFileTransferChatTransport();
        this.setSelectedChatTransport(sendFileTransport, true);
        if(file.length() > sendFileTransport.getMaximumFileLength())
        {
            addMessage(
                chatSession.getCurrentChatTransport().getName(),
                new Date(),
                Chat.ERROR_MESSAGE,
                GuiActivator.getResources()
                    .getI18NString("service.gui.FILE_TOO_BIG",
                    new String[]{
                        sendFileTransport.getMaximumFileLength()/1024/1024
                        + " MB"}),
                "",
                "text");
            fileComponent.setFailed();
            return;
        }
        SwingWorker worker = new SwingWorker()
        {
            @Override
            public Object construct()
                throws Exception
            {
                FileTransfer ft;
                if (writeMessagePanel.isSmsSelected())
                    ft = sendFileTransport.sendMultimediaFile(file);
                else
                    ft = sendFileTransport.sendFile(file);
                final FileTransfer fileTransfer = ft;
                addActiveFileTransfer(fileTransfer.getID(), fileTransfer);
                fileTransfer.addStatusListener(ChatPanel.this);
                fileComponent.setProtocolFileTransfer(fileTransfer);
                return "";
            }
            @Override
            public void catchException(Throwable ex)
            {
                logger.error("Failed to send file.", ex);
                if (ex instanceof IllegalStateException)
                {
                    addErrorMessage(
                        chatSession.getCurrentChatTransport().getName(),
                        GuiActivator.getResources().getI18NString(
                            "service.gui.MSG_SEND_CONNECTION_PROBLEM"));
                }
                else
                {
                    addErrorMessage(
                        chatSession.getCurrentChatTransport().getName(),
                        GuiActivator.getResources().getI18NString(
                            "service.gui.MSG_DELIVERY_ERROR",
                            new String[]{ex.getMessage()}));
                }
            }
        };
        worker.start();
    }
public void sendFile ( final File file , final SendFileConversationComponent fileComponent ) { final ChatTransport sendFileTransport = this . findFileTransferChatTransport ( ) ; this . setSelectedChatTransport ( sendFileTransport , true ) ; if ( file . length ( ) > sendFileTransport . getMaximumFileLength ( ) ) { addMessage ( chatSession . getCurrentChatTransport ( ) . getName ( ) , new Date ( ) , Chat . ERROR_MESSAGE , GuiActivator . getResources ( ) . getI18NString ( "service.gui.FILE_TOO_BIG" , new String [ ] { sendFileTransport . getMaximumFileLength ( ) / 1024 / 1024 + " MB" } ) , "" , "text" ) ; fileComponent . setFailed ( ) ; return ; } SwingWorker worker = new SwingWorker ( ) { @ Override public Object construct ( ) throws Exception { FileTransfer ft ; if ( writeMessagePanel . isSmsSelected ( ) ) ft = sendFileTransport . sendMultimediaFile ( file ) ; else ft = sendFileTransport . sendFile ( file ) ; final FileTransfer fileTransfer = ft ; addActiveFileTransfer ( fileTransfer . getID ( ) , fileTransfer ) ; fileTransfer . addStatusListener ( ChatPanel . this ) ; fileComponent . setProtocolFileTransfer ( fileTransfer ) ; return "" ; } @ Override public void catchException ( Throwable ex ) { logger . error ( "Failed to send file." , ex ) ; if ( ex instanceof IllegalStateException ) { addErrorMessage ( chatSession . getCurrentChatTransport ( ) . getName ( ) , GuiActivator . getResources ( ) . getI18NString ( "service.gui.MSG_SEND_CONNECTION_PROBLEM" ) ) ; } else { addErrorMessage ( chatSession . getCurrentChatTransport ( ) . getName ( ) , GuiActivator . getResources ( ) . getI18NString ( "service.gui.MSG_DELIVERY_ERROR" , new String [ ] { ex . getMessage ( ) } ) ) ; } } } ; worker . start ( ) ; }
Sends the given file through the currently selected chat transport by
 using the given fileComponent to visualize the transfer process in the
 chat conversation panel.
Sends the given file through the currently selected chat transport by using the given fileComponent to visualize the transfer process in the chat conversation panel .
// Add the status listener that would notify us when the file // transfer has been completed and should be removed from // active components.