private void sendStartStream() throws IOException {
   Tag stream = Tag.start("stream:stream");
   stream.setAttribute("from", account.getJid());
   stream.setAttribute("to", account.getServer());
   stream.setAttribute("version", "1.0");
   stream.setAttribute("xml:lang", "en");
   stream.setAttribute("xmlns", "jabber:client");
   stream.setAttribute("xmlns:stream", "http://etherx.jabber.org/streams");
   tagWriter.writeTag(stream);
 }
 public void disconnect(boolean force) {
   changeStatus(Account.STATUS_OFFLINE);
   Log.d(LOGTAG, "disconnecting");
   try {
     if (force) {
       socket.close();
       return;
     }
     if (tagWriter.isActive()) {
       tagWriter.finish();
       while (!tagWriter.finished()) {
         // Log.d(LOGTAG,"not yet finished");
         Thread.sleep(100);
       }
       tagWriter.writeTag(Tag.end("stream:stream"));
     }
   } catch (IOException e) {
     Log.d(LOGTAG, "io exception during disconnect");
   } catch (InterruptedException e) {
     Log.d(LOGTAG, "interupted while waiting for disconnect");
   }
 }
 private void sendStartTLS() throws IOException {
   Tag startTLS = Tag.empty("starttls");
   startTLS.setAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-tls");
   tagWriter.writeTag(startTLS);
 }