Exemplo n.º 1
0
            protected override JSONValue HandlePost(Request request, JSONValue payload)
            {
                string str = payload.Get("action").AsString();
                string key = str;

                if (key != null)
                {
                    int num;
                    if (< > f__switch$map9 == null)
                    {
                        Dictionary <string, int> dictionary = new Dictionary <string, int>(2);
                        dictionary.Add("move", 0);
                        dictionary.Add("create", 1);
Exemplo n.º 2
0
        public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
        {
            string[]  destination = AssetStoreContext.PackageStorePath(publisher_name, category_name, package_name, package_id, url);
            JSONValue jSONValue   = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key));

            if (jSONValue.Get("in_progress").AsBool(true))
            {
                Debug.Log("Will not download " + package_name + ". Download is already in progress.");
                return;
            }
            string    a        = jSONValue.Get("download.url").AsString(true);
            string    a2       = jSONValue.Get("download.key").AsString(true);
            bool      resumeOK = a == url && a2 == key;
            JSONValue value    = default(JSONValue);

            value["url"] = url;
            value["key"] = key;
            JSONValue jSONValue2 = default(JSONValue);

            jSONValue2["download"] = value;
            AssetStoreUtils.Download(package_id, url, destination, key, jSONValue2.ToString(), resumeOK, doneCallback);
        }
        public static void Download(string package_id, string url, string key, string package_name,
                                    string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
        {
            string[] dest = PackageStorePath(publisher_name, category_name,
                                             package_name, package_id, url);

            JSONValue existing = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, dest, key));

            // If the package is actively being downloaded right now just return
            if (existing.Get("in_progress").AsBool(true))
            {
                Debug.Log("Will not download " + package_name + ". Download is already in progress.");
                return;
            }

            // The package is not being downloaded.
            // If the package has previously been partially downloaded then
            // resume that download.
            string existingUrl = existing.Get("download.url").AsString(true);
            string existingKey = existing.Get("download.key").AsString(true);
            bool   resumeOK    = (existingUrl == url && existingKey == key);

            JSONValue download = new JSONValue();

            download["url"] = url;
            download["key"] = key;
            JSONValue parameters = new JSONValue();

            parameters["download"] = download;

            AssetStoreUtils.Download(package_id, url, dest, key, parameters.ToString(), resumeOK, doneCallback);
            EditorAnalytics.SendAssetDownloadEvent(new DownloadAssetInfo()
            {
                package_id     = package_id,
                package_name   = package_name,
                publisher_name = publisher_name,
                category_name  = category_name
            });
        }
Exemplo n.º 4
0
    private static string OnAssetStorePublisher(JSONValue jval, AssetStorePublisher account, PackageDataSource packageDataSource)
    {
        string str;
        string str1 = "unknown field";

        try
        {
            str1 = "publisher";
            Dictionary <string, JSONValue> strs = jval["publisher"].AsDict(false);
            account.mStatus = AssetStorePublisher.Status.New;
            if (strs.ContainsKey("name"))
            {
                account.mStatus = AssetStorePublisher.Status.Existing;
                str1            = "publisher -> id";
                JSONValue item = strs["id"];
                account.publisherId = int.Parse(item.AsString(false));
                str1 = "publisher -> name";
                account.publisherName = strs["name"].AsString(false);
            }

            str1 = "publisher";
            if (AssetStoreManager.sDbg)
            {
                JSONValue jSONValue = jval["publisher"];
                DebugUtils.Log(string.Concat("publisher ", jSONValue.ToString(string.Empty, "    ")));
                JSONValue item1 = jval["packages"];
                DebugUtils.Log(string.Concat("packs ", item1.ToString(string.Empty, "    ")));
            }

            str1 = "packages";
            if (!jval.Get("packages").IsNull())
            {
                AssetStoreAPI.OnPackages(jval["packages"], packageDataSource);
            }

            return(null);
        }
        catch (JSONTypeException jSONTypeException1)
        {
            JSONTypeException jSONTypeException = jSONTypeException1;
            str = string.Concat("Malformed response from server: ", str1, " - ", jSONTypeException.Message);
        }
        catch (KeyNotFoundException keyNotFoundException1)
        {
            KeyNotFoundException keyNotFoundException = keyNotFoundException1;
            str = string.Concat("Malformed response from server. ", str1, " - ", keyNotFoundException.Message);
        }

        return(str);
    }
        public static void Download(string package_id, string url, string key, string package_name, string publisher_name, string category_name, AssetStoreUtils.DownloadDoneCallback doneCallback)
        {
            string[]  destination = PackageStorePath(publisher_name, category_name, package_name, package_id, url);
            JSONValue value2      = JSONParser.SimpleParse(AssetStoreUtils.CheckDownload(package_id, url, destination, key));

            if (value2.Get("in_progress").AsBool(true))
            {
                Debug.Log("Will not download " + package_name + ". Download is already in progress.");
            }
            else
            {
                string    str      = value2.Get("download.url").AsString(true);
                string    str2     = value2.Get("download.key").AsString(true);
                bool      resumeOK = (str == url) && (str2 == key);
                JSONValue value6   = new JSONValue {
                    ["url"] = url,
                    ["key"] = key
                };
                AssetStoreUtils.Download(package_id, url, destination, key, new JSONValue {
                    ["download"] = value6
                }.ToString(), resumeOK, doneCallback);
            }
        }
