public FindGroupChatDialog(Gtk.Window parent, IProtocolManager protocolManager) : base(null, parent, Gtk.DialogFlags.DestroyWithParent) { Build(); f_ProtocolManager = protocolManager; int columnID = 0; Gtk.TreeViewColumn column; columnID++; column = f_TreeView.AppendColumn("#", new Gtk.CellRendererText(), "text", columnID); column.SortColumnId = columnID; columnID++; column = f_TreeView.AppendColumn(_("Name"), new Gtk.CellRendererText(), "text", columnID); column.SortColumnId = columnID; column.Resizable = true; columnID++; column = f_TreeView.AppendColumn(_("Topic"), new Gtk.CellRendererText(), "markup", columnID); column.SortColumnId = columnID; column.Resizable = true; f_ListStore = new Gtk.ListStore( typeof(GroupChatModel), typeof(int), // person count typeof(string), // name typeof(string) // topic pango markup ); f_TreeView.RowActivated += OnTreeViewRowActivated; f_TreeView.Selection.Changed += OnTreeViewSelectionChanged; f_TreeView.Model = f_ListStore; f_TreeView.SearchColumn = 2; // name }
public void Add(ChatModel chatModel) { Trace.Call(chatModel); if (chatModel == null) { throw new ArgumentNullException("chatModel"); } #if LOG4NET DateTime start = DateTime.UtcNow; #endif // REMOTING CALL 1 var chatId = chatModel.ID; // REMOTING CALL 2 var chatType = chatModel.ChatType; // REMOTING CALL 3 var chatPosition = chatModel.Position; // REMOTING CALL 4 IProtocolManager protocolManager = chatModel.ProtocolManager; Type protocolManagerType = null; if (protocolManager != null) { protocolManagerType = chatModel.ProtocolManager.GetType(); } #if LOG4NET DateTime stop = DateTime.UtcNow; double duration = stop.Subtract(start).TotalMilliseconds; Logger.Debug("Add() done, syncing took: " + Math.Round(duration) + " ms"); #endif OnChatAdded(chatModel, chatId, chatType, chatPosition, protocolManagerType); }
internal IrcGroupPersonModel(string nickname, string realname, string ident, string host, string networkID, IProtocolManager networkManager) : base(nickname, realname, ident, host, networkID, networkManager) { }
protected ChatModel(string id, string name, ChatType chatType, IProtocolManager networkManager) { _ID = id; _Name = name; _ChatType = chatType; _ProtocolManager = networkManager; }
private void DoExecute(CommandModel cmd) { Trace.Call(cmd); DateTime start, stop; start = DateTime.UtcNow; bool handled; handled = f_Session.Command(cmd); if (!handled) { // we maybe have no network manager yet IProtocolManager pm = cmd.Chat.ProtocolManager; if (pm != null) { handled = pm.Command(cmd); } else { handled = false; } } if (!handled) { Unknown(cmd); } stop = DateTime.UtcNow; f_LastCommandTimeSpan = (stop - start); }
internal IrcPersonModel(string nickName, string realName, string ident, string host, string networkID, IProtocolManager protocolManager) : base(nickName, nickName, networkID, "IRC", protocolManager) { _RealName = realName; _Ident = ident; _Host = host; }
protected PersonModel(SerializationInfo info, StreamingContext ctx) : base(info, ctx) { if (info == null) { throw new ArgumentNullException("info"); } // TODO: we might optimize this away, causes 800 bytes per remoting call _ProtocolManager = (IProtocolManager) info.GetValue("_ProtocolManager", typeof(IProtocolManager)); }
internal protected CampfirePersonModel(User user, string network, IProtocolManager pm) : base(user.Id.ToString(), user.Name, network, "Campfire", pm) { Uid = user.Id; Name = user.Name; Email = user.Email_Address; Admin = user.Admin; AvatarUrl = user.Avatar_Url; Host = network; Ident = Name; }
public PersonModel(string id, string displayName, string networkID, string networkProtocol, IProtocolManager protocolManager) : base(id, displayName, networkID, networkProtocol) { if (protocolManager == null) { throw new ArgumentNullException("protocolManager"); } _ProtocolManager = protocolManager; }
protected ChatModel(string id, string name, ChatType chatType, IProtocolManager networkManager) { _ID = id; _Name = name; _ChatType = chatType; _ProtocolManager = networkManager; Position = -1; if (ProtocolManager == null) { InitMessageBuffer(MessageBufferPersistencyType.Volatile); } }
protected internal CampfirePersonModel(User user, string network, IProtocolManager pm) : base(user.Id.ToString(), user.Name, network, "Campfire", pm) { Uid = user.Id; Name = user.Name; Email = user.Email_Address; Admin = user.Admin; AvatarUrl = user.Avatar_Url; Host = network; Ident = Name; }
protected PersonModel(SerializationInfo info, StreamingContext ctx) : base(info, ctx) { if (info == null) { throw new ArgumentNullException("info"); } // TODO: we might optimize this away, causes 800 bytes per remoting call _ProtocolManager = (IProtocolManager)info.GetValue("_ProtocolManager", typeof(IProtocolManager)); }
public ChatViewAddedEventArgs(ChatModel chatModel, string chatId, ChatType chatType, int chatPosition, IProtocolManager protocolManager, Type protocolManagerType) { ChatModel = chatModel; ChatID = chatId; ChatType = chatType; ChatPosition = chatPosition; ProtocolManager = protocolManager; ProtocolManagerType = protocolManagerType; }
public ProtocolManagerHookCommand(IProtocolManager protocolManager, ChatModel chat, string commandCharacter) { if (protocolManager == null) { throw new ArgumentNullException("protocolManager"); } ProtocolManager = protocolManager; Chat = chat; CommandCharacter = commandCharacter; CommandName = "ProtocolManager.Command"; }
void OnChatAdded(ChatModel chatModel, string chatId, ChatType chatType, int chatPosition, IProtocolManager protocolManager, Type protocolManagerType) { if (ChatAdded != null) { ChatAdded(this, new ChatViewAddedEventArgs(chatModel, chatId, chatType, chatPosition, protocolManager, protocolManagerType)); } }
public ProtocolManagerHookEnvironment(IProtocolManager protocolManager) { if (protocolManager == null) { throw new ArgumentNullException("protocolManager"); } this["PROTOCOL_MANAGER_PROTOCOL"] = protocolManager.Protocol; this["PROTOCOL_MANAGER_NETWORK"] = protocolManager.NetworkID; this["PROTOCOL_MANAGER_HOST"] = protocolManager.Host; this["PROTOCOL_MANAGER_PORT"] = protocolManager.Port.ToString(); if (protocolManager.Me != null) { this["PROTOCOL_MANAGER_ME_ID"] = protocolManager.Me.ID; } this["PROTOCOL_PRESENCE_STATUS"] = protocolManager.PresenceStatus.ToString(); }
internal IrcPersonModel(string nickName, string realName, string ident, string host, string networkID, IProtocolManager protocolManager) : base(nickName, nickName, networkID, "IRC", protocolManager) { if (ident == null) { throw new ArgumentNullException("ident"); } if (host == null) { throw new ArgumentNullException("host"); } _RealName = realName; _Ident = ident; _Host = host; }
public void Sync() { Trace.Call(); // sync current page List <ChatModel> chats; lock (_Session.Chats) { _CurrentChat = _Session.Chats[0]; chats = new List <ChatModel>(_Session.Chats); } // restore page positions if (_CurrentChat.Position != -1) { // looks like the positions were synced, sort it good chats.Sort( (a, b) => (a.Position.CompareTo(b.Position)) ); } // sync pages foreach (ChatModel chat in chats) { _AddChat(chat); } // sync current network manager (if any exists) IProtocolManager nm = _Session.FirstProtocolManager; if (nm != null) { CurrentProtocolManager = nm; } // sync content of pages foreach (ChatModel chat in chats) { _SyncChat(chat); } _IsFrontendSynced = true; _Session.CheckPresenceStatus(); }
// events private void _OnSwitchPage(object sender, TabControlEventArgs e) { Trace.Call(sender, e); try { // synchronize FrontManager.CurrenPage ChatView chatView = e.TabPage as ChatView; if (chatView != null) { ChatModel chatModel = chatView.ChatModel; IProtocolManager nmanager = chatModel.ProtocolManager; Frontend.FrontendManager.CurrentChat = chatModel; if (nmanager != null) { Frontend.FrontendManager.CurrentProtocolManager = nmanager; } // even when we have no network manager, we still want to update the state Frontend.FrontendManager.UpdateNetworkStatus(); // lets remove any markup / highlight string color = (string)Frontend.UserConfig["Interface/Notebook/Tab/NoActivityColor"]; // TODO: apply color to tab chatView.HasHighlight = false; // sync title if (Frontend.MainWindow != null) { string network = nmanager != null?nmanager.ToString() + " / " : ""; Frontend.MainWindow.Text = network + chatView.Text + " - Smuxi"; } } } catch (Exception ex) { Frontend.ShowException(null, ex); } }
public XmppGroupChatModel(string id, string name, IProtocolManager networkManager) : base(id, name, networkManager) { }
public GroupChatModel(string id, string name, IProtocolManager networkManager) : base(id, name, ChatType.Group, networkManager) { }
public PersonChatModel(PersonModel person, string id, string name, IProtocolManager networkManager) : base(id, name, ChatType.Person, networkManager) { _Person = person; }
private void DoExecute(CommandModel cmd) { Trace.Call(cmd); var handled = false; if (cmd.IsCommand) { switch (cmd.Command) { case "exec": CommandExec(cmd); handled = true; break; case "echo": CommandEcho(cmd); handled = true; break; case "benchmark_message_builder": CommandBenchmarkMessageBuilder(cmd); handled = true; break; case "exception": throw new Exception("You asked for it."); } } if (handled) { // no need to send the command to the engine return; } DateTime start, stop; start = DateTime.UtcNow; handled = f_Session.Command(cmd); IProtocolManager pm = null; if (!handled) { if (cmd.Chat is SessionChatModel && cmd.FrontendManager != null) { pm = cmd.FrontendManager.CurrentProtocolManager; } else { pm = cmd.Chat.ProtocolManager; } // we maybe have no network manager yet if (pm != null) { handled = pm.Command(cmd); } else { handled = false; } } if (!handled) { var filteredCmd = IOSecurity.GetFilteredPath(cmd.Command); var hooks = new HookRunner("frontend", "command-manager", "command-" + filteredCmd); hooks.EnvironmentVariables.Add("FRONTEND_VERSION", FrontendVersion); hooks.Environments.Add(new CommandHookEnvironment(cmd)); hooks.Environments.Add(new ChatHookEnvironment(cmd.Chat)); if (pm != null) { hooks.Environments.Add(new ProtocolManagerHookEnvironment(pm)); } var cmdChar = (string)f_Session.UserConfig["Interface/Entry/CommandCharacter"]; hooks.Commands.Add(new SessionHookCommand(f_Session, cmd.Chat, cmdChar)); if (pm != null) { hooks.Commands.Add(new ProtocolManagerHookCommand(pm, cmd.Chat, cmdChar)); } // show time hooks.Init(); if (hooks.HasHooks) { hooks.Run(); handled = true; } } if (!handled) { Unknown(cmd); } stop = DateTime.UtcNow; f_LastCommandTimeSpan = (stop - start); }
public ChatModel GetChat(string id, ChatType chatType, IProtocolManager networkManager) { if (id == null) { throw new ArgumentNullException("id"); } foreach (ChatModel chat in _Chats) { if ((chat.ID.ToLower() == id.ToLower()) && (chat.ChatType == chatType) && (chat.ProtocolManager == networkManager)) { return chat; } } return null; }
protected internal IrcPersonModel(string nickName, string networkID, IProtocolManager protocolManager) : base(nickName, nickName, networkID, "IRC", protocolManager) { }
internal IrcGroupPersonModel(string nickname, string networkID, IProtocolManager networkManager) : base(nickname, networkID, networkManager) { }
public ProtocolChatModel(string id, string name, IProtocolManager networkManager) : base(id, name, ChatType.Protocol, networkManager) { }
internal protected IrcPersonModel(string nickName, string networkID, IProtocolManager protocolManager) : base(nickName, nickName, networkID, "IRC", protocolManager) { }
protected virtual void OnSwitchPage(object sender, Gtk.SwitchPageArgs e) { Trace.Call(sender, e); if (f_IsBrowseModeEnabled) { return; } // synchronize FrontManager.CurrenPage ChatView chatView = GetChat((int)e.PageNum); if (chatView == null) { return; } ChatModel chatModel = chatView.ChatModel; // clear activity and highlight chatView.HasHighlight = false; chatView.HasActivity = false; var lastMsg = chatView.OutputMessageTextView.LastMessage; var method = Trace.GetMethodBase(); f_SwitchPageQueue.Queue(delegate { // HACK: don't pass the real parameters are it's unsafe from // a non-main (GUI) thread! Trace.Call(method, null, null); try { DateTime start = DateTime.UtcNow, stop; // OPT-TODO: we could use here a TaskStack instead which // would make sure only the newest task gets executed // instead of every task in the FIFO sequence! // REMOTING CALL 1 IProtocolManager nmanager = chatModel.ProtocolManager; // TODO: only set the protocol manager and update network // status if the protocol manager differs from the old one // REMOTING CALL 2 Frontend.FrontendManager.CurrentChat = chatModel; if (nmanager != null) { // REMOTING CALL 3 Frontend.FrontendManager.CurrentProtocolManager = nmanager; } // even when we have no network manager, we still want to update // the network status and title // REMOTING CALL 4 Frontend.FrontendManager.UpdateNetworkStatus(); // update last seen highlight // REMOTING CALL 5 if (lastMsg != null && !Frontend.UseLowBandwidthMode) { chatModel.LastSeenHighlight = lastMsg.TimeStamp; } stop = DateTime.UtcNow; #if LOG4NET f_Logger.Debug("OnSwitchPage(): task took: " + (stop - start).Milliseconds + " ms"); #endif } catch (Exception ex) { #if LOG4NET f_Logger.Error("OnSwitchPage(): Exception", ex); #endif Frontend.ShowException(ex); } }); }
public static bool TryOpenChatLink(Uri link) { Trace.Call(link); if (Session == null) { return(false); } // supported: // smuxi://freenode/#smuxi // smuxi://freenode/#%23csharp (##csharp) // irc://#smuxi // irc://irc.oftc.net/ // irc://irc.oftc.net/#smuxi // irc://irc.oftc.net:6667/#smuxi // not supported (yet): // smuxi:///meebey IProtocolManager manager = null; var linkPort = link.Port; if (linkPort == -1) { switch (link.Scheme) { case "irc": linkPort = 6667; break; case "ircs": linkPort = 6697; break; } } // decode #%23csharp to ##csharp var linkChat = HttpUtility.UrlDecode(link.Fragment); if (String.IsNullOrEmpty(linkChat) && link.AbsolutePath.Length > 0) { linkChat = link.AbsolutePath.Substring(1); } var linkProtocol = link.Scheme; var linkHost = link.Host; string linkNetwork = null; if (!linkHost.Contains(".")) { // this seems to be a network name linkNetwork = linkHost; } // find existing protocol chat foreach (var chatView in MainWindow.ChatViewManager.Chats) { if (!(chatView is ProtocolChatView)) { continue; } var protocolChat = (ProtocolChatView)chatView; var host = protocolChat.Host; var port = protocolChat.Port; var network = protocolChat.NetworkID; // Check first by network name with fallback to host+port. // The network name has to be checked against the NetworkID and // also ChatModel.ID as the user might have entered a different // network name in settings than the server does if (!String.IsNullOrEmpty(network) && (String.Compare(network, linkNetwork, true) == 0 || String.Compare(chatView.ID, linkNetwork, true) == 0)) { manager = protocolChat.ProtocolManager; break; } if (String.Compare(host, linkHost, true) == 0 && port == linkPort) { manager = protocolChat.ProtocolManager; break; } } if (manager == null) { // only irc may autoconnect to a server switch (linkProtocol) { case "irc": case "ircs": case "smuxi": break; default: return(false); } ServerModel server = null; if (!String.IsNullOrEmpty(linkNetwork)) { // try to find a server with this network name and connect to it var serverSettings = new ServerListController(UserConfig); server = serverSettings.GetServerByNetwork(linkNetwork); if (server == null) { // in case someone tried an unknown network return(false); } // ignore OnConnectCommands server.OnConnectCommands = null; } else if (!String.IsNullOrEmpty(linkHost)) { server = new ServerModel() { Protocol = linkProtocol, Hostname = linkHost, Port = linkPort }; } if (server != null) { manager = Session.Connect(server, FrontendManager); } } if (String.IsNullOrEmpty(linkChat)) { return(true); } // switch to existing chat foreach (var chatView in MainWindow.ChatViewManager.Chats) { if (manager != null && chatView.ProtocolManager != manager) { continue; } if (String.Compare(chatView.ID, linkChat, true) == 0) { MainWindow.ChatViewManager.CurrentChatView = chatView; return(true); } } // join chat if (manager != null) { var chat = new GroupChatModel(linkChat, linkChat, null); ThreadPool.QueueUserWorkItem(delegate { try { manager.OpenChat(FrontendManager, chat); } catch (Exception ex) { Frontend.ShowException(ex); } }); } return(true); }
int GetSortedChatPosition(ChatView chatView) { // starting with > 0.8 the Engine supplies ChatModel.Position for us if (Frontend.EngineVersion > new Version("0.8")) { return(chatView.Position); } // COMPAT: Engine <= 0.8 doesn't populate ChatModel.Position thus // _we_ have to find a good position var chat = chatView.ChatModel; // REMOTING CALL 1 int idx = chat.Position; // REMOTING CALL 2 ChatType type = chat.ChatType; // new group person and group chats behind their protocol chat if (idx == -1 && (type == ChatType.Person || type == ChatType.Group)) { // REMOTING CALL 3 IProtocolManager pm = chat.ProtocolManager; for (int i = 0; i < f_Notebook.NPages; i++) { ChatView page = (ChatView)f_Notebook.GetNthPage(i); ChatModel pageChat = page.ChatModel; // REMOTING CALL 4 and 5 if (pageChat.ChatType == ChatType.Protocol && pageChat.ProtocolManager == pm) { idx = i + 1; break; } } if (idx != -1) { // now find the first chat with a different protocol manager bool found = false; for (int i = idx; i < f_Notebook.NPages; i++) { ChatView page = (ChatView)f_Notebook.GetNthPage(i); ChatModel pageChat = page.ChatModel; // REMOTING CALL 6 if (pageChat.ProtocolManager != pm) { found = true; idx = i; break; } } if (!found) { // if there was no next protocol manager, simply append // the chat way to the end idx = -1; } } } return(idx); }
public virtual void Sync() { ProtocolManager = ChatModel.ProtocolManager; Name = ChatModel.Name; #if LOG4NET _Logger.Debug("Sync() syncing messages"); #endif // sync messages // cleanup, be sure the output is empty f_MainWindow.Modify("output_textview", "replace_inner", ""); var messages = ChatModel.Messages; if (messages.Count > 0) { foreach (MessageModel msg in messages) { AddMessage(msg); } } }