private async Task <IUploadFile> FetchUserThumbnail(IUser user, Telegram telegramService, bool small) { var thumbnailLocation = TelegramUtils.GetUserPhotoLocation(user, small); if (thumbnailLocation == null) { return(null); } if (thumbnailLocation.DcId == telegramService.Settings.NearestDcId) { using (var clientDisposable = new Telegram.FullClientDisposable(telegramService)) { return(await FetchFileBytes(clientDisposable.Client, thumbnailLocation)); } } else { try { var telegramClient = telegramService.GetClient((int)thumbnailLocation.DcId); return(await FetchFileBytes(telegramClient, thumbnailLocation)); } catch (Exception ex) { Utils.DebugPrint("Failed to obtain client from DC manager: " + ex); return(null); } } }
public TopCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
public LogsCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
public StatusCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
public ItemsCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
public RecycleCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
protected CommandLocation(TelegramUtils telegramUtils) { TelegramUtils = telegramUtils; }
public ExitCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
private async void Populate(Service service) { _progressBar.IsVisible = true; _lastSeen.IsVisible = false; _userProfile.IsVisible = false; _groups.IsVisible = false; _privacyList.IsVisible = false; var telegramService = service as Telegram; var user = telegramService.Dialogs.GetUser(telegramService.Settings.AccountId); DependencyService.Get <IPluginPageControls>().BackPressEnabled = false; //RPC call using (var client = new Telegram.FullClientDisposable(service as Telegram)) { var iStatusPrivacyRules = await client.Client.Methods.AccountGetPrivacyAsync(new AccountGetPrivacyArgs { Key = new InputPrivacyKeyStatusTimestamp() }); var statusPrivacyRules = iStatusPrivacyRules as AccountPrivacyRules; if (statusPrivacyRules != null) { var statusPrivacyRule = GetPrivacyRule(statusPrivacyRules.Rules); if (statusPrivacyRule is PrivacyValueAllowAll) { _lastSeenPicker.Title = _privacyOptionsLastSeenStrings[0]; } else if (statusPrivacyRule is PrivacyValueAllowContacts) { _lastSeenPicker.Title = _privacyOptionsLastSeenStrings[1]; } else { _lastSeenPicker.Title = _privacyOptionsLastSeenStrings[2]; } } var iChatPrivacyRules = await client.Client.Methods.AccountGetPrivacyAsync(new AccountGetPrivacyArgs { Key = new InputPrivacyKeyChatInvite() }); var chatPrivacyRules = iChatPrivacyRules as AccountPrivacyRules; if (chatPrivacyRules != null) { var chatPrivacyRule = GetPrivacyRule(chatPrivacyRules.Rules); if (chatPrivacyRule is PrivacyValueAllowAll) { _groupsPicker.Title = _privacyOptionsLastSeenStrings[0]; } else if (chatPrivacyRule is PrivacyValueAllowContacts) { _groupsPicker.Title = _privacyOptionsLastSeenStrings[1]; } } var fileBytes = (UploadFile) await FetchUserThumbnail(user, telegramService, true); if (fileBytes != null) { var thumbnail = new DisaThumbnail(telegramService, fileBytes.Bytes, "userprofile"); _userProfile.SetThumbnail(thumbnail); } else { _userProfile.SetThumbnail(null); } _userProfile.Title = TelegramUtils.GetUserName(user); _userProfile.Subtitle = TelegramUtils.GetUserHandle(user); } _progressBar.IsVisible = false; _lastSeen.IsVisible = true; _userProfile.IsVisible = true; _privacyList.IsVisible = true; _groups.IsVisible = true; _userProfile.FetchThumbnail = async() => { var fileBytes = (UploadFile) await FetchUserThumbnail(user, telegramService, false); if (fileBytes == null) { return(null); } return(new DisaThumbnail(telegramService, fileBytes.Bytes, "userprofile")); }; _userProfile.ThumbnailChanged += async(sender, e) => { using (var client = new Telegram.FullClientDisposable(telegramService)) { var resizedPhoto = Platform.GenerateJpegBytes(e, 640, 640); var inputFile = await UploadProfilePhoto(telegramService, client.Client, resizedPhoto); await SetProfilePhoto(telegramService, client.Client, inputFile); } }; _userProfile.ThumbnailRemoved += async(sender, e) => { using (var client = new Telegram.FullClientDisposable(telegramService)) { await RemoveProfilePhoto(client.Client); } }; _groupsPicker.SelectedIndexChanged += async(sender, args) => { await SendGroupPrivacyChangeUpdate(telegramService, _groupsPicker.SelectedIndex); }; _lastSeenPicker.SelectedIndexChanged += async(sender, args) => { await SendLastSeenPrivacyChangeUpdate(telegramService, _lastSeenPicker.SelectedIndex); }; DependencyService.Get <IPluginPageControls>().BackPressEnabled = true; }
public SnipeCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
public RestartCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
protected CommandMessage(TelegramUtils telegramUtils) { TelegramUtils = telegramUtils; }
public AllCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
public ProfileCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
public AccountsCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
public PokedexCommand(TelegramUtils telegramUtils) : base(telegramUtils) { }
private Task <ActivationResult> DoVerify(VerificationOption option) { return(Task <ActivationResult> .Factory.StartNew(() => { var settings = GetSettingsTelegramSettings(); var response = Telegram.RequestCode(_service, CountryCode + NationalNumber, GetSettingsCodeHash(), GetSettingsTelegramSettings(), option == VerificationOption.Voice); if (response.Response == Telegram.CodeRequest.Type.Migrate) { TelegramSettings newSettings; using (var migratedClient = Telegram.GetNewClient(response.MigrateId, GetSettingsTelegramSettings(), out newSettings)) { TelegramUtils.RunSynchronously(migratedClient.Connect()); response = Telegram.RequestCode(_service, CountryCode + NationalNumber, GetSettingsCodeHash(), newSettings, option == VerificationOption.Voice); Utils.DebugPrint(">>>>> Response from the server " + ObjectDumper.Dump(response)); if (option == VerificationOption.Sms) { SetSettingsSettings(newSettings, false); SetSettingsCodeHash(response.CodeHash, false); SetSettingsRegistered(response.Registered, false); } return new ActivationResult { Success = true, }; } } if (response == null || response.Response != Telegram.CodeRequest.Type.Success) { var message = Localize.GetString("TelegramVerifyError"); if (response != null) { if (response.Response == Telegram.CodeRequest.Type.NumberInvalid) { message = Localize.GetString("TelegramVerifyInvalidNumber"); } } return new ActivationResult { Success = false, ErrorMessage = message, }; } if (option == VerificationOption.Sms) { SetSettingsCodeHash(response.CodeHash, true); SetSettingsRegistered(response.Registered, true); } return new ActivationResult { Success = true }; })); }