Пример #1
0
        void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                StatusTextBlock.Text = "A conversation is added";
            }), null);

            if (_conversation != null && e.Conversation.GetHashCode() == _conversation.GetHashCode())
            {
                _sharingModality = (ApplicationSharingModality)_conversation.Modalities[ModalityTypes.ApplicationSharing];
                _sharingModality.ModalityStateChanged += sharingModality_ModalityStateChanged;

                _conversation.AddParticipant(_remoteContact);
            }

            // populate the ShareableListBox with ShareableResources
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                StatusTextBlock.Text = "Populating shareable resources...";
                ShareableResourcesListBox.Items.Clear();
                for (int i = 0; i < _sharingModality.ShareableResources.Count; i++)
                {
                    SharingResource sr = _sharingModality.ShareableResources[i];
                    ShareableResourcesListBox.Items.Add(sr.Name);
                }
                ShareableResourcesListBox.SelectedIndex = 0;
                StatusTextBlock.Text = "Shareable resources are populated.";
            }), null);
        }
Пример #2
0
        void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            try
            {
                // this sample will only handle one conversation
                if (_conversation == null)
                {
                    _conversation = e.Conversation;

                    if (_conversation.Modalities[ModalityTypes.ContentSharing].State == ModalityState.Notified)
                    {
                        // Conversation orignated with remote SIP user. Lets set the modality.
                        // Accept will happen when user clicks Accept button in UI.
                        _contentModality = (ContentSharingModality)_conversation.Modalities[ModalityTypes.ContentSharing];
                        // Following event will help maintain the Content Bin
                        _contentModality.ContentAdded += new EventHandler <ContentCollectionChangedEventArgs>(_contentModality_ContentAdded);
                    }
                    else
                    {
                        // lets add a participant
                        if (_conversation.CanInvoke(ConversationAction.AddParticipant))
                        {
                            _conversation.ParticipantAdded += new EventHandler <ParticipantCollectionChangedEventArgs>(Conversation_ParticipantAdded);
                            _conversation.AddParticipant(_lyncClient.ContactManager.GetContactByUri(targetUri));
                            // above call will result in ParticipantAdded event.
                            // In that event handler, lets Connect the ContentModality.
                        }
                    }
                }
            }
            catch (ArgumentException)
            {
                dispatcher.BeginInvoke(new Action <string>(Log), "Argument Exception: Is the SIP address a valid URI?");
            }
        }
Пример #3
0
        private void ConversationAdd(object sender, ConversationManagerEventArgs e)
        {
            string       DisplayName = "";
            Conversation c           = e.Conversation;

            foreach (Participant p in c.Participants)
            {
                if (!p.IsSelf)
                {
                    DisplayName += ", " + p.Properties[ParticipantProperty.Name].ToString();
                    // conbox1.Items.Add(p.Properties[ParticipantProperty.Name].ToString());
                }
            }
            if (DisplayName.Length > 3)
            {
                DisplayName = DisplayName.Substring(2);
            }
            else
            {
                DisplayName = "My Self";
            }

            dtConv.Rows.Add(DisplayName, c.Properties[ConversationProperty.Id].ToString());
            dtConv.AcceptChanges();
            needUpdated = true;

            //dtConv.Rows.Add();
        }
Пример #4
0
 /// <summary>
 /// This method is called when the ConversationManagerEvent is triggered, and will trigger this event if an audio or video call is received.
 /// </summary>
 void Conversations_ConversationAdded(object sender, ConversationManagerEventArgs e)
 {
     if (e.Conversation.Modalities[ModalityTypes.AudioVideo].State == ModalityState.Notified)
     {
         Trigger();
     }
 }
        private void conversation_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            var conversation = e.Conversation;

            conversation.ParticipantAdded   += conversation_ParticipantAdded;
            conversation.ParticipantRemoved += conversation_ParticipantRemoved;

            // Available Modalities
            // None = 0,
            // InstantMessage = 1,
            // AudioVideo = 2,
            // Reserved1 = 4,
            // Reserved2 = 8,
            // Invalid = -1,

            // We use InstantMessage and AudioVideo
            if (e.Conversation.Modalities.ContainsKey(ModalityTypes.InstantMessage) &&
                e.Conversation.Modalities[ModalityTypes.InstantMessage] != null)
            {
                var imModality = (InstantMessageModality)e.Conversation.Modalities[ModalityTypes.InstantMessage];
                imModality.InstantMessageReceived += conversation_InstantMessageSent;
            }

            if (e.Conversation.Modalities.ContainsKey(ModalityTypes.AudioVideo) &&
                e.Conversation.Modalities[ModalityTypes.AudioVideo] != null)
            {
                var avModality = (AVModality)e.Conversation.Modalities[ModalityTypes.AudioVideo];
                avModality.ModalityStateChanged += av_ModalityStateChanged;
            }

            conversation.StateChanged += conversation_StateChanged;
        }
