Пример #1
0
        static void Mega()
        {
            MegaApiClient       client = MegaNz.GetClient("*****@*****.**");
            IAccountInformation info   = client.GetAccountInformation();

            Console.WriteLine(info.UsedQuota.ToString() + "/" + info.TotalQuota.ToString());
        }
Пример #2
0
        public Balance(IAccountInformation info)
        {
            InitializeComponent();
            textIdentity.Text    = info.Identity;
            textAccount.Text     = (info.Account.Length == 11 ? info.Account : info.Account?.Insert(4, "-")).Insert(9, "-");
            textName.Text        = info.Name;
            textServer.Text      = info.Server.ToString();
            textServer.ForeColor = info.Server ? Color.Navy : Color.Maroon;
            data.ColumnCount     = 0xA;
            data.BackgroundColor = Color.FromArgb(0x79, 0x85, 0x82);
            data.Enabled         = true;
            data.MouseMove      += OnResponseToMouse;
            data.MouseLeave     += OnResponseToMouse;
            dIndex            = new Dictionary <string, int>();
            ToolTipDictionary = new Dictionary <string, string>();

            foreach (Control control in panel.Controls)
            {
                if (control is TextBox box)
                {
                    box.MouseLeave += OnResponseToMouse;
                    box.MouseUp    += OnResponseToMouse;
                }
            }
            for (int i = 0; i < columns.Length; i++)
            {
                data.Columns[i].Name = columns[i];
            }
        }
        /// <inheritdoc />
        public async Task <IUnixFileSystem> Create(IAccountInformation accountInformation)
        {
            var(driveService, rootItem) = await _serviceProvider.GetUserRootAsync(
                accountInformation, CancellationToken.None);

            return(new GoogleDriveFileSystem(driveService, rootItem, _temporaryDataFactory, _options.UseBackgroundUpload));
        }
