1 /*
2 * XNap - A P2P framework and client.
3 *
4 * See the file AUTHORS for copyright information.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 package org.xnap.plugin.opennap.net.msg.client;
21
22 import org.xnap.io.MP3MetaInfo;
23 import org.xnap.io.MetaInfoFile;
24 import org.xnap.plugin.opennap.util.OpenNapFileHelper;
25
26 public class DirectShareFileMessage extends ClientMessage
27 {
28
29 //--- Constant(s) ---
30
31 // FIX ME: should use 10300
32 public static final int TYPE = 100;
33
34
35 //--- Constructor(s) ---
36
37 public DirectShareFileMessage(int index, MetaInfoFile file)
38 {
39 super(TYPE);
40
41 StringBuffer sb = new StringBuffer();
42 sb.append("\"");
43 sb.append(OpenNapFileHelper.getShareString(index, file));
44 sb.append("\" ");
45 // do not calculate md5, send 0 instead
46 sb.append("0 ");
47 sb.append(file.length());
48
49 if (MP3MetaInfo.hasInfo(file)) {
50 MP3MetaInfo m = new MP3MetaInfo(file);
51 sb.append(" ");
52 sb.append(m.getBitrate());
53 sb.append(" ");
54 sb.append(m.getFrequency());
55 sb.append(" ");
56 sb.append(m.getPlayingTime());
57 }
58 else {
59 sb.append(" 24 16000 600");
60 }
61
62 data = sb.toString();
63 }
64
65 }