internal void AddCellularProfile(CellularProfile profile) { Log.Debug(Globals.LogTag, "AddCellularProfile"); if (profile != null) { if (profile.Type == ConnectionProfileType.Cellular) { int ret = Interop.Connection.AddProfile(GetHandle(), profile.ProfileHandle); if ((ConnectionError)ret != ConnectionError.None) { Log.Error(Globals.LogTag, "Failed to add cellular profile, " + (ConnectionError)ret); ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony"); ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.profile)"); ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released"); ConnectionErrorFactory.ThrowConnectionException(ret); } } else { throw new ArgumentException("Profile type is not cellular"); } } else { throw new ArgumentNullException("Profile is null"); } }
internal Task <IEnumerable <ConnectionProfile> > GetProfileListAsync(ProfileListType type) { Log.Debug(Globals.LogTag, "GetProfileListAsync"); var task = new TaskCompletionSource <IEnumerable <ConnectionProfile> >(); List <ConnectionProfile> Result = new List <ConnectionProfile>(); IntPtr iterator; int ret = Interop.Connection.GetProfileIterator(GetHandle(), (int)type, out iterator); if ((ConnectionError)ret != ConnectionError.None) { Log.Error(Globals.LogTag, "It failed to get profile iterator, " + (ConnectionError)ret); ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "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"); ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)"); ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released"); ConnectionErrorFactory.ThrowConnectionException(ret); } while (Interop.Connection.HasNextProfileIterator(iterator)) { IntPtr nextH; IntPtr profileH; Interop.Connection.GetNextProfileIterator(iterator, out nextH); Interop.ConnectionProfile.Clone(out profileH, nextH); int profileType; Interop.ConnectionProfile.GetType(profileH, out profileType); if ((ConnectionProfileType)profileType == ConnectionProfileType.WiFi) { WiFiProfile cur = new WiFiProfile(profileH); Result.Add(cur); } else if ((ConnectionProfileType)profileType == ConnectionProfileType.Cellular) { CellularProfile cur = new CellularProfile(profileH); Result.Add(cur); } else { ConnectionProfile cur = new ConnectionProfile(profileH); Result.Add(cur); } } Interop.Connection.DestroyProfileIterator(iterator); task.SetResult(Result); return(task.Task); }
internal ConnectionProfile GetDefaultCellularProfile(CellularServiceType type) { Log.Debug(Globals.LogTag, "GetDefaultCellularProfile"); IntPtr ProfileHandle; int ret = Interop.Connection.GetDefaultCellularServiceProfile(GetHandle(), (int)type, out ProfileHandle); if ((ConnectionError)ret != ConnectionError.None) { Log.Error(Globals.LogTag, "Error: " + ret); Log.Error(Globals.LogTag, "It failed to get default cellular profile, " + (ConnectionError)ret); ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony"); ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)"); ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released"); ConnectionErrorFactory.ThrowConnectionException(ret); } CellularProfile Profile = new CellularProfile(ProfileHandle); return Profile; }
/// <summary> /// Adds a new profile. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="profile">The cellular profile object.</param> /// <privilege>http://tizen.org/privilege/network.profile</privilege> /// <privilege>http://tizen.org/privilege/network.get</privilege> /// <feature>http://tizen.org/feature/network.telephony</feature> /// <feature>http://tizen.org/feature/network.wifi</feature> /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature> /// <feature>http://tizen.org/feature/network.ethernet</feature> /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception> /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception> /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception> /// <exception cref="System.ArgumentNullException">Thrown when a value is null.</exception> /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception> /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when a method fails due to an invalid operation.</exception> public static void AddCellularProfile(CellularProfile profile) { Log.Debug(Globals.LogTag, "AddCellularProfile"); ConnectionInternalManager.Instance.AddCellularProfile(profile); }