///<summary> /// OnTextMessageReceived /// Handles all incoming TextMessages and places them into the text chat area ///</summary> private void OnTextMessageReceived(Conversation conversation, Message message) { string avatarPath = null; Logger.Debug("OnMessageReceived called: {0}", message.Text); Logger.Debug("Peer Handle: {0}", conversation.PeerUser.ID); Logger.Debug("Peer Screenname: {0}", conversation.PeerUser.Uri); Logger.Debug("Sender: {0}", conversation.PeerUser.Alias); Person person = null; try { person = PersonManager.GetPerson(conversation.PeerUser); } catch {} AddMessage(message, true, conversation.CurrentMessageSameAsLast, null); // if the window doesn't have focus, notify the user if ((notifyUser) && (message is TextMessage)) { if (hasBeenShown && (!HasToplevelFocus)) { this.UrgencyHint = true; NotificationManager.NotifyMessage(person, message); } else { Gnome.Sound.Play(System.IO.Path.Combine(Banter.Defines.SoundDir, "receive.wav")); } } }
public void ProviderUserAdded(ProviderUser user) { Person person = PersonManager.GetPerson(user); if (person == null) { person = new Person(user); //person.JabberId = user.Uri; PersonManager.AddPerson(person); } }
/// <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")); } }
///<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(); }
/// <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")); } }