From a9746878deca88911f66bd0aeed623d46ea565e2 Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 20 Jun 2016 15:53:06 +0530 Subject: [PATCH] Adding system-settings module Implementation + TCTs Modified the Tizen.System.SystemSettings namespace to Tizen.System Change-Id: I2f5cfae46a328a816b3ac5b686f9b4a62d498911 Signed-off-by: Aditya --- src/Tizen.System/Interop/Interop.SystemSettings.cs | 45 + src/Tizen.System/SystemSettings/SystemSettings.cs | 1727 ++++++++++++++++++++ .../SystemSettings/SystemSettingsEnums.cs | 171 ++ .../SystemSettings/SystemSettingsEventArgs.cs | 917 +++++++++++ .../SystemSettingsExceptionFactory.cs | 44 + src/Tizen.System/Tizen.System.csproj | 7 +- 6 files changed, 2910 insertions(+), 1 deletion(-) create mode 100644 src/Tizen.System/Interop/Interop.SystemSettings.cs create mode 100644 src/Tizen.System/SystemSettings/SystemSettings.cs create mode 100644 src/Tizen.System/SystemSettings/SystemSettingsEnums.cs create mode 100644 src/Tizen.System/SystemSettings/SystemSettingsEventArgs.cs create mode 100644 src/Tizen.System/SystemSettings/SystemSettingsExceptionFactory.cs diff --git a/src/Tizen.System/Interop/Interop.SystemSettings.cs b/src/Tizen.System/Interop/Interop.SystemSettings.cs new file mode 100644 index 0000000..df56956 --- /dev/null +++ b/src/Tizen.System/Interop/Interop.SystemSettings.cs @@ -0,0 +1,45 @@ +/// Copyright 2016 by Samsung Electronics, Inc., +/// +/// This software is the confidential and proprietary information +/// of Samsung Electronics, Inc. ("Confidential Information"). You +/// shall not disclose such Confidential Information and shall use +/// it only in accordance with the terms of the license agreement +/// you entered into with Samsung. + + +using System; +using System.Runtime.InteropServices; +using Tizen.System; + +internal static partial class Interop +{ + internal static partial class Settings + { + [DllImport("capi-system-system-settings.so.0", EntryPoint = "system_settings_set_value_int", CallingConvention = CallingConvention.Cdecl)] + internal static extern int SystemSettingsSetValueInt(SystemSettingsKeys key, int value); + + [DllImport("capi-system-system-settings.so.0", EntryPoint = "system_settings_set_value_bool", CallingConvention = CallingConvention.Cdecl)] + internal static extern int SystemSettingsSetValueBool(SystemSettingsKeys key, bool value); + + [DllImport("capi-system-system-settings.so.0", EntryPoint = "system_settings_set_value_string", CallingConvention = CallingConvention.Cdecl)] + internal static extern int SystemSettingsSetValueString(SystemSettingsKeys key, string value); + + + [DllImport("capi-system-system-settings.so.0", EntryPoint = "system_settings_get_value_int", CallingConvention = CallingConvention.Cdecl)] + internal static extern int SystemSettingsGetValueInt(SystemSettingsKeys key, out int value); + + [DllImport("capi-system-system-settings.so.0", EntryPoint = "system_settings_get_value_bool", CallingConvention = CallingConvention.Cdecl)] + internal static extern int SystemSettingsGetValueBool(SystemSettingsKeys key, out bool value); + + [DllImport("capi-system-system-settings.so.0", EntryPoint = "system_settings_get_value_string", CallingConvention = CallingConvention.Cdecl)] + internal static extern int SystemSettingsGetValueString(SystemSettingsKeys key, out string value); + + // Callback + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void SystemSettingsChangedCallback(SystemSettingsKeys key, IntPtr data); + [DllImport("capi-system-system-settings.so.0", EntryPoint = "system_settings_set_changed_cb", CallingConvention = CallingConvention.Cdecl)] + internal static extern int SystemSettingsSetCallback(SystemSettingsKeys systemSettingsKey, SystemSettingsChangedCallback cb, IntPtr data); + [DllImport("capi-system-system-settings.so.0", EntryPoint = "system_settings_unset_changed_cb", CallingConvention = CallingConvention.Cdecl)] + internal static extern int SystemSettingsRemoveCallback(SystemSettingsKeys systemSettingsKey); + } +} diff --git a/src/Tizen.System/SystemSettings/SystemSettings.cs b/src/Tizen.System/SystemSettings/SystemSettings.cs new file mode 100644 index 0000000..e20325b --- /dev/null +++ b/src/Tizen.System/SystemSettings/SystemSettings.cs @@ -0,0 +1,1727 @@ +using System; + +namespace Tizen.System +{ + /// + /// The System Settings API provides APIs for sharing configuration over a system + /// + /// + /// System Settings API provides functions for getting the system configuration related to user preferences. + /// The main features of the System Settings API include accessing system-wide configurations, such as ringtones, wallpapers, and etc + /// + public static class SystemSettings + { + /// + /// The file path of the current ringtone + /// + public static string IncomingCallRingtone + { + get + { + string filePath; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.IncomingCallRingtone, out filePath); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get IncomingCallRingtone system setting value."); + } + return filePath; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.IncomingCallRingtone, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set IncomingCallRingtone system setting."); + } + } + } + + /// + /// The file path of the current home screen wallpaper + /// + public static string WallpaperHomeScreen + { + get + { + string filePath; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.WallpaperHomeScreen, out filePath); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get WallpaperHomeScreen system setting value."); + } + return filePath; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.WallpaperHomeScreen, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set WallpaperHomeScreen system setting."); + } + } + } + + /// + /// The file path of the current lock screen wallpaper + /// + public static string WallpaperLockScreen + { + get + { + string filePath; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.WallpaperLockScreen, out filePath); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get WallpaperLockScreen system setting value."); + } + return filePath; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.WallpaperLockScreen, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set WallpaperLockScreen system setting."); + } + } + } + + /// + /// The current system font size + /// + public static SystemSettingsFontSize FontSize + { + get + { + int fontSize; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueInt(SystemSettingsKeys.FontSize, out fontSize); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get FontSize system setting value."); + } + return (SystemSettingsFontSize)fontSize; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueInt(SystemSettingsKeys.FontSize, (int)value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set FontSize system setting."); + } + } + } + + /// + /// The current system font type + /// + public static string FontType + { + get + { + string fontType; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.FontType, out fontType); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get FontType system setting value."); + } + return fontType; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.FontType, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set FontType system setting."); + } + } + } + + /// + /// Indicates whether the motion service is activated + /// + public static bool MotionActivationEnabled + { + get + { + bool isMotionServiceActivated; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.MotionActivationEnabled, out isMotionServiceActivated); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get MotionActivation system setting value."); + } + return isMotionServiceActivated; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.MotionActivationEnabled, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set MotionActivation system setting."); + } + } + } + + /// + /// The file path of the current email alert ringtone + /// + public static string EmailAlertRingtone + { + get + { + string filePath; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.EmailAlertRingtone, out filePath); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get EmailAlertRingtone system setting value."); + } + return filePath; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.EmailAlertRingtone, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set EmailAlertRingtone system setting."); + } + } + } + /// + /// Indicates whether the USB debugging is enabled (Since 2.4) + /// + public static bool UsbDebuggingEnabled + { + get + { + bool isusbDebuggingEnabled; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.UsbDebuggingEnabled, out isusbDebuggingEnabled); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get UsbDebuggingEnabled system setting value."); + } + return isusbDebuggingEnabled; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.UsbDebuggingEnabled, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set UsbDebuggingEnabled system setting."); + } + } + } + + /// + /// Indicates whether the 3G data network is enabled (Since 2.4) + /// + public static bool Data3GNetworkEnabled + { + get + { + bool is3GDataEnabled; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.Data3GNetworkEnabled, out is3GDataEnabled); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get Data3GNetworkEnabled system setting value."); + } + return is3GDataEnabled; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.Data3GNetworkEnabled, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set Data3GNetworkEnabled system setting."); + } + } + } + + /// + /// Indicates lockscreen app pkg name + /// + public static string LockscreenApp + { + get + { + string pkgName; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.LockscreenApp, out pkgName); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LockscreenApp system setting value."); + } + return pkgName; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.LockscreenApp, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LockscreenApp system setting."); + } + } + } + + /// + /// The current system default font type (only support Get) + /// + public static string DefaultFontType + { + get + { + string defaultFontType; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.DefaultFontType, out defaultFontType); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get DefaultFontType system setting value."); + } + return defaultFontType; + } + } + + /// + /// Indicates the current country setting in the _ syntax. + /// The country setting is in the ISO 639-2 format, + /// and the region setting is in the ISO 3166-1 alpha-2 format + /// + public static string LocaleCountry + { + get + { + string countrySetting; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.LocaleCountry, out countrySetting); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LocaleCountry system setting value."); + } + return countrySetting; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.LocaleCountry, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LocaleCountry system setting."); + } + } + } + + /// + /// Indicates the current language setting in the _ syntax. + /// The language setting is in the ISO 639-2 format + /// and the region setting is in the ISO 3166-1 alpha-2 format. + /// + public static string LocaleLanguage + { + get + { + string languageSetting; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.LocaleLanguage, out languageSetting); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LocaleLanguage system setting value."); + } + return languageSetting; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.LocaleLanguage, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LocaleLanguage system setting."); + } + } + } + + /// + /// Indicates whether the 24-hour clock is used. + /// If the value is false, the 12-hour clock is used. + /// + public static bool LocaleTimeFormat24HourEnabled + { + get + { + bool is24HrFormat; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.LocaleTimeFormat24HourEnabled, out is24HrFormat); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LocaleTimeFormat24Hour system setting value."); + } + return is24HrFormat; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.LocaleTimeFormat24HourEnabled, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LocaleTimeFormat24Hour system setting."); + } + } + } + + /// + /// Indicates the current time zone. + /// + public static string LocaleTimeZone + { + get + { + string timeZone; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.LocaleTimeZone, out timeZone); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LocaleTimeZone system setting value."); + } + return timeZone; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.LocaleTimeZone, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LocaleTimeZone system setting."); + } + } + } + /// + /// Indicates whether the screen lock sound is enabled on the device. ex) LCD on/off sound + /// + public static bool SoundLockEnabled + { + get + { + bool isSoundLockEnabled; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.SoundLockEnabled, out isSoundLockEnabled); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundLock system setting value."); + } + return isSoundLockEnabled; + } + } + + /// + /// Indicates whether the device is in the silent mode. + /// + public static bool SoundSilentModeEnabled + { + get + { + bool isSilent; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.SoundSilentModeEnabled, out isSilent); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundSilentMode system setting value."); + } + return isSilent; + } + } + + /// + /// Indicates whether the screen touch sound is enabled on the device. + /// + public static bool SoundTouchEnabled + { + get + { + bool isTouchSoundEnabled; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.SoundTouchEnabled, out isTouchSoundEnabled); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundTouch system setting value."); + } + return isTouchSoundEnabled; + } + } + + /// + /// Indicates whether rotation control is automatic. + /// + public static bool DisplayScreenRotationAutoEnabled + { + get + { + bool isRotationAutomatic; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.DisplayScreenRotationAutoEnabled, out isRotationAutomatic); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get DisplayScreenRotationAuto system setting value."); + } + return isRotationAutomatic; + } + } + + /// + /// Indicates device name. + /// + public static string DeviceName + { + get + { + string deviceName; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.DeviceName, out deviceName); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get DeviceName system setting value."); + } + return deviceName; + } + } + /// + /// Indicates whether the device user has enabled motion feature. + /// + public static bool MotionEnabled + { + get + { + bool isMotionEnabled; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.MotionEnabled, out isMotionEnabled); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get MotionEnabled system setting value."); + } + return isMotionEnabled; + } + } + + /// + /// Indicates whether Wi-Fi-related notifications are enabled on the device. + /// + public static bool NetworkWifiNotificationEnabled + { + get + { + bool isWifiNotificationEnabled; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.NetworkWifiNotificationEnabled, out isWifiNotificationEnabled); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get NetworkWifiNotification system setting value."); + } + return isWifiNotificationEnabled; + } + } + + /// + /// Indicates whether the device is in the flight mode. + /// + public static bool NetworkFlightModeEnabled + { + get + { + bool isFlightModeEnabled; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.NetworkFlightModeEnabled, out isFlightModeEnabled); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get NetworkFlightMode system setting value."); + } + return isFlightModeEnabled; + } + } + + /// + /// Indicates the backlight time (in seconds). The following values can be used: 15, 30, 60, 120, 300, and 600. + /// + public static int ScreenBacklightTime + { + get + { + int backlightTime; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueInt(SystemSettingsKeys.ScreenBacklightTime, out backlightTime); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get ScreenBacklightTime system setting value."); + } + return backlightTime; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueInt(SystemSettingsKeys.ScreenBacklightTime, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set ScreenBacklightTime system setting."); + } + } + } + + /// + /// Indicates the file path of the current notification tone set by the user. + /// + public static string SoundNotification + { + get + { + string filePath; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.SoundNotification, out filePath); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundNotification system setting value."); + } + return filePath; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.SoundNotification, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set SoundNotification system setting."); + } + } + } + + /// + /// Indicates the time period for notification repetitions. + /// + public static int SoundNotificationRepetitionPeriod + { + get + { + int notificationRepetitionPeriod; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueInt(SystemSettingsKeys.SoundNotificationRepetitionPeriod, out notificationRepetitionPeriod); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundNotificationRepetitionPeriod system setting value."); + } + return notificationRepetitionPeriod; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueInt(SystemSettingsKeys.SoundNotificationRepetitionPeriod, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set SoundNotificationRepetitionPeriod system setting."); + } + } + } + + /// + /// Indicates the current lock state + /// + public static SystemSettingsIdleLockState LockState + { + get + { + int LockState; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueInt(SystemSettingsKeys.LockState, out LockState); + if (res != SystemSettingsError.None) + { + Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LockState system setting value."); + } + return (SystemSettingsIdleLockState)LockState; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueInt(SystemSettingsKeys.LockState, (int)value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LockState system setting."); + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_incomingCallRingtoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string path = SystemSettings.IncomingCallRingtone; + IncomingCallRingtoneChangedEventArgs eventArgs = new IncomingCallRingtoneChangedEventArgs(path); + s_incomingCallRingtoneChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_incomingCallRingtoneChanged; + /// + /// IncomingCallRingtoneChanged event is triggered when the file path of the incoming ringtone is changed + /// + /// + /// A IncomingCallRingtoneChangedEventArgs object that contains the key & changed value + public static event EventHandler IncomingCallRingtoneChanged + { + add + { + if (s_incomingCallRingtoneChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.IncomingCallRingtone, s_incomingCallRingtoneChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_incomingCallRingtoneChanged += value; + } + + remove + { + s_incomingCallRingtoneChanged -= value; + if (s_incomingCallRingtoneChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.IncomingCallRingtone); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_wallpaperHomeScreenChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string path = SystemSettings.WallpaperHomeScreen; + WallpaperHomeScreenChangedEventArgs eventArgs = new WallpaperHomeScreenChangedEventArgs(path); + s_wallpaperHomeScreenChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_wallpaperHomeScreenChanged; + /// + /// WallpaperHomeScreenChanged event is triggered when the file path of the current home screen wallpaper is changed + /// + /// + /// A WallpaperHomeScreenChangedEventArgs object that contains the key & changed value + public static event EventHandler WallpaperHomeScreenChanged + { + add + { + if (s_wallpaperHomeScreenChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.WallpaperHomeScreen, s_wallpaperHomeScreenChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_wallpaperHomeScreenChanged += value; + } + + remove + { + s_wallpaperHomeScreenChanged -= value; + if (s_wallpaperHomeScreenChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.WallpaperHomeScreen); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_wallpaperLockScreenChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string path = SystemSettings.WallpaperLockScreen; + WallpaperLockScreenChangedEventArgs eventArgs = new WallpaperLockScreenChangedEventArgs(path); + s_wallpaperLockScreenChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_wallpaperLockScreenChanged; + /// + /// WallpaperLockScreenChanged event is triggered when the file path of the current lock screen wallpaper is changed + /// + /// + /// A WallpaperLockScreenChangedEventArgs object that contains the key & changed value + public static event EventHandler WallpaperLockScreenChanged + { + add + { + if (s_wallpaperLockScreenChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.WallpaperLockScreen, s_wallpaperLockScreenChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_wallpaperLockScreenChanged += value; + } + + remove + { + s_wallpaperLockScreenChanged -= value; + if (s_wallpaperLockScreenChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.WallpaperLockScreen); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_fontSizeChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + SystemSettingsFontSize fontSize = SystemSettings.FontSize; + FontSizeChangedEventArgs eventArgs = new FontSizeChangedEventArgs(fontSize); + s_fontSizeChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_fontSizeChanged; + /// + /// FontSizeChanged event is triggered when the current system font size is changed + /// + /// + /// A FontSizeChangedEventArgs object that contains the key & changed value + public static event EventHandler FontSizeChanged + { + add + { + if (s_fontSizeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.FontSize, s_fontSizeChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_fontSizeChanged += value; + } + + remove + { + s_fontSizeChanged -= value; + if (s_fontSizeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.FontSize); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_fontTypeChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string fontType = SystemSettings.FontType; + FontTypeChangedEventArgs eventArgs = new FontTypeChangedEventArgs(fontType); + s_fontTypeChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_fontTypeChanged; + /// + /// FontTypeChanged event is triggered when the current system font type is changed + /// + /// + /// A FontTypeChangedEventArgs object that contains the key & changed value + public static event EventHandler FontTypeChanged + { + add + { + if (s_fontTypeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.FontType, s_fontTypeChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_fontTypeChanged += value; + } + + remove + { + s_fontTypeChanged -= value; + if (s_fontTypeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.FontType); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_motionActivationChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool motionActivation = SystemSettings.MotionActivationEnabled; + MotionActivationSettingChangedEventArgs eventArgs = new MotionActivationSettingChangedEventArgs(motionActivation); + s_motionActivationChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_motionActivationChanged; + /// + /// MotionActivationChanged event is triggered when the motion service status is changed + /// + /// + /// A MotionActivationChangedEventArgs object that contains the key & changed value + public static event EventHandler MotionActivationSettingChanged + { + add + { + if (s_motionActivationChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.MotionActivationEnabled, s_motionActivationChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_motionActivationChanged += value; + } + + remove + { + s_motionActivationChanged -= value; + if (s_motionActivationChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.MotionActivationEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_emailAlertRingtoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string emailAlertRingtone = SystemSettings.EmailAlertRingtone; + EmailAlertRingtoneChangedEventArgs eventArgs = new EmailAlertRingtoneChangedEventArgs(emailAlertRingtone); + s_emailAlertRingtoneChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_emailAlertRingtoneChanged; + /// + /// EmailAlertRingtoneChanged event is triggered when the file path of the current email alert ringtone is changed + /// + /// + /// A EmailAlertRingtoneChangedEventArgs object that contains the key & changed value + public static event EventHandler EmailAlertRingtoneChanged + { + add + { + if (s_emailAlertRingtoneChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.EmailAlertRingtone, s_emailAlertRingtoneChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_emailAlertRingtoneChanged += value; + } + + remove + { + s_emailAlertRingtoneChanged -= value; + if (s_emailAlertRingtoneChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.EmailAlertRingtone); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_usbDebuggingSettingChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool usbDebuggingEnabled = SystemSettings.UsbDebuggingEnabled; + UsbDebuggingSettingChangedEventArgs eventArgs = new UsbDebuggingSettingChangedEventArgs(usbDebuggingEnabled); + s_usbDebuggingSettingChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_usbDebuggingSettingChanged; + /// + /// UsbDebuggingSettingChangedEventArgs event is triggered when the USB debugging status is changed + /// + /// + /// A UsbDebuggingSettingChangedEventArgs object that contains the key & changed value + public static event EventHandler UsbDebuggingSettingChanged + { + add + { + if (s_usbDebuggingSettingChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.UsbDebuggingEnabled, s_usbDebuggingSettingChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_usbDebuggingSettingChanged += value; + } + + remove + { + s_usbDebuggingSettingChanged -= value; + if (s_usbDebuggingSettingChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.UsbDebuggingEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_data3GNetworkSettingChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool data3GEnabled = SystemSettings.Data3GNetworkEnabled; + Data3GNetworkSettingChangedEventArgs eventArgs = new Data3GNetworkSettingChangedEventArgs(data3GEnabled); + s_data3GNetworkSettingChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_data3GNetworkSettingChanged; + /// + /// Data3GNetworkSettingChanged event is triggered when the 3G data network status is changed + /// + /// + /// A Data3GNetworkSettingChangedEventArgs object that contains the key & changed value + public static event EventHandler Data3GNetworkSettingChanged + { + add + { + if (s_data3GNetworkSettingChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.Data3GNetworkEnabled, s_data3GNetworkSettingChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_data3GNetworkSettingChanged += value; + } + + remove + { + s_data3GNetworkSettingChanged -= value; + if (s_data3GNetworkSettingChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.Data3GNetworkEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_lockscreenAppChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string lockScreenApp = SystemSettings.LockscreenApp; + LockscreenAppChangedEventArgs eventArgs = new LockscreenAppChangedEventArgs(lockScreenApp); + s_lockscreenAppChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_lockscreenAppChanged; + /// + /// LockscreenAppChanged event is triggered when the lockscreen app pkg name is changed + /// + /// + /// A LockscreenAppChangedEventArgs object that contains the key & changed value + public static event EventHandler LockscreenAppChanged + { + add + { + if (s_lockscreenAppChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LockscreenApp, s_lockscreenAppChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_lockscreenAppChanged += value; + } + + remove + { + s_lockscreenAppChanged -= value; + if (s_lockscreenAppChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LockscreenApp); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_localeCountryChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string localeCountry = SystemSettings.LocaleCountry; + LocaleCountryChangedEventArgs eventArgs = new LocaleCountryChangedEventArgs(localeCountry); + s_localeCountryChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_localeCountryChanged; + /// + /// LocaleCountryChanged event is triggered when the current country setting in the _ syntax, is changed + /// + /// + /// A LocaleCountryChangedEventArgs object that contains the key & changed value + public static event EventHandler LocaleCountryChanged + { + add + { + if (s_localeCountryChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LocaleCountry, s_localeCountryChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_localeCountryChanged += value; + } + + remove + { + s_localeCountryChanged -= value; + if (s_localeCountryChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LocaleCountry); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_localeLanguageChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string localeLanguage = SystemSettings.LocaleLanguage; + LocaleLanguageChangedEventArgs eventArgs = new LocaleLanguageChangedEventArgs(localeLanguage); + s_localeLanguageChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_localeLanguageChanged; + /// + /// LocaleLanguageChanged event is triggered when the current language setting in the _ syntax, is changed + /// + /// + /// A LocaleLanguageChangedEventArgs object that contains the key & changed value + public static event EventHandler LocaleLanguageChanged + { + add + { + if (s_localeLanguageChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LocaleLanguage, s_localeLanguageChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_localeLanguageChanged += value; + } + + remove + { + s_localeLanguageChanged -= value; + if (s_localeLanguageChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LocaleLanguage); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_localeTimeFormat24HourChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool localeTimeFormat24Hour = SystemSettings.LocaleTimeFormat24HourEnabled; + LocaleTimeFormat24HourSettingChangedEventArgs eventArgs = new LocaleTimeFormat24HourSettingChangedEventArgs(localeTimeFormat24Hour); + s_localeTimeFormat24HourChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_localeTimeFormat24HourChanged; + /// + /// LocaleTimeFormat24HourChanged event is triggered when the time format is changed + /// + /// + /// A LocaleTimeFormat24HourChangedEventArgs object that contains the key & changed value + public static event EventHandler LocaleTimeFormat24HourSettingChanged + { + add + { + if (s_localeTimeFormat24HourChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LocaleTimeFormat24HourEnabled, s_localeTimeFormat24HourChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_localeTimeFormat24HourChanged += value; + } + + remove + { + s_localeTimeFormat24HourChanged -= value; + if (s_localeTimeFormat24HourChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LocaleTimeFormat24HourEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_localeTimeZoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string localeTimeZone = SystemSettings.LocaleTimeZone; + LocaleTimeZoneChangedEventArgs eventArgs = new LocaleTimeZoneChangedEventArgs(localeTimeZone); + s_localeTimeZoneChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_localeTimeZoneChanged; + /// + /// LocaleTimeZoneChanged event is triggered when the current time zone is changed + /// + /// + /// A LocaleTimeZoneChangedEventArgs object that contains the key & changed value + public static event EventHandler LocaleTimeZoneChanged + { + add + { + if (s_localeTimeZoneChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LocaleTimeZone, s_localeTimeZoneChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_localeTimeZoneChanged += value; + } + + remove + { + s_localeTimeZoneChanged -= value; + if (s_localeTimeZoneChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LocaleTimeZone); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_timeChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + //bool motionActivation = SystemSettings.Time; + TimeChangedEventArgs eventArgs = new TimeChangedEventArgs(); + s_timeChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_timeChanged; + /// + /// TimeChanged event is triggered when the system time is changed + /// + /// + /// A TimeChangedEventArgs object that contains the key & changed value + public static event EventHandler TimeChanged + { + add + { + if (s_timeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.Time, s_timeChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_timeChanged += value; + } + + remove + { + s_timeChanged -= value; + if (s_timeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.Time); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundLockChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool soundLock = SystemSettings.SoundLockEnabled; + SoundLockSettingChangedEventArgs eventArgs = new SoundLockSettingChangedEventArgs(soundLock); + s_soundLockChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_soundLockChanged; + /// + /// SoundLockChanged event is triggered when the screen lock sound enabled status is changed + /// + /// + /// A SoundLockChangedEventArgs object that contains the key & changed value + public static event EventHandler SoundLockSettingChanged + { + add + { + if (s_soundLockChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundLockEnabled, s_soundLockChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_soundLockChanged += value; + } + + remove + { + s_soundLockChanged -= value; + if (s_soundLockChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundLockEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundSilentModeChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool soundSilentMode = SystemSettings.SoundSilentModeEnabled; + SoundSilentModeSettingChangedEventArgs eventArgs = new SoundSilentModeSettingChangedEventArgs(soundSilentMode); + s_soundSilentModeChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_soundSilentModeChanged; + /// + /// SoundSilentModeChanged event is triggered when the silent mode status is changed + /// + /// + /// A SoundSilentModeChangedEventArgs object that contains the key & changed value + public static event EventHandler SoundSilentModeSettingChanged + { + add + { + if (s_soundSilentModeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundSilentModeEnabled, s_soundSilentModeChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_soundSilentModeChanged += value; + } + + remove + { + s_soundSilentModeChanged -= value; + if (s_soundSilentModeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundSilentModeEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundTouchChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool soundTouch = SystemSettings.SoundTouchEnabled; + SoundTouchSettingChangedEventArgs eventArgs = new SoundTouchSettingChangedEventArgs(soundTouch); + s_soundTouchChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_soundTouchChanged; + /// + /// SoundTouchChanged event is triggered when the screen touch sound enabled status is changed + /// + /// + /// A SoundTouchChangedEventArgs object that contains the key & changed value + public static event EventHandler SoundTouchSettingChanged + { + add + { + if (s_soundTouchChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundTouchEnabled, s_soundTouchChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_soundTouchChanged += value; + } + + remove + { + s_soundTouchChanged -= value; + if (s_soundTouchChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundTouchEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_displayScreenRotationAutoChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool displayScreenRotationAuto = SystemSettings.DisplayScreenRotationAutoEnabled; + DisplayScreenRotationAutoSettingChangedEventArgs eventArgs = new DisplayScreenRotationAutoSettingChangedEventArgs(displayScreenRotationAuto); + s_displayScreenRotationAutoChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_displayScreenRotationAutoChanged; + /// + /// DisplayScreenRotationAutoChanged event is triggered when the automatic rotation control status is changed + /// + /// + /// A DisplayScreenRotationAutoChangedEventArgs object that contains the key & changed value + public static event EventHandler DisplayScreenRotationAutoSettingChanged + { + add + { + if (s_displayScreenRotationAutoChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.DisplayScreenRotationAutoEnabled, s_displayScreenRotationAutoChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_displayScreenRotationAutoChanged += value; + } + + remove + { + s_displayScreenRotationAutoChanged -= value; + if (s_displayScreenRotationAutoChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.DisplayScreenRotationAutoEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_deviceNameChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string deviceName = SystemSettings.DeviceName; + DeviceNameChangedEventArgs eventArgs = new DeviceNameChangedEventArgs(deviceName); + s_deviceNameChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_deviceNameChanged; + /// + /// DeviceNameChanged event is triggered when the device name is changed + /// + /// + /// A DeviceNameChangedEventArgs object that contains the key & changed value + public static event EventHandler DeviceNameChanged + { + add + { + if (s_deviceNameChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.DeviceName, s_deviceNameChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_deviceNameChanged += value; + } + + remove + { + s_deviceNameChanged -= value; + if (s_deviceNameChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.DeviceName); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_motionSettingChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool motionEnabled = SystemSettings.MotionEnabled; + MotionSettingChangedEventArgs eventArgs = new MotionSettingChangedEventArgs(motionEnabled); + s_motionSettingChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_motionSettingChanged; + /// + /// MotionSettingChanged event is triggered when the motion feature enabled status is changed + /// + /// + /// A MotionSettingChangedEventArgs object that contains the key & changed value + public static event EventHandler MotionSettingChanged + { + add + { + if (s_motionSettingChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.MotionEnabled, s_motionSettingChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_motionSettingChanged += value; + } + + remove + { + s_motionSettingChanged -= value; + if (s_motionSettingChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.MotionEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_networkWifiNotificationChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool networkWifiNotification = SystemSettings.NetworkWifiNotificationEnabled; + NetworkWifiNotificationSettingChangedEventArgs eventArgs = new NetworkWifiNotificationSettingChangedEventArgs(networkWifiNotification); + s_networkWifiNotificationChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_networkWifiNotificationChanged; + /// + /// NetworkWifiNotificationChanged event is triggered when the Wi-Fi-related notifications enabled status is changed + /// + /// + /// A NetworkWifiNotificationChangedEventArgs object that contains the key & changed value + public static event EventHandler NetworkWifiNotificationSettingChanged + { + add + { + if (s_networkWifiNotificationChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.NetworkWifiNotificationEnabled, s_networkWifiNotificationChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_networkWifiNotificationChanged += value; + } + + remove + { + s_networkWifiNotificationChanged -= value; + if (s_networkWifiNotificationChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.NetworkWifiNotificationEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_networkFlightModeChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool networkFlightMode = SystemSettings.NetworkFlightModeEnabled; + NetworkFlightModeSettingChangedEventArgs eventArgs = new NetworkFlightModeSettingChangedEventArgs(networkFlightMode); + s_networkFlightModeChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_networkFlightModeChanged; + /// + /// NetworkFlightModeChanged event is triggered when the flight mode status is changed + /// + /// + /// A NetworkFlightModeChangedEventArgs object that contains the key & changed value + public static event EventHandler NetworkFlightModeSettingChanged + { + add + { + if (s_networkFlightModeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.NetworkFlightModeEnabled, s_networkFlightModeChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_networkFlightModeChanged += value; + } + + remove + { + s_networkFlightModeChanged -= value; + if (s_networkFlightModeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.NetworkFlightModeEnabled); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_screenBacklightTimeChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + int screenBacklightTime = SystemSettings.ScreenBacklightTime; + ScreenBacklightTimeChangedEventArgs eventArgs = new ScreenBacklightTimeChangedEventArgs(screenBacklightTime); + s_screenBacklightTimeChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_screenBacklightTimeChanged; + /// + /// ScreenBacklightTimeChanged event is triggered when the backlight time is changed. + /// + /// + /// A ScreenBacklightTimeChangedEventArgs object that contains the key & changed value + public static event EventHandler ScreenBacklightTimeChanged + { + add + { + if (s_screenBacklightTimeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.ScreenBacklightTime, s_screenBacklightTimeChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_screenBacklightTimeChanged += value; + } + + remove + { + s_screenBacklightTimeChanged -= value; + if (s_screenBacklightTimeChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.ScreenBacklightTime); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundNotificationChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + string soundNotification = SystemSettings.SoundNotification; + SoundNotificationChangedEventArgs eventArgs = new SoundNotificationChangedEventArgs(soundNotification); + s_soundNotificationChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_soundNotificationChanged; + /// + /// SoundNotificationChanged event is triggered when the file path of the current notification tone set by the user is changed + /// + /// + /// A SoundNotificationChangedEventArgs object that contains the key & changed value + public static event EventHandler SoundNotificationChanged + { + add + { + if (s_soundNotificationChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundNotification, s_soundNotificationChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_soundNotificationChanged += value; + } + + remove + { + s_soundNotificationChanged -= value; + if (s_soundNotificationChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundNotification); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundNotificationRepetitionPeriodChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + int soundNotificationRepetitionPeriod = SystemSettings.SoundNotificationRepetitionPeriod; + SoundNotificationRepetitionPeriodChangedEventArgs eventArgs = new SoundNotificationRepetitionPeriodChangedEventArgs(soundNotificationRepetitionPeriod); + s_soundNotificationRepetitionPeriodChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_soundNotificationRepetitionPeriodChanged; + /// + /// SoundNotificationRepetitionPeriodChanged event is triggered when the time period for notification repetitions is changed + /// + /// + /// A SoundNotificationRepetitionPeriodChangedEventArgs object that contains the key & changed value + public static event EventHandler SoundNotificationRepetitionPeriodChanged + { + add + { + if (s_soundNotificationRepetitionPeriodChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundNotificationRepetitionPeriod, s_soundNotificationRepetitionPeriodChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_soundNotificationRepetitionPeriodChanged += value; + } + + remove + { + s_soundNotificationRepetitionPeriodChanged -= value; + if (s_soundNotificationRepetitionPeriodChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundNotificationRepetitionPeriod); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_lockStateChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + SystemSettingsIdleLockState lockState = SystemSettings.LockState; + LockStateChangedEventArgs eventArgs = new LockStateChangedEventArgs(lockState); + s_lockStateChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_lockStateChanged; + /// + /// LockStateChanged event is triggered when the current lock state is changed + /// + /// + /// A LockStateChangedEventArgs object that contains the key & changed value + public static event EventHandler LockStateChanged + { + add + { + if (s_lockStateChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LockState, s_lockStateChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_lockStateChanged += value; + } + + remove + { + s_lockStateChanged -= value; + if (s_lockStateChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LockState); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + } + } + } +} + diff --git a/src/Tizen.System/SystemSettings/SystemSettingsEnums.cs b/src/Tizen.System/SystemSettings/SystemSettingsEnums.cs new file mode 100644 index 0000000..43bd94c --- /dev/null +++ b/src/Tizen.System/SystemSettings/SystemSettingsEnums.cs @@ -0,0 +1,171 @@ + +namespace Tizen.System +{ + /// + /// Enumeration for all available system settings + /// + public enum SystemSettingsKeys + { + /// + /// (string) The file path of the current ringtone + /// + IncomingCallRingtone, + /// + /// (string) The file path of the current home screen wallpaper + /// + WallpaperHomeScreen, + /// + /// (string) The file path of the current lock screen wallpaper + /// + WallpaperLockScreen, + /// + /// (int) The current system font size + /// + FontSize, + /// + /// (string) The current system font type + /// + FontType, + /// + /// (bool) Indicates whether the motion service is activated + /// + MotionActivationEnabled, + /// + /// (string) The file path of the current email alert ringtone + /// + EmailAlertRingtone, + /// + /// (bool) Indicates whether the USB debugging is enabled (Since 2.4) + /// + UsbDebuggingEnabled, + /// + /// (bool) Indicates whether the 3G data network is enabled (Since 2.4) + /// + Data3GNetworkEnabled, + /// + /// (string) Indicates lockscreen app pkg name + /// + LockscreenApp = Data3GNetworkEnabled + 2, + /// + /// (string) The current system default font type (only support Get) + /// + DefaultFontType, + /// + /// (string) Indicates the current country setting in the _ syntax. + /// The country setting is in the ISO 639-2 format, + /// and the region setting is in the ISO 3166-1 alpha-2 format + /// + LocaleCountry, + /// + /// (string) Indicates the current language setting in the _ syntax. + /// The language setting is in the ISO 639-2 format + /// and the region setting is in the ISO 3166-1 alpha-2 format. + /// + LocaleLanguage, + /// + /// (bool) Indicates whether the 24-hour clock is used. + /// If the value is false, the 12-hour clock is used. + /// + LocaleTimeFormat24HourEnabled, + /// + /// (string) Indicates the current time zone. + /// + LocaleTimeZone, + /// + /// (int) Once System changes time, this event occurs to notify time change. + /// + Time, + /// + /// GET (bool) Indicates whether the screen lock sound is enabled on the device. ex) LCD on/off sound + /// + SoundLockEnabled, + /// + /// GET (bool) Indicates whether the device is in the silent mode. + /// + SoundSilentModeEnabled, + /// + /// GET (bool) Indicates whether the screen touch sound is enabled on the device. + /// + SoundTouchEnabled, + /// + /// GET (bool) Indicates whether rotation control is automatic. + /// + DisplayScreenRotationAutoEnabled, + /// + /// GET (string) Indicates device name. + /// + DeviceName, + /// + /// GET (bool) Indicates whether the device user has enabled motion feature. + /// + MotionEnabled, + /// + /// GET (bool) Indicates whether Wi-Fi-related notifications are enabled on the device. + /// + NetworkWifiNotificationEnabled, + /// + /// GET (bool) Indicates whether the device is in the flight mode. + /// + NetworkFlightModeEnabled, + /// + /// (int) Indicates the backlight time (in seconds). The following values can be used: 15, 30, 60, 120, 300, and 600. + /// + ScreenBacklightTime, + /// + /// (string) Indicates the file path of the current notification tone set by the user. + /// + SoundNotification, + /// + /// (int) Indicates the time period for notification repetitions. + /// + SoundNotificationRepetitionPeriod, + /// + /// (int) Indicates the current lock state + /// + LockState + } + /// + /// Enumeration for Idle Lock State. + /// + public enum SystemSettingsIdleLockState + { + /// + /// Device is unlocked + /// + Unlock = 0, + /// + /// Device is locked + /// + Lock, + /// + /// Device is being locked + /// + LaunchingLock + } + /// + /// Enumeration for font size. + /// + public enum SystemSettingsFontSize + { + /// + /// A small size + /// + Small = 0, + /// + /// A normal size + /// + Normal, + /// + /// A large size + /// + Large, + /// + /// A huge size + /// + Huge, + /// + /// A giant size + /// + Giant + } +} diff --git a/src/Tizen.System/SystemSettings/SystemSettingsEventArgs.cs b/src/Tizen.System/SystemSettings/SystemSettingsEventArgs.cs new file mode 100644 index 0000000..301fede --- /dev/null +++ b/src/Tizen.System/SystemSettings/SystemSettingsEventArgs.cs @@ -0,0 +1,917 @@ +using System; + +namespace Tizen.System +{ + /// + /// EventArgs type for the event IncomingCallRingtoneChanged + /// + public class IncomingCallRingtoneChangedEventArgs : EventArgs + { + private readonly string _incomingCallRingtone = null; + /// + /// The enum for IncomingCallRingtone system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.IncomingCallRingtone; + } + } + + internal IncomingCallRingtoneChangedEventArgs(string val) + { + _incomingCallRingtone = val; + } + + /// + /// The file path of the current ringtone + /// + public string Value + { + get + { + return _incomingCallRingtone; + } + } + } + + /// + /// EventArgs type for the event WallpaperHomeScreenChanged + /// + public class WallpaperHomeScreenChangedEventArgs : EventArgs + { + private readonly string _wallpaperHomeScreen = null; + /// + /// The enum for WallpaperHomeScreen system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.WallpaperHomeScreen; + } + } + + internal WallpaperHomeScreenChangedEventArgs(string val) + { + _wallpaperHomeScreen = val; + } + + /// + /// The file path of the current home screen wallpaper + /// + public string Value + { + get + { + return _wallpaperHomeScreen; + } + } + } + + /// + /// EventArgs type for the event WallpaperLockScreenChanged + /// + public class WallpaperLockScreenChangedEventArgs : EventArgs + { + private readonly string _wallpaperLockScreen = null; + /// + /// The enum for WallpaperLockScreen system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.WallpaperLockScreen; + } + } + + internal WallpaperLockScreenChangedEventArgs(string val) + { + _wallpaperLockScreen = val; + } + + /// + /// The file path of the current lock screen wallpaper + /// + public string Value + { + get + { + return _wallpaperLockScreen; + } + } + } + + /// + /// EventArgs type for the event FontSizeChanged + /// + public class FontSizeChangedEventArgs : EventArgs + { + private readonly SystemSettingsFontSize _fontSize; + /// + /// The enum for FontSize system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.FontSize; + } + } + internal FontSizeChangedEventArgs(SystemSettingsFontSize val) + { + _fontSize = val; + } + + /// + /// The current system font size + /// + public SystemSettingsFontSize Value + { + get + { + return _fontSize; + } + } + } + + /// + /// EventArgs type for the event FontTypeChanged + /// + public class FontTypeChangedEventArgs : EventArgs + { + private readonly string _fontType = null; + /// + /// The enum for FontType system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.FontType; + } + } + internal FontTypeChangedEventArgs(string val) + { + _fontType = val; + } + + /// + /// The current system font type + /// + public string Value + { + get + { + return _fontType; + } + } + } + + /// + /// EventArgs type for the event MotionActivationChanged + /// + public class MotionActivationSettingChangedEventArgs : EventArgs + { + private readonly bool _motionActivation; + /// + /// The enum for MotionActivation system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.MotionActivationEnabled; + } + } + internal MotionActivationSettingChangedEventArgs(bool val) + { + _motionActivation = val; + } + + /// + /// Indicates whether the motion service is activated + /// + public bool Value + { + get + { + return _motionActivation; + } + } + } + + /// + /// EventArgs type for the event EmailAlertRingtoneChanged + /// + public class EmailAlertRingtoneChangedEventArgs : EventArgs + { + private readonly string _emailAlertRingtone = null; + /// + /// The enum for EmailAlertRingtone system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.EmailAlertRingtone; + } + } + internal EmailAlertRingtoneChangedEventArgs(string val) + { + _emailAlertRingtone = val; + } + + /// + /// The file path of the current email alert ringtone + /// + public string Value + { + get + { + return _emailAlertRingtone; + } + } + } + + /// + /// EventArgs type for the event UsbDebuggingSettingChanged + /// + public class UsbDebuggingSettingChangedEventArgs : EventArgs + { + private readonly bool _usbDebuggingEnabled; + /// + /// The enum for UsbDebuggingEnabled system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.UsbDebuggingEnabled; + } + } + internal UsbDebuggingSettingChangedEventArgs(bool val) + { + _usbDebuggingEnabled = val; + } + + /// + /// Indicates whether the USB debugging is enabled + /// + public bool Value + { + get + { + return _usbDebuggingEnabled; + } + } + } + + /// + /// EventArgs type for the event Data3GNetworkSettingChanged + /// + public class Data3GNetworkSettingChangedEventArgs : EventArgs + { + private readonly bool _data3GNetworkEnabled; + /// + /// The enum for Data3GNetworkEnabled system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.Data3GNetworkEnabled; + } + } + internal Data3GNetworkSettingChangedEventArgs(bool val) + { + _data3GNetworkEnabled = val; + } + + /// + /// Indicates whether the 3G data network is enabled + /// + public bool Value + { + get + { + return _data3GNetworkEnabled; + } + } + } + + /// + /// EventArgs type for the event LockscreenAppChanged + /// + public class LockscreenAppChangedEventArgs : EventArgs + { + private readonly string _lockscreenApp = null; + /// + /// The enum for LockscreenApp system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.LockscreenApp; + } + } + internal LockscreenAppChangedEventArgs(string val) + { + _lockscreenApp = val; + } + + /// + /// Indicates lockscreen app pkg name + /// + public string Value + { + get + { + return _lockscreenApp; + } + } + } + + /// + /// EventArgs type for the event DefaultFontTypeChanged + /// + public class DefaultFontTypeChangedEventArgs : EventArgs + { + private readonly string _defaultFontType = null; + /// + /// The enum for DefaultFontType system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.DefaultFontType; + } + } + internal DefaultFontTypeChangedEventArgs(string val) + { + _defaultFontType = val; + } + + /// + /// The current system default font type + /// + public string Value + { + get + { + return _defaultFontType; + } + } + } + + /// + /// EventArgs type for the event LocaleCountryChanged + /// + public class LocaleCountryChangedEventArgs : EventArgs + { + private readonly string _localeCountry = null; + /// + /// The enum for LocaleCountry system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.LocaleCountry; + } + } + internal LocaleCountryChangedEventArgs(string val) + { + _localeCountry = val; + } + + /// + /// Indicates the current country setting in the _ syntax. + /// The country setting is in the ISO 639-2 format, and the region setting is in the ISO 3166-1 alpha-2 format + /// + public string Value + { + get + { + return _localeCountry; + } + } + } + + /// + /// EventArgs type for the event LocaleLanguageChanged + /// + public class LocaleLanguageChangedEventArgs : EventArgs + { + private readonly string _localeLanguage = null; + /// + /// The enum for LocaleLanguage system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.LocaleLanguage; + } + } + internal LocaleLanguageChangedEventArgs(string val) + { + _localeLanguage = val; + } + + /// + /// Indicates the current language setting in the _ syntax. + /// The language setting is in the ISO 639-2 format and the region setting is in the ISO 3166-1 alpha-2 format + /// + public string Value + { + get + { + return _localeLanguage; + } + } + } + + /// + /// EventArgs type for the event LocaleTimeFormat24HourChanged + /// + public class LocaleTimeFormat24HourSettingChangedEventArgs : EventArgs + { + private readonly bool _localeTimeFormat24Hour; + /// + /// The enum for LocaleTimeFormat24Hour system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.LocaleTimeFormat24HourEnabled; + } + } + internal LocaleTimeFormat24HourSettingChangedEventArgs(bool val) + { + _localeTimeFormat24Hour = val; + } + + /// + /// Indicates whether the 24-hour clock is used. If the value is false, the 12-hour clock is used. + /// + public bool Value + { + get + { + return _localeTimeFormat24Hour; + } + } + } + + /// + /// EventArgs type for the event LocaleTimeZoneChanged + /// + public class LocaleTimeZoneChangedEventArgs : EventArgs + { + private readonly string _localeTimeZone = null; + /// + /// The enum for LocaleTimeZone system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.LocaleTimeZone; + } + } + internal LocaleTimeZoneChangedEventArgs(string val) + { + _localeTimeZone = val; + } + + /// + /// Indicates the current time zone + /// + public string Value + { + get + { + return _localeTimeZone; + } + } + } + + /// + /// EventArgs type for the event TimeChanged + /// + public class TimeChangedEventArgs : EventArgs + { + /// + /// The enum for Time system setting event + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.Time; + } + } + } + + /// + /// EventArgs type for the event SoundLockChanged + /// + public class SoundLockSettingChangedEventArgs : EventArgs + { + private readonly bool _soundLock; + /// + /// The enum for SoundLock system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.SoundLockEnabled; + } + } + internal SoundLockSettingChangedEventArgs(bool val) + { + _soundLock = val; + } + + /// + /// Indicates whether the screen lock sound is enabled on the device. ex) LCD on/off sound + /// + public bool Value + { + get + { + return _soundLock; + } + } + } + + /// + /// EventArgs type for the event SoundSilentModeChanged + /// + public class SoundSilentModeSettingChangedEventArgs : EventArgs + { + private readonly bool _soundSilentMode; + /// + /// The enum for SoundSilentMode system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.SoundSilentModeEnabled; + } + } + internal SoundSilentModeSettingChangedEventArgs(bool val) + { + _soundSilentMode = val; + } + + /// + /// Indicates whether the device is in the silent mode. + /// + public bool Value + { + get + { + return _soundSilentMode; + } + } + } + + /// + /// EventArgs type for the event SoundTouchChanged + /// + public class SoundTouchSettingChangedEventArgs : EventArgs + { + private readonly bool _soundTouch; + /// + /// The enum for SoundTouch system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.SoundTouchEnabled; + } + } + internal SoundTouchSettingChangedEventArgs(bool val) + { + _soundTouch = val; + } + + /// + /// Indicates whether the screen touch sound is enabled on the device. + /// + public bool Value + { + get + { + return _soundTouch; + } + } + } + + /// + /// EventArgs type for the event DisplayScreenRotationAutoChanged + /// + public class DisplayScreenRotationAutoSettingChangedEventArgs : EventArgs + { + private readonly bool _displayScreenRotationAuto; + /// + /// The enum for DisplayScreenRotationAuto system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.DisplayScreenRotationAutoEnabled; + } + } + internal DisplayScreenRotationAutoSettingChangedEventArgs(bool val) + { + _displayScreenRotationAuto = val; + } + + /// + /// Indicates whether rotation control is automatic + /// + public bool Value + { + get + { + return _displayScreenRotationAuto; + } + } + } + + /// + /// EventArgs type for the event DeviceNameChanged + /// + public class DeviceNameChangedEventArgs : EventArgs + { + private readonly string _deviceName = null; + /// + /// The enum for DeviceName system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.DeviceName; + } + } + internal DeviceNameChangedEventArgs(string val) + { + _deviceName = val; + } + + /// + /// Indicates device name + /// + public string Value + { + get + { + return _deviceName; + } + } + } + + /// + /// EventArgs type for the event MotionSettingChanged + /// + public class MotionSettingChangedEventArgs : EventArgs + { + private readonly bool _motionEnabled; + /// + /// The enum for MotionEnabled system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.MotionEnabled; + } + } + internal MotionSettingChangedEventArgs(bool val) + { + _motionEnabled = val; + } + + /// + /// Indicates whether the device user has enabled motion feature + /// + public bool Value + { + get + { + return _motionEnabled; + } + } + } + + /// + /// EventArgs type for the event NetworkWifiNotificationChanged + /// + public class NetworkWifiNotificationSettingChangedEventArgs : EventArgs + { + private readonly bool _networkWifiNotification; + /// + /// The enum for NetworkWifiNotification system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.NetworkWifiNotificationEnabled; + } + } + internal NetworkWifiNotificationSettingChangedEventArgs(bool val) + { + _networkWifiNotification = val; + } + + /// + /// Indicates whether Wi-Fi-related notifications are enabled on the device + /// + public bool Value + { + get + { + return _networkWifiNotification; + } + } + } + + /// + /// EventArgs type for the event NetworkFlightModeChanged + /// + public class NetworkFlightModeSettingChangedEventArgs : EventArgs + { + private readonly bool _networkFlightMode; + /// + /// The enum for NetworkFlightMode system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.NetworkFlightModeEnabled; + } + } + internal NetworkFlightModeSettingChangedEventArgs(bool val) + { + _networkFlightMode = val; + } + + /// + /// Indicates whether the device is in the flight mode + /// + public bool Value + { + get + { + return _networkFlightMode; + } + } + } + + /// + /// EventArgs type for the event ScreenBacklightTimeChanged + /// + public class ScreenBacklightTimeChangedEventArgs : EventArgs + { + private readonly int _screenBacklightTime; + /// + /// The enum for ScreenBacklightTime system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.ScreenBacklightTime; + } + } + internal ScreenBacklightTimeChangedEventArgs(int val) + { + _screenBacklightTime = val; + } + + /// + /// Indicates the backlight time (in seconds) + /// + public int Value + { + get + { + return _screenBacklightTime; + } + } + } + + /// + /// EventArgs type for the event SoundNotificationChanged + /// + public class SoundNotificationChangedEventArgs : EventArgs + { + private readonly string _soundNotification = null; + /// + /// The enum for SoundNotification system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.SoundNotification; + } + } + internal SoundNotificationChangedEventArgs(string val) + { + _soundNotification = val; + } + + /// + /// Indicates the file path of the current notification tone set by the user + /// + public string Value + { + get + { + return _soundNotification; + } + } + } + + /// + /// EventArgs type for the event SoundNotificationRepetitionPeriodChanged + /// + public class SoundNotificationRepetitionPeriodChangedEventArgs : EventArgs + { + private readonly int _soundNotificationRepetitionPeriod; + /// + /// The enum for SoundNotificationRepetitionPeriod system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.SoundNotificationRepetitionPeriod; + } + } + internal SoundNotificationRepetitionPeriodChangedEventArgs(int val) + { + _soundNotificationRepetitionPeriod = val; + } + + /// + /// Indicates the time period for notification repetitions + /// + public int Value + { + get + { + return _soundNotificationRepetitionPeriod; + } + } + } + + /// + /// EventArgs type for the event LockStateChanged + /// + public class LockStateChangedEventArgs : EventArgs + { + private readonly SystemSettingsIdleLockState _lockState; + /// + /// The enum for LockState system setting key + /// + public SystemSettingsKeys Key + { + get + { + return SystemSettingsKeys.LockState; + } + } + internal LockStateChangedEventArgs(SystemSettingsIdleLockState val) + { + _lockState = val; + } + + /// + /// Indicates the current lock state + /// + public SystemSettingsIdleLockState Value + { + get + { + return _lockState; + } + } + } +} diff --git a/src/Tizen.System/SystemSettings/SystemSettingsExceptionFactory.cs b/src/Tizen.System/SystemSettings/SystemSettingsExceptionFactory.cs new file mode 100644 index 0000000..c291e8a --- /dev/null +++ b/src/Tizen.System/SystemSettings/SystemSettingsExceptionFactory.cs @@ -0,0 +1,44 @@ +using System; + +namespace Tizen.System +{ + internal enum SystemSettingsError + { + None = Tizen.Internals.Errors.ErrorCode.None, + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, + IoError = Tizen.Internals.Errors.ErrorCode.IoError, + PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, + NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, + LockScreenAppPasswordMode = -0x01140000 | 0x01 + }; + internal class SystemSettingsExceptionFactory + { + internal const string LogTag = "Tizen.System.SystemSettings"; + + internal static Exception CreateException(SystemSettingsError err, string msg) + { + Exception exp; + switch (err) + { + case SystemSettingsError.InvalidParameter: + exp = new ArgumentException(msg); + break; + case SystemSettingsError.OutOfMemory: + //fall through + case SystemSettingsError.IoError: + //fall through + case SystemSettingsError.PermissionDenied: + //fall through + case SystemSettingsError.NotSupported: + //fall through + case SystemSettingsError.LockScreenAppPasswordMode: + //fall through + default: + exp = new InvalidOperationException(msg); + break; + } + return exp; + } + } +} diff --git a/src/Tizen.System/Tizen.System.csproj b/src/Tizen.System/Tizen.System.csproj index 6b0f8d3..9a1f6bb 100755 --- a/src/Tizen.System/Tizen.System.csproj +++ b/src/Tizen.System/Tizen.System.csproj @@ -71,6 +71,7 @@ + @@ -84,6 +85,10 @@ + + + + @@ -100,4 +105,4 @@ --> - + \ No newline at end of file -- 2.7.4