Ejemplo n.º 1
0
        public static async Task DownloadApp(Steam3Session steam3, string installPath, uint appId, bool manifestOnly = false, Action downloadCompleteAction = null, params string[] fileList)
        {
            //Config.CellID = 0;
            Config.UsingFileList = fileList != null && fileList.Length > 0;
            if (Config.UsingFileList)
            {
                Config.FilesToDownload = new List <string>(fileList);
            }

            Config.InstallDirectory     = installPath;
            Config.DownloadManifestOnly = manifestOnly;
            Config.MaxDownloads         = 4;
            Config.MaxServers           = 20;
            string branch = DEFAULT_BRANCH;

            string os = "windows";

            cdnPool = new CDNClientPool(steam3);
            try
            {
                await DownloadAppAsync(steam3, appId, INVALID_DEPOT_ID, INVALID_MANIFEST_ID, branch, os, false, downloadCompleteAction);
            }
            catch (Exception e) { DebugLog.WriteLine("ErrorContentDownloader", e.ToString()); }
            Shutdown();
        }
Ejemplo n.º 2
0
        public static bool InitializeSteam3(string username, string password)
        {
            string loginKey = null;

            if (username != null && Config.RememberPassword)
            {
                _ = ConfigStore.TheConfig.LoginKeys.TryGetValue(username, out loginKey);
            }

            steam3 = new Steam3Session(
                new SteamUser.LogOnDetails()
            {
                Username = username,
                Password = loginKey == null ? password : null,
                ShouldRememberPassword = Config.RememberPassword,
                LoginKey = loginKey,
            }
                );

            steam3Credentials = steam3.WaitForCredentials();

            if (!steam3Credentials.IsValid)
            {
                Console.WriteLine("Unable to get steam3 credentials.");
                return(false);
            }

            cdnPool = new CDNClientPool(steam3);
            return(true);
        }
        public static bool InitializeSteam3(string username = null, string password = null)
        {
            string loginKey = null;

            if (username != null && Config.RememberPassword)
            {
                _ = AccountSettingsStore.Instance.LoginKeys.TryGetValue(username, out loginKey);
            }

            Steam3 = new Steam3Session(
                new SteamUser.LogOnDetails()
            {
                Username = username,
                Password = loginKey == null ? password : null,
                ShouldRememberPassword = Config.RememberPassword,
                LoginKey = loginKey,
                LoginID  = Config.LoginID ?? 0x534B32,    // "SK2"
            }
                );

            Steam3Credentials = Steam3.WaitForCredentials();

            if (!Steam3Credentials.IsValid)
            {
                Console.WriteLine("Unable to get Steam3 credentials.");
                return(false);
            }

            cdnPool = new CDNClientPool(Steam3);
            return(true);
        }
Ejemplo n.º 4
0
 public static void Shutdown()
 {
     if (cdnPool != null)
     {
         cdnPool.Shutdown();
         cdnPool = null;
     }
 }
Ejemplo n.º 5
0
        public static void ShutdownSteam3()
        {
            if (cdnPool != null)
            {
                cdnPool.Shutdown();
                cdnPool = null;
            }

            if (steam3 == null)
            {
                return;
            }

            steam3.TryWaitForLoginKey();
            steam3.Disconnect();
        }
Ejemplo n.º 6
0
        public static bool InitializeSteam3(string username, string password)
        {
            steam3 = new Steam3Session(
                new SteamUser.LogOnDetails()
                {
                    Username = username,
                    Password = password,
                }
            );

            steam3Credentials = steam3.WaitForCredentials();

            if (!steam3Credentials.IsValid)
            {
                Console.WriteLine("Unable to get steam3 credentials.");
                return false;
            }

            cdnPool = new CDNClientPool(steam3);
            return true;
        }
