예제 #1
0
 private void FriendDenyCallAction(IFriendObject friendObject)
 {
     if (call == null)
     {
         toxav.Reject(friendObject.CallIndex, "I'm busy...");
         friendObject.IsCalling = false;
     }
     else
     {
         call.Stop();
         call = null;
     }
 }
예제 #2
0
        private void EndCall(IFriendObject friend)
        {
            if (friend != null)
            {
                toxav.Cancel(friend.CallIndex, friend.ChatNumber, "I'm busy...");

                friend.IsCalling = false;
                friend.IsCallingToFriend = false;
            }

            if (call != null)
            {
                call.Stop();
                call = null;
            }

            this.ViewModel.CallingFriend = null;

            HangupButton.Visibility = Visibility.Collapsed;
            CallButton.Visibility = Visibility.Visible;
        }
예제 #3
0
        private void FriendAcceptCallAction(IFriendObject friendObject)
        {
            if (call != null)
                return;

            call = new ToxCall(tox, toxav, friendObject.CallIndex, friendObject.ChatNumber);
            call.Answer();
        }
예제 #4
0
        private async void tox_OnGroupInvite(object sender, ToxEventArgs.GroupInviteEventArgs e)
        {
            int number;

            if (e.GroupType == ToxGroupType.Text)
            {
                number = tox.JoinGroup(e.FriendNumber, e.Data);
            }
            else if (e.GroupType == ToxGroupType.Av)
            {
                if (call != null)
                {
                    await Dispatcher.BeginInvoke(((Action)(() =>
                    {
                        this.ShowMessageAsync("Error", "Could not join audio groupchat, there's already a call in progress.");
                    })));
                    return;
                }
                else
                {
                    number = toxav.JoinAvGroupchat(e.FriendNumber, e.Data);
                    call = new ToxGroupCall(toxav, number);
                    call.FilterAudio = config.FilterAudio;
                    call.Start(config.InputDevice, config.OutputDevice, ToxAv.DefaultCodecSettings);
                }
            }
            else
            {
                return;
            }

            Dispatcher.BeginInvoke(((Action)(() =>
            {
                var group = ViewModel.GetGroupObjectByNumber(number);

                if (group != null)
                    SelectGroupControl(group);
                else if (number != -1)
                    AddGroupToView(number, e.GroupType);
            })));
        }
예제 #5
0
        private void CallButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (!this.ViewModel.IsFriendSelected)
                return;

            if (call != null)
                return;

            var selectedChatNumber = this.ViewModel.SelectedChatNumber;
            if (tox.GetFriendConnectionStatus(selectedChatNumber) != 1)
                return;

            int call_index;
            ToxAvError error = toxav.Call(selectedChatNumber, ToxAvCallType.Audio, 30, out call_index);
            if (error != ToxAvError.None)
                return;

            int friendnumber = toxav.GetPeerID(call_index, 0);
            call = new ToxCall(tox, toxav, call_index, friendnumber);

            CallButton.Visibility = Visibility.Collapsed;
            HangupButton.Visibility = Visibility.Visible;
            var callingFriend = this.ViewModel.GetFriendObjectByNumber(friendnumber);
            if (callingFriend != null)
            {
                this.ViewModel.CallingFriend = callingFriend;
                callingFriend.IsCallingToFriend = true;
            }
        }
예제 #6
0
        private async void GroupMenuItem_MouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)e.Source;
            GroupMenuItem item = (GroupMenuItem)menuItem.Tag;

            if (item == GroupMenuItem.TextAudio && call != null)
            {
                await this.ShowMessageAsync("Error", "Could not create audio groupchat, there's already a call in progress.");
                return;
            }

            int groupNumber = item == GroupMenuItem.Text ? tox.NewGroup() : toxav.AddAvGroupchat();
            if (groupNumber != -1)
            {
                AddGroupToView(groupNumber, (ToxGroupType)item);
            }

            if (item == GroupMenuItem.TextAudio)
            {
                call = new ToxGroupCall(toxav, groupNumber);
                call.FilterAudio = config.FilterAudio;
                call.Start(config.InputDevice, config.OutputDevice, ToxAv.DefaultCodecSettings);
            }

            tox.SetGroupTitle(groupNumber, string.Format("Groupchat #{0}", groupNumber));
        }
예제 #7
0
        private void CallButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (!ViewModel.IsFriendSelected)
                return;

            if (call != null)
                return;

            var selectedChatNumber = ViewModel.SelectedChatNumber;
            if (!tox.IsFriendOnline(selectedChatNumber))
                return;

            int call_index;
            ToxAvError error = toxav.Call(selectedChatNumber, ToxAv.DefaultCodecSettings, 30, out call_index);
            if (error != ToxAvError.None)
                return;

            int friendnumber = toxav.GetPeerID(call_index, 0);
            call = new ToxCall(toxav, call_index, friendnumber);
            call.FilterAudio = config.FilterAudio;

            CallButton.Visibility = Visibility.Collapsed;
            HangupButton.Visibility = Visibility.Visible;
            VideoButton.Visibility = Visibility.Visible;

            var callingFriend = ViewModel.GetFriendObjectByNumber(friendnumber);
            if (callingFriend != null)
            {
                ViewModel.CallingFriend = callingFriend;
                callingFriend.IsCallingToFriend = true;
            }
        }
예제 #8
0
        private void KillTox(bool save)
        {
            if (call != null)
            {
                call.Stop();
                call = null;
            }

            foreach (FileTransfer transfer in transfers)
                transfer.Kill(false);

            convdic.Clear();
            groupdic.Clear();
            transfers.Clear();

            if (toxav != null)
                toxav.Dispose();

            if (tox != null)
            {
                if (save)
                    saveTox();

                tox.Dispose();
            }

            if (config != null)
            {
                config.WindowSize = new Size(this.Width, this.Height);
                ConfigTools.Save(config, configFilename);
            }
        }
예제 #9
0
        private void EndCall(IFriendObject friend)
        {
            if (friend != null)
            {
                toxav.Cancel(friend.CallIndex, friend.ChatNumber, "I'm busy...");

                friend.IsCalling = false;
                friend.IsCallingToFriend = false;
            }

            if (call != null)
            {
                call.Stop();
                call = null;

                CurrentCallControl.TimerLabel.Content = "00:00:00";
            }

            ViewModel.CallingFriend = null;
            VideoImageRow.Height = new GridLength(0);
            VideoGridSplitter.IsEnabled = false;
            VideoChatImage.Source = null;

            HangupButton.Visibility = Visibility.Collapsed;
            VideoButton.Visibility = Visibility.Collapsed;
            CallButton.Visibility = Visibility.Visible;
        }
예제 #10
0
        private void GroupDeleteAction(IGroupObject groupObject)
        {
            ViewModel.ChatCollection.Remove(groupObject);
            int groupNumber = groupObject.ChatNumber;
            if (groupdic.ContainsKey(groupNumber))
            {
                groupdic.Remove(groupNumber);

                if (groupObject.Selected)
                    ChatBox.Document = null;
            }

            if (tox.GetGroupType(groupNumber) == ToxGroupType.Av && call != null)
            {
                call.Stop();
                call = null;
            }

            tox.DeleteGroupChat(groupNumber);

            groupObject.SelectedAction = null;
            groupObject.DeleteAction = null;

            MicButton.IsChecked = false;
        }