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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
package de.thedevstack.conversationsplus.entities;
import de.thedevstack.conversationsplus.enums.FileStatus;
import eu.siacs.conversations.utils.MimeUtils;
/**
*
*/
public class FileParams {
private String name;
private String originalFilename;
private String path;
private String url;
private String mimeType;
private long size = 0;
private int width = 0;
private int height = 0;
private FileStatus fileStatus;
private byte[] aeskey;
private byte[] iv;
public FileParams() {
fileStatus = FileStatus.UNDEFINED;
}
public FileParams(String url) {
this();
this.url = url;
}
public FileParams(String url, long size) {
this(url);
this.size = size;
}
public FileParams(String url, long size, int width, int height) {
this(url, size);
this.width = width;
this.height = height;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public long getSize() {
return size;
}
public void setSize(long size) {
this.size = size;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path;
}
public void setKeyAndIv(byte[] keyIvCombo) {
if (null != keyIvCombo) {
if (keyIvCombo.length == 48) {
this.aeskey = new byte[32];
this.iv = new byte[16];
System.arraycopy(keyIvCombo, 0, this.iv, 0, 16);
System.arraycopy(keyIvCombo, 16, this.aeskey, 0, 32);
} else if (keyIvCombo.length >= 32) {
this.aeskey = new byte[32];
System.arraycopy(keyIvCombo, 0, aeskey, 0, 32);
} else if (keyIvCombo.length >= 16) {
this.aeskey = new byte[16];
System.arraycopy(keyIvCombo, 0, this.aeskey, 0, 16);
}
}
}
public void setKey(byte[] key) {
this.aeskey = key;
}
public void setIv(byte[] iv) {
this.iv = iv;
}
public byte[] getKey() {
return this.aeskey;
}
public byte[] getIv() {
return this.iv;
}
/**
* Sets the path to the file.
* If no file name is stored yet here - this method tries to extract the file name from the path.
* If the file name is stored here and the path does not end with the name - the name is appended to the path.
* @param path the path to be stored
*/
public void setPath(String path) {
if (null != path) {
if (null != this.name) {
path = (!path.endsWith(this.name)) ? path + "/" + this.name : path;
} else {
if (!path.endsWith("/")) {
this.setName(path.substring(path.lastIndexOf('/') + 1));
}
}
if (null == this.mimeType) {
int start = path.lastIndexOf('.') + 1;
if (start < path.length()) {
String extension = path.substring(start);
this.mimeType = MimeUtils.guessMimeTypeFromExtension(extension);
}
}
}
this.path = path;
}
public boolean isRemoteAvailable() {
return null != this.url || FileStatus.UPLOADED == this.fileStatus || FileStatus.DELETE_FAILED == this.fileStatus;
}
public void setFileStatus(FileStatus fileStatus) {
this.fileStatus = fileStatus;
}
public FileStatus getFileStatus() {
return this.fileStatus;
}
public void setOriginalFilename(String originalFilename) {
this.originalFilename = originalFilename;
}
public String getOriginalFilename() {
return this.originalFilename;
}
}
|