From dd93de3833f1afb096424a0c4b0af8b235a1a056 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 10 Jun 2025 15:20:34 +0200 Subject: [PATCH 01/76] improve the videocalls: open in internal webview --- src/main/AndroidManifest.xml | 7 ++ .../components/AttachmentTypeSelector.java | 4 -- .../securesms/connect/DcHelper.java | 9 ++- .../AdvancedPreferenceFragment.java | 5 +- .../videochat/VideochatActivity.java | 68 +++++++++++++++++++ .../securesms/videochat/VideochatUtil.java | 33 +++++++-- 6 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 2473b9b9c..11488fc12 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -367,6 +367,13 @@ android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"> + + + { + request.grant(request.getResources()); + }); + } + }); + + Util.runOnAnyBackgroundThread(() -> { + final DcChat chat = dcContext.getChat(chatId); + Util.runOnMain(() -> { + getSupportActionBar().setTitle(chat.getName()); + }); + }); + + webView.loadUrl(url); + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + // do not call super.onPrepareOptionsMenu() as the default "Search" menu is not needed + return true; + } + + @Override + protected boolean openOnlineUrl(String url) { + finish(); + return true; + } +} diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java index dfd64f46b..4bf8d4b8c 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java @@ -1,6 +1,8 @@ package org.thoughtcrime.securesms.videochat; +import android.Manifest; import android.app.Activity; +import android.content.Intent; import androidx.appcompat.app.AlertDialog; @@ -10,7 +12,7 @@ import com.b44t.messenger.DcMsg; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.connect.DcHelper; -import org.thoughtcrime.securesms.util.IntentUtils; +import org.thoughtcrime.securesms.permissions.Permissions; public class VideochatUtil { @@ -23,7 +25,18 @@ public class VideochatUtil { .setMessage(R.string.videochat_invite_user_hint) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.ok, (dialog, which) -> { + String instance = dcContext.getConfig(DcHelper.CONFIG_WEBRTC_INSTANCE); + boolean unset = instance == null || instance.isEmpty(); + if (unset) { + dcContext.setConfig(DcHelper.CONFIG_WEBRTC_INSTANCE, DcHelper.DEFAULT_VIDEOCHAT_URL); + } + int msgId = dcContext.sendVideochatInvitation(dcChat.getId()); + + if (unset) { + dcContext.setConfig(DcHelper.CONFIG_WEBRTC_INSTANCE, null); + } + if (msgId != 0) { join(activity, msgId); } @@ -32,10 +45,20 @@ public class VideochatUtil { } public void join(Activity activity, int msgId) { - DcContext dcContext = DcHelper.getContext(activity); - DcMsg dcMsg = dcContext.getMsg(msgId); - String videochatUrl = dcMsg.getVideochatUrl(); - IntentUtils.showInBrowser(activity, videochatUrl); + Permissions.with(activity) + .request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO) + .ifNecessary() + .withPermanentDenialDialog(activity.getString(R.string.perm_explain_access_to_camera_denied)) + .onAllGranted(() -> { + DcContext dcContext = DcHelper.getContext(activity); + DcMsg dcMsg = dcContext.getMsg(msgId); + Intent intent = new Intent(activity, VideochatActivity.class); + intent.setAction(Intent.ACTION_VIEW); + intent.putExtra(VideochatActivity.EXTRA_CHAT_ID, dcMsg.getChatId()); + intent.putExtra(VideochatActivity.EXTRA_URL, dcMsg.getVideochatUrl()); + activity.startActivity(intent); + }) + .execute(); } } From 5fb61b008b8d660dc42ed66c00053ae607975731 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 10 Jun 2025 16:05:56 +0200 Subject: [PATCH 02/76] set name when joining call --- .../thoughtcrime/securesms/connect/DcHelper.java | 3 ++- .../securesms/videochat/VideochatUtil.java | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java index bfa9230ef..b8f6d22c3 100644 --- a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java +++ b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java @@ -74,7 +74,8 @@ public class DcHelper { public static final String CONFIG_WEBXDC_REALTIME_ENABLED = "webxdc_realtime_enabled"; public static final String CONFIG_PRIVATE_TAG = "private_tag"; - public static final String DEFAULT_VIDEOCHAT_URL = "https://meet.systemli.org/$ROOM#config.prejoinConfig.enabled=false&config.notifications=[]&config.toolbarButtons=[%22microphone%22,%22camera%22,%22hangup%22]"; + public static final String DEFAULT_VIDEOCHAT_URL_PREFIX = "https://meet.systemli.org/"; + public static final String DEFAULT_VIDEOCHAT_URL = DEFAULT_VIDEOCHAT_URL_PREFIX + "$ROOM#config.prejoinConfig.enabled=false&config.notifications=[]&config.toolbarButtons=[%22microphone%22,%22camera%22,%22hangup%22]"; public static DcContext getContext(@NonNull Context context) { return ApplicationContext.getInstance(context).dcContext; diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java index 4bf8d4b8c..8b0cd046a 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java @@ -14,6 +14,10 @@ import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.connect.DcHelper; import org.thoughtcrime.securesms.permissions.Permissions; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class VideochatUtil { public void invite(Activity activity, int chatId) { @@ -52,10 +56,19 @@ public class VideochatUtil { .onAllGranted(() -> { DcContext dcContext = DcHelper.getContext(activity); DcMsg dcMsg = dcContext.getMsg(msgId); + String url = dcMsg.getVideochatUrl(); + if (url.startsWith(DcHelper.DEFAULT_VIDEOCHAT_URL_PREFIX) && url.contains("#")) { + String name = dcContext.getName(); + try { + name = URLEncoder.encode(dcContext.getName(), StandardCharsets.UTF_8.toString()); + } catch (UnsupportedEncodingException ignored) {} + url += "&userInfo.displayName=%22" + name +"%22"; + } + Intent intent = new Intent(activity, VideochatActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.putExtra(VideochatActivity.EXTRA_CHAT_ID, dcMsg.getChatId()); - intent.putExtra(VideochatActivity.EXTRA_URL, dcMsg.getVideochatUrl()); + intent.putExtra(VideochatActivity.EXTRA_URL, url); activity.startActivity(intent); }) .execute(); From fa868077b0a0a350e49d0849f758a8753a64d22e Mon Sep 17 00:00:00 2001 From: adbenitez Date: Wed, 18 Jun 2025 17:41:09 +0200 Subject: [PATCH 03/76] test integrated webxdc --- .../thoughtcrime/securesms/WebxdcActivity.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java b/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java index 770ebbcbd..7a125c62a 100644 --- a/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java @@ -18,6 +18,7 @@ import android.view.MenuItem; import android.view.View; import android.webkit.JavascriptInterface; import android.webkit.MimeTypeMap; +import android.webkit.PermissionRequest; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebResourceResponse; @@ -34,6 +35,7 @@ import androidx.core.content.pm.ShortcutManagerCompat; import androidx.core.graphics.drawable.IconCompat; import com.b44t.messenger.DcChat; +import com.b44t.messenger.DcContact; import com.b44t.messenger.DcContext; import com.b44t.messenger.DcEvent; import com.b44t.messenger.DcMsg; @@ -163,6 +165,13 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE setScreenMode(getResources().getConfiguration()); webView.setWebChromeClient(new WebChromeClient() { + @Override + public void onPermissionRequest(PermissionRequest request) { + Util.runOnMain(() -> { + request.grant(request.getResources()); + }); + } + @Override @RequiresApi(21) public boolean onShowFileChooser(WebView webView, ValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { @@ -206,7 +215,7 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE this.baseURL = "https://acc" + dcContext.getAccountId() + "-msg" + appMessageId + ".localhost"; final JSONObject info = this.dcAppMsg.getWebxdcInfo(); - internetAccess = JsonUtils.optBoolean(info, "internet_access"); + internetAccess = true; //JsonUtils.optBoolean(info, "internet_access"); selfAddr = info.optString("self_addr"); sendUpdateMaxSize = info.optInt("send_update_max_size"); sendUpdateInterval = info.optInt("send_update_interval"); @@ -229,6 +238,10 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE String extraHref = b.getString(EXTRA_HREF, ""); if (TextUtils.isEmpty(extraHref)) { extraHref = "index.html"; + if (this.dcAppMsg.getFromId() == DcContact.DC_CONTACT_ID_SELF) { + extraHref += "#call"; + } + } String href = baseURL + "/" + extraHref; From eee218a3b659bc268f7f5ee6161f4e22d771789b Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Thu, 19 Jun 2025 00:48:59 +0200 Subject: [PATCH 04/76] add call api --- jni/dc_wrapper.c | 24 +++++++++++++++++++ .../java/com/b44t/messenger/DcContext.java | 7 ++++++ src/main/java/com/b44t/messenger/DcMsg.java | 2 ++ 3 files changed, 33 insertions(+) diff --git a/jni/dc_wrapper.c b/jni/dc_wrapper.c index d21404fab..9d9cd2cdc 100644 --- a/jni/dc_wrapper.c +++ b/jni/dc_wrapper.c @@ -773,6 +773,30 @@ JNIEXPORT void Java_com_b44t_messenger_DcContext_setWebxdcIntegration(JNIEnv *en } +JNIEXPORT jint Java_com_b44t_messenger_DcContext_placeOutgoingCall(JNIEnv *env, jobject obj, jint chat_id, jstring info) +{ + CHAR_REF(info); + jint msg_id = dc_place_outgoing_call(get_dc_context(env, obj), chat_id, infoPtr); + CHAR_UNREF(info); + return msg_id; +} + + +JNIEXPORT jint Java_com_b44t_messenger_DcContext_acceptIncomingCall(JNIEnv *env, jobject obj, jint msg_id, jstring info) +{ + CHAR_REF(info); + jboolean ret = dc_accept_incoming_call(get_dc_context(env, obj), msg_id, infoPtr) != 0; + CHAR_UNREF(info); + return ret; +} + + +JNIEXPORT jint Java_com_b44t_messenger_DcContext_endCall(JNIEnv *env, jobject obj, jint msg_id) +{ + return dc_end_call(get_dc_context(env, obj), msg_id) != 0; +} + + JNIEXPORT jint Java_com_b44t_messenger_DcContext_addDeviceMsg(JNIEnv *env, jobject obj, jstring label, jobject msg) { CHAR_REF(label); diff --git a/src/main/java/com/b44t/messenger/DcContext.java b/src/main/java/com/b44t/messenger/DcContext.java index a428659af..cec22f0ac 100644 --- a/src/main/java/com/b44t/messenger/DcContext.java +++ b/src/main/java/com/b44t/messenger/DcContext.java @@ -31,6 +31,10 @@ public class DcContext { public final static int DC_EVENT_WEBXDC_INSTANCE_DELETED = 2121; public final static int DC_EVENT_WEBXDC_REALTIME_DATA = 2150; public final static int DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE = 2200; + public final static int DC_EVENT_INCOMING_CALL = 2550; + public final static int DC_EVENT_INCOMING_CALL_ACCEPTED = 2560; + public final static int DC_EVENT_OUTGOING_CALL_ACCEPTED = 2570; + public final static int DC_EVENT_CALL_ENDED = 2580; public final static int DC_IMEX_EXPORT_SELF_KEYS = 1; public final static int DC_IMEX_IMPORT_SELF_KEYS = 2; @@ -203,6 +207,9 @@ public class DcContext { public native String getWebxdcStatusUpdates(int msg_id, int last_known_serial); public native void setWebxdcIntegration (String file); public native int initWebxdcIntegration(int chat_id); + public native int placeOutgoingCall (int chat_id, String place_call_info); + public native boolean acceptIncomingCall (int msg_id, String accept_call_info); + public native boolean endCall (int msg_id); public native int addDeviceMsg (String label, DcMsg msg); public native boolean wasDeviceMsgEverAdded(String label); public DcLot checkQr (String qr) { return new DcLot(checkQrCPtr(qr)); } diff --git a/src/main/java/com/b44t/messenger/DcMsg.java b/src/main/java/com/b44t/messenger/DcMsg.java index dc7c700b8..4bae7fa2d 100644 --- a/src/main/java/com/b44t/messenger/DcMsg.java +++ b/src/main/java/com/b44t/messenger/DcMsg.java @@ -36,6 +36,8 @@ public class DcMsg { public final static int DC_INFO_PROTECTION_DISABLED = 12; public final static int DC_INFO_INVALID_UNENCRYPTED_MAIL = 13; public final static int DC_INFO_WEBXDC_INFO_MESSAGE = 32; + public final static int DC_INFO_OUTGOING_CALL = 50; + public final static int DC_INFO_INCOMING_CALL = 55; public final static int DC_STATE_UNDEFINED = 0; public final static int DC_STATE_IN_FRESH = 10; From 3086c723046e804f529e45aaa427890acc6e7acc Mon Sep 17 00:00:00 2001 From: adbenitez Date: Thu, 19 Jun 2025 17:17:53 +0200 Subject: [PATCH 05/76] undo temporary test --- .../securesms/ConversationActivity.java | 7 ++- .../securesms/ConversationFragment.java | 2 +- .../securesms/WebxdcActivity.java | 15 +----- .../videochat/VideochatActivity.java | 10 ++-- .../securesms/videochat/VideochatUtil.java | 54 ++++++++++--------- 5 files changed, 41 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java index cdd31e0a8..d090f8284 100644 --- a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java @@ -951,7 +951,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity case AttachmentTypeSelector.ADD_DOCUMENT: AttachmentManager.selectDocument(this, PICK_DOCUMENT); break; case AttachmentTypeSelector.INVITE_VIDEO_CHAT: - new VideochatUtil().invite(this, chatId); break; + if (isMultiUser()) { + VideochatUtil.startMeeting(this, chatId); + } else { + VideochatUtil.startCall(this, chatId); + } + break; case AttachmentTypeSelector.ADD_CONTACT_INFO: startContactChooserActivity(); break; case AttachmentTypeSelector.ADD_LOCATION: diff --git a/src/main/java/org/thoughtcrime/securesms/ConversationFragment.java b/src/main/java/org/thoughtcrime/securesms/ConversationFragment.java index 5ab8be496..e6daec3b3 100644 --- a/src/main/java/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/ConversationFragment.java @@ -741,7 +741,7 @@ public class ConversationFragment extends MessageSelectorFragment } } else if (messageRecord.getType()==DcMsg.DC_MSG_VIDEOCHAT_INVITATION) { - new VideochatUtil().join(getActivity(), messageRecord.getId()); + VideochatUtil.joinMeeting(getActivity(), messageRecord.getId()); } else if(DozeReminder.isDozeReminderMsg(getContext(), messageRecord)) { DozeReminder.dozeReminderTapped(getContext()); diff --git a/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java b/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java index 7a125c62a..770ebbcbd 100644 --- a/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java @@ -18,7 +18,6 @@ import android.view.MenuItem; import android.view.View; import android.webkit.JavascriptInterface; import android.webkit.MimeTypeMap; -import android.webkit.PermissionRequest; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebResourceResponse; @@ -35,7 +34,6 @@ import androidx.core.content.pm.ShortcutManagerCompat; import androidx.core.graphics.drawable.IconCompat; import com.b44t.messenger.DcChat; -import com.b44t.messenger.DcContact; import com.b44t.messenger.DcContext; import com.b44t.messenger.DcEvent; import com.b44t.messenger.DcMsg; @@ -165,13 +163,6 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE setScreenMode(getResources().getConfiguration()); webView.setWebChromeClient(new WebChromeClient() { - @Override - public void onPermissionRequest(PermissionRequest request) { - Util.runOnMain(() -> { - request.grant(request.getResources()); - }); - } - @Override @RequiresApi(21) public boolean onShowFileChooser(WebView webView, ValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { @@ -215,7 +206,7 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE this.baseURL = "https://acc" + dcContext.getAccountId() + "-msg" + appMessageId + ".localhost"; final JSONObject info = this.dcAppMsg.getWebxdcInfo(); - internetAccess = true; //JsonUtils.optBoolean(info, "internet_access"); + internetAccess = JsonUtils.optBoolean(info, "internet_access"); selfAddr = info.optString("self_addr"); sendUpdateMaxSize = info.optInt("send_update_max_size"); sendUpdateInterval = info.optInt("send_update_interval"); @@ -238,10 +229,6 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE String extraHref = b.getString(EXTRA_HREF, ""); if (TextUtils.isEmpty(extraHref)) { extraHref = "index.html"; - if (this.dcAppMsg.getFromId() == DcContact.DC_CONTACT_ID_SELF) { - extraHref += "#call"; - } - } String href = baseURL + "/" + extraHref; diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java index ca80ffd97..5997e4cd0 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java @@ -17,10 +17,10 @@ public class VideochatActivity extends WebViewActivity { private static final String TAG = VideochatActivity.class.getSimpleName(); public static final String EXTRA_CHAT_ID = "chat_id"; - public static final String EXTRA_URL = "url"; + public static final String EXTRA_HASH = "hash"; private DcContext dcContext; - private String url = ""; + private String url = "file:///android_asset/call.html"; @Override protected void onCreate(Bundle state, boolean ready) { @@ -28,12 +28,12 @@ public class VideochatActivity extends WebViewActivity { this.dcContext = DcHelper.getContext(getApplicationContext()); Bundle b = getIntent().getExtras(); - url = b.getString(EXTRA_URL, ""); + String hash = b.getString(EXTRA_HASH, ""); int chatId = b.getInt(EXTRA_CHAT_ID, 0); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); - webSettings.setUserAgentString("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36"); + webSettings.setMediaPlaybackRequiresUserGesture(false); webView.setWebChromeClient(new WebChromeClient() { @Override @@ -51,7 +51,7 @@ public class VideochatActivity extends WebViewActivity { }); }); - webView.loadUrl(url); + webView.loadUrl(url+hash); } @Override diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java index 8b0cd046a..e795ed80d 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java @@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets; public class VideochatUtil { - public void invite(Activity activity, int chatId) { + public static void startMeeting(Activity activity, int chatId) { DcContext dcContext = DcHelper.getContext(activity); DcChat dcChat = dcContext.getChat(chatId); @@ -29,18 +29,7 @@ public class VideochatUtil { .setMessage(R.string.videochat_invite_user_hint) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.ok, (dialog, which) -> { - String instance = dcContext.getConfig(DcHelper.CONFIG_WEBRTC_INSTANCE); - boolean unset = instance == null || instance.isEmpty(); - if (unset) { - dcContext.setConfig(DcHelper.CONFIG_WEBRTC_INSTANCE, DcHelper.DEFAULT_VIDEOCHAT_URL); - } - int msgId = dcContext.sendVideochatInvitation(dcChat.getId()); - - if (unset) { - dcContext.setConfig(DcHelper.CONFIG_WEBRTC_INSTANCE, null); - } - if (msgId != 0) { join(activity, msgId); } @@ -48,27 +37,40 @@ public class VideochatUtil { .show(); } - public void join(Activity activity, int msgId) { + public static void joinMeeting(Activity activity, int msgId) { + DcContext dcContext = DcHelper.getContext(activity); + DcMsg dcMsg = dcContext.getMsg(msgId); + String videochatUrl = dcMsg.getVideochatUrl(); + IntentUtils.showInBrowser(activity, videochatUrl); + } + + public static void startCall(Activity activity, int chatId) { + DcContext dcContext = DcHelper.getContext(activity); + DcChat dcChat = dcContext.getChat(chatId); + + new AlertDialog.Builder(activity) + .setTitle(activity.getString(R.string.videochat_invite_user_to_videochat, dcChat.getName())) + .setNegativeButton(R.string.cancel, null) + .setPositiveButton(R.string.ok, (dialog, which) -> { + joinCall(activity, chatId, "#call"); + }) + .show(); + } + + public static void joinCall(Activity activity, int chatId) { + joinCall(activity, chatId, ""); + } + + private static void joinCall(Activity activity, int chatId, String hash) { Permissions.with(activity) .request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO) .ifNecessary() .withPermanentDenialDialog(activity.getString(R.string.perm_explain_access_to_camera_denied)) .onAllGranted(() -> { - DcContext dcContext = DcHelper.getContext(activity); - DcMsg dcMsg = dcContext.getMsg(msgId); - String url = dcMsg.getVideochatUrl(); - if (url.startsWith(DcHelper.DEFAULT_VIDEOCHAT_URL_PREFIX) && url.contains("#")) { - String name = dcContext.getName(); - try { - name = URLEncoder.encode(dcContext.getName(), StandardCharsets.UTF_8.toString()); - } catch (UnsupportedEncodingException ignored) {} - url += "&userInfo.displayName=%22" + name +"%22"; - } - Intent intent = new Intent(activity, VideochatActivity.class); intent.setAction(Intent.ACTION_VIEW); - intent.putExtra(VideochatActivity.EXTRA_CHAT_ID, dcMsg.getChatId()); - intent.putExtra(VideochatActivity.EXTRA_URL, url); + intent.putExtra(VideochatActivity.EXTRA_CHAT_ID, chatId); + intent.putExtra(VideochatActivity.EXTRA_HASH, hash); activity.startActivity(intent); }) .execute(); From 27f662707a74d98ee7fff87d4554b1ea8aed8efd Mon Sep 17 00:00:00 2001 From: adbenitez Date: Thu, 19 Jun 2025 17:20:46 +0200 Subject: [PATCH 06/76] fix VideochatUtil --- .../org/thoughtcrime/securesms/videochat/VideochatUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java index e795ed80d..716faf0c4 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java @@ -13,6 +13,7 @@ import com.b44t.messenger.DcMsg; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.connect.DcHelper; import org.thoughtcrime.securesms.permissions.Permissions; +import org.thoughtcrime.securesms.util.IntentUtils; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -31,7 +32,7 @@ public class VideochatUtil { .setPositiveButton(R.string.ok, (dialog, which) -> { int msgId = dcContext.sendVideochatInvitation(dcChat.getId()); if (msgId != 0) { - join(activity, msgId); + joinMeeting(activity, msgId); } }) .show(); From 365f1dbbe6dc609bf8dbdd2c82538327bb37c8bc Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 20 Jun 2025 18:56:45 +0200 Subject: [PATCH 07/76] basic call --- jni/deltachat-core-rust | 2 +- src/main/assets/call.html | 72 ++++++++++++++++++ .../securesms/ConversationListFragment.java | 5 ++ .../videochat/VideochatActivity.java | 75 +++++++++++++++---- .../securesms/videochat/VideochatUtil.java | 16 ++-- 5 files changed, 148 insertions(+), 22 deletions(-) create mode 100644 src/main/assets/call.html diff --git a/jni/deltachat-core-rust b/jni/deltachat-core-rust index 47b9bfc8b..c1e2f0bb1 160000 --- a/jni/deltachat-core-rust +++ b/jni/deltachat-core-rust @@ -1 +1 @@ -Subproject commit 47b9bfc8bf807ad099d2211a59d6ba80290b0c95 +Subproject commit c1e2f0bb18bfadaaf0d78848b0e990ad3b1538c7 diff --git a/src/main/assets/call.html b/src/main/assets/call.html new file mode 100644 index 000000000..15da98d8c --- /dev/null +++ b/src/main/assets/call.html @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + +
+ + diff --git a/src/main/java/org/thoughtcrime/securesms/ConversationListFragment.java b/src/main/java/org/thoughtcrime/securesms/ConversationListFragment.java index ea928ec74..af81a13b6 100644 --- a/src/main/java/org/thoughtcrime/securesms/ConversationListFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/ConversationListFragment.java @@ -51,6 +51,7 @@ import org.thoughtcrime.securesms.util.Prefs; import org.thoughtcrime.securesms.util.RelayUtil; import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.ViewUtil; +import org.thoughtcrime.securesms.videochat.VideochatUtil; import java.util.Timer; import java.util.TimerTask; @@ -81,6 +82,7 @@ public class ConversationListFragment extends BaseConversationListFragment eventCenter.addMultiAccountObserver(DcContext.DC_EVENT_INCOMING_MSG, this); eventCenter.addMultiAccountObserver(DcContext.DC_EVENT_MSGS_NOTICED, this); eventCenter.addMultiAccountObserver(DcContext.DC_EVENT_CHAT_DELETED, this); + eventCenter.addMultiAccountObserver(DcContext.DC_EVENT_INCOMING_CALL, this); eventCenter.addObserver(DcContext.DC_EVENT_CHAT_MODIFIED, this); eventCenter.addObserver(DcContext.DC_EVENT_CONTACTS_CHANGED, this); eventCenter.addObserver(DcContext.DC_EVENT_MSGS_CHANGED, this); @@ -343,6 +345,9 @@ public class ConversationListFragment extends BaseConversationListFragment ((ConversationListActivity) activity).refreshAvatar(); } + } else if (event.getId() == DcContext.DC_EVENT_INCOMING_CALL) { + // TODO: show notification + VideochatUtil.joinCall(getActivity(), event.getData1Int(), event.getData2Str()); } else { loadChatlistAsync(); } diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java index 5997e4cd0..7833b63d4 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java @@ -1,57 +1,71 @@ package org.thoughtcrime.securesms.videochat; +import android.annotation.SuppressLint; import android.os.Bundle; import android.view.Menu; +import android.webkit.JavascriptInterface; import android.webkit.PermissionRequest; import android.webkit.WebChromeClient; import android.webkit.WebSettings; +import androidx.annotation.NonNull; + import com.b44t.messenger.DcChat; import com.b44t.messenger.DcContext; +import com.b44t.messenger.DcEvent; import org.thoughtcrime.securesms.WebViewActivity; +import org.thoughtcrime.securesms.connect.DcEventCenter; import org.thoughtcrime.securesms.connect.DcHelper; import org.thoughtcrime.securesms.util.Util; -public class VideochatActivity extends WebViewActivity { - private static final String TAG = VideochatActivity.class.getSimpleName(); +import java.util.Objects; + +public class VideochatActivity extends WebViewActivity implements DcEventCenter.DcEventDelegate { public static final String EXTRA_CHAT_ID = "chat_id"; + public static final String EXTRA_CALL_ID = "call_id"; public static final String EXTRA_HASH = "hash"; private DcContext dcContext; - private String url = "file:///android_asset/call.html"; + private int chatId; + private int callId; + @SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(Bundle state, boolean ready) { super.onCreate(state, ready); this.dcContext = DcHelper.getContext(getApplicationContext()); - Bundle b = getIntent().getExtras(); - String hash = b.getString(EXTRA_HASH, ""); - int chatId = b.getInt(EXTRA_CHAT_ID, 0); + Bundle bundle = getIntent().getExtras(); + assert bundle != null; + String hash = bundle.getString(EXTRA_HASH, ""); + chatId = bundle.getInt(EXTRA_CHAT_ID, 0); + callId = bundle.getInt(EXTRA_CALL_ID, 0); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setMediaPlaybackRequiresUserGesture(false); + webView.addJavascriptInterface(new InternalJSApi(), "calls"); webView.setWebChromeClient(new WebChromeClient() { @Override public void onPermissionRequest(PermissionRequest request) { - Util.runOnMain(() -> { - request.grant(request.getResources()); - }); + Util.runOnMain(() -> request.grant(request.getResources())); } }); + DcEventCenter eventCenter = DcHelper.getEventCenter(getApplicationContext()); + eventCenter.addObserver(DcContext.DC_EVENT_OUTGOING_CALL_ACCEPTED, this); + eventCenter.addObserver(DcContext.DC_EVENT_CALL_ENDED, this); + Util.runOnAnyBackgroundThread(() -> { final DcChat chat = dcContext.getChat(chatId); - Util.runOnMain(() -> { - getSupportActionBar().setTitle(chat.getName()); - }); + Util.runOnMain(() -> Objects.requireNonNull(getSupportActionBar()).setTitle(chat.getName())); }); - webView.loadUrl(url+hash); + String url = "file:///android_asset/call.html"; + webView.loadUrl(url + hash); } @Override @@ -65,4 +79,39 @@ public class VideochatActivity extends WebViewActivity { finish(); return true; } + + @Override + public void handleEvent(@NonNull DcEvent event) { + switch (event.getId()) { + case DcContext.DC_EVENT_OUTGOING_CALL_ACCEPTED: + if (event.getData1Int() == callId) { + String hash = "#answer=" + event.getData2Str(); + webView.evaluateJavascript("window.location.hash = `"+hash+"`", null); + } + break; + case DcContext.DC_EVENT_CALL_ENDED: + if (event.getData1Int() == callId) { + finish(); + } + break; + } + } + + + class InternalJSApi { + @JavascriptInterface + public void startCall(String payload) { + callId = dcContext.placeOutgoingCall(chatId, payload); + } + + @JavascriptInterface + public void acceptCall(String payload) { + dcContext.acceptIncomingCall(callId, payload); + } + + @JavascriptInterface + public void endCall() { + dcContext.endCall(callId); + } + } } diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java index 716faf0c4..00778f577 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java @@ -15,10 +15,6 @@ import org.thoughtcrime.securesms.connect.DcHelper; import org.thoughtcrime.securesms.permissions.Permissions; import org.thoughtcrime.securesms.util.IntentUtils; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; - public class VideochatUtil { public static void startMeeting(Activity activity, int chatId) { @@ -53,16 +49,19 @@ public class VideochatUtil { .setTitle(activity.getString(R.string.videochat_invite_user_to_videochat, dcChat.getName())) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.ok, (dialog, which) -> { - joinCall(activity, chatId, "#call"); + openCall(activity, chatId, 0, "#call"); }) .show(); } - public static void joinCall(Activity activity, int chatId) { - joinCall(activity, chatId, ""); + public static void joinCall(Activity activity, int callId, String payload) { + DcContext dcContext = DcHelper.getContext(activity); + DcMsg dcMsg = dcContext.getMsg(callId); + String hash = "#offer=" + payload; + openCall(activity, dcMsg.getChatId(), callId, hash); } - private static void joinCall(Activity activity, int chatId, String hash) { + private static void openCall(Activity activity, int chatId, int callId, String hash) { Permissions.with(activity) .request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO) .ifNecessary() @@ -71,6 +70,7 @@ public class VideochatUtil { Intent intent = new Intent(activity, VideochatActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.putExtra(VideochatActivity.EXTRA_CHAT_ID, chatId); + intent.putExtra(VideochatActivity.EXTRA_CALL_ID, callId); intent.putExtra(VideochatActivity.EXTRA_HASH, hash); activity.startActivity(intent); }) From 571f49ab13095e3bc447fa8c168ff6c9f05df400 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 20 Jun 2025 19:04:42 +0200 Subject: [PATCH 08/76] revert meeting change --- .../securesms/components/AttachmentTypeSelector.java | 4 ++++ .../org/thoughtcrime/securesms/connect/DcHelper.java | 10 ++-------- .../preferences/AdvancedPreferenceFragment.java | 5 +++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java b/src/main/java/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java index 87e65e27b..5526d9b56 100644 --- a/src/main/java/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java +++ b/src/main/java/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java @@ -92,6 +92,10 @@ public class AttachmentTypeSelector extends PopupWindow { ViewUtil.findById(layout, R.id.location_linear_layout).setVisibility(View.GONE); } + if (!DcHelper.isWebrtcConfigOk(DcHelper.getContext(context))) { + ViewUtil.findById(layout, R.id.invite_video_chat_linear_layout).setVisibility(View.GONE); + } + setLocationButtonImage(context); setContentView(layout); diff --git a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java index b8f6d22c3..f4dec06d1 100644 --- a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java +++ b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java @@ -74,9 +74,6 @@ public class DcHelper { public static final String CONFIG_WEBXDC_REALTIME_ENABLED = "webxdc_realtime_enabled"; public static final String CONFIG_PRIVATE_TAG = "private_tag"; - public static final String DEFAULT_VIDEOCHAT_URL_PREFIX = "https://meet.systemli.org/"; - public static final String DEFAULT_VIDEOCHAT_URL = DEFAULT_VIDEOCHAT_URL_PREFIX + "$ROOM#config.prejoinConfig.enabled=false&config.notifications=[]&config.toolbarButtons=[%22microphone%22,%22camera%22,%22hangup%22]"; - public static DcContext getContext(@NonNull Context context) { return ApplicationContext.getInstance(context).dcContext; } @@ -406,12 +403,9 @@ public class DcHelper { } - public static String getVideochatURL(DcContext dcContext) { + public static boolean isWebrtcConfigOk(DcContext dcContext) { String instance = dcContext.getConfig(DcHelper.CONFIG_WEBRTC_INSTANCE); - if (instance != null && !instance.isEmpty()) { - return instance; - } - return DEFAULT_VIDEOCHAT_URL; + return (instance != null && !instance.isEmpty()); } @NonNull diff --git a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java index a7b24c8f8..a41f302ed 100644 --- a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java @@ -338,7 +338,7 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment View gl = View.inflate(requireActivity(), R.layout.single_line_input, null); EditText inputField = gl.findViewById(R.id.input_field); inputField.setHint(R.string.videochat_instance_placeholder); - inputField.setText(DcHelper.getVideochatURL(dcContext)); + inputField.setText(dcContext.getConfig(DcHelper.CONFIG_WEBRTC_INSTANCE)); inputField.setSelection(inputField.getText().length()); inputField.setInputType(TYPE_TEXT_VARIATION_URI); new AlertDialog.Builder(requireActivity()) @@ -381,7 +381,8 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment private void updateWebrtcSummary() { Preference webrtcInstance = this.findPreference("pref_webrtc_instance"); if (webrtcInstance != null) { - webrtcInstance.setSummary(DcHelper.getVideochatURL(dcContext)); + webrtcInstance.setSummary(DcHelper.isWebrtcConfigOk(dcContext)? + dcContext.getConfig(DcHelper.CONFIG_WEBRTC_INSTANCE) : getString(R.string.none)); } } From 8ab9b92517a8f4a78375129bbf97f492ff1fc65c Mon Sep 17 00:00:00 2001 From: adbenitez Date: Mon, 18 Aug 2025 14:47:57 +0200 Subject: [PATCH 09/76] update core --- jni/deltachat-core-rust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/deltachat-core-rust b/jni/deltachat-core-rust index c1e2f0bb1..2e2cfc4cb 160000 --- a/jni/deltachat-core-rust +++ b/jni/deltachat-core-rust @@ -1 +1 @@ -Subproject commit c1e2f0bb18bfadaaf0d78848b0e990ad3b1538c7 +Subproject commit 2e2cfc4cb3cee10b9a92489003f5b5a0b924d1e6 From 7cc9d7ea2f1cff6d9b3b5cc712ea439385ed2215 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Mon, 18 Aug 2025 14:58:35 +0200 Subject: [PATCH 10/76] update core --- jni/deltachat-core-rust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/deltachat-core-rust b/jni/deltachat-core-rust index 2e2cfc4cb..fa3616a7c 160000 --- a/jni/deltachat-core-rust +++ b/jni/deltachat-core-rust @@ -1 +1 @@ -Subproject commit 2e2cfc4cb3cee10b9a92489003f5b5a0b924d1e6 +Subproject commit fa3616a7cb26b81ebb65d2dd6624f3c2bdc548aa From c9ac4213159d780f8538217c206e4a0a3681b2fa Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 19 Aug 2025 14:00:51 +0200 Subject: [PATCH 11/76] update call.html --- src/main/assets/call.html | 56 +-------------------------------------- 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/src/main/assets/call.html b/src/main/assets/call.html index 15da98d8c..f0de1f9d8 100644 --- a/src/main/assets/call.html +++ b/src/main/assets/call.html @@ -9,62 +9,8 @@ - + - -
From 1c7c3f06e60038ea06081c08a3e3175de00c8ebd Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 22 Aug 2025 15:17:32 +0200 Subject: [PATCH 12/76] prototype with TelecomManager and ConnectionService APIs --- src/main/AndroidManifest.xml | 10 ++ .../securesms/ConversationListFragment.java | 1 - .../videochat/CallIntegrationService.java | 109 ++++++++++++++++++ .../securesms/videochat/VideochatUtil.java | 13 +++ 4 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/thoughtcrime/securesms/videochat/CallIntegrationService.java diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 03c7426cd..b987209ec 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -40,6 +40,7 @@ + @@ -400,6 +401,15 @@ android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize">
+ + + + + + = Build.VERSION_CODES.TIRAMISU) { + if (telecomManager.getOwnSelfManagedPhoneAccounts().contains(handle)) { + Log.d(TAG, "a phone account for " + accountId + " already exists"); + return; + } + } + final PhoneAccount.Builder builder = + PhoneAccount.builder(getHandle(context, accountId), accountId+""); + builder.setSupportedUriSchemes(Collections.singletonList("dc")); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + builder.setCapabilities( + PhoneAccount.CAPABILITY_SELF_MANAGED + | PhoneAccount.CAPABILITY_SUPPORTS_VIDEO_CALLING); + } + final PhoneAccount phoneAccount = builder.build(); + telecomManager.registerPhoneAccount(phoneAccount); + } + + public static void placeCall(Context context, int accountId, int chatId) { + final Bundle extras = new Bundle(); + extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, getHandle(context, accountId)); + final Bundle outgoingCallExtras = new Bundle(); + outgoingCallExtras.putInt(EXTRA_ACCOUNT_ID, accountId); + outgoingCallExtras.putInt(EXTRA_CHAT_ID, chatId); + extras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, outgoingCallExtras); + + final Uri address = Uri.parse("tel:0"); + try { + context.getSystemService(TelecomManager.class).placeCall(address, extras); + } catch (final SecurityException e) { + Log.e(TAG, "call integration not available", e); + Toast.makeText(context, "call integration not available", Toast.LENGTH_LONG).show(); + } + } + + public static void addNewIncomingCall(final Context context, int accId, int chatId, int callId, String payload) { + final PhoneAccountHandle phoneAccountHandle = getHandle(context, accId); + final Bundle bundle = new Bundle(); + bundle.putString(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, chatId+""); + final Bundle extras = new Bundle(); + extras.putInt(EXTRA_CALL_ID, callId); + extras.putString(EXTRA_CALL_PAYLOAD, payload); + bundle.putBundle(TelecomManager.EXTRA_INCOMING_CALL_EXTRAS, extras); + + try { + context.getSystemService(TelecomManager.class).addNewIncomingCall(phoneAccountHandle, bundle); + } catch (final SecurityException e) { + Log.e(TAG, "call integration not available", e); + Toast.makeText(context, "call integration not available", Toast.LENGTH_LONG).show(); + } + } + +} diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java index 00778f577..1c1784eb3 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java @@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.videochat; import android.Manifest; import android.app.Activity; import android.content.Intent; +import android.os.Build; import androidx.appcompat.app.AlertDialog; @@ -57,16 +58,28 @@ public class VideochatUtil { public static void joinCall(Activity activity, int callId, String payload) { DcContext dcContext = DcHelper.getContext(activity); DcMsg dcMsg = dcContext.getMsg(callId); + int accId = dcContext.getAccountId(); + int chatId = dcMsg.getChatId(); String hash = "#offer=" + payload; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + CallIntegrationService.addNewIncomingCall(activity, accId, chatId, callId, payload); + } openCall(activity, dcMsg.getChatId(), callId, hash); } private static void openCall(Activity activity, int chatId, int callId, String hash) { + DcContext dcContext = DcHelper.getContext(activity); + int accId = dcContext.getAccountId(); + Permissions.with(activity) .request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO) .ifNecessary() .withPermanentDenialDialog(activity.getString(R.string.perm_explain_access_to_camera_denied)) .onAllGranted(() -> { + if ("#call".equals(hash) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + CallIntegrationService.registerPhoneAccount(activity, accId); + CallIntegrationService.placeCall(activity, accId, chatId); + } Intent intent = new Intent(activity, VideochatActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.putExtra(VideochatActivity.EXTRA_CHAT_ID, chatId); From 30868198a2a43e971a6a79558ab025a7f2d1c705 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 2 Sep 2025 14:17:30 +0200 Subject: [PATCH 13/76] update calls webapp --- src/main/assets/call.html | 18 -------- src/main/assets/calls/index.html | 72 ++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 18 deletions(-) delete mode 100644 src/main/assets/call.html create mode 100644 src/main/assets/calls/index.html diff --git a/src/main/assets/call.html b/src/main/assets/call.html deleted file mode 100644 index f0de1f9d8..000000000 --- a/src/main/assets/call.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - -
- - diff --git a/src/main/assets/calls/index.html b/src/main/assets/calls/index.html new file mode 100644 index 000000000..933eed414 --- /dev/null +++ b/src/main/assets/calls/index.html @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + +
+ + From 640688d7745aa53dc7c9121914e6846b7ac15e26 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 2 Sep 2025 14:59:06 +0200 Subject: [PATCH 14/76] update code to new calls app path --- .../org/thoughtcrime/securesms/videochat/VideochatActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java index 7833b63d4..85596d43b 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java @@ -64,7 +64,7 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter. Util.runOnMain(() -> Objects.requireNonNull(getSupportActionBar()).setTitle(chat.getName())); }); - String url = "file:///android_asset/call.html"; + String url = "file:///android_asset/calls/index.html"; webView.loadUrl(url + hash); } From 01c766db41450e124b627190c1ddb2141918bc70 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Wed, 3 Sep 2025 16:02:09 +0200 Subject: [PATCH 15/76] remove old videochat invitations --- .../securesms/ConversationActivity.java | 7 ---- .../components/AttachmentTypeSelector.java | 19 +++------- .../securesms/connect/DcHelper.java | 6 --- .../AdvancedPreferenceFragment.java | 37 ------------------- .../securesms/videochat/VideochatUtil.java | 17 --------- .../res/layout/attachment_type_selector.xml | 24 ------------ src/main/res/xml/preferences_advanced.xml | 4 -- 7 files changed, 5 insertions(+), 109 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java index 203e03f1e..642c62850 100644 --- a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java @@ -965,13 +965,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity AttachmentManager.selectGallery(this, PICK_GALLERY); break; case AttachmentTypeSelector.ADD_DOCUMENT: AttachmentManager.selectDocument(this, PICK_DOCUMENT); break; - case AttachmentTypeSelector.INVITE_VIDEO_CHAT: - if (isMultiUser()) { - VideochatUtil.startMeeting(this, chatId); - } else { - VideochatUtil.startCall(this, chatId); - } - break; case AttachmentTypeSelector.ADD_CONTACT_INFO: startContactChooserActivity(); break; case AttachmentTypeSelector.ADD_LOCATION: diff --git a/src/main/java/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java b/src/main/java/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java index 5526d9b56..72baf7c1e 100644 --- a/src/main/java/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java +++ b/src/main/java/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java @@ -35,19 +35,17 @@ public class AttachmentTypeSelector extends PopupWindow { public static final int ADD_GALLERY = 1; public static final int ADD_DOCUMENT = 2; - public static final int INVITE_VIDEO_CHAT = 3; - public static final int ADD_CONTACT_INFO = 4; - public static final int TAKE_PHOTO = 5; - public static final int ADD_LOCATION = 6; - public static final int RECORD_VIDEO = 7; - public static final int ADD_WEBXDC = 8; + public static final int ADD_CONTACT_INFO = 3; + public static final int TAKE_PHOTO = 4; + public static final int ADD_LOCATION = 5; + public static final int RECORD_VIDEO = 6; + public static final int ADD_WEBXDC = 7; private static final int ANIMATION_DURATION = 300; private final @NonNull LoaderManager loaderManager; private final @NonNull RecentPhotoViewRail recentRail; private final @NonNull ImageView imageButton; - private final @NonNull ImageView videoChatButton; private final @NonNull ImageView documentButton; private final @NonNull ImageView contactButton; private final @NonNull ImageView cameraButton; @@ -70,7 +68,6 @@ public class AttachmentTypeSelector extends PopupWindow { this.chatId = chatId; this.recentRail = ViewUtil.findById(layout, R.id.recent_photos); this.imageButton = ViewUtil.findById(layout, R.id.gallery_button); - this.videoChatButton = ViewUtil.findById(layout, R.id.invite_video_chat_button); this.documentButton = ViewUtil.findById(layout, R.id.document_button); this.contactButton = ViewUtil.findById(layout, R.id.contact_button); this.cameraButton = ViewUtil.findById(layout, R.id.camera_button); @@ -79,7 +76,6 @@ public class AttachmentTypeSelector extends PopupWindow { this.webxdcButton = ViewUtil.findById(layout, R.id.webxdc_button); this.imageButton.setOnClickListener(new PropagatingClickListener(ADD_GALLERY)); - this.videoChatButton.setOnClickListener(new PropagatingClickListener(INVITE_VIDEO_CHAT)); this.documentButton.setOnClickListener(new PropagatingClickListener(ADD_DOCUMENT)); this.contactButton.setOnClickListener(new PropagatingClickListener(ADD_CONTACT_INFO)); this.cameraButton.setOnClickListener(new PropagatingClickListener(TAKE_PHOTO)); @@ -92,10 +88,6 @@ public class AttachmentTypeSelector extends PopupWindow { ViewUtil.findById(layout, R.id.location_linear_layout).setVisibility(View.GONE); } - if (!DcHelper.isWebrtcConfigOk(DcHelper.getContext(context))) { - ViewUtil.findById(layout, R.id.invite_video_chat_linear_layout).setVisibility(View.GONE); - } - setLocationButtonImage(context); setContentView(layout); @@ -139,7 +131,6 @@ public class AttachmentTypeSelector extends PopupWindow { animateButtonIn(locationButton, ANIMATION_DURATION / 4); animateButtonIn(documentButton, ANIMATION_DURATION / 4); animateButtonIn(webxdcButton, 0); - animateButtonIn(videoChatButton, 0); } @Override diff --git a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java index 57dbb94d7..2d07ad742 100644 --- a/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java +++ b/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java @@ -69,7 +69,6 @@ public class DcHelper { public static final String CONFIG_BCC_SELF = "bcc_self"; public static final String CONFIG_SHOW_EMAILS = "show_emails"; public static final String CONFIG_MEDIA_QUALITY = "media_quality"; - public static final String CONFIG_WEBRTC_INSTANCE = "webrtc_instance"; public static final String CONFIG_PROXY_ENABLED = "proxy_enabled"; public static final String CONFIG_PROXY_URL = "proxy_url"; public static final String CONFIG_VERIFIED_ONE_ON_ONE_CHATS = "verified_one_on_one_chats"; @@ -397,11 +396,6 @@ public class DcHelper { } - public static boolean isWebrtcConfigOk(DcContext dcContext) { - String instance = dcContext.getConfig(DcHelper.CONFIG_WEBRTC_INSTANCE); - return (instance != null && !instance.isEmpty()); - } - @NonNull public static ThreadRecord getThreadRecord(Context context, DcLot summary, DcChat chat) { // adapted from ThreadDatabase.getCurrent() int chatId = chat.getId(); diff --git a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java index 63d980aa1..3f18901e6 100644 --- a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java @@ -159,12 +159,6 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment submitDebugLog.setOnPreferenceClickListener(new ViewLogListener()); } - Preference webrtcInstance = this.findPreference("pref_webrtc_instance"); - if (webrtcInstance != null) { - webrtcInstance.setOnPreferenceClickListener(new WebrtcInstanceListener()); - } - updateWebrtcSummary(); - Preference webxdcStore = this.findPreference(Prefs.WEBXDC_STORE_URL_PREF); if (webxdcStore != null) { webxdcStore.setOnPreferenceClickListener(new WebxdcStoreUrlListener()); @@ -331,29 +325,6 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment } } - private class WebrtcInstanceListener implements Preference.OnPreferenceClickListener { - @Override - public boolean onPreferenceClick(@NonNull Preference preference) { - View gl = View.inflate(requireActivity(), R.layout.single_line_input, null); - EditText inputField = gl.findViewById(R.id.input_field); - inputField.setHint(R.string.videochat_instance_placeholder); - inputField.setText(dcContext.getConfig(DcHelper.CONFIG_WEBRTC_INSTANCE)); - inputField.setSelection(inputField.getText().length()); - inputField.setInputType(TYPE_TEXT_VARIATION_URI); - new AlertDialog.Builder(requireActivity()) - .setTitle(R.string.videochat_instance) - .setMessage(getString(R.string.videochat_instance_explain_2)+"\n\n"+getString(R.string.videochat_instance_example)) - .setView(gl) - .setNegativeButton(android.R.string.cancel, null) - .setPositiveButton(android.R.string.ok, (dialog, which) -> { - dcContext.setConfig(DcHelper.CONFIG_WEBRTC_INSTANCE, inputField.getText().toString()); - updateWebrtcSummary(); - }) - .show(); - return true; - } - } - private class WebxdcStoreUrlListener implements Preference.OnPreferenceClickListener { @Override public boolean onPreferenceClick(@NonNull Preference preference) { @@ -377,14 +348,6 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment } } - private void updateWebrtcSummary() { - Preference webrtcInstance = this.findPreference("pref_webrtc_instance"); - if (webrtcInstance != null) { - webrtcInstance.setSummary(DcHelper.isWebrtcConfigOk(dcContext)? - dcContext.getConfig(DcHelper.CONFIG_WEBRTC_INSTANCE) : getString(R.string.none)); - } - } - private void updateWebxdcStoreSummary() { Preference preference = this.findPreference(Prefs.WEBXDC_STORE_URL_PREF); if (preference != null) { diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java index 1c1784eb3..b3b2cfb33 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java @@ -18,23 +18,6 @@ import org.thoughtcrime.securesms.util.IntentUtils; public class VideochatUtil { - public static void startMeeting(Activity activity, int chatId) { - DcContext dcContext = DcHelper.getContext(activity); - DcChat dcChat = dcContext.getChat(chatId); - - new AlertDialog.Builder(activity) - .setTitle(activity.getString(R.string.videochat_invite_user_to_videochat, dcChat.getName())) - .setMessage(R.string.videochat_invite_user_hint) - .setNegativeButton(R.string.cancel, null) - .setPositiveButton(R.string.ok, (dialog, which) -> { - int msgId = dcContext.sendVideochatInvitation(dcChat.getId()); - if (msgId != 0) { - joinMeeting(activity, msgId); - } - }) - .show(); - } - public static void joinMeeting(Activity activity, int msgId) { DcContext dcContext = DcHelper.getContext(activity); DcMsg dcMsg = dcContext.getMsg(msgId); diff --git a/src/main/res/layout/attachment_type_selector.xml b/src/main/res/layout/attachment_type_selector.xml index 114932d4d..10f6da10f 100644 --- a/src/main/res/layout/attachment_type_selector.xml +++ b/src/main/res/layout/attachment_type_selector.xml @@ -209,30 +209,6 @@ - - - - - - - - diff --git a/src/main/res/xml/preferences_advanced.xml b/src/main/res/xml/preferences_advanced.xml index 3b310679a..59ee601cc 100644 --- a/src/main/res/xml/preferences_advanced.xml +++ b/src/main/res/xml/preferences_advanced.xml @@ -16,10 +16,6 @@ - - From 9ef01dd3528b6d5fc776d4d1a43f49c255fa0b17 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Wed, 3 Sep 2025 16:07:19 +0200 Subject: [PATCH 16/76] add calls button --- .../securesms/ConversationActivity.java | 5 +++++ .../preferences/AdvancedPreferenceFragment.java | 16 ++++++++++++++++ .../org/thoughtcrime/securesms/util/Prefs.java | 5 +++++ src/main/res/menu/conversation.xml | 5 +++++ src/main/res/values/strings.xml | 3 +++ src/main/res/xml/preferences_advanced.xml | 5 +++++ 6 files changed, 39 insertions(+) diff --git a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java index 642c62850..1990473d9 100644 --- a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java @@ -442,6 +442,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity menu.findItem(R.id.menu_show_map).setVisible(false); } + menu.findItem(R.id.menu_start_call).setVisible(Prefs.isCallsEnabled(this) && dcChat.isEncrypted() && !isMultiUser()); + if (!dcChat.isEncrypted() || !dcChat.canSend() || dcChat.isMailingList() ) { menu.findItem(R.id.menu_ephemeral_messages).setVisible(false); } @@ -532,6 +534,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity } else if (itemId == R.id.menu_show_map) { WebxdcActivity.openMaps(this, chatId); return true; + } else if (itemId == R.id.menu_start_call) { + VideochatUtil.startCall(this, chatId); + return true; } else if (itemId == R.id.menu_all_media) { handleAllMedia(); return true; diff --git a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java index 3f18901e6..b6225518e 100644 --- a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java @@ -205,6 +205,22 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment }); } + Preference callsEnabled = this.findPreference("pref_calls_enabled"); + if (callsEnabled != null) { + callsEnabled.setOnPreferenceChangeListener((preference, newValue) -> { + if ((Boolean)newValue) { + new AlertDialog.Builder(requireActivity()) + .setTitle("Thanks for trying out \"Video Calls\"!") + .setMessage("• You can now call contacts\n\n" + + "• If you want to quit the experimental feature, you can disable it at \"Settings / Advanced\"") + .setCancelable(false) + .setPositiveButton(R.string.ok, null) + .show(); + } + return true; + }); + } + Preference selfReporting = this.findPreference("pref_self_reporting"); if (selfReporting != null) { selfReporting.setOnPreferenceClickListener(((preference) -> { diff --git a/src/main/java/org/thoughtcrime/securesms/util/Prefs.java b/src/main/java/org/thoughtcrime/securesms/util/Prefs.java index 355b56d63..0a01b3878 100644 --- a/src/main/java/org/thoughtcrime/securesms/util/Prefs.java +++ b/src/main/java/org/thoughtcrime/securesms/util/Prefs.java @@ -179,6 +179,11 @@ public class Prefs { return getBooleanPreference(context, "pref_new_broadcast_list", false); } + + public static boolean isCallsEnabled(Context context) { + return getBooleanPreference(context, "pref_calls_enabled", false); + } + // ringtone public static @NonNull Uri getNotificationRingtone(Context context) { diff --git a/src/main/res/menu/conversation.xml b/src/main/res/menu/conversation.xml index 2cbf9a2c9..cbe09e6f7 100644 --- a/src/main/res/menu/conversation.xml +++ b/src/main/res/menu/conversation.xml @@ -25,6 +25,11 @@ android:visible="false" app:showAsAction="always"/> + + File saved to \"%1$s\". + Call + Video Calls + Video Chat diff --git a/src/main/res/xml/preferences_advanced.xml b/src/main/res/xml/preferences_advanced.xml index 59ee601cc..4cb87cfa1 100644 --- a/src/main/res/xml/preferences_advanced.xml +++ b/src/main/res/xml/preferences_advanced.xml @@ -20,6 +20,11 @@ android:title="@string/webxdc_store_url" android:summary="@string/none"/> + + Date: Fri, 5 Sep 2025 14:58:10 +0200 Subject: [PATCH 17/76] end call on closing webview --- .../securesms/videochat/VideochatActivity.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java index 85596d43b..0073baac7 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java @@ -30,6 +30,7 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter. private DcContext dcContext; private int chatId; private int callId; + private boolean ended = false; @SuppressLint("SetJavaScriptEnabled") @Override @@ -68,6 +69,13 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter. webView.loadUrl(url + hash); } + @Override + protected void onDestroy() { + DcHelper.getEventCenter(this).removeObservers(this); + if (callId != 0 && !ended) dcContext.endCall(callId); + super.onDestroy(); + } + @Override public boolean onPrepareOptionsMenu(Menu menu) { // do not call super.onPrepareOptionsMenu() as the default "Search" menu is not needed @@ -91,6 +99,7 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter. break; case DcContext.DC_EVENT_CALL_ENDED: if (event.getData1Int() == callId) { + ended = true; finish(); } break; @@ -111,7 +120,7 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter. @JavascriptInterface public void endCall() { - dcContext.endCall(callId); + finish(); } } } From 831ce196898b51b38f694085b0f0bc276066206d Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 5 Sep 2025 18:43:16 +0200 Subject: [PATCH 18/76] update core --- jni/deltachat-core-rust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/deltachat-core-rust b/jni/deltachat-core-rust index fa3616a7c..b6ab13f1d 160000 --- a/jni/deltachat-core-rust +++ b/jni/deltachat-core-rust @@ -1 +1 @@ -Subproject commit fa3616a7cb26b81ebb65d2dd6624f3c2bdc548aa +Subproject commit b6ab13f1de796b760e6c2981225b48e49f924b77 From 0157510c5d8df53941952ffcef7026268440a8c9 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Sat, 6 Sep 2025 21:39:06 +0200 Subject: [PATCH 19/76] don't ask to start call --- .../securesms/videochat/VideochatUtil.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java index b3b2cfb33..cf6bf8d1e 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java @@ -26,16 +26,7 @@ public class VideochatUtil { } public static void startCall(Activity activity, int chatId) { - DcContext dcContext = DcHelper.getContext(activity); - DcChat dcChat = dcContext.getChat(chatId); - - new AlertDialog.Builder(activity) - .setTitle(activity.getString(R.string.videochat_invite_user_to_videochat, dcChat.getName())) - .setNegativeButton(R.string.cancel, null) - .setPositiveButton(R.string.ok, (dialog, which) -> { - openCall(activity, chatId, 0, "#call"); - }) - .show(); + openCall(activity, chatId, 0, "#call"); } public static void joinCall(Activity activity, int callId, String payload) { From 4fc115b93ddad42b945621c0e2b05a1b0f911393 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 9 Sep 2025 13:22:20 +0200 Subject: [PATCH 20/76] add basic notification --- .../notifications/NotificationCenter.java | 139 +++++++++++++++--- .../videochat/CallIntegrationService.java | 11 ++ .../securesms/videochat/VideochatUtil.java | 4 +- 3 files changed, 129 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java b/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java index 5e2f07d1d..ef44f7b93 100644 --- a/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java +++ b/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java @@ -13,6 +13,7 @@ import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.media.AudioAttributes; +import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; import android.text.TextUtils; @@ -202,6 +203,7 @@ public class NotificationCenter { public static final String CH_MSG_VERSION = "5"; public static final String CH_PERMANENT = "dc_foreground_notification_ch"; public static final String CH_GENERIC = "ch_generic"; + public static final String CH_CALLS_PREFIX = "call_chan"; private boolean notificationChannelsSupported() { return Build.VERSION.SDK_INT >= 26; @@ -333,10 +335,93 @@ public class NotificationCenter { return channelId; } + private String getCallNotificationChannel(NotificationManagerCompat notificationManager, ChatData chatData, String name) { + String channelId = CH_CALLS_PREFIX + "-" + chatData.accountId + "-"+ chatData.chatId; + + if (notificationChannelsSupported()) { + try { + name = "(calls) " + name; + + // check if there is already a channel with the given name + List channels = notificationManager.getNotificationChannels(); + boolean channelExists = false; + for (int i = 0; i < channels.size(); i++) { + String currChannelId = channels.get(i).getId(); + if (currChannelId.startsWith(CH_CALLS_PREFIX)) { + // this is one of the calls channels handled here ... + if (currChannelId.equals(channelId)) { + // ... this is the actually required channel, fine :) + // update the name to reflect localize changes and chat renames + channelExists = true; + channels.get(i).setName(name); + } + } + } + + // create a the channel + if(!channelExists) { + NotificationChannel channel = new NotificationChannel(channelId, name, NotificationManager.IMPORTANCE_HIGH); + channel.setDescription("Informs about incoming calls."); + channel.setShowBadge(true); + + Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); + channel.setSound(ringtone, + new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN) + .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) + .build()); + notificationManager.createNotificationChannel(channel); + } + } catch(Exception e) { + Log.e(TAG, "Error in getCallNotificationChannel()", e); + } + } + + return channelId; + } + // add notifications & co. // -------------------------------------------------------------------------------------------- + public void addCallNotification(int accId, int chatId, int callId) { + Util.runOnAnyBackgroundThread(() -> { + NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); + DcContext dcContext = context.dcAccounts.getAccount(accId); + DcChat dcChat = dcContext.getChat(chatId); + String name = dcChat.getName(); + ChatData chatData = new ChatData(accId, chatId); + String notificationChannel = getCallNotificationChannel(notificationManager, chatData, name); + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, notificationChannel) + .setSmallIcon(R.drawable.icon_notification) + .setColor(context.getResources().getColor(R.color.delta_primary)) + .setPriority(NotificationCompat.PRIORITY_HIGH) + .setCategory(NotificationCompat.CATEGORY_CALL) + .setOngoing(true) + .setOnlyAlertOnce(false) + .setTicker(name) + .setContentTitle(name) + .setContentText("Incoming Call") + ; + // .setDeleteIntenta(getMarkAsReadIntent(chatData, msgId, false)) + // .setContentIntent(getOpenChatIntent(chatData)); + + Bitmap bitmap = getAvatar(dcChat); + if (bitmap != null) { + builder.setLargeIcon(bitmap); + } + + Notification notif = builder.build(); + notif.flags = notif.flags | Notification.FLAG_INSISTENT; + // add notification, we use one notification per chat, + // esp. older android are not that great at grouping + try { + notificationManager.notify(String.valueOf(accId), ID_MSG_OFFSET + chatId, notif); + } catch (Exception e) { + Log.e(TAG, "cannot add notification", e); + } + }); + } + public void notifyMessage(int accountId, int chatId, int msgId) { Util.runOnAnyBackgroundThread(() -> { DcContext dcContext = context.dcAccounts.getAccount(accountId); @@ -495,31 +580,11 @@ public class NotificationCenter { } // set avatar - Recipient recipient = new Recipient(context, dcChat); if (privacy.isDisplayContact()) { - try { - Drawable drawable; - ContactPhoto contactPhoto = recipient.getContactPhoto(context); - if (contactPhoto != null) { - drawable = GlideApp.with(context.getApplicationContext()) - .load(contactPhoto) - .diskCacheStrategy(DiskCacheStrategy.NONE) - .circleCrop() - .submit(context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width), - context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height)) - .get(); - - } else { - drawable = recipient.getFallbackContactPhoto().asDrawable(context, recipient.getFallbackAvatarColor()); - } - if (drawable != null) { - int wh = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size); - Bitmap bitmap = BitmapUtil.createFromDrawable(drawable, wh, wh); - if (bitmap != null) { - builder.setLargeIcon(bitmap); - } - } - } catch (Exception e) { Log.w(TAG, e); } + Bitmap bitmap = getAvatar(dcChat); + if (bitmap != null) { + builder.setLargeIcon(bitmap); + } } // add buttons that allow some actions without opening Delta Chat. @@ -619,6 +684,32 @@ public class NotificationCenter { } } + public Bitmap getAvatar(DcChat dcChat) { + Recipient recipient = new Recipient(context, dcChat); + try { + Drawable drawable; + ContactPhoto contactPhoto = recipient.getContactPhoto(context); + if (contactPhoto != null) { + drawable = GlideApp.with(context.getApplicationContext()) + .load(contactPhoto) + .diskCacheStrategy(DiskCacheStrategy.NONE) + .circleCrop() + .submit(context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width), + context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height)) + .get(); + + } else { + drawable = recipient.getFallbackContactPhoto().asDrawable(context, recipient.getFallbackAvatarColor()); + } + if (drawable != null) { + int wh = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size); + return BitmapUtil.createFromDrawable(drawable, wh, wh); + } + } catch (Exception e) { Log.w(TAG, e); } + + return null; + } + public void removeNotifications(int accountId, int chatId) { boolean removeSummary; synchronized (inboxes) { diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/CallIntegrationService.java b/src/main/java/org/thoughtcrime/securesms/videochat/CallIntegrationService.java index 96aa00bf5..1e7f523e4 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/CallIntegrationService.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/CallIntegrationService.java @@ -46,6 +46,17 @@ public class CallIntegrationService extends ConnectionService { }; } + @Override + public Connection onCreateIncomingConnection(final PhoneAccountHandle phoneAccountHandle, final ConnectionRequest request) { + Log.d(TAG, "onCreateIncomingConnection()"); + return new Connection() { + @Override + public void onAnswer() { + super.onAnswer(); + } + }; + } + private static PhoneAccountHandle getHandle(final Context context, int accountId) { final ComponentName componentName = new ComponentName(context, CallIntegrationService.class); return new PhoneAccountHandle(componentName, accountId+""); diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java index cf6bf8d1e..8201134c7 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatUtil.java @@ -35,10 +35,12 @@ public class VideochatUtil { int accId = dcContext.getAccountId(); int chatId = dcMsg.getChatId(); String hash = "#offer=" + payload; + + DcHelper.getNotificationCenter(activity).addCallNotification(accId, chatId, callId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { CallIntegrationService.addNewIncomingCall(activity, accId, chatId, callId, payload); } - openCall(activity, dcMsg.getChatId(), callId, hash); + //openCall(activity, chatId, callId, hash); } private static void openCall(Activity activity, int chatId, int callId, String hash) { From 2cc0451a8a62e3f054f1036229c1d2a743b0ffef Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 9 Sep 2025 13:48:40 +0200 Subject: [PATCH 21/76] update core --- jni/deltachat-core-rust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/deltachat-core-rust b/jni/deltachat-core-rust index b6ab13f1d..75bcf8660 160000 --- a/jni/deltachat-core-rust +++ b/jni/deltachat-core-rust @@ -1 +1 @@ -Subproject commit b6ab13f1de796b760e6c2981225b48e49f924b77 +Subproject commit 75bcf8660bca5b80bea7835bd85df11518a0f7e4 From 6f10a90c5fb7debd4c9a08f34449338950848b09 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 9 Sep 2025 14:58:05 +0200 Subject: [PATCH 22/76] update calls webapp 0.4.0-beta --- src/main/assets/calls/index.html | 54 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/assets/calls/index.html b/src/main/assets/calls/index.html index 933eed414..53aa9bea8 100644 --- a/src/main/assets/calls/index.html +++ b/src/main/assets/calls/index.html @@ -9,57 +9,57 @@ - +`+T(l));break}$.push(H)}}if(l.__c!=null&&l.__c.__H!=null){var P=l.__c.__H.__;if(P)for(var D=0;D=n.__.length&&n.__.push({}),n.__[e]}function jt(e){return J=1,At(mt,e)}function At(e,t,n){var o=be(Y++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):mt(void 0,t),function(s){var u=o.__N?o.__N[0]:o.__[0],c=o.t(u,s);u!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=k,!k.__f)){var r=function(s,u,c){if(!o.__c.__H)return!0;var v=o.__c.__H.__.filter(function(y){return!!y.__c});if(v.every(function(y){return!y.__N}))return!i||i.call(this,s,u,c);var a=o.__c.props!==s;return v.forEach(function(y){if(y.__N){var h=y.__[0];y.__=y.__N,y.__N=void 0,h!==y.__[0]&&(a=!0)}}),i&&i.call(this,s,u,c)||a};k.__f=!0;var i=k.shouldComponentUpdate,_=k.componentWillUpdate;k.componentWillUpdate=function(s,u,c){if(this.__e){var v=i;i=void 0,r(s,u,c),i=v}_&&_.call(this,s,u,c)},k.shouldComponentUpdate=r}return o.__N||o.__}function Ut(e,t){var n=be(Y++,3);!x.__s&&ht(n.__H,t)&&(n.__=e,n.u=t,k.__H.__h.push(n))}function Ie(e){return J=5,dt(function(){return{current:e}},[])}function dt(e,t){var n=be(Y++,7);return ht(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ft(e,t){return J=8,dt(function(){return e},t)}function Mt(){for(var e;e=pt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ee),e.__H.__h.forEach(de),e.__H.__h=[]}catch(t){e.__H.__h=[],x.__e(t,e.__v)}}x.__b=function(e){k=null,$e&&$e(e)},x.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),De&&De(e,t)},x.__r=function(e){Se&&Se(e),Y=0;var t=(k=e.__c).__H;t&&(_e===k?(t.__h=[],k.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(ee),t.__h.forEach(de),t.__h=[],Y=0)),_e=k},x.diffed=function(e){Ee&&Ee(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(pt.push(t)!==1&&Te===x.requestAnimationFrame||((Te=x.requestAnimationFrame)||Lt)(Mt)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),_e=k=null},x.__c=function(e,t){t.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(o){return!o.__||de(o)})}catch(o){t.some(function(r){r.__h&&(r.__h=[])}),t=[],x.__e(o,n.__v)}}),Pe&&Pe(e,t)},x.unmount=function(e){Oe&&Oe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ee(o)}catch(r){t=r}}),n.__H=void 0,t&&x.__e(t,n.__v))};var Re=typeof requestAnimationFrame=="function";function Lt(e){var t,n=function(){clearTimeout(o),Re&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Re&&(t=requestAnimationFrame(n))}function ee(e){var t=k,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),k=t}function de(e){var t=k;e.__c=e.__(),k=t}function ht(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function mt(e,t){return typeof t=="function"?t(e):t}function vt(e,t){for(var n in t)e[n]=t[n];return e}function He(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function je(e,t){this.props=e,this.context=t}(je.prototype=new E).isPureReactComponent=!0,je.prototype.shouldComponentUpdate=function(e,t){return He(this.props,e)||He(this.state,t)};var Ae=p.__b;p.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ae&&Ae(e)};var Wt=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function yt(e){function t(n){var o=vt({},n);return delete o.ref,e(o,n.ref||null)}return t.$$typeof=Wt,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Bt=p.__e;p.__e=function(e,t,n,o){if(e.then){for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t)}Bt(e,t,n,o)};var Ue=p.unmount;function bt(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=vt({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return bt(o,t,n)})),e}function gt(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return gt(o,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function se(){this.__u=0,this.o=null,this.__b=null}function wt(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function K(){this.i=null,this.l=null}p.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ue&&Ue(e)},(se.prototype=new E).__c=function(e,t){var n=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(n);var r=wt(o.__v),i=!1,_=function(){i||(i=!0,n.__R=null,r?r(s):s())};n.__R=_;var s=function(){if(!--o.__u){if(o.state.__a){var u=o.state.__a;o.__v.__k[0]=gt(u,u.__c.__P,u.__c.__O)}var c;for(o.setState({__a:o.__b=null});c=o.o.pop();)c.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(_,_)},se.prototype.componentWillUnmount=function(){this.o=[]},se.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=bt(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&fe(F,null,e.fallback);return r&&(r.__u&=-33),[fe(F,null,t.__a?null:e.children),r]};var Fe=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]{});this.peerConnection=new RTCPeerConnection(en),this.state="connecting",this.iceTricklingBuffer=[],this.iceTricklingDataChannel=this.peerConnection.createDataChannel("iceTrickling",{negotiated:!0,id:1}),this.iceTricklingDataChannel.onmessage=t=>{console.log("received ICE candidate from remote peer",t.data),this.peerConnection.addIceCandidate(JSON.parse(t.data))},this.iceTricklingDataChannel.onopen=()=>{console.log("iceTricklingDataChannel open: sending buffered ICE candidates",this.iceTricklingBuffer);for(const t of this.iceTricklingBuffer)Ve(this.iceTricklingDataChannel,t);this.iceTricklingBuffer=[]}}async init(t,n,o){this.onStateChanged=o,this.peerConnection.ontrack=s=>{const u=s.streams[0];n(u),this.state="in-call",this.onStateChanged(this.state)},t.getTracks().forEach(s=>this.peerConnection.addTrack(s,t));const r=async s=>{const u=qe(this.peerConnection),c={type:"offer",sdp:s},v=new RTCSessionDescription(c);this.peerConnection.setRemoteDescription(v),this.peerConnection.setLocalDescription(await this.peerConnection.createAnswer()),await u;const a=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),window.calls.acceptCall(encodeURIComponent(a))},i=s=>{const u={type:"answer",sdp:s},c=new RTCSessionDescription(u);this.peerConnection.setRemoteDescription(c)},_=async()=>{const s=decodeURIComponent(window.location.hash.substring(1));console.log("hash changed",s),s==="call"?await this.startCall():s.startsWith("offer=")?await r(s.substring(6)):s.startsWith("answer=")&&i(s.substring(7))};_(),window.addEventListener("hashchange",_)}async startCall(){const t=qe(this.peerConnection);this.peerConnection.setLocalDescription(await this.peerConnection.createOffer()),await t;const n=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),window.calls.startCall(encodeURIComponent(n)),this.state="ringing",this.onStateChanged(this.state)}async endCall(){window.calls.endCall()}getState(){return this.state}trickleIceOverDataChannel(t){if(this.iceTricklingDataChannel.readyState!=="open"){console.log("Gathered new ICE candidate, but iceTricklingDataChannel is not yet open, will buffer it",t.candidate),this.iceTricklingBuffer.push(t.candidate);return}Ve(this.iceTricklingDataChannel,t.candidate)}}function qe(e){(e.localDescription!=null||e.remoteDescription!=null)&&console.warn("gatheredEnoughIce called after setLocalDescription or setRemoteDescription: it might not have captured all ICE candidate events");const t=new Promise(o=>{const r=i=>{i.candidate!=null&&i.candidate.type==="relay"&&(setTimeout(o,100),e.removeEventListener("icecandidate",r))};e.addEventListener("icecandidate",r)}),n=new Promise(o=>{const r=()=>{e.iceGatheringState==="complete"&&(o(),e.removeEventListener("icegatheringstatechange",r))};e.addEventListener("icegatheringstatechange",r)});return Promise.race([t,n])}function Ve(e,t){console.log("sending ICE candidate to remote peer",t),e.send(JSON.stringify(t===null?t:t.toJSON()))}var nn=0;function w(e,t,n,o,r,i){t||(t={});var _,s,u=t;if("ref"in u)for(s in u={},t)s=="ref"?_=t[s]:u[s]=t[s];var c={type:e,props:u,key:n,ref:_,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--nn,__i:-1,__u:0,__source:r,__self:i};if(typeof e=="function"&&(_=e.defaultProps))for(s in _)u[s]===void 0&&(u[s]=_[s]);return p.vnode&&p.vnode(c),c}var ze="/home/runner/work/calls-webapp/calls-webapp/src/components/VideoThumbnail.tsx";const on={position:"absolute",right:"15px",top:"15px",height:"100px",width:"100px",zIndex:1,imageRendering:"crisp-edges",borderRadius:"5px",boxShadow:"rgba(0, 0, 0, 0.29) 0px 2px 8px 0px, rgba(0, 0, 0, 0.28) 0px 2px 8px 0px"};function rn({videoRef:e}){return w("div",{style:on,children:w("video",{style:{borderRadius:"5px",objectFit:"cover",transform:"scaleX(-1)"},width:"100%",height:"100%",muted:!0,autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:ze,lineNumber:21,columnNumber:7},this)},void 0,!1,{fileName:ze,lineNumber:20,columnNumber:5},this)}var Ye="/home/runner/work/calls-webapp/calls-webapp/src/components/FullscreenVideo.tsx";const an={imageRendering:"crisp-edges",width:"100%",height:"100%"};function ln({videoRef:e}){return w("div",{style:an,children:w("video",{style:{transform:"scaleX(-1)"},width:"100%",height:"100%",autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:Ye,lineNumber:14,columnNumber:7},this)},void 0,!1,{fileName:Ye,lineNumber:13,columnNumber:5},this)}var Je="/home/runner/work/calls-webapp/calls-webapp/~icons/material-symbols/call-end.jsx";const _n=(e,t)=>w("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:w("path",{fill:"currentColor",d:"M12 8q2.95 0 5.813 1.188T22.9 12.75q.3.3.3.7t-.3.7l-2.3 2.25q-.275.275-.638.3t-.662-.2l-2.9-2.2q-.2-.15-.3-.35t-.1-.45v-2.85q-.95-.3-1.95-.475T12 10t-2.05.175T8 10.65v2.85q0 .25-.1.45t-.3.35l-2.9 2.2q-.3.225-.663.2t-.637-.3l-2.3-2.25q-.3-.3-.3-.7t.3-.7q2.2-2.375 5.075-3.562T12 8"},void 0,!1,{fileName:Je,lineNumber:3,columnNumber:123},void 0)},void 0,!1,{fileName:Je,lineNumber:3,columnNumber:48},void 0),sn=yt(_n),cn="_btn_ppybd_1",un={btn:cn};var fn="/home/runner/work/calls-webapp/calls-webapp/src/components/Button.tsx";function pn({children:e,...t}){return w("div",{className:un.btn,...t,children:e},void 0,!1,{fileName:fn,lineNumber:10,columnNumber:5},this)}var Xe="/home/runner/work/calls-webapp/calls-webapp/src/components/EndCallButton.tsx";const Ge={color:"white",background:"#cb2233",borderRadius:"50%",fontSize:"1.5em"};function dn({...e}){return e.style={...Ge,...e.style||{}},w(pn,{style:Ge,...e,children:w(sn,{},void 0,!1,{fileName:Xe,lineNumber:20,columnNumber:7},this)},void 0,!1,{fileName:Xe,lineNumber:19,columnNumber:5},this)}var Ke="/home/runner/work/calls-webapp/calls-webapp/~icons/material-symbols/person.jsx";const hn=(e,t)=>w("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:w("path",{fill:"currentColor",d:"M12 12q-1.65 0-2.825-1.175T8 8t1.175-2.825T12 4t2.825 1.175T16 8t-1.175 2.825T12 12m-8 8v-2.8q0-.85.438-1.562T5.6 14.55q1.55-.775 3.15-1.162T12 13t3.25.388t3.15 1.162q.725.375 1.163 1.088T20 17.2V20z"},void 0,!1,{fileName:Ke,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:Ke,lineNumber:3,columnNumber:47},void 0),mn=yt(hn);var vn="/home/runner/work/calls-webapp/calls-webapp/src/components/AvatarCircle.tsx";const Ze={display:"inline-flex",flexDirection:"row",alignItems:"center",padding:"0.5em",color:"white",background:"#c8c7cd",borderRadius:"50%",fontSize:"1.5em"};function yn({children:e,...t}){return t.style={...Ze,...t.style||{}},w("div",{style:Ze,...t,children:e},void 0,!1,{fileName:vn,lineNumber:20,columnNumber:5},this)}var Qe="/home/runner/work/calls-webapp/calls-webapp/src/components/AvatarPlaceholder.tsx";function bn({...e}){return w(yn,{style:{padding:"0.2em",fontSize:"5em"},...e,children:w(mn,{},void 0,!1,{fileName:Qe,lineNumber:12,columnNumber:7},this)},void 0,!1,{fileName:Qe,lineNumber:11,columnNumber:5},this)}var A="/home/runner/work/calls-webapp/calls-webapp/src/App.tsx";const Z=new tn;function gn(){const[e,t]=ie(jt(Z.getState()),"state"),n=ie(Ie(null),"outVidRef"),o=ie(Ie(null),"incVidRef");Ut(()=>{(async()=>{const u=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0});n.current.srcObject=u;const c=v=>{o.current.srcObject=v};await Z.init(u,c,t)})()},[]);const r=Ft(()=>{Z.endCall()},[Z]);let i="";e==="connecting"?i="Connecting...":e==="ringing"&&(i="Ringing...");const _=e==="in-call";return w("div",{style:{height:"100vh",overflow:"hidden"},children:[w("div",{style:{display:_?"block":"none",height:"100%"},children:[w(ln,{videoRef:o},void 0,!1,{fileName:A,lineNumber:54,columnNumber:9},this),w(rn,{videoRef:n},void 0,!1,{fileName:A,lineNumber:55,columnNumber:9},this)]},void 0,!0,{fileName:A,lineNumber:53,columnNumber:7},this),w("div",{style:{position:"absolute",top:0,width:"100%",paddingTop:"1em",textAlign:"center"},children:i},void 0,!1,{fileName:A,lineNumber:58,columnNumber:7},this),w("div",{style:{display:_?"none":"flex",alignItems:"center",textAlign:"center",justifyContent:"center",height:"100%"},children:w(bn,{},void 0,!1,{fileName:A,lineNumber:78,columnNumber:9},this)},void 0,!1,{fileName:A,lineNumber:69,columnNumber:7},this),w("div",{style:{position:"absolute",bottom:"1em",width:"100%",textAlign:"center"},children:w(dn,{onClick:r},void 0,!1,{fileName:A,lineNumber:88,columnNumber:9},this)},void 0,!1,{fileName:A,lineNumber:80,columnNumber:7},this)]},void 0,!0,{fileName:A,lineNumber:52,columnNumber:5},this)}var wn="/home/runner/work/calls-webapp/calls-webapp/src/index.tsx";Ot(w(gn,{},void 0,!1,{fileName:wn,lineNumber:4,columnNumber:8},void 0),document.getElementById("root")); - +`+T(l));break}S.push(R)}}if(l.__c!=null&&l.__c.__H!=null){var P=l.__c.__H.__;if(P)for(var O=0;O=n.__.length&&n.__.push({}),n.__[e]}function At(e){return J=1,Ht(mt,e)}function Ht(e,t,n){var o=ge(Y++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):mt(void 0,t),function(s){var c=o.__N?o.__N[0]:o.__[0],u=o.t(c,s);c!==u&&(o.__N=[u,o.__[1]],o.__c.setState({}))}],o.__c=k,!k.__f)){var r=function(s,c,u){if(!o.__c.__H)return!0;var v=o.__c.__H.__.filter(function(y){return!!y.__c});if(v.every(function(y){return!y.__N}))return!i||i.call(this,s,c,u);var a=o.__c.props!==s;return v.forEach(function(y){if(y.__N){var h=y.__[0];y.__=y.__N,y.__N=void 0,h!==y.__[0]&&(a=!0)}}),i&&i.call(this,s,c,u)||a};k.__f=!0;var i=k.shouldComponentUpdate,_=k.componentWillUpdate;k.componentWillUpdate=function(s,c,u){if(this.__e){var v=i;i=void 0,r(s,c,u),i=v}_&&_.call(this,s,c,u)},k.shouldComponentUpdate=r}return o.__N||o.__}function Ut(e,t){var n=ge(Y++,3);!x.__s&&ht(n.__H,t)&&(n.__=e,n.u=t,k.__H.__h.push(n))}function je(e){return J=5,dt(function(){return{current:e}},[])}function dt(e,t){var n=ge(Y++,7);return ht(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ft(e,t){return J=8,dt(function(){return e},t)}function Lt(){for(var e;e=pt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ee),e.__H.__h.forEach(de),e.__H.__h=[]}catch(t){e.__H.__h=[],x.__e(t,e.__v)}}x.__b=function(e){k=null,Se&&Se(e)},x.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Oe&&Oe(e,t)},x.__r=function(e){$e&&$e(e),Y=0;var t=(k=e.__c).__H;t&&(_e===k?(t.__h=[],k.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(ee),t.__h.forEach(de),t.__h=[],Y=0)),_e=k},x.diffed=function(e){Ee&&Ee(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(pt.push(t)!==1&&Te===x.requestAnimationFrame||((Te=x.requestAnimationFrame)||Mt)(Lt)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),_e=k=null},x.__c=function(e,t){t.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(o){return!o.__||de(o)})}catch(o){t.some(function(r){r.__h&&(r.__h=[])}),t=[],x.__e(o,n.__v)}}),Pe&&Pe(e,t)},x.unmount=function(e){De&&De(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ee(o)}catch(r){t=r}}),n.__H=void 0,t&&x.__e(t,n.__v))};var Ie=typeof requestAnimationFrame=="function";function Mt(e){var t,n=function(){clearTimeout(o),Ie&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Ie&&(t=requestAnimationFrame(n))}function ee(e){var t=k,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),k=t}function de(e){var t=k;e.__c=e.__(),k=t}function ht(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function mt(e,t){return typeof t=="function"?t(e):t}function vt(e,t){for(var n in t)e[n]=t[n];return e}function Re(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function Ae(e,t){this.props=e,this.context=t}(Ae.prototype=new E).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(e,t){return Re(this.props,e)||Re(this.state,t)};var He=p.__b;p.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),He&&He(e)};var zt=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function yt(e){function t(n){var o=vt({},n);return delete o.ref,e(o,n.ref||null)}return t.$$typeof=zt,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Wt=p.__e;p.__e=function(e,t,n,o){if(e.then){for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t)}Wt(e,t,n,o)};var Ue=p.unmount;function gt(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=vt({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return gt(o,t,n)})),e}function bt(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return bt(o,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function se(){this.__u=0,this.o=null,this.__b=null}function wt(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function K(){this.i=null,this.l=null}p.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ue&&Ue(e)},(se.prototype=new E).__c=function(e,t){var n=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(n);var r=wt(o.__v),i=!1,_=function(){i||(i=!0,n.__R=null,r?r(s):s())};n.__R=_;var s=function(){if(!--o.__u){if(o.state.__a){var c=o.state.__a;o.__v.__k[0]=bt(c,c.__c.__P,c.__c.__O)}var u;for(o.setState({__a:o.__b=null});u=o.o.pop();)u.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(_,_)},se.prototype.componentWillUnmount=function(){this.o=[]},se.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=gt(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&fe(F,null,e.fallback);return r&&(r.__u&=-33),[fe(F,null,t.__a?null:e.children),r]};var Fe=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]{});this.peerConnection=new RTCPeerConnection(tn),this.state="connecting",this.iceTricklingBuffer=[],this.iceTricklingDataChannel=this.peerConnection.createDataChannel("iceTrickling",{negotiated:!0,id:1}),this.iceTricklingDataChannel.onmessage=t=>{console.log("received ICE candidate from remote peer",t.data),this.peerConnection.addIceCandidate(JSON.parse(t.data))},this.iceTricklingDataChannel.onopen=()=>{console.log("iceTricklingDataChannel open: sending buffered ICE candidates",this.iceTricklingBuffer);for(const t of this.iceTricklingBuffer)qe(this.iceTricklingDataChannel,t);this.iceTricklingBuffer=[]}}async init(t,n,o){this.onStateChanged=o,this.peerConnection.ontrack=s=>{const c=s.streams[0];n(c),this.state="in-call",this.onStateChanged(this.state)},t.getTracks().forEach(s=>this.peerConnection.addTrack(s,t));const r=async s=>{const c=Be(this.peerConnection),u={type:"offer",sdp:s},v=new RTCSessionDescription(u);this.peerConnection.setRemoteDescription(v),this.peerConnection.setLocalDescription(await this.peerConnection.createAnswer()),await c;const a=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),window.calls.acceptCall(a)},i=s=>{const c={type:"answer",sdp:s},u=new RTCSessionDescription(c);this.peerConnection.setRemoteDescription(u)},_=async()=>{const s=decodeURIComponent(window.location.hash.substring(1));if(s==="startCall")console.log("URL hash CMD: ",s),await this.startCall();else if(s.startsWith("acceptCall=")){const c=window.atob(s.substring(11));console.log("URL hash CMD: acceptCall:",c),await r(c)}else if(s.startsWith("onAnswer=")){const c=window.atob(s.substring(9));console.log("URL hash CMD: onAnswer:",c),i(c)}else console.log("unexpected URL hash: ",s)};_(),window.addEventListener("hashchange",_)}async startCall(){const t=Be(this.peerConnection);this.peerConnection.setLocalDescription(await this.peerConnection.createOffer()),await t;const n=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),window.calls.startCall(n),this.state="ringing",this.onStateChanged(this.state)}async endCall(){window.calls.endCall()}getState(){return this.state}trickleIceOverDataChannel(t){if(this.iceTricklingDataChannel.readyState!=="open"){console.log("Gathered new ICE candidate, but iceTricklingDataChannel is not yet open, will buffer it",t.candidate),this.iceTricklingBuffer.push(t.candidate);return}qe(this.iceTricklingDataChannel,t.candidate)}}function Be(e){(e.localDescription!=null||e.remoteDescription!=null)&&console.warn("gatheredEnoughIce called after setLocalDescription or setRemoteDescription: it might not have captured all ICE candidate events");const t=new Promise(o=>{const r=i=>{i.candidate!=null&&i.candidate.type==="relay"&&(setTimeout(o,100),e.removeEventListener("icecandidate",r))};e.addEventListener("icecandidate",r)}),n=new Promise(o=>{const r=()=>{e.iceGatheringState==="complete"&&(o(),e.removeEventListener("icegatheringstatechange",r))};e.addEventListener("icegatheringstatechange",r)});return Promise.race([t,n])}function qe(e,t){console.log("sending ICE candidate to remote peer",t),e.send(JSON.stringify(t===null?t:t.toJSON()))}var on=0;function w(e,t,n,o,r,i){t||(t={});var _,s,c=t;if("ref"in c)for(s in c={},t)s=="ref"?_=t[s]:c[s]=t[s];var u={type:e,props:c,key:n,ref:_,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--on,__i:-1,__u:0,__source:r,__self:i};if(typeof e=="function"&&(_=e.defaultProps))for(s in _)c[s]===void 0&&(c[s]=_[s]);return p.vnode&&p.vnode(u),u}var Ve="/home/adbenitez/projects/deltachat/call/src/components/VideoThumbnail.tsx";const rn={position:"absolute",right:"15px",top:"15px",height:"100px",width:"100px",zIndex:1,imageRendering:"crisp-edges",borderRadius:"5px",boxShadow:"rgba(0, 0, 0, 0.29) 0px 2px 8px 0px, rgba(0, 0, 0, 0.28) 0px 2px 8px 0px"};function an({videoRef:e}){return w("div",{style:rn,children:w("video",{style:{borderRadius:"5px",objectFit:"cover",transform:"scaleX(-1)"},width:"100%",height:"100%",muted:!0,autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:Ve,lineNumber:21,columnNumber:7},this)},void 0,!1,{fileName:Ve,lineNumber:20,columnNumber:5},this)}var Ye="/home/adbenitez/projects/deltachat/call/src/components/FullscreenVideo.tsx";const ln={imageRendering:"crisp-edges",width:"100%",height:"100%"};function _n({videoRef:e}){return w("div",{style:ln,children:w("video",{style:{transform:"scaleX(-1)"},width:"100%",height:"100%",autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:Ye,lineNumber:14,columnNumber:7},this)},void 0,!1,{fileName:Ye,lineNumber:13,columnNumber:5},this)}var Je="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call-end.jsx";const sn=(e,t)=>w("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:w("path",{fill:"currentColor",d:"M12 8q2.95 0 5.813 1.188T22.9 12.75q.3.3.3.7t-.3.7l-2.3 2.25q-.275.275-.638.3t-.662-.2l-2.9-2.2q-.2-.15-.3-.35t-.1-.45v-2.85q-.95-.3-1.95-.475T12 10t-2.05.175T8 10.65v2.85q0 .25-.1.45t-.3.35l-2.9 2.2q-.3.225-.663.2t-.637-.3l-2.3-2.25q-.3-.3-.3-.7t.3-.7q2.2-2.375 5.075-3.562T12 8"},void 0,!1,{fileName:Je,lineNumber:3,columnNumber:123},void 0)},void 0,!1,{fileName:Je,lineNumber:3,columnNumber:48},void 0),cn=yt(sn),un="_btn_ppybd_1",fn={btn:un};var pn="/home/adbenitez/projects/deltachat/call/src/components/Button.tsx";function dn({children:e,...t}){return w("div",{className:fn.btn,...t,children:e},void 0,!1,{fileName:pn,lineNumber:10,columnNumber:5},this)}var Xe="/home/adbenitez/projects/deltachat/call/src/components/EndCallButton.tsx";const Ge={color:"white",background:"#cb2233",borderRadius:"50%",fontSize:"1.5em"};function hn({...e}){return e.style={...Ge,...e.style||{}},w(dn,{style:Ge,...e,children:w(cn,{},void 0,!1,{fileName:Xe,lineNumber:20,columnNumber:7},this)},void 0,!1,{fileName:Xe,lineNumber:19,columnNumber:5},this)}var Ke="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/person.jsx";const mn=(e,t)=>w("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:w("path",{fill:"currentColor",d:"M12 12q-1.65 0-2.825-1.175T8 8t1.175-2.825T12 4t2.825 1.175T16 8t-1.175 2.825T12 12m-8 8v-2.8q0-.85.438-1.562T5.6 14.55q1.55-.775 3.15-1.162T12 13t3.25.388t3.15 1.162q.725.375 1.163 1.088T20 17.2V20z"},void 0,!1,{fileName:Ke,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:Ke,lineNumber:3,columnNumber:47},void 0),vn=yt(mn);var yn="/home/adbenitez/projects/deltachat/call/src/components/AvatarCircle.tsx";const Ze={display:"inline-flex",flexDirection:"row",alignItems:"center",padding:"0.5em",color:"white",background:"#c8c7cd",borderRadius:"50%",fontSize:"1.5em"};function gn({children:e,...t}){return t.style={...Ze,...t.style||{}},w("div",{style:Ze,...t,children:e},void 0,!1,{fileName:yn,lineNumber:20,columnNumber:5},this)}var Qe="/home/adbenitez/projects/deltachat/call/src/components/AvatarPlaceholder.tsx";function bn({...e}){return w(gn,{style:{padding:"0.2em",fontSize:"5em"},...e,children:w(vn,{},void 0,!1,{fileName:Qe,lineNumber:12,columnNumber:7},this)},void 0,!1,{fileName:Qe,lineNumber:11,columnNumber:5},this)}var wn="/home/adbenitez/projects/deltachat/call/src/components/AvatarImage.tsx";function Nn({url:e,...t}){return t.style={width:"8em",height:"8em",borderRadius:"50%",backgroundImage:`url(${e})`,backgroundSize:"cover",backgroundPosition:"center",...t.style||{}},w("div",{...t},void 0,!1,{fileName:wn,lineNumber:16,columnNumber:10},this)}var A="/home/adbenitez/projects/deltachat/call/src/App.tsx";const Z=new nn;function kn(){const[e,t]=ie(At(Z.getState()),"state"),n=ie(je(null),"outVidRef"),o=ie(je(null),"incVidRef");Ut(()=>{(async()=>{const c=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0});n.current.srcObject=c;const u=v=>{o.current.srcObject=v};await Z.init(c,u,t)})()},[]);const r=Ft(()=>{Z.endCall()},[Z]);let i="";e==="connecting"?i="Connecting...":e==="ringing"&&(i="Ringing...");const _=e==="in-call";return w("div",{style:{height:"100vh",overflow:"hidden"},children:[w("div",{style:{display:_?"block":"none",height:"100%"},children:[w(_n,{videoRef:o},void 0,!1,{fileName:A,lineNumber:55,columnNumber:9},this),w(an,{videoRef:n},void 0,!1,{fileName:A,lineNumber:56,columnNumber:9},this)]},void 0,!0,{fileName:A,lineNumber:54,columnNumber:7},this),w("div",{style:{position:"absolute",top:0,width:"100%",paddingTop:"1em",textAlign:"center"},children:i},void 0,!1,{fileName:A,lineNumber:59,columnNumber:7},this),w("div",{style:{display:_?"none":"flex",alignItems:"center",textAlign:"center",justifyContent:"center",height:"100%"},children:window.calls.getAvatar?w(Nn,{url:window.calls.getAvatar()},void 0,!1,{fileName:A,lineNumber:80,columnNumber:11},this):w(bn,{},void 0,!1,{fileName:A,lineNumber:82,columnNumber:11},this)},void 0,!1,{fileName:A,lineNumber:70,columnNumber:7},this),w("div",{style:{position:"absolute",bottom:"1em",width:"100%",textAlign:"center"},children:w(hn,{onClick:r},void 0,!1,{fileName:A,lineNumber:93,columnNumber:9},this)},void 0,!1,{fileName:A,lineNumber:85,columnNumber:7},this)]},void 0,!0,{fileName:A,lineNumber:53,columnNumber:5},this)}var Cn="/home/adbenitez/projects/deltachat/call/src/index.tsx";Dt(w(kn,{},void 0,!1,{fileName:Cn,lineNumber:4,columnNumber:8},void 0),document.getElementById("root")); - - +`+P(s));break}$.push(O)}}if(s.__c!=null&&s.__c.__H!=null){var w=s.__c.__H.__;if(w)for(var C=0;C=n.__.length&&n.__.push({}),n.__[e]}function te(e){return K=1,Qt(It,e)}function Qt(e,t,n){var o=Se(X++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):It(void 0,t),function(_){var u=o.__N?o.__N[0]:o.__[0],c=o.t(u,_);u!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=S,!S.__f)){var r=function(_,u,c){if(!o.__c.__H)return!0;var m=o.__c.__H.__.filter(function(v){return!!v.__c});if(m.every(function(v){return!v.__N}))return!i||i.call(this,_,u,c);var a=o.__c.props!==_;return m.forEach(function(v){if(v.__N){var p=v.__[0];v.__=v.__N,v.__N=void 0,p!==v.__[0]&&(a=!0)}}),i&&i.call(this,_,u,c)||a};S.__f=!0;var i=S.shouldComponentUpdate,l=S.componentWillUpdate;S.componentWillUpdate=function(_,u,c){if(this.__e){var m=i;i=void 0,r(_,u,c),i=m}l&&l.call(this,_,u,c)},S.shouldComponentUpdate=r}return o.__N||o.__}function He(e,t){var n=Se(X++,3);!E.__s&&Pt(n.__H,t)&&(n.__=e,n.u=t,S.__H.__h.push(n))}function Y(e){return K=5,se(function(){return{current:e}},[])}function se(e,t){var n=Se(X++,7);return Pt(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Xt(e,t){return K=8,se(function(){return e},t)}function Kt(){for(var e;e=xt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(re),e.__H.__h.forEach(we),e.__H.__h=[]}catch(t){e.__H.__h=[],E.__e(t,e.__v)}}E.__b=function(e){S=null,De&&De(e)},E.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),qe&&qe(e,t)},E.__r=function(e){Re&&Re(e),X=0;var t=(S=e.__c).__H;t&&(he===S?(t.__h=[],S.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(re),t.__h.forEach(we),t.__h=[],X=0)),he=S},E.diffed=function(e){je&&je(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xt.push(t)!==1&&Ae===E.requestAnimationFrame||((Ae=E.requestAnimationFrame)||Zt)(Kt)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),he=S=null},E.__c=function(e,t){t.some(function(n){try{n.__h.forEach(re),n.__h=n.__h.filter(function(o){return!o.__||we(o)})}catch(o){t.some(function(r){r.__h&&(r.__h=[])}),t=[],E.__e(o,n.__v)}}),Ue&&Ue(e,t)},E.unmount=function(e){Le&&Le(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{re(o)}catch(r){t=r}}),n.__H=void 0,t&&E.__e(t,n.__v))};var Fe=typeof requestAnimationFrame=="function";function Zt(e){var t,n=function(){clearTimeout(o),Fe&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Fe&&(t=requestAnimationFrame(n))}function re(e){var t=S,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),S=t}function we(e){var t=S;e.__c=e.__(),S=t}function Pt(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function It(e,t){return typeof t=="function"?t(e):t}function Ot(e,t){for(var n in t)e[n]=t[n];return e}function Me(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function Ve(e,t){this.props=e,this.context=t}(Ve.prototype=new A).isPureReactComponent=!0,Ve.prototype.shouldComponentUpdate=function(e,t){return Me(this.props,e)||Me(this.state,t)};var ze=d.__b;d.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ze&&ze(e)};var en=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function V(e){function t(n){var o=Ot({},n);return delete o.ref,e(o,n.ref||null)}return t.$$typeof=en,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var tn=d.__e;d.__e=function(e,t,n,o){if(e.then){for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t)}tn(e,t,n,o)};var We=d.unmount;function At(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=Ot({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return At(o,t,n)})),e}function Dt(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return Dt(o,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function me(){this.__u=0,this.o=null,this.__b=null}function Rt(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ne(){this.i=null,this.l=null}d.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),We&&We(e)},(me.prototype=new A).__c=function(e,t){var n=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(n);var r=Rt(o.__v),i=!1,l=function(){i||(i=!0,n.__R=null,r?r(_):_())};n.__R=l;var _=function(){if(!--o.__u){if(o.state.__a){var u=o.state.__a;o.__v.__k[0]=Dt(u,u.__c.__P,u.__c.__O)}var c;for(o.setState({__a:o.__b=null});c=o.o.pop();)c.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(l,l)},me.prototype.componentWillUnmount=function(){this.o=[]},me.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=At(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&be(H,null,e.fallback);return r&&(r.__u&=-33),[be(H,null,t.__a?null:e.children),r]};var Be=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]r.trim()).filter(r=>r),n={session:{},media:[],ice:{candidates:{host:[],srflx:[],relay:[]},credentials:{}},security:{},codecs:{audio:[],video:[]}};let o=null;for(const r of t){const[i,l]=r.split("=",2);switch(i){case"v":n.session.version=l;break;case"o":const[,_,u,,,c]=l.split(" ");n.session.origin={sessId:_,sessVersion:u,address:c};break;case"s":n.session.name=l==="-"?"Default Session":l;break;case"m":const[m,a,v,...p]=l.split(" ");o={type:m,port:parseInt(a),protocol:v,formats:p,attributes:{}},n.media.push(o);break;case"c":if(o){const[,,k]=l.split(" ");o.connection={address:k}}break;case"a":pn(l,n,o);break}}return n}function pn(e,t,n){if(e.startsWith("candidate:"))hn(e,t.ice.candidates);else if(e.startsWith("ice-ufrag:"))t.ice.credentials.ufrag=e.slice(10);else if(e.startsWith("ice-pwd:"))t.ice.credentials.password=e.slice(8);else if(e.startsWith("fingerprint:")){const[o,r]=e.split("fingerprint:")[1].split(" ",2);t.security.fingerprint={algorithm:o,fingerprint:r}}else if(e.startsWith("rtpmap:"))mn(e,t.codecs,n==null?void 0:n.type);else if(n){const[o,r]=e.split(":",2);n.attributes[o]=r||!0}}function hn(e,t){const n=e.split(" ");if(n.length<6){console.warn("Invalid candidate line format:",e);return}const o={foundation:n[0].split(":")[1]||"",component:n[1]||"",protocol:n[2]||"",priority:parseInt(n[3],10)||0,address:n[4]||"",port:parseInt(n[5],10)||0,type:null},r=n.findIndex(i=>i==="typ");if(r!==-1&&r+1{const a=o[u];a.length>0&&(n.push(` ${c} ${m}: ${a.length} candidate(s)`),a.forEach(v=>{n.push(` • ${v.address}:${v.port} (${v.protocol.toUpperCase()})`)}))}),o.relay.length===0&&(n.push(" ❌ TURN Relay: No relay candidates found"),n.push(" This may cause connection issues in restrictive networks")),n.push(""),n.push("📊 Connection Assessment:");const i={relay:o.relay.length>0,publicIP:o.srflx.length>0,localIP:o.host.length>0},_=[{condition:i.relay&&i.publicIP&&i.localIP,status:" ✅ Excellent: All connection types available",details:[]},{condition:i.publicIP&&i.localIP,status:" ⚠️ Good: Direct connections possible, but no TURN relay",details:[" May fail in restrictive corporate/university networks"]},{condition:i.localIP,status:" ❌ Limited: Only local network connectivity",details:[" Likely to fail across different networks"]},{condition:!0,status:" 🚫 Poor: No valid network candidates found",details:[]}].find(u=>u.condition);return n.push(_.status),_.details.forEach(u=>n.push(u)),n.push(""),n.push("🎥 Media Streams:"),t.media.forEach(u=>{var m;const c=Ke[u.type]||Ke.default;n.push(` ${c} ${u.type.toUpperCase()}:`),n.push(` Port: ${u.port===Ze?`Dynamic (${Ze} = placeholder)`:u.port}`),n.push(` Protocol: ${u.protocol}`),n.push(` Connection: ${((m=u.connection)==null?void 0:m.address)||"Not specified"}`),u.attributes.sendrecv&&n.push(" Direction: Bidirectional (send & receive)"),n.push("")}),t.codecs.audio.length>0&&(n.push("🎵 Audio Codecs:"),t.codecs.audio.forEach(u=>{const c=Xe[u.name]||(u.name.includes("PCM")?" (Basic Quality)":"");n.push(` • ${u.name}${c}: ${u.clockRate}Hz, ${u.channels} channel(s)`)}),n.push("")),t.codecs.video.length>0&&(n.push("📽️ Video Codecs:"),t.codecs.video.forEach(u=>{const c=Xe[u.name]||"";n.push(` • ${u.name}${c}: ${u.clockRate}Hz`)}),n.push("")),t.security.fingerprint&&(n.push("🔒 Security:"),n.push(` DTLS Fingerprint: ${t.security.fingerprint.algorithm.toUpperCase()}`),n.push(` ${t.security.fingerprint.fingerprint}`),n.push("")),t.ice.credentials.ufrag&&(n.push("🔑 ICE Authentication:"),n.push(` Username Fragment: ${t.ice.credentials.ufrag}`),n.push(` Password: ${t.ice.credentials.password?"[PRESENT]":"[MISSING]"}`),n.push("")),n.join(` +`)}function J(e,t){if(!t.trim()){console.error(e,"No SDP content provided");return}try{const n=dn(t);n&&console.log(vn(e,n))}catch(n){const o=n instanceof Error?n.message:"Unknown error";console.error(e,`Error parsing SDP: ${o}`)}}const et={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",iceCandidatePoolSize:1},ue=class ue{constructor(t,n,o){F(this,"peerConnection");F(this,"setIceServersPromise");F(this,"state");F(this,"resolveCallAcceptedPromise");F(this,"iceTricklingDataChannel");F(this,"iceTricklingBuffer");this.outStreamPromise=t,this.onStateChanged=o,this.peerConnection=new RTCPeerConnection(et);const r=c=>{this.peerConnection.setConfiguration({...et,iceServers:c})},i=window.calls.getIceServers();typeof i=="string"?(r(JSON.parse(i)),this.setIceServersPromise=Promise.resolve()):this.setIceServersPromise=i.then(c=>{r(JSON.parse(c))}),this.state=ue.initialState,this.iceTricklingBuffer=[],this.iceTricklingDataChannel=this.peerConnection.createDataChannel("iceTrickling",{negotiated:!0,id:1}),this.iceTricklingDataChannel.onmessage=c=>{console.log("received ICE candidate from remote peer",c.data),this.peerConnection.addIceCandidate(JSON.parse(c.data))},this.iceTricklingDataChannel.onopen=()=>{console.log("iceTricklingDataChannel open: sending buffered ICE candidates",this.iceTricklingBuffer);for(const c of this.iceTricklingBuffer)nt(this.iceTricklingDataChannel,c);this.iceTricklingBuffer=[]},this.peerConnection.ontrack=c=>{const m=c.streams[0];n(m),this.state="in-call",this.onStateChanged(this.state)};const l=async c=>{this.state="connecting",this.onStateChanged(this.state),await this.setIceServersPromise;const m=tt(this.peerConnection),a={type:"offer",sdp:c},v=new RTCSessionDescription(a);this.peerConnection.setRemoteDescription(v);const p=await t;console.log("getUserMedia() completed"),p.getTracks().forEach(s=>this.peerConnection.addTrack(s,p)),this.peerConnection.setLocalDescription(await this.peerConnection.createAnswer()),await m;const k=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),J("Answering incoming call with answer:",k),window.calls.acceptCall(k)},_=c=>{const m={type:"answer",sdp:c},a=new RTCSessionDescription(m);this.peerConnection.setRemoteDescription(a)},u=async()=>{var m;const c=decodeURIComponent(window.location.hash.substring(1));if(!c||c.length===0){console.log("empty URL hash: ",window.location.href);return}if((m=this.resolveCallAcceptedPromise)==null||m.call(this,!1),c==="startCall")console.log("URL hash CMD: ",c),await this.startCall();else if(c.startsWith("offerIncomingCall=")){const a=window.atob(c.split("offerIncomingCall=",2)[1]);J("Incoming call (with user prompt) with offer:",a),this.state="promptingUserToAcceptCall",this.onStateChanged(this.state);const v=await new Promise(p=>{const k=s=>{p(s),this.resolveCallAcceptedPromise===k&&(this.resolveCallAcceptedPromise=void 0)};this.resolveCallAcceptedPromise=k});if(console.log("Accept call prompt resolved: "+(v?"accepted":"not accepted")),!v)return;await l(a)}else if(c.startsWith("acceptCall=")){const a=window.atob(c.substring(11));J("Incoming call with offer:",a),await l(a)}else if(c.startsWith("onAnswer=")){const a=window.atob(c.substring(9));J("Outgoing call was accepted with answer:",a),_(a)}else console.log("unexpected URL hash: ",c)};u(),window.addEventListener("hashchange",u)}async startCall(){await this.setIceServersPromise;const t=tt(this.peerConnection),n=await this.outStreamPromise;console.log("getUserMedia() completed"),n.getTracks().forEach(r=>this.peerConnection.addTrack(r,n)),this.peerConnection.setLocalDescription(await this.peerConnection.createOffer()),await t;const o=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),J("Start outgoing call with offer:",o),window.calls.startCall(o),this.state="ringing",this.onStateChanged(this.state)}acceptCall(){if(this.resolveCallAcceptedPromise==null){console.warn("acceptCall invoked, but we were not waiting for it");return}this.resolveCallAcceptedPromise(!0)}async endCall(){var t;this.peerConnection.close(),window.calls.endCall(),(t=this.resolveCallAcceptedPromise)==null||t.call(this,!1)}getState(){return this.state}trickleIceOverDataChannel(t){if(this.iceTricklingDataChannel.readyState!=="open"){console.log("Gathered new ICE candidate, but iceTricklingDataChannel is not yet open, will buffer it",t.candidate),this.iceTricklingBuffer.push(t.candidate);return}nt(this.iceTricklingDataChannel,t.candidate)}};F(ue,"initialState","connecting");let ce=ue;function tt(e){(e.localDescription!=null||e.remoteDescription!=null)&&console.warn("gatheredEnoughIce called after setLocalDescription or setRemoteDescription: it might not have captured all ICE candidate events");const t=new Promise(o=>{const r=i=>{i.candidate!=null&&i.candidate.type==="relay"&&(setTimeout(o,0),e.removeEventListener("icecandidate",r))};e.addEventListener("icecandidate",r)}),n=new Promise(o=>{const r=()=>{e.iceGatheringState==="complete"&&(o(),e.removeEventListener("icegatheringstatechange",r))};e.addEventListener("icegatheringstatechange",r)});return Promise.race([t,n])}function nt(e,t){console.log("sending ICE candidate to remote peer",t),e.send(JSON.stringify(t===null?t:t.toJSON()))}var yn=0;function b(e,t,n,o,r,i){t||(t={});var l,_,u=t;if("ref"in u)for(_ in u={},t)_=="ref"?l=t[_]:u[_]=t[_];var c={type:e,props:u,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--yn,__i:-1,__u:0,__source:r,__self:i};if(typeof e=="function"&&(l=e.defaultProps))for(_ in l)u[_]===void 0&&(u[_]=l[_]);return d.vnode&&d.vnode(c),c}var ot="/home/adbenitez/projects/deltachat/call/src/components/VideoThumbnail.tsx";const bn={position:"absolute",right:"15px",top:"15px",height:"100px",width:"100px",zIndex:1,imageRendering:"crisp-edges",borderRadius:"5px",boxShadow:"rgba(0, 0, 0, 0.29) 0px 2px 8px 0px, rgba(0, 0, 0, 0.28) 0px 2px 8px 0px"};function gn({videoRef:e}){return b("div",{style:bn,children:b("video",{style:{borderRadius:"5px",objectFit:"cover",transform:"scaleX(-1)"},width:"100%",height:"100%",muted:!0,autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:ot,lineNumber:21,columnNumber:7},this)},void 0,!1,{fileName:ot,lineNumber:20,columnNumber:5},this)}var rt="/home/adbenitez/projects/deltachat/call/src/components/FullscreenVideo.tsx";const wn={imageRendering:"crisp-edges",width:"100%",height:"100%"};function Nn({videoRef:e}){return b("div",{style:wn,children:b("video",{width:"100%",height:"100%",autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:rt,lineNumber:14,columnNumber:7},this)},void 0,!1,{fileName:rt,lineNumber:13,columnNumber:5},this)}var it="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call-end.jsx";const kn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 8q2.95 0 5.813 1.188T22.9 12.75q.3.3.3.7t-.3.7l-2.3 2.25q-.275.275-.638.3t-.662-.2l-2.9-2.2q-.2-.15-.3-.35t-.1-.45v-2.85q-.95-.3-1.95-.475T12 10t-2.05.175T8 10.65v2.85q0 .25-.1.45t-.3.35l-2.9 2.2q-.3.225-.663.2t-.637-.3l-2.3-2.25q-.3-.3-.3-.7t.3-.7q2.2-2.375 5.075-3.562T12 8"},void 0,!1,{fileName:it,lineNumber:3,columnNumber:123},void 0)},void 0,!1,{fileName:it,lineNumber:3,columnNumber:48},void 0),Cn=V(kn),Tn="_btn_2u459_1",Sn={btn:Tn};var $n="/home/adbenitez/projects/deltachat/call/src/components/Button.tsx";function ie({children:e,className:t,...n}){return b("button",{className:(t??"")+" "+Sn.btn,...n,children:e},void 0,!1,{fileName:$n,lineNumber:10,columnNumber:5},this)}var at="/home/adbenitez/projects/deltachat/call/src/components/EndCallButton.tsx";const lt={background:"#f01d2c"};function En({...e}){return e.style={...lt,...e.style||{}},b(ie,{"aria-label":"End call",title:"End call",style:lt,...e,children:b(Cn,{},void 0,!1,{fileName:at,lineNumber:22,columnNumber:7},this)},void 0,!1,{fileName:at,lineNumber:16,columnNumber:5},this)}var st="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/person.jsx";const xn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 12q-1.65 0-2.825-1.175T8 8t1.175-2.825T12 4t2.825 1.175T16 8t-1.175 2.825T12 12m-8 8v-2.8q0-.85.438-1.562T5.6 14.55q1.55-.775 3.15-1.162T12 13t3.25.388t3.15 1.162q.725.375 1.163 1.088T20 17.2V20z"},void 0,!1,{fileName:st,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:st,lineNumber:3,columnNumber:47},void 0),Pn=V(xn);var In="/home/adbenitez/projects/deltachat/call/src/components/AvatarCircle.tsx";const ct={display:"inline-flex",flexDirection:"row",alignItems:"center",padding:"0.5em",color:"white",background:"#c8c7cd",borderRadius:"50%",fontSize:"1.5em"};function On({children:e,...t}){return t.style={...ct,...t.style||{}},b("div",{style:ct,...t,children:e},void 0,!1,{fileName:In,lineNumber:20,columnNumber:5},this)}var ut="/home/adbenitez/projects/deltachat/call/src/components/AvatarPlaceholder.tsx";function An({...e}){return b(On,{style:{padding:"0.2em",fontSize:"5em"},...e,children:b(Pn,{},void 0,!1,{fileName:ut,lineNumber:12,columnNumber:7},this)},void 0,!1,{fileName:ut,lineNumber:11,columnNumber:5},this)}var Dn="/home/adbenitez/projects/deltachat/call/src/components/AvatarImage.tsx";function Rn({url:e,...t}){return t.style={borderRadius:"50%",backgroundImage:`url(${e})`,backgroundSize:"cover",backgroundPosition:"center",...t.style||{}},b("div",{...t},void 0,!1,{fileName:Dn,lineNumber:14,columnNumber:10},this)}var _t="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call.jsx";const jn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M19.95 21q-3.125 0-6.175-1.362t-5.55-3.863t-3.862-5.55T3 4.05q0-.45.3-.75t.75-.3H8.1q.35 0 .625.238t.325.562l.65 3.5q.05.4-.025.675T9.4 8.45L6.975 10.9q.5.925 1.187 1.787t1.513 1.663q.775.775 1.625 1.438T13.1 17l2.35-2.35q.225-.225.588-.337t.712-.063l3.45.7q.35.1.575.363T21 15.9v4.05q0 .45-.3.75t-.75.3"},void 0,!1,{fileName:_t,lineNumber:3,columnNumber:120},void 0)},void 0,!1,{fileName:_t,lineNumber:3,columnNumber:45},void 0),Un=V(jn);var ft="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/videocam.jsx";const Ln=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M4 20q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4h12q.825 0 1.413.588T18 6v4.5l4-4v11l-4-4V18q0 .825-.587 1.413T16 20z"},void 0,!1,{fileName:ft,lineNumber:3,columnNumber:124},void 0)},void 0,!1,{fileName:ft,lineNumber:3,columnNumber:49},void 0),qn=V(Ln);var dt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/videocam-off.jsx";const Hn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"m22 17.5l-4-4v1.675L6.825 4H16q.825 0 1.413.588T18 6v4.5l4-4zm-1.45 5.85L.65 3.45l1.4-1.4l19.9 19.9zM4 4l14 14q0 .825-.587 1.413T16 20H4q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4"},void 0,!1,{fileName:dt,lineNumber:3,columnNumber:127},void 0)},void 0,!1,{fileName:dt,lineNumber:3,columnNumber:52},void 0),Fn=V(Hn);var pt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/mic.jsx";const Mn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 14q-1.25 0-2.125-.875T9 11V5q0-1.25.875-2.125T12 2t2.125.875T15 5v6q0 1.25-.875 2.125T12 14m-1 7v-3.075q-2.6-.35-4.3-2.325T5 11h2q0 2.075 1.463 3.538T12 16t3.538-1.463T17 11h2q0 2.625-1.7 4.6T13 17.925V21z"},void 0,!1,{fileName:pt,lineNumber:3,columnNumber:119},void 0)},void 0,!1,{fileName:pt,lineNumber:3,columnNumber:44},void 0),Vn=V(Mn);var ht="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/mic-off.jsx";const zn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M17.75 14.95L16.3 13.5q.35-.575.525-1.2T17 11h2q0 1.1-.325 2.088t-.925 1.862m-2.95-3L9 6.15V5q0-1.25.875-2.125T12 2t2.125.875T15 5v6q0 .275-.062.5t-.138.45M11 21v-3.1q-2.6-.35-4.3-2.312T5 11h2q0 2.075 1.463 3.538T12 16q.85 0 1.613-.262T15 15l1.425 1.425q-.725.575-1.588.963T13 17.9V21zm8.8 1.6L1.4 4.2l1.4-1.4l18.4 18.4z"},void 0,!1,{fileName:ht,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:ht,lineNumber:3,columnNumber:47},void 0),Wn=V(zn);var x="/home/adbenitez/projects/deltachat/call/src/App.tsx";function Bn(){const[e,t]=U(te(ce.initialState),"state"),n=U(Y(null),"outVidRef"),o=U(Y(null),"incVidRef"),r=U(Y(null),"enableVideoInitiallyRef");r.current==null&&(r.current=!location.search.includes("noOutgoingVideoInitially"));const i=r.current,[l,_]=U(te(!0),"isOutAudioEnabled"),[u,c]=U(te(i),"isOutVideoEnabled"),m=U(Y(l),"isOutAudioEnabledRef");m.current=l;const a=U(Y(u),"isOutVideoEnabledRef");a.current=u;const v=U(se(async()=>{let w;try{w=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0})}catch{console.warn("Failed to getUserMedia with video, will try just audio"),w=await navigator.mediaDevices.getUserMedia({audio:!0})}return w.getAudioTracks().forEach(C=>C.enabled=m.current),w.getVideoTracks().forEach(C=>C.enabled=a.current),w},[]),"outStreamPromise"),[p,k]=U(te(null),"outStream");He(()=>{let w=!1;return k(null),v.then(C=>{w||k(C)}),()=>{w=!0}},[v]),p&&n.current&&n.current.srcObject!==p&&(n.current.srcObject=p);const s=U(se(()=>{const w=C=>{o.current.srcObject=C};return new ce(v,w,t)},[v]),"manager");He(()=>{if(p==null)return;const w=()=>{p.getAudioTracks().forEach(C=>C.enabled=l),p.getVideoTracks().forEach(C=>C.enabled=u)};return w(),p.addEventListener("addtrack",w),p.addEventListener("removetrack",w),()=>{p.removeEventListener("addtrack",w),p.removeEventListener("removetrack",w)}},[p,l,u]);const h=p==null||p.getVideoTracks().length>=1,f=e==="promptingUserToAcceptCall"?()=>s.acceptCall():null,y=Xt(()=>{s.endCall()},[s]);let N;switch(e){case"promptingUserToAcceptCall":N="Incoming call";break;case"connecting":N="Connecting...";break;case"ringing":N="Ringing...";break;case"in-call":N="";break}const g=e==="in-call",$={display:g?"block":"none",height:"100%"},I=l?"Mute microphone":"Unmute microphone",D=u?"Stop camera":"Start camera",O={color:"white",borderRadius:"50%",fontSize:"1.5em",margin:"0.25em 0.625em"};return b("div",{style:{height:"100vh",overflow:"hidden"},children:[b("div",{style:$,children:[b(Nn,{videoRef:o},void 0,!1,{fileName:x,lineNumber:167,columnNumber:9},this),b(gn,{videoRef:n},void 0,!1,{fileName:x,lineNumber:168,columnNumber:9},this)]},void 0,!0,{fileName:x,lineNumber:166,columnNumber:7},this),b("div",{role:"status",style:{position:"absolute",top:0,width:"100%",paddingTop:"1em",textAlign:"center"},children:N},void 0,!1,{fileName:x,lineNumber:171,columnNumber:7},this),b("div",{style:{display:g?"none":"flex",alignItems:"center",textAlign:"center",justifyContent:"center",height:"100%"},children:b("div",{style:{position:"relative"},children:[b(An,{},void 0,!1,{fileName:x,lineNumber:193,columnNumber:11},this),window.calls.getAvatar&&b(Rn,{url:window.calls.getAvatar(),style:{position:"absolute",inset:0}},void 0,!1,{fileName:x,lineNumber:195,columnNumber:13},this)]},void 0,!0,{fileName:x,lineNumber:192,columnNumber:9},this)},void 0,!1,{fileName:x,lineNumber:183,columnNumber:7},this),b("div",{style:{position:"absolute",bottom:"0.75em",width:"100%",textAlign:"center"},children:[f!=null&&b(ie,{"aria-label":"Answer call",title:"Answer call",onClick:f,className:"acceptCallButton",style:{backgroundColor:"#00b000",...O},children:b(Un,{},void 0,!1,{fileName:x,lineNumber:221,columnNumber:13},this)},void 0,!1,{fileName:x,lineNumber:211,columnNumber:11},this),b(ie,{"aria-label":I,title:I,onClick:()=>_(w=>!w),style:O,children:l?b(Vn,{},void 0,!1,{fileName:x,lineNumber:231,columnNumber:13},this):b(Wn,{},void 0,!1,{fileName:x,lineNumber:233,columnNumber:13},this)},void 0,!1,{fileName:x,lineNumber:224,columnNumber:9},this),h&&b(ie,{"aria-label":D,title:D,onClick:()=>c(w=>!w),style:O,children:u?b(qn,{},void 0,!1,{fileName:x,lineNumber:244,columnNumber:15},this):b(Fn,{},void 0,!1,{fileName:x,lineNumber:246,columnNumber:15},this)},void 0,!1,{fileName:x,lineNumber:237,columnNumber:11},this),b(En,{onClick:y,style:O},void 0,!1,{fileName:x,lineNumber:250,columnNumber:9},this)]},void 0,!0,{fileName:x,lineNumber:202,columnNumber:7},this)]},void 0,!0,{fileName:x,lineNumber:165,columnNumber:5},this)}var Yn="/home/adbenitez/projects/deltachat/call/src/index.tsx";Wt(b(Bn,{},void 0,!1,{fileName:Yn,lineNumber:4,columnNumber:8},void 0),document.getElementById("root")); + From 7e3e35a9a19ce81123fe7c770ae060347ed99b9f Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 26 Sep 2025 17:47:35 +0200 Subject: [PATCH 49/76] update calls-app to 0.6.0-beta --- src/main/assets/calls/index.html | 56 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/assets/calls/index.html b/src/main/assets/calls/index.html index bebcd5140..e177038bf 100644 --- a/src/main/assets/calls/index.html +++ b/src/main/assets/calls/index.html @@ -13,59 +13,59 @@ - +`+P(s));break}S.push(j)}}if(s.__c!=null&&s.__c.__H!=null){var O=s.__c.__H.__;if(O)for(var A=0;A=n.__.length&&n.__.push({}),n.__[e]}function re(e){return Z=1,Kt(Rt,e)}function Kt(e,t,n){var o=xe(K++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):Rt(void 0,t),function(_){var u=o.__N?o.__N[0]:o.__[0],c=o.t(u,_);u!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=T,!T.__f)){var r=function(_,u,c){if(!o.__c.__H)return!0;var h=o.__c.__H.__.filter(function(m){return!!m.__c});if(h.every(function(m){return!m.__N}))return!i||i.call(this,_,u,c);var a=o.__c.props!==_;return h.forEach(function(m){if(m.__N){var v=m.__[0];m.__=m.__N,m.__N=void 0,v!==m.__[0]&&(a=!0)}}),i&&i.call(this,_,u,c)||a};T.__f=!0;var i=T.shouldComponentUpdate,l=T.componentWillUpdate;T.componentWillUpdate=function(_,u,c){if(this.__e){var h=i;i=void 0,r(_,u,c),i=h}l&&l.call(this,_,u,c)},T.shouldComponentUpdate=r}return o.__N||o.__}function Me(e,t){var n=xe(K++,3);!E.__s&&At(n.__H,t)&&(n.__=e,n.u=t,T.__H.__h.push(n))}function Y(e){return Z=5,_e(function(){return{current:e}},[])}function _e(e,t){var n=xe(K++,7);return At(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Zt(e,t){return Z=8,_e(function(){return e},t)}function en(){for(var e;e=Ot.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(le),e.__H.__h.forEach(Ce),e.__H.__h=[]}catch(t){e.__H.__h=[],E.__e(t,e.__v)}}E.__b=function(e){T=null,Ue&&Ue(e)},E.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Fe&&Fe(e,t)},E.__r=function(e){Le&&Le(e),K=0;var t=(T=e.__c).__H;t&&(ye===T?(t.__h=[],T.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(le),t.__h.forEach(Ce),t.__h=[],K=0)),ye=T},E.diffed=function(e){qe&&qe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ot.push(t)!==1&&je===E.requestAnimationFrame||((je=E.requestAnimationFrame)||tn)(en)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ye=T=null},E.__c=function(e,t){t.some(function(n){try{n.__h.forEach(le),n.__h=n.__h.filter(function(o){return!o.__||Ce(o)})}catch(o){t.some(function(r){r.__h&&(r.__h=[])}),t=[],E.__e(o,n.__v)}}),He&&He(e,t)},E.unmount=function(e){Ve&&Ve(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{le(o)}catch(r){t=r}}),n.__H=void 0,t&&E.__e(t,n.__v))};var ze=typeof requestAnimationFrame=="function";function tn(e){var t,n=function(){clearTimeout(o),ze&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);ze&&(t=requestAnimationFrame(n))}function le(e){var t=T,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),T=t}function Ce(e){var t=T;e.__c=e.__(),T=t}function At(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function Rt(e,t){return typeof t=="function"?t(e):t}function Dt(e,t){for(var n in t)e[n]=t[n];return e}function We(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function Be(e,t){this.props=e,this.context=t}(Be.prototype=new R).isPureReactComponent=!0,Be.prototype.shouldComponentUpdate=function(e,t){return We(this.props,e)||We(this.state,t)};var Ye=p.__b;p.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ye&&Ye(e)};var nn=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function W(e){function t(n){var o=Dt({},n);return delete o.ref,e(o,n.ref||null)}return t.$$typeof=nn,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var on=p.__e;p.__e=function(e,t,n,o){if(e.then){for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t)}on(e,t,n,o)};var Je=p.unmount;function jt(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=Dt({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return jt(o,t,n)})),e}function Ut(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return Ut(o,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function be(){this.__u=0,this.o=null,this.__b=null}function Lt(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ie(){this.i=null,this.l=null}p.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Je&&Je(e)},(be.prototype=new R).__c=function(e,t){var n=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(n);var r=Lt(o.__v),i=!1,l=function(){i||(i=!0,n.__R=null,r?r(_):_())};n.__R=l;var _=function(){if(!--o.__u){if(o.state.__a){var u=o.state.__a;o.__v.__k[0]=Ut(u,u.__c.__P,u.__c.__O)}var c;for(o.setState({__a:o.__b=null});c=o.o.pop();)c.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(l,l)},be.prototype.componentWillUnmount=function(){this.o=[]},be.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=jt(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&Ne(F,null,e.fallback);return r&&(r.__u&=-33),[Ne(F,null,t.__a?null:e.children),r]};var Ge=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]r.trim()).filter(r=>r),n={session:{},media:[],ice:{candidates:{host:[],srflx:[],relay:[]},credentials:{}},security:{},codecs:{audio:[],video:[]}};let o=null;for(const r of t){const[i,l]=r.split("=",2);switch(i){case"v":n.session.version=l;break;case"o":const[,_,u,,,c]=l.split(" ");n.session.origin={sessId:_,sessVersion:u,address:c};break;case"s":n.session.name=l==="-"?"Default Session":l;break;case"m":const[h,a,m,...v]=l.split(" ");o={type:h,port:parseInt(a),protocol:m,formats:v,attributes:{}},n.media.push(o);break;case"c":if(o){const[,,N]=l.split(" ");o.connection={address:N}}break;case"a":mn(l,n,o);break}}return n}function mn(e,t,n){if(e.startsWith("candidate:"))vn(e,t.ice.candidates);else if(e.startsWith("ice-ufrag:"))t.ice.credentials.ufrag=e.slice(10);else if(e.startsWith("ice-pwd:"))t.ice.credentials.password=e.slice(8);else if(e.startsWith("fingerprint:")){const[o,r]=e.split("fingerprint:")[1].split(" ",2);t.security.fingerprint={algorithm:o,fingerprint:r}}else if(e.startsWith("rtpmap:"))yn(e,t.codecs,n==null?void 0:n.type);else if(n){const[o,r]=e.split(":",2);n.attributes[o]=r||!0}}function vn(e,t){const n=e.split(" ");if(n.length<6){console.warn("Invalid candidate line format:",e);return}const o={foundation:n[0].split(":")[1]||"",component:n[1]||"",protocol:n[2]||"",priority:parseInt(n[3],10)||0,address:n[4]||"",port:parseInt(n[5],10)||0,type:null},r=n.findIndex(i=>i==="typ");if(r!==-1&&r+1{const a=o[u];a.length>0&&(n.push(` ${c} ${h}: ${a.length} candidate(s)`),a.forEach(m=>{n.push(` • ${m.address}:${m.port} (${m.protocol.toUpperCase()})`)}))}),o.relay.length===0&&(n.push(" ❌ TURN Relay: No relay candidates found"),n.push(" This may cause connection issues in restrictive networks")),n.push(""),n.push("📊 Connection Assessment:");const i={relay:o.relay.length>0,publicIP:o.srflx.length>0,localIP:o.host.length>0},_=[{condition:i.relay&&i.publicIP&&i.localIP,status:" ✅ Excellent: All connection types available",details:[]},{condition:i.publicIP&&i.localIP,status:" ⚠️ Good: Direct connections possible, but no TURN relay",details:[" May fail in restrictive corporate/university networks"]},{condition:i.localIP,status:" ❌ Limited: Only local network connectivity",details:[" Likely to fail across different networks"]},{condition:!0,status:" 🚫 Poor: No valid network candidates found",details:[]}].find(u=>u.condition);return n.push(_.status),_.details.forEach(u=>n.push(u)),n.push(""),n.push("🎥 Media Streams:"),t.media.forEach(u=>{var h;const c=tt[u.type]||tt.default;n.push(` ${c} ${u.type.toUpperCase()}:`),n.push(` Port: ${u.port===nt?`Dynamic (${nt} = placeholder)`:u.port}`),n.push(` Protocol: ${u.protocol}`),n.push(` Connection: ${((h=u.connection)==null?void 0:h.address)||"Not specified"}`),u.attributes.sendrecv&&n.push(" Direction: Bidirectional (send & receive)"),n.push("")}),t.codecs.audio.length>0&&(n.push("🎵 Audio Codecs:"),t.codecs.audio.forEach(u=>{const c=et[u.name]||(u.name.includes("PCM")?" (Basic Quality)":"");n.push(` • ${u.name}${c}: ${u.clockRate}Hz, ${u.channels} channel(s)`)}),n.push("")),t.codecs.video.length>0&&(n.push("📽️ Video Codecs:"),t.codecs.video.forEach(u=>{const c=et[u.name]||"";n.push(` • ${u.name}${c}: ${u.clockRate}Hz`)}),n.push("")),t.security.fingerprint&&(n.push("🔒 Security:"),n.push(` DTLS Fingerprint: ${t.security.fingerprint.algorithm.toUpperCase()}`),n.push(` ${t.security.fingerprint.fingerprint}`),n.push("")),t.ice.credentials.ufrag&&(n.push("🔑 ICE Authentication:"),n.push(` Username Fragment: ${t.ice.credentials.ufrag}`),n.push(` Password: ${t.ice.credentials.password?"[PRESENT]":"[MISSING]"}`),n.push("")),n.join(` +`)}function G(e,t){if(!t.trim()){console.error(e,"No SDP content provided");return}try{const n=hn(t);n&&console.log(bn(e,n))}catch(n){const o=n instanceof Error?n.message:"Unknown error";console.error(e,`Error parsing SDP: ${o}`)}}const ot={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",iceCandidatePoolSize:1},fe=class fe{constructor(t,n,o){M(this,"peerConnection");M(this,"setIceServersPromise");M(this,"state");M(this,"resolveCallAcceptedPromise");M(this,"iceTricklingDataChannel");M(this,"iceTricklingBuffer");this.outStreamPromise=t,this.onStateChanged=o,this.peerConnection=new RTCPeerConnection(ot);const r=c=>{this.peerConnection.setConfiguration({...ot,iceServers:c})},i=window.calls.getIceServers();typeof i=="string"?(r(JSON.parse(i)),this.setIceServersPromise=Promise.resolve()):this.setIceServersPromise=i.then(c=>{r(JSON.parse(c))}),this.state=fe.initialState,this.iceTricklingBuffer=[],this.iceTricklingDataChannel=this.peerConnection.createDataChannel("iceTrickling",{negotiated:!0,id:1}),this.iceTricklingDataChannel.onmessage=c=>{console.log("received ICE candidate from remote peer",c.data),this.peerConnection.addIceCandidate(JSON.parse(c.data))},this.iceTricklingDataChannel.onopen=()=>{console.log("iceTricklingDataChannel open: sending buffered ICE candidates",this.iceTricklingBuffer);for(const c of this.iceTricklingBuffer)it(this.iceTricklingDataChannel,c);this.iceTricklingBuffer=[]},this.peerConnection.ontrack=c=>{const h=c.streams[0];n(h),this.state="in-call",this.onStateChanged(this.state)};const l=async c=>{this.state="connecting",this.onStateChanged(this.state),await this.setIceServersPromise;const h=rt(this.peerConnection),a={type:"offer",sdp:c},m=new RTCSessionDescription(a);this.peerConnection.setRemoteDescription(m);const v=await t;console.log("getUserMedia() completed"),v.getTracks().forEach(s=>this.peerConnection.addTrack(s,v)),this.peerConnection.setLocalDescription(await this.peerConnection.createAnswer()),await h;const N=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),G("Answering incoming call with answer:",N),window.calls.acceptCall(N)},_=c=>{const h={type:"answer",sdp:c},a=new RTCSessionDescription(h);this.peerConnection.setRemoteDescription(a)},u=async()=>{var h;const c=decodeURIComponent(window.location.hash.substring(1));if(!c||c.length===0){console.log("empty URL hash: ",window.location.href);return}if((h=this.resolveCallAcceptedPromise)==null||h.call(this,!1),c==="startCall")console.log("URL hash CMD: ",c),await this.startCall();else if(c.startsWith("offerIncomingCall=")){const a=window.atob(c.split("offerIncomingCall=",2)[1]);G("Incoming call (with user prompt) with offer:",a),this.state="promptingUserToAcceptCall",this.onStateChanged(this.state);const m=await new Promise(v=>{const N=s=>{v(s),this.resolveCallAcceptedPromise===N&&(this.resolveCallAcceptedPromise=void 0)};this.resolveCallAcceptedPromise=N});if(console.log("Accept call prompt resolved: "+(m?"accepted":"not accepted")),!m)return;await l(a)}else if(c.startsWith("acceptCall=")){const a=window.atob(c.substring(11));G("Incoming call with offer:",a),await l(a)}else if(c.startsWith("onAnswer=")){const a=window.atob(c.substring(9));G("Outgoing call was accepted with answer:",a),_(a)}else console.log("unexpected URL hash: ",c)};u(),window.addEventListener("hashchange",u)}async startCall(){await this.setIceServersPromise;const t=rt(this.peerConnection),n=await this.outStreamPromise;console.log("getUserMedia() completed"),n.getTracks().forEach(r=>this.peerConnection.addTrack(r,n)),this.peerConnection.setLocalDescription(await this.peerConnection.createOffer()),await t;const o=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),G("Start outgoing call with offer:",o),window.calls.startCall(o),this.state="ringing",this.onStateChanged(this.state)}acceptCall(){if(this.resolveCallAcceptedPromise==null){console.warn("acceptCall invoked, but we were not waiting for it");return}this.resolveCallAcceptedPromise(!0)}async endCall(){var t;this.peerConnection.close(),window.calls.endCall(),(t=this.resolveCallAcceptedPromise)==null||t.call(this,!1)}getState(){return this.state}trickleIceOverDataChannel(t){if(this.iceTricklingDataChannel.readyState!=="open"){console.log("Gathered new ICE candidate, but iceTricklingDataChannel is not yet open, will buffer it",t.candidate),this.iceTricklingBuffer.push(t.candidate);return}it(this.iceTricklingDataChannel,t.candidate)}};M(fe,"initialState","connecting");let de=fe;function rt(e){(e.localDescription!=null||e.remoteDescription!=null)&&console.warn("gatheredEnoughIce called after setLocalDescription or setRemoteDescription: it might not have captured all ICE candidate events");const t=new Promise(o=>{const r=i=>{i.candidate!=null&&i.candidate.type==="relay"&&(setTimeout(o,0),e.removeEventListener("icecandidate",r))};e.addEventListener("icecandidate",r)}),n=new Promise(o=>{const r=()=>{e.iceGatheringState==="complete"&&(o(),e.removeEventListener("icegatheringstatechange",r))};e.addEventListener("icegatheringstatechange",r)});return Promise.race([t,n])}function it(e,t){console.log("sending ICE candidate to remote peer",t),e.send(JSON.stringify(t===null?t:t.toJSON()))}var gn=0;function b(e,t,n,o,r,i){t||(t={});var l,_,u=t;if("ref"in u)for(_ in u={},t)_=="ref"?l=t[_]:u[_]=t[_];var c={type:e,props:u,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--gn,__i:-1,__u:0,__source:r,__self:i};if(typeof e=="function"&&(l=e.defaultProps))for(_ in l)u[_]===void 0&&(u[_]=l[_]);return p.vnode&&p.vnode(c),c}var at="/home/adbenitez/projects/deltachat/call/src/components/VideoThumbnail.tsx";const wn={position:"absolute",right:"15px",top:"15px",height:"100px",width:"100px",zIndex:1,imageRendering:"crisp-edges",borderRadius:"5px",boxShadow:"rgba(0, 0, 0, 0.29) 0px 2px 8px 0px, rgba(0, 0, 0, 0.28) 0px 2px 8px 0px"};function Nn({videoRef:e}){return b("div",{style:wn,children:b("video",{style:{borderRadius:"5px",objectFit:"cover",transform:"scaleX(-1)"},width:"100%",height:"100%",muted:!0,autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:at,lineNumber:21,columnNumber:7},this)},void 0,!1,{fileName:at,lineNumber:20,columnNumber:5},this)}var lt="/home/adbenitez/projects/deltachat/call/src/components/FullscreenVideo.tsx";const kn={imageRendering:"crisp-edges",width:"100%",height:"100%"};function Cn({videoRef:e}){return b("div",{style:kn,children:b("video",{width:"100%",height:"100%",autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:lt,lineNumber:14,columnNumber:7},this)},void 0,!1,{fileName:lt,lineNumber:13,columnNumber:5},this)}var st="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call-end.jsx";const Tn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 8q2.95 0 5.813 1.188T22.9 12.75q.3.3.3.7t-.3.7l-2.3 2.25q-.275.275-.638.3t-.662-.2l-2.9-2.2q-.2-.15-.3-.35t-.1-.45v-2.85q-.95-.3-1.95-.475T12 10t-2.05.175T8 10.65v2.85q0 .25-.1.45t-.3.35l-2.9 2.2q-.3.225-.663.2t-.637-.3l-2.3-2.25q-.3-.3-.3-.7t.3-.7q2.2-2.375 5.075-3.562T12 8"},void 0,!1,{fileName:st,lineNumber:3,columnNumber:123},void 0)},void 0,!1,{fileName:st,lineNumber:3,columnNumber:48},void 0),Sn=W(Tn),$n="_btn_2u459_1",En={btn:$n};var xn="/home/adbenitez/projects/deltachat/call/src/components/Button.tsx";function se({children:e,className:t,...n}){return b("button",{className:(t??"")+" "+En.btn,...n,children:e},void 0,!1,{fileName:xn,lineNumber:10,columnNumber:5},this)}var ct="/home/adbenitez/projects/deltachat/call/src/components/EndCallButton.tsx";const ut={background:"#f01d2c"};function Pn({...e}){return e.style={...ut,...e.style||{}},b(se,{"aria-label":"End call",title:"End call",style:ut,...e,children:b(Sn,{},void 0,!1,{fileName:ct,lineNumber:22,columnNumber:7},this)},void 0,!1,{fileName:ct,lineNumber:16,columnNumber:5},this)}var _t="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/person.jsx";const In=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 12q-1.65 0-2.825-1.175T8 8t1.175-2.825T12 4t2.825 1.175T16 8t-1.175 2.825T12 12m-8 8v-2.8q0-.85.438-1.562T5.6 14.55q1.55-.775 3.15-1.162T12 13t3.25.388t3.15 1.162q.725.375 1.163 1.088T20 17.2V20z"},void 0,!1,{fileName:_t,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:_t,lineNumber:3,columnNumber:47},void 0),On=W(In);var An="/home/adbenitez/projects/deltachat/call/src/components/AvatarCircle.tsx";const dt={display:"inline-flex",flexDirection:"row",alignItems:"center",padding:"0.5em",color:"white",background:"#c8c7cd",borderRadius:"50%",fontSize:"1.5em"};function Rn({children:e,...t}){return t.style={...dt,...t.style||{}},b("div",{style:dt,...t,children:e},void 0,!1,{fileName:An,lineNumber:20,columnNumber:5},this)}var ft="/home/adbenitez/projects/deltachat/call/src/components/AvatarPlaceholder.tsx";function Dn({...e}){return b(Rn,{style:{padding:"0.2em",fontSize:"5em"},...e,children:b(On,{},void 0,!1,{fileName:ft,lineNumber:12,columnNumber:7},this)},void 0,!1,{fileName:ft,lineNumber:11,columnNumber:5},this)}var jn="/home/adbenitez/projects/deltachat/call/src/components/AvatarImage.tsx";function Un({url:e,...t}){return t.style={borderRadius:"50%",backgroundImage:`url(${e})`,backgroundSize:"cover",backgroundPosition:"center",...t.style||{}},b("div",{...t},void 0,!1,{fileName:jn,lineNumber:14,columnNumber:10},this)}var pt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call.jsx";const Ln=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M19.95 21q-3.125 0-6.175-1.362t-5.55-3.863t-3.862-5.55T3 4.05q0-.45.3-.75t.75-.3H8.1q.35 0 .625.238t.325.562l.65 3.5q.05.4-.025.675T9.4 8.45L6.975 10.9q.5.925 1.187 1.787t1.513 1.663q.775.775 1.625 1.438T13.1 17l2.35-2.35q.225-.225.588-.337t.712-.063l3.45.7q.35.1.575.363T21 15.9v4.05q0 .45-.3.75t-.75.3"},void 0,!1,{fileName:pt,lineNumber:3,columnNumber:120},void 0)},void 0,!1,{fileName:pt,lineNumber:3,columnNumber:45},void 0),qn=W(Ln);var ht="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/videocam.jsx";const Hn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M4 20q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4h12q.825 0 1.413.588T18 6v4.5l4-4v11l-4-4V18q0 .825-.587 1.413T16 20z"},void 0,!1,{fileName:ht,lineNumber:3,columnNumber:124},void 0)},void 0,!1,{fileName:ht,lineNumber:3,columnNumber:49},void 0),Vn=W(Hn);var mt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/videocam-off.jsx";const Fn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"m22 17.5l-4-4v1.675L6.825 4H16q.825 0 1.413.588T18 6v4.5l4-4zm-1.45 5.85L.65 3.45l1.4-1.4l19.9 19.9zM4 4l14 14q0 .825-.587 1.413T16 20H4q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4"},void 0,!1,{fileName:mt,lineNumber:3,columnNumber:127},void 0)},void 0,!1,{fileName:mt,lineNumber:3,columnNumber:52},void 0),Mn=W(Fn);var vt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/mic.jsx";const zn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 14q-1.25 0-2.125-.875T9 11V5q0-1.25.875-2.125T12 2t2.125.875T15 5v6q0 1.25-.875 2.125T12 14m-1 7v-3.075q-2.6-.35-4.3-2.325T5 11h2q0 2.075 1.463 3.538T12 16t3.538-1.463T17 11h2q0 2.625-1.7 4.6T13 17.925V21z"},void 0,!1,{fileName:vt,lineNumber:3,columnNumber:119},void 0)},void 0,!1,{fileName:vt,lineNumber:3,columnNumber:44},void 0),Wn=W(zn);var yt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/mic-off.jsx";const Bn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M17.75 14.95L16.3 13.5q.35-.575.525-1.2T17 11h2q0 1.1-.325 2.088t-.925 1.862m-2.95-3L9 6.15V5q0-1.25.875-2.125T12 2t2.125.875T15 5v6q0 .275-.062.5t-.138.45M11 21v-3.1q-2.6-.35-4.3-2.312T5 11h2q0 2.075 1.463 3.538T12 16q.85 0 1.613-.262T15 15l1.425 1.425q-.725.575-1.588.963T13 17.9V21zm8.8 1.6L1.4 4.2l1.4-1.4l18.4 18.4z"},void 0,!1,{fileName:yt,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:yt,lineNumber:3,columnNumber:47},void 0),Yn=W(Bn);var x="/home/adbenitez/projects/deltachat/call/src/App.tsx";function Jn(){const[e,t]=U(re(de.initialState),"state"),n=U(Y(null),"outVidRef"),o=U(Y(null),"incVidRef"),r=U(Y(null),"disableVideoCompletelyRef");r.current==null&&(r.current=location.search.includes("disableVideoCompletely"));const i=r.current,l=U(Y(null),"enableVideoInitiallyRef");l.current==null&&(l.current=!location.search.includes("noOutgoingVideoInitially"));const _=l.current,[u,c]=U(re(!0),"isOutAudioEnabled"),[h,a]=U(re(_),"isOutVideoEnabled_"),m=i?!1:h,v=U(Y(u),"isOutAudioEnabledRef");v.current=u;const N=U(Y(m),"isOutVideoEnabledRef");N.current=m;const s=U(_e(async()=>{let w;try{w=await navigator.mediaDevices.getUserMedia({video:!i,audio:!0})}catch{console.warn("Failed to getUserMedia with video, will try just audio"),w=await navigator.mediaDevices.getUserMedia({audio:!0})}return w.getAudioTracks().forEach(I=>I.enabled=v.current),w.getVideoTracks().forEach(I=>I.enabled=N.current),w},[i]),"outStreamPromise"),[d,f]=U(re(null),"outStream");Me(()=>{let w=!1;return f(null),s.then(I=>{w||f(I)}),()=>{w=!0}},[s]),d&&n.current&&n.current.srcObject!==d&&(n.current.srcObject=d);const y=U(_e(()=>{const w=I=>{i&&(I.getVideoTracks().forEach(ne=>I.removeTrack(ne)),I.addEventListener("addtrack",ne=>{ne.track.kind==="video"&&I.removeTrack(ne.track)}));const q=o.current;q.srcObject=I;const te=()=>{q.paused?(console.log("incoming video not playing, will .play() it"),q.play()):(console.log("incoming video is playing"),clearInterval(qt))},qt=setInterval(te,100);te()};return new de(s,w,t)},[s,i]),"manager");Me(()=>{if(d==null)return;const w=()=>{d.getAudioTracks().forEach(I=>I.enabled=u),d.getVideoTracks().forEach(I=>I.enabled=m)};return w(),d.addEventListener("addtrack",w),d.addEventListener("removetrack",w),()=>{d.removeEventListener("addtrack",w),d.removeEventListener("removetrack",w)}},[d,u,m]);const k=!i&&(d==null||d.getVideoTracks().length>=1),g=e==="promptingUserToAcceptCall"?()=>y.acceptCall():null,S=Zt(()=>{y.endCall()},[y]);let $;switch(e){case"promptingUserToAcceptCall":$="Incoming call";break;case"connecting":$="Connecting...";break;case"ringing":$="Ringing...";break;case"in-call":$="";break}const D=e==="in-call",j={display:D?"block":"none",height:"100%"},O=u?"Mute microphone":"Unmute microphone",A=m?"Stop camera":"Start camera",C={color:"white",borderRadius:"50%",fontSize:"1.5em",margin:"0.25em 0.625em"};return b("div",{style:{height:"100vh",overflow:"hidden"},children:[b("div",{style:j,children:[b(Cn,{videoRef:o},void 0,!1,{fileName:x,lineNumber:203,columnNumber:9},this),b(Nn,{videoRef:n},void 0,!1,{fileName:x,lineNumber:204,columnNumber:9},this)]},void 0,!0,{fileName:x,lineNumber:202,columnNumber:7},this),b("div",{role:"status",style:{position:"absolute",top:0,width:"100%",paddingTop:"1em",textAlign:"center"},children:$},void 0,!1,{fileName:x,lineNumber:207,columnNumber:7},this),b("div",{style:{display:D?"none":"flex",alignItems:"center",textAlign:"center",justifyContent:"center",height:"100%"},children:b("div",{style:{position:"relative"},children:[b(Dn,{},void 0,!1,{fileName:x,lineNumber:229,columnNumber:11},this),window.calls.getAvatar&&b(Un,{url:window.calls.getAvatar(),style:{position:"absolute",inset:0}},void 0,!1,{fileName:x,lineNumber:231,columnNumber:13},this)]},void 0,!0,{fileName:x,lineNumber:228,columnNumber:9},this)},void 0,!1,{fileName:x,lineNumber:219,columnNumber:7},this),b("div",{style:{position:"absolute",bottom:"0.75em",width:"100%",textAlign:"center"},children:[g!=null&&b(se,{"aria-label":"Answer call",title:"Answer call",onClick:g,className:"acceptCallButton",style:{backgroundColor:"#00b000",...C},children:b(qn,{},void 0,!1,{fileName:x,lineNumber:257,columnNumber:13},this)},void 0,!1,{fileName:x,lineNumber:247,columnNumber:11},this),b(se,{"aria-label":O,title:O,onClick:()=>c(w=>!w),style:C,children:u?b(Wn,{},void 0,!1,{fileName:x,lineNumber:267,columnNumber:13},this):b(Yn,{},void 0,!1,{fileName:x,lineNumber:269,columnNumber:13},this)},void 0,!1,{fileName:x,lineNumber:260,columnNumber:9},this),k&&b(se,{"aria-label":A,title:A,onClick:()=>a(w=>!w),style:C,children:m?b(Vn,{},void 0,!1,{fileName:x,lineNumber:280,columnNumber:15},this):b(Mn,{},void 0,!1,{fileName:x,lineNumber:282,columnNumber:15},this)},void 0,!1,{fileName:x,lineNumber:273,columnNumber:11},this),b(Pn,{onClick:S,style:C},void 0,!1,{fileName:x,lineNumber:286,columnNumber:9},this)]},void 0,!0,{fileName:x,lineNumber:238,columnNumber:7},this)]},void 0,!0,{fileName:x,lineNumber:201,columnNumber:5},this)}var Gn="/home/adbenitez/projects/deltachat/call/src/index.tsx";Yt(b(Jn,{},void 0,!1,{fileName:Gn,lineNumber:4,columnNumber:8},void 0),document.getElementById("root")); - +`+P(s));break}A.push(j)}}if(s.__c!=null&&s.__c.__H!=null){var I=s.__c.__H.__;if(I)for(var O=0;O=n.__.length&&n.__.push({}),n.__[e]}function re(e){return Z=1,Kt(Rt,e)}function Kt(e,t,n){var o=Ee(K++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):Rt(void 0,t),function(_){var u=o.__N?o.__N[0]:o.__[0],c=o.t(u,_);u!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=T,!T.__f)){var r=function(_,u,c){if(!o.__c.__H)return!0;var h=o.__c.__H.__.filter(function(m){return!!m.__c});if(h.every(function(m){return!m.__N}))return!i||i.call(this,_,u,c);var a=o.__c.props!==_;return h.forEach(function(m){if(m.__N){var v=m.__[0];m.__=m.__N,m.__N=void 0,v!==m.__[0]&&(a=!0)}}),i&&i.call(this,_,u,c)||a};T.__f=!0;var i=T.shouldComponentUpdate,l=T.componentWillUpdate;T.componentWillUpdate=function(_,u,c){if(this.__e){var h=i;i=void 0,r(_,u,c),i=h}l&&l.call(this,_,u,c)},T.shouldComponentUpdate=r}return o.__N||o.__}function Me(e,t){var n=Ee(K++,3);!$.__s&&Ot(n.__H,t)&&(n.__=e,n.u=t,T.__H.__h.push(n))}function Y(e){return Z=5,_e(function(){return{current:e}},[])}function _e(e,t){var n=Ee(K++,7);return Ot(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Zt(e,t){return Z=8,_e(function(){return e},t)}function en(){for(var e;e=It.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(le),e.__H.__h.forEach(Ce),e.__H.__h=[]}catch(t){e.__H.__h=[],$.__e(t,e.__v)}}$.__b=function(e){T=null,Ue&&Ue(e)},$.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Fe&&Fe(e,t)},$.__r=function(e){Le&&Le(e),K=0;var t=(T=e.__c).__H;t&&(ye===T?(t.__h=[],T.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(le),t.__h.forEach(Ce),t.__h=[],K=0)),ye=T},$.diffed=function(e){He&&He(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(It.push(t)!==1&&je===$.requestAnimationFrame||((je=$.requestAnimationFrame)||tn)(en)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ye=T=null},$.__c=function(e,t){t.some(function(n){try{n.__h.forEach(le),n.__h=n.__h.filter(function(o){return!o.__||Ce(o)})}catch(o){t.some(function(r){r.__h&&(r.__h=[])}),t=[],$.__e(o,n.__v)}}),qe&&qe(e,t)},$.unmount=function(e){Ve&&Ve(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{le(o)}catch(r){t=r}}),n.__H=void 0,t&&$.__e(t,n.__v))};var ze=typeof requestAnimationFrame=="function";function tn(e){var t,n=function(){clearTimeout(o),ze&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);ze&&(t=requestAnimationFrame(n))}function le(e){var t=T,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),T=t}function Ce(e){var t=T;e.__c=e.__(),T=t}function Ot(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function Rt(e,t){return typeof t=="function"?t(e):t}function Dt(e,t){for(var n in t)e[n]=t[n];return e}function Be(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function We(e,t){this.props=e,this.context=t}(We.prototype=new R).isPureReactComponent=!0,We.prototype.shouldComponentUpdate=function(e,t){return Be(this.props,e)||Be(this.state,t)};var Ye=p.__b;p.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ye&&Ye(e)};var nn=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function B(e){function t(n){var o=Dt({},n);return delete o.ref,e(o,n.ref||null)}return t.$$typeof=nn,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var on=p.__e;p.__e=function(e,t,n,o){if(e.then){for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t)}on(e,t,n,o)};var Ge=p.unmount;function jt(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=Dt({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return jt(o,t,n)})),e}function Ut(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return Ut(o,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function be(){this.__u=0,this.o=null,this.__b=null}function Lt(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ie(){this.i=null,this.l=null}p.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ge&&Ge(e)},(be.prototype=new R).__c=function(e,t){var n=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(n);var r=Lt(o.__v),i=!1,l=function(){i||(i=!0,n.__R=null,r?r(_):_())};n.__R=l;var _=function(){if(!--o.__u){if(o.state.__a){var u=o.state.__a;o.__v.__k[0]=Ut(u,u.__c.__P,u.__c.__O)}var c;for(o.setState({__a:o.__b=null});c=o.o.pop();)c.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(l,l)},be.prototype.componentWillUnmount=function(){this.o=[]},be.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=jt(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&Ne(F,null,e.fallback);return r&&(r.__u&=-33),[Ne(F,null,t.__a?null:e.children),r]};var Je=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]r.trim()).filter(r=>r),n={session:{},media:[],ice:{candidates:{host:[],srflx:[],relay:[]},credentials:{}},security:{},codecs:{audio:[],video:[]}};let o=null;for(const r of t){const[i,l]=r.split("=",2);switch(i){case"v":n.session.version=l;break;case"o":const[,_,u,,,c]=l.split(" ");n.session.origin={sessId:_,sessVersion:u,address:c};break;case"s":n.session.name=l==="-"?"Default Session":l;break;case"m":const[h,a,m,...v]=l.split(" ");o={type:h,port:parseInt(a),protocol:m,formats:v,attributes:{}},n.media.push(o);break;case"c":if(o){const[,,N]=l.split(" ");o.connection={address:N}}break;case"a":mn(l,n,o);break}}return n}function mn(e,t,n){if(e.startsWith("candidate:"))vn(e,t.ice.candidates);else if(e.startsWith("ice-ufrag:"))t.ice.credentials.ufrag=e.slice(10);else if(e.startsWith("ice-pwd:"))t.ice.credentials.password=e.slice(8);else if(e.startsWith("fingerprint:")){const[o,r]=e.split("fingerprint:")[1].split(" ",2);t.security.fingerprint={algorithm:o,fingerprint:r}}else if(e.startsWith("rtpmap:"))yn(e,t.codecs,n==null?void 0:n.type);else if(n){const[o,r]=e.split(":",2);n.attributes[o]=r||!0}}function vn(e,t){const n=e.split(" ");if(n.length<6){console.warn("Invalid candidate line format:",e);return}const o={foundation:n[0].split(":")[1]||"",component:n[1]||"",protocol:n[2]||"",priority:parseInt(n[3],10)||0,address:n[4]||"",port:parseInt(n[5],10)||0,type:null},r=n.findIndex(i=>i==="typ");if(r!==-1&&r+1{const a=o[u];a.length>0&&(n.push(` ${c} ${h}: ${a.length} candidate(s)`),a.forEach(m=>{n.push(` • ${m.address}:${m.port} (${m.protocol.toUpperCase()})`)}))}),o.relay.length===0&&(n.push(" ❌ No TURN relay candidates found"),n.push(" This may cause connection issues in restrictive networks")),n.push(""),n.push("📊 Connection Assessment:");const i={relay:o.relay.length>0,publicIP:o.srflx.length>0,localIP:o.host.length>0},_=[{condition:i.relay&&i.publicIP&&i.localIP,status:" ✅ Excellent: All connection types available",details:[]},{condition:i.relay,status:" ✅ Good: TURN relay available",details:[]},{condition:i.publicIP&&i.localIP,status:" ⚠️ Ok: Direct connections possible, but no TURN relay",details:[" May fail in restrictive corporate/university networks"]},{condition:i.localIP,status:" ❌ Limited: Only local network connectivity",details:[" Likely to fail across different networks"]},{condition:!0,status:" 🚫 Poor: No valid network candidates found",details:[]}].find(u=>u.condition);return n.push(_.status),_.details.forEach(u=>n.push(u)),n.push(""),n.push("🎥 Media Streams:"),t.media.forEach(u=>{var h;const c=tt[u.type]||tt.default;n.push(` ${c} ${u.type.toUpperCase()}:`),n.push(` Port: ${u.port===nt?`Dynamic (${nt} = placeholder)`:u.port}`),n.push(` Protocol: ${u.protocol}`),n.push(` Connection: ${((h=u.connection)==null?void 0:h.address)||"Not specified"}`),u.attributes.sendrecv&&n.push(" Direction: Bidirectional (send & receive)"),n.push("")}),t.codecs.audio.length>0&&(n.push("🎵 Audio Codecs:"),t.codecs.audio.forEach(u=>{const c=et[u.name]||(u.name.includes("PCM")?" (Basic Quality)":"");n.push(` • ${u.name}${c}: ${u.clockRate}Hz, ${u.channels} channel(s)`)}),n.push("")),t.codecs.video.length>0&&(n.push("📽️ Video Codecs:"),t.codecs.video.forEach(u=>{const c=et[u.name]||"";n.push(` • ${u.name}${c}: ${u.clockRate}Hz`)}),n.push("")),t.security.fingerprint&&(n.push("🔒 Security:"),n.push(` DTLS Fingerprint: ${t.security.fingerprint.algorithm.toUpperCase()}`),n.push(` ${t.security.fingerprint.fingerprint}`),n.push("")),t.ice.credentials.ufrag&&(n.push("🔑 ICE Authentication:"),n.push(` Username Fragment: ${t.ice.credentials.ufrag}`),n.push(` Password: ${t.ice.credentials.password?"[PRESENT]":"[MISSING]"}`),n.push("")),n.join(` +`)}function J(e,t){if(!t.trim()){console.error(e,"No SDP content provided");return}try{const n=hn(t);n&&console.log(bn(e,n))}catch(n){const o=n instanceof Error?n.message:"Unknown error";console.error(e,`Error parsing SDP: ${o}`)}}const ot={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",iceCandidatePoolSize:1},fe=class fe{constructor(t,n,o){M(this,"peerConnection");M(this,"setIceServersPromise");M(this,"state");M(this,"resolveCallAcceptedPromise");M(this,"iceTricklingDataChannel");M(this,"iceTricklingBuffer");this.outStreamPromise=t,this.onStateChanged=o,this.peerConnection=new RTCPeerConnection(ot);const r=c=>{this.peerConnection.setConfiguration({...ot,iceServers:c})},i=window.calls.getIceServers();typeof i=="string"?(r(JSON.parse(i)),this.setIceServersPromise=Promise.resolve()):this.setIceServersPromise=i.then(c=>{r(JSON.parse(c))}),this.state=fe.initialState,this.iceTricklingBuffer=[],this.iceTricklingDataChannel=this.peerConnection.createDataChannel("iceTrickling",{negotiated:!0,id:1}),this.iceTricklingDataChannel.onmessage=c=>{console.log("received ICE candidate from remote peer",c.data),this.peerConnection.addIceCandidate(JSON.parse(c.data))},this.iceTricklingDataChannel.onopen=()=>{console.log("iceTricklingDataChannel open: sending buffered ICE candidates",this.iceTricklingBuffer);for(const c of this.iceTricklingBuffer)it(this.iceTricklingDataChannel,c);this.iceTricklingBuffer=[]},this.peerConnection.ontrack=c=>{const h=c.streams[0];n(h),this.state="in-call",this.onStateChanged(this.state)};const l=async c=>{this.state="connecting",this.onStateChanged(this.state),await this.setIceServersPromise;const h=rt(this.peerConnection),a={type:"offer",sdp:c},m=new RTCSessionDescription(a);this.peerConnection.setRemoteDescription(m);const v=await t;console.log("getUserMedia() completed"),v.getTracks().forEach(s=>this.peerConnection.addTrack(s,v)),this.peerConnection.setLocalDescription(await this.peerConnection.createAnswer()),await h;const N=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),J("Answering incoming call with answer:",N),window.calls.acceptCall(N)},_=c=>{const h={type:"answer",sdp:c},a=new RTCSessionDescription(h);this.peerConnection.setRemoteDescription(a)},u=async()=>{var h;const c=decodeURIComponent(window.location.hash.substring(1));if(!c||c.length===0){console.log("empty URL hash: ",window.location.href);return}if((h=this.resolveCallAcceptedPromise)==null||h.call(this,!1),c==="startCall")console.log("URL hash CMD: ",c),await this.startCall();else if(c.startsWith("offerIncomingCall=")){const a=window.atob(c.split("offerIncomingCall=",2)[1]);J("Incoming call (with user prompt) with offer:",a),this.state="promptingUserToAcceptCall",this.onStateChanged(this.state);const m=await new Promise(v=>{const N=s=>{v(s),this.resolveCallAcceptedPromise===N&&(this.resolveCallAcceptedPromise=void 0)};this.resolveCallAcceptedPromise=N});if(console.log("Accept call prompt resolved: "+(m?"accepted":"not accepted")),!m)return;await l(a)}else if(c.startsWith("acceptCall=")){const a=window.atob(c.substring(11));J("Incoming call with offer:",a),await l(a)}else if(c.startsWith("onAnswer=")){const a=window.atob(c.substring(9));J("Outgoing call was accepted with answer:",a),_(a)}else console.log("unexpected URL hash: ",c)};u(),window.addEventListener("hashchange",u)}async startCall(){await this.setIceServersPromise;const t=rt(this.peerConnection),n=await this.outStreamPromise;console.log("getUserMedia() completed"),n.getTracks().forEach(r=>this.peerConnection.addTrack(r,n)),this.peerConnection.setLocalDescription(await this.peerConnection.createOffer()),await t;const o=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),J("Start outgoing call with offer:",o),window.calls.startCall(o),this.state="ringing",this.onStateChanged(this.state)}acceptCall(){if(this.resolveCallAcceptedPromise==null){console.warn("acceptCall invoked, but we were not waiting for it");return}this.resolveCallAcceptedPromise(!0)}async endCall(){var t;this.peerConnection.close(),window.calls.endCall(),(t=this.resolveCallAcceptedPromise)==null||t.call(this,!1)}getState(){return this.state}trickleIceOverDataChannel(t){if(this.iceTricklingDataChannel.readyState!=="open"){console.log("Gathered new ICE candidate, but iceTricklingDataChannel is not yet open, will buffer it",t.candidate),this.iceTricklingBuffer.push(t.candidate);return}it(this.iceTricklingDataChannel,t.candidate)}};M(fe,"initialState","connecting");let de=fe;function rt(e){(e.localDescription!=null||e.remoteDescription!=null)&&console.warn("gatheredEnoughIce called after setLocalDescription or setRemoteDescription: it might not have captured all ICE candidate events");const t=new Promise(o=>{const r=i=>{i.candidate!=null&&i.candidate.type==="relay"&&(setTimeout(o,0),e.removeEventListener("icecandidate",r))};e.addEventListener("icecandidate",r)}),n=new Promise(o=>{const r=()=>{e.iceGatheringState==="complete"&&(o(),e.removeEventListener("icegatheringstatechange",r))};e.addEventListener("icegatheringstatechange",r)});return Promise.race([t,n])}function it(e,t){console.log("sending ICE candidate to remote peer",t),e.send(JSON.stringify(t===null?t:t.toJSON()))}var gn=0;function b(e,t,n,o,r,i){t||(t={});var l,_,u=t;if("ref"in u)for(_ in u={},t)_=="ref"?l=t[_]:u[_]=t[_];var c={type:e,props:u,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--gn,__i:-1,__u:0,__source:r,__self:i};if(typeof e=="function"&&(l=e.defaultProps))for(_ in l)u[_]===void 0&&(u[_]=l[_]);return p.vnode&&p.vnode(c),c}var at="/home/adbenitez/projects/deltachat/call/src/components/VideoThumbnail.tsx";const wn={position:"absolute",right:"15px",top:"15px",height:"100px",width:"100px",zIndex:1,imageRendering:"crisp-edges",borderRadius:"5px",boxShadow:"rgba(0, 0, 0, 0.29) 0px 2px 8px 0px, rgba(0, 0, 0, 0.28) 0px 2px 8px 0px"};function Nn({videoRef:e}){return b("div",{style:wn,children:b("video",{poster:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",style:{borderRadius:"5px",objectFit:"cover",transform:"scaleX(-1)"},width:"100%",height:"100%",muted:!0,autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:at,lineNumber:21,columnNumber:7},this)},void 0,!1,{fileName:at,lineNumber:20,columnNumber:5},this)}var lt="/home/adbenitez/projects/deltachat/call/src/components/FullscreenVideo.tsx";const kn={imageRendering:"crisp-edges",width:"100%",height:"100%"};function Cn({videoRef:e}){return b("div",{style:kn,children:b("video",{poster:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",width:"100%",height:"100%",autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:lt,lineNumber:14,columnNumber:7},this)},void 0,!1,{fileName:lt,lineNumber:13,columnNumber:5},this)}var st="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call-end.jsx";const Tn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 8q2.95 0 5.813 1.188T22.9 12.75q.3.3.3.7t-.3.7l-2.3 2.25q-.275.275-.638.3t-.662-.2l-2.9-2.2q-.2-.15-.3-.35t-.1-.45v-2.85q-.95-.3-1.95-.475T12 10t-2.05.175T8 10.65v2.85q0 .25-.1.45t-.3.35l-2.9 2.2q-.3.225-.663.2t-.637-.3l-2.3-2.25q-.3-.3-.3-.7t.3-.7q2.2-2.375 5.075-3.562T12 8"},void 0,!1,{fileName:st,lineNumber:3,columnNumber:123},void 0)},void 0,!1,{fileName:st,lineNumber:3,columnNumber:48},void 0),An=B(Tn),Sn="_btn_2u459_1",$n={btn:Sn};var En="/home/adbenitez/projects/deltachat/call/src/components/Button.tsx";function se({children:e,className:t,...n}){return b("button",{className:(t??"")+" "+$n.btn,...n,children:e},void 0,!1,{fileName:En,lineNumber:10,columnNumber:5},this)}var ct="/home/adbenitez/projects/deltachat/call/src/components/EndCallButton.tsx";const ut={background:"#f01d2c"};function Pn({...e}){return e.style={...ut,...e.style||{}},b(se,{"aria-label":"End call",title:"End call",style:ut,...e,children:b(An,{},void 0,!1,{fileName:ct,lineNumber:22,columnNumber:7},this)},void 0,!1,{fileName:ct,lineNumber:16,columnNumber:5},this)}var _t="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/person.jsx";const xn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 12q-1.65 0-2.825-1.175T8 8t1.175-2.825T12 4t2.825 1.175T16 8t-1.175 2.825T12 12m-8 8v-2.8q0-.85.438-1.562T5.6 14.55q1.55-.775 3.15-1.162T12 13t3.25.388t3.15 1.162q.725.375 1.163 1.088T20 17.2V20z"},void 0,!1,{fileName:_t,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:_t,lineNumber:3,columnNumber:47},void 0),In=B(xn);var On="/home/adbenitez/projects/deltachat/call/src/components/AvatarCircle.tsx";const dt={display:"inline-flex",flexDirection:"row",alignItems:"center",padding:"0.5em",color:"white",background:"#c8c7cd",borderRadius:"50%",fontSize:"1.5em"};function Rn({children:e,...t}){return t.style={...dt,...t.style||{}},b("div",{style:dt,...t,children:e},void 0,!1,{fileName:On,lineNumber:20,columnNumber:5},this)}var ft="/home/adbenitez/projects/deltachat/call/src/components/AvatarPlaceholder.tsx";function Dn({...e}){return b(Rn,{style:{padding:"0.2em",fontSize:"5em"},...e,children:b(In,{},void 0,!1,{fileName:ft,lineNumber:12,columnNumber:7},this)},void 0,!1,{fileName:ft,lineNumber:11,columnNumber:5},this)}var jn="/home/adbenitez/projects/deltachat/call/src/components/AvatarImage.tsx";function Un({url:e,...t}){return t.style={borderRadius:"50%",backgroundImage:`url(${e})`,backgroundSize:"cover",backgroundPosition:"center",...t.style||{}},b("div",{...t},void 0,!1,{fileName:jn,lineNumber:14,columnNumber:10},this)}var pt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call.jsx";const Ln=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M19.95 21q-3.125 0-6.175-1.362t-5.55-3.863t-3.862-5.55T3 4.05q0-.45.3-.75t.75-.3H8.1q.35 0 .625.238t.325.562l.65 3.5q.05.4-.025.675T9.4 8.45L6.975 10.9q.5.925 1.187 1.787t1.513 1.663q.775.775 1.625 1.438T13.1 17l2.35-2.35q.225-.225.588-.337t.712-.063l3.45.7q.35.1.575.363T21 15.9v4.05q0 .45-.3.75t-.75.3"},void 0,!1,{fileName:pt,lineNumber:3,columnNumber:120},void 0)},void 0,!1,{fileName:pt,lineNumber:3,columnNumber:45},void 0),Hn=B(Ln);var ht="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/videocam.jsx";const qn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M4 20q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4h12q.825 0 1.413.588T18 6v4.5l4-4v11l-4-4V18q0 .825-.587 1.413T16 20z"},void 0,!1,{fileName:ht,lineNumber:3,columnNumber:124},void 0)},void 0,!1,{fileName:ht,lineNumber:3,columnNumber:49},void 0),Vn=B(qn);var mt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/videocam-off.jsx";const Fn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"m22 17.5l-4-4v1.675L6.825 4H16q.825 0 1.413.588T18 6v4.5l4-4zm-1.45 5.85L.65 3.45l1.4-1.4l19.9 19.9zM4 4l14 14q0 .825-.587 1.413T16 20H4q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4"},void 0,!1,{fileName:mt,lineNumber:3,columnNumber:127},void 0)},void 0,!1,{fileName:mt,lineNumber:3,columnNumber:52},void 0),Mn=B(Fn);var vt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/mic.jsx";const zn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 14q-1.25 0-2.125-.875T9 11V5q0-1.25.875-2.125T12 2t2.125.875T15 5v6q0 1.25-.875 2.125T12 14m-1 7v-3.075q-2.6-.35-4.3-2.325T5 11h2q0 2.075 1.463 3.538T12 16t3.538-1.463T17 11h2q0 2.625-1.7 4.6T13 17.925V21z"},void 0,!1,{fileName:vt,lineNumber:3,columnNumber:119},void 0)},void 0,!1,{fileName:vt,lineNumber:3,columnNumber:44},void 0),Bn=B(zn);var yt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/mic-off.jsx";const Wn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M17.75 14.95L16.3 13.5q.35-.575.525-1.2T17 11h2q0 1.1-.325 2.088t-.925 1.862m-2.95-3L9 6.15V5q0-1.25.875-2.125T12 2t2.125.875T15 5v6q0 .275-.062.5t-.138.45M11 21v-3.1q-2.6-.35-4.3-2.312T5 11h2q0 2.075 1.463 3.538T12 16q.85 0 1.613-.262T15 15l1.425 1.425q-.725.575-1.588.963T13 17.9V21zm8.8 1.6L1.4 4.2l1.4-1.4l18.4 18.4z"},void 0,!1,{fileName:yt,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:yt,lineNumber:3,columnNumber:47},void 0),Yn=B(Wn);var E="/home/adbenitez/projects/deltachat/call/src/App.tsx";function Gn(){const[e,t]=U(re(de.initialState),"state"),n=U(Y(null),"outVidRef"),o=U(Y(null),"incVidRef"),r=U(Y(null),"disableVideoCompletelyRef");r.current==null&&(r.current=location.search.includes("disableVideoCompletely"));const i=r.current,l=U(Y(null),"enableVideoInitiallyRef");l.current==null&&(l.current=!location.search.includes("noOutgoingVideoInitially"));const _=l.current,[u,c]=U(re(!0),"isOutAudioEnabled"),[h,a]=U(re(_),"isOutVideoEnabled_"),m=i?!1:h,v=U(Y(u),"isOutAudioEnabledRef");v.current=u;const N=U(Y(m),"isOutVideoEnabledRef");N.current=m;const s=U(_e(async()=>{let w;try{w=await navigator.mediaDevices.getUserMedia({video:!i,audio:!0})}catch{console.warn("Failed to getUserMedia with video, will try just audio"),w=await navigator.mediaDevices.getUserMedia({audio:!0})}return w.getAudioTracks().forEach(x=>x.enabled=v.current),w.getVideoTracks().forEach(x=>x.enabled=N.current),w},[i]),"outStreamPromise"),[d,f]=U(re(null),"outStream");Me(()=>{let w=!1;return f(null),s.then(x=>{w||f(x)}),()=>{w=!0}},[s]),d&&n.current&&n.current.srcObject!==d&&(n.current.srcObject=d);const y=U(_e(()=>{const w=x=>{i&&(x.getVideoTracks().forEach(ne=>x.removeTrack(ne)),x.addEventListener("addtrack",ne=>{ne.track.kind==="video"&&x.removeTrack(ne.track)}));const H=o.current;H.srcObject=x;const te=()=>{H.paused?(console.log("incoming video not playing, will .play() it"),H.play()):(console.log("incoming video is playing"),clearInterval(Ht))},Ht=setInterval(te,100);te()};return new de(s,w,t)},[s,i]),"manager");Me(()=>{if(d==null)return;const w=()=>{d.getAudioTracks().forEach(x=>x.enabled=u),d.getVideoTracks().forEach(x=>x.enabled=m)};return w(),d.addEventListener("addtrack",w),d.addEventListener("removetrack",w),()=>{d.removeEventListener("addtrack",w),d.removeEventListener("removetrack",w)}},[d,u,m]);const k=!i&&(d==null||d.getVideoTracks().length>=1),g=e==="promptingUserToAcceptCall"?()=>y.acceptCall():null,A=Zt(()=>{y.endCall()},[y]);let S;switch(e){case"promptingUserToAcceptCall":S="Incoming call";break;case"connecting":S="Connecting...";break;case"ringing":S="Ringing...";break;case"in-call":S="";break}const D=e==="in-call",j={display:D?"block":"none",height:"100%"},I=u?"Mute microphone":"Unmute microphone",O=m?"Stop camera":"Start camera",C={color:"white",borderRadius:"50%",fontSize:"1.5em",margin:"0.25em 0.625em"};return b("div",{style:{height:"100vh",overflow:"hidden"},children:[b("div",{style:j,children:[b(Cn,{videoRef:o},void 0,!1,{fileName:E,lineNumber:203,columnNumber:9},this),b(Nn,{videoRef:n},void 0,!1,{fileName:E,lineNumber:204,columnNumber:9},this)]},void 0,!0,{fileName:E,lineNumber:202,columnNumber:7},this),b("div",{role:"status",style:{position:"absolute",top:0,width:"100%",paddingTop:"1em",textAlign:"center"},children:S},void 0,!1,{fileName:E,lineNumber:207,columnNumber:7},this),b("div",{style:{display:D?"none":"flex",alignItems:"center",textAlign:"center",justifyContent:"center",height:"100%"},children:b("div",{style:{position:"relative"},children:[b(Dn,{},void 0,!1,{fileName:E,lineNumber:229,columnNumber:11},this),window.calls.getAvatar&&b(Un,{url:window.calls.getAvatar(),style:{position:"absolute",inset:0}},void 0,!1,{fileName:E,lineNumber:231,columnNumber:13},this)]},void 0,!0,{fileName:E,lineNumber:228,columnNumber:9},this)},void 0,!1,{fileName:E,lineNumber:219,columnNumber:7},this),b("div",{style:{position:"absolute",bottom:"0.75em",width:"100%",textAlign:"center"},children:[g!=null&&b(se,{"aria-label":"Answer call",title:"Answer call",onClick:g,className:"acceptCallButton",style:{backgroundColor:"#00b000",...C},children:b(Hn,{},void 0,!1,{fileName:E,lineNumber:257,columnNumber:13},this)},void 0,!1,{fileName:E,lineNumber:247,columnNumber:11},this),b(se,{"aria-label":I,title:I,onClick:()=>c(w=>!w),style:C,children:u?b(Bn,{},void 0,!1,{fileName:E,lineNumber:267,columnNumber:13},this):b(Yn,{},void 0,!1,{fileName:E,lineNumber:269,columnNumber:13},this)},void 0,!1,{fileName:E,lineNumber:260,columnNumber:9},this),k&&b(se,{"aria-label":O,title:O,onClick:()=>a(w=>!w),style:C,children:m?b(Vn,{},void 0,!1,{fileName:E,lineNumber:280,columnNumber:15},this):b(Mn,{},void 0,!1,{fileName:E,lineNumber:282,columnNumber:15},this)},void 0,!1,{fileName:E,lineNumber:273,columnNumber:11},this),b(Pn,{onClick:A,style:C},void 0,!1,{fileName:E,lineNumber:286,columnNumber:9},this)]},void 0,!0,{fileName:E,lineNumber:238,columnNumber:7},this)]},void 0,!0,{fileName:E,lineNumber:201,columnNumber:5},this)}var Jn="/home/adbenitez/projects/deltachat/call/src/index.tsx";Yt(b(Gn,{},void 0,!1,{fileName:Jn,lineNumber:4,columnNumber:8},void 0),document.getElementById("root")); - +`)}function J(e,t){if(!t.trim()){console.error(e,"No SDP content provided");return}try{const n=hn(t);n&&console.log(bn(e,n))}catch(n){const o=n instanceof Error?n.message:"Unknown error";console.error(e,`Error parsing SDP: ${o}`)}}const ot={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",iceCandidatePoolSize:1},fe=class fe{constructor(t,n,o){M(this,"peerConnection");M(this,"setIceServersPromise");M(this,"state");M(this,"resolveCallAcceptedPromise");M(this,"iceTricklingDataChannel");M(this,"iceTricklingBuffer");this.outStreamPromise=t,this.onStateChanged=o,this.peerConnection=new RTCPeerConnection(ot);const r=c=>{this.peerConnection.setConfiguration({...ot,iceServers:c})},i=window.calls.getIceServers();typeof i=="string"?(r(JSON.parse(i)),this.setIceServersPromise=Promise.resolve()):this.setIceServersPromise=i.then(c=>{r(JSON.parse(c))}),this.state=fe.initialState,this.iceTricklingBuffer=[],this.iceTricklingDataChannel=this.peerConnection.createDataChannel("iceTrickling",{negotiated:!0,id:1}),this.iceTricklingDataChannel.onmessage=c=>{console.log("received ICE candidate from remote peer",c.data),this.peerConnection.addIceCandidate(JSON.parse(c.data))},this.iceTricklingDataChannel.onopen=()=>{console.log("iceTricklingDataChannel open: sending buffered ICE candidates",this.iceTricklingBuffer);for(const c of this.iceTricklingBuffer)it(this.iceTricklingDataChannel,c);this.iceTricklingBuffer=[]},this.peerConnection.ontrack=c=>{const h=c.streams[0];n(h),this.state="in-call",this.onStateChanged(this.state)};const l=async c=>{this.state="connecting",this.onStateChanged(this.state),await this.setIceServersPromise;const h=rt(this.peerConnection),a={type:"offer",sdp:c},m=new RTCSessionDescription(a);this.peerConnection.setRemoteDescription(m);const v=await t;console.log("getUserMedia() completed"),v.getTracks().forEach(s=>this.peerConnection.addTrack(s,v)),this.peerConnection.setLocalDescription(await this.peerConnection.createAnswer()),await h;const N=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),J("Answering incoming call with answer:",N),window.calls.acceptCall(N)},_=c=>{const h={type:"answer",sdp:c},a=new RTCSessionDescription(h);this.peerConnection.setRemoteDescription(a)},u=async()=>{var h;const c=decodeURIComponent(window.location.hash.substring(1));if(!c||c.length===0){console.log("empty URL hash: ",window.location.href);return}if((h=this.resolveCallAcceptedPromise)==null||h.call(this,!1),c==="startCall")console.log("URL hash CMD: ",c),await this.startCall();else if(c.startsWith("offerIncomingCall=")){const a=window.atob(c.split("offerIncomingCall=",2)[1]);J("Incoming call (with user prompt) with offer:",a),this.state="promptingUserToAcceptCall",this.onStateChanged(this.state);const m=await new Promise(v=>{const N=s=>{v(s),this.resolveCallAcceptedPromise===N&&(this.resolveCallAcceptedPromise=void 0)};this.resolveCallAcceptedPromise=N});if(console.log("Accept call prompt resolved: "+(m?"accepted":"not accepted")),!m)return;await l(a)}else if(c.startsWith("acceptCall=")){const a=window.atob(c.substring(11));J("Incoming call with offer:",a),await l(a)}else if(c.startsWith("onAnswer=")){const a=window.atob(c.substring(9));J("Outgoing call was accepted with answer:",a),_(a)}else console.log("unexpected URL hash: ",c)};u(),window.addEventListener("hashchange",u)}async startCall(){await this.setIceServersPromise;const t=rt(this.peerConnection),n=await this.outStreamPromise;console.log("getUserMedia() completed"),n.getTracks().forEach(r=>this.peerConnection.addTrack(r,n)),this.peerConnection.setLocalDescription(await this.peerConnection.createOffer()),await t;const o=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),J("Start outgoing call with offer:",o),window.calls.startCall(o),this.state="ringing",this.onStateChanged(this.state)}acceptCall(){if(this.resolveCallAcceptedPromise==null){console.warn("acceptCall invoked, but we were not waiting for it");return}this.resolveCallAcceptedPromise(!0)}async endCall(){var t;this.peerConnection.close(),window.calls.endCall(),(t=this.resolveCallAcceptedPromise)==null||t.call(this,!1)}getState(){return this.state}trickleIceOverDataChannel(t){if(this.iceTricklingDataChannel.readyState!=="open"){console.log("Gathered new ICE candidate, but iceTricklingDataChannel is not yet open, will buffer it",t.candidate),this.iceTricklingBuffer.push(t.candidate);return}it(this.iceTricklingDataChannel,t.candidate)}};M(fe,"initialState","connecting");let de=fe;function rt(e){(e.localDescription!=null||e.remoteDescription!=null)&&console.warn("gatheredEnoughIce called after setLocalDescription or setRemoteDescription: it might not have captured all ICE candidate events");const t=new Promise(o=>{const r=i=>{i.candidate!=null&&i.candidate.type==="relay"&&(setTimeout(o,0),e.removeEventListener("icecandidate",r))};e.addEventListener("icecandidate",r)}),n=new Promise(o=>{const r=()=>{e.iceGatheringState==="complete"&&(o(),e.removeEventListener("icegatheringstatechange",r))};e.addEventListener("icegatheringstatechange",r)});return Promise.race([t,n])}function it(e,t){console.log("sending ICE candidate to remote peer",t),e.send(JSON.stringify(t===null?t:t.toJSON()))}var gn=0;function b(e,t,n,o,r,i){t||(t={});var l,_,u=t;if("ref"in u)for(_ in u={},t)_=="ref"?l=t[_]:u[_]=t[_];var c={type:e,props:u,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--gn,__i:-1,__u:0,__source:r,__self:i};if(typeof e=="function"&&(l=e.defaultProps))for(_ in l)u[_]===void 0&&(u[_]=l[_]);return p.vnode&&p.vnode(c),c}var at="/home/adbenitez/projects/deltachat/call/src/components/VideoThumbnail.tsx";const wn={position:"absolute",right:"15px",top:"15px",height:"100px",width:"100px",zIndex:1,imageRendering:"crisp-edges",borderRadius:"5px",boxShadow:"rgba(0, 0, 0, 0.29) 0px 2px 8px 0px, rgba(0, 0, 0, 0.28) 0px 2px 8px 0px"};function Nn({videoRef:e}){return b("div",{style:wn,children:b("video",{poster:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",style:{borderRadius:"5px",objectFit:"cover",transform:"scaleX(-1)"},width:"100%",height:"100%",muted:!0,autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:at,lineNumber:21,columnNumber:7},this)},void 0,!1,{fileName:at,lineNumber:20,columnNumber:5},this)}var lt="/home/adbenitez/projects/deltachat/call/src/components/FullscreenVideo.tsx";const kn={imageRendering:"crisp-edges",width:"100%",height:"100%"};function Cn({videoRef:e}){return b("div",{style:kn,children:b("video",{poster:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",width:"100%",height:"100%",autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:lt,lineNumber:14,columnNumber:7},this)},void 0,!1,{fileName:lt,lineNumber:13,columnNumber:5},this)}var st="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call-end.jsx";const Tn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 8q2.95 0 5.813 1.188T22.9 12.75q.3.3.3.7t-.3.7l-2.3 2.25q-.275.275-.638.3t-.662-.2l-2.9-2.2q-.2-.15-.3-.35t-.1-.45v-2.85q-.95-.3-1.95-.475T12 10t-2.05.175T8 10.65v2.85q0 .25-.1.45t-.3.35l-2.9 2.2q-.3.225-.663.2t-.637-.3l-2.3-2.25q-.3-.3-.3-.7t.3-.7q2.2-2.375 5.075-3.562T12 8"},void 0,!1,{fileName:st,lineNumber:3,columnNumber:123},void 0)},void 0,!1,{fileName:st,lineNumber:3,columnNumber:48},void 0),An=B(Tn),Sn="_btn_2u459_1",$n={btn:Sn};var En="/home/adbenitez/projects/deltachat/call/src/components/Button.tsx";function se({children:e,className:t,...n}){return b("button",{className:(t??"")+" "+$n.btn,...n,children:e},void 0,!1,{fileName:En,lineNumber:10,columnNumber:5},this)}var ct="/home/adbenitez/projects/deltachat/call/src/components/EndCallButton.tsx";const ut={background:"#f01d2c"};function Pn({...e}){return e.style={...ut,...e.style||{}},b(se,{"aria-label":"End call",title:"End call",style:ut,...e,children:b(An,{},void 0,!1,{fileName:ct,lineNumber:22,columnNumber:7},this)},void 0,!1,{fileName:ct,lineNumber:16,columnNumber:5},this)}var _t="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/person.jsx";const xn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 12q-1.65 0-2.825-1.175T8 8t1.175-2.825T12 4t2.825 1.175T16 8t-1.175 2.825T12 12m-8 8v-2.8q0-.85.438-1.562T5.6 14.55q1.55-.775 3.15-1.162T12 13t3.25.388t3.15 1.162q.725.375 1.163 1.088T20 17.2V20z"},void 0,!1,{fileName:_t,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:_t,lineNumber:3,columnNumber:47},void 0),In=B(xn);var On="/home/adbenitez/projects/deltachat/call/src/components/AvatarCircle.tsx";const dt={display:"inline-flex",flexDirection:"row",alignItems:"center",padding:"0.5em",color:"white",background:"#c8c7cd",borderRadius:"50%",fontSize:"1.5em"};function Rn({children:e,...t}){return t.style={...dt,...t.style||{}},b("div",{style:dt,...t,children:e},void 0,!1,{fileName:On,lineNumber:20,columnNumber:5},this)}var ft="/home/adbenitez/projects/deltachat/call/src/components/AvatarPlaceholder.tsx";function Dn({...e}){return b(Rn,{style:{padding:"0.2em",fontSize:"5em"},...e,children:b(In,{},void 0,!1,{fileName:ft,lineNumber:12,columnNumber:7},this)},void 0,!1,{fileName:ft,lineNumber:11,columnNumber:5},this)}var jn="/home/adbenitez/projects/deltachat/call/src/components/AvatarImage.tsx";function Un({url:e,...t}){return t.style={borderRadius:"50%",backgroundImage:`url(${e})`,backgroundSize:"cover",backgroundPosition:"center",...t.style||{}},b("div",{...t},void 0,!1,{fileName:jn,lineNumber:14,columnNumber:10},this)}var pt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call.jsx";const Ln=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M19.95 21q-3.125 0-6.175-1.362t-5.55-3.863t-3.862-5.55T3 4.05q0-.45.3-.75t.75-.3H8.1q.35 0 .625.238t.325.562l.65 3.5q.05.4-.025.675T9.4 8.45L6.975 10.9q.5.925 1.187 1.787t1.513 1.663q.775.775 1.625 1.438T13.1 17l2.35-2.35q.225-.225.588-.337t.712-.063l3.45.7q.35.1.575.363T21 15.9v4.05q0 .45-.3.75t-.75.3"},void 0,!1,{fileName:pt,lineNumber:3,columnNumber:120},void 0)},void 0,!1,{fileName:pt,lineNumber:3,columnNumber:45},void 0),Hn=B(Ln);var ht="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/videocam.jsx";const qn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M4 20q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4h12q.825 0 1.413.588T18 6v4.5l4-4v11l-4-4V18q0 .825-.587 1.413T16 20z"},void 0,!1,{fileName:ht,lineNumber:3,columnNumber:124},void 0)},void 0,!1,{fileName:ht,lineNumber:3,columnNumber:49},void 0),Vn=B(qn);var mt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/videocam-off.jsx";const Fn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"m22 17.5l-4-4v1.675L6.825 4H16q.825 0 1.413.588T18 6v4.5l4-4zm-1.45 5.85L.65 3.45l1.4-1.4l19.9 19.9zM4 4l14 14q0 .825-.587 1.413T16 20H4q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4"},void 0,!1,{fileName:mt,lineNumber:3,columnNumber:127},void 0)},void 0,!1,{fileName:mt,lineNumber:3,columnNumber:52},void 0),Mn=B(Fn);var vt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/mic.jsx";const zn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M12 14q-1.25 0-2.125-.875T9 11V5q0-1.25.875-2.125T12 2t2.125.875T15 5v6q0 1.25-.875 2.125T12 14m-1 7v-3.075q-2.6-.35-4.3-2.325T5 11h2q0 2.075 1.463 3.538T12 16t3.538-1.463T17 11h2q0 2.625-1.7 4.6T13 17.925V21z"},void 0,!1,{fileName:vt,lineNumber:3,columnNumber:119},void 0)},void 0,!1,{fileName:vt,lineNumber:3,columnNumber:44},void 0),Bn=B(zn);var yt="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/mic-off.jsx";const Wn=(e,t)=>b("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:b("path",{fill:"currentColor",d:"M17.75 14.95L16.3 13.5q.35-.575.525-1.2T17 11h2q0 1.1-.325 2.088t-.925 1.862m-2.95-3L9 6.15V5q0-1.25.875-2.125T12 2t2.125.875T15 5v6q0 .275-.062.5t-.138.45M11 21v-3.1q-2.6-.35-4.3-2.312T5 11h2q0 2.075 1.463 3.538T12 16q.85 0 1.613-.262T15 15l1.425 1.425q-.725.575-1.588.963T13 17.9V21zm8.8 1.6L1.4 4.2l1.4-1.4l18.4 18.4z"},void 0,!1,{fileName:yt,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:yt,lineNumber:3,columnNumber:47},void 0),Yn=B(Wn);var P="/home/adbenitez/projects/deltachat/call/src/App.tsx";function Gn(){const[e,t]=U(re(de.initialState),"state"),n=U(Y(null),"outVidRef"),o=U(Y(null),"incVidRef"),r=U(Y(null),"disableVideoCompletelyRef");r.current==null&&(r.current=location.search.includes("disableVideoCompletely"));const i=r.current,l=U(Y(null),"enableVideoInitiallyRef");l.current==null&&(l.current=!location.search.includes("noOutgoingVideoInitially"));const _=l.current,[u,c]=U(re(!0),"isOutAudioEnabled"),[h,a]=U(re(_),"isOutVideoEnabled_"),m=i?!1:h,v=U(Y(u),"isOutAudioEnabledRef");v.current=u;const N=U(Y(m),"isOutVideoEnabledRef");N.current=m;const s=U(_e(async()=>{let w;try{w=await navigator.mediaDevices.getUserMedia({video:!i,audio:!0})}catch{console.warn("Failed to getUserMedia with video, will try just audio"),w=await navigator.mediaDevices.getUserMedia({audio:!0})}return w.getAudioTracks().forEach(E=>E.enabled=v.current),w.getVideoTracks().forEach(E=>E.enabled=N.current),w},[i]),"outStreamPromise"),[d,f]=U(re(null),"outStream");Me(()=>{let w=!1;return f(null),s.then(E=>{w||f(E)}),()=>{w=!0}},[s]),d&&n.current&&n.current.srcObject!==d&&(n.current.srcObject=d);const y=U(_e(()=>{const w=E=>{i&&(E.getVideoTracks().forEach(ne=>E.removeTrack(ne)),E.addEventListener("addtrack",ne=>{ne.track.kind==="video"&&E.removeTrack(ne.track)}));const H=o.current;H.srcObject!==E&&(H.srcObject=E);const te=()=>{H.paused?(console.log("incoming video not playing, will .play() it"),H.play()):(console.log("incoming video is playing"),clearInterval(Ht))},Ht=setInterval(te,100);te()};return new de(s,w,t)},[s,i]),"manager");Me(()=>{if(d==null)return;const w=()=>{d.getAudioTracks().forEach(E=>E.enabled=u),d.getVideoTracks().forEach(E=>E.enabled=m)};return w(),d.addEventListener("addtrack",w),d.addEventListener("removetrack",w),()=>{d.removeEventListener("addtrack",w),d.removeEventListener("removetrack",w)}},[d,u,m]);const k=!i&&(d==null||d.getVideoTracks().length>=1),g=e==="promptingUserToAcceptCall"?()=>y.acceptCall():null,A=Zt(()=>{y.endCall()},[y]);let S;switch(e){case"promptingUserToAcceptCall":S="Incoming call";break;case"connecting":S="Connecting...";break;case"ringing":S="Ringing...";break;case"in-call":S="";break}const D=e==="in-call",j={display:D?"block":"none",height:"100%"},I=u?"Mute microphone":"Unmute microphone",O=m?"Stop camera":"Start camera",C={color:"white",borderRadius:"50%",fontSize:"1.5em",margin:"0.25em 0.625em"};return b("div",{style:{height:"100vh",overflow:"hidden"},children:[b("div",{style:j,children:[b(Cn,{videoRef:o},void 0,!1,{fileName:P,lineNumber:205,columnNumber:9},this),b(Nn,{videoRef:n},void 0,!1,{fileName:P,lineNumber:206,columnNumber:9},this)]},void 0,!0,{fileName:P,lineNumber:204,columnNumber:7},this),b("div",{role:"status",style:{position:"absolute",top:0,width:"100%",paddingTop:"1em",textAlign:"center"},children:S},void 0,!1,{fileName:P,lineNumber:209,columnNumber:7},this),b("div",{style:{display:D?"none":"flex",alignItems:"center",textAlign:"center",justifyContent:"center",height:"100%"},children:b("div",{style:{position:"relative"},children:[b(Dn,{},void 0,!1,{fileName:P,lineNumber:231,columnNumber:11},this),window.calls.getAvatar&&b(Un,{url:window.calls.getAvatar(),style:{position:"absolute",inset:0}},void 0,!1,{fileName:P,lineNumber:233,columnNumber:13},this)]},void 0,!0,{fileName:P,lineNumber:230,columnNumber:9},this)},void 0,!1,{fileName:P,lineNumber:221,columnNumber:7},this),b("div",{style:{position:"absolute",bottom:"0.75em",width:"100%",textAlign:"center"},children:[g!=null&&b(se,{"aria-label":"Answer call",title:"Answer call",onClick:g,className:"acceptCallButton",style:{backgroundColor:"#00b000",...C},children:b(Hn,{},void 0,!1,{fileName:P,lineNumber:259,columnNumber:13},this)},void 0,!1,{fileName:P,lineNumber:249,columnNumber:11},this),b(se,{"aria-label":I,title:I,onClick:()=>c(w=>!w),style:C,children:u?b(Bn,{},void 0,!1,{fileName:P,lineNumber:269,columnNumber:13},this):b(Yn,{},void 0,!1,{fileName:P,lineNumber:271,columnNumber:13},this)},void 0,!1,{fileName:P,lineNumber:262,columnNumber:9},this),k&&b(se,{"aria-label":O,title:O,onClick:()=>a(w=>!w),style:C,children:m?b(Vn,{},void 0,!1,{fileName:P,lineNumber:282,columnNumber:15},this):b(Mn,{},void 0,!1,{fileName:P,lineNumber:284,columnNumber:15},this)},void 0,!1,{fileName:P,lineNumber:275,columnNumber:11},this),b(Pn,{onClick:A,style:C},void 0,!1,{fileName:P,lineNumber:288,columnNumber:9},this)]},void 0,!0,{fileName:P,lineNumber:240,columnNumber:7},this)]},void 0,!0,{fileName:P,lineNumber:203,columnNumber:5},this)}var Jn="/home/adbenitez/projects/deltachat/call/src/index.tsx";Yt(b(Gn,{},void 0,!1,{fileName:Jn,lineNumber:4,columnNumber:8},void 0),document.getElementById("root")); - + - -
From 4185219088735e05c22608eb00b1b0a48f0f5734 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 7 Oct 2025 14:32:18 +0200 Subject: [PATCH 70/76] update calls webapp to v0.9.0-beta --- src/main/assets/calls/index.html | 62 +++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/src/main/assets/calls/index.html b/src/main/assets/calls/index.html index 0830b3cb2..1240d8af6 100644 --- a/src/main/assets/calls/index.html +++ b/src/main/assets/calls/index.html @@ -1,6 +1,6 @@ - + - + + +
From 8f93dacbffdeb359e2f0143b0d21721e7c8588b8 Mon Sep 17 00:00:00 2001 From: adb Date: Wed, 8 Oct 2025 13:40:10 +0000 Subject: [PATCH 71/76] Update src/main/res/xml/preferences_advanced.xml Co-authored-by: bjoern --- src/main/res/xml/preferences_advanced.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/res/xml/preferences_advanced.xml b/src/main/res/xml/preferences_advanced.xml index 8aebc9e4a..6ec084ecd 100644 --- a/src/main/res/xml/preferences_advanced.xml +++ b/src/main/res/xml/preferences_advanced.xml @@ -23,7 +23,7 @@ + android:title="Debug Calls"/> Date: Wed, 8 Oct 2025 13:45:21 +0000 Subject: [PATCH 72/76] Update src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java Co-authored-by: bjoern --- .../securesms/preferences/AdvancedPreferenceFragment.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java index c827220c4..f89dffe50 100644 --- a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java @@ -210,9 +210,9 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment callsEnabled.setOnPreferenceChangeListener((preference, newValue) -> { if ((Boolean)newValue) { new AlertDialog.Builder(requireActivity()) - .setTitle("Thanks for trying out \"Calls\"!") - .setMessage("• You can now call contacts\n\n" - + "• If you want to quit the experimental feature, you can disable it at \"Settings / Advanced\"") + .setTitle("Thanks for helping to debug \"Calls\"!") + .setMessage("• You can now debug calls using the "phone" icon in one-to-one-chats\n\n" + + "• The experiment is about making decentralised calls work and reliable at all, not about options or UI. We're happy about focused feedback at support.delta.chat\n\n") .setCancelable(false) .setPositiveButton(R.string.ok, null) .show(); From 9adc9b34e523933a2c5aec4cf61a153bf4b1e45a Mon Sep 17 00:00:00 2001 From: adbenitez Date: Wed, 8 Oct 2025 15:58:32 +0200 Subject: [PATCH 73/76] fix string --- .../securesms/preferences/AdvancedPreferenceFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java index f89dffe50..e4cebc9ba 100644 --- a/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java @@ -211,7 +211,7 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment if ((Boolean)newValue) { new AlertDialog.Builder(requireActivity()) .setTitle("Thanks for helping to debug \"Calls\"!") - .setMessage("• You can now debug calls using the "phone" icon in one-to-one-chats\n\n" + .setMessage("• You can now debug calls using the \"phone\" icon in one-to-one-chats\n\n" + "• The experiment is about making decentralised calls work and reliable at all, not about options or UI. We're happy about focused feedback at support.delta.chat\n\n") .setCancelable(false) .setPositiveButton(R.string.ok, null) From 6aec209ebc2cb9b34064c6581115986f2dd477c7 Mon Sep 17 00:00:00 2001 From: adb Date: Wed, 8 Oct 2025 14:31:33 +0000 Subject: [PATCH 74/76] Update src/main/res/values/strings.xml Co-authored-by: bjoern --- src/main/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 79aabf8ef..d9e5a2062 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -388,6 +388,7 @@ Declined call Canceled call Missed call + %1$s, %2$s From f9607e445343aa0d0cee329447d4d86db321a5e3 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Wed, 8 Oct 2025 16:45:17 +0200 Subject: [PATCH 75/76] tweak call message-type colors --- .../securesms/components/CallItemView.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/components/CallItemView.java b/src/main/java/org/thoughtcrime/securesms/components/CallItemView.java index d9fdf3136..a66f54790 100644 --- a/src/main/java/org/thoughtcrime/securesms/components/CallItemView.java +++ b/src/main/java/org/thoughtcrime/securesms/components/CallItemView.java @@ -71,22 +71,21 @@ public class CallItemView extends FrameLayout { title.setText(isOutgoing? R.string.outgoing_call : R.string.incoming_call); } + int[] attrs; if (isOutgoing) { - int[] attrs = new int[]{ + attrs = new int[]{ + R.attr.conversation_item_outgoing_text_primary_color, R.attr.conversation_item_outgoing_text_secondary_color, }; - try (TypedArray ta = getContext().obtainStyledAttributes(attrs)) { - footer.setTextColor(ta.getColor(0, Color.BLACK)); - icon.setColorFilter(ta.getColor(0, Color.BLACK)); - } } else { - int[] attrs = new int[]{ + attrs = new int[]{ + R.attr.conversation_item_incoming_text_primary_color, R.attr.conversation_item_incoming_text_secondary_color, }; - try (TypedArray ta = getContext().obtainStyledAttributes(attrs)) { - footer.setTextColor(ta.getColor(0, Color.BLACK)); - } - icon.setColorFilter(getResources().getColor(R.color.delta_accent_darker)); + } + try (TypedArray ta = getContext().obtainStyledAttributes(attrs)) { + icon.setColorFilter(ta.getColor(0, Color.BLACK)); + footer.setTextColor(ta.getColor(1, Color.BLACK)); } } From e586fafc54bebe4b61d39707b9fa8871a5b118c3 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Wed, 8 Oct 2025 16:58:27 +0200 Subject: [PATCH 76/76] tweak call footer's date format --- .../securesms/components/ConversationItemFooter.java | 2 +- src/main/java/org/thoughtcrime/securesms/util/DateUtils.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java b/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java index 11b1b281f..ffc6906ac 100644 --- a/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java +++ b/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java @@ -96,7 +96,7 @@ public class ConversationItemFooter extends LinearLayout { dateView.forceLayout(); Context context = getContext(); String date = dcMsg.getType() == DcMsg.DC_MSG_CALL? - DateUtils.getFormattedCallTime(context, dcMsg.getTimestamp()) + DateUtils.getExtendedTimeSpanString(context, dcMsg.getTimestamp()) : DateUtils.getExtendedRelativeTimeSpanString(context, dcMsg.getTimestamp()); if (callDuration > 0) { String duration = DateUtils.getFormattedCallDuration(context, callDuration); diff --git a/src/main/java/org/thoughtcrime/securesms/util/DateUtils.java b/src/main/java/org/thoughtcrime/securesms/util/DateUtils.java index ed1345792..0a99bf7e1 100644 --- a/src/main/java/org/thoughtcrime/securesms/util/DateUtils.java +++ b/src/main/java/org/thoughtcrime/securesms/util/DateUtils.java @@ -128,10 +128,6 @@ public class DateUtils extends android.text.format.DateUtils { return c.getResources().getQuantityString(R.plurals.n_minutes_ext, mins, mins); } - public static String getFormattedCallTime(final Context c, final long timestamp) { - return getFormattedDateTime(timestamp, DateFormat.is24HourFormat(c)? "HH:mm" : "hh:mm a"); - } - public static String getFormattedTimespan(Context c, int timestamp) { int mins = timestamp / (1000 * 60); if (mins / 60 == 0) {