Ejemplo n.º 1
0
 private void InCallForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (closingApp == true)
     {
         return;
     }
     closingApp         = true;
     Program.actualCall = null;
     Program.isInCall   = false;
     Program.spGlobal   = null;
     if (this.callId == null)
     {
         return;
     }
     packetsCounterTimer.Stop();
     tokenSource.Cancel();
     sp.stop();
     CallProcessing.SendMessages(BitConverter.GetBytes(callId.id));
     CallProcessing.SendMessages(BitConverter.GetBytes(callId.id));
     CallProcessing.SendMessages(BitConverter.GetBytes(callId.id));
     CallProcessing.Stop();
     LoggedInService.declineCall(this.callId);
     if (updateFriendViewOnClosing != null)
     {
         updateFriendViewOnClosing();
     }
 }
 private void invitationsDataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == invitationsDataGrid.Columns["acceptButtons"].Index)
     {
         Invitation inv = (Invitation)invitationsDataGrid[0, e.RowIndex].Value;
         if (processingInvitation.Contains(inv))
         {
             return;
         }
         processingProcessingList.WaitOne();
         processingProcessingList.Reset();
         processingInvitation.Add(inv);
         processingProcessingList.Set();
         LoggedInService.acceptInvitation(inv);
         removeInvitationList(inv);
     }
     else if (e.ColumnIndex == invitationsDataGrid.Columns["declineButtons"].Index)
     {
         Invitation inv = (Invitation)invitationsDataGrid[0, e.RowIndex].Value;
         if (processingInvitation.Contains(inv))
         {
             return;
         }
         processingProcessingList.WaitOne();
         processingProcessingList.Reset();
         processingInvitation.Add(inv);
         processingProcessingList.Set();
         LoggedInService.declineInvitation(inv);
         removeInvitationList(inv);
     }
 }
Ejemplo n.º 3
0
 private void usernameCheckOnTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (checkUsernameTimerStopped == false)
     {
         checkUsernameTimer.Stop();
         checkUsernameTimerStopped = true;
         LoggedInService.checkIsUserExist(this.username_input.Text);
     }
 }
Ejemplo n.º 4
0
 private void declineCall_button_Click(object sender, EventArgs e)
 {
     if (this.call == null)
     {
         return;
     }
     LoggedInService.declineCall(new Id(this.call.callId));
     this.call = null;
     this.Close();
 }
Ejemplo n.º 5
0
 private void LoggedInForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     for (int i = Application.OpenForms.Count - 1; i >= 0; i--)
     {
         if ((Application.OpenForms[i].Name != "LoginForm") && (Application.OpenForms[i].Name != "LoggedInForm"))
         {
             Application.OpenForms[i].Close(); //TODO: invoke ???
         }
     }
     LoggedInService.logout();
 }
Ejemplo n.º 6
0
 private void IncomingCallForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.call == null)
     {
         return;
     }
     if (!acceptedCall)
     {
         LoggedInService.declineCall(new Id(this.call.callId));
     }
     this.call = null;
 }
Ejemplo n.º 7
0
        private void acceptCall_button_Click(object sender, EventArgs e)
        {
            if (this.call == null)
            {
                return;
            }
            acceptedCall = true;
            LoggedInService.acceptCall(new Id(this.call.callId));

            openC(this.call);
            this.Close();
        }
Ejemplo n.º 8
0
 public void callUserReplyFromUser(Boolean reply)
 {
     if (callingStatusLabel.InvokeRequired)
     {
         callingStatusLabel.Invoke(new MethodInvoker(() => { callUserReplyFromUser(reply); }));
     }
     else
     {
         callingStatusLabel.Visible = true;
         if (reply == true)
         {
             callUser.Enabled             = false;
             callingStatusLabel.Text      = "";
             callingStatusLabel.ForeColor = Color.Green;
             if (lastCallId != null && lastCallUsername != null)
             {
                 Call c = new Call(lastCallId.id, new List <string> {
                     lastCallUsername.username
                 });
                 NoneCallback ncb = updateFriendViewOnCallClosing;
                 InCallForm   icf = new InCallForm(c, ncb);
                 icf.Show();
                 updateCallStatus(new Friend(lastCallUsername, 1));
             }
         }
         else
         {
             callUser.Enabled             = true;
             callingStatusLabel.Text      = "Odrzucono połączenie!";
             callingStatusLabel.ForeColor = Color.Red;
             if (!Program.isInCall)
             {
                 LoggedInService.declineCall(lastCallId);
             }
         }
     }
 }
