Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf7817a9

Browse files
committed
feat: wire up file sync window
1 parentda29411 commitf7817a9

File tree

12 files changed

+752
-145
lines changed

12 files changed

+752
-145
lines changed

‎App/App.xaml.cs

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
usingSystem;
2+
usingSystem.Diagnostics;
23
usingSystem.Threading;
34
usingSystem.Threading.Tasks;
45
usingCoder.Desktop.App.Models;
@@ -73,6 +74,8 @@ public async Task ExitApplication()
7374
{
7475
_handleWindowClosed=false;
7576
Exit();
77+
varsyncController=_services.GetRequiredService<ISyncSessionController>();
78+
awaitsyncController.DisposeAsync();
7679
varrpcController=_services.GetRequiredService<IRpcController>();
7780
// TODO: send a StopRequest if we're connected???
7881
awaitrpcController.DisposeAsync();
@@ -86,20 +89,52 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
8689
if(rpcController.GetState().RpcLifecycle==RpcLifecycle.Disconnected)
8790
// Passing in a CT with no cancellation is desired here, because
8891
// the named pipe open will block until the pipe comes up.
89-
_=rpcController.Reconnect(CancellationToken.None);
92+
// TODO: log
93+
_=rpcController.Reconnect(CancellationToken.None).ContinueWith(t=>
94+
{
95+
#ifDEBUG
96+
if(t.Exception!=null)
97+
{
98+
Debug.WriteLine(t.Exception);
99+
Debugger.Break();
100+
}
101+
#endif
102+
});
90103

91-
// Load the credentials in the background. Even though we pass a CT
92-
// with no cancellation, the method itself will impose a timeout on the
93-
// HTTP portion.
104+
// Load the credentials in the background.
105+
varcredentialManagerCts=newCancellationTokenSource(TimeSpan.FromSeconds(15));
94106
varcredentialManager=_services.GetRequiredService<ICredentialManager>();
95-
_=credentialManager.LoadCredentials(CancellationToken.None);
107+
_=credentialManager.LoadCredentials(credentialManagerCts.Token).ContinueWith(t=>
108+
{
109+
// TODO: log
110+
#ifDEBUG
111+
if(t.Exception!=null)
112+
{
113+
Debug.WriteLine(t.Exception);
114+
Debugger.Break();
115+
}
116+
#endif
117+
credentialManagerCts.Dispose();
118+
},CancellationToken.None);
119+
120+
// Initialize file sync.
121+
varsyncSessionCts=newCancellationTokenSource(TimeSpan.FromSeconds(10));
122+
varsyncSessionController=_services.GetRequiredService<ISyncSessionController>();
123+
_=syncSessionController.Initialize(syncSessionCts.Token).ContinueWith(t=>
124+
{
125+
// TODO: log
126+
#ifDEBUG
127+
if(t.IsCanceled||t.Exception!=null)Debugger.Break();
128+
#endif
129+
syncSessionCts.Dispose();
130+
},CancellationToken.None);
96131

97132
// Prevent the TrayWindow from closing, just hide it.
98133
vartrayWindow=_services.GetRequiredService<TrayWindow>();
99-
trayWindow.Closed+=(sender,args)=>
134+
trayWindow.Closed+=(_,closedArgs)=>
100135
{
101136
if(!_handleWindowClosed)return;
102-
args.Handled=true;
137+
closedArgs.Handled=true;
103138
trayWindow.AppWindow.Hide();
104139
};
105140
}

‎App/Models/SyncSessionModel.cs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
usingSystem;
21
usingCoder.Desktop.App.Converters;
32
usingCoder.Desktop.MutagenSdk.Proto.Synchronization;
43
usingCoder.Desktop.MutagenSdk.Proto.Url;
@@ -64,6 +63,10 @@ public class SyncSessionModel
6463

6564
publicreadonlystring[]Errors=[];
6665

66+
// If Paused is true, the session can be resumed. If false, the session can
67+
// be paused.
68+
publicboolPaused=>StatusCategoryisSyncSessionStatusCategory.Paused orSyncSessionStatusCategory.Halted;
69+
6770
publicstringStatusDetails
6871
{
6972
get
@@ -84,37 +87,6 @@ public string SizeDetails
8487
}
8588
}
8689

87-
// TODO: remove once we process sessions from the mutagen RPC
88-
publicSyncSessionModel(stringalphaPath,stringbetaName,stringbetaPath,
89-
SyncSessionStatusCategorystatusCategory,
90-
stringstatusString,stringstatusDescription,string[]errors)
91-
{
92-
Identifier="TODO";
93-
Name="TODO";
94-
95-
AlphaName="Local";
96-
AlphaPath=alphaPath;
97-
BetaName=betaName;
98-
BetaPath=betaPath;
99-
StatusCategory=statusCategory;
100-
StatusString=statusString;
101-
StatusDescription=statusDescription;
102-
AlphaSize=newSyncSessionModelEndpointSize
103-
{
104-
SizeBytes=(ulong)newRandom().Next(0,1000000000),
105-
FileCount=(ulong)newRandom().Next(0,10000),
106-
DirCount=(ulong)newRandom().Next(0,10000),
107-
};
108-
BetaSize=newSyncSessionModelEndpointSize
109-
{
110-
SizeBytes=(ulong)newRandom().Next(0,1000000000),
111-
FileCount=(ulong)newRandom().Next(0,10000),
112-
DirCount=(ulong)newRandom().Next(0,10000),
113-
};
114-
115-
Errors=errors;
116-
}
117-
11890
publicSyncSessionModel(Statestate)
11991
{
12092
Identifier=state.Session.Identifier;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp