From 0ea2a2116e444681f80ea3efbc2f4cc1b1728310 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 6 Jul 2022 11:54:07 -0700 Subject: [PATCH 1/5] File Sharing Manager --- lib/cwtch/cwtch.dart | 10 +++++ lib/cwtch/ffi.dart | 39 ++++++++++++++++ lib/cwtch/gomobile.dart | 15 +++++++ lib/l10n/intl_cy.arb | 5 ++- lib/l10n/intl_da.arb | 5 ++- lib/l10n/intl_de.arb | 5 ++- lib/l10n/intl_el.arb | 5 ++- lib/l10n/intl_en.arb | 5 ++- lib/l10n/intl_es.arb | 5 ++- lib/l10n/intl_fr.arb | 5 ++- lib/l10n/intl_it.arb | 5 ++- lib/l10n/intl_lb.arb | 5 ++- lib/l10n/intl_no.arb | 5 ++- lib/l10n/intl_pl.arb | 5 ++- lib/l10n/intl_pt.arb | 5 ++- lib/l10n/intl_ro.arb | 5 ++- lib/l10n/intl_ru.arb | 5 ++- lib/views/filesharingview.dart | 82 ++++++++++++++++++++++++++++++++++ lib/views/messageview.dart | 23 ++++++++++ lib/views/profilemgrview.dart | 5 ++- lib/widgets/filebubble.dart | 2 +- 21 files changed, 229 insertions(+), 17 deletions(-) create mode 100644 lib/views/filesharingview.dart diff --git a/lib/cwtch/cwtch.dart b/lib/cwtch/cwtch.dart index fffc4fc8..e672438a 100644 --- a/lib/cwtch/cwtch.dart +++ b/lib/cwtch/cwtch.dart @@ -59,6 +59,16 @@ abstract class Cwtch { // ignore: non_constant_identifier_names Future ShareFile(String profile, int handle, String filepath); + + // ignore: non_constant_identifier_names + Future GetSharedFiles(String profile, int handle); + + // ignore: non_constant_identifier_names + void RestartSharing(String profile, String filekey); + + // ignore: non_constant_identifier_names + void StopSharing(String profile, String filekey); + // ignore: non_constant_identifier_names void DownloadFile(String profile, int handle, String filepath, String manifestpath, String filekey); // android-only diff --git a/lib/cwtch/ffi.dart b/lib/cwtch/ffi.dart index 758bdbc9..805e33fd 100644 --- a/lib/cwtch/ffi.dart +++ b/lib/cwtch/ffi.dart @@ -68,6 +68,9 @@ typedef GetJsonBlobFromStrIntStrFn = Pointer Function(Pointer, int, typedef get_json_blob_from_str_str_int_function = Pointer Function(Pointer, Int32, Pointer, Int32, Int32); typedef GetJsonBlobFromStrStrIntFn = Pointer Function(Pointer, int, Pointer, int, int); +typedef get_json_blob_from_str_int_function = Pointer Function(Pointer, Int32, Int32); +typedef GetJsonBlobFromStrIntFn = Pointer Function(Pointer, int, int); + typedef get_json_blob_from_str_int_int_function = Pointer Function(Pointer, Int32, Int32, Int32); typedef GetJsonBlobFromStrIntIntFn = Pointer Function(Pointer, int, int, int); @@ -841,4 +844,40 @@ class CwtchFfi implements Cwtch { _UnsafeFreePointerAnyUseOfThisFunctionMustBeDoubleApproved(result); return debugResult; } + + @override + Future GetSharedFiles(String profile, int handle) async { + var getSharedFiles = library.lookup>("c_GetSharedFiles"); + final GetSharedFiles = getSharedFiles.asFunction(); + final utf8profile = profile.toNativeUtf8(); + Pointer jsonMessageBytes = GetSharedFiles(utf8profile, utf8profile.length, handle); + String jsonMessage = jsonMessageBytes.toDartString(); + _UnsafeFreePointerAnyUseOfThisFunctionMustBeDoubleApproved(jsonMessageBytes); + malloc.free(utf8profile); + return jsonMessage; + } + + @override + void RestartSharing(String profile, String filekey) { + var restartSharingC = library.lookup>("c_RestartSharing"); + // ignore: non_constant_identifier_names + final RestartSharing = restartSharingC.asFunction(); + final utf8profile = profile.toNativeUtf8(); + final ut8filekey = filekey.toNativeUtf8(); + RestartSharing(utf8profile, utf8profile.length, ut8filekey, ut8filekey.length); + malloc.free(utf8profile); + malloc.free(ut8filekey); + } + + @override + void StopSharing(String profile, String filekey) { + var stopSharingC = library.lookup>("c_StopSharing"); + // ignore: non_constant_identifier_names + final StopSharing = stopSharingC.asFunction(); + final utf8profile = profile.toNativeUtf8(); + final ut8filekey = filekey.toNativeUtf8(); + StopSharing(utf8profile, utf8profile.length, ut8filekey, ut8filekey.length); + malloc.free(utf8profile); + malloc.free(ut8filekey); + } } diff --git a/lib/cwtch/gomobile.dart b/lib/cwtch/gomobile.dart index b8b678e3..19515e85 100644 --- a/lib/cwtch/gomobile.dart +++ b/lib/cwtch/gomobile.dart @@ -333,4 +333,19 @@ class CwtchGomobile implements Cwtch { // we don't implement it return Future.value("{}"); } + + @override + Future GetSharedFiles(String profile, int handle) { + return cwtchPlatform.invokeMethod("GetSharedFiles", {"ProfileOnion": profile, "conversation": handle}); + } + + @override + void RestartSharing(String profile, String filekey) { + cwtchPlatform.invokeMethod("RestartSharing", {"ProfileOnion": profile, "filekey": filekey}); + } + + @override + void StopSharing(String profile, String filekey) { + cwtchPlatform.invokeMethod("StopSharing", {"ProfileOnion": profile, "filekey": filekey}); + } } diff --git a/lib/l10n/intl_cy.arb b/lib/l10n/intl_cy.arb index b3a010cf..80fcdb37 100644 --- a/lib/l10n/intl_cy.arb +++ b/lib/l10n/intl_cy.arb @@ -1,6 +1,9 @@ { "@@locale": "cy", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Almaeneg \/ Deutsch", "localePt": "Portiwgaleg \/ Portuguesa", "localeRo": "Rwmaneg \/ Română", diff --git a/lib/l10n/intl_da.arb b/lib/l10n/intl_da.arb index e55c42b1..d2c9e9af 100644 --- a/lib/l10n/intl_da.arb +++ b/lib/l10n/intl_da.arb @@ -1,6 +1,9 @@ { "@@locale": "da", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Tysk \/ Deutsch", "localeEn": "Engelsk \/ English", "localeFr": "Fransk \/ Français", diff --git a/lib/l10n/intl_de.arb b/lib/l10n/intl_de.arb index a82c5a0f..17090263 100644 --- a/lib/l10n/intl_de.arb +++ b/lib/l10n/intl_de.arb @@ -1,6 +1,9 @@ { "@@locale": "de", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeEn": "Englisch \/ English", "localePl": "Polnisch \/ Polski", "localeIt": "Italienisch \/ Italiana", diff --git a/lib/l10n/intl_el.arb b/lib/l10n/intl_el.arb index 3df7fdcf..27a108e8 100644 --- a/lib/l10n/intl_el.arb +++ b/lib/l10n/intl_el.arb @@ -1,6 +1,9 @@ { "@@locale": "el", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Γερμανός \/ Deutsch", "localeEn": "English \/ English", "localeLb": "Λουξεμβουργιανά", diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 9396c185..1f3e4da7 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -1,6 +1,9 @@ { "@@locale": "en", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "German \/ Deutsch", "localeEn": "English \/ English", "localeLb": "Luxembourgish \/ Lëtzebuergesch", diff --git a/lib/l10n/intl_es.arb b/lib/l10n/intl_es.arb index 6365b0d4..35227f35 100644 --- a/lib/l10n/intl_es.arb +++ b/lib/l10n/intl_es.arb @@ -1,6 +1,9 @@ { "@@locale": "es", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Alemán \/ Deutsch", "settingImagePreviewsDescription": "Las imágenes se descargarán y visualizarán automáticamente. Ten en cuenta que las previsualizaciones pueden generar vulnerabilidades de seguridad, no deberías habilitar este experimento si usas Cwtch con contactos que no son de confianza. Las imágenes de perfil están planeadas para Cwtch 1.6.", "tooltipBackToMessageEditing": "Volver a Edición de mensajes", diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index b2398448..e77e678d 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -1,6 +1,9 @@ { "@@locale": "fr", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Allemand \/ Deutsch", "localeDa": "Danois \/ Dansk", "localePt": "Portugais \/ Portuguesa", diff --git a/lib/l10n/intl_it.arb b/lib/l10n/intl_it.arb index 05ccaf1d..65630157 100644 --- a/lib/l10n/intl_it.arb +++ b/lib/l10n/intl_it.arb @@ -1,6 +1,9 @@ { "@@locale": "it", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Tedesco \/ Deutsch", "settingImagePreviewsDescription": "Le immagini e le immagini del profilo verranno scaricate e visualizzate in anteprima automaticamente. Ti consigliamo di non abilitare questo esperimento se usi Cwtch con contatti non attendibili.", "localeNo": "Norvegese \/ Norsk", diff --git a/lib/l10n/intl_lb.arb b/lib/l10n/intl_lb.arb index d44a4972..27eb26c0 100644 --- a/lib/l10n/intl_lb.arb +++ b/lib/l10n/intl_lb.arb @@ -1,6 +1,9 @@ { "@@locale": "lb", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Däitsch \/ Deutsch", "localeEn": "Englesch", "localeLb": "Lëtzebuergesch", diff --git a/lib/l10n/intl_no.arb b/lib/l10n/intl_no.arb index d7cd6e5b..3dde1ad9 100644 --- a/lib/l10n/intl_no.arb +++ b/lib/l10n/intl_no.arb @@ -1,6 +1,9 @@ { "@@locale": "no", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Tysk \/ Deutsch", "localeEn": "Engelsk", "localeLb": "Luxemburgsk", diff --git a/lib/l10n/intl_pl.arb b/lib/l10n/intl_pl.arb index b328fe8c..4d2d8ec8 100644 --- a/lib/l10n/intl_pl.arb +++ b/lib/l10n/intl_pl.arb @@ -1,6 +1,9 @@ { "@@locale": "pl", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Niemiecki \/ Deutsch", "serverLabel": "Server", "deleteBtn": "Usuń", diff --git a/lib/l10n/intl_pt.arb b/lib/l10n/intl_pt.arb index d635aa9c..9c6857b9 100644 --- a/lib/l10n/intl_pt.arb +++ b/lib/l10n/intl_pt.arb @@ -1,6 +1,9 @@ { "@@locale": "pt", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Alemao \/ Deutsch", "localeEn": "English \/ English", "localeLb": "Luxembourgish \/ Lëtzebuergesch", diff --git a/lib/l10n/intl_ro.arb b/lib/l10n/intl_ro.arb index cf048b0f..6126bf74 100644 --- a/lib/l10n/intl_ro.arb +++ b/lib/l10n/intl_ro.arb @@ -1,6 +1,9 @@ { "@@locale": "ro", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "localeDe": "Germană", "localeEn": "Engleză", "localeLb": "Luxemburgheză", diff --git a/lib/l10n/intl_ru.arb b/lib/l10n/intl_ru.arb index b89d52d7..6d72fe2e 100644 --- a/lib/l10n/intl_ru.arb +++ b/lib/l10n/intl_ru.arb @@ -1,6 +1,9 @@ { "@@locale": "ru", - "@@last_modified": "2022-07-04T19:42:38+02:00", + "@@last_modified": "2022-07-06T20:42:11+02:00", + "restartFileShare": "Start Sharing File", + "stopSharingFile": "Stop Sharing File", + "manageSharedFiles": "Manage Shared Files", "exportProfile": "Экспорт профиля", "notificationContentContactInfo": "Показать текст сообщения", "notificationContentSimpleEvent": "Без подробностей", diff --git a/lib/views/filesharingview.dart b/lib/views/filesharingview.dart new file mode 100644 index 00000000..e09d5c0c --- /dev/null +++ b/lib/views/filesharingview.dart @@ -0,0 +1,82 @@ +import 'dart:convert'; + +import 'package:cwtch/config.dart'; +import 'package:cwtch/cwtch/cwtch.dart'; +import 'package:cwtch/main.dart'; +import 'package:cwtch/models/appstate.dart'; +import 'package:cwtch/models/contact.dart'; +import 'package:cwtch/models/profile.dart'; +import 'package:cwtch/settings.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; + +import '../cwtch_icons_icons.dart'; + +class FileSharingView extends StatefulWidget { + @override + _FileSharingViewState createState() => _FileSharingViewState(); +} + +class _FileSharingViewState extends State { + @override + Widget build(BuildContext context) { + var handle = Provider.of(context).nickname; + if (handle.isEmpty) { + handle = Provider.of(context).onion; + } + + var profileHandle = Provider.of(context).onion; + + return Scaffold( + appBar: AppBar( + title: Text(handle + " » " + AppLocalizations.of(context)!.manageSharedFiles), + ), + body: FutureBuilder( + future: Provider.of(context, listen: false).cwtch.GetSharedFiles(profileHandle, Provider.of(context).identifier), + builder: (context, snapshot) { + if (snapshot.hasData) { + List sharedFiles = jsonDecode(snapshot.data as String); + sharedFiles.sort((a, b) { + return a["DateShared"].toString().compareTo(b["DateShared"].toString()); + }); + + var fileList = ScrollablePositionedList.separated( + itemScrollController: ItemScrollController(), + itemCount: sharedFiles.length, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + semanticChildCount: sharedFiles.length, + itemBuilder: (context, index) { + String filekey = sharedFiles[index]["FileKey"]; + EnvironmentConfig.debugLog("$sharedFiles " + sharedFiles[index].toString()); + return SwitchListTile( + title: Text(sharedFiles[index]["Path"]), + subtitle: Text(sharedFiles[index]["DateShared"]), + value: sharedFiles[index]["Active"], + activeTrackColor: Provider.of(context).theme.defaultButtonColor, + inactiveTrackColor: Provider.of(context).theme.defaultButtonDisabledColor, + secondary: Icon(CwtchIcons.attach_file_24px, color: Provider.of(context).current().mainTextColor), + onChanged: (newValue) { + setState(() { + if (newValue) { + Provider.of(context, listen: false).cwtch.RestartSharing(profileHandle, filekey); + } else { + Provider.of(context, listen: false).cwtch.StopSharing(profileHandle, filekey); + } + }); + }); + }, + separatorBuilder: (BuildContext context, int index) { + return Divider(height: 1); + }, + ); + return fileList; + } + return Container(); + }, + ), + ); + } +} diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index c548e348..b4991b55 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -32,6 +32,7 @@ import '../constants.dart'; import '../main.dart'; import '../settings.dart'; import '../widgets/messagelist.dart'; +import 'filesharingview.dart'; import 'groupsettingsview.dart'; class MessageView extends StatefulWidget { @@ -97,6 +98,10 @@ class _MessageViewState extends State { var showMessageFormattingPreview = Provider.of(context).isExperimentEnabled(FormattingExperiment); var showFileSharing = Provider.of(context).isExperimentEnabled(FileSharingExperiment); var appBarButtons = []; + + appBarButtons.add( + IconButton(splashRadius: Material.defaultSplashRadius / 2, icon: Icon(Icons.folder_shared), tooltip: AppLocalizations.of(context)!.conversationSettings, onPressed: _pushFileSharingSettings)); + if (Provider.of(context).isOnline()) { if (showFileSharing) { appBarButtons.add(IconButton( @@ -119,6 +124,7 @@ class _MessageViewState extends State { }, )); } + appBarButtons.add(IconButton( splashRadius: Material.defaultSplashRadius / 2, icon: Icon(CwtchIcons.send_invite, size: 24), @@ -200,6 +206,23 @@ class _MessageViewState extends State { return true; } + void _pushFileSharingSettings() { + var profileInfoState = Provider.of(context, listen: false); + var contactInfoState = Provider.of(context, listen: false); + Navigator.of(context).push( + PageRouteBuilder( + pageBuilder: (builderContext, a1, a2) { + return MultiProvider( + providers: [ChangeNotifierProvider.value(value: profileInfoState), ChangeNotifierProvider.value(value: contactInfoState)], + child: FileSharingView(), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); + } + void _pushContactSettings() { var profileInfoState = Provider.of(context, listen: false); var contactInfoState = Provider.of(context, listen: false); diff --git a/lib/views/profilemgrview.dart b/lib/views/profilemgrview.dart index 0c277207..56ef0183 100644 --- a/lib/views/profilemgrview.dart +++ b/lib/views/profilemgrview.dart @@ -249,8 +249,9 @@ class _ProfileMgrViewState extends State { borderRadius: BorderRadius.horizontal(left: Radius.circular(180), right: Radius.circular(180))), primary: Provider.of(context).theme.backgroundMainColor, ), - child: - Text(AppLocalizations.of(context)!.importProfile, semanticsLabel: AppLocalizations.of(context)!.importProfile, style: TextStyle(color: Provider.of(context).theme.mainTextColor, fontWeight: FontWeight.bold)), + child: Text(AppLocalizations.of(context)!.importProfile, + semanticsLabel: AppLocalizations.of(context)!.importProfile, + style: TextStyle(color: Provider.of(context).theme.mainTextColor, fontWeight: FontWeight.bold)), onPressed: () { // 10GB profiles should be enough for anyone? showFilePicker(context, MaxGeneralFileSharingSize, (file) { diff --git a/lib/widgets/filebubble.dart b/lib/widgets/filebubble.dart index b31a5009..323ada54 100644 --- a/lib/widgets/filebubble.dart +++ b/lib/widgets/filebubble.dart @@ -266,7 +266,7 @@ class FileBubbleState extends State { var manifestPath = file.path + ".manifest"; Provider.of(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil()); Provider.of(context, listen: false).cwtch.SetMessageAttribute(profileOnion, conversation, 0, idx, "file-downloaded", "true"); - ContactInfoState? contact = Provider.of(context, listen: false).contactList.findContact(Provider.of(context).senderHandle); + ContactInfoState? contact = Provider.of(context, listen: false).contactList.findContact(Provider.of(context, listen: false).senderHandle); if (contact != null) { Provider.of(context, listen: false).cwtch.DownloadFile(profileOnion, contact.identifier, file.path, manifestPath, widget.fileKey()); } From 60e822cf12ea8fd8727883b88316df9690eaa581 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 6 Jul 2022 12:14:40 -0700 Subject: [PATCH 2/5] Android + Time out Resume Logic so files can be requested again --- lib/models/filedownloadprogress.dart | 2 ++ lib/models/profile.dart | 17 ++++++++++++++++- lib/views/messageview.dart | 6 ++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/models/filedownloadprogress.dart b/lib/models/filedownloadprogress.dart index 0a4394af..9212f379 100644 --- a/lib/models/filedownloadprogress.dart +++ b/lib/models/filedownloadprogress.dart @@ -7,8 +7,10 @@ class FileDownloadProgress { String? downloadedTo; DateTime? timeStart; DateTime? timeEnd; + DateTime? requested; FileDownloadProgress(this.chunksTotal, this.timeStart); + double progress() { return 1.0 * chunksDownloaded / chunksTotal; } diff --git a/lib/models/profile.dart b/lib/models/profile.dart index 9f53286a..f67179cc 100644 --- a/lib/models/profile.dart +++ b/lib/models/profile.dart @@ -291,12 +291,27 @@ class ProfileInfoState extends ChangeNotifier { } bool downloadInterrupted(String fileKey) { - return this._downloads.containsKey(fileKey) && this._downloads[fileKey]!.interrupted; + if (this._downloads.containsKey(fileKey)) { + if (this._downloads[fileKey]!.interrupted) { + return true; + } + + if (this._downloads[fileKey]!.requested != null) { + if (DateTime.now().difference(this._downloads[fileKey]!.requested!) > Duration(minutes: 1)) { + this._downloads[fileKey]!.requested = null; + this._downloads[fileKey]!.interrupted = true; + return true; + } + } + } + + return false; } void downloadMarkResumed(String fileKey) { if (this._downloads.containsKey(fileKey)) { this._downloads[fileKey]!.interrupted = false; + this._downloads[fileKey]!.requested = DateTime.now(); notifyListeners(); } } diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index b4991b55..dc711bf9 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -99,8 +99,10 @@ class _MessageViewState extends State { var showFileSharing = Provider.of(context).isExperimentEnabled(FileSharingExperiment); var appBarButtons = []; - appBarButtons.add( - IconButton(splashRadius: Material.defaultSplashRadius / 2, icon: Icon(Icons.folder_shared), tooltip: AppLocalizations.of(context)!.conversationSettings, onPressed: _pushFileSharingSettings)); + if (showFileSharing) { + appBarButtons.add(IconButton( + splashRadius: Material.defaultSplashRadius / 2, icon: Icon(Icons.folder_shared), tooltip: AppLocalizations.of(context)!.conversationSettings, onPressed: _pushFileSharingSettings)); + } if (Provider.of(context).isOnline()) { if (showFileSharing) { From c397a9cdb7e0807ee3d2523b7430997ec87b4a6f Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 6 Jul 2022 12:24:34 -0700 Subject: [PATCH 3/5] Update File Sharing tooltip --- lib/views/messageview.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index dc711bf9..2d376d66 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -100,8 +100,8 @@ class _MessageViewState extends State { var appBarButtons = []; if (showFileSharing) { - appBarButtons.add(IconButton( - splashRadius: Material.defaultSplashRadius / 2, icon: Icon(Icons.folder_shared), tooltip: AppLocalizations.of(context)!.conversationSettings, onPressed: _pushFileSharingSettings)); + appBarButtons.add( + IconButton(splashRadius: Material.defaultSplashRadius / 2, icon: Icon(Icons.folder_shared), tooltip: AppLocalizations.of(context)!.manageSharedFiles, onPressed: _pushFileSharingSettings)); } if (Provider.of(context).isOnline()) { From e13ad5d218b38e0c935d513d7ceb41474a3f237d Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 6 Jul 2022 13:11:49 -0700 Subject: [PATCH 4/5] Update lcg --- LIBCWTCH-GO-MACOS.version | 2 +- LIBCWTCH-GO.version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LIBCWTCH-GO-MACOS.version b/LIBCWTCH-GO-MACOS.version index 9950f960..8e8a8f96 100644 --- a/LIBCWTCH-GO-MACOS.version +++ b/LIBCWTCH-GO-MACOS.version @@ -1 +1 @@ -2022-06-27-15-00-v1.8.0 \ No newline at end of file +2022-07-06-15-49-v1.8.0-4-g4417347 \ No newline at end of file diff --git a/LIBCWTCH-GO.version b/LIBCWTCH-GO.version index 7cc814d4..31577150 100644 --- a/LIBCWTCH-GO.version +++ b/LIBCWTCH-GO.version @@ -1 +1 @@ -2022-06-27-19-01-v1.8.0 \ No newline at end of file +2022-07-06-19-50-v1.8.0-4-g4417347 \ No newline at end of file From 5be25b87c44eee154e062d936b6f06439261601d Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 6 Jul 2022 13:57:35 -0700 Subject: [PATCH 5/5] Android --- .../kotlin/im/cwtch/flwtch/MainActivity.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt index 304c704e..d8f50e2b 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt @@ -313,6 +313,7 @@ class MainActivity: FlutterActivity() { result.success(Cwtch.sendInvitation(profile, conversation.toLong(), target.toLong())) return } + "ShareFile" -> { val profile: String = call.argument("ProfileOnion") ?: "" val conversation: Int = call.argument("conversation") ?: 0 @@ -321,6 +322,27 @@ class MainActivity: FlutterActivity() { return } + "GetSharedFiles" -> { + val profile: String = call.argument("ProfileOnion") ?: "" + val conversation: Int = call.argument("conversation") ?: 0 + result.success(Cwtch.getSharedFiles(profile, conversation.toLong())) + return + } + + "RestartSharing" -> { + val profile: String = call.argument("ProfileOnion") ?: "" + val filepath: String = call.argument("filekey") ?: "" + result.success(Cwtch.restartSharing(profile, filepath)) + return + } + + "StopSharing" -> { + val profile: String = call.argument("ProfileOnion") ?: "" + val filepath: String = call.argument("filekey") ?: "" + result.success(Cwtch.stopSharing(profile, filepath)) + return + } + "CreateProfile" -> { val nick: String = call.argument("nick") ?: "" val pass: String = call.argument("pass") ?: ""