Exemplo n.º 6
0
        protected override JSONValue HandlePost(Request request, JSONValue payload)
        {
            JSONValue value2;
            string    str  = payload.Get("action").AsString();
            string    str2 = this.CurrentState();
            string    key  = str;

            if (key != null)
            {
                int num;
                if (< > f__switch$mapA == null)
                {
                    Dictionary <string, int> dictionary = new Dictionary <string, int>(3);
                    dictionary.Add("play", 0);
                    dictionary.Add("pause", 1);
                    dictionary.Add("stop", 2);
Exemplo n.º 7
0
    private static string RefreshMainAssets(JSONValue jval, Package package)
    {
        string text = "unknown";

        try
        {
            text = "assetbundles";
            JSONValue jSONValue = jval.Get(text);
            if (!jSONValue.IsNull())
            {
                List <string>    list  = new List <string>();
                List <JSONValue> list2 = jSONValue.AsList(false);
                foreach (JSONValue current in list2)
                {
                    list.Add(current.AsString(false));
                }
                package.MainAssets = list;
            }
        }
        catch (JSONTypeException ex)
        {
            string result = string.Concat(new string[]
            {
                "Malformed metadata response for mainAssets '",
                package.Name,
                "' field '",
                text,
                "': ",
                ex.Message
            });
            return(result);
        }
        catch (KeyNotFoundException ex2)
        {
            string result = string.Concat(new string[]
            {
                "Malformed metadata response for package. '",
                package.Name,
                "' field '",
                text,
                "': ",
                ex2.Message
            });
            return(result);
        }
        return(null);
    }
Exemplo n.º 8
0
    private static string OnAssetStorePublisher(JSONValue jval, AssetStorePublisher account, PackageDataSource packageDataSource)
    {
        string str = "unknown field";

        try
        {
            str = "publisher";
            Dictionary <string, JSONValue> dictionary = jval["publisher"].AsDict(false);
            account.mStatus = AssetStorePublisher.Status.New;
            if (dictionary.ContainsKey("name"))
            {
                account.mStatus       = AssetStorePublisher.Status.Existing;
                str                   = "publisher -> id";
                account.publisherId   = int.Parse(dictionary["id"].AsString(false));
                str                   = "publisher -> name";
                account.publisherName = dictionary["name"].AsString(false);
            }
            str = "publisher";
            if (AssetStoreManager.sDbg)
            {
                DebugUtils.Log("publisher " + jval["publisher"].ToString(string.Empty, "    "));
                DebugUtils.Log("packs " + jval["packages"].ToString(string.Empty, "    "));
            }
            str = "packages";
            if (!jval.Get("packages").IsNull())
            {
                AssetStoreAPI.OnPackages(jval["packages"], packageDataSource);
            }
        }
        catch (JSONTypeException ex)
        {
            string result = "Malformed response from server: " + str + " - " + ex.Message;
            return(result);
        }
        catch (KeyNotFoundException ex2)
        {
            string result = "Malformed response from server. " + str + " - " + ex2.Message;
            return(result);
        }
        return(null);
    }
Exemplo n.º 9
0
        protected override JSONValue HandlePost(Request request, JSONValue payload)
        {
            string text = payload.Get("action").AsString();
            string s    = this.CurrentState();

            if (text != null)
            {
                if (!(text == "play"))
                {
                    if (!(text == "pause"))
                    {
                        if (!(text == "stop"))
                        {
                            goto IL_7F;
                        }
                        EditorApplication.isPlaying = false;
                    }
                    else
                    {
                        EditorApplication.isPaused = true;
                    }
                }
                else
                {
                    EditorApplication.isPlaying = true;
                    EditorApplication.isPaused  = false;
                }
                JSONValue result = default(JSONValue);
                result["oldstate"] = s;
                result["newstate"] = this.CurrentState();
                return(result);
            }
IL_7F:
            throw new RestRequestException
                  {
                      HttpStatusCode  = HttpStatusCode.BadRequest,
                      RestErrorString = "Invalid action: " + text
                  };
        }
Exemplo n.º 10
0
 private static AssetStoreClient.DoneCallback WrapLoginCallback(AssetStoreClient.DoneLoginCallback callback)
 {
     return((AssetStoreResponse resp) =>
     {
         AssetStoreClient.UserIconUrl = null;
         int num = -1;
         if (resp.HttpHeaders != null)
         {
             num = Array.IndexOf <string>(resp.HttpHeaders.AllKeys, "X-Unity-Reason");
         }
         if (!resp.ok)
         {
             AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR;
             AssetStoreClient.sLoginErrorMessage = (num < 0 ? resp.HttpErrorMessage ?? "Failed communication" : resp.HttpHeaders.Get(num));
             AssetStoreClient.sLoginErrorMessage = (resp.HttpStatusCode != 401 ? AssetStoreClient.sLoginErrorMessage : "The email and/or password you entered are incorrect. Please try again.");
             AssetStoreClient.sLoginErrorMessage = (resp.HttpStatusCode != 500 ? AssetStoreClient.sLoginErrorMessage : "Server error. Possibly due to excess incorrect login attempts. Try again later.");
             DebugUtils.LogError(resp.HttpErrorMessage ?? "Unknown http error");
         }
         else if (!resp.data.StartsWith("<!DOCTYPE"))
         {
             AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGGED_IN;
             JSONValue jSONValue = JSONParser.SimpleParse(resp.data);
             AssetStoreClient.ActiveSessionID = jSONValue["xunitysession"].AsString(false);
             AssetStoreClient.UserIconUrl = jSONValue.Get("keyimage.icon").AsString(false);
             if (AssetStoreClient.RememberSession)
             {
                 AssetStoreClient.SavedSessionID = AssetStoreClient.ActiveSessionID;
             }
         }
         else
         {
             AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR;
             AssetStoreClient.sLoginErrorMessage = (num < 0 ? "Failed to login" : resp.HttpHeaders.Get(num));
             DebugUtils.LogError(resp.data ?? "no data");
         }
         callback(AssetStoreClient.sLoginErrorMessage);
     });
 }
Exemplo n.º 11
0
 private static AssetStoreClient.DoneCallback WrapLoginCallback(AssetStoreClient.DoneLoginCallback callback)
 {
     return(delegate(AssetStoreResponse resp)
     {
         AssetStoreClient.UserIconUrl = null;
         int num = -1;
         if (resp.HttpHeaders != null)
         {
             num = Array.IndexOf <string>(resp.HttpHeaders.AllKeys, "X-Unity-Reason");
         }
         if (!resp.ok)
         {
             AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR;
             AssetStoreClient.sLoginErrorMessage = ((num < 0) ? "Failed communication" : resp.HttpHeaders.Get(num));
             DebugUtils.LogError(resp.HttpErrorMessage ?? "Unknown http error");
         }
         else if (resp.data.StartsWith("<!DOCTYPE"))
         {
             AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR;
             AssetStoreClient.sLoginErrorMessage = ((num < 0) ? "Failed to login" : resp.HttpHeaders.Get(num));
             DebugUtils.LogError(resp.data ?? "no data");
         }
         else
         {
             AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGGED_IN;
             JSONValue jSONValue = JSONParser.SimpleParse(resp.data);
             AssetStoreClient.ActiveSessionID = jSONValue["xunitysession"].AsString(false);
             AssetStoreClient.UserIconUrl = jSONValue.Get("keyimage.icon").AsString(false);
             if (AssetStoreClient.RememberSession)
             {
                 AssetStoreClient.SavedSessionID = AssetStoreClient.ActiveSessionID;
             }
         }
         callback(AssetStoreClient.sLoginErrorMessage);
     });
 }
Exemplo n.º 12
0
        public AssetStoreContext.PackageList GetPackageList()
        {
            Dictionary <string, AssetStoreContext.Package> dictionary = new Dictionary <string, AssetStoreContext.Package>();

            PackageInfo[] packageList = PackageInfo.GetPackageList();
            PackageInfo[] array       = packageList;
            int           i           = 0;

            while (i < array.Length)
            {
                PackageInfo packageInfo           = array[i];
                AssetStoreContext.Package package = new AssetStoreContext.Package();
                if (packageInfo.jsonInfo == string.Empty)
                {
                    package.title = Path.GetFileNameWithoutExtension(packageInfo.packagePath);
                    package.id    = packageInfo.packagePath;
                    if (this.IsBuiltinStandardAsset(packageInfo.packagePath))
                    {
                        package.publisher = new AssetStoreContext.LabelAndId
                        {
                            label = "Unity Technologies",
                            id    = "1"
                        };
                        package.category = new AssetStoreContext.LabelAndId
                        {
                            label = "Prefab Packages",
                            id    = "4"
                        };
                        package.version = "3.5.0.0";
                    }
                    goto IL_144;
                }
                JSONValue json = JSONParser.SimpleParse(packageInfo.jsonInfo);
                if (!json.IsNull())
                {
                    package.Initialize(json);
                    if (package.id != null)
                    {
                        goto IL_144;
                    }
                    JSONValue jSONValue = json.Get("link.id");
                    if (!jSONValue.IsNull())
                    {
                        package.id = jSONValue.AsString();
                        goto IL_144;
                    }
                    package.id = packageInfo.packagePath;
                    goto IL_144;
                }
IL_203:
                i++;
                continue;
IL_144:
                package.local_icon = packageInfo.iconURL;
                package.local_path = packageInfo.packagePath;
                if (!dictionary.ContainsKey(package.id) || dictionary[package.id].version_id == null || dictionary[package.id].version_id == "-1" || (package.version_id != null && package.version_id != "-1" && int.Parse(dictionary[package.id].version_id) <= int.Parse(package.version_id)))
                {
                    dictionary[package.id] = package;
                    goto IL_203;
                }
                goto IL_203;
            }
            AssetStoreContext.Package[] results = dictionary.Values.ToArray <AssetStoreContext.Package>();
            return(new AssetStoreContext.PackageList
            {
                results = results
            });
        }
Exemplo n.º 13
0
        protected override JSONValue HandlePost(Request request, JSONValue payload)
        {
            string str1 = payload.Get("action").AsString();
            string str2 = this.CurrentState();
            string key  = str1;

            if (key != null)
            {
                // ISSUE: reference to a compiler-generated field
                if (PlayModeRestHandler.\u003C\u003Ef__switch\u0024mapA == null)
                {
                    // ISSUE: reference to a compiler-generated field
                    PlayModeRestHandler.\u003C\u003Ef__switch\u0024mapA = new Dictionary <string, int>(3)
                    {
                        {
                            "play",
                            0
                        },
                        {
                            "pause",
                            1
                        },
                        {
                            "stop",
                            2
                        }
                    };
                }
                int num;
                // ISSUE: reference to a compiler-generated field
                if (PlayModeRestHandler.\u003C\u003Ef__switch\u0024mapA.TryGetValue(key, out num))
                {
                    switch (num)
                    {
                    case 0:
                        EditorApplication.isPlaying = true;
                        EditorApplication.isPaused  = false;
                        break;

                    case 1:
                        EditorApplication.isPaused = true;
                        break;

                    case 2:
                        EditorApplication.isPlaying = false;
                        break;

                    default:
                        goto label_8;
                    }
                    JSONValue jsonValue = new JSONValue();
                    jsonValue["oldstate"] = (JSONValue)str2;
                    jsonValue["newstate"] = (JSONValue)this.CurrentState();
                    return(jsonValue);
                }
            }
label_8:
            throw new RestRequestException()
                  {
                      HttpStatusCode = HttpStatusCode.BadRequest, RestErrorString = "Invalid action: " + str1
                  };
        }
        protected override void Parse(Dictionary <string, JSONValue> dict)
        {
            Dictionary <string, JSONValue> dictionary = dict["purchase_info"].AsDict(true);
            string str = dictionary["status"].AsString(true);

            if (str == "basket-not-empty")
            {
                this.status = AssetStoreAssetsInfo.Status.BasketNotEmpty;
            }
            else if (str == "service-disabled")
            {
                this.status = AssetStoreAssetsInfo.Status.ServiceDisabled;
            }
            else if (str == "user-anonymous")
            {
                this.status = AssetStoreAssetsInfo.Status.AnonymousUser;
            }
            else if (str == "ok")
            {
                this.status = AssetStoreAssetsInfo.Status.Ok;
            }
            this.paymentTokenAvailable = dictionary["payment_token_available"].AsBool();
            if (dictionary.ContainsKey("payment_method_card"))
            {
                this.paymentMethodCard = dictionary["payment_method_card"].AsString(true);
            }
            if (dictionary.ContainsKey("payment_method_expire"))
            {
                this.paymentMethodExpire = dictionary["payment_method_expire"].AsString(true);
            }
            this.price     = dictionary["price"].AsFloat(true);
            this.vat       = dictionary["vat"].AsFloat(true);
            this.priceText = dictionary["price_text"].AsString(true);
            this.vatText   = dictionary["vat_text"].AsString(true);
            this.currency  = dictionary["currency"].AsString(true);
            this.message   = !dictionary.ContainsKey("message") ? (string)null : dictionary["message"].AsString(true);
            using (List <JSONValue> .Enumerator enumerator = dict["results"].AsList(true).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    JSONValue       current = enumerator.Current;
                    AssetStoreAsset assetStoreAsset;
                    if (this.assets.TryGetValue(!current["id"].IsString() ? (int)current["id"].AsFloat() : int.Parse(current["id"].AsString()), out assetStoreAsset))
                    {
                        if (assetStoreAsset.previewInfo == null)
                        {
                            assetStoreAsset.previewInfo = new AssetStoreAsset.PreviewInfo();
                        }
                        AssetStoreAsset.PreviewInfo previewInfo = assetStoreAsset.previewInfo;
                        assetStoreAsset.className     = current["class_names"].AsString(true).Trim();
                        previewInfo.packageName       = current["package_name"].AsString(true).Trim();
                        previewInfo.packageShortUrl   = current["short_url"].AsString(true).Trim();
                        assetStoreAsset.price         = !current.ContainsKey("price_text") ? (string)null : current["price_text"].AsString(true).Trim();
                        previewInfo.packageSize       = int.Parse(!current.Get("package_size").IsNull() ? current["package_size"].AsString(true) : "-1");
                        assetStoreAsset.packageID     = int.Parse(current["package_id"].AsString());
                        previewInfo.packageVersion    = current["package_version"].AsString();
                        previewInfo.packageRating     = int.Parse(current.Get("rating").IsNull() || current["rating"].AsString(true).Length == 0 ? "-1" : current["rating"].AsString(true));
                        previewInfo.packageAssetCount = int.Parse(!current["package_asset_count"].IsNull() ? current["package_asset_count"].AsString(true) : "-1");
                        previewInfo.isPurchased       = current.ContainsKey("purchased") && current["purchased"].AsBool(true);
                        previewInfo.isDownloadable    = previewInfo.isPurchased || assetStoreAsset.price == null;
                        previewInfo.publisherName     = current["publisher_name"].AsString(true).Trim();
                        previewInfo.packageUrl        = !current.Get("package_url").IsNull() ? current["package_url"].AsString(true) : string.Empty;
                        previewInfo.encryptionKey     = !current.Get("encryption_key").IsNull() ? current["encryption_key"].AsString(true) : string.Empty;
                        previewInfo.categoryName      = !current.Get("category_name").IsNull() ? current["category_name"].AsString(true) : string.Empty;
                        previewInfo.buildProgress     = -1f;
                        previewInfo.downloadProgress  = -1f;
                    }
                }
            }
        }