Esempio 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"));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// DeclineNotificationHandler
        /// Handles notifications
        /// </summary>
        private void DeclineNotificationHandler(object o, ActionArgs args)
        {
            lock (notifyLock) {
                Logger.Debug("The notification declined");
                Notification notification = (Notification)o;

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

                    currentNotification = null;
                    currentPeerID       = 0;
                }
            }
        }
Esempio n. 3
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. 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"));
            }
        }