public new int AddFriendNoRequest(ToxKey publicKey, out ToxErrorFriendAdd error) { var friendNumber = base.AddFriendNoRequest(publicKey, out error); if (error == ToxErrorFriendAdd.Ok) FriendListChanged(friendNumber, FriendListChangedAction.Add); return friendNumber; }
public OneFriendRequestViewModel(FriendRequestsViewModel friendRequestsViewModel, ToxKey publicKey, string message) { _friendRequestsViewModel = friendRequestsViewModel; _publicKey = publicKey; Message = message; }
/// <summary> /// Initializes a new instance of tox dns3. /// </summary> /// <param name="publicKey">The public key that this instance of toxdns should be initialized with.</param> public ToxDns(ToxKey publicKey) { _toxDns3 = ToxDnsFunctions.New(publicKey.GetBytes()); if (_toxDns3 == null || _toxDns3.IsInvalid) throw new Exception("Could not create a new tox_dns3 instance with the provided publicKey"); }
public ToxDataInfo(ToxId id, string name, string statusMessage, ToxUserStatus status, ToxKey secretKey) { this.Id = id; this.Name = name; this.StatusMessage = statusMessage; this.Status = status; this.SecretKey = secretKey; }
public bool Delete(ToxKey publicKey) { string avatarFilename = Path.Combine(Dir, publicKey.GetString() + ".png"); if (File.Exists(avatarFilename)) { try { File.Delete(avatarFilename); } catch { return false; } return true; } else { return false; } }
/// <summary> /// Initializes a new instance of Tox. If no secret key is specified, toxcore will generate a new keypair. /// </summary> /// <param name="options">The options to initialize this instance of Tox with.</param> /// <param name="secretKey">Optionally, specify the secret key to initialize this instance of Tox with. Must be ToxConstants.SecretKeySize bytes in size.</param> public Tox(ToxOptions options, ToxKey secretKey = null) { var error = ToxErrorNew.Ok; var optionsStruct = options.Struct; if (secretKey != null) optionsStruct.SetData(secretKey.GetBytes(), ToxSaveDataType.SecretKey); _tox = ToxFunctions.New(ref optionsStruct, ref error); if (_tox == null || _tox.IsInvalid || error != ToxErrorNew.Ok) throw new Exception("Could not create a new instance of tox, error: " + error.ToString()); optionsStruct.Free(); Options = options; }
public override bool Equals(object obj) { if (obj == null) { return(false); } ToxKey key = obj as ToxKey; if ((object)key == null) { return(false); } return(this == key); }
public BitmapImage Load(ToxKey publicKey, out byte[] result) { byte[] bytes = LoadBytes(publicKey); if (bytes == null) { result = null; return null; } MemoryStream stream = new MemoryStream(bytes); using (Bitmap bmp = new Bitmap(stream)) { result = bytes; return bmp.ToBitmapImage(ImageFormat.Png); } }
/// <summary> /// Creates a new tox id with the specified public key and nospam. /// </summary> /// <param name="publicKey">Public key to create this Tox ID with.</param> /// <param name="nospam">Nospam value to create this Tox ID with.</param> public ToxId([NotNull] ToxKey publicKey, uint nospam) { if (publicKey.KeyType != ToxKeyType.Public) { throw new ArgumentException(nameof(publicKey)); } byte[] id = new byte[ToxConstants.AddressSize]; Array.Copy(publicKey.GetBytes(), 0, id, 0, ToxConstants.PublicKeySize); Array.Copy(BitConverter.GetBytes(nospam), 0, id, ToxConstants.PublicKeySize, ToxConstants.NospamSize); ushort checksum = CalculateChecksum(id, ToxConstants.PublicKeySize + ToxConstants.NospamSize); Array.Copy(BitConverter.GetBytes(checksum), 0, id, ToxConstants.PublicKeySize + ToxConstants.NospamSize, ToxConstants.ChecksumSize); this.id = id; }
/// <summary> /// Retrieves the friendNumber associated with the specified public key. /// </summary> /// <param name="publicKey">The public key to look for.</param> /// <param name="error"></param> /// <returns>The friend number on success.</returns> public int GetFriendByPublicKey(ToxKey publicKey, out ToxErrorFriendByPublicKey error) { ThrowIfDisposed(); if (publicKey == null) throw new ArgumentNullException("publicKey"); error = ToxErrorFriendByPublicKey.Ok; return (int)ToxFunctions.FriendByPublicKey(_tox, publicKey.GetBytes(), ref error); }
public FriendRequestEventArgs(ToxKey publicKey, string message) { PublicKey = publicKey; Message = message; }
/// <summary> /// Adds a friend to the friend list without sending a friend request. /// This method should be used to accept friend requests. /// </summary> /// <param name="publicKey">The public key of the friend to add.</param> /// <returns>The friend number.</returns> public int AddFriendNoRequest(ToxKey publicKey) { var error = ToxErrorFriendAdd.Ok; return AddFriendNoRequest(publicKey, out error); }
public bool Contains(ToxKey publicKey) { return File.Exists(Path.Combine(Dir, publicKey.GetString() + ".png")); }
/// <summary> /// Initializes a new instance of the <see cref="ToxNode"/> class. /// </summary> /// <param name="address"></param> /// <param name="port"></param> /// <param name="publicKey"></param> public ToxNode(string address, int port, ToxKey publicKey) { Address = address; Port = port; PublicKey = publicKey; }
public new int AddFriendNoRequest(ToxKey publicKey) { var friendNumber = base.AddFriendNoRequest(publicKey); FriendListChanged(friendNumber, FriendListChangedAction.Add); return friendNumber; }
public bool Save(byte[] img, ToxKey publicKey) { try { File.WriteAllBytes(Path.Combine(Dir, publicKey.GetString() + ".png"), img); return true; } catch { return false; } }
private byte[] LoadBytes(ToxKey publicKey) { try { string avatarFilename = Path.Combine(Dir, publicKey.GetString() + ".png"); if (File.Exists(avatarFilename)) { byte[] bytes = File.ReadAllBytes(avatarFilename); if (bytes.Length > 0) return bytes; } return null; } catch { return null; } }
/// <summary> /// Retrieves the friendNumber associated with the specified public key. /// </summary> /// <param name="publicKey">The public key to look for.</param> /// <returns>The friend number on success.</returns> public int GetFriendByPublicKey(ToxKey publicKey) { var error = ToxErrorFriendByPublicKey.Ok; return GetFriendByPublicKey(publicKey, out error); }
/// <summary> /// Initializes a new instance of the <see cref="ToxNode"/> class. /// </summary> /// <param name="address"></param> /// <param name="port"></param> /// <param name="publicKey"></param> public ToxNode(string address, ushort port, ToxKey publicKey) { this.Address = address; this.Port = port; this.PublicKey = publicKey; }
/// <summary> /// Adds a friend to the friend list without sending a friend request. /// This method should be used to accept friend requests. /// </summary> /// <param name="publicKey">The public key of the friend to add.</param> /// <param name="error"></param> /// <returns>The friend number.</returns> public int AddFriendNoRequest(ToxKey publicKey, out ToxErrorFriendAdd error) { ThrowIfDisposed(); if (publicKey == null) throw new ArgumentNullException("publicKey"); error = ToxErrorFriendAdd.Ok; return (int)ToxFunctions.FriendAddNoRequest(_tox, publicKey.GetBytes(), ref error); }
public int AddFriendNoRequest(ToxKey publicKey) { ToxErrorFriendAdd error; var retVal = _tox.AddFriendNoRequest(publicKey, out error); ToxErrorViewModel.Instance.RelayError(error); return retVal; }
public GroupPeer(int groupNumber, ToxKey publicKey) { GroupNumber = groupNumber; PublicKey = publicKey; }