Пример #1
0
        public void ProviderUserAdded(ProviderUser user)
        {
            Person person = PersonManager.GetPerson(user);

            if (person == null)
            {
                person = new Person(user);
                //person.JabberId = user.Uri;
                PersonManager.AddPerson(person);
            }
        }
Пример #2
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"));
            }
        }
Пример #3
0
        ///<summary>
        ///	Constructor
        /// Creates a ChatWindow based on an existing conversation.  This mainly used on
        /// incoming conversations.
        ///</summary>
        public ChatWindow(Conversation conversation, ChatType type) :
            base(WindowType.Toplevel)
        {
            Logger.Debug("ChatWindow is being created with the ChatType: {0}", type.ToString());

            this.chatType = type;
            conv          = conversation;

            // no need to Add any channels, they will be set up already

            peerProviderUser = conv.PeerUser;
            peerPerson       = PersonManager.GetPerson(peerProviderUser);

            InitWindow();
        }
Пример #4
0
        /// <summary>
        /// Gets the Person object for a given Id
        /// </summary>
        public static Person GetPerson(string id)
        {
            lock (modelLock) {
                PersonManager pm = PersonManager.Instance;

                if ((pm.me != null) && (pm.me.JabberId.CompareTo(id) == 0))
                {
                    return(pm.me);
                }

                if (pm.personIters.ContainsKey(id))
                {
                    Gtk.TreeIter iter = pm.personIters[id];
                    return((Person)pm.personTreeStore.GetValue(iter, 0));
                }
            }
            return(null);
        }
Пример #5
0
 public void ProviderUserRemoved(string uri)
 {
     PersonManager.RemovePerson(uri);
 }
Пример #6
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"));
            }
        }