Exemplo n.º 1
0
        /// <summary>
        /// NotifyOfVideoRequest
        /// Notifies user of an incoming video request
        /// </summary>
        private void NotifyOfVideoRequest(Conversation conversation)
        {
            // close the current notification before adding another
            if (currentNotification != null)
            {
                Logger.Debug("Current notification != null");
                currentNotification.Close();
                currentNotification = null;
                currentPeerID       = 0;
            }

            lock (notifyLock) {
                Person peer = PersonManager.GetPerson(conversation.PeerUser);
                if (peer == null)
                {
                    return;
                }

                peer.VideoNotifyCount++;

                String    messageTitle = Catalog.GetString("Incoming Video Chat");
                String    messageBody  = String.Format(Catalog.GetString("{0} is requesting a video chat"), peer.DisplayName);
                Message[] messages     = conversation.GetReceivedMessages();


                Notification notification;
                if (peer.Photo != null)
                {
                    Gdk.Pixbuf sizedPhoto = peer.Photo.ScaleSimple(48, 48, Gdk.InterpType.Bilinear);
                    notification = new Notification(messageTitle,
                                                    messageBody,
                                                    sizedPhoto);
                }
                else
                {
                    Gdk.Pixbuf banterIcon = Application.GetIcon("banter-44", 44);
                    notification = new Notification(messageTitle,
                                                    messageBody,
                                                    banterIcon);
                }

                NotificationData data = new NotificationData(conversation, ChatType.Video, peer);
                pendingData[conversation.PeerUser.ID] = data;

                notification.AddAction("Accept", Catalog.GetString("Accept"), AcceptNotificationHandler);
                notification.AddAction("Decline", Catalog.GetString("Decline"), DeclineNotificationHandler);
                notification.Closed += ClosedNotificationHandler;
                notification.Timeout = 120000;
                currentNotification  = notification;
                currentPeerID        = conversation.PeerUser.ID;
                Banter.Application.ShowAppNotification(notification);
                Gnome.Sound.Play(Path.Combine(Banter.Defines.SoundDir, "notify.wav"));
            }
        }
Exemplo n.º 2
0
        ///<summary>
        ///	OnVideoViewRealized
        /// Handles all setup of the window after it's been realized on the screen
        ///</summary>
        private void OnWindowShown(object sender, EventArgs args)
        {
            if (hasBeenShown)
            {
                return;
            }

            SetupConversationEvents();

            try {
                switch (chatType)
                {
                default:
                case ChatType.Text:
                    // do nothing, text doesn't need to setup streams
                    break;

                case ChatType.Audio:
                    Logger.Debug("ChatWindow setting up video windows and calling StartAudioStream");
                    conv.StartAudioStream();
                    break;

                case ChatType.Video:
                    if (this.videoView != null)
                    {
                        Logger.Debug("ChatWindow setting up video windows and calling StartAudioVideoStreams");
                        conv.StartAudioVideoStreams(videoView.PreviewWindowId, videoView.WindowId);
                    }
                    else
                    {
                        Logger.Debug("ChatWindow didn't have a videoWindow created");
                    }
                    break;
                }
            } catch (Exception ows) {
                Logger.Debug("Exception thrown setting up media channels");
                Logger.Debug(ows.Message);
            }

            notifyUser = false;
            // Check for any existing messages including previous chat log
            Message[] messages = conv.GetReceivedMessages();
            foreach (Message msg in messages)
            {
                OnTextMessageReceived(conv, msg);
            }

            notifyUser   = true;
            hasBeenShown = true;

            // Set the default focus to the TextView where users should type
            typingTextView.GrabFocus();
        }
