diff --git a/bin/main.dart b/bin/main.dart index 98e2fd14..362b84bf 100644 --- a/bin/main.dart +++ b/bin/main.dart @@ -9,7 +9,7 @@ void main(List arguments) async { try { // configureNetworkTools('network_tools_db'); - SystemCommandsManager(); + // setInstanceForDartNative(); SharedVariables() .asyncConstructor(arguments.firstOrNull ?? Directory.current.path); } catch (error) { diff --git a/lib/application/usecases/core_u/smart_device_manager_u.dart b/lib/application/usecases/core_u/smart_device_manager_u.dart index 696dfc10..669f3165 100644 --- a/lib/application/usecases/core_u/smart_device_manager_u.dart +++ b/lib/application/usecases/core_u/smart_device_manager_u.dart @@ -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() { @@ -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); } diff --git a/lib/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base.dart b/lib/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base.dart index 8c6ef8b4..f57cefe4 100644 --- a/lib/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base.dart +++ b/lib/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base.dart @@ -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. @@ -55,12 +53,6 @@ abstract class SmartDeviceBase extends SmartDeviceBaseAbstract { ); } - /// Getting the saved IP of this object - @override - Future getIp() async { - return getIps(); - } - /// Get the list of gpio pin of the device @override List getGpioPinList() { @@ -69,7 +61,7 @@ abstract class SmartDeviceBase extends SmartDeviceBaseAbstract { @override Future getUuid() { - return SmartDeviceObjectsR.getUuid(); + return SystemCommandsBaseClassD.instance.getUuidOfCurrentDevice(); } bool getDeviceState() => onOff; diff --git a/lib/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base_abstract.dart b/lib/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base_abstract.dart index 24300975..9de2f3e7 100644 --- a/lib/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base_abstract.dart +++ b/lib/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base_abstract.dart @@ -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 @@ -70,17 +68,12 @@ abstract class SmartDeviceBaseAbstract { ); } - /// Getting the saved IP of this object - Future getIp() async { - return getIps(); - } - /// Get the list of gpio pin of the device List getGpioPinList() { return _gpioPinList; } Future getUuid() { - return SmartDeviceObjectsR.getUuid(); + return SystemCommandsBaseClassD.instance.getUuidOfCurrentDevice(); } } diff --git a/lib/application/usecases/smart_server_u/smart_server_u.dart b/lib/application/usecases/smart_server_u/smart_server_u.dart index e23e43c4..b2909548 100644 --- a/lib/application/usecases/smart_server_u/smart_server_u.dart +++ b/lib/application/usecases/smart_server_u/smart_server_u.dart @@ -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 devicesList = MySingleton().smartDevicesList; diff --git a/lib/application/usecases/wish_classes_u/smart_computer_wish_u.dart b/lib/application/usecases/wish_classes_u/smart_computer_wish_u.dart index 953a06fb..f0fb97a8 100644 --- a/lib/application/usecases/wish_classes_u/smart_computer_wish_u.dart +++ b/lib/application/usecases/wish_classes_u/smart_computer_wish_u.dart @@ -7,7 +7,7 @@ class SmartComputerWishU { static Future suspendComputer( DeviceInformation deviceInformation, ) { - return SystemCommandsManager().suspendComputer(); + return SystemCommandsBaseClassD.instance.suspendComputer(); // return 'Response from this device suspend successful'; } @@ -15,6 +15,6 @@ class SmartComputerWishU { static Future shutdownComputer( DeviceInformation deviceInformation, ) { - return SystemCommandsManager().shutdownComputer(); + return SystemCommandsBaseClassD.instance.shutdownComputer(); } } diff --git a/lib/core/helper_methods.dart b/lib/core/helper_methods.dart deleted file mode 100644 index a73c5bbe..00000000 --- a/lib/core/helper_methods.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'dart:io'; - -/// Get Ip info -Future getIps() async { - for (final NetworkInterface interface in await NetworkInterface.list()) { -// print('== Interface: ${interface.name} =='); - for (final InternetAddress address in interface.addresses) { -// print( -// '${addr.address} ${addr.host} ${addr.isLoopback} ${addr.rawAddress} ${addr.type.name}'); - return address.address; - } - } - return null; -} diff --git a/lib/core/my_singleton.dart b/lib/core/my_singleton.dart index f83a322e..339bb7a0 100644 --- a/lib/core/my_singleton.dart +++ b/lib/core/my_singleton.dart @@ -18,10 +18,10 @@ class MySingleton { Future? _currentUserName; Future getUuid() => - _deviceUid ??= SystemCommandsManager().getUuidOfCurrentDevice(); + _deviceUid ??= SystemCommandsBaseClassD.instance.getUuidOfCurrentDevice(); - Future getCurrentUserName() => - _currentUserName ??= SystemCommandsManager().getCurrentUserName(); + Future getCurrentUserName() => _currentUserName ??= + SystemCommandsBaseClassD.instance.getCurrentUserName(); void addToSmartDevicesList(SmartDeviceBaseAbstract smartDeviceVal) { smartDevicesList.add(smartDeviceVal); diff --git a/lib/domain/entities/set_devices_e/set_devices_e.dart b/lib/domain/entities/set_devices_e/set_devices_e.dart index 14243a1d..ef9bd240 100644 --- a/lib/domain/entities/set_devices_e/set_devices_e.dart +++ b/lib/domain/entities/set_devices_e/set_devices_e.dart @@ -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 getCurrentDeviceUUid() { - return _setDevicesR.getCurrentDeviceUUid(); + return _setDevicesR.getUuidOfCurrentDevice(); } Future getDeviceDefaultConfig() { - return _setDevicesR.getDeviceDefaultConfig(); + return _setDevicesR.getDeviceConfiguration(); } Future> convertToListOfDevices( diff --git a/lib/infrastructure/datasources/hive_d/hive_d.dart b/lib/infrastructure/datasources/hive_d/hive_d.dart index bddfd371..0854cce8 100644 --- a/lib/infrastructure/datasources/hive_d/hive_d.dart +++ b/lib/infrastructure/datasources/hive_d/hive_d.dart @@ -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(); diff --git a/lib/infrastructure/datasources/set_devices_d/set_devices_d.dart b/lib/infrastructure/datasources/set_devices_d/set_devices_d.dart deleted file mode 100644 index 8ee1f24b..00000000 --- a/lib/infrastructure/datasources/set_devices_d/set_devices_d.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:cbj_integrations_controller/integrations_controller.dart'; - -class SetDevicesD { - Future getCurrentDeviceUUid() { - final SystemCommandsManager systemCommandsManager = SystemCommandsManager(); - return systemCommandsManager.getUuidOfCurrentDevice(); - } - - Future getDeviceDefaultConfig() { - final SystemCommandsManager systemCommandsManager = SystemCommandsManager(); - return systemCommandsManager.getDeviceConfiguration(); - } -} diff --git a/lib/infrastructure/datasources/smart_device_objects_d/smart_device_objects_d.dart b/lib/infrastructure/datasources/smart_device_objects_d/smart_device_objects_d.dart deleted file mode 100644 index 50c2d233..00000000 --- a/lib/infrastructure/datasources/smart_device_objects_d/smart_device_objects_d.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:cbj_integrations_controller/integrations_controller.dart'; - -class SmartDeviceObjectsD { - static Future getUuid() { - final SystemCommandsManager systemCommandsManager = SystemCommandsManager(); - return systemCommandsManager.getUuidOfCurrentDevice(); - } -} diff --git a/lib/infrastructure/repositories/set_devices_r/set_devices_r.dart b/lib/infrastructure/repositories/set_devices_r/set_devices_r.dart deleted file mode 100644 index 30a1038b..00000000 --- a/lib/infrastructure/repositories/set_devices_r/set_devices_r.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:cbj_smart_device/infrastructure/datasources/set_devices_d/set_devices_d.dart'; - -class SetDevicesR { - SetDevicesR() { - _setDevicesD = SetDevicesD(); - } - - late SetDevicesD _setDevicesD; - - Future getCurrentDeviceUUid() { - return _setDevicesD.getCurrentDeviceUUid(); - } - - Future getDeviceDefaultConfig() { - return _setDevicesD.getDeviceDefaultConfig(); - } -} diff --git a/lib/infrastructure/repositories/smart_device_objects_r/smart_device_objects_r.dart b/lib/infrastructure/repositories/smart_device_objects_r/smart_device_objects_r.dart deleted file mode 100644 index 02c4fb6b..00000000 --- a/lib/infrastructure/repositories/smart_device_objects_r/smart_device_objects_r.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:cbj_smart_device/infrastructure/datasources/smart_device_objects_d/smart_device_objects_d.dart'; - -class SmartDeviceObjectsR { - static Future getUuid() { - return SmartDeviceObjectsD.getUuid(); - } -} diff --git a/pubspec.yaml b/pubspec.yaml index a154824b..31537934 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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' diff --git a/test/smart_server_test.dart b/test/smart_server_test.dart index 984ff1f4..63d5f1c6 100644 --- a/test/smart_server_test.dart +++ b/test/smart_server_test.dart @@ -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'); -// }); -// }