Пример #6
0
 /// <summary>
 /// This event is fired when the ConversationWindow is closing.  This sample application is handling
 /// the event for illustration purposes only.
 /// </summary>
 void HandleConversationRemoved(object sender, ConversationManagerEventArgs e)
 {
     if (ConversationRemoveEvent != null)
     {
         ConversationRemoveEvent(this, null);
     }
 }
        void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            var participants = e.Conversation.Participants;

            e.Conversation.ParticipantAdded += new EventHandler <ParticipantCollectionChangedEventArgs>(Conversation_ParticipantAdded);
            e.Conversation.StateChanged     += new EventHandler <ConversationStateChangedEventArgs>(Conversation_StateChanged);
        }
Пример #8
0
 void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
 {
     e.Conversation.ContextDataReceived += Conversation_ContextDataReceived;
     e.Conversation.ContextDataSent     += Conversation_ContextDataSent;
     e.Conversation.ParticipantAdded    += Conversation_ParticipantAdded;
     //MessageBox.Show("Added");
 }
Пример #9
0
 private void OnConversationManagerConversationRemoved(object sender, ConversationManagerEventArgs e)
 {
     if (_currentLyncConversation != null)
     {
         //	_currentLyncConversation.Close();
     }
 }
Пример #10
0
        private void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            bool IncomingCall = false;
            foreach (var Modality in e.Conversation.Modalities)
            {
                if (Modality.Value != null && Modality.Value.State == ModalityState.Notified)
                {
                    IncomingCall = true;
                }
            }

            if (IncomingCall)
            {
                if (Properties.Settings.Default.DanceOnIncomingCall)
                {
                    _buddies.Dance(5000);
                    _buddies.FlapWings(5000);
                }

                if (e.Conversation.Participants.Count >= 2)
                {
                    var Initiator = e.Conversation.Participants[1].Contact;
                    Trace.WriteLine(string.Format("LyncFellow: Initiator.Uri=\"{0}\"", Initiator.Uri));
                    // magic heartbeat for incoming conversations from G&K ;-)
                    if (Initiator.Uri.Contains("glueckkanja")
                        || Initiator.Uri.Contains("+4969800706")
                        || Initiator.Uri.Contains("+49711460533")
                        || Initiator.Uri.Contains("+4940609298")
                        || Initiator.Uri.Contains("+49151182260"))
                    {
                        _buddies.Heartbeat(10000);
                    }
                }
            }
        }
Пример #11
0
        /// <summary>
        /// Handles ConversationAdded state change event raised on ConversationsManager
        /// </summary>
        /// <param name="source">ConversationsManager The source of the event.</param>
        /// <param name="data">ConversationsManagerEventArgs The event data. The incoming Conversation is obtained here.</param>
        void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs data)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            if (data.Conversation.Modalities[ModalityTypes.InstantMessage].State == ModalityState.Connected)
            {
                sb.Append("Incoming IM from ");
            }
            string callerName = data.Conversation.Participants[1].Contact.GetContactInformation(ContactInformationType.DisplayName).ToString();

            sb.Append(callerName);
            sb.Append(System.Environment.NewLine);
            sb.Append("Do you want to Ignore the invitiation? IM P2P is always auto-accepted");
            if (System.Windows.Forms.MessageBox.Show(
                    sb.ToString()
                    , "Incoming Invitation"
                    , System.Windows.Forms.MessageBoxButtons.YesNo
                    , System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
            {
                data.Conversation.ParticipantAdded += Conversation_ParticipantAdded;
                data.Conversation.StateChanged     += new EventHandler <ConversationStateChangedEventArgs>(Conversation_StateChanged);
            }
            else
            {
                data.Conversation.End();
            }
        }
Пример #12
0
        void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            // this sample will only handle one conversation
            if (_conversation == null)
            {
                _conversation = e.Conversation;

                if (_conversation.Modalities[ModalityTypes.ContentSharing].State == ModalityState.Notified)
                {
                    // Conversation orignated with remote SIP user. Lets set the modality.
                    // Accept will happen when user clicks Accept button in UI.
                    _contentModality = (ContentSharingModality)_conversation.Modalities[ModalityTypes.ContentSharing];
                }
                else
                {
                    // lets add a participant
                    if (_conversation.CanInvoke(ConversationAction.AddParticipant))
                    {
                        _conversation.ParticipantAdded += new EventHandler <ParticipantCollectionChangedEventArgs>(Conversation_ParticipantAdded);
                        _conversation.AddParticipant(_lyncClient.ContactManager.GetContactByUri(targetUri));
                        // above call will result in ParticipantAdded event.
                        // In that event handler, lets Connect the ContentModality.
                    }
                }
            }
        }
        void _onConversationAdded(object sender, ConversationManagerEventArgs ea)
        {
            System.Console.WriteLine("conversation added");

            _conversations.Add(Guid.NewGuid().ToString(), ea.Conversation);
            ea.Conversation.ParticipantAdded   += _onParticipantAdded;
            ea.Conversation.ParticipantRemoved += _onParticipantRemoved;
        }
