Threema 4 lat temu
rodzic
commit
b1778658d8

+ 4 - 4
app/build.gradle

@@ -11,7 +11,7 @@ if (getGradle().getStartParameter().getTaskRequests().toString().contains("Hms")
 }
 
 // version codes
-def app_version = "4.58"
+def app_version = "4.581"
 def beta_suffix = "" // with leading dash
 
 /**
@@ -86,7 +86,7 @@ android {
         vectorDrawables.useSupportLibrary = true
         applicationId "ch.threema.app"
         testApplicationId 'ch.threema.app.test'
-        versionCode 697
+        versionCode 698
         versionName "${app_version}${beta_suffix}"
         resValue "string", "app_name", "Threema"
         // package name used for sync adapter
@@ -542,8 +542,8 @@ dependencies {
     implementation 'androidx.activity:activity:1.2.4'
     implementation 'androidx.sqlite:sqlite:2.1.0'
     implementation "androidx.concurrent:concurrent-futures:1.1.0"
-    implementation "androidx.camera:camera-camera2:1.0.1"
-    implementation "androidx.camera:camera-lifecycle:1.0.1"
+    implementation "androidx.camera:camera-camera2:1.0.2"
+    implementation "androidx.camera:camera-lifecycle:1.0.2"
     // camera-view >1.0.0-alpha25 requires compileSDK 30
     implementation "androidx.camera:camera-view:1.0.0-alpha25"
     implementation 'androidx.multidex:multidex:2.0.1'

+ 0 - 1
app/src/main/AndroidManifest.xml

@@ -683,7 +683,6 @@
 			android:label="@string/capture_name"
 			android:clearTaskOnLaunch="true"
 			android:stateNotNeeded="true"
-			android:screenOrientation="portrait"
 			android:configChanges="orientation|keyboardHidden"
 			android:theme="@style/Theme.Threema.Translucent"
 			android:windowSoftInputMode="stateAlwaysHidden"/>

+ 1 - 1
app/src/main/java/ch/threema/app/notifications/NotificationBuilderWrapper.java

@@ -175,7 +175,7 @@ public class NotificationBuilderWrapper extends NotificationCompat.Builder {
 				if (ContentResolver.SCHEME_FILE.equalsIgnoreCase(ringtone.getScheme())) {
 					// https://commonsware.com/blog/2016/09/07/notifications-sounds-android-7p0-aggravation.html
 					ThreemaApplication.getAppContext().grantUriPermission("com.android.systemui", ringtone, Intent.FLAG_GRANT_READ_URI_PERMISSION);
-				} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && ContentResolver.SCHEME_CONTENT.equalsIgnoreCase(ringtone.getScheme())) {
+				} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P && ContentResolver.SCHEME_CONTENT.equalsIgnoreCase(ringtone.getScheme())) {
 					// content://settings/system/notification_sound
 					if (!ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
 						// check if ringtone is still available

+ 5 - 0
app/src/main/java/ch/threema/app/qrscanner/activity/CaptureActivity.java

@@ -37,6 +37,7 @@
 package ch.threema.app.qrscanner.activity;
 
 import android.content.Intent;
+import android.content.pm.ActivityInfo;
 import android.content.res.Configuration;
 import android.graphics.Color;
 import android.os.Build;
@@ -62,6 +63,7 @@ import ch.threema.app.qrscanner.assit.AmbientLightManager;
 import ch.threema.app.qrscanner.assit.BeepManager;
 import ch.threema.app.qrscanner.camera.CameraManager;
 import ch.threema.app.qrscanner.view.ViewfinderView;
+import ch.threema.app.utils.ConfigUtils;
 
 /**
  * This activity opens the camera and does the actual scanning on a background thread. It draws a
@@ -138,6 +140,9 @@ public final class CaptureActivity extends AppCompatActivity implements SurfaceH
 	public void onCreate(Bundle icicle) {
 		super.onCreate(icicle);
 		windowSetting();
+
+		ConfigUtils.setRequestedOrientation(this, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+
 		setContentView(R.layout.activity_capture);
 
 		Bundle bundle = new Bundle();

+ 20 - 8
app/src/main/java/ch/threema/app/utils/QRScannerUtil.java

@@ -23,10 +23,12 @@ package ch.threema.app.utils;
 
 import android.app.Activity;
 import android.content.Intent;
+import android.content.pm.ActivityInfo;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import androidx.annotation.NonNull;
 import androidx.appcompat.app.AppCompatActivity;
 import ch.threema.app.R;
 import ch.threema.app.ThreemaApplication;
@@ -39,6 +41,7 @@ public class QRScannerUtil {
 
 	private static boolean scanAnyCode;
 	public static final int REQUEST_CODE_QR_SCANNER = 26657;
+	public static int orientation;
 	// Singleton stuff
 	private static QRScannerUtil sInstance = null;
 
@@ -49,8 +52,12 @@ public class QRScannerUtil {
 		return sInstance;
 	}
 
-	public void initiateScan(AppCompatActivity activity, boolean anyCode, String hint) {
+	public void initiateScan(@NonNull AppCompatActivity activity, boolean anyCode, String hint) {
 		logger.info("initiateScan");
+
+		orientation = activity.getRequestedOrientation();
+		ConfigUtils.setRequestedOrientation(activity, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+
 		scanAnyCode = anyCode;
 		Intent intent = new Intent(activity, CaptureActivity.class);
 		if (!TestUtil.empty(hint)) {
@@ -68,6 +75,8 @@ public class QRScannerUtil {
 	public String parseActivityResult(AppCompatActivity activity, int requestCode, int resultCode, Intent intent) {
 		if (requestCode == REQUEST_CODE_QR_SCANNER) {
 			if (activity != null) {
+				ConfigUtils.setRequestedOrientation(activity, orientation);
+
 				if (resultCode == Activity.RESULT_OK) {
 					if (scanAnyCode || intent.getBooleanExtra(ThreemaApplication.INTENT_DATA_QRCODE_TYPE_OK, false)) {
 						return intent.getStringExtra(ThreemaApplication.INTENT_DATA_QRCODE);
@@ -81,14 +90,17 @@ public class QRScannerUtil {
 	}
 
 	public QRCodeService.QRCodeContentResult parseActivityResult(AppCompatActivity activity, int requestCode, int resultCode, Intent intent, QRCodeService qrCodeService) {
-		if (qrCodeService != null) {
-			String scanResult = parseActivityResult(activity, requestCode, resultCode, intent);
-			if (scanResult != null) {
-				QRCodeService.QRCodeContentResult qrRes = qrCodeService.getResult(scanResult);
-				if (qrRes != null) {
-					return qrRes;
+		if (activity != null) {
+			ConfigUtils.setRequestedOrientation(activity, orientation);
+			if (qrCodeService != null) {
+				String scanResult = parseActivityResult(activity, requestCode, resultCode, intent);
+				if (scanResult != null) {
+					QRCodeService.QRCodeContentResult qrRes = qrCodeService.getResult(scanResult);
+					if (qrRes != null) {
+						return qrRes;
+					}
+					invalidCodeDialog(activity);
 				}
-				invalidCodeDialog(activity);
 			}
 		}
 		return null;

+ 2 - 2
app/src/main/res/values/strings.xml

@@ -859,7 +859,7 @@
 	<string name="error_attaching_files">Error adding attachments.</string>
 	<string name="prefs_fix_powermanager_problems">Disable power restrictions</string>
 	<string name="prefs_fix_powermanager_problems_desc">Allow Threema to run in the background so it can receive messages even when it’s not active.</string>
-	<string name="disable_powermanager_explain">In the following screen, make sure, “%s” is protected or excluded from any power management restrictions of your phone.Tap the “back” button when you’re done.</string>
+	<string name="disable_powermanager_explain">In the following screen, make sure, “%s” is protected or excluded from any power management restrictions of your phone. Tap the “back” button when you’re done.</string>
 	<string name="disable_autostart_explain">In the following screen, make sure “%s” is included in the list of apps that can autostart. Tap the “back” button when you’re done.</string>
 	<string name="notification_priority_default">Low</string>
 	<string name="notification_priority_high">High</string>
@@ -1121,7 +1121,7 @@
 	<string name="work_life_dnd_active">Off-hours active</string>
 	<string name="pencil">Pencil</string>
 	<string name="warning">Warning</string>
-	<string name="password_remember_warning">Remember what you enter here! Since %s does not save any passwords on severs, we cannot help you out, if you forgot your PIN or password.</string>
+	<string name="password_remember_warning">Remember what you enter here! Since %s does not save any passwords on severs, we cannot help you out, if you forget your PIN or password.</string>
 	<string name="safe_backup_tap_to_restart">Tap on the system notification shown to restart the app now. If you cannot see the notification, please swipe down your phone’s notification bar.</string>
 	<string name="send_to_support">Send to Threema Support</string>
 	<string name="menu_legal">Legal</string>

+ 0 - 10
app/src/protobuf/README.md

@@ -1,10 +0,0 @@
-# Threema Protobuf Files
-
-This repository contains Protocol Buffer Messages for communication between Threema apps and services.
-
-| File | Description |
-|---|---|
-| common.proto | Commonly used types |
-| d2m.proto | Multi-Device: Communication between device and mediator server |
-| d2d.proto | Multi-Device: Communication between devices |
-| call-signaling.proto | In-call signaling messages |

+ 0 - 620
app/src/protobuf/d2d.proto

@@ -1,620 +0,0 @@
-syntax = "proto3";
-
-package d2d;
-
-option java_package = "ch.threema.protobuf.d2d";
-
-import "common.proto";
-import "safe.proto";
-
-// Device to Device Protocol
-// =========================
-//
-// General Information
-// -------------------
-//
-// All messages are symmetrically encrypted with the Mediator Key (MK).
-//
-// Encryption format: 24 byte nonce prepended, followed by an NaCl box.
-//
-// All strings are UTF-8 encoded.
-
-
-
-// Initial data sent to a device that wants to participate in the device
-// group (i.e. a new device to be added by the user).
-message InitialData {
-  // Threema Safe Backup
-  safe.Backup backup = 1;
-}
-
-// Data shared across all devices and transmitted during the handshake.
-message SharedDeviceData {
-  // Random amount of padding, ignored by the receiver
-  bytes padding = 1;
-
-  // MDM parameters to be applied on all devices
-  MdmParameters mdm_parameters = 2;
-}
-
-// Metadata about a device, determined by the device itself.
-message DeviceInfo {
-  // Random amount of padding, ignored by the receiver
-  bytes padding = 1;
-
-  // Platform
-  enum Platform {
-    // Unknown platform
-    UNSPECIFIED = 0;
-    // Android
-    ANDROID = 1;
-    // Apple iOS
-    IOS = 2;
-    // Web application
-    WEB = 3;
-  }
-  Platform platform = 2;
-
-  // App version
-  string app_version = 3;
-
-  // Device description (smartphone model / browser)
-  string description = 4;
-}
-
-// A transaction scope. Used in the d2m transaction messages.
-message TransactionScope {
-    enum Scope {
-      USER_PROFILE_SYNC = 0;
-      CONTACT_SYNC = 1;
-      GROUP_SYNC = 2;
-      DISTRIBUTION_LIST_SYNC = 3;
-      SETTINGS_SYNC = 4;
-    }
-    Scope scope = 1;
-}
-
-// Root message
-message Envelope {
-  // Random amount of padding, ignored by the receiver
-  bytes padding = 1;
-
-  // The enveloped reflected message
-  oneof content {
-    OutgoingMessage outgoing_message = 2;
-    IncomingMessage incoming_message = 3;
-    UserProfileSync user_profile_sync = 4;
-    ContactSync contact_sync = 5;
-    GroupSync group_sync = 6;
-    DistributionListSync distribution_list_sync = 7;
-    SettingsSync settings_sync = 8;
-
-    MdmParameters mdm_parameters = 9999;
-  };
-}
-
-
-
-// Mobile device management parameters shared across Threema Work devices.
-//
-// More detailed parameter information is available here:
-// https://work.threema.ch/en/docs/mdm_configuration
-message MdmParameters {
-  // Username required for activation of the app
-  // References: `th_license_username`
-  oneof license_username { string license_username_value = 1; }
-
-  // Password required for activation of the app
-  // References: `th_license_password`
-  oneof license_password { string license_password_value = 2; }
-
-  // Nickname to be used
-  // References: `th_nickname`
-  oneof nickname { string nickname_value = 3; }
-
-  // First name of the user
-  // References: `th_firstname`
-  oneof first_name { string first_name_value = 4; }
-
-  // Last name of the user
-  // References: `th_lastname`
-  oneof last_name { string last_name_value = 5; }
-
-  // Customer specific identifier
-  // References: `th_csi`
-  oneof customer_specific_id { string customer_specific_id_value = 6; }
-
-  // User category
-  // References: `th_category`
-  oneof category { string category_value = 7; }
-
-  // Email address linked to the ID
-  // References: `th_linked_email`
-  oneof linked_email { string linked_email_value = 8; }
-
-  // Phone number linked to the ID
-  // References: `th_linked_phone`
-  oneof linked_phone { string linked_phone_value = 9; }
-
-  // Restore a Threema ID
-  // References: `th_id_backup`
-  oneof identity_restore { string identity_restore_value = 10; }
-
-  // Password for restoring a Threema ID
-  // References: `th_id_backup_password`
-  oneof identity_restore_password {
-    string identity_restore_password_value = 11;
-  }
-
-  // Threema Safe configuration
-  // References: `th_safe_enable`
-  enum ThreemaSafePolicy {
-    // Configurable by the user
-    SAFE_OPTIONAL = 0;
-    // Forcibly enabled
-    SAFE_MANDATORY = 1;
-    // Forcibly disabled
-    SAFE_DISABLED = 2;
-  }
-  ThreemaSafePolicy threema_safe_policy = 12;
-
-  // Threema Safe password (predefined)
-  // References: `th_safe_password`
-  oneof threema_safe_password { string threema_safe_password_value = 13; }
-
-  // Threema Safe password pattern
-  // References: `th_safe_password_pattern`
-  oneof threema_safe_password_pattern {
-    string threema_safe_password_pattern_value = 14;
-  }
-
-  // Threema Safe password pattern error (mismatch) message
-  // References: `th_safe_password_message`
-  oneof threema_safe_password_pattern_error_message {
-    string threema_safe_password_pattern_error_message_value = 15;
-  }
-
-  // Threema Safe server URL
-  // References: `th_safe_server_url`
-  oneof threema_safe_server_url { string threema_safe_server_url_value = 16; }
-
-  // Threema Safe server username for authentication
-  // References: `th_safe_server_username`
-  oneof threema_safe_server_username {
-    string threema_safe_server_username_value = 17;
-  }
-
-  // Threema Safe server password for authentication
-  // References: `th_safe_server_password`
-  oneof threema_safe_server_password {
-    string threema_safe_server_password_value = 18;
-  }
-
-  // Restore policy for restoring from a Threema Safe backup
-  // References: `th_safe_restore_enable`
-  enum ThreemaSafeRestorePolicy {
-    // Choosable by the user
-    SAFE_RESTORE_OPTIONAL = 0;
-    // Automatic restore
-    SAFE_RESTORE_MANDATORY = 1;
-    // Forcibly disabled
-    SAFE_RESTORE_DISABLED = 2;
-  }
-  ThreemaSafeRestorePolicy threema_safe_restore_policy = 19;
-
-  // Threema ID to be restored from Threema Safe
-  // References: `th_safe_restore_id`
-  oneof threema_safe_restore_identity {
-    string threema_safe_restore_identity_value = 20;
-  }
-
-  // Override policy in regards to MDM parameters (profile, settings, ...)
-  // References: `th_readonly_profile`
-  enum OverridePolicy {
-    // Allows the user to override some of the MDM parameter presets
-    LOOSE = 0;
-    // The user may not override any MDM parameter presets
-    STRICT = 1;
-  }
-  OverridePolicy override_policy = 21;
-
-  // Contact synchronisation policy
-  // References: `th_contact_sync`
-  enum ContactSyncPolicy {
-    // Not synced
-    NOT_SYNCED = 0;
-    // Synced
-    SYNC = 1;
-  }
-  ContactSyncPolicy contact_sync_policy = 22;
-
-  // Inactive Threema ID display policy
-  // References: `th_hide_inactive_ids`
-  enum InactiveIdentityDisplayPolicy {
-    // Show inactive IDs
-    SHOW_INACTIVE = 0;
-    // Hide inactive IDs
-    HIDE_INACTIVE = 1;
-  }
-  InactiveIdentityDisplayPolicy inactive_identity_display_policy = 23;
-
-  // Unknown contacts policy
-  // References: `th_block_unknown`
-  enum UnknownContactPolicy {
-    // Allowed to contact the user
-    ALLOW_UNKNOWN = 0;
-    // Will be blocked by the user
-    BLOCK_UNKNOWN = 1;
-  }
-  UnknownContactPolicy unknown_contact_policy = 24;
-
-  // Auto-save media policy
-  // References: `th_disable_save_to_gallery`
-  enum AutoSaveMediaPolicy {
-    // Allow auto-saving, configurable by the user
-    ALLOW_AUTO_SAVE = 0;
-    // Deny auto-saving
-    DENY_AUTO_SAVE = 1;
-  }
-  AutoSaveMediaPolicy auto_save_media_policy = 25;
-
-  // Screenshot policy
-  // References: `th_disable_screenshots`
-  enum ScreenshotPolicy {
-    // Allow taking screenshots
-    ALLOW_SCREENSHOT = 0;
-    // Deny taking screenshots, if possible
-    DENY_SCREENSHOT = 1;
-  }
-  ScreenshotPolicy screenshot_policy = 26;
-
-  // Add contact policy
-  // References: `th_disable_add_contact`
-  enum AddContactPolicy {
-    // Allow manually adding contacts
-    ALLOW_ADD_CONTACT = 0;
-    // Deny manually adding contacts
-    DENY_ADD_CONTACT = 1;
-  }
-  AddContactPolicy add_contact_policy = 27;
-
-  // Chat export policy
-  // References: `th_disable_export`
-  enum ChatExportPolicy {
-    // Allow exporting chats
-    ALLOW_CHAT_EXPORT = 0;
-    // Deny exporting of chats
-    DENY_CHAT_EXPORT = 1;
-  }
-  ChatExportPolicy chat_export_policy = 28;
-
-  // Backup policy
-  // References: `th_disable_backups`
-  enum BackupPolicy {
-    // Generally allow backups to be made
-    ALLOW_BACKUP = 0;
-    // Deny creating backups
-    DENY_BACKUP = 1;
-  }
-  BackupPolicy backup_policy = 29;
-
-  // Threema ID export policy
-  // References: `th_disable_id_export`
-  enum IdentityExportPolicy {
-    // Allow exporting of the Threema ID
-    ALLOW_IDENTITY_EXPORT = 0;
-    // Deny exporting of the Threema ID
-    DENY_IDENTITY_EXPORT = 1;
-  }
-  IdentityExportPolicy identity_export_policy = 30;
-
-  // Data backup policy
-  // References: `th_disable_data_backups`
-  enum DataBackupPolicy {
-    // Allow creating data backups
-    ALLOW_DATA_BACKUP = 0;
-    // Deny creating data backups
-    DENY_DATA_BACKUP = 1;
-  }
-  DataBackupPolicy data_backup_policy = 31;
-
-  // System backup policy
-  // References: `th_disable_system_backups`
-  enum SystemBackupPolicy {
-    // The system may include app data
-    ALLOW_SYSTEM_BACKUP = 0;
-    // The system is denied from including app data
-    DENY_SYSTEM_BACKUP = 1;
-  }
-  SystemBackupPolicy system_backup_policy = 32;
-
-  // Message preview (in notifications)
-  // References: `th_disable_message_preview`
-  enum MessagePreviewPolicy {
-    // Allow showing a message preview
-    ALLOW_PREVIEW = 0;
-    // Deny showing a message preview
-    DENY_PREVIEW = 1;
-  }
-  MessagePreviewPolicy message_preview_policy = 33;
-
-  // Profile picture sharing policy
-  // References: `th_disable_send_profile_picture`
-  enum ProfilePictureSharePolicy {
-    // Allow the profile picture to be shared with contacts
-    ALLOW_SHARE = 0;
-    // Denied from sharing the profile picture with contacts
-    DENY_SHARE = 1;
-  }
-  ProfilePictureSharePolicy profile_picture_share_policy = 34;
-
-  // Threema Call policy
-  // References: `th_disable_calls`
-  enum CallPolicy {
-    // Allow creating/receiving Threema Calls
-    ALLOW_CALL = 0;
-    // Denied from creating/receiving any Threema Calls
-    DENY_CALL = 1;
-  }
-  CallPolicy call_policy = 35;
-
-  // Setup wizard policy
-  // References: `th_skip_wizard`
-  enum SetupWizardPolicy {
-    // Show the setup wizard
-    SHOW_WIZARD = 0;
-    // Skip the setup wizard (restores an ID or a backup and sets up the
-    // profile automatically).
-    SKIP_WIZARD = 1;
-  }
-  SetupWizardPolicy setup_wizard_policy = 36;
-
-  // Group creation policy
-  // References: `th_disable_create_group`
-  enum CreateGroupPolicy {
-    // Allow manually creating groups
-    ALLOW_CREATE_GROUP = 0;
-    // Deny manually creating groups
-    DENY_CREATE_GROUP = 1;
-  }
-  CreateGroupPolicy create_group_policy = 37;
-
-  // Share media policy
-  // References: `th_disable_share_media`
-  enum ShareMediaPolicy {
-    // Allow unrestricted sharing of media
-    ALLOW_SHARE_MEDIA = 0;
-    // Deny sharing of media outside of Threema, if possible
-    DENY_OUTSIDE_APP = 1;
-  }
-  ShareMediaPolicy share_media_policy = 38;
-}
-
-// Message type as defined by the Chat Server Protocol.
-enum MessageType {
-  // Invalid message type
-  INVALID = 0x00;
-
-  // Text message
-  TEXT = 0x01;
-  // Image message (deprecated, use `FILE_MESSAGE`)
-  IMAGE = 0x02;
-  // Location message
-  LOCATION = 0x10;
-  // Audio message (deprecated, use `FILE_MESSAGE`)
-  AUDIO = 0x14;
-  // Video message (deprecated, use `FILE_MESSAGE`)
-  VIDEO = 0x13;
-  // File message
-  FILE = 0x17;
-  // Create a poll
-  POLL_CREATE = 0x15;
-  // Cast a vote on a poll
-  POLL_VOTE = 0x16;
-  // Call offer
-  CALL_OFFER = 0x60;
-  // Call answer
-  CALL_ANSWER = 0x61;
-  // Call ICE Candidate
-  CALL_ICE_CANDIDATE = 0x62;
-  // Call hangup
-  CALL_HANGUP = 0x63;
-  // Call ringing
-  CALL_RINGING = 0x64;
-  // Call missed
-  CALL_MISSED = 0x65;
-
-  // Delivery receipt
-  DELIVERY_RECEIPT = 0x80;
-  // Typing indicator
-  TYPING_INDICATOR = 0x90;
-
-  // Set profile picture of a contact
-  CONTACT_SET_PROFILE_PICTURE = 0x18;
-  // Delete profile picture of a contact
-  CONTACT_DELETE_PROFILE_PICTURE = 0x19;
-  // Request profile picture of a contact
-  CONTACT_REQUEST_PROFILE_PICTURE = 0x1a;
-
-  // Create a group
-  GROUP_CREATE = 0x4a;
-  // Rename a group
-  GROUP_RENAME = 0x4b;
-  // Leave a group
-  GROUP_LEAVE = 0x4c;
-  // Set a group's profile picture
-  GROUP_SET_PROFILE_PICTURE = 0x50;
-  // Delete a group's profile picture
-  GROUP_DELETE_PROFILE_PICTURE = 0x54;
-  // Request group synchronisation
-  GROUP_REQUEST_SYNC = 0x51;
-
-  // Group text message
-  GROUP_TEXT = 0x41;
-  // Group location message
-  GROUP_LOCATION = 0x42;
-  // Group image message
-  GROUP_IMAGE = 0x43;
-  // Group audio message
-  GROUP_AUDIO = 0x45;
-  // Group video message
-  GROUP_VIDEO = 0x44;
-  // Group file message
-  GROUP_FILE = 0x46;
-  // Create a group poll
-  GROUP_POLL_CREATE = 0x52;
-  // Cast a vote on a group poll
-  GROUP_POLL_VOTE = 0x53;
-}
-
-// A message receiver can be a single user or a group.
-message MessageReceiver {
-  // The recipient's Threema ID or a group identity.
-  oneof receiver {
-    string identity = 1;
-    common.GroupIdentity group = 2;
-  }
-}
-
-// An outgoing message, reflected to other devices.
-message OutgoingMessage {
-  // Recipient of the enclosed message.
-  //
-  // Note: If the receiver is a group identity, group and group creator id of
-  //       the enclosed message must match the values of the supplied group
-  //       identity. Otherwise, the message must be considered invalid.
-  MessageReceiver receiver = 1;
-
-  // Unique ID of the enclosed message
-  fixed64 message_id = 2;
-
-  // Unix-ish timestamp in milliseconds for when the message has been created
-  uint64 created_at = 3;
-
-  // Enclosed message's type
-  MessageType type = 4;
-
-  // The message's body as defined for `Message` (0x01/0x02) of the Chat
-  // Server Protocol.
-  bytes body = 5;
-}
-
-// An outgoing message has been delivered to the chat server.
-//
-// Note: This indicates that the message has been successfully stored in the
-//       message queue of the server. It does NOT indicate that the message has
-//       been delivered to the intended receiver.
-message OutgoingMessageDelivered {
-  // Recipient of the delivered message.
-  MessageReceiver receiver = 1;
-
-  // Unique ID of the delivered message
-  fixed64 message_id = 2;
-}
-
-// An incoming message, reflected to other devices.
-message IncomingMessage {
-  // Sender's Threema ID
-  string sender_identity = 1;
-
-  // Sender's public nickname
-  string sender_nickname = 2;
-
-  // Unique ID of the enclosed message
-  fixed64 message_id = 3;
-
-  // Unix-ish timestamp in milliseconds for when the message has been created
-  uint64 created_at = 4;
-
-  // Enclosed message's type
-  MessageType type = 5;
-
-  // The message's body as defined for `Message` (0x01/0x02) of the Chat
-  // Server Protocol.
-  bytes body = 6;
-}
-
-// User profile synchronisation message.
-message UserProfileSync {
-  // Update the user's profile
-  message Set {
-    safe.UserProfile user_profile = 1;
-  }
-
-  // Synchronisation type
-  oneof action {
-    Set set = 1;
-  }
-}
-
-// Contact synchronisation message.
-message ContactSync {
-  // Set a Threema contact
-  message Set {
-    safe.Contact contact = 1;
-  }
-
-  // Delete a Threema contact
-  message Delete {
-    string delete_identity = 1;
-  }
-
-  // Synchronisation type
-  oneof action {
-    Set set = 1;
-    Delete delete = 2;
-  }
-}
-
-// Group synchronisation message.
-message GroupSync {
-  // Set a group
-  message Set {
-    safe.Group group = 1;
-  }
-
-  // Delete a group
-  message Delete {
-    // Unique group identity
-    common.GroupIdentity group_identity = 1;
-  }
-
-  // Synchronisation type
-  oneof action {
-    Set set = 1;
-    Delete delete = 2;
-  }
-}
-
-// Distribution list synchronisation message.
-message DistributionListSync {
-  // Set a distribution list
-  message Set {
-    safe.DistributionList distribution_list = 1;
-  }
-
-  // Delete a group
-  message Delete {
-    // Unique ID of the distribution list
-    fixed64 distribution_list_id = 1;
-  }
-
-  // Synchronisation type
-  oneof action {
-    Set set = 1;
-    Delete delete = 2;
-  }
-}
-
-// Settings synchronisation message.
-message SettingsSync {
-  // Apply settings
-  message Set {
-    safe.Settings settings = 1;
-  }
-
-  // Synchronisation type
-  oneof action {
-    Set set = 1;
-  }
-}

+ 0 - 460
app/src/protobuf/d2m.proto

@@ -1,460 +0,0 @@
-syntax = "proto3";
-
-package d2m;
-
-option java_package = "ch.threema.protobuf.d2m";
-
-// Device to Mediator Protocol
-// ===========================
-//
-// General Information
-// -------------------
-//
-// Encryption format: 24 byte nonce prepended, followed by an NaCl box.
-//
-// All strings are UTF-8 encoded.
-//
-// Terminology
-// -----------
-//
-// - `MK`: Mediator Key (Client)
-// - `MPK`: Mediator Path Key (Client)
-// - `TPK`: Temporary Path Key (Server)
-// - `Box(A, B)`: A NaCl box encrypted with A and B
-// - `Device ID`: Refers to the *Mediator Device ID*
-//
-// Common Header
-// -------------
-//
-//  0                   1                   2                   3
-//  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |     Type      |                   Reserved                    |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                           Payload                          ...
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-//
-// Type: 1 byte (u8)
-//
-//   Identifies the payload type contained in the `Payload` field.
-//
-// Reserved: 3 byte
-//
-//   Should be set to all `0`s and ignored by the receiver.
-//
-// Payload: 0..65532 byte
-//
-//   A payload, which can look differently depending on the payload type.
-
-
-// Send along client information when connecting to the mediator server.
-//
-// This message is serialized, hex-encoded (lowercase) and then used as the
-// WebSocket path.
-//
-// Type: n/a
-// Direction: Client -> Server
-message ClientUrlInfo {
-    // 32 byte mediator path public key
-    bytes mpk = 1;
-
-    // Server group, as assigned by the server when the Threema identity has
-    // been created.
-    uint32 server_group = 2;
-}
-
-
-// Proxy a message to/from the chat server.
-//
-// Name: Proxy
-// Type: 0x00
-// Direction: Client <-> Server
-//
-//  0                   1                   2                   3
-//  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                             Data                           ...
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-//
-// Data: 0..65532 byte
-//
-//   The data to be proxied to/from the chat server, encrypted by following
-//   the Chat Server Protocol.
-
-
-
-// Initial message from the server, containing an authentication challenge.
-//
-// Type: 0x10
-// Direction: Client <-- Server
-message ServerHello {
-  // Highest protocol version the server supports
-  uint32 version = 1;
-
-  // 32 byte temporary public key
-  bytes tpk = 2;
-
-  // 32 byte random challenge
-  bytes challenge = 3;
-}
-
-// Policy determining the device slot's lifetime.
-enum DeviceSlotExpirationPolicy {
-  // The device slot should be removed shortly after the device
-  // disconnected. However, there should be a delay of several minutes to
-  // ensure that the device can reconnect if it disconnected unintentionally.
-  VOLATILE = 0;
-  // The device slot should be kept as long as possible
-  PERSISTENT = 1;
-}
-
-// Initial message from the client, containing the authentication challenge
-// response and additional login information.
-//
-// Type: 0x11
-// Direction: Client --> Server
-message ClientHello {
-  // Protocol version which the client has selected
-  uint32 version = 1;
-
-  // Challenge response (72 bytes) for authentication.
-  //
-  // The response is created using NaCl box encryption:
-  //
-  //   Box(MPK.secret, TPK.public)
-  //    .encrypt(data=<challenge>, nonce=<random>)
-  //
-  // The nonce is then prepended to the encrypted challenge.
-  //
-  //   nonce (24 bytes) || encrypted-box (16 + 32 bytes)
-  bytes response = 2;
-
-  // Unique device id
-  fixed64 device_id = 3;
-
-  // Policy to be applied in case the device id is not registered on the server
-  // and all device slots have been exhausted.
-  enum DeviceSlotsExhaustedPolicy {
-    // Terminate the connection
-    REJECT = 0;
-    // Drop the least recently used device
-    DROP_LEAST_RECENT = 1;
-  }
-  DeviceSlotsExhaustedPolicy device_slots_exhausted_policy = 4;
-
-  // Policy determining the device slot's lifetime
-  DeviceSlotExpirationPolicy device_slot_expiration_policy = 5;
-
-  // Device info (`d2d.DeviceInfo`), encrypted by `MK.secret`
-  bytes encrypted_device_info = 6;
-}
-
-// Parts of the server's configuration and the device slot state.
-//
-// Type: 0x12
-// Direction: Client <-- Server
-message ServerInfo {
-  // Maximum number of device slots
-  uint32 max_device_slots = 1;
-
-  // Informs the device about its device slot state on the server
-  enum DeviceSlotState {
-    // A new device slot has been allocated for the device (i.e. the device's
-    // id was not registered on the server).
-    NEW = 0;
-    // An existing device slot has been reused for the device (i.e. the
-    // device's id is already registered on the server).
-    EXISTING = 1;
-  }
-  DeviceSlotState device_slot_state = 2;
-
-  // Device data shared among devices (`SharedDeviceData`), encrypted by
-  // `MK.secret`.
-  bytes encrypted_shared_device_data = 3;
-}
-
-
-
-// The device's reflection queue on the server has been fully transmitted to
-// the device.
-//
-// Note: This does not mean that reflected messages have already been
-//       acknowledged by the device!
-//
-// Type: 0x20
-// Direction: Client <-- Server
-message ReflectionQueueDry {
-}
-
-// The device's role has been promoted to leader, indicating that the device
-// should now request to receive and reflect messages from the chat server.
-//
-// Type: 0x21
-// Direction: Client <-- Server
-message RolePromotedToLeader {
-}
-
-
-
-// Request device information of all devices.
-//
-// Type: 0x30
-// Direction: Client --> Server
-message GetDevicesInfo {
-}
-
-// Device information of all devices.
-//
-// Type: 0x31
-// Direction: Client <-- Server
-message DevicesInfo {
-  // Device id to (augmented) device info map of all devices.
-  message AugmentedDeviceInfo {
-    // Device info (`d2d.DeviceInfo`), encrypted by `MK.secret`.
-    bytes encrypted_device_info = 1;
-
-    // Unix-ish timestamp in milliseconds containing the most recent login
-    // time of the device.
-    uint64 last_login_at = 2;
-
-    // Expiration policy of the device.
-    DeviceSlotExpirationPolicy device_slot_expiration_policy = 3;
-  }
-  map<fixed64, AugmentedDeviceInfo> augmented_device_info = 1;
-}
-
-// Request to drop a device and free its device slot.
-//
-// Type: 0x32
-// Direction: Client --> Server
-message DropDevice {
-  // Unique device id
-  fixed64 device_id = 1;
-}
-
-// Acknowledges that a device has been dropped and the device slot has been
-// free'd.
-//
-// Type: 0x33
-// Direction: Client <-- Server
-message DropDeviceAck {
-  // Unique device id
-  fixed64 device_id = 1;
-}
-
-// Set the shared device data which is being sent to each device during login.
-//
-// Type: 0x34
-// Direction: Client --> Server
-message SetSharedDeviceData {
-  // Device data shared among devices (`SharedDeviceData`), encrypted by
-  // `MK.secret`.
-  bytes encrypted_shared_device_data = 1;
-}
-
-
-
-// Acquires a device group lock for an atomic operation shared across the
-// device group.
-//
-// Reflection messages from the device to the mediator server will only be
-// reflected once the transaction is committed.
-//
-// Type: 0x40
-// Direction: Client --> Server
-message BeginTransaction {
-  // The transaction scope (`TransactionScope` in D2D), encrypted by
-  // `MK.secret`
-  bytes encrypted_scope = 1;
-}
-
-// Acknowledges that the device group lock has been acquired and that the
-// transaction has been started.
-//
-// Type: 0x41
-// Direction: Client <-- Server
-message BeginTransactionAck {
-}
-
-// Commits a transaction, releases a device group lock.
-//
-// Type: 0x42
-// Direction: Client --> Server
-message CommitTransaction {
-}
-
-// Acknowledges that the transaction has been committed and that the device
-// group lock has been released.
-//
-// Type: 0x43
-// Direction: Client <-- Server
-message CommitTransactionAck {
-}
-
-// A `BeginTransaction` request is rejected because another transaction is
-// already in process.
-//
-// Type: 0x44
-// Direction: Client <-- Server
-message TransactionRejected {
-  // The device that currently holds the lock
-  fixed64 device_id = 1;
-
-  // The encrypted transaction scope associated with the currently locked transaction
-  bytes encrypted_scope = 2;
-}
-
-// When a transaction ends (either because it was committed or because the
-// device disconnected), this message is sent to all connected devices except
-// for the device that committed the transaction.
-//
-// This can be used by the other devices as a "retry signal" if a previous
-// "BeginTransaction" attempt was unsuccessful.
-//
-// Type: 0x45
-// Direction: Client <-- Server
-message TransactionEnded {
-  // The device that held the lock up until now
-  fixed64 device_id = 1;
-
-  // The encrypted transaction scope associated with the transaction that just ended
-  bytes encrypted_scope = 2;
-}
-
-
-
-// Reflect a message into the reflection queue of all other devices.
-//
-// Name: Reflect
-// Type: 0x80
-// Direction: Client --> Server
-//
-//  0                   1                   2                   3
-//  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |    HL = 8     |                   Reserved                    |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                          Reflect ID                           |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                           Envelope                         ...
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-//
-// Header Length (HL): 1 byte (u8)
-//
-//   Contains the length of the header, including the header length field
-//   itself (but not the common header), excluding the envelope.
-//   Currently, this value will always be set to `8`.
-//
-// Reserved: 3 byte
-//
-//   Should be set to all `0`s and ignored by the receiver.
-//
-// Reflect ID: 4 byte (u32, little endian)
-//
-//   Unique number (per connection) used for acknowledgement.
-//
-// Envelope: 0..65276 byte
-//
-//   The protobuf-encoded and encrypted data to be reflected, encrypted by `MK.secret`.
-//   See `d2d.proto` for details on the `Envelope` contents.
-
-
-// Acknowledges that a message to be reflected to all other devices has been
-// stored in their respective reflection queues.
-//
-// Name: ReflectAck
-// Type: 0x81
-// Direction: Client <-- Server
-//
-//  0                   1                   2                   3
-//  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                           Reserved                            |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                          Reflect ID                           |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                           Timestamp                           |
-// |                                                               |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-//
-// Reserved: 4 byte
-//
-//   Should be set to all `0`s and ignored by the receiver.
-//
-// Reflect ID: 4 byte (u32, little endian)
-//
-//   Refers to the `Reflect ID` as sent in the `Reflect` message.
-//
-// Timestamp: 8 byte (u64, little endian)
-//
-//   Unix-ish timestamp in milliseconds when the message has been stored in
-//   the reflection queue of the mediator server.
-
-
-// Deliver a message from the device's reflection queue.
-//
-// Name: Reflected
-// Type: 0x82
-// Direction: Client <-- Server
-//
-//  0                   1                   2                   3
-//  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |    HL = 8     |                   Reserved                    |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                         Reflected ID                          |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                           Timestamp                           |
-// |                                                               |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                           Envelope                        ...
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-//
-// Header Length (HL): 1 byte (u8)
-//
-//   Contains the length of the header, including the header length field
-//   itself (but not the common header), excluding the envelope.
-//   Currently, this value will always be set to `16`.
-//
-// Reserved: 3 byte
-//
-//   Should be set to all `0`s and ignored by the receiver.
-//
-// Reflected ID: 4 byte (u32, little endian)
-//
-//   Monotonically increasing unique number (per device slot) used for
-//   acknowledgement. May wrap.
-//
-// Timestamp: 8 byte (u64, little endian)
-//
-//   Unix-ish timestamp in milliseconds when the message has been stored in
-//   the reflection queue of the mediator server.
-//
-// Envelope: 0..65276 byte
-//
-//   The protobuf-encoded and encrypted data to be reflected, encrypted by `MK.secret`.
-//   See `d2d.proto` for details on the `Envelope` contents.
-
-
-// Acknowledges that a reflected message has been processed by the device.
-//
-// Name: ReflectedAck
-// Type: 0x83
-// Direction: Client --> Server
-//
-//  0                   1                   2                   3
-//  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                           Reserved                            |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// |                         Reflected ID                          |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-//
-// Reserved: 4 byte
-//
-//   Should be set to all `0`s and ignored by the receiver.
-//
-// Reflected ID: 4 byte (u32, little endian)
-//
-//   Refers to the `Reflected ID` as sent in the `Reflected` message.
-

+ 0 - 17
app/src/protobuf/test.sh

@@ -1,17 +0,0 @@
-#!/bin/sh
-set -eu
-
-ENTRYPOINTS="d2m d2d call-signaling"
-
-for e in $ENTRYPOINTS; do
-    DIR="out/$e/"
-    ( mkdir -p "$DIR" && cd "$DIR" && mkdir -p cpp java py js )
-    echo "Building $e.proto..."
-    protoc \
-      --cpp_out="$DIR/cpp" \
-      --java_out="$DIR/java" \
-      --python_out="$DIR/py" \
-      --js_out="$DIR/js" \
-      "$e.proto"
-    echo "  OK"
-done