Skip to content

Commit

Permalink
revert: move onto another branch & refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed May 18, 2024
1 parent 8590205 commit 73bf3bb
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 65 deletions.
1 change: 1 addition & 0 deletions GalaxyBudsClient.Platform.Linux/BluetoothService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;
using Serilog;
using ThePBone.BlueZNet;
using ThePBone.BlueZNet.Interop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
<ItemGroup>
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="SharpHook" Version="5.3.2" />
<PackageReference Include="Tmds.DBus" Version="0.16.0" />
<PackageReference Include="Tmds.DBus.Protocol" Version="0.16.0" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions GalaxyBudsClient.Platform.OSX/BluetoothService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading;
using System.Threading.Tasks;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;
using Serilog;

namespace GalaxyBudsClient.Platform.OSX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using GalaxyBudsClient.Platform.Windows.Utils;
using GalaxyBudsClient.Platform;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;
using InTheHand.Net.Bluetooth;
using InTheHand.Net.Bluetooth.Msft;
using InTheHand.Net.Sockets;
Expand Down
4 changes: 2 additions & 2 deletions GalaxyBudsClient.Platform.WindowsRT/BluetoothDeviceRT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Windows.Devices.Enumeration;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;

namespace GalaxyBudsClient.Platform.WindowsRT
{
Expand All @@ -18,7 +18,7 @@ internal class BluetoothDeviceRt(DeviceInformation info, IEnumerable<Guid>? serv
public override bool IsConnected => (bool) (DeviceInfo.Properties["System.Devices.Aep.IsConnected"] ?? false);
public override Guid[]? ServiceUuids => _services?.ToArray();

public void Update(DeviceInformationUpdate? update, IEnumerable<Guid> services)
public void Update(DeviceInformationUpdate? update, IEnumerable<Guid>? services)
{
if (update == null)
{
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient.Platform.WindowsRT/BluetoothService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Windows.Storage.Streams;
using GalaxyBudsClient.Platform.Interfaces;
using Serilog;
using BluetoothDevice = GalaxyBudsClient.Platform.Interfaces.BluetoothDevice;
using BluetoothDevice = GalaxyBudsClient.Platform.Model.BluetoothDevice;
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
#pragma warning disable CS0169 // Field is never used

Expand Down
5 changes: 5 additions & 0 deletions GalaxyBudsClient.Platform/GalaxyBudsClient.Platform.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>

<ItemGroup>
<Compile Remove="Model\Notification.cs" />
<Compile Remove="Stubs\BluetoothService.Dummy.cs" />
</ItemGroup>
</Project>
66 changes: 15 additions & 51 deletions GalaxyBudsClient.Platform/Interfaces/IBluetoothService.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,24 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using GalaxyBudsClient.Platform.Model;

namespace GalaxyBudsClient.Platform.Interfaces
{
public class BluetoothDevice(string name, string address, bool isConnected, bool isPaired, BluetoothCoD cod, Guid[]? serviceUuids = null)
{
public BluetoothDevice(uint cod) : this(string.Empty, string.Empty, false, false, new BluetoothCoD(cod))
{
}

public override string ToString()
{
return $"{Name} ({Address})"; //$"BluetoothDevice[Name={Name},Address={Address},IsConnected={IsConnected},IsPaired='{IsPaired}',CoD='{Class}']";
}
namespace GalaxyBudsClient.Platform.Interfaces;

public virtual string Name { get; } = name;
public virtual string Address { get; } = address;
public virtual bool IsConnected { get; } = isConnected;
public virtual bool IsPaired { get; } = isPaired;
public BluetoothCoD Class { get; } = cod;
public virtual Guid[]? ServiceUuids { get; } = serviceUuids;

public static IEnumerable<BluetoothDevice> DummyDevices()
{
/* Dummy devices for testing */
var cod = new BluetoothCoD(0);
return new BluetoothDevice[]
{
new("Galaxy Buds (36FD) [Dummy]", "36:AB:38:F5:04:FD", true, true, cod),
new("Galaxy Buds+ (A2D5) [Dummy]", "A2:BF:D4:4A:52:D5", true, true, cod),
new("Galaxy Buds Live (4AC3) [Dummy]", "4A:6B:87:E5:12:C3", true, true, cod),
new("Galaxy Buds Pro (E43F) [Dummy]", "E4:25:FA:6D:B9:3F", true, true, cod),
new("Galaxy Buds2 (D592) [Dummy]", "D5:97:B8:23:AB:92", true, true, cod),
new("Galaxy Buds2 Pro (3292) [Dummy]", "32:97:B8:23:AB:92", true, true, cod),
new("Galaxy Buds FE (A7D4) [Dummy]", "A7:97:B8:23:AB:D4", true, true, cod)
};
}
}

public interface IBluetoothService
{
event EventHandler<BluetoothException>? BluetoothErrorAsync;
event EventHandler? Connecting;
event EventHandler? Connected;
event EventHandler? RfcommConnected;
event EventHandler<string>? Disconnected;
event EventHandler<byte[]>? NewDataAvailable;
public interface IBluetoothService
{
event EventHandler<BluetoothException>? BluetoothErrorAsync;
event EventHandler? Connecting;
event EventHandler? Connected;
event EventHandler? RfcommConnected;
event EventHandler<string>? Disconnected;
event EventHandler<byte[]>? NewDataAvailable;

bool IsStreamConnected { get; }
bool IsStreamConnected { get; }

Task ConnectAsync(string macAddress, string serviceUuid, CancellationToken cancelToken);
Task DisconnectAsync();
Task SendAsync(byte[] data);
Task ConnectAsync(string macAddress, string serviceUuid, CancellationToken cancelToken);
Task DisconnectAsync();
Task SendAsync(byte[] data);

Task<BluetoothDevice[]> GetDevicesAsync();
}
Task<BluetoothDevice[]> GetDevicesAsync();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GalaxyBudsClient.Platform
namespace GalaxyBudsClient.Platform.Model
{
public class BluetoothCoD
{
Expand Down
39 changes: 39 additions & 0 deletions GalaxyBudsClient.Platform/Model/BluetoothDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;

namespace GalaxyBudsClient.Platform.Model;

public class BluetoothDevice(string name, string address, bool isConnected, bool isPaired, BluetoothCoD cod, Guid[]? serviceUuids = null)
{
protected BluetoothDevice(uint cod) : this(string.Empty, string.Empty, false, false, new BluetoothCoD(cod))
{
}

public override string ToString()
{
return $"{Name} ({Address})"; //$"BluetoothDevice[Name={Name},Address={Address},IsConnected={IsConnected},IsPaired='{IsPaired}',CoD='{Class}']";
}

public virtual string Name { get; } = name;
public virtual string Address { get; } = address;
public virtual bool IsConnected { get; } = isConnected;
public virtual bool IsPaired { get; } = isPaired;
public BluetoothCoD Class { get; } = cod;
public virtual Guid[]? ServiceUuids { get; } = serviceUuids;

public static IEnumerable<BluetoothDevice> DummyDevices()
{
/* Dummy devices for testing */
var cod = new BluetoothCoD(0);
return new BluetoothDevice[]
{
new("Galaxy Buds (36FD) [Dummy]", "36:AB:38:F5:04:FD", true, true, cod),
new("Galaxy Buds+ (A2D5) [Dummy]", "A2:BF:D4:4A:52:D5", true, true, cod),
new("Galaxy Buds Live (4AC3) [Dummy]", "4A:6B:87:E5:12:C3", true, true, cod),
new("Galaxy Buds Pro (E43F) [Dummy]", "E4:25:FA:6D:B9:3F", true, true, cod),
new("Galaxy Buds2 (D592) [Dummy]", "D5:97:B8:23:AB:92", true, true, cod),
new("Galaxy Buds2 Pro (3292) [Dummy]", "32:97:B8:23:AB:92", true, true, cod),
new("Galaxy Buds FE (A7D4) [Dummy]", "A7:97:B8:23:AB:D4", true, true, cod)
};
}
}
1 change: 1 addition & 0 deletions GalaxyBudsClient.Platform/PlatformUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum Platforms
public static bool SupportsAutoboot => IsWindows || (IsLinux && !IsRunningInFlatpak) || IsOSX;
public static bool SupportsHotkeys => IsWindows || IsLinux || IsOSX;
public static bool SupportsHotkeysBroadcast => IsWindows || IsLinux || IsOSX;
public static bool SupportsNotificationListener => IsLinux;
public static bool SupportsMicaTheme => IsWindows && Environment.OSVersion.Version.Build >= 22000;
public static bool SupportsBlurTheme => IsWindows || IsOSX || (IsLinux && Environment.GetEnvironmentVariable("XDG_CURRENT_DESKTOP")?.Contains("KDE") == true);

Expand Down
4 changes: 4 additions & 0 deletions GalaxyBudsClient/GalaxyBudsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
<AvaloniaXaml Remove="bin\**" />
<EmbeddedResource Remove="bin\**" />
<None Remove="bin\**" />
<Compile Remove="Platform\NotificationReaderManager.cs" />
<Compile Remove="Interface\ViewModels\Pages\NotificationReaderPageViewModel.cs" />
<Compile Remove="Interface\Pages\NotificationReaderPage.axaml.cs" />
</ItemGroup>

<!-- Dependencies -->
Expand Down Expand Up @@ -107,6 +110,7 @@
<PackageReference Include="Serilog.Sinks.Trace" Version="3.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
<PackageReference Include="Tmds.DBus" Version="0.16.0" />
<PackageReference Include="Voice100" Version="1.3.0" />
</ItemGroup>

<!-- Project references -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
xmlns:input="clr-namespace:FluentAvalonia.UI.Input;assembly=FluentAvalonia"
xmlns:i18N="clr-namespace:GalaxyBudsClient.Generated.I18N"
xmlns:config="clr-namespace:GalaxyBudsClient.Model.Config"
xmlns:interfaces="clr-namespace:GalaxyBudsClient.Platform.Interfaces;assembly=GalaxyBudsClient.Platform"
xmlns:model="clr-namespace:GalaxyBudsClient.Platform.Model;assembly=GalaxyBudsClient.Platform"
mc:Ignorable="d"
Padding="0, 5, 0, 0"
x:CompileBindings="True"
Expand All @@ -35,7 +35,7 @@
IsVisible="{Binding !NoDevices}"
Name="DevList">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="interfaces:BluetoothDevice">
<DataTemplate x:DataType="model:BluetoothDevice">
<Border Background="Transparent" PointerPressed="OnListItemPressed">
<Panel>
<StackPanel Spacing="4" Margin="4 10" VerticalAlignment="Center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using GalaxyBudsClient.Interface.ViewModels.Dialogs;
using GalaxyBudsClient.Model.Constants;
using GalaxyBudsClient.Platform;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;

namespace GalaxyBudsClient.Interface.Dialogs;

Expand Down
4 changes: 2 additions & 2 deletions GalaxyBudsClient/Interface/Dialogs/ManualPairDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:ext="clr-namespace:GalaxyBudsClient.Interface.MarkupExtensions"
xmlns:i18N="clr-namespace:GalaxyBudsClient.Generated.I18N"
xmlns:interfaces="clr-namespace:GalaxyBudsClient.Platform.Interfaces;assembly=GalaxyBudsClient.Platform"
xmlns:model="clr-namespace:GalaxyBudsClient.Platform.Model;assembly=GalaxyBudsClient.Platform"
mc:Ignorable="d"
Padding="0, 5, 0, 0"
x:CompileBindings="True"
Expand All @@ -21,7 +21,7 @@
<StackPanel Spacing="12">
<TextBlock Text="{ext:Translate {x:Static i18N:Keys.ManualpairTitleDialog}}"
TextWrapping="Wrap" />
<ComboBox DisplayMemberBinding="{Binding Name, DataType=interfaces:BluetoothDevice}"
<ComboBox DisplayMemberBinding="{Binding Name, DataType=model:BluetoothDevice}"
ItemsSource="{Binding Devices}"
SelectedValue="{Binding SelectedDevice}"
HorizontalAlignment="Stretch" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using GalaxyBudsClient.Interface.ViewModels.Dialogs;
using GalaxyBudsClient.Model.Constants;
using GalaxyBudsClient.Platform;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;

namespace GalaxyBudsClient.Interface.Dialogs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using GalaxyBudsClient.Model.Constants;
using GalaxyBudsClient.Model.Specifications;
using GalaxyBudsClient.Platform;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;
using ReactiveUI.Fody.Helpers;

namespace GalaxyBudsClient.Interface.ViewModels.Dialogs;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using GalaxyBudsClient.Model.Constants;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;
using ReactiveUI.Fody.Helpers;

namespace GalaxyBudsClient.Interface.ViewModels.Dialogs;
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/Model/Specifications/DeviceSpecHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using GalaxyBudsClient.Model.Constants;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;
using Serilog;

namespace GalaxyBudsClient.Model.Specifications;
Expand Down
1 change: 1 addition & 0 deletions GalaxyBudsClient/Platform/BluetoothImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using GalaxyBudsClient.Model.Constants;
using GalaxyBudsClient.Model.Specifications;
using GalaxyBudsClient.Platform.Interfaces;
using GalaxyBudsClient.Platform.Model;
using GalaxyBudsClient.Platform.Stubs;
using GalaxyBudsClient.Scripting;
using GalaxyBudsClient.Utils;
Expand Down

0 comments on commit 73bf3bb

Please sign in to comment.