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 int GetProfileIterator(ProfileListType type, out IntPtr iterator) { return(Interop.Connection.GetProfileIterator(GetHandle(), (int)type, out iterator)); }
/// <summary> /// Gets the list of the profile with the profile list type. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="type">The type of profile.</param> /// <returns>List of connection profile objects.</returns> /// <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 value is an invalid parameter.</exception> /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception> /// <exception cref="System.InvalidOperationException">Thrown when a connection instance has been disposed.</exception> public static Task <IEnumerable <ConnectionProfile> > GetProfileListAsync(ProfileListType type) { Log.Debug(Globals.LogTag, "GetProfileListAsync"); return(ConnectionInternalManager.Instance.GetProfileListAsync(type)); }