Esempio n. 1
0
        /// <summary>
        /// OnNewIncomingConversation
        /// Handles new conversations initiated by a peer
        /// </summary>
        private void OnNewIncomingConversation(Conversation conversation, ChatType chatType)
        {
            Logger.Debug("NotificationManager.OnNewIncomingConversation was called");

            if (conversation.PeerUser == null)
            {
                Logger.Error("NewIncomingConversation event had a conversation with null PeerUser");
                return;
            }

            // If we have a ChatWindow for this conversation, don't do anything... the ChatWindow
            // will handle the change
            if (ChatWindowManager.ChatWindowExists(conversation.PeerUser.ID))
            {
                return;
            }

            if (chatType == ChatType.Text)
            {
                NotifyOfTextMessage(conversation);
            }
            else if (chatType == ChatType.Audio)
            {
                NotifyOfAudioRequest(conversation);
            }
            else if (chatType == ChatType.Video)
            {
                NotifyOfVideoRequest(conversation);
            }

            conversation.MessageReceived    += OnTextAdditionalMessageReceived;
            conversation.MediaChannelOpened += OnMediaChannelOpened;
            conversation.MediaChannelClosed += OnMediaChannelClosed;
            conversation.TextChannelOpened  += OnTextChannelOpened;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a chat of type with person
        /// </summary>
        static public void InitiateChat(Person person, ChatType type)
        {
            Logger.Debug("ChatWindowManager.InitiateChat with {0}", person.DisplayName);

            if (person.ProviderUser == null)
            {
                throw new ApplicationException("Person contained a null ProviderUser");
            }

            if (ChatWindowManager.ChatWindowExists(person.ProviderUser.ID) == true)
            {
                ChatWindow cw = ChatWindowManager.Instance.chatWindows[person.ProviderUser.ID];
                cw.UpdateChatType(type);
                cw.Present();
            }
            else
            {
                // Create a new ChatWindow
                ChatWindow cw = new ChatWindow(person, person.ProviderUser, type);
                ChatWindowManager.Instance.chatWindows[person.ProviderUser.ID] = cw;
                cw.DeleteEvent += ChatWindowManager.Instance.OnChatWindowDeleted;
                Logger.Debug("About to present the window to chat with: {0}", person.DisplayName);
                cw.Present();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// OnNewIncomingConversation
        /// Handles new conversations initiated by a peer
        /// </summary>
        static internal void HandleAcceptedConversation(Conversation conversation, ChatType chatType)
        {
            Logger.Debug("ChatWindowManager.NewAcceptedConversation was called");

            if (conversation.PeerUser == null)
            {
                Logger.Error("NewIncomingConversation event had a conversation with null PeerUser");
                return;
            }

            // If we have a ChatWindow for this conversation, don't do anything... the ChatWindow
            // will handle the change
            if (ChatWindowManager.ChatWindowExists(conversation.PeerUser.ID))
            {
                return;
            }

            ChatWindowManager cwm = ChatWindowManager.Instance;

            Logger.Debug("**************Creating chat window");
            ChatWindow cw = new ChatWindow(conversation, chatType);

            Logger.Debug("**************Creating chat window 2");
            cwm.chatWindows[conversation.PeerUser.ID] = cw;
            cw.DeleteEvent += cwm.OnChatWindowDeleted;
            cw.ShowAll();
        }
Esempio n. 4
0
        /// <summary>
        /// AcceptNotificationHandler
        /// Handles notifications
        /// </summary>
        private void AcceptNotificationHandler(object o, ActionArgs args)
        {
            lock (notifyLock) {
                Logger.Debug("The notification was accepted");
                Notification notification = (Notification)o;

                if (currentNotification != null)
                {
                    NotificationData data = pendingData[currentPeerID];
                    if (data.Conversation != null)
                    {
                        CleanUpConversation(data.Conversation, false);
                    }

                    currentNotification = null;
                    currentPeerID       = 0;
                    ChatWindowManager.HandleAcceptedConversation(data.Conversation, data.ChatType);
                }
            }
        }
Esempio n. 5
0
        private void OnQuitAction(object sender, EventArgs args)
        {
            Logger.Info("OnQuitAction called - terminating application");

            trayIcon.Hide();

            // Save off the GroupWindow states
            if (groupWindows.Count > 0)
            {
                Logger.Info("Saving the state of all group windows...");
                foreach (GroupWindow gw in groupWindows.Values)
                {
                    gw.SaveState();
                    gw.Hide();
                }
            }

            // close all chat windows
            ChatWindowManager.CloseAllChatWindows();

            // Give the appearance of quitting quickly even though we don't
            GLib.Idle.Add(ShutdownIdle);
        }
Esempio n. 6
0
 private void OnVideoChatClicked(object o, EventArgs args)
 {
     ChatWindowManager.InitiateChat(person, ChatType.Video);
 }