Task More(ButtonRow button) { IsBusy = true; UIApp.Run(() => NoteApp.Current.DownloadNoteData(true)); return(Task.CompletedTask); }
public async Task <HeleusClientResponse> ChangeSubscription(long accountId, bool subscribe) { var response = await SetSubmitAccount(_submitAccount); if (response != null) { goto end; } var fanTransaction = new FeatureRequestDataTransaction(_submitAccount.AccountId, _submitAccount.ChainId, StatusServiceInfo.FanChainIndex); fanTransaction.SetFeatureRequest(new FanRequest(subscribe ? FanRequestMode.AddFanOf : FanRequestMode.RemoveFanOf, accountId)); fanTransaction.PrivacyType = DataTransactionPrivacyType.PublicData; response = await _client.SendDataTransaction(fanTransaction, true); if (response.TransactionResult == TransactionResultTypes.Ok) { UIApp.Run(StatusApp.Current.QueryStatusNodes); } end: await UIApp.PubSub.PublishAsync(new SubscriptionEvent(response, accountId, subscribe)); return(response); }
public MoreUpdatesPage(SubscriptionInfo[] updates, bool recent) : base("MoreUpdatesPage") { Subscribe <ProfileDataResultEvent>(UpdateProfileData); AddTitleRow("Title"); if (recent) { AddHeaderRow("StatusPage.RecentUpdates"); } else { AddHeaderRow("StatusPage.ViewedUpdates"); } foreach (var info in updates) { var row = new StatusProfileButtonRow(info.Subscriptions.Status.ServiceNode, info.AccountId, info.Profile, ProfileManager.Current.GetCachedProfileData(info.AccountId), ViewMessages, recent); row.UpdateMessagesCount(info); row.Tag = info; _updates.Add(row); AddRow(row); } AddFooterRow(); UIApp.Run(() => QueryProfileData(updates, updates.Length)); }
async Task VerifyUploaded(VerifyUploadEvent uploadEvent) { IsBusy = false; if (uploadEvent.Response.TransactionResult == TransactionResultTypes.Ok) { var transaction = uploadEvent.Response.Transaction as Transaction; var link = VerifyApp.Current.GetRequestCode(uploadEvent.ServiceNode, transaction.ChainIndex, ViewVerificationSchemeAction.ActionName, transaction.TransactionId); UIApp.CopyToClipboard(link); try { if (await ConfirmTextAsync(T("Success", link))) { await Navigation.PushAsync(new VerifyPage(new VerificationResult(uploadEvent.Response.Transaction as AttachementDataTransaction, _verify, uploadEvent.ServiceNode))); } } catch { } await ScrollToTop(); Clear(); } else { await ErrorTextAsync(uploadEvent.Response.GetErrorMessage()); } }
public async Task <AcceptInvitationEvent> AcceptFriendInvitation(long friendId) { var submitAccount = ServiceNode.GetSubmitAccounts <SubmitAccount>(MessageServiceInfo.SubmitAccountIndex).FirstOrDefault(); var result = await SetSubmitAccount(submitAccount); if (result != null) { goto end; } var transaction = NewFriendTransaction(AccountId, ChainId, FriendRequestMode.AcceptInvitation, friendId); result = await _client.SendDataTransaction(transaction, true); if (result.TransactionResult == TransactionResultTypes.Ok) { UIApp.Run(() => DownloadFriends(false)); } end: var @event = new AcceptInvitationEvent(friendId, this, result); await UIApp.PubSub.PublishAsync(@event); return(@event); }
async Task Verify(ButtonViewRow <VerifyFileView> button) { if (!(button.Tag is VerifyFileJson verify)) { return; } if (string.IsNullOrEmpty(verify.link)) { await Verify(verify); } else { var result = await DisplayVerifyFileAction(); if (result == VerifyFileAction.Verify) { await Verify(verify); } else if (result == VerifyFileAction.OpenLink) { if (!string.IsNullOrEmpty(verify.link)) { UIApp.OpenUrl(new Uri(verify.link)); } } } }
protected override async Task Submit(ButtonRow button) { try { if (!await ConfirmAsync("AuthorizeConfirm")) { return; } var password = _password?.Edit?.Text; var chainId = int.Parse(_chainIdText.Edit.Text); IsBusy = true; if (!_useCoreAccount) { // TODO Join Key Expire UIApp.Run(() => WalletApp.JoinChain(chainId, 0, _chainKey.PublicKey, password)); } else { UIApp.Run(() => WalletApp.JoinChainWithCoreAccount(chainId, password)); } } catch { } }
async Task StatusButton(ButtonRow button) { if (await ConfirmAsync("ConfirmStatus")) { IsBusy = true; UIApp.Run(() => TodoApp.Current.UpdateTodoItemStatus(_submitAccount.SubmitAccount, _status.Selection, _todoList, _task)); } }
protected override async Task ServiceNodesLoaded(ServiceNodesLoadedEvent arg) { await base.ServiceNodesLoaded(arg); await UIApp.Current.SetFinishedLoading(); UIApp.Run(QueryAllTodoLists); }
public StatusAccountPage(ProfileDataResult profileData, ServiceNode serviceNode, long accountId, StatusAccountProfileType profileType, long transactionId) : base("StatusAccountPage") { Subscribe <SubscriptionEvent>(Subscription); Subscribe <ProfileDataResultEvent>(ProfileData); StackLayout.Suspended = true; _transactionId = transactionId; _profileType = profileType; _serviceNode = serviceNode; _status = StatusApp.Current.GetStatus(serviceNode); _accountId = accountId; _accountIndex = Chain.Index.New().Add(_accountId).Build(); _messagesDownload = new AccountIndexTransactionDownload(accountId, StatusServiceInfo.MessageIndex, serviceNode.GetTransactionDownloadManager(StatusServiceInfo.StatusDataChainIndex)) { Count = 10 }; AddTitleRow("Title"); if (profileType == StatusAccountProfileType.Small || transactionId > 0) { var row = new StatusProfileButtonRow(serviceNode, _accountId, profileData?.ProfileInfo, profileData, async(button) => { await Navigation.PushAsync(new StatusAccountPage(profileData, serviceNode, accountId, StatusAccountProfileType.Big, transactionId)); }, false); AddRow(row); } if (profileType == StatusAccountProfileType.Big && transactionId <= 0) { if (_status != null) { AddHeaderRow("Subscription"); _subscribe = AddSwitchRow("Subscribe"); _subscribe.Switch.IsToggled = _status.IsSubscribed(_accountId); _subscribe.Switch.ToggledAsync = Subscribe_Toggled; _subscribe.SetDetailViewIcon(Icons.Check); _notification = AddSwitchRow("Notification"); _notification.Switch.IsToggled = UIApp.Current.IsPushChannelSubscribed(_accountIndex); _notification.Switch.ToggledAsync = Notification_Toggled; _notification.SetDetailViewIcon(Icons.Bell); AddFooterRow(); } if (profileData == null || profileType == StatusAccountProfileType.Big) { UIApp.Run(() => ProfileManager.Current.GetProfileData(_accountId, ProfileDownloadType.ForceDownload, true)); } } IsBusy = true; }
async Task Delete(ButtonRow button) { if (await ConfirmAsync("ConirmDelete")) { IsBusy = true; UIApp.Run(() => TodoApp.Current.UpdateTodoItemStatus(_submitAccount.SubmitAccount, TodoTaskStatusTypes.Deleted, _todoList, _task)); } }
public async Task Button(ButtonLayoutRow button) { var cancel = Tr.Get("Common.Cancel"); var download = Tr.Get("Common.MessageDownload"); var link = Tr.Get("Common.MessageLink"); var share = Tr.Get("Common.Share"); var copy = Tr.Get("Common.CopyShareLink"); var items = new List <string>(); if (!string.IsNullOrWhiteSpace(_link)) { items.Add(link); } if (!HasAllAttachements) { items.Add(download); } if (UIApp.CanShare) { items.Add(share); } items.Add(copy); if (items.Count == 0) { return; } var result = await Page.DisplayActionSheet(null, cancel, null, items.ToArray()); if (result == download) { await Transaction.TransactionManager.DownloadTransactionAttachement(Transaction); if (!HasAllAttachements) { await Page.ErrorAsync("MessageDownloadFailed"); } Update(); } else if (result == link) { UIApp.OpenUrl(new Uri(_link)); } else if (result == share) { UIApp.Share(StatusApp.Current.GetRequestCode(Transaction.Tag as ServiceNode, StatusServiceInfo.StatusDataChainIndex, ViewMessageSchemeAction.ActionName, Transaction.Transaction.AccountId, Transaction.Transaction.TransactionId)); } else if (result == copy) { UIApp.CopyToClipboard(StatusApp.Current.GetRequestCode(Transaction.Tag as ServiceNode, StatusServiceInfo.StatusDataChainIndex, ViewMessageSchemeAction.ActionName, Transaction.Transaction.AccountId, Transaction.Transaction.TransactionId)); UIApp.Toast(Tr.Get("Common.CopiedToClipboard")); } }
Task DownloadTransactions(TransactionDownloadEvent <Transaction> downloadEvent) { AddIndexBefore = false; AddIndex = GetRow("Notes"); var rows = GetHeaderSectionRows("Notes"); IsBusy = false; foreach (var item in downloadEvent.Items) { if (!item.Result.Ok) { UIApp.Toast(Tr.Get("TransactionDownloadResult.DownloadFailed", item.ServiceNode.GetName())); } } var transactions = downloadEvent.GetSortedTransactions(TransactionSortMode.TimestampDescening); if (transactions.Count > 0 && _listView != null) { RemoveView(GetRow("Info")); RemoveView(GetRow("Add")); if (!UIAppSettings.AppReady) { UIAppSettings.AppReady = true; UIApp.Current.SaveSettings(); } _listView.Update(transactions); UIApp.Run(UpdateNotes); if (downloadEvent.HasMore) { if (_more == null) { _more = AddButtonRow("MoreButton", More); } } else { RemoveView(_more); _more = null; } } else { if (ServiceNodeManager.Current.HadUnlockedServiceNode && UIAppSettings.AppReady) { Toast("NoNotes"); } } return(Task.CompletedTask); }
Task Copy(ButtonRow button) { if (button.Tag is string url) { UIApp.CopyToClipboard(url); Toast("VerifyCopied"); } return(Task.CompletedTask); }
Task Loaded(ServiceNodesLoadedEvent arg) { if (ServiceNodeManager.Current.HadUnlockedServiceNode) { IsBusy = true; UIApp.Run(() => NoteApp.Current.DownloadNoteData(false)); } return(Task.CompletedTask); }
async Task NewTodoList(ButtonRow arg) { if (!await ConfirmAsync("Confirm")) { return; } IsBusy = true; UIApp.Run(() => TodoApp.Current.RegisterNewList(_submitAccount.SubmitAccount)); }
Task NoteUploaded(NoteUploadedEvent uploadedEvent) { if (uploadedEvent.Response.TransactionResult == TransactionResultTypes.Ok) { IsBusy = true; UIApp.Run(() => NoteApp.Current.DownloadNoteData(false)); } return(Task.CompletedTask); }
void Download(bool queryOlder = false) { if (!ServiceNodeManager.Current.Ready) { return; } IsBusy = true; UIApp.Run(() => VerifyApp.Current.DownloadAccountIndexTransactions(VerifyServiceInfo.ChainIndex, VerifyServiceInfo.VerifyIndex, (download) => download.QueryOlder = queryOlder)); }
async Task Submit(ButtonRow button) { if (await ConfirmAsync("SubmitConfirm")) { IsBusy = true; var submitAccount = _submitAccount.SubmitAccount; submitAccount.SecretKeyManager.AddSecretKey(TodoList.BuildIndex(_invitation.ListId), _invitation.SecretKey); UIApp.Run(() => TodoApp.Current.AcceptListInvitation(submitAccount, _invitation.ListId, _invitation.SecretKey)); } }
protected override async Task Submit(ButtonRow button) { IsBusy = true; var password = _password?.Edit?.Text; if (!WalletApp.IsCoreAccountUnlocked) { if (!await WalletApp.UnlockCoreAccount(password)) { await ErrorAsync("PasswordWrong"); IsBusy = false; return; } } var chainId = int.Parse(_chainIdText.Edit.Text); var coreAccount = WalletApp.CurrentCoreAccount; var secretKey = await PassphraseSecretKeyInfo.NewPassphraseSecretKey(chainId, $"{Hex.ToString(coreAccount.RawData)}.{coreAccount.AccountId}"); var key = await Task.Run(() => Key.GenerateEd25519(secretKey.SecretHash)); var encryption = await Task.Run(() => Encryption.GenerateAes256(key.Data, _derivedPassword)); _keyView.Update(key); if (!await ConfirmAsync("AuthorizeConfirm")) { IsBusy = false; return; } (var response, var publicKey) = await WalletApp.JoinChain(chainId, 0, key.PublicKey, password); if (response.TransactionResult == TransactionResultTypes.Ok || response.TransactionResult == TransactionResultTypes.AlreadyJoined) { var derivedKey = new DerivedKey(coreAccount.AccountId, chainId, publicKey.KeyIndex, encryption); var hex = Hex.ToCrcString(derivedKey.ToByteArray()); _export.Edit.Text = hex; UIApp.CopyToClipboard(hex); await MessageAsync("SuccessDerived"); } else { await ErrorTextAsync(response.GetErrorMessage()); } IsBusy = false; }
Task AccountAuthorized(ServiceAccountAuthorizedEvent arg) { var status = StatusApp.Current.GetStatus(arg.ServiceNode); if (status != null) { UIApp.Run(() => ProfileManager.Current.GetProfileData(status.AccountId, ProfileDownloadType.ForceDownload, true)); } SetupPage(); return(Task.CompletedTask); }
async Task Select(ButtonRow button) { using (var file = await UIApp.OpenFilePicker2(null)) { if (file.Valid) { await HashFile(file); } } Status.ReValidate(); }
async Task Submit(ButtonRow button) { var profileName = _profileName.Edit.Text; var realName = _realName.Edit.Text; var bio = _bio.Edit.Text; var items = new List <ProfileItemJson>(); if (!string.IsNullOrEmpty(profileName)) { items.Add(new ProfileItemJson { k = ProfileItemJson.ProfileNameItem, v = profileName, p = ProfileItemJson.ProfileNameItem }); } if (!string.IsNullOrEmpty(realName)) { items.Add(new ProfileItemJson { k = ProfileItemJson.RealNameItem, v = realName, p = ProfileItemJson.RealNameItem }); } if (!string.IsNullOrEmpty(bio)) { items.Add(new ProfileItemJson { k = ProfileItemJson.BioItem, v = bio, p = ProfileItemJson.BioItem }); } var rows = GetHeaderSectionRows("EditSection"); foreach (var row in rows) { if (row.Tag is ProfileItemJson profileItem) { items.Add(profileItem); } } if (ProfileItemJson.ListsEqual(items, _profileData.ProfileJsonItems)) { items = null; } if (items == null && _imageData == null) { await MessageAsync("NoChanges"); return; } IsBusy = true; UIApp.Run(() => WalletApp.UploadProfileData(_imageData, items)); }
public static async Task <HeleusClientResponse> TransferCoins(long targetAcount, long amount, string reason, string accountPassword) { HeleusClientResponse result; if (!HasCoreAccount) { result = new HeleusClientResponse(HeleusClientResultTypes.NoCoreAccount); goto end; } if (_busy) { result = new HeleusClientResponse(HeleusClientResultTypes.Busy); goto end; } _busy = true; if (!IsCoreAccountUnlocked) { try { await CurrentCoreAccount.DecryptKeyAsync(accountPassword, true); } catch { result = new HeleusClientResponse(HeleusClientResultTypes.PasswordError); goto end; } await UnlockCoreAccount(accountPassword); } await Client.SetTargetChain(Protocol.CoreChainId); result = await Client.TransferCoins(targetAcount, amount, reason); if (result.TransactionResult == TransactionResultTypes.Ok) { UIApp.Run(() => UpdateCoreAccountBalance()); } end: await UIApp.PubSub.PublishAsync(new CoreAccountTransferEvent(result)); if (result.ResultType != HeleusClientResultTypes.Busy) { _busy = false; } return(result); }
public async Task <HeleusClientResponse> RegisterNewList(SubmitAccount submitAccount) { var serviceNode = submitAccount?.ServiceNode; var groupId = GroupAdministrationInfo.InvalidGroupId; var result = await SetSubmitAccount(submitAccount, false); if (result != null) { goto end; } if (_groupBusy) { result = new HeleusClientResponse(HeleusClientResultTypes.Busy); goto end; } _groupBusy = true; var groupReg = new FeatureRequestDataTransaction(submitAccount.AccountId, submitAccount.ChainId, TodoServiceInfo.GroupChainIndex); groupReg.SetFeatureRequest(new GroupRegistrationRequest(GroupFlags.AdminOnlyInvitation)); result = await serviceNode.Client.SendDataTransaction(groupReg, true); if (result.TransactionResult == TransactionResultTypes.Ok) { groupId = (result.Transaction as Transaction).GetFeature <GroupAdministration>(GroupAdministration.FeatureId).NewGroupId; var todo = GetTodo(serviceNode); var todoList = todo.AddGroupId(groupId); await todo.SaveAsync(); UIApp.Run(todoList.DownloadTransactions); UpdateSubmitAccounts(); } end: if (result.ResultType != HeleusClientResultTypes.Busy) { _groupBusy = false; } await UIApp.PubSub.PublishAsync(new TodoListRegistrationEvent(result, groupId)); return(result); }
Task Submit(ButtonRow button) { var files = GetVerifyFiles(); var description = _description.Edit.Text; var link = _link.Edit.Text; _verify = new VerifyJson { description = description, link = link, files = files }; IsBusy = true; UIApp.Run(() => VerifyApp.Current.UploadVerification(_submitAccount.SubmitAccount, _verify)); return(Task.CompletedTask); }
Task Register(ButtonRow button) { IsBusy = true; var seed = Hex.FromString(_keyRow.Edit.Text); var key = Key.GenerateEd25519(seed); var name = _name.Edit.Text; var password = _password1.Edit.Text; UIApp.Run(() => WalletApp.RegisterCoreAccount(name, password, key)); return(Task.CompletedTask); }
void Update() { SetupPage(); SetupRecentTasks(); if (UIApp.SetupTodoList(this, ViewTodoList)) { RemoveView(GetRow("Info")); if (!UIAppSettings.AppReady) { UIAppSettings.AppReady = true; UIApp.Current.SaveSettings(); } } }
public MessageNode(ServiceNode serviceNode) : base(serviceNode) { try { var data = serviceNode.CacheStorage.ReadFileBytes(GetType().Name); if (data != null) { using (var unpacker = new Unpacker(data)) { if (unpacker.UnpackBool()) { ProfileInfo = new ProfileInfo(unpacker); } unpacker.Unpack(_friends, (u) => new Friend(u, this)); unpacker.Unpack(_chats, (u) => new Chat(u, this)); if (unpacker.UnpackBool()) { _friendInfo = new FriendInfo(unpacker); } if (unpacker.UnpackBool()) { _lastAccountTransaction = new LastTransactionCountInfo(unpacker); } if (unpacker.UnpackBool()) { _lastReceivedTransaction = new LastTransactionCountInfo(unpacker); } InboxNameRecords = unpacker.UnpackList((u) => new InboxNameRecordInfo(u)); } } } catch (Exception ex) { Log.IgnoreException(ex); } if (InboxNameRecords == null) { InboxNameRecords = new List <InboxNameRecordInfo>(); } foreach (var inbox in _chats.Values) { GenerateSubmitAccount(inbox.Index); } UIApp.Run(GenerateDefaultExchangeKeys); }
async Task Subscribe_Toggled(ExtSwitch swtch) { var subscribe = swtch.IsToggled; if (await ConfirmAsync(subscribe ? "ConfirmSubscribe" : "ConfirmUnsubscribe")) { IsBusy = true; UIApp.Run(() => _status.ChangeSubscription(_accountId, subscribe)); } else { swtch.SetToogle(!subscribe); } }