From 9fad42e9e1ce21afc18a4f1fe4cb39e35cc9b995 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sun, 16 Oct 2016 20:30:02 +0800 Subject: [PATCH 1/2] Frontend: rename method in ChatViewSyncManager, to follow convention Methods that start with "On" are normally the ones that get called because they got subscribed to some event. In this case, this method is the one in charge of raising that event so to make it a bit less confusing, let's rename it to have the "Raise" prefix instead of "On". --- src/Frontend/ChatViewSyncManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Frontend/ChatViewSyncManager.cs b/src/Frontend/ChatViewSyncManager.cs index 7a726b47d..cd57e08dc 100644 --- a/src/Frontend/ChatViewSyncManager.cs +++ b/src/Frontend/ChatViewSyncManager.cs @@ -79,8 +79,8 @@ public void Add(ChatModel chatModel) Math.Round(duration) + " ms"); #endif - OnChatAdded(chatModel, chatId, chatType, chatPosition, - protocolManager, protocolManagerType); + RaiseChatAdded(chatModel, chatId, chatType, chatPosition, + protocolManager, protocolManagerType); } /// @@ -290,10 +290,10 @@ void SyncWorker(ChatModel chatModel) } } - void OnChatAdded(ChatModel chatModel, string chatId, - ChatType chatType, int chatPosition, - IProtocolManager protocolManager, - Type protocolManagerType) + void RaiseChatAdded(ChatModel chatModel, string chatId, + ChatType chatType, int chatPosition, + IProtocolManager protocolManager, + Type protocolManagerType) { if (ChatAdded != null) { ChatAdded(this, From 41b248b3813675be8fe396816105f8cc66c95639 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sun, 16 Oct 2016 20:39:40 +0800 Subject: [PATCH 2/2] Engine(-Twitter),Frontend: avoid Close warning dialog (closes: #1093) There are some protocols, like Twitter, in which there are no consequences from disconnecting from the server: no unavailable status is shown to our contacts, and no chat buffers will be lost because all the info resides server-side. For these, there is not really any point in warning the user about current open chats when she intends to close the connection, so let's whitelist Twitter in this way to avoid the pointless dialog. --- .../Protocols/Twitter/TwitterProtocolManager.cs | 6 ++++++ src/Engine/Protocols/IProtocolManager.cs | 4 ++++ src/Engine/Protocols/ProtocolManagerBase.cs | 6 ++++++ src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs | 2 +- src/Frontend-Tests/Mocks/MockProtocolManager.cs | 6 ++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs b/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs index 72660ec28..64b38127e 100644 --- a/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs +++ b/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs @@ -115,6 +115,12 @@ protected bool HasTokens { } } + public override bool HiddenPresenceStatus { + get { + return true; + } + } + public TwitterProtocolManager(Session session) : base(session) { Trace.Call(session); diff --git a/src/Engine/Protocols/IProtocolManager.cs b/src/Engine/Protocols/IProtocolManager.cs index 35ff6c93c..0722db254 100644 --- a/src/Engine/Protocols/IProtocolManager.cs +++ b/src/Engine/Protocols/IProtocolManager.cs @@ -67,6 +67,10 @@ PresenceStatus PresenceStatus { get; } + bool HiddenPresenceStatus { + get; + } + void Connect(FrontendManager frontendManager, ServerModel server); void Disconnect(FrontendManager frontendManager); void Reconnect(FrontendManager frontendManager); diff --git a/src/Engine/Protocols/ProtocolManagerBase.cs b/src/Engine/Protocols/ProtocolManagerBase.cs index 3b6e1ca06..5b7dc7dc6 100644 --- a/src/Engine/Protocols/ProtocolManagerBase.cs +++ b/src/Engine/Protocols/ProtocolManagerBase.cs @@ -86,6 +86,12 @@ public virtual PresenceStatus PresenceStatus { } } + public virtual bool HiddenPresenceStatus { + get { + return false; + } + } + public abstract string NetworkID { get; } diff --git a/src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs b/src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs index 4fb9844d9..5a5b50ac7 100644 --- a/src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs +++ b/src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs @@ -168,7 +168,7 @@ public override void Close() ownedChats++; } } - if (ownedChats > 1) { + if (!ProtocolManager.HiddenPresenceStatus && ownedChats > 1) { Gtk.MessageDialog md = new Gtk.MessageDialog( Frontend.MainWindow, Gtk.DialogFlags.Modal, diff --git a/src/Frontend-Tests/Mocks/MockProtocolManager.cs b/src/Frontend-Tests/Mocks/MockProtocolManager.cs index cf7ec8342..df3908e90 100644 --- a/src/Frontend-Tests/Mocks/MockProtocolManager.cs +++ b/src/Frontend-Tests/Mocks/MockProtocolManager.cs @@ -35,6 +35,12 @@ public Session Session { } } + public bool HiddenPresenceStatus { + get { + return false; + } + } + public string NetworkID { get { return "MockProtocolManagerNetwork";