/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace Tizen.Network.Bluetooth
{
///
/// An extended EventArgs class contains the changed Bluetooth state.
///
/// 3
public class StateChangedEventArgs : EventArgs
{
private BluetoothState _type;
private BluetoothError _result;
internal StateChangedEventArgs(BluetoothError result, BluetoothState type)
{
_type = type;
_result = result;
}
///
/// The state of Bluetooth.
///
/// 3
public BluetoothState BTState
{
get
{
return _type;
}
}
///
/// The BluetoothError result.
///
/// 3
public BluetoothError Result
{
get
{
return _result;
}
}
}
///
/// An extended EventArgs class contains the changed Bluetooth name.
///
/// 3
public class NameChangedEventArgs : EventArgs
{
private string _name;
internal NameChangedEventArgs(string name)
{
_name = name;
}
///
/// The name of the device.
///
/// 3
public string DeviceName
{
get
{
return _name;
}
}
}
///
/// An extended EventArgs class contains the changed Bluetooth visibility mode.
///
/// 3
public class VisibilityModeChangedEventArgs : EventArgs
{
private VisibilityMode _mode;
private BluetoothError _result;
internal VisibilityModeChangedEventArgs(BluetoothError result, VisibilityMode mode)
{
_result = result;
_mode = mode;
}
///
/// The visibility mode.
///
/// 3
public VisibilityMode Visibility
{
get
{
return _mode;
}
}
///
/// The BluetoothError result.
///
/// 3
public BluetoothError Result
{
get
{
return _result;
}
}
}
///
/// An extended EventArgs class contains the duration until the visibility mode is changed from TimeLimitedDiscoverable to NonDiscoverable.
///
/// 3
public class VisibilityDurationChangedEventArgs : EventArgs
{
private int _duration;
internal VisibilityDurationChangedEventArgs(int duration)
{
_duration = duration;
}
///
/// The duration.
///
/// 3
public int Duration
{
get
{
return _duration;
}
}
}
///
/// An extended EventArgs class contains the changed Bluetooth device discovery state and the discovered device information.
///
/// 3
public class DiscoveryStateChangedEventArgs : EventArgs
{
private BluetoothError _result;
private BluetoothDeviceDiscoveryState _state;
private BluetoothDevice _device;
internal DiscoveryStateChangedEventArgs(BluetoothError result, BluetoothDeviceDiscoveryState state)
{
_result = result;
_state = state;
}
internal DiscoveryStateChangedEventArgs(BluetoothError result, BluetoothDeviceDiscoveryState state, BluetoothDevice device)
{
_result = result;
_state = state;
_device = device;
}
///
/// The BluetoothError result.
///
/// 3
public BluetoothError Result
{
get
{
return _result;
}
}
///
/// The state of the discovery.
///
/// 3
public BluetoothDeviceDiscoveryState DiscoveryState
{
get
{
return _state;
}
}
///
/// The remote device found.
///
/// 3
public BluetoothDevice DeviceFound
{
get
{
return _device;
}
}
}
///
/// An extended EventArgs class contains the bonded device information.
///
/// 3
public class BondCreatedEventArgs : EventArgs
{
private BluetoothError _result;
private BluetoothDevice _device;
internal BondCreatedEventArgs(BluetoothError result, BluetoothDevice device)
{
_result = result;
_device = device;
}
///
/// The BluetoothError result.
///
/// 3
public BluetoothError Result
{
get
{
return _result;
}
}
///
/// The remote device.
///
/// 3
public BluetoothDevice Device
{
get
{
return _device;
}
}
}
///
/// An extended EventArgs class contains the address of the remote Bluetooth device to destroy bond with.
///
/// 3
public class BondDestroyedEventArgs : EventArgs
{
private BluetoothError _result;
private string _address;
internal BondDestroyedEventArgs(BluetoothError result, string address)
{
_result = result;
_address = address;
}
///
/// The BluetoothError result.
///
/// 3
public BluetoothError Result
{
get
{
return _result;
}
}
///
/// The remote device address.
///
/// The device address.
/// 3
public string DeviceAddress
{
get
{
return _address;
}
}
}
///
/// An extended EventArgs class contains the authorization state and the address of the remote Bluetooth device.
///
/// 3
public class AuthorizationChangedEventArgs : EventArgs
{
private BluetoothAuthorizationType _authType;
private string _address;
internal AuthorizationChangedEventArgs(BluetoothAuthorizationType authType, string address)
{
_authType = authType;
_address = address;
}
///
/// The authorization.
///
/// 3
public BluetoothAuthorizationType Authorization
{
get
{
return _authType;
}
}
///
/// The device address.
///
/// 3
public string DeviceAddress
{
get
{
return _address;
}
}
}
///
/// An extended EventArgs class contains the service lists found on the remote Bluetooth device.
///
/// 3
public class ServiceSearchedEventArgs : EventArgs
{
private BluetoothDeviceSdpData _sdpData;
private BluetoothError _result;
internal ServiceSearchedEventArgs(BluetoothError result, BluetoothDeviceSdpData sdpData)
{
_result = result;
_sdpData = sdpData;
}
///
/// The BluetoothError result.
///
/// 3
public BluetoothError Result
{
get
{
return _result;
}
}
///
/// The sdp data.
///
/// 3
public BluetoothDeviceSdpData SdpData
{
get
{
return _sdpData;
}
}
}
///
/// An extended EventArgs class contains the connection state and the connection information of the remote device.
///
/// 3
public class DeviceConnectionStateChangedEventArgs : EventArgs
{
private bool _isConnected;
private BluetoothDeviceConnectionData _connectionData;
internal DeviceConnectionStateChangedEventArgs(bool isConnected, BluetoothDeviceConnectionData connectionData)
{
_isConnected = isConnected;
_connectionData = connectionData;
}
///
/// A value indicating whether the device is connected.
///
/// 3
public bool IsConnected
{
get
{
return _isConnected;
}
}
///
/// The device connection data.
///
/// 3
public BluetoothDeviceConnectionData ConnectionData
{
get
{
return _connectionData;
}
}
}
///
/// An extended EventArgs class contains the data received information.
///
/// 3
public class SocketDataReceivedEventArgs : EventArgs
{
private SocketData _data;
internal SocketDataReceivedEventArgs(SocketData data)
{
_data = data;
}
///
/// The socket data.
///
/// 3
public SocketData Data
{
get
{
return _data;
}
}
}
///
/// An extended EventArgs class contains the changed connection state.
///
/// 3
public class SocketConnectionStateChangedEventArgs : EventArgs
{
private BluetoothError _result;
private BluetoothSocketState _state;
private SocketConnection _connection;
internal SocketConnectionStateChangedEventArgs(BluetoothError result, BluetoothSocketState state, SocketConnection connection)
{
_result = result;
_state = state;
_connection = connection;
}
///
/// The BluetoothError result.
///
/// 3
public BluetoothError Result
{
get
{
return _result;
}
}
///
/// The socket state.
///
/// 3
public BluetoothSocketState State
{
get
{
return _state;
}
}
///
/// The socket connection.
///
/// 3
public SocketConnection Connection
{
get
{
return _connection;
}
}
}
///
/// The AcceptStateChanged event is raised when the socket connection state is changed.
///
/// 3
public class AcceptStateChangedEventArgs : EventArgs
{
private BluetoothError _result;
private BluetoothSocketState _state;
private SocketConnection _connection;
private IBluetoothServerSocket _server;
internal AcceptStateChangedEventArgs(BluetoothError result, BluetoothSocketState state, SocketConnection connection, BluetoothSocket server)
{
_result = result;
_state = state;
_connection = connection;
_server = (IBluetoothServerSocket)server;
}
///
/// The BluetoothError result.
///
/// 3
public BluetoothError Result
{
get
{
return _result;
}
}
///
/// The socket state.
///
/// 3
public BluetoothSocketState State
{
get
{
return _state;
}
}
///
/// The socket connection.
///
/// 3
public SocketConnection Connection
{
get
{
return _connection;
}
}
///
/// The server socket instance.
///
/// 3
[Obsolete("Deprecated since API level 6. Please use the 'Client' in the SocketConnection.")]
public IBluetoothServerSocket Server
{
get
{
return _server;
}
}
}
///
/// An extended EventArgs class contains the socket connection requested.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public class SocketConnectionRequestedEventArgs : EventArgs
{
internal SocketConnectionRequestedEventArgs(int socketFd, string remoteAddress)
{
SocketFd = socketFd;
RemoteAddress = remoteAddress;
}
///
/// The socket fd.
///
/// 6
internal int SocketFd
{
get;
private set;
}
///
/// The remote address.
///
/// 6
public string RemoteAddress
{
get;
private set;
}
}
///
/// An extended EventArgs class contains the connection state, remote address, and the type of audio profile.
///
/// 3
public class AudioConnectionStateChangedEventArgs : EventArgs
{
private int _result;
private bool _isConnected;
private string _address;
private BluetoothAudioProfileType _type;
internal AudioConnectionStateChangedEventArgs(int result, bool isConnected, string address, BluetoothAudioProfileType type)
{
_result = result;
_type = type;
_isConnected = isConnected;
_address = address;
}
///
/// The result.
///
/// 3
public int Result
{
get
{
return _result;
}
}
///
/// A value indicating whether this instance is connected.
///
/// 3
public bool IsConnected
{
get
{
return _isConnected;
}
}
///
/// The address.
///
/// 3
public string Address
{
get
{
return _address;
}
}
///
/// The type of the audio profile.
///
/// 3
public BluetoothAudioProfileType ProfileType
{
get
{
return _type;
}
}
}
///
/// An extended EventArgs class contains the connection state and the address of the remote Bluetooth device.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public class AgScoStateChangedEventArgs : EventArgs
{
internal AgScoStateChangedEventArgs(bool isOpened)
{
IsOpened = isOpened;
}
///
/// A value indicating whether the state is connected.
///
/// 6
public bool IsOpened
{
get;
private set;
}
}
///
/// An extended EventArgs class contains the connection state and the address of the remote Bluetooth device.
///
/// 3
public class HidConnectionStateChangedEventArgs : EventArgs
{
private int _result;
private bool _isConnected;
private string _address;
internal HidConnectionStateChangedEventArgs(int result, bool isConnected, string address)
{
_result = result;
_isConnected = isConnected;
_address = address;
}
///
/// The result.
///
/// 3
public int Result
{
get
{
return _result;
}
}
///
/// A value indicating whether this instance is connected.
///
/// 3
public bool IsConnected
{
get
{
return _isConnected;
}
}
///
/// The address.
///
/// 3
public string Address
{
get
{
return _address;
}
}
}
///
/// An extended EventArgs class contains the connection state and the address of the remote Bluetooth device.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public class HidDeviceConnectionStateChangedEventArgs : EventArgs
{
internal HidDeviceConnectionStateChangedEventArgs(bool isConnected, string address)
{
IsConnected = isConnected;
Address = address;
}
internal HidDeviceConnectionStateChangedEventArgs(int result, bool isConnected, string address)
{
Result = result;
IsConnected = isConnected;
Address = address;
}
internal int Result
{
get;
private set;
}
///
/// A value indicating whether this instance is connected.
///
/// 6
public bool IsConnected
{
get;
private set;
}
///
/// The address.
///
/// 6
public string Address
{
get;
private set;
}
}
///
/// An extended EventArgs class contains the connection state and the address of the remote Bluetooth device.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public class HidDeviceDataReceivedEventArgs : EventArgs
{
internal HidDeviceDataReceivedEventArgs(BluetoothHidDeviceReceivedData receivedData)
{
ReceivedData = receivedData;
}
///
/// The result.
///
/// 6
public BluetoothHidDeviceReceivedData ReceivedData
{
get;
private set;
}
}
///
/// An extended EventArgs class contains the changed equalizer state.
///
/// 3
public class EqualizerStateChangedEventArgs : EventArgs
{
private EqualizerState _state;
internal EqualizerStateChangedEventArgs(EqualizerState state)
{
_state = state;
}
///
/// The state of the equalizer.
///
/// 3
public EqualizerState State
{
get
{
return _state;
}
}
}
///
/// An extended EventArgs class contains the changed repeat mode.
///
/// 3
public class RepeatModeChangedEventArgs : EventArgs
{
private RepeatMode _mode;
internal RepeatModeChangedEventArgs(RepeatMode mode)
{
_mode = mode;
}
///
/// The repeat mode.
///
/// 3
public RepeatMode Mode
{
get
{
return _mode;
}
}
}
///
/// An extended EventArgs class contains the changed shuffle mode.
///
/// 3
public class ShuffleModeChangedeventArgs : EventArgs
{
private ShuffleMode _mode;
internal ShuffleModeChangedeventArgs(ShuffleMode mode)
{
_mode = mode;
}
///
/// The shuffle mode.
///
/// 3
public ShuffleMode Mode
{
get
{
return _mode;
}
}
}
///
/// An extended EventArgs class contains the changed scan mode.
///
/// 3
public class ScanModeChangedEventArgs : EventArgs
{
private ScanMode _mode;
internal ScanModeChangedEventArgs(ScanMode mode)
{
_mode = mode;
}
///
/// The scan mode.
///
/// 3
public ScanMode Mode
{
get
{
return _mode;
}
}
}
///
/// An extended EventArgs class contains the connection state and the remote device address.
///
/// 3
public class TargetConnectionStateChangedEventArgs : EventArgs
{
private bool _isConnected;
private string _address;
internal TargetConnectionStateChangedEventArgs(bool isConnected, string address)
{
_isConnected = isConnected;
_address = address;
}
///
/// A value indicating whether this instance is connected.
///
/// 3
public bool IsConnected
{
get
{
return _isConnected;
}
}
///
/// The address.
///
/// 3
public string Address
{
get
{
return _address;
}
}
}
///
/// An extended EventArgs class contains the changed Bluetooth LE advertising state changed information.
///
/// 3
public class AdvertisingStateChangedEventArgs : EventArgs
{
private BluetoothLeAdvertisingState _state;
private int _result;
private IntPtr _advertiserHandle;
//TODO : Add conversion code from IntPtr to BluetoothLeAdvertiser class later
internal AdvertisingStateChangedEventArgs(int result, IntPtr advertiserHandle,
BluetoothLeAdvertisingState state)
{
_result = result;
_advertiserHandle = advertiserHandle;
_state = state;
}
///
/// The result.
///
/// 3
public int Result
{
get
{
return _result;
}
}
///
/// The advertiser handle.
///
/// 3
public IntPtr AdvertiserHandle
{
get
{
return _advertiserHandle;
}
}
///
/// The LE advertising state.
///
/// 3
public BluetoothLeAdvertisingState State
{
get
{
return _state;
}
}
}
///
/// An extended EventArgs class contains the changed Bluetooth LE scan result information.
///
/// 3
public class AdapterLeScanResultChangedEventArgs : EventArgs
{
private BluetoothLeDevice _deviceData;
private BluetoothError _result;
internal AdapterLeScanResultChangedEventArgs(BluetoothError result, BluetoothLeDevice deviceData)
{
_deviceData = deviceData;
_result = result;
}
///
/// The result.
///
/// 3
public BluetoothError Result
{
get
{
return _result;
}
}
///
/// The LE device data.
///
/// 3
public BluetoothLeDevice DeviceData
{
get
{
return _deviceData;
}
}
}
///
/// An extended EventArgs class contains the changed Bluetooth LE GATT connection state.
///
/// 3
public class GattConnectionStateChangedEventArgs : EventArgs
{
private bool _isConnected;
private int _result;
private string _remoteAddress;
internal GattConnectionStateChangedEventArgs(int result, bool connected, string remoteAddress)
{
_isConnected = connected;
_result = result;
_remoteAddress = remoteAddress;
}
///
/// The result.
///
/// 3
public int Result
{
get
{
return _result;
}
}
///
/// A value indicating whether this instance is connected.
///
/// 3
public bool IsConnected
{
get
{
return _isConnected;
}
}
///
/// The remote address.
///
/// 3
public string RemoteAddress
{
get
{
return _remoteAddress;
}
}
}
///
/// An extended EventArgs class contains the changed attribute value.
///
/// 3
public class ValueChangedEventArgs : EventArgs
{
internal ValueChangedEventArgs(IntPtr value, int len)
{
Value = new byte[len];
unsafe
{
for (int i = 0; i < len; i++)
{
Value[i] = *((byte*)value.ToPointer() + i);
}
}
}
///
/// The attribute value.
///
/// 3
public byte[] Value { get; }
}
///
/// An extended EventArgs class contains the read value request data.
///
/// 3
public class ReadRequestedEventArgs : EventArgs
{
internal ReadRequestedEventArgs(BluetoothGattServer server, string clientAddress, int requestId, int offset)
{
Server = server;
ClientAddress = clientAddress;
RequestId = requestId;
Offset = offset;
}
///
/// The GATT server instance.
///
/// 3
public BluetoothGattServer Server { get; }
///
/// The client address.
///
/// 3
public string ClientAddress { get; }
///
/// The request identifier.
///
/// 3
public int RequestId { get; }
///
/// The offset.
///
/// 3
public int Offset { get; }
}
///
/// An extended EventArgs class contains the read value request data.
///
/// 3
public class WriteRequestedEventArgs : EventArgs
{
internal WriteRequestedEventArgs(BluetoothGattServer server, string clientAddress, int requestId, byte[] value, int offset, bool response_needed)
{
Server = server;
ClientAddress = clientAddress;
RequestId = requestId;
Value = value;
Offset = offset;
Response_needed = response_needed;
}
///
/// The GATT server instance.
///
/// 3
public BluetoothGattServer Server { get; }
///
/// The client address.
///
/// 3
public string ClientAddress { get; }
///
/// The request identifier.
///
/// 3
public int RequestId { get; }
///
/// The read value.
///
/// 3
public byte[] Value { get; }
///
/// The offset.
///
/// 3
public int Offset { get; }
///
/// Indicates whether a response is required by the remote device.
///
/// 3
public bool Response_needed { get; }
}
///
/// An extended EventArgs class contains the client preference to enable or disable the Notification/Indication.
///
/// 3
public class NotificationStateChangedEventArg : EventArgs
{
internal NotificationStateChangedEventArg(BluetoothGattServer server, bool value)
{
Server = server;
Value = value;
}
///
/// The GATT server instance.
///
/// 3
public BluetoothGattServer Server { get; }
///
/// A value indicating whether the notification is enabled.
///
/// 3
public bool Value { get; }
}
///
/// An extended EventArgs class contains the read value request data.
///
/// 3
public class NotificationSentEventArg : EventArgs
{
internal NotificationSentEventArg(BluetoothGattServer server, string clientAddress, int result, bool completed)
{
Result = result;
ClientAddress = clientAddress;
Server = server;
Completed = completed;
}
///
/// The GATT server instance.
///
/// 3
public BluetoothGattServer Server { get; }
///
/// The client address.
///
/// 3
public string ClientAddress { get; }
///
/// The result.
///
/// 3
public int Result { get; }
///
/// Gets a value indicating whether the notification sent is completed.
///
/// 3
public bool Completed { get; }
}
///
/// An extended EventArgs class which contains the connection state and address of the remote Bluetooth device.
///
/// 4
public class ConnectionRequestedEventArgs : EventArgs
{
private string _address;
internal ConnectionRequestedEventArgs(string address)
{
_address = address;
}
///
/// The address.
///
/// 4
public string Address
{
get
{
return _address;
}
}
}
///
/// An extended EventArgs class which contains the file transfer progress state, file transfer progress by percent.
///
/// 4
public class TransferProgressEventArgs : EventArgs
{
private string _file;
private long _size;
private int _percent;
internal TransferProgressEventArgs(string file, long size, int percent)
{
_file = file;
_size = size;
_percent = percent;
}
///
/// The File name.
///
/// 4
public string File
{
get
{
return _file;
}
}
///
/// The File size.
///
/// 4
public long Size
{
get
{
return _size;
}
}
///
/// The File transfer percent.
///
/// 4
public int Percent
{
get
{
return _percent;
}
}
}
///
/// An extended EventArgs class which contains the file transfer finished state and file state.
///
/// 4
public class TransferFinishedEventArgs : EventArgs
{
private string _file;
private long _size;
private int _result;
internal TransferFinishedEventArgs(int result, string file, long size)
{
_file = file;
_size = size;
_result = result;
}
///
/// The File name.
///
/// 4
public string File
{
get
{
return _file;
}
}
///
/// The File size.
///
/// 4
public long Size
{
get
{
return _size;
}
}
///
/// The return value.
///
/// 4
public int Result
{
get
{
return _result;
}
}
}
///
/// An extended EventArgs class which contains the Push Request respond state
///
/// 4
public class PushRespondedEventArgs : EventArgs
{
int _result;
string _address;
internal PushRespondedEventArgs(int result, string address)
{
_address = address;
_result = result;
}
///
/// The return value.
///
/// 4
public int Result
{
get
{
return _result;
}
}
///
/// The address.
///
/// 4
public string Address
{
get
{
return _address;
}
}
}
///
/// An extended EventArgs class which contains the file push progress state, push progress by percent.
///
/// 4
public class PushProgressEventArgs : EventArgs
{
private string _file;
private long _size;
private int _percent;
internal PushProgressEventArgs(string file, long size, int percent)
{
_file = file;
_size = size;
_percent = percent;
}
///
/// The File name.
///
/// 4
public string File
{
get
{
return _file;
}
}
///
/// The File size.
///
/// 4
public long Size
{
get
{
return _size;
}
}
///
/// The File transfer percent.
///
/// 4
public int Percent
{
get
{
return _percent;
}
}
}
///
/// An extended EventArgs class which contains the Push Request respond state
///
/// 4
public class PushFinishedEventArgs : EventArgs
{
int _result;
string _address;
internal PushFinishedEventArgs(int result, string address)
{
_address = address;
_result = result;
}
///
/// The return value.
///
/// 4
public int Result
{
get
{
return _result;
}
}
///
/// The address.
///
/// 4
public string Address
{
get
{
return _address;
}
}
}
}