Пример #14
0
 private void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
 {
     if (ContainsAVCall((Conversation)e.Conversation))
     {
         e.Conversation.Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += BlinkLyncConnectorAppContext_ModalityStateChanged;
         SetBlink1State(new Rgb(0, 0, 255));
     }
 }
Пример #15
0
 private void ConversationAdded(object sender, ConversationManagerEventArgs e)
 {
     e.Conversation.ParticipantAdded   -= ParticipantAdded;
     e.Conversation.ParticipantRemoved -= ParticipantRemoved;
     e.Conversation.ParticipantAdded   += ParticipantAdded;
     e.Conversation.ParticipantRemoved += ParticipantRemoved;
     //e.Conversation.StateChanged -= Conversation_StateChanged;
     //e.Conversation.StateChanged += Conversation_StateChanged;
 }
Пример #16
0
        /// Handles ConversationAdded state change event raised on ConversationsManager
        /// <param name="source">ConversationsManager: The source of the event</param>
        /// <param name="data">ConversationsManagerEventArgs The event data. The incoming Conversation is obtained here</param>
        void ConversationsManager_ConversationAdded(Object source, ConversationManagerEventArgs data)
        {
            // Register for Conversation state changed events.
            data.Conversation.ParticipantAdded += Conversation_ParticipantAdded;
            //data.Conversation.StateChanged += Conversation_ConversationChangedEvent;

            // Add a remote participant.
            data.Conversation.AddParticipant(_LyncClient.ContactManager.GetContactByUri(this.myRemoteParticipantUri));
        }
Пример #17
0
 void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
 {
     this.Dispatcher.BeginInvoke((Action)(() =>
     {
         this.Topmost = false;
         this.Hide();
         this.WindowState = System.Windows.WindowState.Minimized;
     }));
 }
        private void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
        {
            var callId = e.Conversation.Properties[ConversationProperty.Id].ToString();

            OnCallChanged(
                new SkypeCall()
            {
                CallId = callId
            }, SkypeCallState.Finished);
        }
Пример #19
0
 void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
 {
     if (_conversation != null)
     {
         if (e.Conversation.Equals(_conversation))
         {
             _conversation = null;
         }
     }
 }
Пример #20
0
        static void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
        {
            // DumpConversation(e.Conversation);
            var container = FindContainerOf(e.Conversation);

            if (container != null)
            {
                ActiveConversations.Remove(container);
            }
        }
        //ConversationAdded event handler
        internal void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            // Register for Conversation state changed events.
            e.Conversation.ParticipantAdded += new EventHandler <ParticipantCollectionChangedEventArgs>(Conversation_ParticipantAdded);
            e.Conversation.StateChanged     += new EventHandler <ConversationStateChangedEventArgs>(Conversation_StateChanged);

            // Add a remote participant.
            if (_LyncClient.ContactManager.GetContactByUri(this.myRemoteParticipantUri) != null)
            {
                e.Conversation.AddParticipant(_LyncClient.ContactManager.GetContactByUri(this.myRemoteParticipantUri));
            }
        }
