Search in sources :

Example 21 with NetworkException

use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.

the class OTRManager method initSmp.

/**
 * Initiate request using SM protocol.
 */
public void initSmp(AccountJid account, UserJid user, String question, String secret) throws NetworkException {
    LogManager.i(this, "initializing smp... " + user);
    removeSMRequest(account.toString(), user.toString());
    addSMProgress(account, user);
    try {
        getOrCreateSession(account.toString(), user.toString()).initSmp(question, secret);
    } catch (OtrException e) {
        throw new NetworkException(R.string.OTR_ERROR, e);
    }
}
Also used : OtrException(net.java.otr4j.OtrException) NetworkException(com.xabber.android.data.NetworkException)

Example 22 with NetworkException

use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.

the class OTRManager method respondSmp.

/**
 * Respond using SM protocol.
 */
public void respondSmp(AccountJid account, UserJid user, String question, String secret) throws NetworkException {
    LogManager.i(this, "responding smp... " + user);
    removeSMRequest(account, user);
    addSMProgress(account, user);
    try {
        getOrCreateSession(account.toString(), user.toString()).respondSmp(question, secret);
    } catch (OtrException e) {
        throw new NetworkException(R.string.OTR_ERROR, e);
    }
}
Also used : OtrException(net.java.otr4j.OtrException) NetworkException(com.xabber.android.data.NetworkException)

Example 23 with NetworkException

use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.

the class OTRManager method startSession.

public void startSession(AccountJid account, UserJid user) throws NetworkException {
    LogManager.i(this, "Starting session for " + user);
    try {
        getOrCreateSession(account.toString(), user.toString()).startSession();
    } catch (OtrException e) {
        throw new NetworkException(R.string.OTR_ERROR, e);
    }
    LogManager.i(this, "Started session for " + user);
}
Also used : OtrException(net.java.otr4j.OtrException) NetworkException(com.xabber.android.data.NetworkException)

Example 24 with NetworkException

use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.

the class SSNManager method sendFeature.

private void sendFeature(AccountJid account, Jid user, String session, Feature feature) {
    Message message = new Message(user, Message.Type.normal);
    message.setThread(session);
    message.addExtension(feature);
    try {
        StanzaSender.sendStanza(account, message);
    } catch (NetworkException e) {
        LogManager.exception(this, e);
    }
}
Also used : Message(org.jivesoftware.smack.packet.Message) NetworkException(com.xabber.android.data.NetworkException)

Example 25 with NetworkException

use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.

the class ChatActivity method onMenuItemClick.

