summaryrefslogtreecommitdiffstats
blob: e12b07de95ed4018cd35e7fdfb6499933b076bea (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
/*
 * Copyright (c) 2011 Tobias Markmann
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */
/*
 * Copyright (c) 2013-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */
/*
 * Copyright (c) 2015 Tarun Gupta.
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

package com.isode.stroke.filetransfer;

import com.isode.stroke.signals.Signal1;

/**
 * Because of the lack of multiple inheritance in Java, this has to be done
 * slightly differently from Swiften. What happens is that the methods in Swiften
 * are provided abstract here. Any class implementing this interface directly/indirectly (through other interface) has to implement these methods.
 * OutgoingJingleFileTransfer implements this interface indirectly through OutgoingFileTransfer.
 * IncomingJingleFileTransfer implements this interface indirectly through IncomingFileTransfer.
 * OutgoingSIFileTransfer implements this interface indirectly through OutgoingFileTransfer.
 */
public interface FileTransfer {

	public static class State {
		public enum Type {
			Initial,
			WaitingForStart,
			Negotiating,
			WaitingForAccept,
			Transferring,
			Canceled,
			Failed,
			Finished
		};

		public State(Type type) {
			this(type, "");
		}

		public State(Type type, final String message) {
			this.type = type;
			this.message = message;
		}

		public Type type;
		public String message = "";
	};

	public final Signal1<Integer /* proccessedBytes */> onProcessedBytes = new Signal1<Integer>();
	public final Signal1<State> onStateChanged = new Signal1<State>();
	public final Signal1<FileTransferError> onFinished = new Signal1<FileTransferError>();

	public void cancel();

	public String getFileName();

	public long getFileSizeInBytes();

	public void setFileInfo(final String name, long size);
	
	public State getState();
	
}