private async void Authenticate_Tapped(object sender, TappedRoutedEventArgs e) { try { this.IsEnabled = false; progressRing.Visibility = Visibility.Visible; var graph = new Graph(await MSAAuthenticator.GetAccessTokenAsync("User.Read")); //await (new MessageDialog(await graph.GetUserUniqueIdAsync())).ShowAsync(); var userId = await graph.GetUserUniqueIdAsync(); SecureKeyStorage.SetUserId(userId); } catch (Exception ex) { Debug.WriteLine($"Authenticate failed. {ex.ToString()}"); MainPage.Current.IsAskedAboutMSAPermission = false; MainPage.Current.isAskedAboutMSAPermissionThisTime = true; } finally { this.IsEnabled = true; FlyoutCloseRequest?.Invoke(this, new EventArgs()); } }
private void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) { if ((args.Uri.AbsolutePath.Contains("/v2/Graph/Welcome")) && (args.Uri.Query.Length > 12)) { webView.Visibility = Visibility.Collapsed; string id = args.Uri.Query.Substring(11); Debug.WriteLine($"Account Id is: {id}"); SecureKeyStorage.SetAccountId(id); Windows.Storage.ApplicationData.Current.LocalSettings.Values["SendCloudClipboard"] = true; #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed PCExtensionHelper.StartPCExtension(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed if (PCExtensionHelper.IsSupported) { ToastFunctions.SendUniversalClipboardNoticeToast(); } Frame.GoBack(); } else { loadingProgress.IsIndeterminate = false; loadingProgress.Visibility = Visibility.Collapsed; } }
public static List <string> GetWhatsNewContentId() { List <string> output = new List <string>(); if (!ShouldShowWhatsNew()) { return(output); } System.Version prevVersion = new System.Version(0, 0, 0, 0); if (ApplicationData.Current.LocalSettings.Values.ContainsKey("LatestWhatsNewVersion")) { System.Version.TryParse(ApplicationData.Current.LocalSettings.Values["LatestWhatsNewVersion"].ToString(), out prevVersion); } if (prevVersion < new System.Version("2.4.0.0")) { output.Add("7"); } if (prevVersion < new System.Version("2.3.0.0")) { output.Add("6"); } if (prevVersion < new System.Version("2.0.0.0")) { output.Add("4"); } if (prevVersion < new System.Version("1.6.1.0")) { output.Add("3"); } //if (prevVersion < new System.Version("1.5.2.0")) // output.Add("2"); if ((prevVersion < new System.Version("1.2.1.0")) && ((DeviceInfo.FormFactorType == DeviceInfo.DeviceFormFactorType.Desktop) || (DeviceInfo.FormFactorType == DeviceInfo.DeviceFormFactorType.Tablet))) { output.Add("1"); } //Important message regarding Android app's new listing if ((prevVersion < new System.Version("2.1.5.0")) && (SecureKeyStorage.IsUserIdStored())) { output.Clear(); output.Add("5"); } MarkThisWhatsNewAsRead(); return(output); }
private async void SignOutFromCloudService_Tapped(object sender, TappedRoutedEventArgs e) { await PCExtensionHelper.StopPCExtensionIfRunning(); SecureKeyStorage.DeleteAccountId(); ApplicationData.Current.LocalSettings.Values["SendCloudClipboard"] = false.ToString(); Model.SendCloudClipboard = false; Model.RefreshCloudClipboardBindings(); }
private async Task <RomeAppServiceConnectionStatus> Connect(object rs) { if (rs is NormalizedRemoteSystem) { return(await MainPage.Current.AndroidPackageManager.Connect(rs as NormalizedRemoteSystem, SecureKeyStorage.GetUserId(), MainPage.Current.PackageManager.RemoteSystems.Where(x => x.Kind != "Unknown").Select(x => x.Id))); } else { return(await MainPage.Current.PackageManager.Connect(rs, true, new Uri("roamit://wake"))); } }
private async void SetReceiveCloudClipboardValue(bool value) { ReceiveCloudClipboardEnabled = false; ReceiveCloudClipboardProgressRingActive = true; await Common.Service.CloudClipboardService.SetCloudClipboardActivation(SecureKeyStorage.GetAccountId(), deviceId, value); receiveCloudClipboard = value; OnPropertyChanged("ReceiveCloudClipboard"); ReceiveCloudClipboardEnabled = true; ReceiveCloudClipboardProgressRingActive = false; }
private async Task <bool> TrySendFastClipboard(string text, object rs, string deviceName) { if (rs is NormalizedRemoteSystem) { return(await AndroidRomePackageManager.QuickClipboard(text, rs as NormalizedRemoteSystem, SecureKeyStorage.GetUserId(), deviceName)); } else { if (ShouldPrioritizeRomePackageManager(rs as RemoteSystem)) { var result = await MainPage.Current.PackageManager.QuickClipboard(text, rs as RemoteSystem, deviceName, "roamit://clipboard"); if (!result) { // Try using Cloud Service for that instead if (CloudServiceRomePackageManager.Instance.IsInitialized) { return(await CloudServiceRomePackageManager.Instance.QuickClipboardForWindowsDevice(text, (rs as RemoteSystem).DisplayName, deviceName)); } return(false); } return(true); } else { var result = await CloudServiceRomePackageManager.Instance.QuickClipboardForWindowsDevice(text, (rs as RemoteSystem).DisplayName, deviceName); if (result) { return(true); } else { // If launching via cloud service failed, fall back to local Project Rome SDK. return(await MainPage.Current.PackageManager.QuickClipboard(text, rs as RemoteSystem, deviceName, "roamit://clipboard")); } } } }
private void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) { if ((args.Uri.AbsolutePath.Contains("/v3/Graph/Welcome"))) { var queryStrings = QueryHelpers.ParseQuery(args.Uri.Query); if (queryStrings.ContainsKey("accountId") && queryStrings.ContainsKey("token")) { webView.Visibility = Visibility.Collapsed; string id = queryStrings["accountId"][0]; string token = queryStrings["token"][0]; Debug.WriteLine($"Account Id is: '{id}', token is: '{token}'"); SecureKeyStorage.SetAccountId(id); SecureKeyStorage.SetToken(token); if (ApplicationData.Current.LocalSettings.Values.ContainsKey("SendCloudClipboard") && ApplicationData.Current.LocalSettings.Values["SendCloudClipboard"].ToString().ToLower() == "true") { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed PCExtensionHelper.StartPCExtension(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed if (PCExtensionHelper.IsSupported) { ToastFunctions.SendUniversalClipboardNoticeToast(); } } Frame.GoBack(); } else { // Failed to log in var errorCode = queryStrings.ContainsKey("error") ? queryStrings["error"][0] : "null"; var md = new MessageDialog($"Login failed with error '{errorCode}'. Functionality may be limited."); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed md.ShowAsync(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Frame.GoBack(); } } else { loadingProgress.IsIndeterminate = false; loadingProgress.Visibility = Visibility.Collapsed; } }
private async void RetrieveCloudServiceUserName() { if (!SecureKeyStorage.IsAccountIdStored()) { return; } UserName = await Common.Service.CloudClipboardService.GetUserName(SecureKeyStorage.GetAccountId()); if (string.IsNullOrWhiteSpace(UserName)) { UserName = "******"; } }
private async void ActivateFindingOtherDevices() { var graph = new Graph(await MSAAuthenticator.GetAccessTokenAsync("User.Read")); var userId = await graph.GetUserUniqueIdAsync(); SecureKeyStorage.SetUserId(userId); findOtherDevices = true; OnPropertyChanged("FindOtherDevices"); FindOtherDevicesProgressRingActive = false; FindOtherDevicesEnabled = true; #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed MainPage.Current.DiscoverOtherDevices(true); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }
private async Task <bool> TrySendFastClipboard(string text, object rs, string deviceName) { if (rs is NormalizedRemoteSystem) { return(await AndroidRomePackageManager.QuickClipboard(text, rs as NormalizedRemoteSystem, SecureKeyStorage.GetUserId(), deviceName)); } else { return(await MainPage.Current.PackageManager.QuickClipboard(text, rs as RemoteSystem, deviceName, "roamit://clipboard")); } }
private async void RetrieveCloudClipboardActivationStatus() { if (!SecureKeyStorage.IsAccountIdStored()) { return; } ReceiveCloudClipboardEnabled = false; ReceiveCloudClipboardProgressRingActive = true; try { var result = await Common.Service.CloudClipboardService.GetDevices(SecureKeyStorage.GetAccountId()); var deviceName = (new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation()).FriendlyName; Debug.WriteLine($"Current device name is '{deviceName}'"); var currentDevice = result.FirstOrDefault(x => (x.Name ?? "").ToLower() == deviceName.ToLower()); if (currentDevice == null) { return; } deviceId = currentDevice.DeviceID; receiveCloudClipboard = currentDevice.CloudClipboardEnabled; OnPropertyChanged("ReceiveCloudClipboard"); ReceiveCloudClipboardEnabled = true; } catch (Exception ex) { Debug.WriteLine($"Exception in RetrieveCloudClipboardActivationStatus: {ex.Message}"); } finally { ReceiveCloudClipboardProgressRingActive = false; } }
private async Task <Tuple <RomeAppServiceConnectionStatus, IRomePackageManager> > Connect(object rs, bool openReceiveFileDialogIfOverCloud) { if (rs is NormalizedRemoteSystem) { var result = await MainPage.Current.AndroidPackageManager.Connect(rs as NormalizedRemoteSystem, SecureKeyStorage.GetUserId(), MainPage.Current.PackageManager.RemoteSystems.Where(x => x.Kind != "Unknown").Select(x => x.Id)); return(new Tuple <RomeAppServiceConnectionStatus, IRomePackageManager>(result, MainPage.Current.AndroidPackageManager)); } else { if (ShouldPrioritizeRomePackageManager(rs as RemoteSystem)) { var result = await MainPage.Current.PackageManager.Connect(rs, true, new Uri("roamit://wake")); if (result == RomeAppServiceConnectionStatus.RemoteSystemUnavailable && CloudServiceRomePackageManager.Instance.IsInitialized) { // 1809 bug. Try to use CloudService instead. RomeAppServiceConnectionStatus result2; if (openReceiveFileDialogIfOverCloud) { result2 = await CloudServiceRomePackageManager.Instance.Connect(((RemoteSystem)rs).DisplayName, new Uri("roamit://receiveDialog")); } else { result2 = await CloudServiceRomePackageManager.Instance.Connect(((RemoteSystem)rs).DisplayName); } if (result2 == RomeAppServiceConnectionStatus.Success) { return(new Tuple <RomeAppServiceConnectionStatus, IRomePackageManager>(result2, CloudServiceRomePackageManager.Instance)); } } return(new Tuple <RomeAppServiceConnectionStatus, IRomePackageManager>(result, MainPage.Current.PackageManager)); } else { RomeAppServiceConnectionStatus result2; if (openReceiveFileDialogIfOverCloud) { result2 = await CloudServiceRomePackageManager.Instance.Connect(((RemoteSystem)rs).DisplayName, new Uri("roamit://receiveDialog")); } else { result2 = await CloudServiceRomePackageManager.Instance.Connect(((RemoteSystem)rs).DisplayName); } if (result2 == RomeAppServiceConnectionStatus.Success) { return(new Tuple <RomeAppServiceConnectionStatus, IRomePackageManager>(result2, CloudServiceRomePackageManager.Instance)); } else { var result = await MainPage.Current.PackageManager.Connect(rs, true, new Uri("roamit://wake")); return(new Tuple <RomeAppServiceConnectionStatus, IRomePackageManager>(result, MainPage.Current.PackageManager)); } } } }
private async Task LaunchUri(object rs) { ViewModel.ProgressPercentIndicatorVisibility = Visibility.Collapsed; RomeRemoteLaunchUriStatus launchResult; if (rs is NormalizedRemoteSystem) { launchResult = await AndroidRomePackageManager.LaunchUri(SendDataTemporaryStorage.LaunchUri, rs as NormalizedRemoteSystem, SecureKeyStorage.GetUserId()); } else { if (ShouldPrioritizeRomePackageManager(rs as RemoteSystem)) { launchResult = await MainPage.Current.PackageManager.LaunchUri(SendDataTemporaryStorage.LaunchUri, rs, false); if (launchResult == RomeRemoteLaunchUriStatus.RemoteSystemUnavailable) { // 1809 bug, will try cloud service if available if (CloudServiceRomePackageManager.Instance.IsInitialized) { launchResult = await CloudServiceRomePackageManager.Instance.LaunchUri(((RemoteSystem)rs).DisplayName, SendDataTemporaryStorage.LaunchUri); } } } else { launchResult = await CloudServiceRomePackageManager.Instance.LaunchUri(((RemoteSystem)rs).DisplayName, SendDataTemporaryStorage.LaunchUri); // If launching via cloud service failed, fall back to local Project Rome SDK. if (launchResult != RomeRemoteLaunchUriStatus.Success) { launchResult = await MainPage.Current.PackageManager.LaunchUri(SendDataTemporaryStorage.LaunchUri, rs, false); } } } string status; if (launchResult == RomeRemoteLaunchUriStatus.Success) { status = ""; } else { status = launchResult.ToString(); } SendTextFinished(status); }
public DevicesSettings() { this.InitializeComponent(); Model = new DevicesSettingsViewModel(SecureKeyStorage.GetAccountId()); }
private async void OnPCAppServiceRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { Debug.WriteLine("OnPCAppServiceRequestReceived"); AppServiceDeferral messageDeferral = args.GetDeferral(); try { if (!args.Request.Message.ContainsKey("Action")) { throw new Exception("Invalid message received."); } string action = args.Request.Message["Action"] as string; Debug.WriteLine($"Action: {action}"); if (action == "Hello") { ValueSet vs = new ValueSet { { "Hey", "Hey" } }; await args.Request.SendResponseAsync(vs); } else if (action == "WhyImHere") { Debug.WriteLine($"Win32 process asked for its purpose, which is {PCExtensionCurrentPurpose}"); if (PCExtensionCurrentPurpose == PCExtensionPurpose.Default) { bool shouldItRun = false; if (ApplicationData.Current.LocalSettings.Values.ContainsKey("SendCloudClipboard")) { bool.TryParse(ApplicationData.Current.LocalSettings.Values["SendCloudClipboard"].ToString(), out shouldItRun); } if (SecureKeyStorage.IsAccountIdStored() == false) { shouldItRun = false; } var status = await args.Request.SendResponseAsync(new ValueSet { { "Answer", shouldItRun ? "Alone" : "Die" }, { "AccountId", SecureKeyStorage.GetAccountId() } }); } else if (PCExtensionCurrentPurpose == PCExtensionPurpose.Genocide) { var status = await args.Request.SendResponseAsync(new ValueSet { { "Answer", "Genocide" }, }); } else if (PCExtensionCurrentPurpose == PCExtensionPurpose.ForgetEverything) { var status = await args.Request.SendResponseAsync(new ValueSet { { "Answer", "ForgetEverything" }, }); } PCExtensionCurrentPurpose = PCExtensionPurpose.Default; } else if (action == "Die") { Application.Current.Exit(); } } catch (Exception ex) { Debug.WriteLine($"Exception on OnPCAppServiceRequestReceived: {ex.Message}"); } finally { messageDeferral.Complete(); pcAppServiceDeferral?.Complete(); Debug.WriteLine("Request finished."); } }
private async Task LaunchUri(object rs) { ViewModel.ProgressPercentIndicatorVisibility = Visibility.Collapsed; RomeRemoteLaunchUriStatus launchResult; if (rs is NormalizedRemoteSystem) { launchResult = await UWP.Rome.AndroidRomePackageManager.LaunchUri(SendDataTemporaryStorage.LaunchUri, rs as NormalizedRemoteSystem, SecureKeyStorage.GetUserId()); } else { launchResult = await MainPage.Current.PackageManager.LaunchUri(SendDataTemporaryStorage.LaunchUri, rs); } string status; if (launchResult == RomeRemoteLaunchUriStatus.Success) { status = ""; } else { status = launchResult.ToString(); } SendTextFinished(status); }