private boolean parseMtdt(BoxHeader header) { // if mCurrentBoxSequence contains trak, then add metadata to current // track // else metadata is for file // we're currently not interested in anything on track level try { int numberOfUnits = mDataSource.readShort(); mHmmpTitles = new ArrayList<>(1); ArrayDeque<String> titleLanguages = new ArrayDeque<>(1); ArrayDeque<String> iconLanguages = new ArrayDeque<>(1); for (int i = 0; i < numberOfUnits; i++) { short dataUnitSize = mDataSource.readShort(); int dataTypeID = mDataSource.readInt(); short language = mDataSource.readShort(); char l1 = Character.toChars(((language >> 10) & 0x1F) + 96)[0]; char l2 = Character.toChars(((language >> 5) & 0x1F) + 96)[0]; char l3 = Character.toChars(((language) & 0x1F) + 96)[0]; String languageString = "" + l1 + l2 + l3; short encodingType = mDataSource.readShort(); if (encodingType == 0x01) { byte[] metadata = new byte[dataUnitSize - 10]; mDataSource.read(metadata); String metadataString = new String(metadata, "UTF-16BE").trim(); if ((dataTypeID & 0xFFFF) == 0x01) { mHmmpTitles.add(metadataString); titleLanguages.add(languageString); } } else if (encodingType == 0x101) { if (dataTypeID == 0xA04) { if (mIconList == null) { mIconList = new ArrayList<>(); } mDataSource.skipBytes(4); // selectionFlags mDataSource.skipBytes(4); // reserved int artworkCount = mDataSource.readInt(); for (int j = 0; j < artworkCount; j++) { IconInfo iconInfo = new IconInfo(); iconInfo.mtsmId = mDataSource.readInt(); iconInfo.mdstIndex = mDataSource.readInt(); iconInfo.languageIndex = iconLanguages.size(); mDataSource.skipBytes(4); mIconList.add(iconInfo); } iconLanguages.add(languageString); } } } addMetaDataValue(KEY_HMMP_TITLE_LANGUAGES, titleLanguages.toArray()); addMetaDataValue(KEY_HMMP_ICON_LANGUAGES, iconLanguages.toArray()); } catch (EOFException e) { if (LOGS_ENABLED) Log.e(TAG, "Exception while reading from 'MTDT' box", e); return false; } catch (IOException e) { if (LOGS_ENABLED) Log.e(TAG, "Exception while reading from 'MTDT' box", e); return false; } return true; }
@Test public void testRecipientEnabledFor2Resources2Presences() throws TigaseStringprepException, NotAuthorizedException { String recipient = "recipient-1@localhost"; JID recp1 = JID.jidInstanceNS(recipient + "/res1"); JID recp2 = JID.jidInstanceNS(recipient + "/res2"); JID connId1 = JID.jidInstanceNS("c2s@localhost/recipient1-res1"); JID connId2 = JID.jidInstanceNS("c2s@localhost/recipient1-res2"); XMPPResourceConnection session1 = getSession(connId1, recp1); getSession(connId2, recp2); enableMobileV3(session1, recp1); Packet presence = Packet.packetInstance( "presence", "sender-1@localhost/res1", recp1.toString(), StanzaType.available); presence.setPacketTo(connId1); ArrayDeque<Packet> results = new ArrayDeque<Packet>(); results.offer(presence); Packet[] expected = new Packet[0]; // results.toArray(new Packet[0]); mobileV3.filter(presence, session1, null, results); Packet[] processed = results.toArray(new Packet[0]); Assert.assertArrayEquals(expected, processed); presence = Packet.packetInstance( "presence", "sender-1@localhost/res1", recp1.toString(), StanzaType.available); presence.setPacketTo(connId1); results = new ArrayDeque<Packet>(); results.offer(presence); expected = new Packet[0]; // results.toArray(new Packet[0]); mobileV3.filter(presence, session1, null, results); processed = results.toArray(new Packet[0]); Assert.assertArrayEquals(expected, processed); results.clear(); Packet p = Packet.packetInstance( "message", "sender-1@localhost/res1", recp1.toString(), StanzaType.chat); p.setPacketTo(connId1); results.offer(p); Packet p1 = Packet.packetInstance( "presence", "sender-1@localhost/res1", recp1.toString(), StanzaType.error); p1.setPacketTo(connId1); results.offer(p1); expected = new Packet[] {presence, p, p1}; mobileV3.filter(p, session1, null, results); processed = results.toArray(new Packet[0]); Assert.assertArrayEquals(expected, processed); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; VersionStack that = (VersionStack) o; return Arrays.equals(versions.toArray(), that.versions.toArray()); }
private void createPath() { this.isFinished = true; this.isPathFound = true; this.isRunning = false; Node curr = this.goal; // create path ArrayDeque<Node> foundPath = new ArrayDeque<>(); foundPath.addFirst(curr); while (parentMap.containsKey(curr)) { curr = parentMap.get(curr); foundPath.addFirst(curr); } path = new Path(foundPath.toArray(new Node[0])); }
private void appendMessage(CompatibilityMessage.Impact impact, String format, Object... args) { CompatibilityMessage message = new CompatibilityMessage(_path.toArray(), impact, format, args); _result._messages.add(message); }
@SuppressWarnings({"unchecked"}) private void endLocationPath(int scope, ArrayDeque steps) { LocationPath path = new LocationPath(scope, steps.size()); steps.toArray(path.steps); push(LocationPathAnalyzer.simplify(path)); }
@Test public void testRecipientEnabledFor2ResourcesMixed() throws TigaseStringprepException, NotAuthorizedException { String recipient = "recipient-1@localhost"; JID recp1 = JID.jidInstanceNS(recipient + "/res1"); JID recp2 = JID.jidInstanceNS(recipient + "/res2"); JID connId1 = JID.jidInstanceNS("c2s@localhost/recipient1-res1"); JID connId2 = JID.jidInstanceNS("c2s@localhost/recipient1-res2"); XMPPResourceConnection session1 = getSession(connId1, recp1); getSession(connId2, recp2); enableMobileV3(session1, recp1); Packet presence = Packet.packetInstance( "presence", "sender-1@localhost/res1", recp1.toString(), StanzaType.available); presence.setPacketTo(connId1); ArrayDeque<Packet> results = new ArrayDeque<Packet>(); results.offer(presence); Packet[] expected = new Packet[0]; // results.toArray(new Packet[0]); mobileV3.filter(presence, session1, null, results); Packet[] processed = results.toArray(new Packet[0]); Assert.assertArrayEquals(expected, processed); results.clear(); Packet m1 = Packet.packetInstance("message", recp2.toString(), recp1.toString(), StanzaType.chat); Element receivedEl = new Element("received", new String[] {"xmlns"}, new String[] {"urn:xmpp:carbons:2"}); Element forwardedEl = new Element("forwarded", new String[] {"xmlns"}, new String[] {"urn:xmpp:forward:0"}); forwardedEl.addChild( new Element( "message", new String[] {"from", "to"}, new String[] {recp2.toString(), "sender-1@localhost/res1"})); receivedEl.addChild(forwardedEl); m1.getElement().addChild(receivedEl); m1.setPacketTo(connId1); results.offer(m1); expected = new Packet[0]; mobileV3.filter(m1, session1, null, results); processed = results.toArray(new Packet[0]); Assert.assertArrayEquals(expected, processed); results.clear(); presence = Packet.packetInstance( "presence", "sender-1@localhost/res1", recp1.toString(), StanzaType.available); presence.setPacketTo(connId1); results.offer(presence); expected = new Packet[0]; // results.toArray(new Packet[0]); mobileV3.filter(presence, session1, null, results); processed = results.toArray(new Packet[0]); Assert.assertArrayEquals(expected, processed); results.clear(); Packet p = Packet.packetInstance( "message", "sender-1@localhost/res1", recp1.toString(), StanzaType.chat); p.setPacketTo(connId1); results.offer(p); Packet p1 = Packet.packetInstance( "presence", "sender-1@localhost/res1", recp1.toString(), StanzaType.error); p1.setPacketTo(connId1); results.offer(p1); expected = new Packet[] {presence, m1, p, p1}; mobileV3.filter(p, session1, null, results); processed = results.toArray(new Packet[0]); Assert.assertArrayEquals(expected, processed); }