fixing warnings
This commit is contained in:
parent
20d3d2458f
commit
18e7f5cccd
|
@ -1,18 +1,32 @@
|
|||
abstract class Cwtch {
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<void> Start();
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
void SelectProfile(String onion);
|
||||
// ignore: non_constant_identifier_names
|
||||
void CreateProfile(String nick, String pass);
|
||||
// ignore: non_constant_identifier_names
|
||||
void LoadProfiles(String pass);
|
||||
// ignore: non_constant_identifier_names
|
||||
void SendProfileEvent(String onion, String jsonEvent);
|
||||
// ignore: non_constant_identifier_names
|
||||
void SendAppEvent(String jsonEvent);
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> ACNEvents();
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> ContactEvents();
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> GetProfiles();
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<int> NumMessages(String profile, String handle);
|
||||
// ignore: non_constant_identifier_names
|
||||
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);
|
||||
|
||||
void dispose();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../model.dart';
|
||||
import '../settings.dart';
|
||||
|
||||
|
|
|
@ -2,14 +2,12 @@ import 'dart:convert';
|
|||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_app/cwtch/cwtchNotifier.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter_app/cwtch/cwtch.dart';
|
||||
|
||||
import '../model.dart';
|
||||
|
||||
/////////////////////
|
||||
/// Cwtch API ///
|
||||
|
@ -55,12 +53,14 @@ class CwtchFfi implements Cwtch {
|
|||
DynamicLibrary library;
|
||||
CwtchNotifier cwtchNotifier;
|
||||
Isolate cwtchIsolate;
|
||||
ReceivePort rp;
|
||||
|
||||
CwtchFfi(CwtchNotifier _cwtchNotifier) {
|
||||
library = DynamicLibrary.open("libCwtch.so");
|
||||
cwtchNotifier = _cwtchNotifier;
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<void> Start() async {
|
||||
String home = "";
|
||||
Map<String, String> envVars = Platform.environment;
|
||||
|
@ -80,9 +80,10 @@ class CwtchFfi implements Cwtch {
|
|||
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
|
||||
var _receivePort = ReceivePort();
|
||||
cwtchIsolate = await Isolate.spawn(_checkAppbusEvents, _receivePort.sendPort);
|
||||
_receivePort.listen((message) {
|
||||
//var _receivePort = ReceivePort();
|
||||
rp = ReceivePort();
|
||||
cwtchIsolate = await Isolate.spawn(_checkAppbusEvents, rp.sendPort);//_receivePort.sendPort);
|
||||
/*_receivePort*/rp.listen((message) {
|
||||
var env = jsonDecode(message);
|
||||
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
|
||||
@override
|
||||
void dispose() {
|
||||
if (rp != null) {
|
||||
rp.close();
|
||||
}
|
||||
|
||||
if (cwtchIsolate != null) {
|
||||
cwtchIsolate.kill();
|
||||
cwtchIsolate.kill(priority: Isolate.immediate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,6 +105,7 @@ class CwtchFfi implements Cwtch {
|
|||
static void _checkAppbusEvents(SendPort sendPort) async {
|
||||
var stream = pollAppbusEvents();
|
||||
await for (var value in stream) {
|
||||
print("_checkAppbusEvent: " + value);
|
||||
sendPort.send(value);
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +114,7 @@ class CwtchFfi implements Cwtch {
|
|||
static Stream<String> pollAppbusEvents() async* {
|
||||
var library = DynamicLibrary.open("libCwtch.so");
|
||||
var getAppbusEventC = library.lookup<NativeFunction<acn_events_function>>("c_GetAppBusEvent");
|
||||
// ignore: non_constant_identifier_names
|
||||
final GetAppbusEvent = getAppbusEventC.asFunction<ACNEventsFn>();
|
||||
|
||||
while (true) {
|
||||
|
@ -145,6 +152,7 @@ class CwtchFfi implements Cwtch {
|
|||
LoadProfiles(ut8pass, ut8pass.length);
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> ACNEvents() async {
|
||||
var acnEventsC = library.lookup<NativeFunction<acn_events_function>>("c_ACNEvents");
|
||||
// ignore: non_constant_identifier_names
|
||||
|
@ -155,6 +163,7 @@ class CwtchFfi implements Cwtch {
|
|||
return event;
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> ContactEvents() async {
|
||||
var acnEventsC = library.lookup<NativeFunction<acn_events_function>>("c_ContactEvents");
|
||||
// ignore: non_constant_identifier_names
|
||||
|
@ -165,6 +174,7 @@ class CwtchFfi implements Cwtch {
|
|||
return event;
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> GetProfiles() async {
|
||||
var getProfilesC = library.lookup<NativeFunction<get_json_blob_void_function>>("c_GetProfiles");
|
||||
// ignore: non_constant_identifier_names
|
||||
|
@ -175,6 +185,7 @@ class CwtchFfi implements Cwtch {
|
|||
return jsonProfiles;
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<int> NumMessages(String profile, String handle) async {
|
||||
var numMessagesC = library.lookup<NativeFunction<get_int_from_str_str_function>>("c_NumMessages");
|
||||
// ignore: non_constant_identifier_names
|
||||
|
@ -185,6 +196,7 @@ class CwtchFfi implements Cwtch {
|
|||
return num;
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
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");
|
||||
// ignore: non_constant_identifier_names
|
||||
|
@ -196,6 +208,7 @@ class CwtchFfi implements Cwtch {
|
|||
return jsonMessage;
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
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");
|
||||
// ignore: non_constant_identifier_names
|
||||
|
@ -208,6 +221,7 @@ class CwtchFfi implements Cwtch {
|
|||
}
|
||||
|
||||
@override
|
||||
// ignore: non_constant_identifier_names
|
||||
void SendProfileEvent(String onion, String json) {
|
||||
var sendAppBusEvent = library.lookup<NativeFunction<string_string_to_void_function>>("c_SendProfileEvent");
|
||||
// ignore: non_constant_identifier_names
|
||||
|
@ -218,6 +232,7 @@ class CwtchFfi implements Cwtch {
|
|||
}
|
||||
|
||||
@override
|
||||
// ignore: non_constant_identifier_names
|
||||
void SendAppEvent(String json) {
|
||||
var sendAppBusEvent = library.lookup<NativeFunction<string_to_void_function>>("c_SendAppEvent");
|
||||
// ignore: non_constant_identifier_names
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:convert';
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_app/model.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'dart:async';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
@ -42,6 +41,7 @@ class CwtchGomobile implements Cwtch {
|
|||
appbusEventChannel.setMethodCallHandler(this._handleAppbusEvent);
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<void> Start() async {
|
||||
print("gomobile.dart: Start()...");
|
||||
var cwtchDir = path.join((await androidHomeDirectory).path, ".cwtch/dev/");
|
||||
|
@ -57,51 +57,65 @@ class CwtchGomobile implements Cwtch {
|
|||
cwtchNotifier.handleMessage(call.method, obj);
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
void SelectProfile(String onion) {
|
||||
cwtchPlatform.invokeMethod("SelectProfile", {"profile": onion});
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
void CreateProfile(String nick, String pass) {
|
||||
cwtchPlatform.invokeMethod("CreateProfile", {"nick": nick, "pass": pass});
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
void LoadProfiles(String pass) {
|
||||
cwtchPlatform.invokeMethod("LoadProfiles", {"pass": pass});
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> ACNEvents() {
|
||||
return cwtchPlatform.invokeMethod("ACNEvents");
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> ContactEvents() {
|
||||
return cwtchPlatform.invokeMethod("ContactEvents");
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> GetProfiles() {
|
||||
print("gomobile.dart: GetProfiles()");
|
||||
return cwtchPlatform.invokeMethod("GetProfiles");
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<int> NumMessages(String profile, String handle) {
|
||||
return cwtchPlatform.invokeMethod("NumMessages", {"profile": profile, "contact": handle});
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
Future<String> GetMessage(String profile, String handle, int index) {
|
||||
print("gomobile.dart GetMessage " + index.toString());
|
||||
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) {
|
||||
return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "start": start, "end": end});
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: non_constant_identifier_names
|
||||
void SendProfileEvent(String onion, String jsonEvent) {
|
||||
cwtchPlatform.invokeMethod("SendProfileEvent", {"onion": onion, "jsonEvent": jsonEvent});
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: non_constant_identifier_names
|
||||
void SendAppEvent(String jsonEvent) {
|
||||
cwtchPlatform.invokeMethod("SendAppEvent", {"jsonEvent": jsonEvent});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() => {};
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ class FlwtchState extends State<Flwtch> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
appStatus = AppModel(cwtch: cwtch);
|
||||
//appStatus = AppModel(cwtch: cwtch);
|
||||
|
||||
return MultiProvider(
|
||||
providers: [getFlwtchStateProvider(), getProfileListProvider(), getSettingsProvider()],
|
||||
|
@ -127,4 +127,10 @@ class FlwtchState extends State<Flwtch> {
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
cwtch.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,6 +217,12 @@ class ContactInfoState extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
get isGroup => this._isGroup;
|
||||
set isGroup(bool newVal) {
|
||||
this._isGroup = newVal;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
get isBlocked => this._isBlocked;
|
||||
set isBlocked(bool newVal) {
|
||||
this._isBlocked = newVal;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_app/opaque.dart';
|
||||
|
|
|
@ -57,7 +57,7 @@ class _MessageViewState extends State<MessageView> {
|
|||
}
|
||||
|
||||
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));
|
||||
ctrlrCompose.clear();
|
||||
}
|
||||
|
@ -81,8 +81,8 @@ class _MessageViewState extends State<MessageView> {
|
|||
onPressed: _sendMessage,
|
||||
),
|
||||
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.attach_file, 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()), onPressed: placeHolder,)),
|
||||
])
|
||||
]),
|
||||
),
|
||||
|
@ -90,4 +90,6 @@ class _MessageViewState extends State<MessageView> {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
void placeHolder() => {};
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_app/model.dart';
|
||||
import 'package:flutter_app/widgets/buttontextfield.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_app/opaque.dart';
|
||||
import 'package:flutter_app/settings.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
|
|
Loading…
Reference in New Issue