fixing warnings

This commit is contained in:
erinn 2021-03-23 15:42:10 -07:00
parent 20d3d2458f
commit 18e7f5cccd
11 changed files with 72 additions and 18 deletions

View File

@ -1,18 +1,32 @@
abstract class Cwtch { abstract class Cwtch {
// ignore: non_constant_identifier_names
Future<void> Start(); Future<void> Start();
// ignore: non_constant_identifier_names
void SelectProfile(String onion); void SelectProfile(String onion);
// ignore: non_constant_identifier_names
void CreateProfile(String nick, String pass); void CreateProfile(String nick, String pass);
// ignore: non_constant_identifier_names
void LoadProfiles(String pass); void LoadProfiles(String pass);
// ignore: non_constant_identifier_names
void SendProfileEvent(String onion, String jsonEvent); void SendProfileEvent(String onion, String jsonEvent);
// ignore: non_constant_identifier_names
void SendAppEvent(String jsonEvent); void SendAppEvent(String jsonEvent);
// ignore: non_constant_identifier_names
Future<String> ACNEvents(); Future<String> ACNEvents();
// ignore: non_constant_identifier_names
Future<String> ContactEvents(); Future<String> ContactEvents();
// ignore: non_constant_identifier_names
Future<String> GetProfiles(); Future<String> GetProfiles();
// ignore: non_constant_identifier_names
Future<int> NumMessages(String profile, String handle); Future<int> NumMessages(String profile, String handle);
// ignore: non_constant_identifier_names
Future<String> GetMessage(String profile, String handle, int index); Future<String> GetMessage(String profile, String handle, int index);
// ignore: non_constant_identifier_names
Future<String> GetMessages(String profile, String handle, int start, int end); Future<String> GetMessages(String profile, String handle, int start, int end);
void dispose();
} }

View File

@ -1,8 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'package:provider/provider.dart';
import 'package:provider/provider.dart';
import '../model.dart'; import '../model.dart';
import '../settings.dart'; import '../settings.dart';

View File

