public static void OnLog(object sender, SktEvents.OnLogArgs e)
 {
     if (logWindow == null) return;
     if (!logWindow.Visible) return;
     TimeSpan diff = DateTime.Now.Subtract(lastLogEntryTimepstamp);
     lastLogEntryTimepstamp = DateTime.Now;
     logWindow.logBox.AppendText(diff.TotalMilliseconds.ToString("00000") + "  " + e.message + "\r\n");
 }
Example #2
0
        // This will fire whenever account (login) status changes value.
        public void OnAccountStatus(SktAccount sender, SktEvents.OnAccountStatusArgs e)
        {
            textBox1.AppendText(e.value.ToString() + '\n');

            if (e.value == SktAccount.STATUS.LOGGED_IN)
            {
                textBox1.AppendText(String.Format("Hello {0}! You should see this account as online on Skype, in a few seconds.\n", username));
            }

            if (e.value == SktAccount.STATUS.LOGGED_OUT)
            {
                textBox1.AppendText("Login failed because of " + sender.P_LOGOUTREASON + '\n');
            }
        }
Example #3
0
        public void OnAccountStatus(SktAccount sender, SktEvents.OnAccountStatusArgs e)
        {
            feedbackLabel.Text = "Login in progress.. " + sender.P_STATUS.ToString();
            if (e.value == SktAccount.STATUS.LOGGED_IN)
            {
                feedbackLabel.Text = "";
                UpdateContactListBox();
            }

            if (e.value == SktAccount.STATUS.LOGGED_OUT)
            {
                DialogResult result = MessageBox.Show(this,
                    "Login failed because of " + sender.P_LOGOUTREASON.ToString(), "Login has failed",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1,MessageBoxOptions.RightAlign);
            }
        }
        // Logging account status, and when it goes LOGGED_IN, populate our listbox.
        public void OnAccountStatus(SktAccount sender, SktEvents.OnAccountStatusArgs e)
        {
            this.messageLog.AppendText(e.value.ToString() + "\r\n");

            if (e.value == SktAccount.STATUS.LOGGED_IN)
            {
                this.messageLog.AppendText("Retrieving conversation list..\r\n");

                conversationList = skype.GetConversationList(SktConversation.LIST_TYPE.INBOX_CONVERSATIONS);

                foreach (SktConversation conversation in conversationList)
                {
                    // Because we overrided SktConverstaion.ToString, we can add
                    // Conversation objects directly, to a standard ListBox.
                    this.conversationListBox.Items.Add(conversation);
                }
            }

            if (e.value == SktAccount.STATUS.LOGGED_OUT)
            {
                this.messageLog.AppendText("Login failed because of " + sender.P_LOGOUTREASON + "\r\n");
            }
        }
Example #5
0
 // When a participant goes "live" -> update background color
 public void OnParticipantVoiceStatus(SktParticipant sender, SktEvents.OnParticipantVoiceStatusArgs e)
 {
     Participant p = (Participant)sender;
     if (p.IsLive() & (p.gui.BackColor == Participant.nonLiveColor)) p.gui.BackColor = Participant.liveColor;
     if (!p.IsLive() & (p.gui.BackColor == Participant.liveColor)) p.gui.BackColor = Participant.nonLiveColor;
 }
Example #6
0
 // Checkig for incoming calls here
 public void OnConversationLocalLiveStatus(SktConversation sender, SktEvents.OnConversationLocalLivestatusArgs e)
 {
     switch (e.value)
     {
         case SktConversation.LOCAL_LIVESTATUS.RINGING_FOR_ME:
             if (liveSession != null) return; // busy..
             liveSession = sender;
             // forcibly switching the UI to the ringing conversation
             if (convListBox.SelectedItem != sender) convListBox.SelectedItem = sender;
             UiToRinginggMode();
             break;
     }
 }
Example #7
0
 public void OnParticipantSoundLevel(SktParticipant sender, SktEvents.OnParticipantSoundLevelArgs e)
 {
     Participant p = (Participant)sender;
     p.voiceVolume.Value = (int)e.value;
 }