Пример #22
0
 private void ConversationRemoved(object sender, ConversationManagerEventArgs args)
 {
     try
     {
         ChatLog.Close(args.Conversation);
     }
     catch (Exception ex)
     {
         LogException("ConversationRemoved", ex);
         throw;
     }
 }
 private static void HandleConversationAdded(object sender, ConversationManagerEventArgs e)
 {
     try
     {
         string s  = e.Conversation.GetApplicationData(_contextualApplicationGuid);
         string id = s.Split('\n')[3];
         _managers[id].HandleConversationStarted(e.Conversation);
     }
     catch (ItemNotFoundException)
     {
         //Probably means that a conversation was started by something else. This is safe to ignore.
     }
 }
Пример #24
0
        private void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            e.Conversation.ParticipantAdded += Conversation_ParticipantAdded;

            foreach (var key in e.Conversation.Modalities.Keys)
            {
                Modality val = e.Conversation.Modalities[key];
                if (val != null)
                {
                    val.Accept();
                }
            }
        }
        void _onConversationRemoved(object sender, ConversationManagerEventArgs e)
        {
            System.Console.Write("conv removed " + _conversations.Count);

            e.Conversation.ParticipantAdded   -= _onParticipantAdded;
            e.Conversation.ParticipantRemoved -= _onParticipantRemoved;

            if (_conversations.ContainsValue(e.Conversation))
            {
                _conversations.Remove(_conversations.First(x => x.Value == e.Conversation).Key);
            }
            System.Console.WriteLine(" " + _conversations.Count);
        }
Пример #26
0
        static void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            InitializeTracking(e.Conversation);

            if (e.Conversation.Modalities[ModalityTypes.AudioVideo].State != ModalityState.Disconnected)
            {
                StoreConversation(e.Conversation);
            }
            else
            {
                e.Conversation.Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += Program_ModalityStateChanged;
            }
        }
        /// <summary>
        /// Handles the event raised when the active conversation is terminated and removed from the collection of conversations
        /// on ConversationManager.Conversations
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
        {
            //If the removed conversation is the conversation hosted by this window then resume listening for new conversations.
            if (_conversation == e.Conversation)
            {
                EnableDisableButtonDelegate buttonDelegate = new EnableDisableButtonDelegate(EnableDisableButton);
                this.Invoke(new SetContactSelectionModeDelegate(SetContactSelectionMode), new object[] { SelectionMode.MultiSimple });
                this.Invoke(buttonDelegate, new object[] { EndConversation_Button, false });
                this.Invoke(buttonDelegate, new object[] { Disconnect_Button, false });
                this.Invoke(buttonDelegate, new object[] { Request_Button, false });
                this.Invoke(buttonDelegate, new object[] { StartSharingResource_Button, false });
                this.Invoke(buttonDelegate, new object[] { Start_Button, true });
                this.Invoke(new ChangeLabelTextDelegate(ChangeLabelText), new object[] { ContactList_Label, "1) Choose contacts" });
                this.Invoke(new UpdateSharedResourcesListboxDelegate(UpdateSharedResourcesListbox));

                this.Invoke(new LoadAllContactsDelegate(LoadAllContacts));


                //Un-register for participant events on the conversation that is terminated.
                _conversation.ParticipantAdded   -= _conversation_ParticipantAdded;
                _conversation.ParticipantRemoved -= _conversation_ParticipantRemoved;
                _conversation.StateChanged       -= _conversation_StateChanged;

                //Unregister for events on the terminated conversation's sharing modality events.
                _sharingModality.ModalityStateChanged        -= _sharingModality_ModalityStateChanged;
                _sharingModality.ControlRequestReceived      -= _sharingModality_ControlRequestReceived;
                _sharingModality.LocalSharedResourcesChanged -= _sharingModality_LocalSharedResourcesChanged;
                _sharingModality.ControllerChanged           -= _sharingModality_ControllerChanged;
                _sharingModality.ActionAvailabilityChanged   -= _sharingModality_ActionAvailabilityChanged;



                //Unregister for the application sharing events on each and every participant in the terminated
                //conversation
                foreach (string contactUri in _selectedContacts.Keys)
                {
                    ApplicationSharingModality participantSharingModality = (ApplicationSharingModality)_participantSharingModalities[contactUri];
                    participantSharingModality.ActionAvailabilityChanged -= _sharingModality_ActionAvailabilityChanged;
                }


                //Resume listening for new conversations
                _LyncClient.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded;
                //de-reference the class state
                _conversation = null;
                _ResourceControllingContact = null;
                _sharingModality            = null;
                _participantSharingModalities.Clear();
            }
        }
