public ChatView(ChatModel chat) { Trace.Call(chat); _ChatModel = chat; _Name = _ChatModel.Name; ID = _ChatModel.ID; Name = _Name; MessageTextView tv = new MessageTextView(); _EndMark = tv.Buffer.CreateMark("end", tv.Buffer.EndIter, false); tv.ShowTimestamps = true; tv.ShowMarkerline = true; tv.Editable = false; tv.CursorVisible = true; tv.WrapMode = Gtk.WrapMode.Char; tv.MessageAdded += OnMessageTextViewMessageAdded; tv.MessageHighlighted += OnMessageTextViewMessageHighlighted; tv.PopulatePopup += OnMessageTextViewPopulatePopup; _OutputMessageTextView = tv; Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow(); //sw.HscrollbarPolicy = Gtk.PolicyType.Never; sw.HscrollbarPolicy = Gtk.PolicyType.Automatic; sw.VscrollbarPolicy = Gtk.PolicyType.Always; sw.ShadowType = Gtk.ShadowType.In; sw.Add(_OutputMessageTextView); _OutputScrolledWindow = sw; // popup menu _TabMenu = new Gtk.Menu(); Gtk.ImageMenuItem close_item = new Gtk.ImageMenuItem(Gtk.Stock.Close, null); close_item.Activated += new EventHandler(OnTabMenuCloseActivated); _TabMenu.Append(close_item); //FocusChild = _OutputTextView; //CanFocus = false; _TabLabel = new Gtk.Label(); _TabLabel.Text = _Name; _TabHBox = new Gtk.HBox(); _TabHBox.PackEnd(new Gtk.Fixed(), true, true, 0); _TabHBox.PackEnd(_TabLabel, false, false, 0); _TabHBox.ShowAll(); _TabEventBox = new Gtk.EventBox(); _TabEventBox.VisibleWindow = false; _TabEventBox.ButtonPressEvent += new Gtk.ButtonPressEventHandler(OnTabButtonPress); _TabEventBox.Add(_TabHBox); _TabEventBox.ShowAll(); _ThemeSettings = new ThemeSettings(); // OPT-TODO: this should use a TaskStack instead of TaskQueue _LastSeenHighlightQueue = new TaskQueue("LastSeenHighlightQueue("+_Name+")"); _LastSeenHighlightQueue.AbortedEvent += OnLastSeenHighlightQueueAbortedEvent; _LastSeenHighlightQueue.ExceptionEvent += OnLastSeenHighlightQueueExceptionEvent; }
public void AddChat(ChatModel page) { Trace.Call(page); Console.WriteLine("New page: "+page.Name+ " type: "+page.ChatType); Frontend.ChangeActiveChat(page); }
public override void AddChat(ChatModel chat) { ChatView chatView = (ChatView) CreateChatView(chat); chatView.MainWindow = _MainWindow; _ChatViews.Add(chat, chatView); _ActiveChat = chatView; }
public ProtocolChatView(ChatModel chat) : base(chat) { Trace.Call(chat); Add(OutputScrolledWindow); ShowAll(); }
public ChatView(ChatModel chat, MainWindow window) { Trace.Call(chat, window); if (chat == null) { throw new ArgumentNullException("chat"); } if (window == null) { throw new ArgumentNullException("window"); } ChatModel = chat; f_MainWindow = window; f_WidgetID = f_NextID++; f_WidgetName = "output_textview_" + f_WidgetID; f_MainWindow.Modify("output_vbox", "append", "{" + "textview[" + f_WidgetName + "] " + ".expand:vh " + ".display[" + f_WidgetID + "d]:0 " + "offset[" + f_WidgetID + "os]:0 " + "richtext:1 " + "style_color0_normal:fg=black " + "style_color1_normal:fg=red " + "style_color2_normal:fg=green " + "style_color3_normal:fg=yellow " + "style_color4_normal:fg=blue " + "style_color5_normal:fg=magenta " + "style_color6_normal:fg=cyan " + "style_color7_normal:fg=white " + "style_color8_normal:fg=black,attr=bold " + "style_color9_normal:fg=red,attr=bold " + "style_color10_normal:fg=green,attr=bold " + "style_color11_normal:fg=yellow,attr=bold " + "style_color12_normal:fg=blue,attr=bold " + "style_color13_normal:fg=magenta,attr=bold " + "style_color14_normal:fg=cyan,attr=bold " + "style_color15_normal:fg=white,attr=bold " + "style_url_normal:attr=underline " + "style_u_normal:attr=underline " + "style_b_normal:attr=bold " + "style_i_normal:attr=standout " + "}" ); MessageTextView = new TextView(f_MainWindow, f_WidgetName); MessageTextView.OffsetVariableName = f_WidgetID + "os"; // HACK: as the chat is not always visible we can't extract the // heigth and width information from the textview because it simply // returns 0 when invisible, thus we need to abuse output_vbox MessageTextView.HeigthVariableName = "output_vbox:h"; MessageTextView.WidthVariableName = "output_vbox:w"; MessageTextView.AutoLineWrap = true; Participants = new List<PersonModel>(); }
public SessionChatView(ChatModel chat) : base(chat) { Trace.Call(chat); OutputMessageTextView.ShowMarkerline = false; OutputMessageTextView.ShowTimestamps = false; Add(OutputScrolledWindow); }
public ChatViewAddedEventArgs(ChatModel chatModel, string chatId, ChatType chatType, int chatPosition, Type protocolManagerType) { ChatModel = chatModel; ChatID = chatId; ChatType = chatType; ChatPosition = chatPosition; ProtocolManagerType = protocolManagerType; }
public void AddChat(ChatModel chat) { TraceRemotingCall(chat); try { _ChatViewManager.AddChat(chat); } catch (Exception ex) { Frontend.ShowException(ex); } }
protected ChatView(ChatModel chat) { _ChatModel = chat; InitializeComponent(); Name = chat.Name; Text = chat.Name; _OutputTextView.SelectionChanged += new EventHandler(OutputSelectionChanged); }
public override void AddChat(ChatModel chat) { ChatView chatView = (ChatView) CreateChatView(chat); f_Chats.Add(chatView); if (f_Config != null) { chatView.ApplyConfig(f_Config); } f_Notebook.TabPages.Add(chatView); }
public void AddChat(ChatModel chat) { Trace.Call(chat); try { _ChatViewManager.AddChat(chat); } catch (Exception ex) { #if LOG4NET _Logger.Fatal(ex); #endif } }
public ProtocolManagerHookCommand(ProtocolManagerBase protocolManager, ChatModel chat, string commandCharacter) { if (protocolManager == null) { throw new ArgumentNullException("protocolManager"); } ProtocolManager = protocolManager; Chat = chat; CommandCharacter = commandCharacter; CommandName = "ProtocolManager.Command"; }
public SessionHookCommand(Session session, ChatModel chat, string commandCharacter) { if (session == null) { throw new ArgumentNullException("session"); } Session = session; Chat = chat; CommandCharacter = commandCharacter; CommandName = "Session.Command"; }
public SessionChatView(ChatModel chat) : base(chat) { Trace.Call(chat); OutputMessageTextView.ShowMarkerline = false; var tabImage = new Gtk.Image(IconPixbuf); TabHBox.PackStart(tabImage, false, false, 2); TabHBox.ShowAll(); Add(OutputScrolledWindow); }
public ProtocolChatView(ChatModel chat) : base(chat) { Trace.Call(chat); var tabImage = new Gtk.Image(IconPixbuf); TabHBox.PackStart(tabImage, false, false, 2); TabHBox.ShowAll(); Add(OutputScrolledWindow); ShowAll(); }
public void AddMessageToChat(ChatModel chat, MessageModel msg) { Trace.Call(chat, msg); ChatView chatView = _ChatViewManager.GetChat(chat); #if LOG4NET if (chatView == null) { _Logger.Fatal(String.Format("AddMessageToChat(): _ChatViewManager.GetChat(chat) chat.Name: {0} returned null!", chat.Name)); return; } #endif chatView.AddMessage(msg); }
public void AddChat(ChatModel chat) { TraceRemotingCall(chat); MethodBase mb = Trace.GetMethodBase(); Gtk.Application.Invoke(delegate { TraceRemotingCall(mb, chat); try { _ChatViewManager.AddChat(chat); } catch (Exception ex) { Frontend.ShowException(ex); } }); }
public PersonChatView(ChatModel chat) : base(chat) { Trace.Call(chat); _TabImage = new Gtk.Image( new Gdk.Pixbuf( null, "person-chat.svg", 16, 16 ) ); TabHBox.PackStart(_TabImage, false, false, 2); TabHBox.ShowAll(); Add(OutputScrolledWindow); }
public CommandModel(FrontendManager fm, ChatModel chat, string cmdChar, string data) { Trace.Call(fm, chat == null ? "(null)" : chat.GetType().ToString(), cmdChar, data); _Data = data; _DataArray = data.Split(new char[] {' '}); _Parameter = String.Join(" ", _DataArray, 1, _DataArray.Length - 1); _CommandCharacter = cmdChar; if (data.StartsWith(cmdChar) && !data.StartsWith(cmdChar + cmdChar)) { _IsCommand = true; _Command = (_DataArray[0].Length > cmdChar.Length) ? _DataArray[0].Substring(cmdChar.Length).ToLower() : String.Empty; } else if (data.StartsWith(cmdChar + cmdChar)) { _Data = data.Substring(cmdChar.Length); _DataArray[0] = _DataArray[0].Substring(cmdChar.Length); } _FrontendManager = fm; _Chat = chat; }
public void AddMessageToChat(ChatModel chat, MessageModel msg) { Trace.Call(chat, msg); try { ChatView chatView = _ChatViewManager.GetChat(chat); if (chatView == null) { #if LOG4NET _Logger.Fatal(String.Format("AddMessageToChat(): _ChatViewManager.GetChat(chat) chat.Name: {0} returned null!", chat.Name)); #endif return; } // FIXME: this must be marshalled into the UI thread! chatView.AddMessage(msg); _ChatViewManager.UpdateNavigation(); } catch (Exception ex) { #if LOG4NET _Logger.Fatal(ex); #endif } }
public ChatView(ChatModel chat, MainWindow window) { Trace.Call(chat, window); if (chat == null) { throw new ArgumentNullException("chat"); } if (window == null) { throw new ArgumentNullException("window"); } f_ChatModel = chat; f_MainWindow = window; f_WidgetID = f_NextID++; f_WidgetName = "output_textview_" + f_WidgetID; f_MainWindow.Modify("output_vbox", "append", "{" + "textview[" + f_WidgetName + "] " + ".expand:vh " + ".display[" + f_WidgetID + "d]:0 " + "offset[" + f_WidgetID + "os]:0 " + "richtext:1 " + "style_red_normal:fg=red " + "style_url_normal:attr=underline " + "style_u_normal:attr=underline " + "style_b_normal:attr=bold " + "style_i_normal:attr=standout " + "}" ); MessageTextView = new TextView(f_MainWindow, f_WidgetName); MessageTextView.OffsetVariableName = f_WidgetID + "os"; // HACK: as the chat is not always visible we can't extract the // heigth and width information from the textview because it simply // returns 0 when invisible, thus we need to abuse output_vbox MessageTextView.HeigthVariableName = "output_vbox:h"; MessageTextView.WidthVariableName = "output_vbox:w"; MessageTextView.AutoLineWrap = true; }
public void AddMessageToChat(ChatModel page, MessageModel msg) { Trace.Call(page, msg); string finalMsg = String.Empty; foreach (MessagePartModel msgPart in msg.MessageParts) { // TODO: implement other types if (msgPart is TextMessagePartModel) { TextMessagePartModel fmsgti = (TextMessagePartModel) msgPart; finalMsg += fmsgti.Text; } } string timestamp; try { timestamp = msg.TimeStamp.ToLocalTime().ToString((string)Frontend.UserConfig["Interface/Notebook/TimestampFormat"]); } catch (FormatException e) { timestamp = "Timestamp Format ERROR: " + e.Message; } finalMsg = timestamp + " " + page.Name + " " + finalMsg; Console.WriteLine(finalMsg); }
public override void CloseChat(FrontendManager fm, ChatModel chat) { Trace.Call(fm, chat); throw new NotImplementedException(); }
public override void DisableChat(Smuxi.Engine.ChatModel chat) { throw new NotImplementedException(); }
public CommandModel(FrontendManager fm, ChatModel chat, string parameter) : this(fm, chat, "/", "/cmd " + parameter) { }
public override void OpenChat(FrontendManager fm, ChatModel chat) { Trace.Call(fm, chat); throw new NotImplementedException(); }
public override void CloseChat(FrontendManager fm, ChatModel chat) { throw new System.NotImplementedException(); }
public override void OpenChat(FrontendManager fm, ChatModel chat_) { Trace.Call(fm, chat_); var room = Rooms.Single(r => r.Name.Equals(chat_.Name)); Client.Post<object>(String.Format("/room/{0}/join.json", room.Id), null); room = Client.Get<RoomResponse>(String.Format("/room/{0}.json", room.Id)).Room; var chat = Session.GetChat(room.Name, ChatType.Group, this) as GroupChatModel; if (chat == null) chat = Session.CreateChat<GroupChatModel>(room.Id.ToString(), room.Name, this); var bld = CreateMessageBuilder(); bld.AppendMessage(room.Topic); chat.Topic = bld.ToMessage(); Session.AddChat(chat); /* Fill what we know about the users, this is only the currently-connected ones */ lock (Users) { foreach (User user in room.Users) { if (!Users.ContainsKey(user.Id)) Users[user.Id] = CreatePerson(user); Session.AddPersonToGroupChat(chat, Users[user.Id]); } } /* Show the recent messages, then go live. FIXME: race condition */ var recent = Client.Get<MessagesResponse>(String.Format("/room/{0}/recent.json", chat.ID)).Messages; foreach (Message message in recent) ShowMessage(this, new MessageReceivedEventArgs(chat, message)); Session.SyncChat(chat); chat.IsSynced = true; // Let the part and join messages take affect var stream = new CampfireEventStream(chat, BaseUri, new NetworkCredential(Key, "X")); lock (EventStreams) EventStreams.Add(chat, stream); stream.MessageReceived += ShowMessage; stream.ErrorReceived += ShowError; stream.Start(); }
private void _SyncChat(ChatModel chat) { f_TaskQueue.Queue(delegate { _UI.SyncChat(chat); }); }
private void _AddMessageToChat(ChatModel chat, MessageModel msg) { f_TaskQueue.Queue(delegate { _UI.AddMessageToChat(chat, msg); }); }
private void _Say(ChatModel chat, string text) { _Say(chat, text, true); }
public ChatView(ChatModel chat) { Trace.Call(chat); _ChatModel = chat; IsAutoScrolling = true; MessageTextView tv = new MessageTextView(); _EndMark = tv.Buffer.CreateMark("end", tv.Buffer.EndIter, false); tv.ShowTimestamps = true; tv.ShowMarkerline = true; tv.Editable = false; tv.CursorVisible = true; tv.WrapMode = Gtk.WrapMode.Char; tv.MessageAdded += OnMessageTextViewMessageAdded; tv.MessageHighlighted += OnMessageTextViewMessageHighlighted; tv.PopulatePopup += OnMessageTextViewPopulatePopup; tv.SizeRequested += delegate { AutoScroll(); }; tv.PersonClicked += OnMessageTextViewPersonClicked; _OutputMessageTextView = tv; Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow(); _OutputScrolledWindow = sw; //sw.HscrollbarPolicy = Gtk.PolicyType.Never; sw.HscrollbarPolicy = Gtk.PolicyType.Automatic; sw.VscrollbarPolicy = Gtk.PolicyType.Always; sw.ShadowType = Gtk.ShadowType.In; sw.Vadjustment.ValueChanged += OnVadjustmentValueChanged; sw.Add(_OutputMessageTextView); // popup menu _TabMenu = new Gtk.Menu(); _TabMenu.Shown += OnTabMenuShown; //FocusChild = _OutputTextView; //CanFocus = false; _TabLabel = new Gtk.Label(); TabImage = DefaultTabImage; _TabHBox = new Gtk.HBox(); _TabHBox.PackEnd(new Gtk.Fixed(), true, true, 0); _TabHBox.PackEnd(_TabLabel, false, false, 0); _TabHBox.PackStart(TabImage, false, false, 2); _TabHBox.ShowAll(); _TabEventBox = new Gtk.EventBox(); _TabEventBox.VisibleWindow = false; _TabEventBox.ButtonPressEvent += new Gtk.ButtonPressEventHandler(OnTabButtonPress); _TabEventBox.Add(_TabHBox); _TabEventBox.ShowAll(); _ThemeSettings = new ThemeSettings(); // OPT-TODO: this should use a TaskStack instead of TaskQueue _LastSeenHighlightQueue = new TaskQueue("LastSeenHighlightQueue("+ID+")"); _LastSeenHighlightQueue.AbortedEvent += OnLastSeenHighlightQueueAbortedEvent; _LastSeenHighlightQueue.ExceptionEvent += OnLastSeenHighlightQueueExceptionEvent; }
private void OnMessage(object sender, Message msg) { if (msg.Body == null) { return; } var delay = msg["delay"]; string stamp = null; if (delay != null) { stamp = delay.Attributes["stamp"].Value; } bool display = true; ChatModel chat = null; PersonModel person = null; if (msg.Type != XmppMessageType.groupchat) { string jid = msg.From.Bare; var contact = _RosterManager[jid]; string nickname = null; if (contact == null || String.IsNullOrEmpty(contact.Nickname)) { nickname = jid; } else { nickname = contact.Nickname; } PersonChatModel personChat = (PersonChatModel)Session.GetChat(jid, ChatType.Person, this); if (personChat == null) { person = new PersonModel(jid, nickname, NetworkID, Protocol, this); personChat = Session.CreatePersonChat( person, jid, nickname, this ); Session.AddChat(personChat); Session.SyncChat(personChat); } else { person = personChat.Person; } chat = personChat; } else { string group_jid = msg.From.Bare; string group_name = group_jid; string sender_jid = msg.From.ToString(); XmppGroupChatModel groupChat = (XmppGroupChatModel)Session.GetChat(group_jid, ChatType.Group, this); if (groupChat == null) { // FIXME shouldn't happen? groupChat = Session.CreateChat <XmppGroupChatModel>( group_jid, group_name, this ); Session.AddChat(groupChat); Session.SyncChat(groupChat); } person = groupChat.GetPerson(msg.From.Resource); if (person == null) { // happens in case of a delayed message if the participant has left meanwhile person = new PersonModel(msg.From.Resource, msg.From.Resource, NetworkID, Protocol, this); } // XXX maybe only a Google Talk bug requires this: if (stamp != null) { // XXX can't use > because of seconds precision :-( if (stamp.CompareTo(groupChat.LatestSeenStamp) >= 0) { groupChat.LatestSeenStamp = stamp; } else { display = false; // already seen newer delayed message } if (groupChat.SeenNewMessages) { display = false; // already seen newer messages } } else { groupChat.SeenNewMessages = true; } chat = groupChat; } if (display) { var builder = CreateMessageBuilder(); if (msg.Type != XmppMessageType.error) { builder.AppendMessage(person, msg.Body); } else { // TODO: nicer formatting builder.AppendMessage(msg.Error.ToString()); } if (stamp != null) { string format = DateTimeFormatInfo.InvariantInfo.UniversalSortableDateTimePattern.Replace(" ", "T"); builder.TimeStamp = DateTime.ParseExact(stamp, format, null); } Session.AddMessageToChat(chat, builder.ToMessage()); } }
public abstract void OpenChat(FrontendManager fm, ChatModel chat);
public ChatView GetChat(ChatModel chat) { for (int i=0; i < NPages; i++) { ChatView chatView = (ChatView) GetNthPage(i); if (chatView.ChatModel == chat) { return chatView; } } return null; }
void FormatUpload(MessageBuilder bld, PersonModel person, ChatModel chat, Message message) { // Figure out what the user uploaded, we need to issue another call for this var upload = Client.Get<UploadWrapper>(String.Format("/room/{0}/messages/{1}/upload.json", chat.ID, message.Id)).Upload; bld.AppendEventPrefix(); bld.AppendIdendityName(person).AppendSpace(); bld.AppendText(_("has uploaded '{0}' ({1} B) {2}"), upload.Name, upload.Byte_Size, upload.Full_Url); }
public abstract void CloseChat(FrontendManager fm, ChatModel chat);
public override void Connect(FrontendManager fm, string host, int port, string username, string password) { Trace.Call(fm, host, port, username, password); _FrontendManager = fm; Host = "login.oscar.aol.com"; Port = 5190; // TODO: use config for single network chat or once per network manager _NetworkChat = new ProtocolChatModel(NetworkID, NetworkID + " Messenger", this); Session.AddChat(_NetworkChat); Session.SyncChat(_NetworkChat); _OscarSession = new OscarSession(username, password); _OscarSession.ClientCapabilities = Capabilities.Chat | Capabilities.OscarLib; _OscarSession.LoginCompleted += new LoginCompletedHandler(_OnLoginCompleted); _OscarSession.LoginFailed += new LoginFailedHandler(_OnLoginFailed); _OscarSession.LoginStatusUpdate += new LoginStatusUpdateHandler(_OnLoginStatusUpdate); _OscarSession.ErrorMessage += new ErrorMessageHandler(_OnErrorMessage); _OscarSession.WarningMessage += new WarningMessageHandler(_OnWarningMessage); _OscarSession.StatusUpdate += new InformationMessageHandler(_OnStatusUpdate); _OscarSession.ContactListFinished += new ContactListFinishedHandler(_OnContactListFinished); _OscarSession.Messages.MessageReceived += new MessageReceivedHandler(_OnMessageReceived); _OscarSession.Logon(Host, Port); }
private void _AddChat(ChatModel chat) { f_TaskQueue.Queue(delegate { _UI.AddChat(chat); }); }
private void _Say(ChatModel chat, string message) { if (!chat.IsEnabled) { return; } MessageModel msg = new MessageModel(); TextMessagePartModel msgPart; _OscarSession.Messages.SendMessage(chat.ID, message); msgPart = new TextMessagePartModel(); msgPart.Text = "<"; msg.MessageParts.Add(msgPart); msgPart = new TextMessagePartModel(); msgPart.Text = _OscarSession.ScreenName; msgPart.ForegroundColor = new TextColor(0x0000FF); msg.MessageParts.Add(msgPart); msgPart = new TextMessagePartModel(); msgPart.Text = "> "; msg.MessageParts.Add(msgPart); msgPart = new TextMessagePartModel(); msgPart.Text = message; msg.MessageParts.Add(msgPart); Session.AddMessageToChat(chat, msg); }
public void AddTextToChat(ChatModel chat, string text) { AddMessageToChat(chat, new MessageModel(text)); }
public ProtocolChatView(ChatModel chat) : base(chat) { Trace.Call(chat); ProxySettings = new ProxySettings(); Add(OutputScrolledWindow); ReconnectItem = new Gtk.ImageMenuItem(_("Reconnect")); ReconnectItem.Image = new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Menu); ReconnectItem.Activated += new EventHandler(OnTabMenuReconnectActivated); ShowAll(); }
public void EnableChat(ChatModel chat) { f_TaskQueue.Queue(delegate { _UI.EnableChat(chat); }); }