/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace Tizen.Network.Connection { /// /// This class is ConnectionProfileManager. It provides functions to add, get, connect or modify the connection profile. /// /// 3 public static class ConnectionProfileManager { /// /// Adds a new profile /// /// 3 /// The cellular profile object /// http://tizen.org/privilege/network.profile /// http://tizen.org/privilege/network.get /// http://tizen.org/feature/network.telephony /// http://tizen.org/feature/network.wifi /// http://tizen.org/feature/network.tethering.bluetooth /// http://tizen.org/feature/network.ethernet /// Thrown when feature is not supported. /// Thrown when permission is denied. /// Thrown when value is invalid parameter. /// Thrown when value is null. /// Thrown when memory is not enough to continue execution. /// Thrown when connection or profile instance is invalid or when method failed due to invalid operation public static void AddCellularProfile(CellularProfile profile) { Log.Debug(Globals.LogTag, "AddCellularProfile"); ConnectionInternalManager.Instance.AddCellularProfile(profile); } /// /// Gets the list of profile with profile list type /// /// 3 /// The type of profile /// List of connection profile objects. /// http://tizen.org/privilege/network.get /// http://tizen.org/feature/network.telephony /// http://tizen.org/feature/network.wifi /// http://tizen.org/feature/network.tethering.bluetooth /// http://tizen.org/feature/network.ethernet /// Thrown when feature is not supported. /// Thrown when permission is denied. /// Thrown when value is invalid parameter. /// Thrown when memory is not enough to continue execution. /// Thrown when connection instance has been disposed. public static Task> GetProfileListAsync(ProfileListType type) { Log.Debug(Globals.LogTag, "GetProfileListAsync"); return ConnectionInternalManager.Instance.GetProfileListAsync(type); } /// /// Opens a connection of profile, asynchronously. /// /// 3 /// The connection profile object /// A task indicates whether the ConnectProfileAsync method is done successfully or not. /// http://tizen.org/privilege/network.get /// http://tizen.org/privilege/network.set /// http://tizen.org/feature/network.telephony /// http://tizen.org/feature/network.wifi /// http://tizen.org/feature/network.tethering.bluetooth /// http://tizen.org/feature/network.ethernet /// Thrown when feature is not supported. /// Thrown when permission is denied. /// Thrown when value is invalid parameter. /// Thrown when value is null. /// Thrown when memory is not enough to continue execution. /// Thrown when connection or profile instance is invalid or when method failed due to invalid operation public static Task ConnectProfileAsync(ConnectionProfile profile) { Log.Debug(Globals.LogTag, "ConnectProfile"); return ConnectionInternalManager.Instance.OpenProfileAsync(profile); } /// /// Closes a connection of profile. /// /// 3 /// The connection profile object /// A task indicates whether the DisconnectProfileAsync method is done successfully or not. /// http://tizen.org/privilege/network.get /// http://tizen.org/privilege/network.set /// http://tizen.org/feature/network.telephony /// http://tizen.org/feature/network.wifi /// http://tizen.org/feature/network.tethering.bluetooth /// http://tizen.org/feature/network.ethernet /// Thrown when feature is not supported. /// Thrown when permission is denied. /// Thrown when value is invalid parameter. /// Thrown when value is null. /// Thrown when memory is not enough to continue execution. /// Thrown when connection or profile instance is invalid or when method failed due to invalid operation public static Task DisconnectProfileAsync(ConnectionProfile profile) { Log.Debug(Globals.LogTag, "DisconnectProfileAsync"); return ConnectionInternalManager.Instance.CloseProfileAsync(profile); } /// /// Removes an existing profile. /// /// 3 /// The connection profile object /// http://tizen.org/privilege/network.get /// http://tizen.org/privilege/network.profile /// http://tizen.org/feature/network.telephony /// http://tizen.org/feature/network.wifi /// http://tizen.org/feature/network.tethering.bluetooth /// http://tizen.org/feature/network.ethernet /// Thrown when feature is not supported. /// Thrown when permission is denied. /// Thrown when value is invalid parameter. /// Thrown when value is null. /// Thrown when memory is not enough to continue execution. /// Thrown when connection or profile instance is invalid or when method failed due to invalid operation public static void RemoveProfile(ConnectionProfile profile) { Log.Debug(Globals.LogTag, "RemoveProfile. Id: " + profile.Id + ", Name: " + profile.Name + ", Type: " + profile.Type); ConnectionInternalManager.Instance.RemoveProfile(profile); } /// /// Updates an existing profile. /// When a profile is changed, these changes will be not applied to the ConnectionProfileManager immediately. /// When you call this function, your changes affect the ConnectionProfileManager and the existing profile is updated. /// /// 3 /// The connection profile object /// http://tizen.org/privilege/network.get /// http://tizen.org/privilege/network.profile /// http://tizen.org/feature/network.telephony /// http://tizen.org/feature/network.wifi /// http://tizen.org/feature/network.tethering.bluetooth /// http://tizen.org/feature/network.ethernet /// Thrown when feature is not supported. /// Thrown when permission is denied. /// Thrown when value is invalid parameter. /// Thrown when value is null. /// Thrown when memory is not enough to continue execution. /// Thrown when connection or profile instance is invalid or when method failed due to invalid operation public static void UpdateProfile(ConnectionProfile profile) { Log.Debug(Globals.LogTag, "UpdateProfile"); ConnectionInternalManager.Instance.UpdateProfile(profile); } /// /// Gets the name of the default profile. /// /// 3 /// Connection profile object. /// http://tizen.org/privilege/network.get /// http://tizen.org/feature/network.telephony /// http://tizen.org/feature/network.wifi /// http://tizen.org/feature/network.tethering.bluetooth /// http://tizen.org/feature/network.ethernet /// Thrown when feature is not supported. /// Thrown when permission is denied. /// Thrown when value is invalid parameter. /// Thrown when memory is not enough to continue execution. /// Thrown when connection instance is invalid or when method failed due to invalid operation public static ConnectionProfile GetCurrentProfile() { Log.Debug(Globals.LogTag, "GetCurrentProfile"); return ConnectionInternalManager.Instance.GetCurrentProfile(); } /// /// Gets the default profile which provides the given cellular service. /// /// 3 /// The cellular service type /// Connection profile object. /// http://tizen.org/privilege/network.get /// http://tizen.org/feature/network.telephony /// http://tizen.org/feature/network.wifi /// http://tizen.org/feature/network.tethering.bluetooth /// http://tizen.org/feature/network.ethernet /// Thrown when feature is not supported. /// Thrown when permission is denied. /// Thrown when value is invalid parameter. /// Thrown when memory is not enough to continue execution. /// Thrown when connection instance is invalid or when method failed due to invalid operation public static ConnectionProfile GetDefaultCellularProfile(CellularServiceType type) { Log.Debug(Globals.LogTag, "GetDefaultCurrentProfile"); return ConnectionInternalManager.Instance.GetDefaultCellularProfile(type); } /// /// Sets the default profile which provides the given cellular service. /// /// 3 /// The cellular service type /// The connection profile object /// A task indicates whether the SetDefaultCellularProfile method is done successfully or not. /// http://tizen.org/privilege/network.get /// http://tizen.org/privilege/network.profile /// http://tizen.org/feature/network.telephony /// http://tizen.org/feature/network.wifi /// http://tizen.org/feature/network.tethering.bluetooth /// http://tizen.org/feature/network.ethernet /// Thrown when feature is not supported. /// Thrown when permission is denied. /// Thrown when value is invalid parameter. /// Thrown when value is null. /// Thrown when memory is not enough to continue execution. /// Thrown when connection or profile instance is invalid or when method failed due to invalid operation public static Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile) { Log.Debug(Globals.LogTag, "SetDefaultCellularProfile"); return ConnectionInternalManager.Instance.SetDefaultCellularProfile(type, profile); } } /// /// An extended EventArgs class which contains the state of changed connection profile. /// /// 3 public class ConnectionProfileStateEventArgs : EventArgs { private ConnectionProfileState State; internal ConnectionProfileStateEventArgs(ConnectionProfileState state) { State = state; } /// /// The connection profile state. /// /// 3 /// State of the connection profile. public ConnectionProfileState ConnectionProfileState { get { return State; } } } }