Esempio n. 1
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);
        }
 private void CheckMegaAccounts()
 {
     try
     {
         var client           = new MegaApiClient();
         var possibleAccounts = this.Config.Accounts.Where(x => x.Name.ToLower().Equals("mega"));
         foreach (var account in possibleAccounts)
         {
             client.Login(account.UserName, account.Password);
             var info      = client.GetAccountInformation();
             var freeSpace = GetFreeSpace(info.UsedQuota, info.TotalQuota);
             this.AddAccountToTable(
                 "Mega.nz",
                 account.UserName,
                 GetMegabytes(freeSpace),
                 GetMegabytes(info.TotalQuota),
                 GetMegabytes(info.UsedQuota),
                 GetQuotaUsed(info.UsedQuota, info.TotalQuota));
             client.Logout();
         }
     }
     catch (Exception ex)
     {
         this.errorHandler.Show(ex);
         Log.Error("An exception occurred: {@Exception}", ex);
     }
 }
Esempio n. 3
0
        static void Mega()
        {
            MegaApiClient       client = MegaNz.GetClient("*****@*****.**");
            IAccountInformation info   = client.GetAccountInformation();

            Console.WriteLine(info.UsedQuota.ToString() + "/" + info.TotalQuota.ToString());
        }
Esempio n. 4
0
        public override void Process(BotData data)
        {
            base.Process(data);
            string        email         = BlockBase.ReplaceValues(this.Email, data);
            string        password      = BlockBase.ReplaceValues(this.Password, data);
            MegaApiClient megaApiClient = new MegaApiClient();

            try
            {
                megaApiClient.Login(email, password);
                bool flag = !megaApiClient.IsLoggedIn;
                if (flag)
                {
                    throw new Exception();
                }
                IEnumerator <INode> enumerator = megaApiClient.GetNodes().GetEnumerator();
                List <string>       list       = new List <string>();
                int num = 0;
                while (enumerator.MoveNext() && num < this.MaxFilesCaptured)
                {
                    bool flag2 = enumerator.Current.Name != null;
                    if (flag2)
                    {
                        list.Add(enumerator.Current.Name);
                        num++;
                    }
                }
                IAccountInformation accountInformation = megaApiClient.GetAccountInformation();
                BlockBase.InsertVariable(data, this.IsCapture, accountInformation.UsedQuota.ToString(), "USEDQUOTA", "", "", false, false);
                BlockBase.InsertVariable(data, this.IsCapture, accountInformation.TotalQuota.ToString(), "TOTALQUOTA", "", "", false, false);
                BlockBase.InsertVariable(data, this.IsCapture, list, this.VariableName, "", "", false, false);
                data.Status = RuriLib.BotStatus.SUCCESS;
            }
            catch (Exception ex)
            {
                data.Log(ex.Message);
                data.Status = RuriLib.BotStatus.FAIL;
            }
        }