Search in sources :

Example 1 with MessagePacket

use of de.pixart.messenger.xmpp.stanzas.MessagePacket in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method pushSubjectToConference.

public void pushSubjectToConference(final Conversation conference, final String subject) {
    MessagePacket packet = this.getMessageGenerator().conferenceSubject(conference, subject);
    this.sendMessagePacket(conference.getAccount(), packet);
    final MucOptions mucOptions = conference.getMucOptions();
    final MucOptions.User self = mucOptions.getSelf();
    if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) {
        Bundle options = new Bundle();
        options.putString("muc#roomconfig_persistentroom", "1");
        options.putString("muc#roomconfig_roomname", subject);
        this.pushConferenceConfiguration(conference, options, null);
    }
}
Also used : MessagePacket(de.pixart.messenger.xmpp.stanzas.MessagePacket) MucOptions(de.pixart.messenger.entities.MucOptions) Bundle(android.os.Bundle)

Example 2 with MessagePacket

use of de.pixart.messenger.xmpp.stanzas.MessagePacket in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method invite.

public void invite(Conversation conversation, Jid contact) {
    Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": inviting " + contact + " to " + conversation.getJid().toBareJid());
    MessagePacket packet = mMessageGenerator.invite(conversation, contact);
    sendMessagePacket(conversation.getAccount(), packet);
}
Also used : MessagePacket(de.pixart.messenger.xmpp.stanzas.MessagePacket)

Example 3 with MessagePacket

use of de.pixart.messenger.xmpp.stanzas.MessagePacket in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method renewSymmetricKey.

public boolean renewSymmetricKey(Conversation conversation) {
    Account account = conversation.getAccount();
    byte[] symmetricKey = new byte[32];
    this.mRandom.nextBytes(symmetricKey);
    Session otrSession = conversation.getOtrSession();
    if (otrSession != null) {
        MessagePacket packet = new MessagePacket();
        packet.setType(MessagePacket.TYPE_CHAT);
        packet.setFrom(account.getJid());
        MessageGenerator.addMessageHints(packet);
        packet.setAttribute("to", otrSession.getSessionID().getAccountID() + "/" + otrSession.getSessionID().getUserID());
        try {
            packet.setBody(otrSession.transformSending(CryptoHelper.FILETRANSFER + CryptoHelper.bytesToHex(symmetricKey))[0]);
            sendMessagePacket(account, packet);
            conversation.setSymmetricKey(symmetricKey);
            return true;
        } catch (OtrException e) {
            return false;
        }
    }
    return false;
}
Also used : MessagePacket(de.pixart.messenger.xmpp.stanzas.MessagePacket) Account(de.pixart.messenger.entities.Account) OtrException(net.java.otr4j.OtrException) Session(net.java.otr4j.session.Session)

Example 4 with MessagePacket

use of de.pixart.messenger.xmpp.stanzas.MessagePacket in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method directInvite.

public void directInvite(Conversation conversation, Jid jid) {
    MessagePacket packet = mMessageGenerator.directInvite(conversation, jid);
    sendMessagePacket(conversation.getAccount(), packet);
}
Also used : MessagePacket(de.pixart.messenger.xmpp.stanzas.MessagePacket)

Example 5 with MessagePacket

use of de.pixart.messenger.xmpp.stanzas.MessagePacket in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method onOtrSessionEstablished.

public void onOtrSessionEstablished(Conversation conversation) {
    final Account account = conversation.getAccount();
    final Session otrSession = conversation.getOtrSession();
    Log.d(Config.LOGTAG, account.getJid().toBareJid() + " otr session established with " + conversation.getJid() + "/" + otrSession.getSessionID().getUserID());
    conversation.findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR, new Conversation.OnMessageFound() {

        @Override
        public void onMessageFound(Message message) {
            SessionID id = otrSession.getSessionID();
            try {
                message.setCounterpart(Jid.fromString(id.getAccountID() + "/" + id.getUserID()));
            } catch (InvalidJidException e) {
                return;
            }
            if (message.needsUploading()) {
                mJingleConnectionManager.createNewConnection(message);
            } else {
                MessagePacket outPacket = mMessageGenerator.generateOtrChat(message);
                if (outPacket != null) {
                    mMessageGenerator.addDelay(outPacket, message.getTimeSent());
                    message.setStatus(Message.STATUS_SEND);
                    databaseBackend.updateMessage(message);
                    sendMessagePacket(account, outPacket);
                }
            }
            updateConversationUi();
        }
    });
}
Also used : MessagePacket(de.pixart.messenger.xmpp.stanzas.MessagePacket) Account(de.pixart.messenger.entities.Account) XmppAxolotlMessage(de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage) Message(de.pixart.messenger.entities.Message) InvalidJidException(de.pixart.messenger.xmpp.jid.InvalidJidException) Conversation(de.pixart.messenger.entities.Conversation) SessionID(net.java.otr4j.session.SessionID) Session(net.java.otr4j.session.Session)

Aggregations

MessagePacket (de.pixart.messenger.xmpp.stanzas.MessagePacket)32 Element (de.pixart.messenger.xml.Element)8 Account (de.pixart.messenger.entities.Account)6 Conversation (de.pixart.messenger.entities.Conversation)6 XmppAxolotlMessage (de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage)5 Message (de.pixart.messenger.entities.Message)5 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)5 Jid (de.pixart.messenger.xmpp.jid.Jid)5 AbstractAcknowledgeableStanza (de.pixart.messenger.xmpp.stanzas.AbstractAcknowledgeableStanza)3 Session (net.java.otr4j.session.Session)3 MucOptions (de.pixart.messenger.entities.MucOptions)2 ReceiptRequest (de.pixart.messenger.entities.ReceiptRequest)2 Tag (de.pixart.messenger.xml.Tag)2 RequestPacket (de.pixart.messenger.xmpp.stanzas.streammgmt.RequestPacket)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 OtrException (net.java.otr4j.OtrException)2 Bundle (android.os.Bundle)1 Bookmark (de.pixart.messenger.entities.Bookmark)1 Contact (de.pixart.messenger.entities.Contact)1