@Override
public boolean onMenuItemClick(MenuItem item) {
    AbstractChat abstractChat = MessageManager.getInstance().getChat(account, user);
    switch(item.getItemId()) {
        case R.id.action_start_encryption:
            if (chatFragment != null)
                chatFragment.showResourceChoiceAlert(account, user, false);
            return true;
        case R.id.action_restart_encryption:
            if (chatFragment != null)
                chatFragment.showResourceChoiceAlert(account, user, true);
            return true;
        case R.id.action_stop_encryption:
            if (chatFragment != null)
                chatFragment.stopEncryption(account, user);
            return true;
        case R.id.action_verify_with_fingerprint:
            startActivity(FingerprintActivity.createIntent(this, account, user));
            return true;
        case R.id.action_verify_with_question:
            startActivity(QuestionActivity.createIntent(this, account, user, true, false, null));
            return true;
        case R.id.action_verify_with_shared_secret:
            startActivity(QuestionActivity.createIntent(this, account, user, false, false, null));
            return true;
        case R.id.action_send_contact:
            sendContact();
            return true;
        case R.id.action_view_contact:
            if (chatFragment != null)
                chatFragment.showContactInfo();
            return true;
        case R.id.action_configure_notifications:
            startActivity(CustomNotifySettings.createIntent(this, account, user));
            return true;
        case R.id.action_authorization_settings:
            startActivity(ConferenceAddActivity.createIntent(this, account, user.getBareUserJid()));
            return true;
        case R.id.action_clear_history:
            if (chatFragment != null)
                chatFragment.clearHistory(account, user);
            return true;
        case R.id.action_export_chat:
            if (chatFragment != null)
                chatFragment.onExportChatClick();
            return true;
        case R.id.action_call_attention:
            if (chatFragment != null)
                chatFragment.callAttention();
            return true;
        case R.id.action_block_contact:
            BlockContactDialog.newInstance(account, user).show(getFragmentManager(), BlockContactDialog.class.getName());
            return true;
        case R.id.action_request_subscription:
            try {
                PresenceManager.getInstance().requestSubscription(account, user);
            } catch (NetworkException e) {
                Application.getInstance().onError(e);
            }
            return true;
        case R.id.action_archive_chat:
            if (abstractChat != null)
                abstractChat.setArchived(true, true);
            return true;
        case R.id.action_unarchive_chat:
            if (abstractChat != null)
                abstractChat.setArchived(false, true);
            return true;
        case R.id.action_mute_chat:
            showSnoozeDialog(abstractChat);
            return true;
        case R.id.action_unmute_chat:
            if (abstractChat != null)
                abstractChat.setNotificationStateOrDefault(new NotificationState(NotificationState.NotificationMode.enabled, 0), true);
            onSnoozed();
            return true;
        case R.id.action_join_conference:
            onJoinConferenceClick();
            return true;
        case R.id.action_invite_to_chat:
            startActivity(ContactListActivity.createRoomInviteIntent(this, account, user.getBareUserJid()));
            return true;
        case R.id.action_leave_conference:
            if (chatFragment != null)
                chatFragment.leaveConference(account, user);
            return true;
        case R.id.action_show_archived:
            this.showArchived = !this.showArchived;
            if (recentChatFragment != null) {
                recentChatFragment.closeSnackbar();
                recentChatFragment.updateChats();
                Toast.makeText(this, this.showArchived ? R.string.toast_archived_show : R.string.toast_archived_hide, Toast.LENGTH_SHORT).show();
            }
            return true;
        case R.id.action_edit_alias:
            editAlias();
            return true;
        case R.id.action_edit_groups:
            startActivity(GroupEditActivity.createIntent(this, account, user));
            return true;
        case R.id.action_remove_contact:
            ContactDeleteDialogFragment.newInstance(account, user).show(getFragmentManager(), "CONTACT_DELETE");
            return true;
        case R.id.action_delete_conference:
            ContactDeleteDialogFragment.newInstance(account, user).show(getFragmentManager(), "CONTACT_DELETE");
            return true;
        default:
            return false;
    }
}
Also used : AbstractChat(com.xabber.android.data.message.AbstractChat) NetworkException(com.xabber.android.data.NetworkException) BlockContactDialog(com.xabber.android.ui.dialog.BlockContactDialog) NotificationState(com.xabber.android.data.message.NotificationState)

Aggregations

NetworkException (com.xabber.android.data.NetworkException)64 Message (org.jivesoftware.smack.packet.Message)13 AccountJid (com.xabber.android.data.entity.AccountJid)11 OtrException (net.java.otr4j.OtrException)11 AccountItem (com.xabber.android.data.account.AccountItem)10 AbstractChat (com.xabber.android.data.message.AbstractChat)10 OnResponseListener (com.xabber.android.data.connection.OnResponseListener)6 Date (java.util.Date)6 IQ (org.jivesoftware.smack.packet.IQ)6 UserJid (com.xabber.android.data.entity.UserJid)5 ArrayList (java.util.ArrayList)4 Presence (org.jivesoftware.smack.packet.Presence)4 Intent (android.content.Intent)3 Set (com.xabber.xmpp.rsm.Set)3 File (java.io.File)3 SmackException (org.jivesoftware.smack.SmackException)3 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)3 MessageItem (com.xabber.android.data.database.messagerealm.MessageItem)2 Captcha (com.xabber.android.data.extension.captcha.Captcha)2 RoomChat (com.xabber.android.data.extension.muc.RoomChat)2