Пример #28
0
        void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
        {
            arduino.ClearCallerId();

            if (lyncClient.State == ClientState.SignedIn)
            {
                int numOfConversations = lyncClient.ConversationManager.Conversations.Count;
                if (numOfConversations != 0)
                {
                    Conversation lastConversation = lyncClient.ConversationManager.Conversations[numOfConversations - 1];
                    arduino.SetCallerId(lastConversation.Participants[1].Contact.GetContactInformation(ContactInformationType.DisplayName).ToString());
                }
            }
        }
        private void conversation_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            Conversation conversation = e.Conversation;
            conversation.ParticipantAdded += new EventHandler<ParticipantCollectionChangedEventArgs>(conversation_ParticipantAdded);
            conversation.ParticipantRemoved += new EventHandler<ParticipantCollectionChangedEventArgs>(conversation_ParticipantRemoved);

            if (e.Conversation.Modalities.ContainsKey(ModalityTypes.InstantMessage) && e.Conversation.Modalities[ModalityTypes.InstantMessage] != null)
            {
                var imModality = (InstantMessageModality)e.Conversation.Modalities[ModalityTypes.InstantMessage];
                imModality.InstantMessageReceived += new EventHandler<MessageSentEventArgs>(conversation_InstantMessageSent);
            }

            conversation.StateChanged += new EventHandler<ConversationStateChangedEventArgs>(conversation_StateChanged);
        }
Пример #30
0
 private void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
 {
     //Alert incoming call
     if (e.Conversation != null)
     {
         if (e.Conversation.Modalities.ContainsKey(ModalityTypes.AudioVideo) &&
             e.Conversation.Modalities[ModalityTypes.AudioVideo].State != ModalityState.Disconnected)
         {
             //Incoming call
             Console.WriteLine("Incoming call!");
             controlBusylight("1,kRing;");
         }
     }
 }
        /// <summary>
        /// Handles ConversationAdded state change event raised on ConversationsManager
        /// </summary>
        /// <param name="source">ConversationsManager The source of the event.</param>
        /// <param name="data">ConversationsManagerEventArgs The event data. The incoming Conversation is obtained here.</param>
        void ConversationsManager_ConversationAdded(Object source, ConversationManagerEventArgs data)
        {
            if (_targetUri == null || _targetUri.Length == 0)
            {
                //***********************************************
                //User has not specified the SIP address of a remote user.
                //***********************************************
                return;
            }

            //***********************************************
            //Register for Conversation state changed events.
            //***********************************************
            data.Conversation.ParticipantAdded += Conversation_ParticipantAdded;
            data.Conversation.StateChanged     += Conversation_StateChangedEvent;
            try
            {
                //***********************************************
                //Get a Contact instance using the SIP address of a
                //remote user. _targetUri is a class field that is initiated
                //with the contents of the SIP address text entry box
                //on the conversation form.
                //***********************************************
                _remoteContact = _ClientModel._LyncClient.ContactManager.GetContactByUri(_targetUri);

                //***********************************************
                //Register for contact information changed events to catch changes in contact availablity before and during a conversation.
                //***********************************************
                _remoteContact.ContactInformationChanged += new EventHandler <ContactInformationChangedEventArgs>(_remoteContact_ContactInformationChanged);

                //***********************************************
                //Set conversation window title to current state of conversation
                //***********************************************
                this.Dispatcher.Invoke(FormActor, new object[] { FormActions.UpdateWindowTitle, this, "Conversation is " + data.Conversation.State.ToString() });

                //**************************************
                //Call helper method to add the contact to the conversation.
                //**************************************
                if (AddContactToConversation(data.Conversation, _remoteContact) == false)
                {
                    this.Dispatcher.Invoke(FormActor, new object[] { FormActions.UpdateLabel, ActivityText_Label, "ConversationAdded Event: Participant not added" });
                }
            }
            catch (ItemNotFoundException)
            {
                data.Conversation.End();
            }
            catch (ItemAlreadyExistException) { }
        }
        private void conversation_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            Conversation conversation = e.Conversation;

            conversation.ParticipantAdded   += new EventHandler <ParticipantCollectionChangedEventArgs>(conversation_ParticipantAdded);
            conversation.ParticipantRemoved += new EventHandler <ParticipantCollectionChangedEventArgs>(conversation_ParticipantRemoved);

            if (e.Conversation.Modalities.ContainsKey(ModalityTypes.InstantMessage) && e.Conversation.Modalities[ModalityTypes.InstantMessage] != null)
            {
                var imModality = (InstantMessageModality)e.Conversation.Modalities[ModalityTypes.InstantMessage];
                imModality.InstantMessageReceived += new EventHandler <MessageSentEventArgs>(conversation_InstantMessageSent);
            }

            conversation.StateChanged += new EventHandler <ConversationStateChangedEventArgs>(conversation_StateChanged);
        }
