Skip to content

Commit

Permalink
Engine(-Twitter),Frontend: avoid Close warning dialog (closes: #1093)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
knocte committed Nov 17, 2020
1 parent 9fad42e commit 41b248b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ protected bool HasTokens {
}
}

public override bool HiddenPresenceStatus {
get {
return true;
}
}

public TwitterProtocolManager(Session session) : base(session)
{
Trace.Call(session);
Expand Down
4 changes: 4 additions & 0 deletions src/Engine/Protocols/IProtocolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ PresenceStatus PresenceStatus {
get;
}

bool HiddenPresenceStatus {
get;
}

void Connect(FrontendManager frontendManager, ServerModel server);
void Disconnect(FrontendManager frontendManager);
void Reconnect(FrontendManager frontendManager);
Expand Down
6 changes: 6 additions & 0 deletions src/Engine/Protocols/ProtocolManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public virtual PresenceStatus PresenceStatus {
}
}

public virtual bool HiddenPresenceStatus {
get {
return false;
}
}

public abstract string NetworkID {
get;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Frontend-GNOME/Views/Chats/ProtocolChatView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/Frontend-Tests/Mocks/MockProtocolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public Session Session {
}
}

public bool HiddenPresenceStatus {
get {
return false;
}
}

public string NetworkID {
get {
return "MockProtocolManagerNetwork";
Expand Down

0 comments on commit 41b248b

Please sign in to comment.