Search in sources :

Example 46 with SmackException

use of org.jivesoftware.smack.SmackException in project xabber-android by redsolution.

the class AccountInfoEditorFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    account = args.getString(ARGUMENT_ACCOUNT, null);
    String vCardString = args.getString(ARGUMENT_VCARD, null);
    if (vCardString != null) {
        try {
            vCard = ContactVcardViewerFragment.parseVCard(vCardString);
        } catch (XmlPullParserException | IOException | SmackException e) {
            LogManager.exception(this, e);
        }
    }
    if (savedInstanceState != null) {
        final String avatarImageUriString = savedInstanceState.getString(SAVE_NEW_AVATAR_IMAGE_URI);
        if (avatarImageUriString != null) {
            newAvatarImageUri = Uri.parse(avatarImageUriString);
        }
        final String photoFileUriString = savedInstanceState.getString(SAVE_PHOTO_FILE_URI);
        if (photoFileUriString != null) {
            photoFileUri = Uri.parse(photoFileUriString);
        }
        removeAvatarFlag = savedInstanceState.getBoolean(SAVE_REMOVE_AVATAR_FLAG);
    }
}
Also used : Bundle(android.os.Bundle) SmackException(org.jivesoftware.smack.SmackException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

Example 47 with SmackException

use of org.jivesoftware.smack.SmackException in project xabber-android by redsolution.

the class ForwardedProvider method parse.

@Override
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
    DelayInformationProvider delayInformationProvider = new DelayInformationProvider();
    DelayInformation delayInformation = null;
    Stanza packet = null;
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("delay"))
                delayInformation = delayInformationProvider.parse(parser);
            else if (parser.getName().equals("message"))
                packet = PacketParserUtils.parseMessage(parser);
            else
                throw new SmackException("Unsupported forwarded packet type: " + parser.getName());
        } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(Forwarded.ELEMENT_NAME))
            done = true;
    }
    if (packet == null)
        throw new SmackException("forwarded extension must contain a packet");
    return new Forwarded(delayInformation, packet);
}
Also used : DelayInformation(org.jivesoftware.smackx.delay.packet.DelayInformation) Stanza(org.jivesoftware.smack.packet.Stanza) SmackException(org.jivesoftware.smack.SmackException) DelayInformationProvider(org.jivesoftware.smackx.delay.provider.DelayInformationProvider)

Example 48 with SmackException

use of org.jivesoftware.smack.SmackException in project xabber-android by redsolution.

the class AccountViewer method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode != ACCOUNT_INFO_EDITOR_REQUEST_CODE) {
        return;
    }
    final ContactVcardViewerFragment contactVcardViewerFragment = (ContactVcardViewerFragment) getFragmentManager().findFragmentById(R.id.scrollable_container);
    if (resultCode == AccountInfoEditorFragment.REQUEST_NEED_VCARD) {
        contactVcardViewerFragment.requestVCard();
    }
    if (resultCode == RESULT_OK) {
        String vCardXml = data.getStringExtra(AccountInfoEditorFragment.ARGUMENT_VCARD);
        VCard vCard = null;
        if (vCardXml != null) {
            try {
                vCard = ContactVcardViewerFragment.parseVCard(vCardXml);
            } catch (XmlPullParserException | IOException | SmackException e) {
                e.printStackTrace();
            }
        }
        if (vCard != null) {
            vCard.getField(VCardProperty.NICKNAME.name());
            contactVcardViewerFragment.onVCardReceived(account, Jid.getBareAddress(account), vCard);
        } else {
            contactVcardViewerFragment.requestVCard();
        }
    }
}
Also used : SmackException(org.jivesoftware.smack.SmackException) ContactVcardViewerFragment(com.xabber.android.ui.fragment.ContactVcardViewerFragment) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) VCard(org.jivesoftware.smackx.vcardtemp.packet.VCard)

Aggregations

SmackException (org.jivesoftware.smack.SmackException)48 IOException (java.io.IOException)20 XMPPException (org.jivesoftware.smack.XMPPException)13 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)10 Test (org.junit.Test)9 Socket (java.net.Socket)8 StreamHost (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost)6 FeatureNotSupportedException (org.jivesoftware.smack.SmackException.FeatureNotSupportedException)5 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)5 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)5 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)5 DataInputStream (java.io.DataInputStream)4 DataOutputStream (java.io.DataOutputStream)4 ConnectException (java.net.ConnectException)4 DiscoverItems (org.jivesoftware.smackx.disco.packet.DiscoverItems)4 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)4 InputStream (java.io.InputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 ServerSocket (java.net.ServerSocket)3 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)3