예제 #1
0
 private Element processPacket(Tag currentTag, int packetType)
     throws XmlPullParserException, IOException {
   Element element;
   switch (packetType) {
     case PACKET_IQ:
       element = new IqPacket();
       break;
     case PACKET_MESSAGE:
       element = new MessagePacket();
       break;
     case PACKET_PRESENCE:
       element = new PresencePacket();
       break;
     default:
       return null;
   }
   element.setAttributes(currentTag.getAttributes());
   Tag nextTag = tagReader.readTag();
   while (!nextTag.isEnd(element.getName())) {
     if (!nextTag.isNo()) {
       Element child = tagReader.readElement(nextTag);
       if ((packetType == PACKET_IQ) && ("jingle".equals(child.getName()))) {
         element = new JinglePacket();
         element.setAttributes(currentTag.getAttributes());
       }
       element.addChild(child);
     }
     nextTag = tagReader.readTag();
   }
   ++stanzasReceived;
   lastPaketReceived = SystemClock.elapsedRealtime();
   return element;
 }
예제 #2
0
 public Element asElement() {
   final Element item = new Element("item");
   item.setAttribute("jid", this.jid.toString());
   if (this.serverName != null) {
     item.setAttribute("name", this.serverName);
   }
   for (String group : getGroups()) {
     item.addChild("group").setContent(group);
   }
   return item;
 }
예제 #3
0
 private void sendCompressionZlib() throws IOException {
   Element compress = new Element("compress");
   compress.setAttribute("xmlns", "http://jabber.org/protocol/compress");
   compress.addChild("method").setContent("zlib");
   tagWriter.writeElement(compress);
 }