}
public Boolean sendDestroy(Protocol protocol, int position) throws DespotifyException {
ChannelCallback callback = new ChannelCallback();
/* Create channel and buffer. */
Channel channel = new Channel("Create-Playlist-Channel", Channel.Type.TYPE_PLAYLIST, callback);
PlaylistContainer playlists = user.getPlaylists();
String xml = String.format
("<change><ops><destroy/></ops><time>%s</time><user>%s</user></change>" +
"<version>%010d,%010d,%010d,%d</version>",
new Date().getTime() / 1000,
user.getId(),
// version
playlist.getRevision() + 1,
playlist.getTracks().size(),
playlist.getChecksum(),
playlist.isCollaborative() ? 1 : 0
);
byte[] xmlBytes = xml.getBytes();
ByteBuffer buffer = ByteBuffer.allocate(2 + 16 + 1 + 4 + 4 + 4 + 1 + 1 + xmlBytes.length);
// 3600bd00000000 000000000000000000 000000000000 00000426 0000001a a63f [6????????????????????????&??????]
// d3a7 00 03 3c636861 6e67653e3c6f7073 3e3c64656c3e3c69 3e32313c2f693e3c [????<change><ops><del><i>21</i><]
buffer.putShort((short) channel.getId());
buffer.put(playlist.getByteUUID());
buffer.put((byte) 0x02); // playlist type UUID tag
buffer.putInt((int) playlist.getRevision().longValue());
buffer.putInt(playlist.getTracks().size());
buffer.putInt((int) playlists.getChecksum());
buffer.put((byte) (playlist.isCollaborative() ? 0x01 : 0x00));
buffer.put((byte) 0x03); // unknown
buffer.put(xmlBytes);
buffer.flip();
/* Register channel. */
Channel.register(channel);
/* Send packet. */
protocol.sendPacket(PacketType.changePlaylist, buffer, "destroy playlist");
/* Get response. */
byte[] data = callback.getData("destroy playlist response");
xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<playlists>\n" +
new String(data, Charset.forName("UTF-8")) +
"\n</playlists>";