Search in sources :

Example 66 with Account

use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method switchToForeground.

private void switchToForeground() {
    final boolean broadcastLastActivity = broadcastLastActivity();
    for (Conversation conversation : getConversations()) {
        if (conversation.getMode() == Conversation.MODE_MULTI) {
            conversation.getMucOptions().resetChatState();
        } else {
            conversation.setIncomingChatState(Config.DEFAULT_CHATSTATE);
        }
    }
    for (Account account : getAccounts()) {
        if (account.getStatus() == Account.State.ONLINE) {
            account.deactivateGracePeriod();
            final XmppConnection connection = account.getXmppConnection();
            if (connection != null) {
                if (connection.getFeatures().csi()) {
                    connection.sendActive();
                }
                if (broadcastLastActivity) {
                    // send new presence but don't include idle because we are not
                    sendPresence(account, false);
                }
            }
        }
    }
    Log.d(Config.LOGTAG, "app switched into foreground");
}
Also used : XmppConnection(de.pixart.messenger.xmpp.XmppConnection) Account(de.pixart.messenger.entities.Account) Conversation(de.pixart.messenger.entities.Conversation)

Example 67 with Account

use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.

the class ShareViaAccountActivity method onBackendConnected.

@Override
void onBackendConnected() {
    final int numAccounts = xmppConnectionService.getAccounts().size();
    if (numAccounts == 1) {
        final String body = getIntent().getStringExtra(EXTRA_BODY);
        final Account account = xmppConnectionService.getAccounts().get(0);
        try {
            final Jid contact = Jid.fromString(getIntent().getStringExtra(EXTRA_CONTACT));
            final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, contact, false, false);
            switchToConversation(conversation, body, false);
        } catch (InvalidJidException e) {
        // ignore error
        }
        finish();
    } else {
        refreshUiReal();
    }
}
Also used : Account(de.pixart.messenger.entities.Account) Jid(de.pixart.messenger.xmpp.jid.Jid) InvalidJidException(de.pixart.messenger.xmpp.jid.InvalidJidException) Conversation(de.pixart.messenger.entities.Conversation)

Example 68 with Account

use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.

the class ShareWithActivity method share.

private void share() {
    final Conversation conversation;
    if (share.uuid != null) {
        conversation = xmppConnectionService.findConversationByUuid(share.uuid);
        if (conversation == null) {
            return;
        }
    } else {
        Account account;
        try {
            account = xmppConnectionService.findAccountByJid(Jid.fromString(share.account));
        } catch (final InvalidJidException e) {
            account = null;
        }
        if (account == null) {
            return;
        }
        try {
            conversation = xmppConnectionService.findOrCreateConversation(account, Jid.fromString(share.contact), false, true);
        } catch (final InvalidJidException e) {
            return;
        }
    }
    ContactChosen = true;
    share(conversation);
}
Also used : Account(de.pixart.messenger.entities.Account) InvalidJidException(de.pixart.messenger.xmpp.jid.InvalidJidException) Conversation(de.pixart.messenger.entities.Conversation)

Example 69 with Account

use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.

the class StartConversationActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (resultCode == RESULT_OK) {
        if (xmppConnectionServiceBound) {
            this.mPostponedActivityResult = null;
            if (requestCode == REQUEST_CREATE_CONFERENCE) {
                Account account = extractAccount(intent);
                final String subject = intent.getStringExtra("subject");
                List<Jid> jids = new ArrayList<>();
                if (intent.getBooleanExtra("multiple", false)) {
                    String[] toAdd = intent.getStringArrayExtra("contacts");
                    for (String item : toAdd) {
                        try {
                            jids.add(Jid.fromString(item));
                        } catch (InvalidJidException e) {
                        // ignored
                        }
                    }
                } else {
                    try {
                        jids.add(Jid.fromString(intent.getStringExtra("contact")));
                    } catch (Exception e) {
                    // ignored
                    }
                }
                if (account != null && jids.size() > 0) {
                    if (xmppConnectionService.createAdhocConference(account, subject, jids, mAdhocConferenceCallback)) {
                        mToast = Toast.makeText(this, R.string.creating_conference, Toast.LENGTH_LONG);
                        mToast.show();
                    }
                }
            }
        } else {
            this.mPostponedActivityResult = new Pair<>(requestCode, intent);
        }
    }
    super.onActivityResult(requestCode, requestCode, intent);
}
Also used : Account(de.pixart.messenger.entities.Account) Jid(de.pixart.messenger.xmpp.jid.Jid) InvalidJidException(de.pixart.messenger.xmpp.jid.InvalidJidException) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) ActivityNotFoundException(android.content.ActivityNotFoundException) InvalidJidException(de.pixart.messenger.xmpp.jid.InvalidJidException)

Example 70 with Account

use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.

the class StartConversationActivity method onBackendConnected.

@Override
protected void onBackendConnected() {
    if (mPostponedActivityResult != null) {
        onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second);
        this.mPostponedActivityResult = null;
    }
    this.mActivatedAccounts.clear();
    for (Account account : xmppConnectionService.getAccounts()) {
        if (account.getStatus() != Account.State.DISABLED) {
            if (Config.DOMAIN_LOCK != null) {
                this.mActivatedAccounts.add(account.getJid().getLocalpart());
            } else {
                this.mActivatedAccounts.add(account.getJid().toBareJid().toString());
            }
        }
    }
    final Intent intent = getIntent();
    final ActionBar ab = getSupportActionBar();
    boolean init = intent != null && intent.getBooleanExtra("init", false);
    boolean noConversations = xmppConnectionService.getConversations().size() == 0;
    if ((init || noConversations) && ab != null) {
        ab.setDisplayShowHomeEnabled(false);
        ab.setDisplayHomeAsUpEnabled(false);
        ab.setHomeButtonEnabled(false);
    }
    this.mKnownHosts = xmppConnectionService.getKnownHosts();
    this.mKnownConferenceHosts = xmppConnectionService.getKnownConferenceHosts();
    if (this.mPendingInvite != null) {
        mPendingInvite.invite();
        this.mPendingInvite = null;
        filter(null);
    } else if (!handleIntent(getIntent())) {
        if (mSearchEditText != null) {
            filter(mSearchEditText.getText().toString());
        } else {
            filter(null);
        }
    } else {
        filter(null);
    }
    setIntent(null);
}
Also used : Account(de.pixart.messenger.entities.Account) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) ActionBar(android.support.v7.app.ActionBar)

Aggregations

Account (de.pixart.messenger.entities.Account)104 IqPacket (de.pixart.messenger.xmpp.stanzas.IqPacket)39 OnIqPacketReceived (de.pixart.messenger.xmpp.OnIqPacketReceived)31 Jid (de.pixart.messenger.xmpp.jid.Jid)26 Element (de.pixart.messenger.xml.Element)23 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)19 Conversation (de.pixart.messenger.entities.Conversation)18 ArrayList (java.util.ArrayList)14 Intent (android.content.Intent)12 Contact (de.pixart.messenger.entities.Contact)12 Bookmark (de.pixart.messenger.entities.Bookmark)10 PendingIntent (android.app.PendingIntent)9 Message (de.pixart.messenger.entities.Message)8 Bundle (android.os.Bundle)7 AlertDialog (android.support.v7.app.AlertDialog)7 MucOptions (de.pixart.messenger.entities.MucOptions)7 List (java.util.List)7 SuppressLint (android.annotation.SuppressLint)6 Bitmap (android.graphics.Bitmap)6 View (android.view.View)6