Example #8
0
 // This event will keep our audio device lists up to date, even if some
 // USB devices get plugged in or out.
 void OnSkypeAvailableDeviceListChange(SktSkype sender, SktEvents.OnSkypeAvailableDeviceListChangeArgs e)
 {
     UpdateAudioDevices();
 }
Example #9
0
 // when contact online status changes
 public void OnContactAvailability(SktContact sender, SktEvents.OnContactAvailabilityArgs e)
 {
     contactListBox.Refresh();
     if (contactListBox.SelectedItem == sender) onlineStatusText.Text = e.value.ToString();
 }
Example #10
0
        // And this we already covered in the Incoming Calls tutorial..
        public void OnSkypeMessage(SktSkype sender, SktEvents.OnSkypeMessageArgs e)
        {
            if (!convListBox.Items.Contains(e.conversation)) return;
            var conv = (Conversation)e.conversation;

            switch (e.message.P_TYPE)
            {
                case SktMessage.TYPE.STARTED_LIVESESSION:
                    UiToInCallMode();
                    liveSession = e.conversation;
                    break;

                case SktMessage.TYPE.ENDED_LIVESESSION:
                    // This is a temporary workaround for releasing the webcam after live session ends.
                    SktVideo temp = skype.GetPreviewVideo(SktVideo.MEDIATYPE.MEDIA_VIDEO, webcam.name, webcam.path);
                    temp.SetRemoteRendererId(0);
                    // Resetting UI to not-in-live state
                    liveSession = null;
                    UiToWaitingMode();
                    break;
            }

            if (conv.messageHistoryLoaded)
            {
                Message msg = (Message)e.message;
                {
                    string newLine = msg.GetText();
                    conv.messageHistory = conv.messageHistory + newLine;

                    if (conv == convListBox.SelectedItem)
                    {
                        msgLog.AppendText(newLine);
                        conv.SetConsumedHorizon(DateTime.Now, false);
                    }
                }
            }
        }
Example #11
0
 // Checking for "migration" from 1-on-1 to a conference. Note that
 // the reloading participant list and UI is conveniently done for us
 // by what we already have in the listbox selected index change callback.
 void OnConversationSpawnConference(SktConversation sender, SktEvents.OnConversationSpawnConferenceArgs e)
 {
     if (convListBox.SelectedItem == sender) convListBox.SelectedItem = e.spawned;
     if (sender == liveSession) liveSession = e.spawned;
 }
Example #12
0
 public void OnContactGroupChange(SktContactGroup sender, SktEvents.OnContactGroupChangeArgs e)
 {
     if (sender.P_TYPE == SktContactGroup.TYPE.SKYPE_BUDDIES) UpdateContactCombo();
 }
Example #13
0
 // This gets fired when we receive a datagram
 void OnSkypeApp2AppDatagram(SktSkype sender, SktEvents.OnSkypeApp2AppDatagramArgs e)
 {
     string msg = Encoding.UTF8.GetString(e.data, 0, e.data.Length);
     msgHistory.AppendText("Incoming datagram: " + msg + "\r\n");
 }
