private async void SendLocationExecute() { var page = new DialogSendLocationPage(); var dialog = new ContentDialogBase(); dialog.Content = page; page.Dialog = dialog; var confirm = await dialog.ShowAsync(); if (confirm == ContentDialogBaseResult.OK) { if (page.Media is TLMessageMediaVenue venue) { await SendGeoPointAsync(venue); } else if (page.Media is TLMessageMediaGeo geo && geo.Geo is TLGeoPoint geoPoint) { await SendGeoPointAsync(geoPoint.Lat, geoPoint.Long); } } //NavigationService.Navigate(typeof(DialogSendLocationPage)); }
public async void Clear(StorageStatisticsByChat byChat) { if (byChat == null) { return; } var dialog = new ContentDialogBase(); var page = new SettingsStorageOptimizationPage(ProtoService, dialog, byChat); dialog.Content = page; var confirm = await dialog.ShowAsync(); if (confirm != ContentDialogBaseResult.OK) { return; } var types = page.SelectedItems ?? new FileType[0]; if (types.IsEmpty()) { return; } var chatIds = new long[0]; var excludedChatIds = new long[0]; if (byChat.ChatId != 0) { chatIds = new[] { byChat.ChatId }; } else if (byChat != _totalStatistics) { excludedChatIds = _statistics.ByChat.Select(x => x.ChatId).Where(x => x != 0).ToArray(); } IsLoading = true; TaskCompleted = false; var response = await ProtoService.SendAsync(new OptimizeStorage(long.MaxValue, 0, int.MaxValue, 0, types, chatIds, excludedChatIds, 25)); if (response is StorageStatistics statistics) { Statistics = statistics; } IsLoading = false; TaskCompleted = true; }
private async void SendLocationExecute() { var page = new DialogShareLocationPage(); var dialog = new ContentDialogBase(); dialog.Content = page; page.Dialog = dialog; //page.LiveLocation = !_liveLocationService.IsTracking(Peer.ToPeer()); var confirm = await dialog.ShowAsync(); if (confirm == ContentDialogBaseResult.OK) { var reply = GetReply(true); var input = page.Media; await SendMessageAsync(reply, input); //if (page.Media is TLMessageMediaVenue venue) //{ // await SendGeoAsync(venue); //} //else if (page.Media is TLMessageMediaGeoLive geoLive) //{ // if (geoLive.Geo == null || geoLive.Period == 0 || _liveLocationService.IsTracking(Peer.ToPeer())) // { // _liveLocationService.StopTracking(Peer.ToPeer()); // } // else // { // await SendGeoAsync(geoLive); // } //} //else if (page.Media is TLMessageMediaGeo geo && geo.Geo is TLGeoPoint geoPoint) //{ // await SendGeoAsync(geoPoint.Lat, geoPoint.Long); //} } //NavigationService.Navigate(typeof(DialogSendLocationPage)); }
private async void SendLocationExecute() { var page = new DialogSendLocationPage(); var dialog = new ContentDialogBase(); dialog.Content = page; page.Dialog = dialog; page.LiveLocation = !_liveLocationService.IsTracking(Peer.ToPeer()); var confirm = await dialog.ShowAsync(); if (confirm == ContentDialogBaseResult.OK) { if (page.Media is TLMessageMediaVenue venue) { await SendGeoAsync(venue); } else if (page.Media is TLMessageMediaGeoLive geoLive) { if (geoLive.Geo == null || geoLive.Period == 0 || _liveLocationService.IsTracking(Peer.ToPeer())) { _liveLocationService.StopTracking(Peer.ToPeer()); } else { await SendGeoAsync(geoLive); } } else if (page.Media is TLMessageMediaGeo geo && geo.Geo is TLGeoPoint geoPoint) { await SendGeoAsync(geoPoint.Lat, geoPoint.Long); } } //NavigationService.Navigate(typeof(DialogSendLocationPage)); }
private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { var deferral = args.GetDeferral(); var message = args.Request.Message; try { if (message.ContainsKey("caption") && message.ContainsKey("request")) { var caption = message["caption"] as string; var buffer = message["request"] as string; var req = TLSerializationService.Current.Deserialize(buffer); if (caption.Equals("voip.getUser") && req is TLPeerUser userPeer) { var user = InMemoryCacheService.Current.GetUser(userPeer.UserId); if (user != null) { await args.Request.SendResponseAsync(new ValueSet { { "result", TLSerializationService.Current.Serialize(user) } }); } else { //await args.Request.SendResponseAsync(new ValueSet { { "error", TLSerializationService.Current.Serialize(new TLRPCError { ErrorMessage = "USER_NOT_FOUND", ErrorCode = 404 }) } }); } } else if (caption.Equals("voip.getConfig")) { var config = InMemoryCacheService.Current.GetConfig(); await args.Request.SendResponseAsync(new ValueSet { { "result", TLSerializationService.Current.Serialize(config) } }); } else if (caption.Equals("voip.callInfo") && req is byte[] data) { using (var from = TLObjectSerializer.CreateReader(data.AsBuffer())) { var tupleBase = new TLTuple <int, TLPhoneCallBase, TLUserBase, string>(from); var tuple = new TLTuple <TLPhoneCallState, TLPhoneCallBase, TLUserBase, string>((TLPhoneCallState)tupleBase.Item1, tupleBase.Item2, tupleBase.Item3, tupleBase.Item4); if (tuple.Item2 is TLPhoneCallDiscarded) { if (_phoneView != null) { var newView = _phoneView; _phoneViewExists = false; _phoneView = null; await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { newView.SetCall(tuple); newView.Dispose(); if (newView.Dialog != null) { newView.Dialog.Hide(); } else { Window.Current.Close(); } }); } return; } if (_phoneViewExists == false) { VoIPCallTask.Log("Creating VoIP UI", "Creating VoIP UI"); _phoneViewExists = true; await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { if (ApplicationView.GetForCurrentView().IsCompactOverlaySupported()) { var newView = CoreApplication.CreateNewView(); var newViewId = 0; await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var newPlayer = new PhoneCallPage(true); Window.Current.Content = newPlayer; Window.Current.Activate(); newViewId = ApplicationView.GetForCurrentView().Id; newPlayer.Dialog = null; newPlayer.SetCall(tuple); _phoneView = newPlayer; }); var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay); preferences.CustomSize = new Size(340, 200); var viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(newViewId, ApplicationViewMode.CompactOverlay, preferences); } else { var dialog = new ContentDialogBase(); dialog.VerticalAlignment = VerticalAlignment.Stretch; dialog.HorizontalAlignment = HorizontalAlignment.Stretch; var newPlayer = new PhoneCallPage(false); newPlayer.Dialog = dialog; newPlayer.SetCall(tuple); _phoneView = newPlayer; dialog.Content = newPlayer; await dialog.ShowAsync(); } }); } else if (_phoneView != null) { VoIPCallTask.Log("VoIP UI already exists", "VoIP UI already exists"); await _phoneView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _phoneView.SetCall(tuple); }); } } } else if (caption.Equals("voip.signalBars") && req is byte[] data2) { using (var from = TLObjectSerializer.CreateReader(data2.AsBuffer())) { var tuple = new TLTuple <int>(from); if (_phoneView != null) { await _phoneView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _phoneView.SetSignalBars(tuple.Item1); }); } } } else if (caption.Equals("voip.setCallRating") && req is TLInputPhoneCall peer) { Execute.BeginOnUIThread(async() => { var dialog = new PhoneCallRatingView(); var confirm = await dialog.ShowQueuedAsync(); if (confirm == ContentDialogResult.Primary) { await MTProtoService.Current.SetCallRatingAsync(peer, dialog.Rating, dialog.Rating >= 0 && dialog.Rating <= 3 ? dialog.Comment : null); } }); } else { var response = await MTProtoService.Current.SendRequestAsync <object>(caption, req as TLObject); if (response.IsSucceeded) { await args.Request.SendResponseAsync(new ValueSet { { "result", TLSerializationService.Current.Serialize(response.Result) } }); } else { await args.Request.SendResponseAsync(new ValueSet { { "error", TLSerializationService.Current.Serialize(response.Error) } }); } } } } finally { deferral.Complete(); } }