@ -2,14 +2,12 @@ import 'dart:convert';
import 'dart:ffi'; import 'dart:ffi';
import 'dart:io'; import 'dart:io';
import 'dart:isolate'; import 'dart:isolate';
import 'package:flutter/rendering.dart';
import 'package:flutter_app/cwtch/cwtchNotifier.dart'; import 'package:flutter_app/cwtch/cwtchNotifier.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:ffi/ffi.dart'; import 'package:ffi/ffi.dart';
import 'package:flutter_app/cwtch/cwtch.dart'; import 'package:flutter_app/cwtch/cwtch.dart';
import '../model.dart';
///////////////////// /////////////////////
/// Cwtch API /// /// Cwtch API ///
@ -55,12 +53,14 @@ class CwtchFfi implements Cwtch {
DynamicLibrary library; DynamicLibrary library;
CwtchNotifier cwtchNotifier; CwtchNotifier cwtchNotifier;
Isolate cwtchIsolate; Isolate cwtchIsolate;
ReceivePort rp;
CwtchFfi(CwtchNotifier _cwtchNotifier) { CwtchFfi(CwtchNotifier _cwtchNotifier) {
library = DynamicLibrary.open("libCwtch.so"); library = DynamicLibrary.open("libCwtch.so");
cwtchNotifier = _cwtchNotifier; cwtchNotifier = _cwtchNotifier;
} }
// ignore: non_constant_identifier_names
Future<void> Start() async { Future<void> Start() async {
String home = ""; String home = "";
Map<String, String> envVars = Platform.environment; Map<String, String> envVars = Platform.environment;
@ -80,9 +80,10 @@ class CwtchFfi implements Cwtch {
StartCwtch(ut8CwtchDir, ut8CwtchDir.length, "".toNativeUtf8(), 0); StartCwtch(ut8CwtchDir, ut8CwtchDir.length, "".toNativeUtf8(), 0);
// Spawn an isolate to listen to events from libcwtch-go and then dispatch them when received on main thread to cwtchNotifier // Spawn an isolate to listen to events from libcwtch-go and then dispatch them when received on main thread to cwtchNotifier
var _receivePort = ReceivePort(); //var _receivePort = ReceivePort();
cwtchIsolate = await Isolate.spawn(_checkAppbusEvents, _receivePort.sendPort); rp = ReceivePort();
_receivePort.listen((message) { cwtchIsolate = await Isolate.spawn(_checkAppbusEvents, rp.sendPort);//_receivePort.sendPort);
/*_receivePort*/rp.listen((message) {
var env = jsonDecode(message); var env = jsonDecode(message);
cwtchNotifier.handleMessage(env["EventType"], env["Data"]); cwtchNotifier.handleMessage(env["EventType"], env["Data"]);
}); });
@ -91,8 +92,12 @@ class CwtchFfi implements Cwtch {
// Called on object being disposed to (presumably on app close) to close the isolate that's listening to libcwtch-go events // Called on object being disposed to (presumably on app close) to close the isolate that's listening to libcwtch-go events
@override @override
void dispose() { void dispose() {
if (rp != null) {
rp.close();
}
if (cwtchIsolate != null) { if (cwtchIsolate != null) {
cwtchIsolate.kill(); cwtchIsolate.kill(priority: Isolate.immediate);
} }
} }
@ -100,6 +105,7 @@ class CwtchFfi implements Cwtch {
static void _checkAppbusEvents(SendPort sendPort) async { static void _checkAppbusEvents(SendPort sendPort) async {
var stream = pollAppbusEvents(); var stream = pollAppbusEvents();
await for (var value in stream) { await for (var value in stream) {
print("_checkAppbusEvent: " + value);
sendPort.send(value); sendPort.send(value);
} }
} }
@ -108,6 +114,7 @@ class CwtchFfi implements Cwtch {
static Stream<String> pollAppbusEvents() async* { static Stream<String> pollAppbusEvents() async* {
var library = DynamicLibrary.open("libCwtch.so"); var library = DynamicLibrary.open("libCwtch.so");
var getAppbusEventC = library.lookup<NativeFunction<acn_events_function>>("c_GetAppBusEvent"); var getAppbusEventC = library.lookup<NativeFunction<acn_events_function>>("c_GetAppBusEvent");
// ignore: non_constant_identifier_names
final GetAppbusEvent = getAppbusEventC.asFunction<ACNEventsFn>(); final GetAppbusEvent = getAppbusEventC.asFunction<ACNEventsFn>();
while (true) { while (true) {
@ -145,6 +152,7 @@ class CwtchFfi implements Cwtch {
LoadProfiles(ut8pass, ut8pass.length); LoadProfiles(ut8pass, ut8pass.length);
} }
// ignore: non_constant_identifier_names
Future<String> ACNEvents() async { Future<String> ACNEvents() async {
var acnEventsC = library.lookup<NativeFunction<acn_events_function>>("c_ACNEvents"); var acnEventsC = library.lookup<NativeFunction<acn_events_function>>("c_ACNEvents");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
@ -155,6 +163,7 @@ class CwtchFfi implements Cwtch {
return event; return event;
} }
// ignore: non_constant_identifier_names
Future<String> ContactEvents() async { Future<String> ContactEvents() async {
var acnEventsC = library.lookup<NativeFunction<acn_events_function>>("c_ContactEvents"); var acnEventsC = library.lookup<NativeFunction<acn_events_function>>("c_ContactEvents");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
@ -165,6 +174,7 @@ class CwtchFfi implements Cwtch {
return event; return event;
} }
// ignore: non_constant_identifier_names
Future<String> GetProfiles() async { Future<String> GetProfiles() async {
var getProfilesC = library.lookup<NativeFunction<get_json_blob_void_function>>("c_GetProfiles"); var getProfilesC = library.lookup<NativeFunction<get_json_blob_void_function>>("c_GetProfiles");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
@ -175,6 +185,7 @@ class CwtchFfi implements Cwtch {
return jsonProfiles; return jsonProfiles;
} }
// ignore: non_constant_identifier_names
Future<int> NumMessages(String profile, String handle) async { Future<int> NumMessages(String profile, String handle) async {
var numMessagesC = library.lookup<NativeFunction<get_int_from_str_str_function>>("c_NumMessages"); var numMessagesC = library.lookup<NativeFunction<get_int_from_str_str_function>>("c_NumMessages");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
@ -185,6 +196,7 @@ class CwtchFfi implements Cwtch {
return num; return num;
} }
// ignore: non_constant_identifier_names
Future<String> GetMessage(String profile, String handle, int index) async { Future<String> GetMessage(String profile, String handle, int index) async {
var getMessageC = library.lookup<NativeFunction<get_json_blob_from_str_str_int_function>>("c_GetMessage"); var getMessageC = library.lookup<NativeFunction<get_json_blob_from_str_str_int_function>>("c_GetMessage");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
@ -196,6 +208,7 @@ class CwtchFfi implements Cwtch {
return jsonMessage; return jsonMessage;
} }
// ignore: non_constant_identifier_names
Future<String> GetMessages(String profile, String handle, int start, int end) async { Future<String> GetMessages(String profile, String handle, int start, int end) async {
var getMessagesC = library.lookup<NativeFunction<get_json_blob_from_str_str_int_int_function>>("c_GetMessages"); var getMessagesC = library.lookup<NativeFunction<get_json_blob_from_str_str_int_int_function>>("c_GetMessages");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
@ -208,6 +221,7 @@ class CwtchFfi implements Cwtch {
} }
@override @override
// ignore: non_constant_identifier_names
void SendProfileEvent(String onion, String json) { void SendProfileEvent(String onion, String json) {
var sendAppBusEvent = library.lookup<NativeFunction<string_string_to_void_function>>("c_SendProfileEvent"); var sendAppBusEvent = library.lookup<NativeFunction<string_string_to_void_function>>("c_SendProfileEvent");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
@ -218,6 +232,7 @@ class CwtchFfi implements Cwtch {
} }
@override @override
// ignore: non_constant_identifier_names
void SendAppEvent(String json) { void SendAppEvent(String json) {
var sendAppBusEvent = library.lookup<NativeFunction<string_to_void_function>>("c_SendAppEvent"); var sendAppBusEvent = library.lookup<NativeFunction<string_to_void_function>>("c_SendAppEvent");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names

View File

@ -2,7 +2,6 @@ import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_app/model.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'dart:async'; import 'dart:async';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
@ -42,6 +41,7 @@ class CwtchGomobile implements Cwtch {
appbusEventChannel.setMethodCallHandler(this._handleAppbusEvent); appbusEventChannel.setMethodCallHandler(this._handleAppbusEvent);
} }
// ignore: non_constant_identifier_names
Future<void> Start() async { Future<void> Start() async {
print("gomobile.dart: Start()..."); print("gomobile.dart: Start()...");
var cwtchDir = path.join((await androidHomeDirectory).path, ".cwtch/dev/"); var cwtchDir = path.join((await androidHomeDirectory).path, ".cwtch/dev/");
@ -57,51 +57,65 @@ class CwtchGomobile implements Cwtch {
cwtchNotifier.handleMessage(call.method, obj); cwtchNotifier.handleMessage(call.method, obj);
} }
// ignore: non_constant_identifier_names
void SelectProfile(String onion) { void SelectProfile(String onion) {
cwtchPlatform.invokeMethod("SelectProfile", {"profile": onion}); cwtchPlatform.invokeMethod("SelectProfile", {"profile": onion});
} }
// ignore: non_constant_identifier_names
void CreateProfile(String nick, String pass) { void CreateProfile(String nick, String pass) {
cwtchPlatform.invokeMethod("CreateProfile", {"nick": nick, "pass": pass}); cwtchPlatform.invokeMethod("CreateProfile", {"nick": nick, "pass": pass});
} }
// ignore: non_constant_identifier_names
void LoadProfiles(String pass) { void LoadProfiles(String pass) {
cwtchPlatform.invokeMethod("LoadProfiles", {"pass": pass}); cwtchPlatform.invokeMethod("LoadProfiles", {"pass": pass});
} }
// ignore: non_constant_identifier_names
Future<String> ACNEvents() { Future<String> ACNEvents() {
return cwtchPlatform.invokeMethod("ACNEvents"); return cwtchPlatform.invokeMethod("ACNEvents");
} }
// ignore: non_constant_identifier_names
Future<String> ContactEvents() { Future<String> ContactEvents() {
return cwtchPlatform.invokeMethod("ContactEvents"); return cwtchPlatform.invokeMethod("ContactEvents");
} }
// ignore: non_constant_identifier_names
Future<String> GetProfiles() { Future<String> GetProfiles() {
print("gomobile.dart: GetProfiles()"); print("gomobile.dart: GetProfiles()");
return cwtchPlatform.invokeMethod("GetProfiles"); return cwtchPlatform.invokeMethod("GetProfiles");
} }
// ignore: non_constant_identifier_names
Future<int> NumMessages(String profile, String handle) { Future<int> NumMessages(String profile, String handle) {
return cwtchPlatform.invokeMethod("NumMessages", {"profile": profile, "contact": handle}); return cwtchPlatform.invokeMethod("NumMessages", {"profile": profile, "contact": handle});
} }
// ignore: non_constant_identifier_names
Future<String> GetMessage(String profile, String handle, int index) { Future<String> GetMessage(String profile, String handle, int index) {
print("gomobile.dart GetMessage " + index.toString()); print("gomobile.dart GetMessage " + index.toString());
return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "index": index}); return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "index": index});
} }
// ignore: non_constant_identifier_names
Future<String> GetMessages(String profile, String handle, int start, int end) { Future<String> GetMessages(String profile, String handle, int start, int end) {
return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "start": start, "end": end}); return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "start": start, "end": end});
} }
@override @override
// ignore: non_constant_identifier_names
void SendProfileEvent(String onion, String jsonEvent) { void SendProfileEvent(String onion, String jsonEvent) {
cwtchPlatform.invokeMethod("SendProfileEvent", {"onion": onion, "jsonEvent": jsonEvent}); cwtchPlatform.invokeMethod("SendProfileEvent", {"onion": onion, "jsonEvent": jsonEvent});
} }
@override @override
// ignore: non_constant_identifier_names
void SendAppEvent(String jsonEvent) { void SendAppEvent(String jsonEvent) {
cwtchPlatform.invokeMethod("SendAppEvent", {"jsonEvent": jsonEvent}); cwtchPlatform.invokeMethod("SendAppEvent", {"jsonEvent": jsonEvent});
} }
@override
void dispose() => {};
} }

View File

@ -69,7 +69,7 @@ class FlwtchState extends State<Flwtch> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
appStatus = AppModel(cwtch: cwtch); //appStatus = AppModel(cwtch: cwtch);
return MultiProvider( return MultiProvider(
providers: [getFlwtchStateProvider(), getProfileListProvider(), getSettingsProvider()], providers: [getFlwtchStateProvider(), getProfileListProvider(), getSettingsProvider()],
@ -127,4 +127,10 @@ class FlwtchState extends State<Flwtch> {
}, },
); );
} }
@override
void dispose() {
cwtch.dispose();
super.dispose();
}
} }

View File

@ -217,6 +217,12 @@ class ContactInfoState extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
get isGroup => this._isGroup;
set isGroup(bool newVal) {
this._isGroup = newVal;
notifyListeners();
}
get isBlocked => this._isBlocked; get isBlocked => this._isBlocked;
set isBlocked(bool newVal) { set isBlocked(bool newVal) {
this._isBlocked = newVal; this._isBlocked = newVal;

View File

@ -1,5 +1,4 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_app/opaque.dart'; import 'package:flutter_app/opaque.dart';

View File

@ -57,7 +57,7 @@ class _MessageViewState extends State<MessageView> {
} }
void _sendMessage() { void _sendMessage() {
ChatMessage cm = new ChatMessage(o: 1, d: ctrlrCompose.value.text); //ChatMessage cm = new ChatMessage(o: 1, d: ctrlrCompose.value.text);
//todo: merge: Provider.of<FlwtchState>(context).cwtch.SendMessage(widget.profile.onion, widget.conversationHandle, jsonEncode(cm)); //todo: merge: Provider.of<FlwtchState>(context).cwtch.SendMessage(widget.profile.onion, widget.conversationHandle, jsonEncode(cm));
ctrlrCompose.clear(); ctrlrCompose.clear();
} }
@ -81,8 +81,8 @@ class _MessageViewState extends State<MessageView> {
onPressed: _sendMessage, onPressed: _sendMessage,
), ),
Row(children: <Widget>[ Row(children: <Widget>[
SizedBox(width: 45, child: ElevatedButton(child: Icon(Icons.emoji_emotions_outlined, color: Opaque.current().mainTextColor()))), SizedBox(width: 45, child: ElevatedButton(child: Icon(Icons.emoji_emotions_outlined, color: Opaque.current().mainTextColor()), onPressed: placeHolder,)),
SizedBox(width: 45, child: ElevatedButton(child: Icon(Icons.attach_file, color: Opaque.current().mainTextColor()))), SizedBox(width: 45, child: ElevatedButton(child: Icon(Icons.attach_file, color: Opaque.current().mainTextColor()), onPressed: placeHolder,)),
]) ])
]), ]),
), ),
@ -90,4 +90,6 @@ class _MessageViewState extends State<MessageView> {
), ),
); );
} }
void placeHolder() => {};
} }

View File

@ -1,12 +1,9 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_app/model.dart'; import 'package:flutter_app/model.dart';
import 'package:flutter_app/widgets/buttontextfield.dart'; import 'package:flutter_app/widgets/buttontextfield.dart';
import 'package:flutter_app/widgets/cwtchlabel.dart'; import 'package:flutter_app/widgets/cwtchlabel.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_app/opaque.dart';
import 'package:flutter_app/settings.dart'; import 'package:flutter_app/settings.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';

View File

@ -2,6 +2,8 @@
// Generated file. Do not edit. // Generated file. Do not edit.
// //
// clang-format off
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"

View File

@ -2,6 +2,8 @@
// Generated file. Do not edit. // Generated file. Do not edit.
// //
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_ #ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_ #define GENERATED_PLUGIN_REGISTRANT_