Example #14
0
        public void OnAccountStatus(SktAccount sender, SktEvents.OnAccountStatusArgs e)
        {
            msgHistory.AppendText(e.value.ToString() + "\r\n");
            if (e.value == SktAccount.STATUS.LOGGED_IN)
            {
                this.UpdateContactCombo();
                this.Text = this.Text + " (" + account.P_SKYPENAME + ")";
            }

            if (e.value == SktAccount.STATUS.LOGGED_OUT)
            {
                DialogResult result = MessageBox.Show(this,
                    "Login failed because of " + sender.P_LOGOUTREASON.ToString(), "Login has failed",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
            }
        }
Example #15
0
 public void OnConnect(object sender, SktEvents.OnConnectArgs e)
 {
     if (e.success)
     {
         LoginRec login = tutorials.ShowLoginDialog(this);
         username = login.username;
         password = login.password;
         if (!login.abort)
         {
             account = skype.GetAccount(username);
             account.LoginWithPassword(password, false, false);
         }
     }
     else
     {
         throw new Exception("IPC handshake failed with: " + e.handshakeResult);
     }
 }
Example #16
0
 // when contact mood message changes
 public void OnContactMoodText(SktContact sender, SktEvents.OnContactMoodTextArgs e)
 {
     if (contactListBox.SelectedItem == sender) moodText.Text = e.value.ToString();
 }
Example #17
0
 // when contact last online timestamp changes
 public void OnContactLastOnlineTimestamp(SktContact sender, SktEvents.OnContactLastonlineTimestampArgs e)
 {
     if (contactListBox.SelectedItem == sender) lastOnlineText.Text = e.value.ToString();
 }
Example #18
0
        // Here we keep our contactList up-to-date, in case contacts get added or removed to the
        // ALL_BUDDIES list. Not going to happen in this tutorial but in a real application, it will.
        public void OnContactGroupChange(SktContactGroup sender, SktEvents.OnContactGroupChangeArgs e)
        {
            if (sender.P_TYPE != SktContactGroup.TYPE.ALL_BUDDIES) return;
            if (e.contact == null) return; // It can be null sometimes.

            // if it was already in, a change means it was removed
            if (contactList.Contains(sender))
            {
                contactList.Remove(sender);
                contactListBox.Items.Remove(sender);
            }
            else // if it wasn't already in, it must have been added
            {
                contactList.Add(sender);
                contactListBox.Items.Add(sender);
            };
        }
Example #19
0
 public void OnSkypeAvailableVideoDeviceListChange(SktSkype sender, SktEvents.OnSkypeAvailableVideoDeviceListChangeArgs e)
 {
     UpdateVideoDevices();
 }
Example #20
0
        // Here we check for three things..
        void OnSkypeApp2AppStreamListChange(SktSkype sender, SktEvents.OnSkypeApp2AppStreamListChangeArgs e)
        {
            // ALL_STREAMS & stream list is non-null -> a new app2app connection is established.
            // This gets fired when both sides have called App2AppConnect. This is also the place to
            // get and remember the stream name.
            if ((e.listType == SktSkype.APP2APP_STREAMS.ALL_STREAMS) & (e.streams != null))
            {
                msgHistory.AppendText("App2app connection established.\r\n");
                streamName = e.streams[0];
                sendBtn.Enabled = true;
                return;
            }

            // ALL_STREAMS & stream list is null -> connection just went down. This happens when the remote
            // participant calls App2appDisconnect or closes the client.
            if ((e.listType == SktSkype.APP2APP_STREAMS.ALL_STREAMS) & (e.streams == null))
            {
                msgHistory.AppendText("App2app connection closed.\r\n");
                sendBtn.Enabled = false;
                return;
            }

            // SENDING_STREAMS & streams list is not null -> we have just sent some data.
            if ((e.listType == SktSkype.APP2APP_STREAMS.SENDING_STREAMS) & (e.streams != null))
            {
                msgHistory.AppendText("Datagram sent.\r\n");
                return;
            }
        }
Example #21
0
 // Keeping conversation list and listbox up-to-date
 public void OnSkypeConversationListChange(SktSkype sender, SktEvents.OnSkypeConversationListChangeArgs e)
 {
     if (e.type == SktConversation.LIST_TYPE.INBOX_CONVERSATIONS)
     {
         if (e.added)
         {
             conversationList.Insert(0, e.conversation);
             convListBox.Items.Insert(0, e.conversation);
         }
         else
         {
             conversationList.Remove(e.conversation);
             convListBox.Items.Remove(e.conversation);
         }
     }
 }
Example #22
0
 // Fired when connection to the runtime is established (or fails)
 // If it's up, we can initiate account login.
 // Once we have called account.LoginWithPassword, we can expect
 // OnAccountStatus events firing, in near future..
 public void OnConnect(object sender, SktEvents.OnConnectArgs e)
 {
     if (e.success)
     {
         textBox1.AppendText("Connection to runtime is up. Lets see if we can log in..\n");
         LoginRec login = tutorials.ShowLoginDialog(this);
         username = login.username;
         password = login.password;
         if (!login.abort)
         {
             account = skype.GetAccount(username);
             account.LoginWithPassword(password, false, true);
         }
     }
     else
     {
         textBox1.AppendText("IPC handshake failed with: " + e.handshakeResult + "\n");
     }
 }
Example #23
0
        public void OnVideoStatus(SktVideo sender, SktEvents.OnVideoStatusArgs e)
        {
            Video video = (Video)sender;
            // Checking if we know already, what participant we are linked to
            // participant and video get linked in OnParticipantVideoStatus
            // and also in CheckIfVideoIsAvailable
            if (video.participant == null) return;

            if (e.value == SktVideo.STATUS.AVAILABLE)
            {
                video.Start();
            }
            else
            {
                if (e.value == SktVideo.STATUS.RUNNING)
                {
                    // just in case.. checking if the participant already has renderer running
                    if (!video.participant.pic.IsRunning) video.participant.SwitchPicModeToVideo();
                }
                else
                {
                    // The video is no longer streaming. Switching participant UI back to displaying avatar
                    video.participant.SwitchPicModeToAvatar();
                }
            }
        }
Example #24
0
        // This is where we handle live session starts and ends. This can be most easily and reliably
        // done via monitoring special non-text messages in our live conversation.
        public void OnSkypeMessage(SktSkype sender, SktEvents.OnSkypeMessageArgs e)
        {
            if (e.conversation != liveSession) return;

            switch (e.message.P_TYPE)
            {
                // Live session goes up - we switch UI into live session mode
                case SktMessage.TYPE.STARTED_LIVESESSION:
                    UiToInCallMode();
                    liveSession = e.conversation;
                    break;

                // Live session goes down - we switch UI into "wait for next call" mode
                // NB! this will fire only when the entire conversation goes off-live!
                // Should we leave before others, by clicking the drop call button,
                // then we will need to handle the UI state change there as well.
                case SktMessage.TYPE.ENDED_LIVESESSION:
                    liveSession = null;
                    UiToWaitingMode();
                    break;
            };
        }
Example #25
0
 void OnParticipantVideoStatus(SktParticipant sender, SktEvents.OnParticipantVideoStatusArgs e)
 {
     if (e.value == SktParticipant.VIDEO_STATUS.VIDEO_AVAILABLE)
     {
         // Linking participant and video objects
         Participant participant = (Participant)sender;
         participant.video = (Video)participant.GetVideo();
         participant.video.participant = participant;
         participant.SwitchPicModeToVideo();
     }
 }
Example #26
0
        public void OnAccountStatus(SktAccount sender, SktEvents.OnAccountStatusArgs e)
        {
            this.msgLog.AppendText(e.value.ToString() + "\r\n");

            if (e.value == SktAccount.STATUS.LOGGED_IN)
            {
                this.msgLog.AppendText("Retrieving conversation list..\r\n");
                conversationList = skype.GetConversationList(SktConversation.LIST_TYPE.INBOX_CONVERSATIONS);

                foreach (SktConversation conversation in conversationList)
                {
                    this.convListBox.Items.Add(conversation);
                }
                UpdateAudioDevices();
                UpdateVideoDevices();
            }

            if (e.value == SktAccount.STATUS.LOGGED_OUT)
            {
                this.msgLog.AppendText("Login failed because of " + sender.P_LOGOUTREASON + "\r\n");
            }
        }
Example #27
0
        // Here we catch both incoming and outgoing messages.
        public void OnSkypeMessage(SktSkype sender, SktEvents.OnSkypeMessageArgs e)
        {
            if (conversationListBox.Items.Contains(e.conversation))
            {
                var conv = (Conversation)e.conversation;
                var msg = (Message)e.message;

                // if history is loaded, we append the new message to it
                if (conv.messageHistoryLoaded)
                {
                    string newLine = msg.GetText();
                    conv.messageHistory = conv.messageHistory + newLine;

                    if (conv == conversationListBox.SelectedItem)
                    {
                        // updating our TextBox with new text..
                        messageLog.AppendText(newLine);
                        // and this is how we set the conversation as "read"
                        conv.SetConsumedHorizon(DateTime.Now, false);
                    }
                }
                // if history is not loaded - we don't care. This message will be fetched
                // together with others, when needed.
            }
        }
Example #28
0
        // Now, this is the tricky bit! What happens when you first start out with an 1-on-1 call,
        // and then someone adds more people, making it into a conference call? Well, what happens is this:
        // 1. a new conversation is created, both people from old 1-on-1 call and the new ones get added in;
        // 2. the new conversation goes live;
        // 3. the old 1-on-1 conversation goes OFF live;
        // 4. in the old 1-on-1, a message gets posted with type SktMessage.TYPE.SPAWNED_CONFERENCE
        //    and this event will fire with new conversation in the e.spawned field.
        // At that point, what we need to do is to switcheverything over to that one.
        void OnConversationSpawnConference(SktConversation sender, SktEvents.OnConversationSpawnConferenceArgs e)
        {
            if (sender == liveSession)
            {
                // As participants are conversation-specific, our participants list is now invalid as well.
                // At this point we will need to do a *complete* re-load of both participants and the UI!
                participants.Clear();
                while (participantPanel.Controls.Count > 0) participantPanel.Controls.RemoveAt(0);

                liveSession = e.spawned;
                participants = liveSession.GetParticipants(SktConversation.PARTICIPANTFILTER.ALL);
                int participantsInNewConv = participants.Count;
                for (int i = 0; i < participantsInNewConv; i++)
                    AddParticipantToLiveSession((Participant)participants[i]);
            }
        }
        /** Skype constructor for console applications. In console applications, all the callbacks you assign to events
        and property change updates will fire in individual threads. You will need to synchronize data with your main thread,
        as necessary.

        NB! You should only use the logging switches during development and testing. Do not leave them ON in
        your production code. The logging, particularly transport logging, can cause substantial drop in your
        application's performane. To give you the picture - transport logging does a file append operation
        every time a byte is read from or written to the IPC socket.

        @param cert X509 certificate, extracted from your keypair file. NB! The X509Certificate2 assumes the keyfile
        being in .pfx format. If your keyfile is still in pem format, you will need to convert it to .pfx.

        @param wrapperLog Enables generation of wrapper debug log. This log records wrapper internal activity. You can use
        this two ways. By default, simply switching this argument true, will create a "wrapper.log" file in your
        application's executable directory. The name of this file cannot be changed, each client run will overwrite
        the existing file. Secondly, you can assign your own callback to skype.events.OnLog event.
        With this callback you can get the log in real time, in your UI. If the OnLog event is assigned, the "wrapper.log"
        will no longer be generated.

        @param transportLog Enables generation of wrapper transport log. The transport log contains IPC traffic
        between the wrapper and the runtime. The log file is named "transport.log" and is also placed in your
        application's executable directory.

        @param port local TCP port for wrapper-runtime communication. If you launch the runtime automatically with
        SktSkype.LaunchRuntime then the runtime will also take the communication port from this value.
        */
        public SktSkype(
        X509Certificate2 cert, 
        bool wrapperLog=false, 
        bool transportLog=false,
        int port=8963)
            : base(cert, wrapperLog, transportLog, port)
        {
            debugMode = false;
            RegisterDefaultClasses();
            events = new SktEvents(null, this);
            events.OnConnect += events.OnConnectInternalCallback;
        }
Example #30
0
 private void OnParticipantTextStatus(object o, SktEvents.OnParticipantTextStatusArgs e)
 {
     this.Text = e.value.ToString();
 }