Пример #4
0
        private static Thread Mount(this Settings settings)
        {
            Thread mounter = new Thread(() =>
            {
                IAccountInformation acc = mega.GetAccountInformation();

                Console.WriteLine($@"Mounting the filesystem to \\{mountpoint = settings.Drive}:\ with the following data:

    Base driver version: {Dokan.DriverVersion:x8} ({Dokan.DriverVersion})
    Dokan API version:   {Dokan.Version:x8} ({Dokan.Version})
    Used bytes:          {acc.UsedQuota}
    Total bytes:         {acc.TotalQuota}
");

                try
                {
                    filesys = new FileSystem(new DirectoryInfo($"./tmp/{settings.Email}/"), mega, settings.Email, settings.CacheSz);
                    regkey  = Registry.LocalMachine.CreateSubKey($"{REG_BASE}\\{mountpoint}", true);

                    string iconpath = $"{mountpoint}:\\{FileSystem.CFILE_ICON},0";

                    using (RegistryKey defico = regkey.CreateSubKey("DefaultIcon", true))
                    {
                        defico.SetValue("", iconpath);
                        defico.Flush();
                    }

                    using (RegistryKey deflbl = regkey.CreateSubKey("DefaultLabel", true))
                    {
                        deflbl.SetValue("", FileSystem.LABEL);
                        deflbl.Flush();
                    }

                    regkey.Flush();

                    Win32.SHUpdateImage(iconpath, 0, 0x0202, 0);

                    filesys.Mount($"{settings.Drive}:\\", DokanOptions.StderrOutput);
                }
                catch (Exception ex)
                {
                    StringBuilder sb = new StringBuilder();

                    sb.AppendLine("An error occured during the mounting of the file system:");

                    while (ex != null)
                    {
                        sb.Insert(0, $"{ex.Message}:\n{ex.StackTrace}");

                        ex = ex.InnerException;
                    }

                    Console.WriteLine(sb);

                    Unmount(settings);
                }
            });

            return(mounter);
        }
Пример #5
0
        public Task <IUnixFileSystem> Create(IAccountInformation accountInformation)
        {
            // TODO: Update the bucketName variable with the actual name of the bucket
            var bucketName = Environment.GetEnvironmentVariable("BUCKET_NAME") ?? "[BUCKET-NAME]";

            return(Task.FromResult <IUnixFileSystem>(new GcsFileSystem(bucketName)));
        }
Пример #6
0
        public IAccountInformation SetPrivacy(IAccountInformation privacy)
        {
            var ai = new AccountInformation
            {
                Identity = textIdentity.Text,
                Account  = privacy.AccountNumber,
                Server   = checkDemo.Checked
            };

            if (API is Connect api)
            {
                var name = api.SetAccountName(privacy.AccountNumber, privacy.AccountPassword);
                Invoke(new Action(async() =>
                {
                    ai.Name = name.Item2;
                    ai.Nick = name.Item1;

                    if (checkPrivacy.Checked && int.MaxValue > await new Secrecy().Encrypt(this.privacy, textIdentity.Text, textPassword.Text, textCertificate.Text, privacy.AccountNumber, privacy.AccountPassword, checkDemo.Checked))
                    {
                        Console.WriteLine(ai.Nick);
                    }
                }));
            }
            return(ai);
        }
        /// <inheritdoc />
        public Task <IUnixFileSystem> Create(IAccountInformation accountInformation)
        {
            var directories = _accountDirectoryQuery.GetDirectories(accountInformation);

            return(Task.FromResult <IUnixFileSystem>(
                       new S3FileSystem(_options, S3Path.Combine(_options.RootPath, directories.RootPath))));
        }
        public MegaConfigureViewModel()
        {
            Task.Run(async() =>
            {
                try
                {
                    IsWorking = true;

                    if (AssistantOptions.BackupOptions.Provider is MegaBackupProvider provider &&
                        provider.Authentication != null)
                    {
                        OverwriteExisting = provider.OverwriteExisting;

                        _client.Login(new MegaApiClient.LogonSessionToken(provider.Authentication.SessionId,
                                                                          provider.Authentication.MasterKey));

                        IAccountInformation info = await _client.GetAccountInformationAsync();

                        IsLoggedIn = true;
                    }
                }
                catch (Exception)
                {
                    IsLoggedIn = false;
                }
                finally
                {
                    IsWorking = false;
                }
            });
        }
        /// <inheritdoc />
        public Task AuthorizedAsync(IAccountInformation accountInformation, CancellationToken cancellationToken)
        {
            if (!accountInformation.FtpUser.IsUnixUser())
            {
                return(Task.CompletedTask);
            }

            var pamSessionFeature = _connectionAccessor.FtpConnection.Features.Get <PamSessionFeature>();

            if (pamSessionFeature == null)
            {
                return(Task.CompletedTask);
            }

            try
            {
                pamSessionFeature.OpenSession();
            }
            catch
            {
                // Ignore errors...
            }

            return(Task.CompletedTask);
        }
        public async Task <IUnixFileSystem> Create(IAccountInformation accountInformation)
        {
            _logger.LogTrace($"Generating new {nameof(AzureStorageFileSystem)} using storage account name and key...");
            var user = accountInformation.User as AzureStorageFtpUser;
            var fs   = new AzureStorageFileSystem(user.AccountName, user.AccountKey, _fslogger);

            return(fs);
        }
Пример #11
0
 public LoginViewModel(INavigation navigation)
 {
     this._navigation          = navigation;
     this.LoginCommand         = new Command(async() => await Login());
     this._AppLoginClass       = new AppLoginClass();
     this._IAllDataServices    = new AllDataServices();
     this._IAccountInformation = new AccountInformation();
 }
Пример #12
0
        /// <inheritdoc />
        public Task <(DriveService service, File rootEntry)> GetUserRootAsync(IAccountInformation accountInformation, CancellationToken cancellationToken)
        {
            var rootEntry = new File()
            {
                Id = "root",
            };

            return(Task.FromResult((_driveService, rootEntry)));
        }
Пример #13
0
        public void GetAccountInformation_AuthenticatedUserV2_Succeeds(string email, string password)
        {
            this.context.Client.Login(email, password);

            IAccountInformation accountInformation = this.context.Client.GetAccountInformation();

            Assert.NotNull(accountInformation);
            Assert.Equal(16106127360, accountInformation.TotalQuota);
            Assert.Equal(0, accountInformation.UsedQuota);
        }
Пример #14
0
        public void GetAccountInformation_AnonymousUser_Succeeds()
        {
            this.context.Client.LoginAnonymous();

            IAccountInformation accountInformation = this.context.Client.GetAccountInformation();

            Assert.NotNull(accountInformation);
            Assert.Equal(16106127360, accountInformation.TotalQuota);
            Assert.Equal(0, accountInformation.UsedQuota);
        }
Пример #15
0
        public void GetAccountInformation_AnonymousUser_Succeeds()
        {
            this.Client.LoginAnonymous();

            IAccountInformation accountInformation = this.Client.GetAccountInformation();

            Assert.That(accountInformation, Is.Not.Null
                        .And.Property <IAccountInformation>(x => x.TotalQuota).EqualTo(53687091200)
                        .And.Property <IAccountInformation>(x => x.UsedQuota).EqualTo(0));
        }
Пример #16
0
        public void GetAccountInformation_AuthenticatedUser_Succeeds(string email, string password)
        {
            this.Client.Login(email, password);

            IAccountInformation accountInformation = this.Client.GetAccountInformation();

            Assert.That(accountInformation, Is.Not.Null
                        .And.Property <IAccountInformation>(x => x.TotalQuota).EqualTo(53687091200)
                        .And.Property <IAccountInformation>(x => x.UsedQuota).EqualTo(523265));
        }
Пример #17
0
        /// <inheritdoc />
        public IAccountDirectories GetDirectories(IAccountInformation accountInformation)
        {
            if (accountInformation.User is IAnonymousFtpUser anonymousFtpUser)
            {
                return(GetAnonymousDirectories(anonymousFtpUser));
            }

            var rootPath = Path.Combine(_userRoot, accountInformation.User.Name);

            return(new GenericAccountDirectories(rootPath));
        }
Пример #18
0
        /// <inheritdoc/>
        public Task <IUnixFileSystem> Create(IAccountInformation accountInformation)
        {
            var path = _rootPath;

            if (_useUserIdAsSubFolder)
            {
                path = Path.Combine(path, accountInformation.User.Name);
            }

            return(Task.FromResult <IUnixFileSystem>(new DotNetFileSystem(path, _allowNonEmptyDirectoryDelete, _streamBufferSize)));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DotNetFileSystem"/> class.
        /// </summary>
        /// <param name="rootPath">The path to use as root.</param>
        /// <param name="allowNonEmptyDirectoryDelete">Defines whether the deletion of non-empty directories is allowed.</param>
        /// <param name="streamBufferSize">Buffer size to be used in async IO methods.</param>
        /// <param name="flushStream">Flush the stream after every write operation.</param>
        public ServerManagerFileSystem(IAccountInformation account, IServiceProvider serviceProvider, string rootPath, bool allowNonEmptyDirectoryDelete, int streamBufferSize, bool flushStream)
        {
            _account         = account;
            _serviceProvider = serviceProvider;
            //_userManager = _serviceProvider.GetService<UserManager<MonitorUser>>();

            FileSystemEntryComparer = StringComparer.OrdinalIgnoreCase;
            Root = new ServerManagerDirectoryEntry(Directory.CreateDirectory(rootPath), allowNonEmptyDirectoryDelete);
            SupportsNonEmptyDirectoryDelete = allowNonEmptyDirectoryDelete;
            _streamBufferSize = streamBufferSize;
            _flushStream      = flushStream;
        }
        /// <inheritdoc />
        public async Task AuthorizedAsync(IAccountInformation accountInformation, CancellationToken cancellationToken)
        {
            var connection = _ftpConnectionAccessor.FtpConnection;

            var fsFeature = connection.Features.Get <IFileSystemFeature>();

            fsFeature.FileSystem = await _fileSystemFactory
                                   .Create(accountInformation)
                                   .ConfigureAwait(false);

            fsFeature.Path = new Stack <IUnixDirectoryEntry>();
        }
Пример #21
0
 public void SendOrder(IAccountInformation info, Tuple <int, string, int, int, string> order) => (API as Connect)?.SendOrder(new SendOrder
 {
     RQName     = axAPI.GetMasterCodeName(order.Item2),
     ScreenNo   = (API as Connect)?.LookupScreenNo,
     AccNo      = info.Account,
     OrderType  = order.Item1,
     Code       = order.Item2,
     Qty        = order.Item3,
     Price      = order.Item4,
     HogaGb     = ((int)HogaGb.지정가).ToString("D2"),
     OrgOrderNo = order.Item5
 });
Пример #22
0
        /// <inheritdoc />
        public Task <IUnixFileSystem> Create(IAccountInformation accountInformation)
        {
            var fsComparer = _options.FileSystemComparer;
            var user       = accountInformation.User;
            InMemoryFileSystem fileSystem;
            string             userId;

            if (user is IAnonymousFtpUser anonymousFtpUser)
            {
                userId = string.IsNullOrEmpty(anonymousFtpUser.Email)
                    ? anonymousFtpUser.Name
                    : anonymousFtpUser.Email;

                if (_options.KeepAnonymousFileSystem)
                {
                    lock (_anonymousFileSystemLock)
                    {
                        if (!_anonymousFileSystems.TryGetValue(userId, out fileSystem))
                        {
                            fileSystem = new InMemoryFileSystem(fsComparer);
                            _anonymousFileSystems.Add(userId, fileSystem);
                        }
                    }
                }
                else
                {
                    fileSystem = new InMemoryFileSystem(fsComparer);
                }
            }
            else
            {
                userId = user.Name;

                if (_options.KeepAuthenticatedUserFileSystem)
                {
                    lock (_authUserFileSystemLock)
                    {
                        if (!_authUserFileSystems.TryGetValue(userId, out fileSystem))
                        {
                            fileSystem = new InMemoryFileSystem(fsComparer);
                            _authUserFileSystems.Add(userId, fileSystem);
                        }
                    }
                }
                else
                {
                    fileSystem = new InMemoryFileSystem(fsComparer);
                }
            }

            return(Task.FromResult <IUnixFileSystem>(fileSystem));
        }
        /// <inheritdoc />
        public Task AuthorizedAsync(IAccountInformation accountInformation, CancellationToken cancellationToken)
        {
            var connection = _ftpConnectionAccessor.FtpConnection;

            connection.Features.Get <IAuthorizationInformationFeature>().User = accountInformation.User;

#pragma warning disable 618
            connection.Data.IsAnonymous = accountInformation.User is IAnonymousFtpUser;
            connection.Data.IsLoggedIn  = true;
#pragma warning restore 618

            return(Task.CompletedTask);
        }
Пример #24
0
 public void SendOrder(IAccountInformation info, Tuple <string, int, string, string, int, string, string> order) => (API as Connect)?.SendOrder(new SendOrderFO
 {
     RQName   = order.Item1,
     ScreenNo = (API as Connect)?.LookupScreenNo,
     AccNo    = info.Account,
     Code     = order.Item1,
     OrdKind  = order.Item2,
     SlbyTp   = order.Item3,
     OrdTp    = order.Item4,
     Qty      = order.Item5,
     Price    = order.Item6,
     OrgOrdNo = order.Item7
 });
        public async Task <IUnixFileSystem> Create(IAccountInformation accountInformation)
        {
            var path        = _rootPath;
            var directories = _accountDirectoryQuery.GetDirectories(accountInformation);

            if (!string.IsNullOrEmpty(directories.RootPath))
            {
                path = Path.Combine(path, directories.RootPath);
            }

            _logger?.LogDebug("The root directory for {userName} is {rootPath}", accountInformation.FtpUser.Identity.Name, path);

            return(new ServerManagerFileSystem(accountInformation, _serviceProvider, path, _allowNonEmptyDirectoryDelete, _streamBufferSize, _flushAfterWrite));
        }
        /// <inheritdoc/>
        public Task <IUnixFileSystem> Create(IAccountInformation accountInformation)
        {
            var path        = _rootPath;
            var directories = _accountDirectoryQuery.GetDirectories(accountInformation);

            if (!string.IsNullOrEmpty(directories.RootPath))
            {
                path = Path.Combine(path, directories.RootPath);
            }

            _logger?.LogDebug("The root directory for {userName} is {rootPath}", accountInformation.FtpUser.Identity.Name, path);

            return(Task.FromResult <IUnixFileSystem>(new DotNetFileSystem(path, _allowNonEmptyDirectoryDelete, _streamBufferSize)));
        }
Пример #27
0
 public void SendOrder(IAccountInformation info, Tuple <int, string, int, int, string> order)
 {
     if (Connect.HoldingStock.TryGetValue(order.Item2, out Holding holding))
     {
         if (order.Item1 == 1 && Connect.Cash < order.Item4 * 2 && holding.OrderNumber.Count(o => o.Value < order.Item4) > 0)
         {
             (API as Connect)?.SendOrder(new SendOrder
             {
                 RQName     = axAPI.GetMasterCodeName(order.Item2),
                 ScreenNo   = (API as Connect)?.LookupScreenNo,
                 AccNo      = info.Account,
                 OrderType  = 3,
                 Code       = order.Item2,
                 Qty        = order.Item3,
                 Price      = order.Item4,
                 HogaGb     = ((int)HogaGb.지정가).ToString("D2"),
                 OrgOrderNo = holding.OrderNumber.OrderBy(o => o.Value).First().Key
             });
         }
         else if (order.Item1 == 2 && holding.Quantity > 0 && holding.Quantity - holding.OrderNumber.Count(o => o.Value > order.Item4) < 1)
         {
             (API as Connect)?.SendOrder(new SendOrder
             {
                 RQName     = axAPI.GetMasterCodeName(order.Item2),
                 ScreenNo   = (API as Connect)?.LookupScreenNo,
                 AccNo      = info.Account,
                 OrderType  = 4,
                 Code       = order.Item2,
                 Qty        = order.Item3,
                 Price      = order.Item4,
                 HogaGb     = ((int)HogaGb.지정가).ToString("D2"),
                 OrgOrderNo = holding.OrderNumber.OrderByDescending(o => o.Value).First().Key
             });
         }
     }
     (API as Connect)?.SendOrder(new SendOrder
     {
         RQName     = axAPI.GetMasterCodeName(order.Item2),
         ScreenNo   = (API as Connect)?.LookupScreenNo,
         AccNo      = info.Account,
         OrderType  = order.Item1,
         Code       = order.Item2,
         Qty        = order.Item3,
         Price      = order.Item4,
         HogaGb     = ((int)HogaGb.지정가).ToString("D2"),
         OrgOrderNo = order.Item5
     });
     Connect.Cash += (order.Item1 == 1 ? -order.Item4 : order.Item4) * order.Item3;
 }
Пример #28
0
        public void GetAccountInformation_AuthenticatedUser_Succeeds(string email, string password)
        {
            this.context.Client.Login(email, password);

            var authenticatedTestContext = new AuthenticatedTestContext();
            var protectedNodes           = authenticatedTestContext.ProtectedNodes;

            this.SanitizeStorage(protectedNodes);

            IAccountInformation accountInformation = this.context.Client.GetAccountInformation();

            Assert.NotNull(accountInformation);
            Assert.Equal(53687091200, accountInformation.TotalQuota);
            Assert.Equal(1569795, accountInformation.UsedQuota);
        }
Пример #29
0
        public void GetAccountInformation_AuthenticatedUserV1_Succeeds(string email, string password)
        {
            this.context.Client.Login(email, password);

            var authenticatedTestContext = new AuthenticatedTestContext();
            var protectedNodes           = authenticatedTestContext.ProtectedNodes;

            this.SanitizeStorage(protectedNodes);

            IAccountInformation accountInformation = this.context.Client.GetAccountInformation();

            Assert.NotNull(accountInformation);
            Assert.Equal(53687091200, accountInformation.TotalQuota);
            Assert.Equal(1046530 + AuthenticatedTestContext.FileSize + AuthenticatedTestContext.SubFolderFileSize, accountInformation.UsedQuota); // 1046530 is from incoming shares
        }
        /// <inheritdoc />
        public IAccountDirectories GetDirectories(IAccountInformation accountInformation)
        {
            if (accountInformation.User is IAnonymousFtpUser anonymousFtpUser)
            {
                return(GetAnonymousDirectories(anonymousFtpUser));
            }

            var userHome = GetUserHome(accountInformation.User);

            if (_userHomeIsRoot)
            {
                return(new GenericAccountDirectories(userHome));
            }

            return(new GenericAccountDirectories(null, userHome));
        }