aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol/jabber/IncomingFileTransferJabberImpl.java
blob: b0adf2860634168f38a4c8849a4ecddd8ae48a13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.impl.protocol.jabber;

import java.io.*;

import org.jivesoftware.smackx.filetransfer.*;

import net.java.sip.communicator.service.protocol.*;

/**
 * The Jabber protocol extension of the <tt>AbstractFileTransfer</tt>.
 * 
 * @author Yana Stamcheva
 */
public class IncomingFileTransferJabberImpl
    extends AbstractFileTransfer
{
    private Contact sender = null;
    private File file = null;

    /**
     * The jabber incoming file transfer.
     */
    private IncomingFileTransfer jabberTransfer;

    public IncomingFileTransferJabberImpl(Contact sender,
        File file,
        IncomingFileTransfer jabberTransfer)
    {
        this.jabberTransfer = jabberTransfer;
        this.sender = sender;
        this.file = file;
    }

    /**
     * Cancels the file transfer.
     */
    public void cancel()
    {
        this.jabberTransfer.cancel();
    }

    /**
     * Returns the number of bytes already received from the recipient.
     * 
     * @return the number of bytes already received from the recipient.
     */
    public long getTransferedBytes()
    {
        return jabberTransfer.getAmountWritten();
    }

    /**
     * The direction is incoming.
     * @return IN.
     */
    public int getDirection()
    {
        return IN;
    }

    /**
     * The file we are receiving.
     * @return the file.
     */
    public File getFile()
    {
        return file;
    }

    public Contact getContact()
    {
        return sender;
    }
}