aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules6
-rw-r--r--AndroidManifest.xml4
-rw-r--r--CHANGELOG.md6
-rw-r--r--README.md16
m---------libs/openpgp-api-lib6
m---------libs/openpgp-keychain0
-rw-r--r--project.properties2
-rw-r--r--res/layout/fragment_conversation.xml2
-rw-r--r--res/layout/otr_fingerprint.xml10
-rw-r--r--res/menu/conversations.xml4
-rw-r--r--res/values-de/arrays.xml22
-rw-r--r--res/values-de/strings.xml86
-rw-r--r--res/values-es/arrays.xml4
-rw-r--r--res/values-es/strings.xml99
-rw-r--r--res/values-eu/arrays.xml22
-rw-r--r--res/values-eu/strings.xml86
-rw-r--r--res/values/strings.xml11
-rw-r--r--src/eu/siacs/conversations/crypto/PgpEngine.java226
-rw-r--r--src/eu/siacs/conversations/entities/Conversation.java33
-rw-r--r--src/eu/siacs/conversations/entities/Message.java17
-rw-r--r--src/eu/siacs/conversations/persistance/FileBackend.java13
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java58
-rw-r--r--src/eu/siacs/conversations/ui/ContactDetailsActivity.java29
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java250
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java644
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java38
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java39
-rw-r--r--src/eu/siacs/conversations/utils/MessageParser.java7
-rw-r--r--src/eu/siacs/conversations/utils/UIHelper.java8
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java24
30 files changed, 1197 insertions, 575 deletions
diff --git a/.gitmodules b/.gitmodules
index 886fc27b..17cbe617 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,7 +1,7 @@
-[submodule "libs/openpgp-keychain"]
- path = libs/openpgp-keychain
- url = https://github.com/openpgp-keychain/openpgp-keychain.git
[submodule "libs/minidns"]
path = libs/minidns
url = https://github.com/rtreffer/minidns.git
+[submodule "libs/openpgp-api-lib"]
+ path = libs/openpgp-api-lib
+ url = https://github.com/open-keychain/openpgp-api-lib.git
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c7f564bc..ce0bd52f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.siacs.conversations"
- android:versionCode="9"
- android:versionName="0.1.3" >
+ android:versionCode="10"
+ android:versionName="0.2-alpha" >
<uses-sdk
android:minSdkVersion="14"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e352af59..fbb9576e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
###Changelog
+####Version 0.2
+* Image file transfer
+* Better integration with OpenKeychain (PGP encryption)
+* Nicer conversation tiles for conferences
+* A lot of bug fixes and code clean up
+
####Version 0.1.3
* Switched to minidns library to resolve SRV records
* Faster DNS in some cases
diff --git a/README.md b/README.md
index ff0b3824..07b15d4e 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
#Conversations
-Conversations is an open source XMPP (formally known as Jabber) client for
+Conversations is an open source XMPP (formerly known as Jabber) client for
Android 4.0+ smart phones.
[![Google Play](http://developer.android.com/images/brand/en_generic_rgb_wo_45.png)](https://play.google.com/store/apps/details?id=eu.siacs.conversations)
@@ -14,6 +14,7 @@ Android 4.0+ smart phones.
##Features
* End-to-end encryption with either OTR or openPGP
+* Sending and receiving images
* Holo UI
* Syncs with your desktop client
* Group Chats
@@ -38,10 +39,15 @@ These XEPs are - as of now:
* XEP-0237: Roster Versioning mainly to save bandwith on poor mobile connections
##Contributors
-(In order of appearance))
+(In order of appearance)
+
+###Code
* Rene Treffer @rtreffer
* Andreas Straub @strb
+###Translations
+* @beriain (Spanish and Basque)
+
##FAQ
###General
####How do I install Conversations?
@@ -73,6 +79,12 @@ detais within Conversations. This will start an add to address book intent with
as payload. This doesn’t require Conversations to have write permissions on your
address book but also doesn’t require you to copy past Jabber ID from one app to
another.
+####How can I change my status
+You can set an account offline by long pressing on it and select temporarily
+disable account from the context menu. Other statuses like away, DND and N/A are
+not supported for simplicity reasons. Users tend to forget their status, other
+users ignore them and setting the status automatically would mean too much of an
+impact on privacy.
###Security
####Why are there to end-to-end encryption methods and which one should I choose?
In most cases OTR should be the encryption method of choice. It works out of the box with most contacts as long as they are online.
diff --git a/libs/openpgp-api-lib b/libs/openpgp-api-lib
new file mode 160000
+Subproject 650e1ebda82596cd4fbfaae406e6eccf189f4f6
diff --git a/libs/openpgp-keychain b/libs/openpgp-keychain
deleted file mode 160000
-Subproject e0a0bf04ee6fa4794a82b44dae905bc814d8549
diff --git a/project.properties b/project.properties
index f54b95ea..86ae5d0c 100644
--- a/project.properties
+++ b/project.properties
@@ -13,4 +13,4 @@
# Project target.
target=android-19
android.library.reference.1=libs/minidns
-android.library.reference.2=libs/openpgp-keychain/OpenKeychain-API/libraries/openpgp-api-library
+android.library.reference.2=libs/openpgp-api-lib
diff --git a/res/layout/fragment_conversation.xml b/res/layout/fragment_conversation.xml
index 0ecccc68..ca09d770 100644
--- a/res/layout/fragment_conversation.xml
+++ b/res/layout/fragment_conversation.xml
@@ -26,7 +26,7 @@
android:layout_toLeftOf="@+id/textSendButton"
android:background="#eee"
android:ems="10"
- android:inputType="textMultiLine"
+ android:inputType="textShortMessage|textMultiLine|textCapSentences"
android:minLines="1" >
<requestFocus />
</EditText>
diff --git a/res/layout/otr_fingerprint.xml b/res/layout/otr_fingerprint.xml
index 666dadcd..b9eafca4 100644
--- a/res/layout/otr_fingerprint.xml
+++ b/res/layout/otr_fingerprint.xml
@@ -6,11 +6,19 @@
android:padding="8dp">
<TextView
+ android:id="@+id/otr_no_fingerprint"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="20sp"
+ android:text="@string/no_otr_fingerprint"
+ android:visibility="visible"/>
+
+ <TextView
android:id="@+id/otr_fingerprint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:typeface="monospace"
- android:text="@string/no_otr_fingerprint"/>
+ android:visibility="gone"/>
</LinearLayout>
diff --git a/res/menu/conversations.xml b/res/menu/conversations.xml
index 58fd3bfa..68bcc957 100644
--- a/res/menu/conversations.xml
+++ b/res/menu/conversations.xml
@@ -4,13 +4,13 @@
android:id="@+id/action_add"
android:orderInCategory="10"
android:icon="@drawable/ic_action_add"
- android:showAsAction="always"
+ android:showAsAction="ifRoom"
android:title="@string/action_add" />
<item
android:id="@+id/action_security"
android:orderInCategory="20"
- android:showAsAction="always"
+ android:showAsAction="ifRoom"
android:icon="@drawable/ic_action_unsecure"
android:title="@string/action_secure" />
diff --git a/res/values-de/arrays.xml b/res/values-de/arrays.xml
new file mode 100644
index 00000000..ef500600
--- /dev/null
+++ b/res/values-de/arrays.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <array name="resources">
+ <item>Mobile</item>
+ <item>Phone</item>
+ <item>Tablet</item>
+ <item>Conversations</item>
+ <item>Android</item>
+ </array>
+ <string-array name="filesizes">
+ <item>nie</item>
+ <item>256 KB</item>
+ <item>512 KB</item>
+ <item>1 MB</item>
+ </string-array>
+ <string-array name="filesizes_values">
+ <item>0</item>
+ <item>262144</item>
+ <item>524288</item>
+ <item>1048576</item>
+ </string-array>
+</resources>
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
new file mode 100644
index 00000000..c6209625
--- /dev/null
+++ b/res/values-de/strings.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">Conversations</string>
+ <string name="action_settings">Einstellungen</string>
+ <string name="action_add">Neue Unterhaltung</string>
+ <string name="action_accounts">Accounts verwalten</string>
+ <string name="action_end_conversation">Unterhaltung beenden</string>
+ <string name="action_contact_details">Kontaktdetails</string>
+ <string name="action_muc_details">Konferenzdetails</string>
+ <string name="action_secure">Verschlüsselte Unterhaltung</string>
+ <string name="action_add_account">Account hinzufügen</string>
+ <string name="title_activity_contacts">Kontakte</string>
+ <string name="just_now">gerade</string>
+ <string name="sending">senden&#8230;</string>
+ <string name="announce_pgp">PGP Ankündigung erneuern</string>
+ <string name="encrypted_message">Entschlüssle Nachricht. Bitte warten&#8230;</string>
+ <string name="conference_details">Konferenzdetails</string>
+ <string name="nick_in_use">Nickname wird bereits verwendet</string>
+ <string name="moderator">Moderator</string>
+ <string name="participant">Teilnehmer</string>
+ <string name="visitor">Besucher</string>
+ <string name="enter_new_name">Gib einen neuen Namen ein:</string>
+ <string name="remove_contact_text">Möchtest du %s von deiner Kontaktliste enfernen? Die Unterhaltung mit diesem Kontakt wird dabei nicht entfernt.</string>
+ <string name="untrusted_cert_hint">Der Server %s hat Dir ein unbekanntes, möglicherweise selbstsigniertes Zertifikat geschickt.</string>
+ <string name="account_info">Server Info</string>
+ <string name="register_account">Neuen Account auf dem Server erstellen</string>
+ <string name="share_with">Teile mit&#8230;</string>
+ <string name="ask_again"><u>Klick um noch einmal zu fragen</u></string>
+ <string name="show_otr_key">OTR Fingerabdruck</string>
+ <string name="no_otr_fingerprint">Es wurde noch kein OTR-Fingerabdruck erzeugt. Beginne einfach eine verschlüsselte Unterhaltung um einen Fingerabdruck zu erzeugen.</string>
+ <string name="start_conversation">Beginne Unterhaltung</string>
+ <string name="invite_contacts">Kontakte einladen</string>
+ <string name="invite_contacts_to_existing">Lade zu bestehender Konferenz ein</string>
+ <string name="new_conference">Erzeuge neue Konferenz</string>
+ <string name="cancel">Abbrechen</string>
+ <string name="create_invite">Erzeugen \u0026 Einladen</string>
+ <string name="new_conference_explained">Do you want to create a new conference with a randomly generated address and invite the selected contacts to it?</string>
+ <string name="no_open_mucs">Keine bestehende Konferenz</string>
+ <string name="invitation_sent">Einladung wurde versandt</string>
+ <string name="account_offline">Account offline</string>
+ <string name="cant_invite_while_offline">Du musst online sein um andere Leute zu einer Konferenz einzuladen</string>
+ <string name="crash_report_title">Conversations ist abgestürzt</string>
+ <string name="crash_report_message">By sending in stack traces you are helping the ongoing development of Conversations\n<b>Warning:</b> This will use your XMPP account to send the stack trace to the developer.</string>
+ <string name="send_now">Jetzt abschicken</string>
+ <string name="send_never">Nie mehr nachfragen</string>
+ <string name="problem_connecting_to_account">Es gibt Probleme beim Verbindungsaufbau mit einem Account</string>
+ <string name="problem_connecting_to_accounts">Es gibt Probleme beim Verbindungsaufbau mit mehreren Accounts</string>
+ <string name="touch_to_fix">Drücke hier um den Account zu verwalten</string>
+ <string name="attach_file">Datei anfügen</string>
+ <string name="not_in_roster">Der Kontakt ist nicht in deiner Kontaktliste. Möchtest du ihn hinzufügen?</string>
+ <string name="add_contact">Kontakt hinzufügen</string>
+ <string name="send_failed">Zustellung nicht erfolgreich</string>
+ <string name="send_rejected">abgelehnt</string>
+ <string name="receiving_image">Empfange Bild. Bitte warten&#8230;</string>
+ <string name="preparing_image">Bereite Bild für die Übertragung vor. Bitte warten&#8230;</string>
+ <string name="action_clear_history">Unterhaltungsverlauf löschen</string>
+ <string name="clear_conversation_history">Unterhaltungsverlauf löschen</string>
+ <string name="clear_histor_msg">Möchtest du alle Nachrichten in dieser Unterhaltung löschen?\n\n<b>Achtung:</b> Das beeinflust nicht Nachrichten die eventuell auf anderen Geräten gespeichert wurden.</string>
+ <string name="delete_messages">Nachrichten löschen</string>
+ <string name="also_end_conversation">Diese Unterhaltung danach beenden</string>
+ <string name="choose_presence">Choose presence to contact</string>
+ <string name="send_message_to_conference">Nachricht an Konferenz schicken</string>
+ <string name="send_plain_text_message">Unverschlüsselte Nachricht schicken</string>
+ <string name="send_otr_message">Nachricht OTR-verschlüsselt verschicken</string>
+ <string name="send_pgp_message">Nachricht openPGP-verschlüsselt verschicken</string>
+ <string name="your_nick_has_been_changed">Dein Nickname wurde geändert</string>
+ <string name="download_image">Bild herunter laden</string>
+ <string name="error_loading_image">Fehler beim laden des Bildes. (Datei wurde nicht gefunden)</string>
+ <string name="image_offered_for_download"><i>Bild Datei zum Download angeboten</i></string>
+ <string name="not_connected">Nicht verbunden</string>
+ <string name="you_are_offline">Du musst online sein um % zu verschicken. Dein Account der mit dieser Unterhaltung verbunden ist aber gerade offline.</string>
+ <string name="you_are_offline_blank">Du kannst diese Aktion nicht ausführen so lange du offline bist.</string>
+ <string name="files">Dateien</string>
+ <string name="otr_messages">OTR-verschlüsselte Nachrichten</string>
+ <string name="manage_account">Account verwalten</string>
+ <string name="contact_offline">Dein Kontakt ist offline</string>
+ <string name="contact_offline_otr">Dein Kontakt muss online sein um OTR-verschlüsselte Nachrichten zu empfangen. Möchtest Du die Nachricht gerne im Klartext übertragen?</string>
+ <string name="contact_offline_file">Der Kontakt muss online sein um Datein zu empfangen.</string>
+ <string name="send_unencrypted">Unverschlüsselt verschicken</string>
+ <string name="decryption_failed">Entschlüsselung fehlgeschlagen. Vielleicht hast du nicht den richtigen Private Key.</string>
+ <string name="openkeychain_required">OpenKeychain</string>
+ <string name="openkeychain_required_long">Conversations benutzt eine Third-party-app names <b>OpenKeychain</b> um Nachrichten zu ver- und entschlüsseln und um deine Schlüssel zu verwalten.\n\nOpenKeychain ist GPLv3 lizensiert und bei F-Droid oder Google Play zu bekommen.\n\n<small>(Bitte starte Conversations danach neu)</small></string>
+ <string name="restart">Neustarten</string>
+ <string name="install">Installieren</string>
+</resources>
diff --git a/res/values-es/arrays.xml b/res/values-es/arrays.xml
index a26fbfa4..318b9d5c 100644
--- a/res/values-es/arrays.xml
+++ b/res/values-es/arrays.xml
@@ -4,11 +4,11 @@
<item>Móvil</item>
<item>Teléfono</item>
<item>Tablet</item>
- <item>Conversaciones</item>
+ <item>Conversations</item>
<item>Android</item>
</array>
<string-array name="filesizes">
- <item>Nunca</item>
+ <item>nunca</item>
<item>256 KB</item>
<item>512 KB</item>
<item>1 MB</item>
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
index f8729d3c..2c569187 100644
--- a/res/values-es/strings.xml
+++ b/res/values-es/strings.xml
@@ -1,86 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">Conversaciones</string>
+ <string name="app_name">Conversations</string>
<string name="action_settings">Ajustes</string>
<string name="action_add">Nueva conversación</string>
<string name="action_accounts">Gestionar cuentas</string>
<string name="action_end_conversation">Terminar conversación</string>
- <string name="action_contact_details">Información del contacto</string>
- <string name="action_muc_details">Información de conferencia</string>
- <string name="action_secure">Conversación privada</string>
+ <string name="action_contact_details">Detalles del contacto</string>
+ <string name="action_muc_details">Detalles de la conferencia</string>
+ <string name="action_secure">Conversación segura</string>
<string name="action_add_account">Añadir cuenta</string>
<string name="title_activity_contacts">Contactos</string>
- <string name="just_now">Ahora</string>
+ <string name="just_now">ahora</string>
<string name="sending">enviando&#8230;</string>
- <string name="announce_pgp">Renovar comunicación PGP</string>
- <string name="encrypted_message">Desencriptando mensaje. Por favor espere&#8230;</string>
- <string name="conference_details">Información de conferencia</string>
- <string name="nick_in_use">El alias ya está en uso</string>
+ <string name="announce_pgp">Renovar anuncio PGP</string>
+ <string name="encrypted_message">Desencriptando mensaje. Espera por favor&#8230;</string>
+ <string name="conference_details">Detalles de la conferencia</string>
+ <string name="nick_in_use">El apodo ya está en uso</string>
<string name="moderator">Moderador</string>
<string name="participant">Participante</string>
<string name="visitor">Visitante</string>
- <string name="enter_new_name">Introduce nuevo nombre:</string>
- <string name="remove_contact_text">¿Deseas eliminar %s de tu lista? La conversación asociada a este contacto no se eliminará.</string>
- <string name="untrusted_cert_hint">El servidor %s presenta un certificado no confiable, posiblemente autofirmado.</string>
+ <string name="enter_new_name">Introduce un nuevo nombre:</string>
+ <string name="remove_contact_text">¿Quieres eliminar a %s de tu lista?. La conversación asociada a esta cuenta no se eliminará.</string>
+ <string name="untrusted_cert_hint">El servidor %s presenta un certificado no confiable, posiblemente auto firmado.</string>
<string name="account_info">Información del servidor</string>
<string name="register_account">Registrar nueva cuenta en servidor</string>
<string name="share_with">Compartir con</string>
- <string name="ask_again"><u>Pulse para preguntar de nuevo</u></string>
- <string name="show_otr_key">Huella digital OTR</string>
- <string name="no_otr_fingerprint">Huella digital OTR no generada. Continúa y comienza una conversación encriptada</string>
+ <string name="ask_again"><u>Pulsa para preguntar otra vez</u></string>
+ <string name="show_otr_key">Huella dactilar OTR</string>
+ <string name="no_otr_fingerprint">No se ha generado una huella dactilar OTR. Simplemente continúa y comienza una conversación encriptada</string>
<string name="start_conversation">Comenzar conversación</string>
<string name="invite_contacts">Invitar contactos</string>
- <string name="invite_contacts_to_existing">Invitar a conferencia exsitente</string>
+ <string name="invite_contacts_to_existing">Invitar a conferencia existente</string>
<string name="new_conference">Crear nueva conferencia</string>
<string name="cancel">Cancelar</string>
<string name="create_invite">Crear \u0026 Invitar</string>
- <string name="new_conference_explained">¿Deseas crear una nueva conferencia con una dirección aleatoria e invitar los contactos seleccionados a ella?</string>
- <string name="no_open_mucs">Conferencia no existente</string>
+ <string name="new_conference_explained">¿Quieres crear una nueva conferencia con una dirección generada aleatoriamente e invitar a los contactos seleccionados a ella?</string>
+ <string name="no_open_mucs">No hay conferencias existentes</string>
<string name="invitation_sent">Invitación enviada</string>
<string name="account_offline">Cuenta desconectada</string>
- <string name="cant_invite_while_offline">Tienes que estar conectado para invitar a contactos a la conferencia</string>
- <string name="crash_report_title">Conversaciones ha fallado</string>
- <string name="crash_report_message">Enviando registros de actividad estás ayudando al desarrollo de Conversaciones\n<b>Advertencia:</b> Esto usarará tu cuenta XMPP para enviar registros de actividad al desarrollador.</string>
+ <string name="cant_invite_while_offline">Debes estar conectado para invitar a contactos a la conferencia</string>
+ <string name="crash_report_title">Conversations se ha detenido.</string>
+ <string name="crash_report_message">Enviando volcados de pilas ayudas al desarrollo de Conversations\n<b>Aviso:</b> Esto usará tu cuenta XMPP para enviar el volcado de pila al desarrollador.</string>
<string name="send_now">Enviar ahora</string>
- <string name="send_never">Nunca preguntar de nuevo</string>
+ <string name="send_never">No preguntar de nuevo</string>
<string name="problem_connecting_to_account">No se ha podido conectar a la cuenta</string>
- <string name="problem_connecting_to_accounts">No se ha podido conectar a las cuentas</string>
+ <string name="problem_connecting_to_accounts">No se ha podido conectar a múltiples cuentas</string>
<string name="touch_to_fix">Pulsa aquí para gestionar tus cuentas</string>
- <string name="attach_file">Enviar fichero</string>
- <string name="not_in_roster">El contacto no está en tu lista. ¿Desea añadirlo?</string>
+ <string name="attach_file">Enviar archivo</string>
+ <string name="not_in_roster">El contacto no está en tu lista. ¿Quieres añadirlo?</string>
<string name="add_contact">Añadir contacto</string>
<string name="send_failed">Error al enviar</string>
<string name="send_rejected">rechazado</string>
- <string name="receiving_image">Recibiendo archivo de imagen. Por favor espere&#8230;</string>
- <string name="preparing_image">Preparando imagen para enviar. Por favor espere&#8230;</string>
+ <string name="receiving_image">Recibiendo archivo de imagen. Espera por favor&#8230;</string>
+ <string name="preparing_image">Preparando imagen para enviar</string>
<string name="action_clear_history">Limpiar historial</string>
<string name="clear_conversation_history">Limpiar historial de conversación</string>
- <string name="clear_histor_msg">¿Deseas eliminar todos los mensajes de esta conversación?\n\n<b>Advertencia:</b> Esto no afectará a los mensajes almacenados en otros dispositivos o servidor.</string>
- <string name="delete_messages">Eliminar mensajes</string>
- <string name="also_end_conversation">Terminar esta conversación después</string>
- <string name="choose_presence">Seleccionar recurso</string>
+ <string name="clear_histor_msg">¿Quieres borrar todos los mensajes de esta conversación?\n\n<b>Aviso:</b> Esto no afectará a los mensajes guardados en otros dispositivos o servidores.</string>
+ <string name="delete_messages">Borrar mensajes</string>
+ <string name="also_end_conversation">Terminar esta conversación más tarde</string>
+ <string name="choose_presence">Selecciona recurso del contacto</string>
<string name="send_message_to_conference">Enviar mensaje a conferencia</string>
<string name="send_plain_text_message">Enviar mensaje de texto</string>
- <string name="send_otr_message">Enviar mensaje encriptado OTR</string>
- <string name="send_pgp_message">Enviar mensaje encriptado openPGP</string>
- <string name="your_nick_has_been_changed">Tu alias ha sido modificado</string>
+ <string name="send_otr_message">Enviar mensaje encriptado con OTR</string>
+ <string name="send_pgp_message">Enviar mensaje encriptado con openPGP</string>
+ <string name="your_nick_has_been_changed">Tu apodo se ha modificado</string>
<string name="download_image">Descargar imagen</string>
<string name="error_loading_image">Error cargando imagen (Archivo no encontrado)</string>
<string name="image_offered_for_download"><i>Archivo de imagen ofrecido para descarga</i></string>
<string name="not_connected">No conectado</string>
- <string name="you_are_offline">Debes estar conectado para enviar %s pero tu cuenta asociada con esta conversación está actualmente desconectada.</string>
- <string name="you_are_offline_blank">No puedes realizar esta operación mientras estás desconectado</string>
+ <string name="you_are_offline">Debes estar conectado para enviar %s pero tu cuenta asociada a esta conversación está desconectada.</string>
+ <string name="you_are_offline_blank">No puedes ejecutar esta acción estando desconectado</string>
<string name="files">archivos</string>
- <string name="otr_messages">Mensajes encriptados OTR</string>
- <string name="manage_account">Gestionar cuentas</string>
- <string name="contact_offline">El contacto está desconectado</string>
- <string name="contact_offline_otr">Desafortunadamente no está soportado enviar mensajes encriptados OTR a contactos desconectados.\n¿Te gustaría enviar un mensaje de texto plano?</string>
- <string name="contact_offline_file">Desafortunadamente no está soportado enviar archivos a contactos desconectados.</string>
- <string name="send_unencrypted">Enviado sin encriptar</string>
- <string name="decryption_failed">Fallo al desencriptar. Es posible que no tengas una clave privada apropiada.</string>
+ <string name="otr_messages">Mensajes encriptados con OTR</string>
+ <string name="manage_account">Gestionar cuenta</string>
+ <string name="contact_offline">Tu contacto está desconectado</string>
+ <string name="contact_offline_otr">Desgraciadamente no es posible enviar mensajes encriptados con OTR a un contacto desconectado.\n¿Quieres enviar el mensaje en texto plano?</string>
+ <string name="contact_offline_file">Desgraciadamente no es posible enviar archivos a un contacto desconectado.</string>
+ <string name="send_unencrypted">Enviar sin encriptar</string>
+ <string name="decryption_failed">Falló la desencriptación. Tal vez no tengas la clave privada apropiada.</string>
<string name="openkeychain_required">OpenKeychain</string>
- <string name="openkeychain_required_long">Conversaciones utiliza una aplicación de terceros llamada <b>OpenKeychain</b> para encriptar y desencriptar mensajes y gestionar tus claves públicas.\n\nOpenKeychain está publicado bajo licencia GPLv3 y disponible on F-Droid y Google Play.\n\n<small>(Por favor, reinicie Conversaciones después.)</small></string>
+ <string name="openkeychain_required_long">Conversations utiliza una aplicación de terceros llamada <b>OpenKeychain</b> para encriptar y desencriptar mensajes y gestionar tus claves públicas.\n\nOpenKeychain está publicado bajo licencia GPLv3 y disponible on F-Droid y Google Play.\n\n<small>(Por favor, reinicie Conversations después.)</small></string>
<string name="restart">Reiniciar</string>
<string name="install">Instalar</string>
-</resources>
+ <string name="offering">ofreciendo&#8230;</string>
+ <string name="no_pgp_key">Clave openPGP no encontrada</string>
+ <string name="contact_has_no_pgp_key">Conversations no ha podido encriptar tus mensajes porque tu contacto no está anunciando su clave publica.\n\n<small>Por favor, pide a tu contacto que configure openPGP.</small></string>
+ <string name="encrypted_message_received"><i>Mensaje encriptado recibido. Pulsa para desencriptar y ver.</i></string>
+ <string name="encrypted_image_received"><i>Imagen encriptada recibida. Pulsa para desencriptar y ver.</i></string>
+ <string name="image_file"><i>Imagen recibida. Pulsa para ver</i></string>
+ <string name="otr_file_transfer">Encriptación con OTR no disponible</string>
+ <string name="otr_file_transfer_msg">Desafortunadamente la encriptación con OTR no está disponible para transferencia de archivos. Puedes selecionar encriptación con openPGP o no usar encriptación.</string>
+ <string name="use_pgp_encryption">Usa encriptación con openPGP</string>
+</resources> \ No newline at end of file
diff --git a/res/values-eu/arrays.xml b/res/values-eu/arrays.xml
new file mode 100644
index 00000000..2a5c3ce3
--- /dev/null
+++ b/res/values-eu/arrays.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <array name="resources">
+ <item>Mugikorra</item>
+ <item>Telefonoa</item>
+ <item>Tableta</item>
+ <item>Conversations</item>
+ <item>Android</item>
+ </array>
+ <string-array name="filesizes">
+ <item>inoiz</item>
+ <item>256 KB</item>
+ <item>512 KB</item>
+ <item>1 MB</item>
+ </string-array>
+ <string-array name="filesizes_values">
+ <item>0</item>
+ <item>262144</item>
+ <item>524288</item>
+ <item>1048576</item>
+ </string-array>
+</resources>
diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml
new file mode 100644
index 00000000..4ad8932c
--- /dev/null
+++ b/res/values-eu/strings.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">Conversations</string>
+ <string name="action_settings">Ezarpenak</string>
+ <string name="action_add">Elkarrizketa berria</string>
+ <string name="action_accounts">Kontuak kudeatu</string>
+ <string name="action_end_conversation">Elkarrizketa hau amaitu</string>
+ <string name="action_contact_details">Kontaktu xehetasunak</string>
+ <string name="action_muc_details">Konferentzia xehetasunak</string>
+ <string name="action_secure">Elkarrizketa segurua</string>
+ <string name="action_add_account">Kontua gehitu</string>
+ <string name="title_activity_contacts">Kontaktuak</string>
+ <string name="just_now">orain</string>
+ <string name="sending">bidaltzen&#8230;</string>
+ <string name="announce_pgp">PGP iragarpena berritu</string>
+ <string name="encrypted_message">Mezua desenkriptatzen. Mesedez itxaron&#8230;</string>
+ <string name="conference_details">Konferentzia xehetasunak</string>
+ <string name="nick_in_use">Ezizena erabilita dagoeneko</string>
+ <string name="moderator">Moderatzailea</string>
+ <string name="participant">Parte-hartzailea</string>
+ <string name="visitor">Bisitaria</string>
+ <string name="enter_new_name">Sartu izen berri bat:</string>
+ <string name="remove_contact_text">%s zure zerrendatik ezabatu nahi duzu. Kontu honekin lotutako elkarrizketa ez da ezabatuko.</string>
+ <string name="untrusted_cert_hint">%s zerbitzariak konfiantzarik gabeko, agian bere buruak izenpetutako, ziurtagiri batekin aurkeztu zaitu.</string>
+ <string name="account_info">Zerbitzari informazioa</string>
+ <string name="register_account">Kontu berria zerbitzarian erregistratu</string>
+ <string name="share_with">Honekin partekatu</string>
+ <string name="ask_again"><u>Sakatu berriz galdetzeko</u></string>
+ <string name="show_otr_key">OTR hatz-marka</string>
+ <string name="no_otr_fingerprint">Ez da OTR hatz-markarik sortu. Aurrera joan eta enkriptatutako elkarrizketa hasi</string>
+ <string name="start_conversation">Elkarrizketa hasi</string>
+ <string name="invite_contacts">Kontaktuak gonbidatu</string>
+ <string name="invite_contacts_to_existing">Existitzen den konferentzia batera gonbidatu</string>
+ <string name="new_conference">Konferentzia berria sortu</string>
+ <string name="cancel">Utzi</string>
+ <string name="create_invite">Sortu \u0026 Gonbidatu</string>
+ <string name="new_conference_explained">Ausazki sortutako helbide batekin konferentzia berri bat sortu eta hautatutako kontaktuak bertara gonbidatu nahi al dituzu?</string>
+ <string name="no_open_mucs">Ez da konferentziarik existitzen</string>
+ <string name="invitation_sent">Gonbidapena bidali da</string>
+ <string name="account_offline">Kontua lineaz kanpo</string>
+ <string name="cant_invite_while_offline">Konektatuta egon behar zara jendea konferentzietara gonbidatzeko</string>
+ <string name="crash_report_title">Conversations gelditu da</string>
+ <string name="crash_report_message">Akats harraskak bidaliz Conversationsen garapenean laguntzen duzu\n<b>Abisua:</b> Honek zure XMPP kontua erabiliko du garatzaileari akats harraska bidaltzeko.</string>
+ <string name="send_now">Bidali orain</string>
+ <string name="send_never">Ez galdetu berriz</string>
+ <string name="problem_connecting_to_account">Ezin izan da kontura konektatu</string>
+ <string name="problem_connecting_to_accounts">Ezin izan da hainbat kontuetara konektatu</string>
+ <string name="touch_to_fix">Ukitu hemen zure kontuak kudeatzeko</string>
+ <string name="attach_file">Fitxategia erantsi</string>
+ <string name="not_in_roster">Kontaktua ez dago zure zerrendan. Gehitu nahiko al zenuke?</string>
+ <string name="add_contact">Kontaktua gehitu</string>
+ <string name="send_failed">bidaltze okerra</string>
+ <string name="send_rejected">ukatua</string>
+ <string name="receiving_image">Irudi fitxategia jasotzen. Mesedez itxaron&#8230;</string>
+ <string name="preparing_image">Irudia transmisiorako prestatzen. Mesedez itxaron&#8230;</string>
+ <string name="action_clear_history">Historia garbitu</string>
+ <string name="clear_conversation_history">Elkarrizketa historia garbitu</string>
+ <string name="clear_histor_msg">Elkarrizketa honetako mezu guztiak ezabatu nahi al dituzu?\n\n<b>Abisua:</b> Honek ez du beste gailu edo zerbitzarietan gordetako mezuetan eraginik izango.</string>
+ <string name="delete_messages">Mezuak ezabatu</string>
+ <string name="also_end_conversation">Elkarrizketa hau geroago amaitu</string>
+ <string name="choose_presence">Hautatu agerpena kontaktuarentzat</string>
+ <string name="send_message_to_conference">Mezua konferentziara bidali</string>
+ <string name="send_plain_text_message">Testu zapaleko mezua bidali</string>
+ <string name="send_otr_message">OTRz enkriptatutako mezua bidali</string>
+ <string name="send_pgp_message">openPGPz enkriptatutako mezua bidali</string>
+ <string name="your_nick_has_been_changed">Zure ezizena aldatu da</string>
+ <string name="download_image">Irudia deskargatu</string>
+ <string name="error_loading_image">Akatsa irudia kargatzen (fitxategia ez da aurkitu)</string>
+ <string name="image_offered_for_download"><i>Irudi fitxategia deskargarako eskeinia</i></string>
+ <string name="not_connected">Ez konektaturik</string>
+ <string name="you_are_offline">Konektatuta egon behar zara %s bidaltzeko baina elkarrizketa honekin lotutako kontua lineaz kanpo dago.</string>
+ <string name="you_are_offline_blank">Ezin duzu ekintza hau lineaz kanpo egonda burutu</string>
+ <string name="files">fitxategiak</string>
+ <string name="otr_messages">OTRz enkriptatutako mezuak</string>
+ <string name="manage_account">Kontua kudeatu</string>
+ <string name="contact_offline">Zure kontaktua lineaz kanpo dago</string>
+ <string name="contact_offline_otr">Zoritxarrez ezin da OTRz enkriptatutako mezurik bidali lineaz kanpo dagoen kontaktu bati.\nMezua testu zapalean bidali nahiko al zenuke?</string>
+ <string name="contact_offline_file">Zoritxarrez ezin da fitxategirik bidali lineaz kanpo dagoen kontaktu bati.</string>
+ <string name="send_unencrypted">Enkriptatu gabe bidali</string>
+ <string name="decryption_failed">Desenkriptazioak huts egin du. Agian ez duzu gako pribatu egokia.</string>
+ <string name="openkeychain_required">OpenKeychain</string>
+ <string name="openkeychain_required_long">Conversationsek <b>OpenKeychain</b> izeneko hirugarren app bat erabiltzen du mezuak enkriptatu eta desenkriptatzeko eta zure gako publikoak kudeatzeko.\n\nOpenKeychain GPLv3 lizentziapean dago eta F-Droid eta Google Playn eskura daiteke.\n\n<small>(Mesedez ondoren Conversations berrabiarazi)</small></string>
+ <string name="restart">Berrabiarazi</string>
+ <string name="install">Instalatu</string>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fa41b7b8..5c844964 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -53,7 +53,7 @@
<string name="send_failed">unsuccessful delivery</string>
<string name="send_rejected">rejected</string>
<string name="receiving_image">Receiving image file. Please wait&#8230;</string>
- <string name="preparing_image">Preparing image for transmission. Please wait&#8230;</string>
+ <string name="preparing_image">Preparing image for transmission</string>
<string name="action_clear_history">Clear history</string>
<string name="clear_conversation_history">Clear Conversation History</string>
<string name="clear_histor_msg">Do you want to delete all messages within this Conversation?\n\n<b>Warning:</b> This will not influence messages stored on other devices or servers.</string>
@@ -83,4 +83,13 @@
<string name="openkeychain_required_long">Conversations utilizes a third party app called <b>OpenKeychain</b> to encrypt and decrypt messages and to mange your public keys.\n\nOpenKeychain is licensed under GPLv3 and available on F-Droid and Google Play.\n\n<small>(Please restart Conversations afterwards.)</small></string>
<string name="restart">Restart</string>
<string name="install">Install</string>
+ <string name="offering">offering&#8230;</string>
+ <string name="no_pgp_key">No openPGP Key found</string>
+ <string name="contact_has_no_pgp_key">Conversations is unable to encrypt your messages because your contact is not announcing his or hers public key.\n\n<small>Please ask your contact to setup openPGP.</small></string>
+ <string name="encrypted_message_received"><i>Encrypted message received. Touch to view and decrypt.</i></string>
+ <string name="encrypted_image_received"><i>Encrypted image received. Touch to view and decrypt.</i></string>
+ <string name="image_file"><i>Image received. Touch to view</i></string>
+ <string name="otr_file_transfer">OTR encryption not available</string>
+ <string name="otr_file_transfer_msg">Unfortunaly OTR encryption is not available for file transfer. You can choose either openPGP or no encryption.</string>
+ <string name="use_pgp_encryption">Use openPGP encryption</string>
</resources>
diff --git a/src/eu/siacs/conversations/crypto/PgpEngine.java b/src/eu/siacs/conversations/crypto/PgpEngine.java
index cfe39e4c..229b4300 100644
--- a/src/eu/siacs/conversations/crypto/PgpEngine.java
+++ b/src/eu/siacs/conversations/crypto/PgpEngine.java
@@ -2,6 +2,10 @@ package eu.siacs.conversations.crypto;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -13,86 +17,176 @@ import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Message;
+import eu.siacs.conversations.services.XmppConnectionService;
+import eu.siacs.conversations.xmpp.jingle.JingleFile;
import android.app.PendingIntent;
import android.content.Intent;
+import android.graphics.BitmapFactory;
import android.util.Log;
public class PgpEngine {
private OpenPgpApi api;
+ private XmppConnectionService mXmppConnectionService;
- public PgpEngine(OpenPgpApi api) {
+ public PgpEngine(OpenPgpApi api, XmppConnectionService service) {
this.api = api;
+ this.mXmppConnectionService = service;
}
public void decrypt(final Message message, final OnPgpEngineResult callback) {
+ Log.d("xmppService","decrypting message "+message.getUuid());
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, message
.getConversation().getAccount().getJid());
- InputStream is = new ByteArrayInputStream(message.getBody().getBytes());
- final OutputStream os = new ByteArrayOutputStream();
- api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
-
- @Override
- public void onReturn(Intent result) {
- switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
- OpenPgpApi.RESULT_CODE_ERROR)) {
- case OpenPgpApi.RESULT_CODE_SUCCESS:
- message.setBody(os.toString());
- message.setEncryption(Message.ENCRYPTION_DECRYPTED);
- callback.success();
- return;
- case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
- callback.userInputRequried((PendingIntent) result
- .getParcelableExtra(OpenPgpApi.RESULT_INTENT));
- return;
- case OpenPgpApi.RESULT_CODE_ERROR:
- callback.error((OpenPgpError) result
- .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
- return;
- default:
- return;
+ if (message.getType() == Message.TYPE_TEXT) {
+ InputStream is = new ByteArrayInputStream(message.getBody().getBytes());
+ final OutputStream os = new ByteArrayOutputStream();
+ api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
+
+ @Override
+ public void onReturn(Intent result) {
+ switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
+ OpenPgpApi.RESULT_CODE_ERROR)) {
+ case OpenPgpApi.RESULT_CODE_SUCCESS:
+ message.setBody(os.toString());
+ message.setEncryption(Message.ENCRYPTION_DECRYPTED);
+ callback.success();
+ return;
+ case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
+ callback.userInputRequried((PendingIntent) result
+ .getParcelableExtra(OpenPgpApi.RESULT_INTENT));
+ return;
+ case OpenPgpApi.RESULT_CODE_ERROR:
+ callback.error((OpenPgpError) result
+ .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ return;
+ default:
+ return;
+ }
}
+ });
+ } else if (message.getType() == Message.TYPE_IMAGE) {
+ try {
+ final JingleFile inputFile = this.mXmppConnectionService.getFileBackend().getJingleFile(message, false);
+ final JingleFile outputFile = this.mXmppConnectionService.getFileBackend().getJingleFile(message,true);
+ outputFile.createNewFile();
+ InputStream is = new FileInputStream(inputFile);
+ OutputStream os = new FileOutputStream(outputFile);
+ api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
+
+ @Override
+ public void onReturn(Intent result) {
+ switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
+ OpenPgpApi.RESULT_CODE_ERROR)) {
+ case OpenPgpApi.RESULT_CODE_SUCCESS:
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inJustDecodeBounds = true;
+ BitmapFactory.decodeFile(outputFile.getAbsolutePath(),options);
+ int imageHeight = options.outHeight;
+ int imageWidth = options.outWidth;
+ message.setBody(""+outputFile.getSize()+","+imageWidth+","+imageHeight);
+ message.setEncryption(Message.ENCRYPTION_DECRYPTED);
+ PgpEngine.this.mXmppConnectionService.updateMessage(message);
+ PgpEngine.this.mXmppConnectionService.updateUi(message.getConversation(), false);
+ callback.success();
+ return;
+ case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
+ callback.userInputRequried((PendingIntent) result
+ .getParcelableExtra(OpenPgpApi.RESULT_INTENT));
+ return;
+ case OpenPgpApi.RESULT_CODE_ERROR:
+ callback.error((OpenPgpError) result
+ .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ return;
+ default:
+ return;
+ }
+ }
+ });
+ } catch (FileNotFoundException e) {
+ callback.error(new OpenPgpError(0, "file not found: "+e.getMessage()));
+ } catch (IOException e) {
+ callback.error(new OpenPgpError(0, "io exception: "+e.getMessage()));
}
- });
+
+ }
}
- public void encrypt(Account account, long keyId, Message message,
- final OnPgpEngineResult callback) {
- Log.d("xmppService", "called to pgpengine::encrypt");
- long[] keys = { keyId };
+ public void encrypt(final Message message,final OnPgpEngineResult callback) {
+ long[] keys = { message.getConversation().getContact().getPgpKeyId() };
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_ENCRYPT);
params.putExtra(OpenPgpApi.EXTRA_KEY_IDS, keys);
- params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
- params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid());
-
- InputStream is = new ByteArrayInputStream(message.getBody().getBytes());
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- Intent result = api.executeApi(params, is, os);
- switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
- OpenPgpApi.RESULT_CODE_ERROR)) {
- case OpenPgpApi.RESULT_CODE_SUCCESS:
- StringBuilder encryptedMessageBody = new StringBuilder();
- String[] lines = os.toString().split("\n");
- for (int i = 3; i < lines.length - 1; ++i) {
- encryptedMessageBody.append(lines[i].trim());
+ params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, message.getConversation().getAccount().getJid());
+
+ if (message.getType() == Message.TYPE_TEXT) {
+ params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
+
+ InputStream is = new ByteArrayInputStream(message.getBody().getBytes());
+ final OutputStream os = new ByteArrayOutputStream();
+ api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
+
+ @Override
+ public void onReturn(Intent result) {
+ switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
+ OpenPgpApi.RESULT_CODE_ERROR)) {
+ case OpenPgpApi.RESULT_CODE_SUCCESS:
+ StringBuilder encryptedMessageBody = new StringBuilder();
+ String[] lines = os.toString().split("\n");
+ for (int i = 3; i < lines.length - 1; ++i) {
+ encryptedMessageBody.append(lines[i].trim());
+ }
+ message.setEncryptedBody(encryptedMessageBody.toString());
+ callback.success();
+ break;
+ case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
+ callback.userInputRequried((PendingIntent) result
+ .getParcelableExtra(OpenPgpApi.RESULT_INTENT));
+ break;
+ case OpenPgpApi.RESULT_CODE_ERROR:
+ callback.error((OpenPgpError) result
+ .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ break;
+ }
+ }
+ });
+ } else if (message.getType() == Message.TYPE_IMAGE) {
+ try {
+ JingleFile inputFile = this.mXmppConnectionService.getFileBackend().getJingleFile(message, true);
+ JingleFile outputFile = this.mXmppConnectionService.getFileBackend().getJingleFile(message, false);
+ outputFile.createNewFile();
+ InputStream is = new FileInputStream(inputFile);
+ OutputStream os = new FileOutputStream(outputFile);
+ api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
+
+ @Override
+ public void onReturn(Intent result) {
+ switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
+ OpenPgpApi.RESULT_CODE_ERROR)) {
+ case OpenPgpApi.RESULT_CODE_SUCCESS:
+ callback.success();
+ break;
+ case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
+ callback.userInputRequried((PendingIntent) result
+ .getParcelableExtra(OpenPgpApi.RESULT_INTENT));
+ break;
+ case OpenPgpApi.RESULT_CODE_ERROR:
+ callback.error((OpenPgpError) result
+ .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ break;
+ }
+ }
+ });
+ } catch (FileNotFoundException e) {
+ Log.d("xmppService","file not found: "+e.getMessage());
+ } catch (IOException e) {
+ Log.d("xmppService","io exception during file encrypt");
}
- message.setEncryptedBody(encryptedMessageBody.toString());
- callback.success();
- return;
- case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
- callback.userInputRequried((PendingIntent) result
- .getParcelableExtra(OpenPgpApi.RESULT_INTENT));
- return;
- case OpenPgpApi.RESULT_CODE_ERROR:
- callback.error((OpenPgpError) result
- .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
- return;
}
}
-
+
public long fetchKeyId(Account account, String status, String signature) {
if ((signature == null) || (api == null)) {
return 0;
@@ -130,10 +224,11 @@ public class PgpEngine {
return 0;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
- Log.d("xmppService","user interaction required");
+ Log.d("xmppService","openpgp user interaction requeried");
return 0;
case OpenPgpApi.RESULT_CODE_ERROR:
- Log.d("xmppService","pgp error");
+ Log.d("xmppService","openpgp error: "+((OpenPgpError) result
+ .getParcelableExtra(OpenPgpApi.RESULT_ERROR)).getMessage());
return 0;
}
return 0;
@@ -174,14 +269,12 @@ public class PgpEngine {
});
}
- public void hasKey(Account account, long keyId, final OnPgpEngineResult callback) {
+ public void hasKey(Contact contact, final OnPgpEngineResult callback) {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_GET_KEY);
- params.putExtra(OpenPgpApi.EXTRA_KEY_ID, keyId);
- params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid());
- InputStream is = new ByteArrayInputStream(new byte[0]);
- OutputStream os = new ByteArrayOutputStream();
- api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
+ params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
+ params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, contact.getAccount().getJid());
+ api.executeApiAsync(params, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
@@ -201,4 +294,13 @@ public class PgpEngine {
}
});
}
+
+ public PendingIntent getIntentForKey(Contact contact) {
+ Intent params = new Intent();
+ params.setAction(OpenPgpApi.ACTION_GET_KEY);
+ params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
+ params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, contact.getAccount().getJid());
+ Intent result = api.executeApi(params, null, null);
+ return (PendingIntent) result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
+ }
}
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java
index 0f4d24e5..5674f84a 100644
--- a/src/eu/siacs/conversations/entities/Conversation.java
+++ b/src/eu/siacs/conversations/entities/Conversation.java
@@ -15,7 +15,6 @@ import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
-import android.util.Log;
public class Conversation extends AbstractEntity {
@@ -56,7 +55,8 @@ public class Conversation extends AbstractEntity {
private transient String otrFingerprint = null;
- public int nextMessageEncryption = Message.ENCRYPTION_NONE;
+ private int nextMessageEncryption = -1;
+ private String nextMessage;
private transient MucOptions mucOptions = null;
@@ -237,7 +237,6 @@ public class Conversation extends AbstractEntity {
}
return this.otrSession;
} catch (OtrException e) {
- Log.d("xmppServic", "couldnt start otr");
return null;
}
}
@@ -320,4 +319,32 @@ public class Conversation extends AbstractEntity {
public String getNextPresence() {
return this.nextPresence;
}
+
+ public int getLatestEncryption() {
+ int latestEncryption = this.getLatestMessage().getEncryption();
+ if ((latestEncryption == Message.ENCRYPTION_DECRYPTED) || (latestEncryption == Message.ENCRYPTION_DECRYPTION_FAILED)) {
+ return Message.ENCRYPTION_PGP;
+ } else {
+ return latestEncryption;
+ }
+ }
+
+ public int getNextEncryption() {
+ if (this.nextMessageEncryption == -1) {
+ return this.getLatestEncryption();
+ }
+ return this.nextMessageEncryption;
+ }
+
+ public void setNextEncryption(int encryption) {
+ this.nextMessageEncryption = encryption;
+ }
+
+ public String getNextMessage() {
+ return this.nextMessage;
+ }
+
+ public void setNextMessage(String message) {
+ this.nextMessage = message;
+ }
}
diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java
index 49ae0265..33f7a8d4 100644
--- a/src/eu/siacs/conversations/entities/Message.java
+++ b/src/eu/siacs/conversations/entities/Message.java
@@ -1,7 +1,9 @@
package eu.siacs.conversations.entities;
+import eu.siacs.conversations.R;
import eu.siacs.conversations.xmpp.jingle.JingleConnection;
import android.content.ContentValues;
+import android.content.Context;
import android.database.Cursor;
public class Message extends AbstractEntity {
@@ -17,7 +19,6 @@ public class Message extends AbstractEntity {
public static final int STATUS_SEND = 2;
public static final int STATUS_SEND_FAILED = 3;
public static final int STATUS_SEND_REJECTED = 4;
- public static final int STATUS_PREPARING = 5;
public static final int STATUS_OFFERED = 6;
public static final int ENCRYPTION_NONE = 0;
@@ -104,6 +105,20 @@ public class Message extends AbstractEntity {
public String getBody() {
return body;
}
+
+ public String getReadableBody(Context context) {
+ if ((encryption == ENCRYPTION_PGP)&&(type == TYPE_TEXT)) {
+ return ""+context.getText(R.string.encrypted_message_received);
+ } else if ((encryption == ENCRYPTION_OTR)&&(type == TYPE_IMAGE)) {
+ return ""+context.getText(R.string.encrypted_image_received);
+ } else if (encryption == ENCRYPTION_DECRYPTION_FAILED) {
+ return ""+context.getText(R.string.decryption_failed);
+ } else if (type == TYPE_IMAGE) {
+ return ""+context.getText(R.string.image_file);
+ } else {
+ return body.trim();
+ }
+ }
public long getTimeSent() {
return timeSent;
diff --git a/src/eu/siacs/conversations/persistance/FileBackend.java b/src/eu/siacs/conversations/persistance/FileBackend.java
index c451b906..868e2398 100644
--- a/src/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/eu/siacs/conversations/persistance/FileBackend.java
@@ -47,13 +47,22 @@ public class FileBackend {
public LruCache<String, Bitmap> getThumbnailCache() {
return thumbnailCache;
}
-
+
public JingleFile getJingleFile(Message message) {
+ return getJingleFile(message, true);
+ }
+
+ public JingleFile getJingleFile(Message message, boolean decrypted) {
Conversation conversation = message.getConversation();
String prefix = context.getFilesDir().getAbsolutePath();
String path = prefix + "/" + conversation.getAccount().getJid() + "/"
+ conversation.getContactJid();
- String filename = message.getUuid() + ".webp";
+ String filename;
+ if ((decrypted)||(message.getEncryption() == Message.ENCRYPTION_NONE)) {
+ filename = message.getUuid() + ".webp";
+ } else {
+ filename = message.getUuid() + ".webp.pgp";
+ }
return new JingleFile(path + "/" + filename);
}
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 06ba34ab..3581d189 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -47,6 +47,7 @@ import eu.siacs.conversations.xmpp.OnStatusChanged;
import eu.siacs.conversations.xmpp.OnTLSExceptionReceived;
import eu.siacs.conversations.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager;
+import eu.siacs.conversations.xmpp.jingle.JingleFile;
import eu.siacs.conversations.xmpp.jingle.OnJinglePacketReceived;
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
@@ -92,7 +93,7 @@ public class XmppConnectionService extends Service {
private JingleConnectionManager mJingleConnectionManager = new JingleConnectionManager(
this);
- public OnConversationListChangedListener convChangedListener = null;
+ private OnConversationListChangedListener convChangedListener = null;
private int convChangedListenerCount = 0;
private OnAccountListChangedListener accountChangedListener = null;
private OnTLSExceptionReceived tlsException = null;
@@ -325,7 +326,7 @@ public class XmppConnectionService extends Service {
msg = "";
}
contact.setPgpKeyId(pgp.fetchKeyId(account,msg,x.getContent()));
- Log.d("xmppService","fetched key id for "+contact.getDisplayName()+" was:"+contact.getPgpKeyId());
+ Log.d("xmppService",account.getJid()+": fetched key id for "+contact.getJid()+" was:"+contact.getPgpKeyId());
}
}
replaceContactInConversation(account,
@@ -432,7 +433,7 @@ public class XmppConnectionService extends Service {
if (this.mPgpEngine == null) {
this.mPgpEngine = new PgpEngine(new OpenPgpApi(
getApplicationContext(),
- pgpServiceConnection.getService()));
+ pgpServiceConnection.getService()),this);
}
return mPgpEngine;
} else {
@@ -445,30 +446,43 @@ public class XmppConnectionService extends Service {
return this.fileBackend;
}
- public void attachImageToConversation(final Conversation conversation,
+ public Message attachImageToConversation(final Conversation conversation,
final String presence, final Uri uri) {
+ final Message message = new Message(conversation, "",Message.ENCRYPTION_NONE);
+ message.setPresence(presence);
+ message.setType(Message.TYPE_IMAGE);
+ message.setStatus(Message.STATUS_OFFERED);
new Thread(new Runnable() {
@Override
public void run() {
- Message message = new Message(conversation, "",
- Message.ENCRYPTION_NONE);
- message.setPresence(presence);
- message.setType(Message.TYPE_IMAGE);
- message.setStatus(Message.STATUS_PREPARING);
- conversation.getMessages().add(message);
- if (convChangedListener != null) {
- convChangedListener.onConversationListChanged();
- }
getFileBackend().copyImageToPrivateStorage(message, uri);
- message.setStatus(Message.STATUS_OFFERED);
databaseBackend.createMessage(message);
+ conversation.getMessages().add(message);
if (convChangedListener != null) {
convChangedListener.onConversationListChanged();
}
sendMessage(message, null);
}
}).start();
+ return message;
+ }
+
+ public Message attachEncryptedImageToConversation(final Conversation conversation, final String presence, final Uri uri, final OnPgpEngineResult callback) {
+ Log.d(LOGTAG,"attach encrypted image");
+ final Message message = new Message(conversation, "",Message.ENCRYPTION_DECRYPTED);
+ message.setPresence(presence);
+ message.setType(Message.TYPE_IMAGE);
+ message.setStatus(Message.STATUS_OFFERED);
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ getFileBackend().copyImageToPrivateStorage(message, uri);
+ getPgpEngine().encrypt(message, callback);
+ }
+ }).start();
+ return message;
}
protected Conversation findMuc(String name, Account account) {
@@ -754,8 +768,6 @@ public class XmppConnectionService extends Service {
addToConversation = true;
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
message.getConversation().endOtrIfNeeded();
- long keyId = message.getConversation().getContact()
- .getPgpKeyId();
packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_CHAT);
packet.setFrom(message.getConversation().getAccount()
@@ -1409,12 +1421,6 @@ public class XmppConnectionService extends Service {
}).start();
}
- public void updateConversationInGui() {
- if (convChangedListener != null) {
- convChangedListener.onConversationListChanged();
- }
- }
-
public void sendConversationSubject(Conversation conversation,
String subject) {
MessagePacket packet = new MessagePacket();
@@ -1480,4 +1486,12 @@ public class XmppConnectionService extends Service {
return PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
}
+
+ public void updateUi(Conversation conversation, boolean notify) {
+ if (convChangedListener != null) {
+ convChangedListener.onConversationListChanged();
+ } else {
+ UIHelper.updateNotification(getApplicationContext(), getConversations(), conversation, notify);
+ }
+ }
}
diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 1ed3fa13..eaa9b8ee 100644
--- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -4,10 +4,14 @@ import java.math.BigInteger;
import java.util.Iterator;
import java.util.Locale;
+import org.openintents.openpgp.util.OpenPgpUtils;
+
import android.app.AlertDialog;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.IntentSender.SendIntentException;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.CommonDataKinds;
@@ -26,6 +30,7 @@ import android.widget.QuickContactBadge;
import android.widget.TextView;
import android.widget.Toast;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.utils.UIHelper;
@@ -252,17 +257,29 @@ public class ContactDetailsActivity extends XmppActivity {
key.setText(otrFingerprint);
keys.addView(view);
}
- Log.d("gultsch", "pgp key id " + contact.getPgpKeyId());
if (contact.getPgpKeyId() != 0) {
View view = (View) inflater.inflate(R.layout.contact_key, null);
TextView key = (TextView) view.findViewById(R.id.key);
TextView keyType = (TextView) view.findViewById(R.id.key_type);
keyType.setText("PGP Key ID");
- BigInteger bi = new BigInteger("" + contact.getPgpKeyId());
- StringBuilder builder = new StringBuilder(bi.toString(16)
- .toUpperCase(Locale.US));
- builder.insert(8, " ");
- key.setText(builder.toString());
+ key.setText(OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId()));
+ view.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ PgpEngine pgp = activity.xmppConnectionService.getPgpEngine();
+ if (pgp!=null) {
+ PendingIntent intent = pgp.getIntentForKey(contact);
+ if (intent!=null) {
+ try {
+ startIntentSenderForResult(intent.getIntentSender(), 0, null, 0, 0, 0);
+ } catch (SendIntentException e) {
+
+ }
+ }
+ }
+ }
+ });
keys.addView(view);
}
}
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index fc19ecc7..234730fc 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -6,21 +6,27 @@ import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
+import org.openintents.openpgp.OpenPgpError;
+
import eu.siacs.conversations.R;
+import eu.siacs.conversations.crypto.OnPgpEngineResult;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.UIHelper;
+import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
+import android.content.IntentSender.SendIntentException;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
@@ -48,6 +54,7 @@ import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.TextView;
import android.widget.ImageView;
+import android.widget.Toast;
public class ConversationActivity extends XmppActivity {
@@ -58,7 +65,10 @@ public class ConversationActivity extends XmppActivity {
public static final int REQUEST_SEND_MESSAGE = 0x75441;
public static final int REQUEST_DECRYPT_PGP = 0x76783;
- private static final int ATTACH_FILE = 0x48502;
+ private static final int REQUEST_ATTACH_FILE_DIALOG = 0x48502;
+ private static final int REQUEST_SEND_PGP_IMAGE = 0x53883;
+ private static final int REQUEST_ATTACH_FILE = 0x73824;
+ public static final int REQUEST_ENCRYPT_MESSAGE = 0x378018;
protected SlidingPaneLayout spl;
@@ -69,6 +79,8 @@ public class ConversationActivity extends XmppActivity {
private boolean paneShouldBeOpen = true;
private boolean useSubject = true;
private ArrayAdapter<Conversation> listAdapter;
+
+ public Message pendingMessage = null;
private OnConversationListChangedListener onConvChanged = new OnConversationListChangedListener() {
@@ -100,6 +112,7 @@ public class ConversationActivity extends XmppActivity {
protected ConversationActivity activity = this;
private DisplayMetrics metrics;
+ private Toast prepareImageToast;
public List<Conversation> getConversationList() {
return this.conversationList;
@@ -166,20 +179,22 @@ public class ConversationActivity extends XmppActivity {
Message latestMessage = conv.getLatestMessage();
if (latestMessage.getType() == Message.TYPE_TEXT) {
- convLastMsg.setText(conv.getLatestMessage().getBody());
+ if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP)&&(latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
+ convLastMsg.setText(conv.getLatestMessage().getBody());
+ } else {
+ convLastMsg.setText(getText(R.string.encrypted_message_received));
+ }
convLastMsg.setVisibility(View.VISIBLE);
imagePreview.setVisibility(View.GONE);
} else if (latestMessage.getType() == Message.TYPE_IMAGE) {
- if ((latestMessage.getStatus() >= Message.STATUS_RECIEVED)&&(latestMessage.getStatus() != Message.STATUS_PREPARING)) {
+ if (latestMessage.getStatus() >= Message.STATUS_RECIEVED) {
convLastMsg.setVisibility(View.GONE);
imagePreview.setVisibility(View.VISIBLE);
loadBitmap(latestMessage, imagePreview);
} else {
convLastMsg.setVisibility(View.VISIBLE);
imagePreview.setVisibility(View.GONE);
- if (latestMessage.getStatus() == Message.STATUS_PREPARING) {
- convLastMsg.setText(getText(R.string.preparing_image));
- } else if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) {
+ if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) {
convLastMsg.setText(getText(R.string.image_offered_for_download));
} else if (latestMessage.getStatus() == Message.STATUS_RECIEVING) {
convLastMsg.setText(getText(R.string.receiving_image));
@@ -312,7 +327,96 @@ public class ConversationActivity extends XmppActivity {
}
return true;
}
+
+ private void attachFileDialog() {
+ selectPresence(getSelectedConversation(), new OnPresenceSelected() {
+
+ @Override
+ public void onPresenceSelected(boolean success, String presence) {
+ if (success) {
+ Intent attachFileIntent = new Intent();
+ attachFileIntent.setType("image/*");
+ attachFileIntent.setAction(Intent.ACTION_GET_CONTENT);
+ Intent chooser = Intent.createChooser(attachFileIntent, getString(R.string.attach_file));
+ startActivityForResult(chooser, REQUEST_ATTACH_FILE_DIALOG);
+ }
+ }
+ @Override
+ public void onSendPlainTextInstead() {
+
+ }
+ },"file");
+ }
+
+ private void attachFile() {
+ final Conversation conversation = getSelectedConversation();
+ if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
+ if (hasPgp()) {
+ if (conversation.getContact().getPgpKeyId()!=0) {
+ xmppConnectionService.getPgpEngine().hasKey(conversation.getContact(), new OnPgpEngineResult() {
+
+ @Override
+ public void userInputRequried(PendingIntent pi) {
+ ConversationActivity.this.runIntent(pi, REQUEST_ATTACH_FILE);
+ }
+
+ @Override
+ public void success() {
+ attachFileDialog();
+ }
+
+ @Override
+ public void error(OpenPgpError openPgpError) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ } else {
+ final ConversationFragment fragment = (ConversationFragment) getFragmentManager()
+ .findFragmentByTag("conversation");
+ if (fragment != null) {
+ fragment.showNoPGPKeyDialog(new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ conversation.setNextEncryption(Message.ENCRYPTION_NONE);
+ attachFileDialog();
+ }
+ });
+ }
+ }
+ }
+ } else if (getSelectedConversation().getNextEncryption() == Message.ENCRYPTION_NONE) {
+ attachFileDialog();
+ } else {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(getString(R.string.otr_file_transfer));
+ builder.setMessage(getString(R.string.otr_file_transfer_msg));
+ builder.setNegativeButton(getString(R.string.cancel), null);
+ if (conversation.getContact().getPgpKeyId()==0) {
+ builder.setPositiveButton(getString(R.string.send_unencrypted), new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ conversation.setNextEncryption(Message.ENCRYPTION_NONE);
+ attachFile();
+ }
+ });
+ } else {
+ builder.setPositiveButton(getString(R.string.use_pgp_encryption), new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ conversation.setNextEncryption(Message.ENCRYPTION_PGP);
+ attachFile();
+ }
+ });
+ }
+ builder.create().show();
+ }
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
@@ -320,25 +424,7 @@ public class ConversationActivity extends XmppActivity {
spl.openPane();
break;
case R.id.action_attach_file:
- selectPresence(getSelectedConversation(), new OnPresenceSelected() {
-
- @Override
- public void onPresenceSelected(boolean success, String presence) {
- if (success) {
- Intent attachFileIntent = new Intent();
- attachFileIntent.setType("image/*");
- attachFileIntent.setAction(Intent.ACTION_GET_CONTENT);
- Intent chooser = Intent.createChooser(attachFileIntent, getString(R.string.attach_file));
- startActivityForResult(chooser, ATTACH_FILE);
- }
- }
-
- @Override
- public void onSendPlainTextInstead() {
- // TODO Auto-generated method stub
-
- }
- },"file");
+ attachFile();
break;
case R.id.action_add:
startActivity(new Intent(this, ContactsActivity.class));
@@ -371,7 +457,7 @@ public class ConversationActivity extends XmppActivity {
startActivity(inviteIntent);
break;
case R.id.action_security:
- final Conversation selConv = getSelectedConversation();
+ final Conversation conversation = getSelectedConversation();
View menuItemView = findViewById(R.id.action_security);
PopupMenu popup = new PopupMenu(this, menuItemView);
final ConversationFragment fragment = (ConversationFragment) getFragmentManager()
@@ -383,19 +469,25 @@ public class ConversationActivity extends XmppActivity {
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.encryption_choice_none:
- selConv.nextMessageEncryption = Message.ENCRYPTION_NONE;
+ conversation.setNextEncryption(Message.ENCRYPTION_NONE);
item.setChecked(true);
break;
case R.id.encryption_choice_otr:
- selConv.nextMessageEncryption = Message.ENCRYPTION_OTR;
+ conversation.setNextEncryption(Message.ENCRYPTION_OTR);
item.setChecked(true);
break;
case R.id.encryption_choice_pgp:
- selConv.nextMessageEncryption = Message.ENCRYPTION_PGP;
- item.setChecked(true);
+ if (hasPgp()) {
+ if (conversation.getAccount().getKeys().has("pgp_signature")) {
+ conversation.setNextEncryption(Message.ENCRYPTION_PGP);
+ item.setChecked(true);
+ } else {
+ announcePgp(conversation.getAccount(),conversation);
+ }
+ }
break;
default:
- selConv.nextMessageEncryption = Message.ENCRYPTION_NONE;
+ conversation.setNextEncryption(Message.ENCRYPTION_NONE);
break;
}
fragment.updateChatMsgHint();
@@ -403,7 +495,7 @@ public class ConversationActivity extends XmppActivity {
}
});
popup.inflate(R.menu.encryption_choices);
- switch (selConv.nextMessageEncryption) {
+ switch (conversation.getNextEncryption()) {
case Message.ENCRYPTION_NONE:
popup.getMenu().findItem(R.id.encryption_choice_none)
.setChecked(true);
@@ -416,10 +508,6 @@ public class ConversationActivity extends XmppActivity {
popup.getMenu().findItem(R.id.encryption_choice_pgp)
.setChecked(true);
break;
- case Message.ENCRYPTION_DECRYPTED:
- popup.getMenu().findItem(R.id.encryption_choice_pgp)
- .setChecked(true);
- break;
default:
popup.getMenu().findItem(R.id.encryption_choice_none)
.setChecked(true);
@@ -580,14 +668,57 @@ public class ConversationActivity extends XmppActivity {
if (selectedFragment != null) {
selectedFragment.hidePgpPassphraseBox();
}
- } else if (requestCode == ATTACH_FILE) {
- Conversation conversation = getSelectedConversation();
+ } else if (requestCode == REQUEST_ATTACH_FILE_DIALOG) {
+ prepareImageToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_image), Toast.LENGTH_LONG);
+ final Conversation conversation = getSelectedConversation();
String presence = conversation.getNextPresence();
- xmppConnectionService.attachImageToConversation(conversation, presence, data.getData());
+ if (conversation.getNextEncryption() == Message.ENCRYPTION_NONE) {
+ prepareImageToast.show();
+ xmppConnectionService.attachImageToConversation(conversation, presence, data.getData());
+ } else if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
+ prepareImageToast.show();
+ attachPgpFile(conversation,data.getData());
+ } else {
+ Log.d(LOGTAG,"unknown next message encryption: "+conversation.getNextEncryption());
+ }
+ } else if (requestCode == REQUEST_SEND_PGP_IMAGE) {
+ } else if (requestCode == REQUEST_ATTACH_FILE) {
+ attachFile();
+ } else if (requestCode == REQUEST_ANNOUNCE_PGP) {
+ announcePgp(getSelectedConversation().getAccount(),getSelectedConversation());
+ } else if (requestCode == REQUEST_ENCRYPT_MESSAGE) {
+ encryptTextMessage();
+ } else {
+ Log.d(LOGTAG,"unknown result code:"+requestCode);
}
}
}
+
+ private void attachPgpFile(Conversation conversation, Uri uri) {
+ String presence = conversation.getNextPresence();
+ pendingMessage = xmppConnectionService.attachEncryptedImageToConversation(conversation, presence, uri, new OnPgpEngineResult() {
+
+ @Override
+ public void userInputRequried(PendingIntent pi) {
+ ConversationActivity.this.runIntent(pi, ConversationActivity.REQUEST_SEND_PGP_IMAGE);
+ }
+
+ @Override
+ public void success() {
+ pendingMessage.getConversation().getMessages().add(pendingMessage);
+ xmppConnectionService.databaseBackend.createMessage(pendingMessage);
+ xmppConnectionService.sendMessage(pendingMessage, null);
+ xmppConnectionService.updateUi(pendingMessage.getConversation(), false);
+ pendingMessage = null;
+ }
+
+ @Override
+ public void error(OpenPgpError openPgpError) {
+ Log.d(LOGTAG,"pgp error"+openPgpError.getMessage());
+ }
+ });
+ }
public void updateConversationList() {
conversationList.clear();
@@ -690,6 +821,15 @@ public class ConversationActivity extends XmppActivity {
builder.create().show();
}
+ public void runIntent(PendingIntent pi, int requestCode) {
+ try {
+ this.startIntentSenderForResult(pi.getIntentSender(),requestCode, null, 0,
+ 0, 0);
+ } catch (SendIntentException e1) {
+ Log.d("xmppService","failed to start intent to send message");
+ }
+ }
+
class BitmapWorkerTask extends AsyncTask<Message, Void, Bitmap> {
private final WeakReference<ImageView> imageViewReference;
@@ -783,4 +923,36 @@ public class ConversationActivity extends XmppActivity {
return bitmapWorkerTaskReference.get();
}
}
+
+ public void encryptTextMessage() {
+ xmppConnectionService.getPgpEngine().encrypt(this.pendingMessage, new OnPgpEngineResult() {
+
+ @Override
+ public void userInputRequried(
+ PendingIntent pi) {
+ activity.runIntent(
+ pi,
+ ConversationActivity.REQUEST_SEND_MESSAGE);
+ }
+
+ @Override
+ public void success() {
+ xmppConnectionService.sendMessage(pendingMessage, null);
+ pendingMessage = null;
+ ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager()
+ .findFragmentByTag("conversation");
+ if (selectedFragment != null) {
+ selectedFragment.clearInputField();
+ }
+ }
+
+ @Override
+ public void error(
+ OpenPgpError openPgpError) {
+ // TODO Auto-generated method
+ // stub
+
+ }
+ });
+ }
}
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index c2373cf1..6850ac54 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -35,6 +35,8 @@ import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.text.Editable;
+import android.text.Selection;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
@@ -67,7 +69,7 @@ public class ConversationFragment extends Fragment {
private String pastedText = null;
protected Bitmap selfBitmap;
-
+
private boolean useSubject = true;
private IntentSender askForPassphraseIntent = null;
@@ -79,10 +81,10 @@ public class ConversationFragment extends Fragment {
if (chatMsg.getText().length() < 1)
return;
Message message = new Message(conversation, chatMsg.getText()
- .toString(), conversation.nextMessageEncryption);
- if (conversation.nextMessageEncryption == Message.ENCRYPTION_OTR) {
+ .toString(), conversation.getNextEncryption());
+ if (conversation.getNextEncryption() == Message.ENCRYPTION_OTR) {
sendOtrMessage(message);
- } else if (conversation.nextMessageEncryption == Message.ENCRYPTION_PGP) {
+ } else if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
sendPgpMessage(message);
} else {
sendPlainTextMessage(message);
@@ -129,7 +131,7 @@ public class ConversationFragment extends Fragment {
if (conversation.getMode() == Conversation.MODE_MULTI) {
chatMsg.setHint(getString(R.string.send_message_to_conference));
} else {
- switch (conversation.nextMessageEncryption) {
+ switch (conversation.getNextEncryption()) {
case Message.ENCRYPTION_NONE:
chatMsg.setHint(getString(R.string.send_plain_text_message));
break;
@@ -139,9 +141,6 @@ public class ConversationFragment extends Fragment {
case Message.ENCRYPTION_PGP:
chatMsg.setHint(getString(R.string.send_pgp_message));
break;
- case Message.ENCRYPTION_DECRYPTED:
- chatMsg.setHint(getString(R.string.send_pgp_message));
- break;
default:
break;
}
@@ -153,17 +152,13 @@ public class ConversationFragment extends Fragment {
ViewGroup container, Bundle savedInstanceState) {
final DisplayMetrics metrics = getResources().getDisplayMetrics();
-
+
this.inflater = inflater;
final View view = inflater.inflate(R.layout.fragment_conversation,
container, false);
chatMsg = (EditText) view.findViewById(R.id.textinput);
-
- if (pastedText!=null) {
- chatMsg.setText(pastedText);
- }
-
+
ImageButton sendButton = (ImageButton) view
.findViewById(R.id.textSendButton);
sendButton.setOnClickListener(this.sendMsgListener);
@@ -197,6 +192,155 @@ public class ConversationFragment extends Fragment {
}
}
+ private void displayStatus(ViewHolder viewHolder, Message message) {
+ String filesize = null;
+ String info = null;
+ boolean error = false;
+ if (message.getType() == Message.TYPE_IMAGE) {
+ String[] fileParams = message.getBody().split(",");
+ long size = Long.parseLong(fileParams[0]);
+ filesize = size / 1024 + " KB";
+ }
+ switch (message.getStatus()) {
+ case Message.STATUS_UNSEND:
+ info = getString(R.string.sending);
+ break;
+ case Message.STATUS_OFFERED:
+ info = getString(R.string.offering);
+ break;
+ case Message.STATUS_SEND_FAILED:
+ info = getString(R.string.send_failed);
+ error = true;
+ break;
+ case Message.STATUS_SEND_REJECTED:
+ info = getString(R.string.send_rejected);
+ error = true;
+ break;
+ default:
+ if ((message.getConversation().getMode() == Conversation.MODE_MULTI)
+ && (message.getStatus() <= Message.STATUS_RECIEVED)) {
+ info = message.getCounterpart();
+ }
+ break;
+ }
+ if (error) {
+ viewHolder.time.setTextColor(0xFFe92727);
+ } else {
+ viewHolder.time.setTextColor(0xFF8e8e8e);
+ }
+ if (message.getEncryption() == Message.ENCRYPTION_NONE) {
+ viewHolder.indicator.setVisibility(View.GONE);
+ } else {
+ viewHolder.indicator.setVisibility(View.VISIBLE);
+ }
+
+ String formatedTime = UIHelper.readableTimeDifference(message
+ .getTimeSent());
+ if (message.getStatus() <= Message.STATUS_RECIEVED) {
+ if ((filesize != null) && (info != null)) {
+ viewHolder.time.setText(filesize + " \u00B7 " + info);
+ } else if ((filesize == null) && (info != null)) {
+ viewHolder.time.setText(formatedTime + " \u00B7 "
+ + info);
+ } else if ((filesize != null) && (info == null)) {
+ viewHolder.time.setText(formatedTime + " \u00B7 "
+ + filesize);
+ } else {
+ viewHolder.time.setText(formatedTime);
+ }
+ } else {
+ if ((filesize != null) && (info != null)) {
+ viewHolder.time.setText(filesize + " \u00B7 " + info);
+ } else if ((filesize == null) && (info != null)) {
+ viewHolder.time.setText(info + " \u00B7 "
+ + formatedTime);
+ } else if ((filesize != null) && (info == null)) {
+ viewHolder.time.setText(filesize + " \u00B7 "
+ + formatedTime);
+ } else {
+ viewHolder.time.setText(formatedTime);
+ }
+ }
+ }
+
+ private void displayInfoMessage(ViewHolder viewHolder, int r) {
+ viewHolder.download_button.setVisibility(View.GONE);
+ viewHolder.image.setVisibility(View.GONE);
+ viewHolder.messageBody.setVisibility(View.VISIBLE);
+ viewHolder.messageBody.setText(getString(r));
+ viewHolder.messageBody.setTextColor(0xff33B5E5);
+ viewHolder.messageBody.setTypeface(null, Typeface.ITALIC);
+ }
+
+ private void displayDecryptionFailed(ViewHolder viewHolder) {
+ viewHolder.download_button.setVisibility(View.GONE);
+ viewHolder.image.setVisibility(View.GONE);
+ viewHolder.messageBody.setVisibility(View.VISIBLE);
+ viewHolder.messageBody
+ .setText(getString(R.string.decryption_failed));
+ viewHolder.messageBody.setTextColor(0xFFe92727);
+ viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
+ }
+
+ private void displayTextMessage(ViewHolder viewHolder, String text) {
+ if (viewHolder.download_button != null) {
+ viewHolder.download_button.setVisibility(View.GONE);
+ }
+ viewHolder.image.setVisibility(View.GONE);
+ viewHolder.messageBody.setVisibility(View.VISIBLE);
+ if (text != null) {
+ viewHolder.messageBody.setText(text.trim());
+ } else {
+ viewHolder.messageBody.setText("");
+ }
+ viewHolder.messageBody.setTextColor(0xff333333);
+ viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
+ }
+
+ private void displayImageMessage(ViewHolder viewHolder,
+ final Message message) {
+ if (viewHolder.download_button != null) {
+ viewHolder.download_button.setVisibility(View.GONE);
+ }
+ viewHolder.messageBody.setVisibility(View.GONE);
+ viewHolder.image.setVisibility(View.VISIBLE);
+ String[] fileParams = message.getBody().split(",");
+ if (fileParams.length == 3) {
+ double target = metrics.density * 288;
+ int w = Integer.parseInt(fileParams[1]);
+ int h = Integer.parseInt(fileParams[2]);
+ int scalledW;
+ int scalledH;
+ if (w <= h) {
+ scalledW = (int) (w / ((double) h / target));
+ scalledH = (int) target;
+ } else {
+ scalledW = (int) target;
+ scalledH = (int) (h / ((double) w / target));
+ }
+ viewHolder.image
+ .setLayoutParams(new LinearLayout.LayoutParams(
+ scalledW, scalledH));
+ }
+ activity.loadBitmap(message, viewHolder.image);
+ viewHolder.image.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Uri uri = Uri
+ .parse("content://eu.siacs.conversations.images/"
+ + message.getConversationUuid()
+ + "/"
+ + message.getUuid());
+ Log.d("xmppService",
+ "staring intent with uri:" + uri.toString());
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setDataAndType(uri, "image/*");
+ startActivity(intent);
+ }
+ });
+ }
+
@Override
public View getView(int position, View view, ViewGroup parent) {
final Message item = getItem(position);
@@ -217,14 +361,18 @@ public class ConversationFragment extends Fragment {
R.layout.message_recieved, null);
viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo);
-
- viewHolder.download_button = (Button) view.findViewById(R.id.download_button);
-
+
+ viewHolder.download_button = (Button) view
+ .findViewById(R.id.download_button);
+
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
- viewHolder.contact_picture.setImageBitmap(mBitmapCache
- .get(item.getConversation().getName(useSubject), item
- .getConversation().getContact(),
+ viewHolder.contact_picture
+ .setImageBitmap(mBitmapCache.get(
+ item.getConversation().getName(
+ useSubject), item
+ .getConversation()
+ .getContact(),
getActivity()
.getApplicationContext()));
@@ -234,8 +382,10 @@ public class ConversationFragment extends Fragment {
viewHolder = null;
break;
}
- viewHolder.indicator = (ImageView) view.findViewById(R.id.security_indicator);
- viewHolder.image = (ImageView) view.findViewById(R.id.message_image);
+ viewHolder.indicator = (ImageView) view
+ .findViewById(R.id.security_indicator);
+ viewHolder.image = (ImageView) view
+ .findViewById(R.id.message_image);
viewHolder.messageBody = (TextView) view
.findViewById(R.id.message_body);
viewHolder.time = (TextView) view
@@ -244,156 +394,70 @@ public class ConversationFragment extends Fragment {
} else {
viewHolder = (ViewHolder) view.getTag();
}
-
+
if (type == RECIEVED) {
if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
if (item.getCounterpart() != null) {
- viewHolder.contact_picture.setImageBitmap(mBitmapCache
- .get(item.getCounterpart(), null,
+ viewHolder.contact_picture
+ .setImageBitmap(mBitmapCache.get(item
+ .getCounterpart(), null,
getActivity()
.getApplicationContext()));
} else {
- viewHolder.contact_picture.setImageBitmap(mBitmapCache
- .get(item.getConversation().getName(useSubject),
- null, getActivity()
+ viewHolder.contact_picture
+ .setImageBitmap(mBitmapCache.get(
+ item.getConversation().getName(
+ useSubject), null,
+ getActivity()
.getApplicationContext()));
}
}
}
-
- if (item.getEncryption() == Message.ENCRYPTION_NONE) {
- viewHolder.indicator.setVisibility(View.GONE);
- } else {
- viewHolder.indicator.setVisibility(View.VISIBLE);
- }
-
- String filesize = "";
-
+
if (item.getType() == Message.TYPE_IMAGE) {
- String[] fileParams = item.getBody().split(",");
- if ((fileParams.length>=1)&&(item.getStatus() != Message.STATUS_PREPARING)) {
- long size = Long.parseLong(fileParams[0]);
- filesize = size/1024+" KB \u00B7 ";
- }
- if ((item.getStatus() == Message.STATUS_PREPARING)||(item.getStatus() == Message.STATUS_RECIEVING)) {
- viewHolder.image.setVisibility(View.GONE);
- viewHolder.messageBody.setVisibility(View.VISIBLE);
- if (item.getStatus() == Message.STATUS_PREPARING) {
- viewHolder.messageBody.setText(getString(R.string.preparing_image));
- } else if (item.getStatus() == Message.STATUS_RECIEVING) {
- viewHolder.download_button.setVisibility(View.GONE);
- viewHolder.messageBody.setText(getString(R.string.receiving_image));
- }
- viewHolder.messageBody.setTextColor(0xff33B5E5);
- viewHolder.messageBody.setTypeface(null,Typeface.ITALIC);
+ if (item.getStatus() == Message.STATUS_RECIEVING) {
+ displayInfoMessage(viewHolder, R.string.receiving_image);
} else if (item.getStatus() == Message.STATUS_RECEIVED_OFFER) {
viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.GONE);
viewHolder.download_button.setVisibility(View.VISIBLE);
- viewHolder.download_button.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- JingleConnection connection = item.getJingleConnection();
- if (connection!=null) {
- connection.accept();
- } else {
- Log.d("xmppService","attached jingle connection was null");
- }
- }
- });
+ viewHolder.download_button
+ .setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ JingleConnection connection = item
+ .getJingleConnection();
+ if (connection != null) {
+ connection.accept();
+ } else {
+ Log.d("xmppService",
+ "attached jingle connection was null");
+ }
+ }
+ });
+ } else if ((item.getEncryption() == Message.ENCRYPTION_DECRYPTED)
+ || (item.getEncryption() == Message.ENCRYPTION_NONE)) {
+ displayImageMessage(viewHolder, item);
+ } else if (item.getEncryption() == Message.ENCRYPTION_PGP) {
+ displayInfoMessage(viewHolder,
+ R.string.encrypted_message);
} else {
- viewHolder.messageBody.setVisibility(View.GONE);
- viewHolder.image.setVisibility(View.VISIBLE);
- if (fileParams.length==3) {
- double target = metrics.density * 288;
- int w = Integer.parseInt(fileParams[1]);
- int h = Integer.parseInt(fileParams[2]);
- int scalledW;
- int scalledH;
- if (w <= h) {
- scalledW = (int) (w / ((double) h / target));
- scalledH = (int) target;
- } else {
- scalledW = (int) target;
- scalledH = (int) (h / ((double) w / target));
- }
- viewHolder.image.setLayoutParams(new LinearLayout.LayoutParams(scalledW, scalledH));
- } else {
- Log.d("xmppService","message body has less than 3 params");
- }
- activity.loadBitmap(item, viewHolder.image);
- viewHolder.image.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- Uri uri = Uri.parse("content://eu.siacs.conversations.images/"+item.getConversationUuid()+"/"+item.getUuid());
- Log.d("xmppService","staring intent with uri:"+uri.toString());
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(uri, "image/*");
- startActivity(intent);
- }
- });
+ displayDecryptionFailed(viewHolder);
}
} else {
- viewHolder.image.setVisibility(View.GONE);
- viewHolder.messageBody.setVisibility(View.VISIBLE);
- String body = item.getBody();
- if (body != null) {
- if (item.getEncryption() == Message.ENCRYPTION_PGP) {
- viewHolder.messageBody
- .setText(getString(R.string.encrypted_message));
- viewHolder.messageBody.setTextColor(0xff33B5E5);
- viewHolder.messageBody.setTypeface(null,
- Typeface.ITALIC);
- } else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
- viewHolder.messageBody.setText(getString(R.string.decryption_failed));
- viewHolder.messageBody.setTextColor(0xFFe92727);
- viewHolder.messageBody.setTypeface(null,Typeface.NORMAL);
- } else {
- viewHolder.messageBody.setText(body.trim());
- viewHolder.messageBody.setTextColor(0xff333333);
- viewHolder.messageBody.setTypeface(null,
- Typeface.NORMAL);
- }
- }
- }
- switch (item.getStatus()) {
- case Message.STATUS_UNSEND:
- viewHolder.time.setTypeface(null, Typeface.ITALIC);
- viewHolder.time.setTextColor(0xFF8e8e8e);
- viewHolder.time.setText(filesize+"sending\u2026");
- break;
- case Message.STATUS_OFFERED:
- viewHolder.time.setTypeface(null, Typeface.ITALIC);
- viewHolder.time.setTextColor(0xFF8e8e8e);
- viewHolder.time.setText(filesize+"offering\u2026");
- break;
- case Message.STATUS_SEND_FAILED:
- viewHolder.time.setText(filesize+getString(R.string.send_failed) + " \u00B7 " + UIHelper.readableTimeDifference(item
- .getTimeSent()));
- viewHolder.time.setTextColor(0xFFe92727);
- viewHolder.time.setTypeface(null,Typeface.NORMAL);
- break;
- case Message.STATUS_SEND_REJECTED:
- viewHolder.time.setText(filesize+getString(R.string.send_rejected));
- viewHolder.time.setTextColor(0xFFe92727);
- viewHolder.time.setTypeface(null,Typeface.NORMAL);
- break;
- default:
- viewHolder.time.setTypeface(null, Typeface.NORMAL);
- viewHolder.time.setTextColor(0xFF8e8e8e);
- if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
- viewHolder.time.setText(filesize+UIHelper
- .readableTimeDifference(item.getTimeSent()));
+ if (item.getEncryption() == Message.ENCRYPTION_PGP) {
+ displayInfoMessage(viewHolder,
+ R.string.encrypted_message);
+ } else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
+ displayDecryptionFailed(viewHolder);
} else {
- viewHolder.time.setText(item.getCounterpart()
- + " \u00B7 "
- + UIHelper.readableTimeDifference(item
- .getTimeSent()));
+ displayTextMessage(viewHolder, item.getBody());
}
- break;
}
+
+ displayStatus(viewHolder, item);
+
return view;
}
};
@@ -417,43 +481,56 @@ public class ConversationFragment extends Fragment {
public void onStart() {
super.onStart();
this.activity = (ConversationActivity) getActivity();
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
+ SharedPreferences preferences = PreferenceManager
+ .getDefaultSharedPreferences(activity);
this.useSubject = preferences.getBoolean("use_subject_in_muc", true);
if (activity.xmppConnectionServiceBound) {
this.onBackendConnected();
}
}
+ @Override
+ public void onStop() {
+ super.onStop();
+ if (this.conversation!=null) {
+ this.conversation.setNextMessage(chatMsg.getText().toString());
+ }
+ }
+
public void onBackendConnected() {
this.conversation = activity.getSelectedConversation();
if (this.conversation == null) {
return;
}
+ if (this.pastedText == null) {
+ this.chatMsg.setText(conversation.getNextMessage());
+ } else {
+ chatMsg.setText(conversation.getNextMessage() + " " + pastedText);
+ pastedText = null;
+ }
+ int position = chatMsg.length();
+ Editable etext = chatMsg.getText();
+ Selection.setSelection(etext, position);
this.selfBitmap = findSelfPicture();
updateMessages();
- // rendering complete. now go tell activity to close pane
if (activity.getSlidingPaneLayout().isSlideable()) {
if (!activity.shouldPaneBeOpen()) {
activity.getSlidingPaneLayout().closePane();
activity.getActionBar().setDisplayHomeAsUpEnabled(true);
- activity.getActionBar().setTitle(conversation.getName(useSubject));
+ activity.getActionBar().setTitle(
+ conversation.getName(useSubject));
activity.invalidateOptionsMenu();
}
}
- if (queuedPqpMessage != null) {
- this.conversation.nextMessageEncryption = Message.ENCRYPTION_PGP;
- Message message = new Message(conversation, queuedPqpMessage,
- Message.ENCRYPTION_PGP);
- sendPgpMessage(message);
- }
if (conversation.getMode() == Conversation.MODE_MULTI) {
activity.xmppConnectionService
.setOnRenameListener(new OnRenameListener() {
@Override
public void onRename(final boolean success) {
- activity.xmppConnectionService.updateConversation(conversation);
+ activity.xmppConnectionService
+ .updateConversation(conversation);
getActivity().runOnUiThread(new Runnable() {
@Override
@@ -464,7 +541,8 @@ public class ConversationFragment extends Fragment {
getString(R.string.your_nick_has_been_changed),
Toast.LENGTH_SHORT).show();
} else {
- Toast.makeText(getActivity(),
+ Toast.makeText(
+ getActivity(),
getString(R.string.nick_in_use),
Toast.LENGTH_SHORT).show();
}
@@ -474,43 +552,44 @@ public class ConversationFragment extends Fragment {
});
}
}
-
+
private void decryptMessage(final Message message) {
- Log.d("xmppService","called to decrypt");
PgpEngine engine = activity.xmppConnectionService.getPgpEngine();
- if (engine!=null) {
- engine.decrypt(message,new OnPgpEngineResult() {
-
+ if (engine != null) {
+ engine.decrypt(message, new OnPgpEngineResult() {
+
@Override
public void userInputRequried(PendingIntent pi) {
askForPassphraseIntent = pi.getIntentSender();
pgpInfo.setVisibility(View.VISIBLE);
}
-
+
@Override
public void success() {
- Log.d("xmppService","successfully decrypted");
- activity.xmppConnectionService.databaseBackend.updateMessage(message);
+ activity.xmppConnectionService.databaseBackend
+ .updateMessage(message);
updateMessages();
}
-
+
@Override
public void error(OpenPgpError openPgpError) {
- Log.d("xmppService","decryption error"+openPgpError.getMessage());
+ Log.d("xmppService",
+ "decryption error" + openPgpError.getMessage());
message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED);
- //updateMessages();
+ // updateMessages();
}
});
} else {
- Log.d("xmppService","engine was null");
+ pgpInfo.setVisibility(View.VISIBLE);
}
}
-
+
public void updateMessages() {
ConversationActivity activity = (ConversationActivity) getActivity();
if (this.conversation != null) {
for (Message message : this.conversation.getMessages()) {
- if (message.getEncryption() == Message.ENCRYPTION_PGP) {
+ if ((message.getEncryption() == Message.ENCRYPTION_PGP)
+ && (message.getStatus() == Message.STATUS_RECIEVED)) {
decryptMessage(message);
break;
}
@@ -520,14 +599,7 @@ public class ConversationFragment extends Fragment {
this.messageListAdapter.notifyDataSetChanged();
if (conversation.getMode() == Conversation.MODE_SINGLE) {
if (messageList.size() >= 1) {
- int latestEncryption = this.conversation.getLatestMessage()
- .getEncryption();
- if ((latestEncryption == Message.ENCRYPTION_DECRYPTED)||(latestEncryption == Message.ENCRYPTION_DECRYPTION_FAILED)) {
- conversation.nextMessageEncryption = Message.ENCRYPTION_PGP;
- } else {
- conversation.nextMessageEncryption = latestEncryption;
- }
- makeFingerprintWarning(latestEncryption);
+ makeFingerprintWarning(conversation.getLatestEncryption());
}
} else {
if (conversation.getMucOptions().getError() != 0) {
@@ -594,88 +666,61 @@ public class ConversationFragment extends Fragment {
}
protected void sendPgpMessage(final Message message) {
- ConversationActivity activity = (ConversationActivity) getActivity();
+ activity.pendingMessage = message;
+ final ConversationActivity activity = (ConversationActivity) getActivity();
final XmppConnectionService xmppService = activity.xmppConnectionService;
final Contact contact = message.getConversation().getContact();
- final Account account = message.getConversation().getAccount();
if (activity.hasPgp()) {
if (contact.getPgpKeyId() != 0) {
- xmppService.getPgpEngine().hasKey(account,contact.getPgpKeyId(), new OnPgpEngineResult() {
-
- @Override
- public void userInputRequried(PendingIntent pi) {
- Log.d("xmppService","hasKey returned user input required");
- try {
- getActivity().startIntentSenderForResult(pi.getIntentSender(),
- ConversationActivity.REQUEST_SEND_MESSAGE, null, 0,
- 0, 0);
- } catch (SendIntentException e1) {
- Log.d("xmppService","failed to start intent to send message");
- }
- }
-
- @Override
- public void success() {
- Log.d("xmppService","hasKey returned success");
- xmppService.getPgpEngine().encrypt(account, contact.getPgpKeyId(), message,new OnPgpEngineResult() {
-
+ xmppService.getPgpEngine().hasKey(contact,
+ new OnPgpEngineResult() {
+
@Override
public void userInputRequried(PendingIntent pi) {
- try {
- getActivity().startIntentSenderForResult(pi.getIntentSender(),
- ConversationActivity.REQUEST_SEND_MESSAGE, null, 0,
- 0, 0);
- } catch (SendIntentException e1) {
- Log.d("xmppService","failed to start intent to send message");
- }
+ activity.runIntent(
+ pi,
+ ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
}
-
+
@Override
public void success() {
- xmppService.sendMessage(message, null);
- chatMsg.setText("");
+ activity.encryptTextMessage();
}
-
+
@Override
public void error(OpenPgpError openPgpError) {
- // TODO Auto-generated method stub
-
+ Log.d("xmppService", "openpgp error"
+ + openPgpError.getMessage());
}
});
- }
-
+
+ } else {
+ showNoPGPKeyDialog(new DialogInterface.OnClickListener() {
+
@Override
- public void error(OpenPgpError openPgpError) {
- Log.d("xmppService","openpgp error"+openPgpError.getMessage());
+ public void onClick(DialogInterface dialog,
+ int which) {
+ conversation
+ .setNextEncryption(Message.ENCRYPTION_NONE);
+ message.setEncryption(Message.ENCRYPTION_NONE);
+ xmppService.sendMessage(message, null);
+ chatMsg.setText("");
}
});
-
-
-
-
- } else {
- AlertDialog.Builder builder = new AlertDialog.Builder(
- getActivity());
- builder.setTitle("No openPGP key found");
- builder.setIconAttribute(android.R.attr.alertDialogIcon);
- builder.setMessage("There is no openPGP key associated with this contact");
- builder.setNegativeButton("Cancel", null);
- builder.setPositiveButton("Send plain text",
- new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- conversation.nextMessageEncryption = Message.ENCRYPTION_NONE;
- message.setEncryption(Message.ENCRYPTION_NONE);
- xmppService.sendMessage(message, null);
- chatMsg.setText("");
- }
- });
- builder.create().show();
}
}
}
+
+ public void showNoPGPKeyDialog(DialogInterface.OnClickListener listener) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(
+ getActivity());
+ builder.setTitle(getString(R.string.no_pgp_key));
+ builder.setIconAttribute(android.R.attr.alertDialogIcon);
+ builder.setMessage(getText(R.string.contact_has_no_pgp_key));
+ builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setPositiveButton(getString(R.string.send_unencrypted),listener);
+ builder.create().show();
+ }
protected void sendOtrMessage(final Message message) {
ConversationActivity activity = (ConversationActivity) getActivity();
@@ -684,23 +729,25 @@ public class ConversationFragment extends Fragment {
activity.xmppConnectionService.sendMessage(message, null);
chatMsg.setText("");
} else {
- activity.selectPresence(message.getConversation(), new OnPresenceSelected() {
-
- @Override
- public void onPresenceSelected(boolean success, String presence) {
- if (success) {
- xmppService.sendMessage(message,presence);
- chatMsg.setText("");
- }
- }
+ activity.selectPresence(message.getConversation(),
+ new OnPresenceSelected() {
- @Override
- public void onSendPlainTextInstead() {
- message.setEncryption(Message.ENCRYPTION_NONE);
- xmppService.sendMessage(message,null);
- chatMsg.setText("");
- }
- },"otr");
+ @Override
+ public void onPresenceSelected(boolean success,
+ String presence) {
+ if (success) {
+ xmppService.sendMessage(message, presence);
+ chatMsg.setText("");
+ }
+ }
+
+ @Override
+ public void onSendPlainTextInstead() {
+ message.setEncryption(Message.ENCRYPTION_NONE);
+ xmppService.sendMessage(message, null);
+ chatMsg.setText("");
+ }
+ }, "otr");
}
}
@@ -724,8 +771,9 @@ public class ConversationFragment extends Fragment {
return bitmaps.get(name);
} else {
Bitmap bm;
- if (contact != null){
- bm = UIHelper.getContactPicture(contact, 48, context, false);
+ if (contact != null) {
+ bm = UIHelper
+ .getContactPicture(contact, 48, context, false);
} else {
bm = UIHelper.getContactPicture(name, 48, context, false);
}
@@ -735,71 +783,11 @@ public class ConversationFragment extends Fragment {
}
}
- /*class DecryptMessage extends AsyncTask<Message, Void, Boolean> {
-
- @Override
- protected Boolean doInBackground(Message... params) {
- final ConversationActivity activity = (ConversationActivity) getActivity();
- askForPassphraseIntent = null;
- for (int i = 0; i < params.length; ++i) {
- if (params[i].getEncryption() == Message.ENCRYPTION_PGP) {
- String body = params[i].getBody();
- String decrypted = null;
- if (activity == null) {
- return false;
- } else if (!activity.xmppConnectionServiceBound) {
- return false;
- }
- try {
- decrypted = activity.xmppConnectionService
- .getPgpEngine().decrypt(conversation.getAccount(),body);
- } catch (UserInputRequiredException e) {
- askForPassphraseIntent = e.getPendingIntent()
- .getIntentSender();
- activity.runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- pgpInfo.setVisibility(View.VISIBLE);
- }
- });
-
- return false;
-
- } catch (OpenPgpException e) {
- Log.d("gultsch", "error decrypting pgp");
- }
- if (decrypted != null) {
- params[i].setBody(decrypted);
- params[i].setEncryption(Message.ENCRYPTION_DECRYPTED);
- activity.xmppConnectionService.updateMessage(params[i]);
- }
- if (activity != null) {
- activity.runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- messageListAdapter.notifyDataSetChanged();
- }
- });
- }
- }
- if (activity != null) {
- activity.runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- activity.updateConversationList();
- }
- });
- }
- }
- return true;
- }
-
- }*/
-
public void setText(String text) {
this.pastedText = text;
}
+
+ public void clearInputField() {
+ this.chatMsg.setText("");
+ }
}
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index db0a72b6..0a1cb5cd 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -38,8 +38,6 @@ import android.widget.ListView;
import android.widget.TextView;
public class ManageAccountActivity extends XmppActivity {
-
- public static final int REQUEST_ANNOUNCE_PGP = 0x73731;
protected boolean isActionMode = false;
protected ActionMode actionMode;
@@ -281,7 +279,7 @@ public class ManageAccountActivity extends XmppActivity {
} else if (item.getItemId()==R.id.mgmt_account_announce_pgp) {
if (activity.hasPgp()) {
mode.finish();
- announcePgp();
+ announcePgp(selectedAccountForActionMode,null);
}
} else if (item.getItemId() == R.id.mgmt_otr_key) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
@@ -290,7 +288,10 @@ public class ManageAccountActivity extends XmppActivity {
View view = (View) getLayoutInflater().inflate(R.layout.otr_fingerprint, null);
if (fingerprintTxt!=null) {
TextView fingerprint = (TextView) view.findViewById(R.id.otr_fingerprint);
+ TextView noFingerprintView = (TextView) view.findViewById(R.id.otr_no_fingerprint);
fingerprint.setText(fingerprintTxt);
+ fingerprint.setVisibility(View.VISIBLE);
+ noFingerprintView.setVisibility(View.GONE);
}
builder.setView(view);
builder.setPositiveButton("Done", null);
@@ -361,33 +362,6 @@ public class ManageAccountActivity extends XmppActivity {
}
});
}
-
- private void announcePgp() {
- final Account account = selectedAccountForActionMode;
- xmppConnectionService.getPgpEngine().generateSignature(account, "online", new OnPgpEngineResult() {
-
- @Override
- public void userInputRequried(PendingIntent pi) {
- try {
- startIntentSenderForResult(pi.getIntentSender(), REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
- } catch (SendIntentException e) {
- Log.d("xmppService","coulnd start intent for pgp anncouncment");
- }
- }
-
- @Override
- public void success() {
- xmppConnectionService.databaseBackend.updateAccount(account);
- xmppConnectionService.sendPgpPresence(account, account.getPgpSignature());
- }
-
- @Override
- public void error(OpenPgpError openPgpError) {
- // TODO Auto-generated method stub
-
- }
- });
- }
@Override
protected void onStop() {
@@ -487,8 +461,8 @@ public class ManageAccountActivity extends XmppActivity {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_ANNOUNCE_PGP) {
- announcePgp();
- }
+ announcePgp(selectedAccountForActionMode,null);
+ }
}
}
}
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 70c4614d..55dcecc9 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -1,28 +1,38 @@
package eu.siacs.conversations.ui;
+import org.openintents.openpgp.OpenPgpError;
+
import eu.siacs.conversations.R;
+import eu.siacs.conversations.crypto.OnPgpEngineResult;
+import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
+import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
import eu.siacs.conversations.utils.ExceptionHelper;
import android.app.Activity;
import android.app.AlertDialog;
+import android.app.PendingIntent;
import android.app.AlertDialog.Builder;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
+import android.content.IntentSender.SendIntentException;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
+import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public abstract class XmppActivity extends Activity {
+ public static final int REQUEST_ANNOUNCE_PGP = 0x73731;
+
protected final static String LOGTAG = "xmppService";
public XmppConnectionService xmppConnectionService;
@@ -152,4 +162,33 @@ public abstract class XmppActivity extends Activity {
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(viewConversationIntent);
}
+
+ protected void announcePgp(final Account account, final Conversation conversation) {
+ xmppConnectionService.getPgpEngine().generateSignature(account, "online", new OnPgpEngineResult() {
+
+ @Override
+ public void userInputRequried(PendingIntent pi) {
+ try {
+ startIntentSenderForResult(pi.getIntentSender(), REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
+ } catch (SendIntentException e) {
+ Log.d("xmppService","coulnd start intent for pgp anncouncment");
+ }
+ }
+
+ @Override
+ public void success() {
+ xmppConnectionService.databaseBackend.updateAccount(account);
+ xmppConnectionService.sendPgpPresence(account, account.getPgpSignature());
+ if (conversation!=null) {
+ conversation.setNextEncryption(Message.ENCRYPTION_PGP);
+ }
+ }
+
+ @Override
+ public void error(OpenPgpError openPgpError) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
}
diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java
index 568386d5..52b18f66 100644
--- a/src/eu/siacs/conversations/utils/MessageParser.java
+++ b/src/eu/siacs/conversations/utils/MessageParser.java
@@ -77,9 +77,7 @@ public class MessageParser {
.sendMessagePacket(outPacket);
}
}
- if (service.convChangedListener!=null) {
- service.convChangedListener.onConversationListChanged();
- }
+ service.updateUi(conversation, false);
} else if ((before != after) && (after == SessionStatus.FINISHED)) {
conversation.resetOtrSession();
Log.d(LOGTAG,"otr session stoped");
@@ -101,7 +99,7 @@ public class MessageParser {
Conversation conversation = service.findOrCreateConversation(account, fromParts[0],true);
if (packet.hasChild("subject")) {
conversation.getMucOptions().setSubject(packet.findChild("subject").getContent());
- service.updateConversationInGui();
+ service.updateUi(conversation, false);
return null;
}
if ((fromParts.length == 1)) {
@@ -118,7 +116,6 @@ public class MessageParser {
public static Message parseCarbonMessage(MessagePacket packet,
Account account, XmppConnectionService service) {
- // TODO Auto-generated method stub
int status;
String fullJid;
Element forwarded;
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index 1c52ff0b..8baa3c25 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -389,7 +389,7 @@ public class UIHelper {
context, true));
mBuilder.setContentTitle(conversation.getName(useSubject));
if (notify) {
- mBuilder.setTicker(conversation.getLatestMessage().getBody().trim());
+ mBuilder.setTicker(conversation.getLatestMessage().getReadableBody(context));
}
StringBuilder bigText = new StringBuilder();
List<Message> messages = conversation.getMessages();
@@ -397,10 +397,10 @@ public class UIHelper {
for (int i = messages.size() - 1; i >= 0; --i) {
if (!messages.get(i).isRead()) {
if (i == messages.size() - 1) {
- firstLine = messages.get(i).getBody().trim();
+ firstLine = messages.get(i).getReadableBody(context);
bigText.append(firstLine);
} else {
- firstLine = messages.get(i).getBody().trim();
+ firstLine = messages.get(i).getReadableBody(context);
bigText.insert(0, firstLine + "\n");
}
} else {
@@ -422,7 +422,7 @@ public class UIHelper {
names.append(unread.get(i).getName(useSubject));
}
style.addLine(Html.fromHtml("<b>" + unread.get(i).getName(useSubject)
- + "</b> " + unread.get(i).getLatestMessage().getBody().trim()));
+ + "</b> " + unread.get(i).getLatestMessage().getReadableBody(context)));
}
mBuilder.setContentTitle(unread.size() + " unread Conversations");
mBuilder.setContentText(names.toString());
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index 3a20b87f..3c9120ec 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -67,7 +67,9 @@ public class JingleConnection {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE_ERROR) {
- mXmppConnectionService.markMessage(message, Message.STATUS_SEND_FAILED);
+ if (initiator.equals(account.getFullJid())) {
+ mXmppConnectionService.markMessage(message, Message.STATUS_SEND_FAILED);
+ }
status = STATUS_FAILED;
}
}
@@ -81,6 +83,7 @@ public class JingleConnection {
sendSuccess();
if (acceptedAutomatically) {
message.markUnread();
+ JingleConnection.this.mXmppConnectionService.updateUi(message.getConversation(), true);
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
@@ -91,7 +94,7 @@ public class JingleConnection {
mXmppConnectionService.databaseBackend.createMessage(message);
mXmppConnectionService.markMessage(message, Message.STATUS_RECIEVED);
}
- Log.d("xmppService","sucessfully transmitted file. sha1:"+file.getSha1Sum()+" "+message.getBody());
+ Log.d("xmppService","sucessfully transmitted file:"+file.getName()+" encryption:"+message.getEncryption());
}
};
@@ -226,7 +229,6 @@ public class JingleConnection {
this.mergeCandidates(JingleCandidate.parse(content.socks5transport().getChildren()));
this.fileOffer = packet.getJingleContent().getFileOffer();
if (fileOffer!=null) {
- this.file = this.mXmppConnectionService.getFileBackend().getJingleFile(message);
Element fileSize = fileOffer.findChild("size");
Element fileNameElement = fileOffer.findChild("name");
if (fileNameElement!=null) {
@@ -243,20 +245,20 @@ public class JingleConnection {
}
}
if (supportedFile) {
- this.file.setExpectedSize(Long.parseLong(fileSize.getContent()));
- message.setBody(""+this.file.getExpectedSize());
+ long size = Long.parseLong(fileSize.getContent());
+ message.setBody(""+size);
conversation.getMessages().add(message);
- if (this.file.getExpectedSize()<=this.mJingleConnectionManager.getAutoAcceptFileSize()) {
+ if (size<=this.mJingleConnectionManager.getAutoAcceptFileSize()) {
Log.d("xmppService","auto accepting file from "+packet.getFrom());
this.acceptedAutomatically = true;
this.sendAccept();
} else {
message.markUnread();
- Log.d("xmppService","not auto accepting new file offer with size: "+this.file.getExpectedSize()+" allowed size:"+this.mJingleConnectionManager.getAutoAcceptFileSize());
- if (this.mXmppConnectionService.convChangedListener!=null) {
- this.mXmppConnectionService.convChangedListener.onConversationListChanged();
- }
+ Log.d("xmppService","not auto accepting new file offer with size: "+size+" allowed size:"+this.mJingleConnectionManager.getAutoAcceptFileSize());
+ this.mXmppConnectionService.updateUi(conversation, true);
}
+ this.file = this.mXmppConnectionService.getFileBackend().getJingleFile(message,false);
+ this.file.setExpectedSize(size);
} else {
this.sendCancel();
}
@@ -273,7 +275,7 @@ public class JingleConnection {
Content content = new Content(this.contentCreator,this.contentName);
if (message.getType() == Message.TYPE_IMAGE) {
content.setTransportId(this.transportId);
- this.file = this.mXmppConnectionService.getFileBackend().getJingleFile(message);
+ this.file = this.mXmppConnectionService.getFileBackend().getJingleFile(message,false);
content.setFileOffer(this.file);
this.transportId = this.mJingleConnectionManager.nextRandomId();
content.setTransportId(this.transportId);