Пример #33
0
        //private void ContactInformationChanged(object sender, ContactInformationChangedEventArgs args)
        //{
        //	if (args.ChangedContactInformation.Contains(ContactInformationType.Availability))
        //	{
        //		ContactStatus status = LyncHelper.GetContactStatus((Contact) sender);

        //		if (status != null)
        //		{
        //			Debug.WriteLine("{0} updated status: {1} {2}", status.Username, status.Availability, status.Activity);
        //		}
        //	}
        //}

        private void ConversationAdded(object sender, ConversationManagerEventArgs args)
        {
            try
            {
                ChatLog.Open(args.Conversation);

                // subscribe to event for new participants being added to this conversation
                args.Conversation.ParticipantAdded += ParticipantAdded;
            }
            catch (Exception ex)
            {
                LogException("ConversationAdded", ex);
                throw;
            }
        }
Пример #34
0
        static void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            Conversation conversation = e.Conversation;

            var details = "Hello Lync 2013 SDK!" + Environment.NewLine;

            if (conversation != null)
            {
                if (e.Conversation.Modalities[ModalityTypes.InstantMessage].State == ModalityState.Notified)
                {

                    if (conversation.Properties.ContainsKey(ConversationProperty.Inviter))
                    {

                        var contact = (Contact)conversation.Properties[ConversationProperty.Inviter];

                        if (contact != null)
                        {

                            details += "  INVITE FROM: " + contact.Uri + Environment.NewLine;

                        }

                    }

                    foreach (Participant p in conversation.Participants)
                    {
                        details += "  Participiant:" + p.Contact.Uri + Environment.NewLine;
                    }

                    if (_conversation == null)
                    {
                        _conversation = conversation;
                        _LyncConversation = new LyncConversation(conversation);
                        foreach (Participant p in conversation.Participants)
                        {
                            if (client.Self.Contact.Uri.ToLower() != p.Contact.Uri.ToLower())
                            {
                                ((InstantMessageModality)p.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += _LyncConversation.InstantMessageReceived;
                            }
                        }
                    }
                }
            }

            Console.WriteLine("Incomming conversation details: " + details);
        }
Пример #35
0
        private static void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e, Func<bool> autoAnswerPredicate)
        {
            var lync = LyncClient.GetClient();
            var incomingAV = false;
            var sb = new StringBuilder();
            var av = e.Conversation.Modalities[ModalityTypes.AudioVideo];
            var im = e.Conversation.Modalities[ModalityTypes.InstantMessage];

            // Is this an audio/video invitation?
            if (av.State == ModalityState.Notified)
            {
                if (lync.DeviceManager.ActiveAudioDevice != null)
                {
                    sb.Append("Incoming call from ");
                    incomingAV = true;
                }
                else
                {
                    av.Reject(ModalityDisconnectReason.NotAcceptableHere);
                }
            }
            if (im.State == ModalityState.Connected)
            {
                sb.Append("Incoming IM from ");
            }

            sb.Append(String.Join(", ", e.Conversation.Participants.Select(i => i.Contact.Uri)));
            Debug.WriteLine(sb.ToString());

            //eventArgs.Conversation.ParticipantAdded += Conversation_ParticipantAdded;
            //eventArgs.Conversation.StateChanged += Conversation_ConversationChangedEvent;
            //eventArgs.Conversation.ActionAvailabilityChanged += Conversation_ActionAvailabilityChanged;

            if (incomingAV && autoAnswerPredicate())
            {
                e.Conversation.AnswerVideo();
            }
        }
        /// <summary>
        /// Called when a conversation is removed.
        /// 
        /// Will dispose the window associated with the removed conversation.
        /// </summary>
        void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
        {
            //posts the execution into the UI thread
            UiThreadControl.BeginInvoke(new MethodInvoker(delegate()
            {
                //checks if a conversation window was created, and dispose it
                if (this.ConversationInfos.ContainsKey(e.Conversation))
                {
                    //gets the existing conversation window
                    ConversationInfo info = ConversationInfos[e.Conversation];

                    //remove the conversation from the dictionary
                    this.ConversationInfos.Remove(e.Conversation);

                    if (info.ConversationEnded != null)
                        info.ConversationEnded(null);

                    //cleanup
                    info.Dispose();
                }

            }));
        }
