private static string GetIconName(ToxUserStatus status, ToxConnectionStatus connStatus, bool hasUnreadMessages) { string result; if (connStatus == ToxConnectionStatus.None) { result = "tox_dot_offline"; } else { switch (status) { case ToxUserStatus.None: result = "tox_dot_online"; break; case ToxUserStatus.Away: result = "tox_dot_idle"; break; case ToxUserStatus.Busy: result = "tox_dot_busy"; break; default: result = "tox_dot_online"; //we don't know about this status, just show 'online' break; } } return(result + (hasUnreadMessages ? "_notification" : string.Empty)); }
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; }
private void SetFriendStatus(ToxUserStatus status) { if (_toxModel.IsFriendOnline(FriendNumber)) { Status = (ExtendedToxUserStatus)status; } else { Status = ExtendedToxUserStatus.Offline; } }
private void UpdateComponent() { this.connectionStatus = ToxConnectionStatus.None; this.userStatus = ToxUserStatus.None; this.notification = false; this.mouseOverBackColor = Color.Transparent; this.mouseOutBackColor = this.pictureBox.BackColor; this.pictureBox.Layout += this.OnPictureBoxLayout; this.pictureBox.Click += this.OnPictureBoxClick; this.pictureBox.MouseEnter += this.OnPictureBoxMouseEnter; this.pictureBox.MouseLeave += this.OnPictureBoxMouseLeave; this.notificationTimer = new Timer(); this.notificationTimer.Enabled = false; this.notificationTimer.Interval = 250; this.notificationTimer.Tick += this.OnNotificationTimerTick; this.notificationCounter = 0; this.UpdateControl(); }
public static Status ToxStatusToDetoxStatus(ToxUserStatus status, ToxConnectionStatus conn) { if (conn == ToxConnectionStatus.None) { return(Status.Offline); } switch (status) { case ToxUserStatus.Away: return(Status.Away); case ToxUserStatus.Busy: return(Status.Busy); case ToxUserStatus.None: default: return(Status.Available); } }
private static int GetStatusPriority(bool isOnline, ToxUserStatus status) { if (!isOnline) { return(4); } switch (status) { case ToxUserStatus.None: return(0); case ToxUserStatus.Away: return(1); case ToxUserStatus.Busy: return(2); default: return(3); } }
private static string GetColor(ToxUserStatus status, ToxConnectionStatus connStatus) { if (connStatus == ToxConnectionStatus.None) { return("ToxDotOfflineBrush"); } switch (status) { case ToxUserStatus.None: return("ToxDotOnlineBrush"); case ToxUserStatus.Away: return("ToxDotIdleBrush"); case ToxUserStatus.Busy: return("ToxDotBusyBrush"); default: return("ToxDotOnlineBrush"); } }
private void tox_OnUserStatus(int friendnumber, ToxUserStatus status) { var friend = this.ViewModel.GetFriendObjectByNumber(friendnumber); if (friend != null) { friend.ToxStatus = status; } }
public StatusEventArgs(int friendNumber, ToxUserStatus status) : base(friendNumber) { Status = status; }
private void SetFriendStatus(ToxUserStatus status) { if (ToxModel.Instance.IsFriendOnline(FriendNumber)) { Status = (ExtendedToxUserStatus) status; } else { Status = ExtendedToxUserStatus.Offline; } }
internal static ToxDataInfo FromToxData(ToxData data) { try { ToxId id = null; string name = null; string statusMessage = null; ToxUserStatus status = ToxUserStatus.None; byte[] secretKey = null; using (var stream = new MemoryStream(data.Bytes)) using (var reader = new BinaryReader(stream)) { stream.Position += sizeof(uint); uint cookie = reader.ReadUInt32(); if (cookie != ToxConstants.Cookie) { throw new Exception("Invalid cookie, this doesn't look like a tox profile"); } uint length = reader.ReadUInt32(); long left = reader.BaseStream.Length - reader.BaseStream.Position; while (left >= length) { var type = ReadStateType(reader); if (type == StateType.EOF) { break; } switch (type) { case StateType.NospamKeys: int nospam = reader.ReadInt32(); byte[] publicKey = reader.ReadBytes(ToxConstants.PublicKeySize); secretKey = reader.ReadBytes(ToxConstants.SecretKeySize); id = new ToxId(publicKey, nospam); break; case StateType.Name: name = Encoding.UTF8.GetString(reader.ReadBytes((int)length), 0, (int)length); break; case StateType.StatusMessage: statusMessage = Encoding.UTF8.GetString(reader.ReadBytes((int)length), 0, (int)length); break; case StateType.Status: status = (ToxUserStatus)reader.ReadByte(); break; default: case StateType.Dht: case StateType.Friends: case StateType.TcpRelay: case StateType.PathNode: stream.Position += length; //skip this break; case StateType.Corrupt: throw new Exception("This Tox save file is corrupt"); } left = reader.BaseStream.Length - reader.BaseStream.Position; if (left < sizeof(uint)) { break; } else { length = reader.ReadUInt32(); } } } return(new ToxDataInfo() { Id = id, Name = name, StatusMessage = statusMessage, Status = status, SecretKey = new ToxKey(ToxKeyType.Secret, secretKey) }); } catch { return(null); } }
public static extern void SetStatus(ToxHandle tox, ToxUserStatus status);
internal static extern void SelfSetStatus(ToxHandle tox, ToxUserStatus status);
private void SetStatus(ToxUserStatus? newStatus) { if (newStatus == null) newStatus = tox.GetSelfUserStatus(); else tox.SetUserStatus(newStatus.GetValueOrDefault()); this.ViewModel.MainToxyUser.ToxStatus = newStatus.GetValueOrDefault(); }
public UserStatusEventArgs(int friendNumber, ToxUserStatus userStatus) : base(friendNumber) { UserStatus = userStatus; }
/// <summary> /// Sets the user status of this tox instance. /// </summary> /// <param name="status"></param> /// <returns></returns> public bool SetUserStatus(ToxUserStatus status) { if (disposed) throw new ObjectDisposedException(GetType().FullName); return ToxFunctions.SetUserStatus(tox, (byte)status) == 0; }