Exemplo n.º 1
0
        public static CDNIndexHandler Initialize(CASCConfig config, AsyncAction worker)
        {
            var handler = new CDNIndexHandler(config, worker);

            if (worker != null)
            {
                worker.ThrowOnCancel();
                //worker.ReportProgress(0);
            }

            for (int i = 0; i < config.Archives.Count; i++)
            {
                string index = config.Archives[i];

                if (config.OnlineMode)
                {
                    handler.DownloadFile(index, i);
                }
                else
                {
                    handler.OpenFile(index, i);
                }

                if (worker != null)
                {
                    worker.ThrowOnCancel();
                    //worker.ReportProgress((int)((float)i / (float)config.Archives.Count * 100));
                }
            }

            Logger.WriteLine("CDNIndexHandler: loaded {0} indexes", handler.Count);

            return(handler);
        }
Exemplo n.º 2
0
        public static CASCConfig LoadOnlineStorageConfig(string product)
        {
            var config = new CASCConfig {
                OnlineMode = true
            };

            using (var cdnsStream = CDNIndexHandler.OpenFileDirect(String.Format("http://us.patch.battle.net/{0}/cdns", product)))
            {
                config._CDNData = KeyValueConfig.ReadVerBarConfig(cdnsStream);
            }

            using (var versionsStream = CDNIndexHandler.OpenFileDirect(String.Format("http://us.patch.battle.net/{0}/versions", product)))
            {
                config._VersionsData = KeyValueConfig.ReadVerBarConfig(versionsStream);
            }

            int index = 0;
            int build = 0;

            for (int i = 0; i < config._VersionsData["BuildId"].Count; ++i)
            {
                int build2 = Convert.ToInt32(config._VersionsData["BuildId"][i]);
                if (build2 > build)
                {
                    build = build2;
                    index = i;
                }
            }

            config.Build = build;

            string buildKey = config._VersionsData["BuildConfig"][index];

            using (Stream stream = CDNIndexHandler.OpenConfigFileDirect(config.CDNUrl, buildKey))
            {
                config._BuildConfig = KeyValueConfig.ReadKeyValueConfig(stream);
            }

            string cdnKey = config._VersionsData["CDNConfig"][index];

            using (Stream stream = CDNIndexHandler.OpenConfigFileDirect(config.CDNUrl, cdnKey))
            {
                config._CDNConfig = KeyValueConfig.ReadKeyValueConfig(stream);
            }
            return(config);
        }
Exemplo n.º 3
0
        private CASCHandler(CASCConfig config, AsyncAction worker)
        {
            this.config = config;

            CDNIndex = CDNIndexHandler.Initialize(config, worker);

            if (!config.OnlineMode)
            {
                LocalIndex = LocalIndexHandler.Initialize(config, worker);
            }

            using (var fs = OpenEncodingFile())
                EncodingHandler = new EncodingHandler(fs, worker);

            Logger.WriteLine("CASCHandler: loaded {0} encoding data", EncodingHandler.Count);

            using (var fs = OpenRootFile())
                RootHandler = new WowRootHandler(fs, worker);

            Logger.WriteLine("CASCHandler: loaded {0} root data", RootHandler.Count);
        }