Ejemplo n.º 7
0
        public static async Task DownloadAppAsync(uint appId, uint depotId, ulong manifestId, string branch, string os, string arch, string language, bool lv, bool isUgc)
        {
            cdnPool = new CDNClientPool(steam3, appId);

            // Load our configuration data containing the depots currently installed
            string configPath = ContentDownloader.Config.InstallDirectory;

            if (string.IsNullOrWhiteSpace(configPath))
            {
                configPath = DEFAULT_DOWNLOAD_DIR;
            }

            Directory.CreateDirectory(Path.Combine(configPath, CONFIG_DIR));
            DepotConfigStore.LoadFromFile(Path.Combine(configPath, CONFIG_DIR, "depot.config"));

            if (steam3 != null)
            {
                steam3.RequestAppInfo(appId);
            }

            if (!AccountHasAccess(appId))
            {
                if (steam3.RequestFreeAppLicense(appId))
                {
                    Console.WriteLine("Obtained FreeOnDemand license for app {0}", appId);

                    // Fetch app info again in case we didn't get it fully without a license.
                    steam3.RequestAppInfo(appId, true);
                }
                else
                {
                    string contentName = GetAppOrDepotName(INVALID_DEPOT_ID, appId);
                    throw new ContentDownloaderException(String.Format("App {0} ({1}) is not available from this account.", appId, contentName));
                }
            }

            var      depotIDs = new List <uint>();
            KeyValue depots   = GetSteam3AppSection(appId, EAppInfoSection.Depots);

            if (isUgc)
            {
                var workshopDepot = depots["workshopdepot"].AsUnsignedInteger();
                if (workshopDepot != 0)
                {
                    depotId = workshopDepot;
                }

                depotIDs.Add(depotId);
            }
            else
            {
                Console.WriteLine("Using app branch: '{0}'.", branch);

                if (depots != null)
                {
                    foreach (var depotSection in depots.Children)
                    {
                        uint id = INVALID_DEPOT_ID;
                        if (depotSection.Children.Count == 0)
                        {
                            continue;
                        }

                        if (!uint.TryParse(depotSection.Name, out id))
                        {
                            continue;
                        }

                        if (depotId != INVALID_DEPOT_ID && id != depotId)
                        {
                            continue;
                        }

                        if (depotId == INVALID_DEPOT_ID)
                        {
                            var depotConfig = depotSection["config"];
                            if (depotConfig != KeyValue.Invalid)
                            {
                                if (!Config.DownloadAllPlatforms &&
                                    depotConfig["oslist"] != KeyValue.Invalid &&
                                    !string.IsNullOrWhiteSpace(depotConfig["oslist"].Value))
                                {
                                    var oslist = depotConfig["oslist"].Value.Split(',');
                                    if (Array.IndexOf(oslist, os ?? Util.GetSteamOS()) == -1)
                                    {
                                        continue;
                                    }
                                }

                                if (depotConfig["osarch"] != KeyValue.Invalid &&
                                    !string.IsNullOrWhiteSpace(depotConfig["osarch"].Value))
                                {
                                    var depotArch = depotConfig["osarch"].Value;
                                    if (depotArch != (arch ?? Util.GetSteamArch()))
                                    {
                                        continue;
                                    }
                                }

                                if (!Config.DownloadAllLanguages &&
                                    depotConfig["language"] != KeyValue.Invalid &&
                                    !string.IsNullOrWhiteSpace(depotConfig["language"].Value))
                                {
                                    var depotLang = depotConfig["language"].Value;
                                    if (depotLang != (language ?? "english"))
                                    {
                                        continue;
                                    }
                                }

                                if (!lv &&
                                    depotConfig["lowviolence"] != KeyValue.Invalid &&
                                    depotConfig["lowviolence"].AsBoolean())
                                {
                                    continue;
                                }
                            }
                        }

                        depotIDs.Add(id);
                    }
                }
                if (depotIDs == null || (depotIDs.Count == 0 && depotId == INVALID_DEPOT_ID))
                {
                    throw new ContentDownloaderException(String.Format("Couldn't find any depots to download for app {0}", appId));
                }
                else if (depotIDs.Count == 0)
                {
                    throw new ContentDownloaderException(String.Format("Depot {0} not listed for app {1}", depotId, appId));
                }
            }

            var infos = new List <DepotDownloadInfo>();

            foreach (var depot in depotIDs)
            {
                var info = GetDepotInfo(depot, appId, manifestId, branch);
                if (info != null)
                {
                    infos.Add(info);
                }
            }

            try
            {
                await DownloadSteam3Async(appId, infos).ConfigureAwait(false);
            }
            catch (OperationCanceledException)
            {
                Console.WriteLine("App {0} was not completely downloaded.", appId);
                throw;
            }
        }