Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Bluetooth / Tizen.Network.Bluetooth / BluetoothEventArgs.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections.Generic;
19
20 namespace Tizen.Network.Bluetooth
21 {
22     /// <summary>
23     /// An extended EventArgs class contains the changed Bluetooth state.
24     /// </summary>
25     public class StateChangedEventArgs : EventArgs
26     {
27         private BluetoothState _type;
28         private BluetoothError _result;
29
30         internal StateChangedEventArgs(BluetoothError result, BluetoothState type)
31         {
32             _type = type;
33             _result = result;
34         }
35
36         /// <summary>
37         /// The state of Bluetooth.
38         /// </summary>
39         public BluetoothState BTState
40         {
41             get
42             {
43                 return _type;
44             }
45         }
46
47         /// <summary>
48         /// The BluetoothError result.
49         /// </summary>
50         public BluetoothError Result
51         {
52             get
53             {
54                 return _result;
55             }
56         }
57     }
58
59     /// <summary>
60     /// An extended EventArgs class contains the changed Bluetooth name.
61     /// </summary>
62     public class NameChangedEventArgs : EventArgs
63     {
64         private string _name;
65
66         internal NameChangedEventArgs(string name)
67         {
68             _name = name;
69         }
70
71         /// <summary>
72         /// The name of the device.
73         /// </summary>
74         public string DeviceName
75         {
76             get
77             {
78                 return _name;
79             }
80         }
81     }
82
83     /// <summary>
84     /// An extended EventArgs class contains the changed Bluetooth visibility mode.
85     /// </summary>
86     public class VisibilityModeChangedEventArgs : EventArgs
87     {
88         private VisibilityMode _mode;
89         private BluetoothError _result;
90
91         internal VisibilityModeChangedEventArgs(BluetoothError result, VisibilityMode mode)
92         {
93             _result = result;
94             _mode = mode;
95         }
96
97         /// <summary>
98         /// The visibility mode.
99         /// </summary>
100         public VisibilityMode Visibility
101         {
102             get
103             {
104                 return _mode;
105             }
106         }
107
108         /// <summary>
109         /// The BluetoothError result.
110         /// </summary>
111         public BluetoothError Result
112         {
113             get
114             {
115                 return _result;
116             }
117         }
118     }
119
120     /// <summary>
121     /// An extended EventArgs class contains the duration until the visibility mode is changed from TimeLimitedDiscoverable to NonDiscoverable.
122     /// </summary>
123     public class VisibilityDurationChangedEventArgs : EventArgs
124     {
125         private int _duration;
126
127         internal VisibilityDurationChangedEventArgs(int duration)
128         {
129             _duration = duration;
130         }
131
132         /// <summary>
133         /// The duration.
134         /// </summary>
135         public int Duration
136         {
137             get
138             {
139                 return _duration;
140             }
141         }
142     }
143
144     /// <summary>
145     /// An extended EventArgs class contains the changed Bluetooth device discovery state and the discovered device information.
146     /// </summary>
147     public class DiscoveryStateChangedEventArgs : EventArgs
148     {
149         private BluetoothError _result;
150         private BluetoothDeviceDiscoveryState _state;
151         private BluetoothDevice _device;
152
153         internal DiscoveryStateChangedEventArgs(BluetoothError result, BluetoothDeviceDiscoveryState state)
154         {
155             _result = result;
156             _state = state;
157         }
158
159         internal DiscoveryStateChangedEventArgs(BluetoothError result, BluetoothDeviceDiscoveryState state, BluetoothDevice device)
160         {
161             _result = result;
162             _state = state;
163             _device = device;
164         }
165
166         /// <summary>
167         /// The BluetoothError result.
168         /// </summary>
169         public BluetoothError Result
170         {
171             get
172             {
173                 return _result;
174             }
175         }
176
177         /// <summary>
178         /// The state of the discovery.
179         /// </summary>
180         public BluetoothDeviceDiscoveryState DiscoveryState
181         {
182             get
183             {
184                 return _state;
185             }
186         }
187
188         /// <summary>
189         /// The remote device found.
190         /// </summary>
191         public BluetoothDevice DeviceFound
192         {
193             get
194             {
195                 return _device;
196             }
197         }
198     }
199
200     /// <summary>
201     /// An extended EventArgs class contains the bonded device information.
202     /// </summary>
203     public class BondCreatedEventArgs : EventArgs
204     {
205         private BluetoothError _result;
206         private BluetoothDevice _device;
207
208         internal BondCreatedEventArgs(BluetoothError result, BluetoothDevice device)
209         {
210             _result = result;
211             _device = device;
212         }
213
214         /// <summary>
215         /// The BluetoothError result.
216         /// </summary>
217         public BluetoothError Result
218         {
219             get
220             {
221                 return _result;
222             }
223         }
224
225         /// <summary>
226         /// The remote device.
227         /// </summary>
228         public BluetoothDevice Device
229         {
230             get
231             {
232                 return _device;
233             }
234         }
235     }
236
237     /// <summary>
238     /// An extended EventArgs class contains the address of the remote Bluetooth device to destroy bond with.
239     /// </summary>
240     public class BondDestroyedEventArgs : EventArgs
241     {
242         private BluetoothError _result;
243         private string _address;
244
245         internal BondDestroyedEventArgs(BluetoothError result, string address)
246         {
247             _result = result;
248             _address = address;
249         }
250
251         /// <summary>
252         /// The BluetoothError result.
253         /// </summary>
254         public BluetoothError Result
255         {
256             get
257             {
258                 return _result;
259             }
260         }
261
262         /// <summary>
263         /// The remote device address.
264         /// </summary>
265         /// <value>The device address.</value>
266         public string DeviceAddress
267         {
268             get
269             {
270                 return _address;
271             }
272         }
273     }
274
275     /// <summary>
276     /// An extended EventArgs class contains the authorization state and the address of the remote Bluetooth device.
277     /// </summary>
278     public class AuthorizationChangedEventArgs : EventArgs
279     {
280         private BluetoothAuthorizationType _authType;
281         private string _address;
282
283         internal AuthorizationChangedEventArgs(BluetoothAuthorizationType authType, string address)
284         {
285             _authType = authType;
286             _address = address;
287         }
288
289         /// <summary>
290         /// The authorization.
291         /// </summary>
292         public BluetoothAuthorizationType Authorization
293         {
294             get
295             {
296                 return _authType;
297             }
298         }
299
300         /// <summary>
301         /// The device address.
302         /// </summary>
303         public string DeviceAddress
304         {
305             get
306             {
307                 return _address;
308             }
309         }
310
311     }
312
313     /// <summary>
314     /// An extended EventArgs class contains the service lists found on the remote Bluetooth device.
315     /// </summary>
316     public class ServiceSearchedEventArgs : EventArgs
317     {
318         private BluetoothDeviceSdpData _sdpData;
319         private BluetoothError _result;
320
321         internal ServiceSearchedEventArgs(BluetoothError result, BluetoothDeviceSdpData sdpData)
322         {
323             _result = result;
324             _sdpData = sdpData;
325         }
326
327         /// <summary>
328         /// The BluetoothError result.
329         /// </summary>
330         public BluetoothError Result
331         {
332             get
333             {
334                 return _result;
335             }
336         }
337         /// <summary>
338         /// The sdp data.
339         /// </summary>
340         public BluetoothDeviceSdpData SdpData
341         {
342             get
343             {
344                 return _sdpData;
345             }
346         }
347     }
348
349     /// <summary>
350     /// An extended EventArgs class contains the connection state and the connection information of the remote device.
351     /// </summary>
352     public class DeviceConnectionStateChangedEventArgs : EventArgs
353     {
354         private bool _isConnected;
355         private BluetoothDeviceConnectionData _connectionData;
356
357         internal DeviceConnectionStateChangedEventArgs(bool isConnected, BluetoothDeviceConnectionData connectionData)
358         {
359             _isConnected = isConnected;
360             _connectionData = connectionData;
361         }
362
363         /// <summary>
364         /// A value indicating whether the device is connected.
365         /// </summary>
366         public bool IsConnected
367         {
368             get
369             {
370                 return _isConnected;
371             }
372         }
373
374         /// <summary>
375         /// The device connection data.
376         /// </summary>
377         public BluetoothDeviceConnectionData ConnectionData
378         {
379             get
380             {
381                 return _connectionData;
382             }
383         }
384     }
385
386     /// <summary>
387     /// An extended EventArgs class contains the data received information.
388     /// </summary>
389     public class SocketDataReceivedEventArgs : EventArgs
390     {
391         private SocketData _data;
392
393         internal SocketDataReceivedEventArgs(SocketData data)
394         {
395             _data = data;
396         }
397
398         /// <summary>
399         /// The socket data.
400         /// </summary>
401         public SocketData Data
402         {
403             get
404             {
405                 return _data;
406             }
407         }
408     }
409
410     /// <summary>
411     /// An extended EventArgs class contains the changed connection state.
412     /// </summary>
413     public class SocketConnectionStateChangedEventArgs : EventArgs
414     {
415         private BluetoothError _result;
416         private BluetoothSocketState _state;
417         private SocketConnection _connection;
418
419         internal SocketConnectionStateChangedEventArgs(BluetoothError result, BluetoothSocketState state, SocketConnection connection)
420         {
421             _result = result;
422             _state = state;
423             _connection = connection;
424         }
425
426         /// <summary>
427         /// The BluetoothError result.
428         /// </summary>
429         public BluetoothError Result
430         {
431             get
432             {
433                 return _result;
434             }
435         }
436
437         /// <summary>
438         /// The socket state.
439         /// </summary>
440         public BluetoothSocketState State
441         {
442             get
443             {
444                 return _state;
445             }
446         }
447
448         /// <summary>
449         /// The socket connection.
450         /// </summary>
451         public SocketConnection Connection
452         {
453             get
454             {
455                 return _connection;
456             }
457         }
458     }
459
460     public class AcceptStateChangedEventArgs : EventArgs
461     {
462         private BluetoothError _result;
463         private BluetoothSocketState _state;
464         private SocketConnection _connection;
465         private IBluetoothServerSocket _server;
466
467         internal AcceptStateChangedEventArgs(BluetoothError result, BluetoothSocketState state, SocketConnection connection, BluetoothSocket server)
468         {
469             _result = result;
470             _state = state;
471             _connection = connection;
472             _server = (IBluetoothServerSocket)server;
473         }
474
475         /// <summary>
476         /// The BluetoothError result.
477         /// </summary>
478         public BluetoothError Result
479         {
480             get
481             {
482                 return _result;
483             }
484         }
485
486         /// <summary>
487         /// The socket state.
488         /// </summary>
489         public BluetoothSocketState State
490         {
491             get
492             {
493                 return _state;
494             }
495         }
496
497         /// <summary>
498         /// The socket connection.
499         /// </summary>
500         public SocketConnection Connection
501         {
502             get
503             {
504                 return _connection;
505             }
506         }
507
508         /// <summary>
509         /// The server socket instance.
510         /// </summary>
511         public IBluetoothServerSocket Server
512         {
513             get
514             {
515                 return _server;
516             }
517         }
518     }
519
520     /// <summary>
521     /// An extended EventArgs class contains the connection state, remote address, and the type of audio profile.
522     /// </summary>
523     public class AudioConnectionStateChangedEventArgs : EventArgs
524     {
525         private int _result;
526         private bool _isConnected;
527         private string _address;
528         private BluetoothAudioProfileType _type;
529
530         internal AudioConnectionStateChangedEventArgs(int result, bool isConnected, string address, BluetoothAudioProfileType type)
531         {
532             _result = result;
533             _type = type;
534             _isConnected = isConnected;
535             _address = address;
536         }
537
538         /// <summary>
539         /// The result.
540         /// </summary>
541         public int Result
542         {
543             get
544             {
545                 return _result;
546             }
547         }
548
549         /// <summary>
550         /// A value indicating whether this instance is connected.
551         /// </summary>
552         public bool IsConnected
553         {
554             get
555             {
556                 return _isConnected;
557             }
558         }
559
560         /// <summary>
561         /// The address.
562         /// </summary>
563         public string Address
564         {
565             get
566             {
567                 return _address;
568             }
569         }
570
571         /// <summary>
572         /// The type of the audio profile.
573         /// </summary>
574         public BluetoothAudioProfileType ProfileType
575         {
576             get
577             {
578                 return _type;
579             }
580         }
581     }
582
583     /// <summary>
584     /// An extended EventArgs class contains the connection state and the address of the remote Bluetooth device.
585     /// </summary>
586     public class HidConnectionStateChangedEventArgs : EventArgs
587     {
588         private int _result;
589         private bool _isConnected;
590         private string _address;
591
592         internal HidConnectionStateChangedEventArgs(int result, bool isConnected, string address)
593         {
594             _result = result;
595             _isConnected = isConnected;
596             _address = address;
597         }
598
599         /// <summary>
600         /// The result.
601         /// </summary>
602         public int Result
603         {
604             get
605             {
606                 return _result;
607             }
608         }
609
610         /// <summary>
611         /// A value indicating whether this instance is connected.
612         /// </summary>
613         public bool IsConnected
614         {
615             get
616             {
617                 return _isConnected;
618             }
619         }
620
621         /// <summary>
622         /// The address.
623         /// </summary>
624         public string Address
625         {
626             get
627             {
628                 return _address;
629             }
630         }
631     }
632
633     /// <summary>
634     /// An extended EventArgs class contains the changed equalizer state.
635     /// </summary>
636     public class EqualizerStateChangedEventArgs : EventArgs
637     {
638         private EqualizerState _state;
639
640         internal EqualizerStateChangedEventArgs(EqualizerState state)
641         {
642             _state = state;
643         }
644
645         /// <summary>
646         /// The state of the equalizer.
647         /// </summary>
648         public EqualizerState State
649         {
650             get
651             {
652                 return _state;
653             }
654         }
655     }
656
657     /// <summary>
658     /// An extended EventArgs class contains the changed repeat mode.
659     /// </summary>
660     public class RepeatModeChangedEventArgs : EventArgs
661     {
662         private RepeatMode _mode;
663
664         internal RepeatModeChangedEventArgs(RepeatMode mode)
665         {
666             _mode = mode;
667         }
668
669         /// <summary>
670         /// The repeat mode.
671         /// </summary>
672         public RepeatMode Mode
673         {
674             get
675             {
676                 return _mode;
677             }
678         }
679     }
680
681     /// <summary>
682     /// An extended EventArgs class contains the changed shuffle mode.
683     /// </summary>
684     public class ShuffleModeChangedeventArgs : EventArgs
685     {
686         private ShuffleMode _mode;
687
688         internal ShuffleModeChangedeventArgs(ShuffleMode mode)
689         {
690             _mode = mode;
691         }
692
693         /// <summary>
694         /// The shuffle mode.
695         /// </summary>
696         public ShuffleMode Mode
697         {
698             get
699             {
700                 return _mode;
701             }
702         }
703     }
704
705     /// <summary>
706     /// An extended EventArgs class contains the changed scan mode.
707     /// </summary>
708     public class ScanModeChangedEventArgs : EventArgs
709     {
710         private ScanMode _mode;
711
712         internal ScanModeChangedEventArgs(ScanMode mode)
713         {
714             _mode = mode;
715         }
716
717         /// <summary>
718         /// The scan mode.
719         /// </summary>
720         public ScanMode Mode
721         {
722             get
723             {
724                 return _mode;
725             }
726         }
727     }
728
729     /// <summary>
730     /// An extended EventArgs class contains the connection state and the remote device address.
731     /// </summary>
732     public class TargetConnectionStateChangedEventArgs : EventArgs
733     {
734         private bool _isConnected;
735         private string _address;
736
737         internal TargetConnectionStateChangedEventArgs(bool isConnected, string address)
738         {
739             _isConnected = isConnected;
740             _address = address;
741         }
742
743         /// <summary>
744         /// A value indicating whether this instance is connected.
745         /// </summary>
746         public bool IsConnected
747         {
748             get
749             {
750                 return _isConnected;
751             }
752         }
753
754         /// <summary>
755         /// The address.
756         /// </summary>
757         public string Address
758         {
759             get
760             {
761                 return _address;
762             }
763         }
764     }
765
766     /// <summary>
767     /// An extended EventArgs class contains the changed Bluetooth LE advertising state changed information.
768     /// </summary>
769     public class AdvertisingStateChangedEventArgs : EventArgs
770     {
771         private BluetoothLeAdvertisingState _state;
772         private int _result;
773         private IntPtr _advertiserHandle;
774
775                 //TODO : Add conversion code from IntPtr to BluetoothLeAdvertiser class later
776         internal AdvertisingStateChangedEventArgs(int result, IntPtr advertiserHandle,
777             BluetoothLeAdvertisingState state)
778         {
779             _result = result;
780             _advertiserHandle = advertiserHandle;
781             _state = state;
782         }
783
784         /// <summary>
785         /// The result.
786         /// </summary>
787         public int Result
788         {
789             get
790             {
791                 return _result;
792             }
793         }
794
795         /// <summary>
796         /// The advertiser handle.
797         /// </summary>
798         public IntPtr AdvertiserHandle
799         {
800             get
801             {
802                 return _advertiserHandle;
803             }
804         }
805
806         /// <summary>
807         /// The LE advertising state.
808         /// </summary>
809         public BluetoothLeAdvertisingState State
810         {
811             get
812             {
813                 return _state;
814             }
815         }
816     }
817
818     /// <summary>
819     /// An extended EventArgs class contains the changed Bluetooth LE scan result information.
820     /// </summary>
821     public class AdapterLeScanResultChangedEventArgs : EventArgs
822     {
823         private BluetoothLeDevice _deviceData;
824         private BluetoothError _result;
825
826         internal AdapterLeScanResultChangedEventArgs(BluetoothError result, BluetoothLeDevice deviceData)
827         {
828             _deviceData = deviceData;
829             _result = result;
830         }
831
832         /// <summary>
833         /// The result.
834         /// </summary>
835         public BluetoothError Result
836         {
837             get
838             {
839                 return _result;
840             }
841         }
842
843         /// <summary>
844         /// The LE device data.
845         /// </summary>
846         public BluetoothLeDevice DeviceData
847         {
848             get
849             {
850                 return _deviceData;
851             }
852         }
853     }
854
855     /// <summary>
856     /// An extended EventArgs class contains the changed Bluetooth LE GATT connection state.
857     /// </summary>
858     public class GattConnectionStateChangedEventArgs : EventArgs
859     {
860         private bool _isConnected;
861         private int _result;
862         private string _remoteAddress;
863
864         internal GattConnectionStateChangedEventArgs(int result, bool connected, string remoteAddress)
865         {
866             _isConnected = connected;
867             _result = result;
868             _remoteAddress = remoteAddress;
869         }
870
871         /// <summary>
872         /// The result.
873         /// </summary>
874         public int Result
875         {
876             get
877             {
878                 return _result;
879             }
880         }
881
882         /// <summary>
883         /// A value indicating whether this instance is connected.
884         /// </summary>
885         public bool IsConnected
886         {
887             get
888             {
889                 return _isConnected;
890             }
891         }
892
893         /// <summary>
894         /// The remote address.
895         /// </summary>
896         public string RemoteAddress
897         {
898             get
899             {
900                 return _remoteAddress;
901             }
902         }
903     }
904
905     /// <summary>
906     /// An extended EventArgs class contains the changed attribute value.
907     /// </summary>
908     public class ValueChangedEventArgs : EventArgs
909     {
910         internal ValueChangedEventArgs(byte[] value)
911         {
912             Value = value;
913         }
914
915         /// <summary>
916         /// The attribute value.
917         /// </summary>
918         public byte[] Value { get; }
919     }
920
921     /// <summary>
922     /// An extended EventArgs class contains the read value request data.
923     /// </summary>
924     public class ReadRequestedEventArgs : EventArgs
925     {
926         internal ReadRequestedEventArgs(BluetoothGattServer server, string clientAddress, int requestId, int offset)
927         {
928             Server = server;
929             ClientAddress = clientAddress;
930             RequestId = requestId;
931             Offset = offset;
932         }
933
934         /// <summary>
935         /// The GATT server instance.
936         /// </summary>
937         public BluetoothGattServer Server { get; }
938         /// <summary>
939         /// The client address.
940         /// </summary>
941         public string ClientAddress { get; }
942         /// <summary>
943         /// The request identifier.
944         /// </summary>
945         public int RequestId { get; }
946         /// <summary>
947         /// The offset.
948         /// </summary>
949         public int Offset { get; }
950     }
951
952     /// <summary>
953     /// An extended EventArgs class contains the read value request data.
954     /// </summary>
955     public class WriteRequestedEventArgs : EventArgs
956     {
957         internal WriteRequestedEventArgs(BluetoothGattServer server, string clientAddress, int requestId, byte[] value, int offset, bool response_needed)
958         {
959             Server = server;
960             ClientAddress = clientAddress;
961             RequestId = requestId;
962             Value = value;
963             Offset = offset;
964             Response_needed = response_needed;
965         }
966
967         /// <summary>
968         /// The GATT server instance.
969         /// </summary>
970         public BluetoothGattServer Server { get; }
971         /// <summary>
972         /// The client address.
973         /// </summary>
974         public string ClientAddress { get; }
975         /// <summary>
976         /// The request identifier.
977         /// </summary>
978         public int RequestId { get; }
979         /// <summary>
980         /// The read value.
981         /// </summary>
982         public byte[] Value { get; }
983         /// <summary>
984         /// The offset.
985         /// </summary>
986         public int Offset { get; }
987         /// <summary>
988         /// Indicates whether a response is required by the remote device.
989         /// </summary>
990         public bool Response_needed { get; }
991     }
992
993     /// <summary>
994     /// An extended EventArgs class contains the client preference to enable or disable the Notification/Indication.
995     /// </summary>
996     public class NotificationStateChangedEventArg : EventArgs
997     {
998         internal NotificationStateChangedEventArg(BluetoothGattServer server, bool value)
999         {
1000             Server = server;
1001             Value = value;
1002         }
1003
1004         /// <summary>
1005         /// The GATT server instance.
1006         /// </summary>
1007         public BluetoothGattServer Server { get; }
1008         /// <summary>
1009         /// A value indicating whether the notification is enabled.
1010         /// </summary>
1011         public bool Value { get; }
1012     }
1013
1014     /// <summary>
1015     /// An extended EventArgs class contains the read value request data.
1016     /// </summary>
1017     public class NotificationSentEventArg : EventArgs
1018     {
1019         internal NotificationSentEventArg(BluetoothGattServer server, string clientAddress, int result, bool completed)
1020         {
1021             Result = result;
1022             ClientAddress = clientAddress;
1023             Server = server;
1024             Completed = completed;
1025         }
1026
1027         /// <summary>
1028         /// The GATT server instance.
1029         /// </summary>
1030         public BluetoothGattServer Server { get; }
1031         /// <summary>
1032         /// The client address.
1033         /// </summary>
1034         public string ClientAddress { get; }
1035         /// <summary>
1036         /// The result.
1037         /// </summary>
1038         public int Result { get; }
1039         /// <summary>
1040         /// Gets a value indicating whether the notification sent is completed.
1041         /// </summary>
1042         public bool Completed { get; }
1043     }
1044 }