1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.overnet.net.msg.core;
21
22 import java.nio.ByteBuffer;
23 import java.util.*;
24
25 import org.apache.log4j.Logger;
26 import org.xnap.plugin.overnet.util.OvernetPreferences;
27
28 public class NewDownloadMessage extends OvernetCoreMessage
29 {
30
31
32 public static final byte TYPE = (byte)188;
33
34 public static final byte PRIORITY_LOW = 0;
35 public static final byte PRIORITY_NORMAL = 1;
36 public static final byte PRIORITY_HIGH = 2;
37 public static final byte PRIORITY_HIGHEST = 3;
38
39
40
41 public String filename;
42 public int filesize;
43 public byte[] hash = new byte[16];
44 /***
45 * Holds the priority whith which the file should be downloaded.
46 *
47 * <pre>
48 * 0, low
49 * 1, normal
50 * 2, high
51 * 3, highest
52 * </pre>
53 */
54 public byte priority;
55 public int id = 0;
56
57 public Tags tags;
58
59 private static Logger logger = Logger.getLogger(NewDownloadMessage.class);
60
61
62
63 public NewDownloadMessage(ByteBuffer buffer)
64 {
65 super(TYPE, buffer);
66 get(hash);
67 skip(6);
68 tags = readTags();
69 filename = tags.getShortName();
70 filesize = tags.getSize();
71
72 for (Iterator i = tags.iterator(); i.hasNext();) {
73 logger.debug(i.next());
74 }
75 priority = get();
76
77 logger.debug("priority : " + priority);
78
79 if (remaining() > 0) {
80
81
82
83
84
85
86
87
88
89
90 String tmpFileName = getString();
91 logger.debug("tmp filename " + tmpFileName);
92 }
93 if (remaining() >= 4) {
94 OvernetPreferences.getInstance().setNewDownloadID(true);
95 id = getInt();
96 logger.debug("new dl: " + filename + " with id " + id);
97 }
98 else {
99 OvernetPreferences.getInstance().setNewDownloadID(false);
100 }
101 }
102
103
104 }