Skip to content

Commit

Permalink
Merge pull request #205 from CyBear-Jinni/Changing_grpc
Browse files Browse the repository at this point in the history
Changing grpc
  • Loading branch information
guyluz11 authored Feb 5, 2024
2 parents 030fb45 + c51fcaa commit 0321486
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 111 deletions.
2 changes: 1 addition & 1 deletion bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main(List<String> arguments) async {

try {
// configureNetworkTools('network_tools_db');
SystemCommandsManager();
// setInstanceForDartNative();
SharedVariables()
.asyncConstructor(arguments.firstOrNull ?? Directory.current.path);
} catch (error) {
Expand Down
5 changes: 1 addition & 4 deletions lib/application/usecases/core_u/smart_device_manager_u.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import 'package:cbj_smart_device/application/usecases/local_db_u/local_db_u.dart
import 'package:cbj_smart_device/application/usecases/set_devices_u/set_devices_u.dart';
import 'package:cbj_smart_device/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base_abstract.dart';
import 'package:cbj_smart_device/application/usecases/smart_server_u/smart_server_u.dart';
import 'package:cbj_smart_device/core/helper_methods.dart';

import 'package:cbj_smart_device/core/my_singleton.dart';
import 'package:cbj_smart_device/infrastructure/datasources/accounts_information_d/accounts_information_d.dart';
import 'package:cbj_smart_device/utils.dart';

class SmartDeviceManagerU {
SmartDeviceManagerU() {
Expand All @@ -31,8 +30,6 @@ class SmartDeviceManagerU {
/// Setting up all the device from the memory
_setDevicesUseCase.setAllDevices(deviceList: smartDeviceFromDb);

logger.i('Entity local IP: ${await getIps()}');

/// Start listen for in incoming connections from the local internet (LAN/Wifi)
_smartServerUseCase.waitForConnection(firebaseAccountsInformationD);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import 'package:cbj_smart_device/application/usecases/smart_device_objects_u/abs
import 'package:cbj_smart_device/application/usecases/wish_classes_u/off_wish_u.dart';
import 'package:cbj_smart_device/application/usecases/wish_classes_u/on_wish_u.dart';
import 'package:cbj_smart_device/application/usecases/wish_classes_u/smart_computer_wish_u.dart';
import 'package:cbj_smart_device/core/helper_methods.dart';
import 'package:cbj_smart_device/domain/entities/core_e/enums_e.dart';
import 'package:cbj_smart_device/infrastructure/repositories/smart_device_objects_r/smart_device_objects_r.dart';
import 'package:cbj_smart_device/utils.dart';

/// Abstract class for smart devices that can get actions from commands.
Expand Down Expand Up @@ -55,12 +53,6 @@ abstract class SmartDeviceBase extends SmartDeviceBaseAbstract {
);
}

/// Getting the saved IP of this object
@override
Future<String?> getIp() async {
return getIps();
}

/// Get the list of gpio pin of the device
@override
List<PinInformation> getGpioPinList() {
Expand All @@ -69,7 +61,7 @@ abstract class SmartDeviceBase extends SmartDeviceBaseAbstract {

@override
Future<String> getUuid() {
return SmartDeviceObjectsR.getUuid();
return SystemCommandsBaseClassD.instance.getUuidOfCurrentDevice();
}

bool getDeviceState() => onOff;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'package:cbj_integrations_controller/integrations_controller.dart';
import 'package:cbj_smart_device/application/usecases/devices_pin_configuration_u/pin_information.dart';
import 'package:cbj_smart_device/core/device_information.dart';
import 'package:cbj_smart_device/core/helper_methods.dart';
import 'package:cbj_smart_device/core/permissions/permissions_manager.dart';
import 'package:cbj_smart_device/domain/entities/core_e/enums_e.dart';
import 'package:cbj_smart_device/infrastructure/repositories/smart_device_objects_r/smart_device_objects_r.dart';

/// The super base class of all the smart device class and
/// smart device abstract classes
Expand Down Expand Up @@ -70,17 +68,12 @@ abstract class SmartDeviceBaseAbstract {
);
}

/// Getting the saved IP of this object
Future<String?> getIp() async {
return getIps();
}

/// Get the list of gpio pin of the device
List<PinInformation> getGpioPinList() {
return _gpioPinList;
}

Future<String> getUuid() {
return SmartDeviceObjectsR.getUuid();
return SystemCommandsBaseClassD.instance.getUuidOfCurrentDevice();
}
}
6 changes: 3 additions & 3 deletions lib/application/usecases/smart_server_u/smart_server_u.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ class CbjSmartDeviceServerU extends CbjSmartDeviceConnectionsServiceBase {

final String compId = const Uuid().v1();
final String compUuid =
await SystemCommandsManager().getUuidOfCurrentDevice();
final String os = SystemCommandsManager().getOs();
final String osVersion = SystemCommandsManager().getOsVersion();
await SystemCommandsBaseClassD.instance.getUuidOfCurrentDevice();
final String os = SystemCommandsBaseClassD.instance.getOs();
final String osVersion = SystemCommandsBaseClassD.instance.getOsVersion();

final List<SmartDeviceBaseAbstract> devicesList =
MySingleton().smartDevicesList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ class SmartComputerWishU {
static Future<String?> suspendComputer(
DeviceInformation deviceInformation,
) {
return SystemCommandsManager().suspendComputer();
return SystemCommandsBaseClassD.instance.suspendComputer();
// return 'Response from this device suspend successful';
}

/// Shut down the computer
static Future<String?> shutdownComputer(
DeviceInformation deviceInformation,
) {
return SystemCommandsManager().shutdownComputer();
return SystemCommandsBaseClassD.instance.shutdownComputer();
}
}
14 changes: 0 additions & 14 deletions lib/core/helper_methods.dart

This file was deleted.

6 changes: 3 additions & 3 deletions lib/core/my_singleton.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class MySingleton {
Future<String>? _currentUserName;

Future<String> getUuid() =>
_deviceUid ??= SystemCommandsManager().getUuidOfCurrentDevice();
_deviceUid ??= SystemCommandsBaseClassD.instance.getUuidOfCurrentDevice();

Future<String?> getCurrentUserName() =>
_currentUserName ??= SystemCommandsManager().getCurrentUserName();
Future<String?> getCurrentUserName() => _currentUserName ??=
SystemCommandsBaseClassD.instance.getCurrentUserName();

void addToSmartDevicesList(SmartDeviceBaseAbstract smartDeviceVal) {
smartDevicesList.add(smartDeviceVal);
Expand Down
9 changes: 4 additions & 5 deletions lib/domain/entities/set_devices_e/set_devices_e.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import 'package:cbj_integrations_controller/integrations_controller.dart';
import 'package:cbj_smart_device/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base_abstract.dart';
import 'package:cbj_smart_device/domain/entities/core_e/enums_e.dart';
import 'package:cbj_smart_device/infrastructure/repositories/set_devices_r/set_devices_r.dart';
import 'package:cbj_smart_device/utils.dart';

class SetDevicesE {
SetDevicesE() {
_setDevicesR = SetDevicesR();
_setDevicesR = SystemCommandsBaseClassD.instance;
}

late SetDevicesR _setDevicesR;
late SystemCommandsBaseClassD _setDevicesR;

Future<String> getCurrentDeviceUUid() {
return _setDevicesR.getCurrentDeviceUUid();
return _setDevicesR.getUuidOfCurrentDevice();
}

Future<String?> getDeviceDefaultConfig() {
return _setDevicesR.getDeviceDefaultConfig();
return _setDevicesR.getDeviceConfiguration();
}

Future<List<SmartDeviceBaseAbstract>> convertToListOfDevices(
Expand Down
3 changes: 2 additions & 1 deletion lib/infrastructure/datasources/hive_d/hive_d.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class IsarD {
try {
if (finishedInitializing == null) {
final String? snapCommonEnvironmentVariablePath =
await SystemCommandsManager().getSnapCommonEnvironmentVariable();
await SystemCommandsBaseClassD.instance
.getSnapCommonEnvironmentVariable();
if (snapCommonEnvironmentVariablePath == null) {
final String? currentUserName =
await MySingleton().getCurrentUserName();
Expand Down
13 changes: 0 additions & 13 deletions lib/infrastructure/datasources/set_devices_d/set_devices_d.dart

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions lib/infrastructure/repositories/set_devices_r/set_devices_r.dart

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: cbj_smart_device
description: Creating CyBear Jinni Smart Devices
version: 1.0.6
version: 1.0.7
homepage: https://cybearjinni.com
publish_to: 'none'

Expand Down
15 changes: 0 additions & 15 deletions test/smart_server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,3 @@ void main() {
expect(42, 42);
});
}

// void main() {
// test('ip list', () async {
// for (var interface in await NetworkInterface.list()) {
// // print('== Interface: ${interface.name} ==');
// for (var addr in interface.addresses) {
// // print(
// // '${addr.address} ${addr.host} ${addr.isLoopback} ${addr.rawAddress} ${addr.type.name}');
// print('IP: ' + addr.address);
// }
// }
//
// expect(await getIps(), '10.0.0.10');
// });
// }

0 comments on commit 0321486

Please sign in to comment.