Exemplo n.º 3
0
        /// <summary>
        /// NotifyOfVideoRequest
        /// Notifies user of an incoming video request
        /// </summary>	
        private void NotifyOfVideoRequest(Conversation conversation)
        {
            // close the current notification before adding another
            if(currentNotification != null) {
                Logger.Debug("Current notification != null");
                currentNotification.Close();
                currentNotification = null;
                currentPeerID = 0;
            }

            lock(notifyLock) {
                Person peer = PersonManager.GetPerson(conversation.PeerUser);
                if(peer == null)
                    return;

                peer.VideoNotifyCount++;

                String messageTitle = Catalog.GetString("Incoming Video Chat");
                String messageBody = String.Format(Catalog.GetString("{0} is requesting a video chat"), peer.DisplayName);
                Message[] messages = conversation.GetReceivedMessages();

                Notification notification;
                if(peer.Photo != null) {
                    Gdk.Pixbuf sizedPhoto = peer.Photo.ScaleSimple(48, 48, Gdk.InterpType.Bilinear);
                    notification = new Notification(messageTitle,
                                                    messageBody,
                                                    sizedPhoto);
                } else {
                    Gdk.Pixbuf banterIcon = Application.GetIcon ("banter-44", 44);
                    notification = new Notification(messageTitle,
                                                    messageBody,
                                                    banterIcon);
                }

                NotificationData data = new NotificationData(conversation, ChatType.Video, peer);
                pendingData[conversation.PeerUser.ID] = data;

                notification.AddAction("Accept", Catalog.GetString("Accept"), AcceptNotificationHandler);
                notification.AddAction("Decline", Catalog.GetString("Decline"), DeclineNotificationHandler);
                notification.Closed += ClosedNotificationHandler;
                notification.Timeout = 120000;
                currentNotification = notification;
                currentPeerID = conversation.PeerUser.ID;
                Banter.Application.ShowAppNotification(notification);
                Gnome.Sound.Play(Path.Combine(Banter.Defines.SoundDir, "notify.wav"));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// NotifyOfTextMessage
        /// Notifies user of an incoming text message
        /// </summary>	
        private void NotifyOfTextMessage(Conversation conversation)
        {
            // close the current notification before adding another
            if(currentNotification != null) {
                Logger.Debug("Current notification != null");
                currentNotification.Close();
                currentNotification = null;
                currentPeerID = 0;
            }

            lock(notifyLock) {
                Person peer = PersonManager.GetPerson(conversation.PeerUser);
                if(peer == null)
                    return;

                peer.TextNotifyCount++;

                String messageTitle = String.Format(Catalog.GetString("Message from {0}"), peer.DisplayName);
                Message[] messages = conversation.GetReceivedMessages();
                String messageBody;

                if(messages.Length > 0) {
                    messageBody = messages[messages.Length - 1].Text;
                }
                else
                    messageBody = "";

                // Limit the size of the message that is sent
                if(messageBody.Length > 200) {
                    messageBody = messageBody.Substring(0, 200);
                    messageBody = messageBody + " ...";
                }

                Notification notification;
                if(peer.Photo != null) {
                    Gdk.Pixbuf sizedPhoto = peer.Photo.ScaleSimple(48, 48, Gdk.InterpType.Bilinear);
                    notification = new Notification(messageTitle,
                                                    messageBody,
                                                    sizedPhoto);
                } else {
                    Gdk.Pixbuf banterIcon = Application.GetIcon ("banter-44", 44);
                    notification = new Notification(messageTitle,
                                                    messageBody,
                                                    banterIcon);
                }

                NotificationData data = new NotificationData(conversation, ChatType.Text, peer);
                pendingData[conversation.PeerUser.ID] = data;

                notification.AddAction("Accept", Catalog.GetString("Accept"), AcceptNotificationHandler);
                notification.AddAction("Decline", Catalog.GetString("Decline"), DeclineNotificationHandler);
                notification.Closed += ClosedNotificationHandler;
                currentNotification = notification;
                currentPeerID = conversation.PeerUser.ID;
                Banter.Application.ShowAppNotification(notification);
                Gnome.Sound.Play(Path.Combine(Banter.Defines.SoundDir, "notify.wav"));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// NotifyOfTextMessage
        /// Notifies user of an incoming text message
        /// </summary>
        private void NotifyOfTextMessage(Conversation conversation)
        {
            // close the current notification before adding another
            if (currentNotification != null)
            {
                Logger.Debug("Current notification != null");
                currentNotification.Close();
                currentNotification = null;
                currentPeerID       = 0;
            }

            lock (notifyLock) {
                Person peer = PersonManager.GetPerson(conversation.PeerUser);
                if (peer == null)
                {
                    return;
                }

                peer.TextNotifyCount++;

                String    messageTitle = String.Format(Catalog.GetString("Message from {0}"), peer.DisplayName);
                Message[] messages     = conversation.GetReceivedMessages();
                String    messageBody;

                if (messages.Length > 0)
                {
                    messageBody = messages[messages.Length - 1].Text;
                }
                else
                {
                    messageBody = "";
                }

                // Limit the size of the message that is sent
                if (messageBody.Length > 200)
                {
                    messageBody = messageBody.Substring(0, 200);
                    messageBody = messageBody + " ...";
                }

                Notification notification;
                if (peer.Photo != null)
                {
                    Gdk.Pixbuf sizedPhoto = peer.Photo.ScaleSimple(48, 48, Gdk.InterpType.Bilinear);
                    notification = new Notification(messageTitle,
                                                    messageBody,
                                                    sizedPhoto);
                }
                else
                {
                    Gdk.Pixbuf banterIcon = Application.GetIcon("banter-44", 44);
                    notification = new Notification(messageTitle,
                                                    messageBody,
                                                    banterIcon);
                }

                NotificationData data = new NotificationData(conversation, ChatType.Text, peer);
                pendingData[conversation.PeerUser.ID] = data;

                notification.AddAction("Accept", Catalog.GetString("Accept"), AcceptNotificationHandler);
                notification.AddAction("Decline", Catalog.GetString("Decline"), DeclineNotificationHandler);
                notification.Closed += ClosedNotificationHandler;
                currentNotification  = notification;
                currentPeerID        = conversation.PeerUser.ID;
                Banter.Application.ShowAppNotification(notification);
                Gnome.Sound.Play(Path.Combine(Banter.Defines.SoundDir, "notify.wav"));
            }
        }