namespace Febe.Web.Connection; /// State of the link to Instagram shown at the bottom of the sidebar and on the Collegamento page (spec §4.1). public enum ConnectionState { /// No session in the browser profile: «Non collegato». NotConnected, /// Session cookie present: «Collegato». Connected, /// The engine stopped for a challenge or a disconnection: «Verifica richiesta». VerificationRequired, /// The browser is not available (starting, crashed, demo without browser). BrowserUnavailable, } /// What the interface knows about the link to Instagram. /// Current state. /// Connected account (from the data the page received, hypothesis H10), when known. /// Display name, when known. /// True while Alberto is using the browser (login page, remote view, browser window): the engine is still. /// Address shown in the remote view's address bar, without query string. public sealed record ConnectionStatus( ConnectionState State, string? Username, string? DisplayName, bool UserIsDriving, string? CurrentUrl); /// Result of «Ho finito» on the Collegamento page. /// True when the session cookie now exists. /// Italian message for the page (what happened, what Febe did, what Alberto should do). public sealed record FinishResult(bool Connected, string Message); /// /// The link to Instagram (spec §4.1, §10.3 «Collegamento» and «Browser» pages). Implemented by the server/desktop /// composition over the real browser host, and by the demo mode with a fake driven by the scene. /// Opening the login page here is not an engine action (rule 7): Alberto is using the browser and the engine is still. /// public interface IConnectionService { Task GetStatusAsync(CancellationToken ct); /// /// Alberto starts using the browser: the engine stops acting (UserIsDriving), and when /// is true the browser loads the real Instagram login page. Windows: the browser window is brought to the front. /// Task BeginUserDrivingAsync(bool openLogin, CancellationToken ct); /// «Ho finito»: checks that the session cookie exists (value never read), hides the browser, ends user driving. Task FinishAsync(CancellationToken ct); /// «Annulla»: ends user driving and puts the browser on the empty rest page. Task CancelAsync(CancellationToken ct); /// /// «Apri il browser» on Windows (spec §10.3, issue #52): the window comes to the front and holds the engine still /// while it is on screen. A browser resting on the empty page first opens the start page (the site's home when /// connected, the login page otherwise); with the login page in any case (the red strip /// of a disconnection). /// Task ShowBrowserAsync(bool openLogin, CancellationToken ct); /// /// The Febe page that took the browser was left (another page, a reload, the tab closed) while the browser is a /// window of its own (Windows, issue #52): only the page's hold ends. The window stays as it is, on screen and with /// its page, until Alberto closes it or presses «Ho finito». /// Task ReleaseAsync(CancellationToken ct); /// «Scollega» (after confirmation in the UI): stops the engine and deletes the browser profile. Task DisconnectAsync(CancellationToken ct); }