Ejemplo n.º 9
0
        public LoggedInForm()
        {
            InitializeComponent();
            invitationContainer.Clear();
            friendsContainer.Clear();

            UsernameCallback callback4 = newInactiveFriendFunc;
            UsernameCallback callback5 = newActiveFriendFunc;
            IdCallback       callback6 = callUserReply;
            BooleanCallback  callback7 = callUserReplyFromUser;
            CallCallback     callback8 = openInCallWindow;
            FriendCallback   callback9 = addToFriendContainer;

            LoggedInService.AddToFriendList                   = callback9;
            LoggedInService.NewInactiveFriend                 = callback4;
            LoggedInService.NewActiveFriend                   = callback5;
            LoggedInService.InviteToConversationReplyOk       = callback6;
            LoggedInService.InviteToConversationReplyFromUser = callback7;
            LoggedInService.OpenInCallForm = callback8;


            StringCallback callback2 = writeToInvitingList;

            LoggedInService.NewInvitationCallback = callback2;
            this.signedInLogin_Text.Text          = Program.username;

            StringCallback callback = writeToFriendContainer;

            LoggedInService.GetFriendsCallback = callback;

            InvitationCallback callback3 = removeFromInvitingList;

            LoggedInService.InvitationProcessedCallback = callback3;

            LoggedInService.getFriends();
        }
Ejemplo n.º 10
0
 private void LoggedInForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     LoggedInService.logout();
     this.Close();
 }
Ejemplo n.º 11
0
 private void closeApp_button_Click(object sender, EventArgs e)
 {
     LoggedInService.logout();
     this.Close();
 }
Ejemplo n.º 12
0
 private void callUser_Click(object sender, EventArgs e)
 {
     LoggedInService.inviteToConversation(new Username(activeUserWindow.Text));
     lastCallUsername = new Username(activeUserWindow.Text);
 }
Ejemplo n.º 13
0
        public static void processReceivedMessage(String message)
        {
            if (message[0] == 'O') //ASYNC (Incoming Call, Invitation etc)
            {
                String[] replySplit = message.Split(new String[] { "$$" }, StringSplitOptions.RemoveEmptyEntries);
                Options  opt        = (Options)int.Parse(replySplit[0].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1]);
                switch (opt)
                {
                case Options.FRIEND_INVITATIONS:
                    LoggedInService.incomingInvitation(message);
                    break;

                case Options.ACTIVE_FRIENDS:
                    LoggedInService.newActiveFriends(message);
                    break;

                case Options.INACTIVE_FRIENDS:
                    LoggedInService.newInactiveFriends(message);
                    break;

                case Options.ACCEPTED_CALL:
                    LoggedInService.inviteToConversationReplyFromUserFunc(message, true);
                    break;

                case Options.DECLINED_CALL:
                    LoggedInService.inviteToConversationReplyFromUserFunc(message, false);
                    break;

                case Options.INCOMMING_CALL:
                    LoggedInService.incomingCall(message);
                    break;
                }
            }
            else if (message[0] == 'E')
            {
                switch (lastOptions)
                {
                case Options.LOGIN:
                    LoginService.loginReply(message);
                    break;

                case Options.CREATE_USER:
                    LoginService.registerReply(message);
                    break;

                case Options.LOGOUT:
                    LoggedInService.logoutReply(message);
                    break;

                case Options.GET_FRIENDS:
                    LoggedInService.getFriendsReply(message);
                    break;

                case Options.ADD_FRIEND:
                    LoggedInService.addFriendReply(message);
                    break;

                case Options.ACCEPT_FRIEND:
                    LoggedInService.acceptInvitationReply(message);
                    break;

                case Options.DECLINE_FRIEND:
                    LoggedInService.declineInvitationReply(message);
                    break;

                case Options.CHECK_USER_NAME:
                    if (Program.isLoggedIn)
                    {
                        LoggedInService.checkIsUserExistReply(message);
                    }
                    else
                    {
                        LoginService.checkIsUserExistReply(message);
                    }
                    break;

                case Options.INVITE_TO_CONVERSATION:
                    LoggedInService.inviteToConversationReply(message);
                    break;

                case Options.LEAVE_CONVERSATION:
                    break;

                case Options.JOIN_CONVERSATION:
                    break;
                }
                syncMessageStop();
            }
            else
            {
            }
        }
Ejemplo n.º 14
0
 private void addFriend_button_Click(object sender, EventArgs e)
 {
     LoggedInService.addFriend(this.username_input.Text);
     this.addFriend_button.Enabled = false;
     this.Close();
 }