Пример #37
0
        private void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            bool IncomingCall = false;
              bool NewConversationIM = false;
              foreach (var Modality in e.Conversation.Modalities)
              {
            if (Modality.Value != null && Modality.Value.State == ModalityState.Notified)
            {
              if (Modality.Key == ModalityTypes.InstantMessage)
              {
            NewConversationIM = true;
              }
              else if (Modality.Key == ModalityTypes.AudioVideo)
              {
            IncomingCall = true;
              }
            }
              }

              if (IncomingCall)
              {
            if (Properties.Settings.Default.IncomingCall_DoDance)
              _buddies.Dance(5000);
            if (Properties.Settings.Default.IncomingCall_DoFlapWings)
              _buddies.FlapWings(5000);
            if (Properties.Settings.Default.IncomingCall_DoGlowHeart)
              _buddies.Heartbeat(5000);

            if (Properties.Settings.Default.IncomingCall_DoBlinkSingleColor)
              _buddies.BlinkSingleColor(5000);
            else if (Properties.Settings.Default.IncomingCall_DoBlinkRainbow)
              _buddies.Rainbow(5000);
              }

              if (NewConversationIM)
              {
            if (Properties.Settings.Default.NewIMConversation_DoDance)
              _buddies.Dance(5000);
            if (Properties.Settings.Default.NewIMConversation_DoFlapWings)
              _buddies.FlapWings(5000);
            if (Properties.Settings.Default.NewIMConversation_DoGlowHeart)
              _buddies.Heartbeat(5000);

            if (Properties.Settings.Default.NewIMConversation_DoBlinkSingleColor)
              _buddies.BlinkSingleColor(5000);
            else if (Properties.Settings.Default.NewIMConversation_DoBlinkRainbow)
              _buddies.Rainbow(5000);
              }
        }
Пример #38
0
 private void ConversationAdded(object sender, ConversationManagerEventArgs args)
 {
     var lconversation = new LConversation(args.Conversation, _messageDelegate);
     _mapConversations.Add(args.Conversation, lconversation);
 }
Пример #39
0
        void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            Conversation conv = e.Conversation;
            _convServ = new ConversationService(conv);
            _convServ.Start();
            _convServ.MessageRecived += new MessageRecived(_convServ_MessageRecived);

            _activeConversations.Add(conv);

            //Modality modality;
            //if (conv.Modalities.TryGetValue(ModalityTypes.InstantMessage, out modality))
            //{
            //    InstantMessageModality instMsg = ((InstantMessageModality)modality);
            //    instMsg.InstantMessageReceived += new EventHandler<MessageSentEventArgs>(Form1_InstantMessageReceived);

            //}
        }
 static void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
 {
     // TODO - this will probably kill the existing conversation, if a new one comes in - change it!
     _conversation = null;
     OnCallEnded();
 }
Пример #41
0
 private static void ConeversAded(object sender, ConversationManagerEventArgs e)
 {
     e.Conversation.ParticipantAdded += new EventHandler<ParticipantCollectionChangedEventArgs>(PartiAded);
 }
Пример #42
0
 private void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
 {
     RefreshConversations();
 }
