Search in sources :

Example 6 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class JingleConnection method init.

public void init(final Message message) {
    if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
        Conversation conversation = message.getConversation();
        conversation.getAccount().getAxolotlService().prepareKeyTransportMessage(conversation, new OnMessageCreatedCallback() {

            @Override
            public void run(XmppAxolotlMessage xmppAxolotlMessage) {
                if (xmppAxolotlMessage != null) {
                    init(message, xmppAxolotlMessage);
                } else {
                    fail();
                }
            }
        });
    } else {
        init(message, null);
    }
}
Also used : OnMessageCreatedCallback(eu.siacs.conversations.crypto.axolotl.OnMessageCreatedCallback) Conversation(eu.siacs.conversations.entities.Conversation) XmppAxolotlMessage(eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)

Example 7 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class GeoHelper method createGeoIntentsFromMessage.

public static ArrayList<Intent> createGeoIntentsFromMessage(Message message) {
    final ArrayList<Intent> intents = new ArrayList<>();
    Matcher matcher = GEO_URI.matcher(message.getBody());
    if (!matcher.matches()) {
        return intents;
    }
    double latitude;
    double longitude;
    try {
        latitude = Double.parseDouble(matcher.group(1));
        if (latitude > 90.0 || latitude < -90.0) {
            return intents;
        }
        longitude = Double.parseDouble(matcher.group(2));
        if (longitude > 180.0 || longitude < -180.0) {
            return intents;
        }
    } catch (NumberFormatException nfe) {
        return intents;
    }
    final Conversation conversation = message.getConversation();
    String label;
    if (conversation.getMode() == Conversation.MODE_SINGLE && message.getStatus() == Message.STATUS_RECEIVED) {
        try {
            label = "(" + URLEncoder.encode(message.getConversation().getName(), "UTF-8") + ")";
        } catch (UnsupportedEncodingException e) {
            label = "";
        }
    } else {
        label = "";
    }
    Intent locationPluginIntent = new Intent("eu.siacs.conversations.location.show");
    locationPluginIntent.putExtra("latitude", latitude);
    locationPluginIntent.putExtra("longitude", longitude);
    if (message.getStatus() != Message.STATUS_RECEIVED) {
        locationPluginIntent.putExtra("jid", conversation.getAccount().getJid().toString());
        locationPluginIntent.putExtra("name", conversation.getAccount().getJid().getLocalpart());
    } else {
        Contact contact = message.getContact();
        if (contact != null) {
            locationPluginIntent.putExtra("name", contact.getDisplayName());
            locationPluginIntent.putExtra("jid", contact.getJid().toString());
        } else {
            locationPluginIntent.putExtra("name", UIHelper.getDisplayedMucCounterpart(message.getCounterpart()));
        }
    }
    intents.add(locationPluginIntent);
    Intent geoIntent = new Intent(Intent.ACTION_VIEW);
    geoIntent.setData(Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude) + "?q=" + String.valueOf(latitude) + "," + String.valueOf(longitude) + label));
    intents.add(geoIntent);
    Intent httpIntent = new Intent(Intent.ACTION_VIEW);
    httpIntent.setData(Uri.parse("https://maps.google.com/maps?q=loc:" + String.valueOf(latitude) + "," + String.valueOf(longitude) + label));
    intents.add(httpIntent);
    return intents;
}
Also used : Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Intent(android.content.Intent) Conversation(eu.siacs.conversations.entities.Conversation) Contact(eu.siacs.conversations.entities.Contact)

Example 8 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class OtrService method verify.

@Override
public void verify(SessionID id, String fingerprint, boolean approved) {
    Log.d(Config.LOGTAG, "OtrService.verify(" + id.toString() + "," + fingerprint + "," + String.valueOf(approved) + ")");
    try {
        final Jid jid = Jid.fromSessionID(id);
        Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
        if (conversation != null) {
            if (approved) {
                conversation.getContact().addOtrFingerprint(fingerprint);
            }
            conversation.smp().hint = null;
            conversation.smp().status = Conversation.Smp.STATUS_VERIFIED;
            mXmppConnectionService.updateConversationUi();
            mXmppConnectionService.syncRosterToDisk(conversation.getAccount());
        }
    } catch (final InvalidJidException ignored) {
    }
}
Also used : Jid(eu.siacs.conversations.xmpp.jid.Jid) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) Conversation(eu.siacs.conversations.entities.Conversation)

Example 9 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class OtrService method setSmpStatus.

private void setSmpStatus(SessionID id, int status) {
    try {
        final Jid jid = Jid.fromSessionID(id);
        Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
        if (conversation != null) {
            conversation.smp().status = status;
            mXmppConnectionService.updateConversationUi();
        }
    } catch (final InvalidJidException ignored) {
    }
}
Also used : Jid(eu.siacs.conversations.xmpp.jid.Jid) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) Conversation(eu.siacs.conversations.entities.Conversation)

Example 10 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class OtrService method askForSecret.

@Override
public void askForSecret(SessionID id, InstanceTag instanceTag, String question) {
    try {
        final Jid jid = Jid.fromSessionID(id);
        Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
        if (conversation != null) {
            conversation.smp().hint = question;
            conversation.smp().status = Conversation.Smp.STATUS_CONTACT_REQUESTED;
            mXmppConnectionService.updateConversationUi();
        }
    } catch (InvalidJidException e) {
        Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": smp in invalid session " + id.toString());
    }
}
Also used : Jid(eu.siacs.conversations.xmpp.jid.Jid) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) Conversation(eu.siacs.conversations.entities.Conversation)

Aggregations

Conversation (eu.siacs.conversations.entities.Conversation)110 Account (eu.siacs.conversations.entities.Account)27 Message (eu.siacs.conversations.entities.Message)24 Jid (eu.siacs.conversations.xmpp.Jid)22 Contact (eu.siacs.conversations.entities.Contact)17 MucOptions (eu.siacs.conversations.entities.MucOptions)10 Intent (android.content.Intent)9 Element (eu.siacs.conversations.xml.Element)9 PendingIntent (android.app.PendingIntent)8 XmppAxolotlMessage (eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)8 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)8 Uri (android.net.Uri)7 Conversational (eu.siacs.conversations.entities.Conversational)7 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)7 SuppressLint (android.annotation.SuppressLint)6 SpannableString (android.text.SpannableString)6 XmppConnection (eu.siacs.conversations.xmpp.XmppConnection)6 Jid (eu.siacs.conversations.xmpp.jid.Jid)6 ArrayList (java.util.ArrayList)6 Fragment (android.app.Fragment)4