Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.NotificationEventListener / Tizen.Applications.NotificationEventListener / NotificationAccessoryArgsBinder.cs
1 /*
2  * Copyright (c) 2017 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 namespace Tizen.Applications.NotificationEventListener
18 {
19     internal static class NotificationAccessoryAgsBinder
20     {
21         internal static void BindObject(NotificationEventArgs eventargs)
22         {
23             AccessoryOption type;
24             int color;
25             string path;
26
27             NotificationEventArgs.AccessoryArgs accessory = new NotificationEventArgs.AccessoryArgs();
28
29             Interop.NotificationEventListener.GetLed(eventargs.Handle, out type, out color);
30             accessory.LedOption = type;
31             if (type != AccessoryOption.Off)
32             {
33                 int on, off;
34
35                 Interop.NotificationEventListener.GetLedTime(eventargs.Handle, out on, out off);
36                 accessory.LedOnMillisecond = on;
37                 accessory.LedOffMillisecond = off;
38
39                 if (type == AccessoryOption.Custom)
40                 {
41                     accessory.LedColor = new Common.Color(color >> 16 & 255, color >> 8 & 255, color >> 0 & 255, color >> 24 & 255);
42                 }
43             }
44
45             Interop.NotificationEventListener.GetSound(eventargs.Handle, out type, out path);
46             accessory.SoundOption = type;
47             if (type == AccessoryOption.Custom)
48             {
49                 accessory.SoundPath = path;
50             }
51
52             Interop.NotificationEventListener.GetVibration(eventargs.Handle, out type, out path);
53             if (type == AccessoryOption.Off)
54             {
55                 accessory.CanVibrate = false;
56             }
57             else
58             {
59                 accessory.CanVibrate = true;
60             }
61
62             eventargs.Accessory = accessory;
63         }
64     }
65 }