Пример #43
0
        /// <summary>
        /// Create conversation log file and listen on what participants say
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void conversations_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            String firstContactName = e.Conversation.Participants.Count > 1
            ? e.Conversation.Participants[1].Contact.GetContactInformation(ContactInformationType.DisplayName).ToString()
            : "meet now";
            DateTime currentTime = DateTime.Now;

            String fileLog = String.Format(_fileLog, firstContactName.Replace(", ", "_"), currentTime.ToString("yyyyMMdd"));

            String logHeader;
            FileInfo[] Files = _folderLog.GetFiles("*.log");
            if (Files.Count(f => f.Name == fileLog.Substring(fileLog.LastIndexOf('\\') + 1)) == 0)
            {
                logHeader = String.Format(LOG_HEADER, firstContactName, currentTime.ToString("yyyy/MM/dd"));
            }
            else
            {
                logHeader = String.Format(LOG_MIDDLE_HEADER);
            }

            using (FileStream stream = File.Open(fileLog, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
            {
                using (StreamWriter writer = new StreamWriter(stream))
                {
                    writer.WriteLine(logHeader);
                }
            }

            Conversation conv = e.Conversation;

            //detect all participant (including user)
            conv.ParticipantAdded += (_sender, _e) =>
            {
                var participant = _e.Participant;
                InstantMessageModality remoteImModality = (InstantMessageModality)participant.Modalities[ModalityTypes.InstantMessage];

                //detect all messages (including user's)
                remoteImModality.InstantMessageReceived += (__sender, __e) =>
                {
                    _log.Info("message event: " + __e.Text);
                    remoteImModality_InstantMessageReceived(__sender, __e, fileLog);
                };
            };

            //get audio conversation informations about user (not the other participants)
            AVModality callImModality = (AVModality)conv.Participants[0].Modalities[ModalityTypes.AudioVideo];
            //notify call
            callImModality.ModalityStateChanged += (_sender, _e) =>
            {
                _log.Info("call event: " + _e.NewState);
                callImModality_ModalityStateChanged(_e, fileLog + ".mp3");
            };
        }
        //*****************************************************************************************
        //                              ConversationManager Event Handling
        //
        // ConversationAdded occurs when:
        // 1) A new conversation was created by this application
        // 2) A new conversation was created by another third party application or Lync itself
        // 2) An invite was received at this endpoint (InstantMessaging / AudioVideo)
        //
        // ConversationRemoved occurs when:
        // 1) A conversation is terminated
        //
        //*****************************************************************************************
        /// <summary>
        /// Called when a new conversation is added (incoming or outgoing).
        /// 
        /// Will create a window for this new conversation and show it.
        /// </summary>
        void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            //*****************************************************************************************
            //                              Registering for events
            //
            // It is very important that registering for an object's events happens within the handler
            // of that object's added event. In another words, the application should register for the
            // conversation events within the ConversationAdded event handler.
            //
            // This is required to avoid timing issues which would cause the application to miss events.
            // While this handler method is executing, the Lync client is unable to process events for
            // this application (synce its thread is running this method), so no events will be lost.
            //
            // By registering for events here, we guarantee that all conversation related events will be
            // caught the first time they occur.
            //
            // We want to show the availability of the buttons in the conversation window based
            // on the ActionAvailability events. The solution below uses a lock to allow the window
            // to load while holding the event queue. This prevents events from being raised even
            // before the user interface controls get a change to load.
            //
            //*****************************************************************************************

            //posts the execution into the UI thread
            UiThreadControl.BeginInvoke(new MethodInvoker(delegate()
            {
                //shows the new window
                //window.Show(this);

                //creates a new window (which will register for Conversation and child object events)
                ConversationInfo info = new ConversationInfo(e.Conversation, _LyncClient, this.lastHandle, this.lastBounds, this.lastConversationEndedCallback, this.lastVideoCallStartedCallback);
                this.ConversationInfos.Add(e.Conversation, info);

                this.lastConversationEndedCallback = null;
                this.lastVideoCallStartedCallback = null;
                //conversationWindowLock.Set();

                info.StartVideo();
            }));

            //waits until the window is loaded to release the SDK thread
            //conversationWindowLock.WaitOne();
        }
Пример #45
0
 private void ConversationManagerConversationAdded(object sender, ConversationManagerEventArgs e)
 {
     var handler = this.ConversationStarted;
     if (handler != null)
     {
         var contactInfo = this.GetParticipantInfoFromConversation(e.Conversation);
         handler(sender, new ConversationEventArgs(e.Conversation, contactInfo, this.currentConversationType));
     }
 }
 private static void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
 {
     _conversation = null;
     OnCallEnded();
 }
Пример #47
0
 private void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
 {
     e.Conversation.ParticipantAdded += new EventHandler<ParticipantCollectionChangedEventArgs>(Conversation_ParticipantAdded);
     _Conversation = e.Conversation;
 }
Пример #48
0
        static void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
        {
            Conversation conversation = e.Conversation;

            if (conversation != null)
            {
                Console.WriteLine("Closed conversation details: ");
                if (conversation.Participants != null)
                {
                    foreach (Participant p in conversation.Participants)
                    {
                        Console.WriteLine("  P:" + p.Contact.Uri);
                    }

                }

                if (_conversation == conversation)
                {
                    _conversation = null;
                    _LyncConversation = null;
                }
            }
        }
Пример #49
0
 private void ConversationRemoved(object sender, ConversationManagerEventArgs args)
 {
     _mapConversations.Remove(args.Conversation);
 }