Exemple #1
0
 public void Upload(string path, Stream stream, CancellableProgress progress, Action <string> success, Action <Exception> failure)
 {
     try
     {
         VerifyLoggedIn();
         JsonObject jsonObject = new JsonObject();
         jsonObject.Add("path", NormalizePath(path));
         jsonObject.Add("mode", "add");
         jsonObject.Add("autorename", true);
         jsonObject.Add("mute", false);
         Dictionary <string, string> dictionary = new Dictionary <string, string>();
         dictionary.Add("Authorization", "Bearer " + SettingsManager.ScpboxAccessToken);
         dictionary.Add("Content-Type", "application/octet-stream");
         dictionary.Add("Dropbox-API-Arg", jsonObject.ToString());
         WebManager.Post(m_redirectUri + "/com/files/upload", null, dictionary, stream, progress, delegate
         {
             success(null);
         }, delegate(Exception error)
         {
             failure(error);
         });
     }
     catch (Exception obj)
     {
         failure(obj);
     }
 }
Exemple #2
0
 public void Link(string path, CancellableProgress progress, Action <string> success, Action <Exception> failure)
 {
     try
     {
         VerifyLoggedIn();
         Dictionary <string, string> dictionary = new Dictionary <string, string>();
         dictionary.Add("Authorization", "Bearer " + SettingsManager.ScpboxAccessToken);
         dictionary.Add("Content-Type", "application/json");
         JsonObject jsonObject = new JsonObject();
         jsonObject.Add("path", NormalizePath(path));
         jsonObject.Add("short_url", false);
         MemoryStream data = new MemoryStream(Encoding.UTF8.GetBytes(jsonObject.ToString()));
         WebManager.Post(m_redirectUri + "/com/sharing/create_shared_link", null, dictionary, data, progress, delegate(byte[] result)
         {
             try
             {
                 JsonObject jsonObject2 = (JsonObject)WebManager.JsonFromBytes(result);
                 success(JsonObjectToLinkAddress(jsonObject2));
             }
             catch (Exception obj2)
             {
                 failure(obj2);
             }
         }, delegate(Exception error)
         {
             failure(error);
         });
     }
     catch (Exception obj)
     {
         failure(obj);
     }
 }
Exemple #3
0
 public void Login(CancellableProgress progress, Action success, Action <Exception> failure)
 {
     try
     {
         if (m_loginProcessData != null)
         {
             throw new InvalidOperationException("登陆已经在进程中");
         }
         if (!WebManager.IsInternetConnectionAvailable())
         {
             throw new InvalidOperationException("网络连接错误");
         }
         Logout();
         progress.Cancelled += delegate
         {
             if (m_loginProcessData != null)
             {
                 LoginProcessData loginProcessData = m_loginProcessData;
                 m_loginProcessData = null;
                 loginProcessData.Fail(this, null);
             }
         };
         m_loginProcessData          = new LoginProcessData();
         m_loginProcessData.Progress = progress;
         m_loginProcessData.Success  = success;
         m_loginProcessData.Failure  = failure;
         LoginLaunchBrowser();
     }
     catch (Exception obj)
     {
         failure(obj);
     }
 }
Exemple #4
0
        public static void Delete(string address, string userId, CancellableProgress progress, Action success, Action <Exception> failure)
        {
            progress = (progress ?? new CancellableProgress());
            if (!WebManager.IsInternetConnectionAvailable())
            {
                failure(new InvalidOperationException("Internet connection is unavailable."));
                return;
            }
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("Action", "delete");
            dictionary.Add("UserId", userId);
            dictionary.Add("Url", address);
            dictionary.Add("Platform", VersionsManager.Platform.ToString());
            dictionary.Add("Version", VersionsManager.Version);
            WebManager.Post(m_scResDirAddress, null, null, WebManager.UrlParametersToStream(dictionary), progress, delegate
            {
                success();
                AnalyticsManager.LogEvent("[CommunityContentManager] Delete Success", new AnalyticsParameter("Name", address), new AnalyticsParameter("User", userId));
            }, delegate(Exception error)
            {
                failure(error);
                AnalyticsManager.LogEvent("[CommunityContentManager] Delete Failure", new AnalyticsParameter("Name", address), new AnalyticsParameter("User", userId), new AnalyticsParameter("Error", error.Message.ToString()));
            });
        }
Exemple #5
0
        public static void List(string cursor, string userFilter, string typeFilter, string moderationFilter, string sortOrder, CancellableProgress progress, Action <List <CommunityContentEntry>, string> success, Action <Exception> failure)
        {
            progress = (progress ?? new CancellableProgress());
            if (!WebManager.IsInternetConnectionAvailable())
            {
                failure(new InvalidOperationException("Internet connection is unavailable."));
                return;
            }
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("Action", "list");
            dictionary.Add("Cursor", cursor ?? string.Empty);
            dictionary.Add("UserId", userFilter ?? string.Empty);
            dictionary.Add("Type", typeFilter ?? string.Empty);
            dictionary.Add("Moderation", moderationFilter ?? string.Empty);
            dictionary.Add("SortOrder", sortOrder ?? string.Empty);
            dictionary.Add("Platform", VersionsManager.Platform.ToString());
            dictionary.Add("Version", VersionsManager.Version);
            WebManager.Post(m_scResDirAddress, null, null, WebManager.UrlParametersToStream(dictionary), progress, delegate(byte[] result)
            {
                try
                {
                    XElement xElement                 = XmlUtils.LoadXmlFromString(Encoding.UTF8.GetString(result, 0, result.Length), throwOnError: true);
                    string attributeValue             = XmlUtils.GetAttributeValue <string>(xElement, "NextCursor");
                    List <CommunityContentEntry> list = new List <CommunityContentEntry>();
                    foreach (XElement item in xElement.Elements())
                    {
                        try
                        {
                            list.Add(new CommunityContentEntry
                            {
                                Type           = XmlUtils.GetAttributeValue(item, "Type", ExternalContentType.Unknown),
                                Name           = XmlUtils.GetAttributeValue <string>(item, "Name"),
                                Address        = XmlUtils.GetAttributeValue <string>(item, "Url"),
                                UserId         = XmlUtils.GetAttributeValue <string>(item, "UserId"),
                                Size           = XmlUtils.GetAttributeValue <long>(item, "Size"),
                                ExtraText      = XmlUtils.GetAttributeValue(item, "ExtraText", string.Empty),
                                RatingsAverage = XmlUtils.GetAttributeValue(item, "RatingsAverage", 0f)
                            });
                        }
                        catch (Exception)
                        {
                        }
                    }
                    success(list, attributeValue);
                }
                catch (Exception obj)
                {
                    failure(obj);
                }
            }, delegate(Exception error)
            {
                failure(error);
            });
        }
Exemple #6
0
 public static void VerifyLinkContent(string address, string name, ExternalContentType type, CancellableProgress progress, Action <byte[]> success, Action <Exception> failure)
 {
     progress = (progress ?? new CancellableProgress());
     WebManager.Get(address, null, null, progress, delegate(byte[] data)
     {
         ExternalContentManager.ImportExternalContent(new MemoryStream(data), type, "__Temp", delegate(string downloadedName)
         {
             ExternalContentManager.DeleteExternalContent(type, downloadedName);
             success(data);
         }, failure);
     }, failure);
 }
Exemple #7
0
 public void WindowActivated()
 {
     if (m_loginProcessData != null && !m_loginProcessData.IsTokenFlow)
     {
         LoginProcessData loginProcessData = m_loginProcessData;
         m_loginProcessData = null;
         TextBoxDialog dialog = new TextBoxDialog("输入用户登录Token:", "", 256, delegate(string s)
         {
             if (s != null)
             {
                 try
                 {
                     WebManager.Post(m_redirectUri + "/com/oauth2/token", new Dictionary <string, string>
                     {
                         {
                             "code",
                             s.Trim()
                         },
                         {
                             "client_id",
                             "1unnzwkb8igx70k"
                         },
                         {
                             "client_secret",
                             "3i5u3j3141php7u"
                         },
                         {
                             "grant_type",
                             "authorization_code"
                         }
                     }, null, new MemoryStream(), loginProcessData.Progress, delegate(byte[] result)
                     {
                         SettingsManager.ScpboxAccessToken = ((IDictionary <string, object>)WebManager.JsonFromBytes(result))["access_token"].ToString();
                         loginProcessData.Succeed(this);
                     }, delegate(Exception error)
                     {
                         loginProcessData.Fail(this, error);
                     });
                 }
                 catch (Exception error2)
                 {
                     loginProcessData.Fail(this, error2);
                 }
             }
             else
             {
                 loginProcessData.Fail(this, null);
             }
         });
         DialogsManager.ShowDialog(null, dialog);
     }
 }
Exemple #8
0
        public static void Feedback(string address, string feedback, string feedbackParameter, string hash, long size, string userId, CancellableProgress progress, Action success, Action <Exception> failure)
        {
            progress = (progress ?? new CancellableProgress());
            if (!WebManager.IsInternetConnectionAvailable())
            {
                failure(new InvalidOperationException("Internet connection is unavailable."));
                return;
            }

            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("Action", "feedback");
            dictionary.Add("Feedback", feedback);
            if (feedbackParameter != null)
            {
                dictionary.Add("FeedbackParameter", feedbackParameter);
            }
            dictionary.Add("UserId", userId);
            if (address != null)
            {
                dictionary.Add("Url", address);
            }
            if (hash != null)
            {
                dictionary.Add("Hash", hash);
            }
            if (size > 0)
            {
                dictionary.Add("Size", size.ToString(CultureInfo.InvariantCulture));
            }
            dictionary.Add("Platform", VersionsManager.Platform.ToString());
            dictionary.Add("Version", VersionsManager.Version);
            WebManager.Post(m_scResDirAddress, null, null, WebManager.UrlParametersToStream(dictionary), progress, delegate
            {
                string key = MakeFeedbackCacheKey(address, feedback, userId);
                if (m_feedbackCache.ContainsKey(key))
                {
                    Task.Run(delegate
                    {
                        Task.Delay(1500).Wait();
                        failure(new InvalidOperationException("Duplicate feedback."));
                    });
                    return;
                }
                m_feedbackCache[key] = true;
                success();
            }, delegate(Exception error)
            {
                failure(error);
            });
        }
Exemple #9
0
 public override void Update()
 {
     if (btna.IsClicked)
     {
         Dictionary <string, string> par = new Dictionary <string, string>();
         par.Add("user", txa.Text);
         par.Add("pass", txb.Text);
         WebManager.Post(SPMBoxExternalContentProvider.m_redirectUri + "/com/api/login", par, null, new MemoryStream(), new CancellableProgress(), succ, fail);
     }
     if (btnb.IsClicked)
     {
         WebBrowserManager.LaunchBrowser(SPMBoxExternalContentProvider.m_redirectUri + "/com/reg");
     }
     if (btnc.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
 }
Exemple #10
0
 public static void Update()
 {
     if (Time.PeriodicEvent(1.0, 0.0))
     {
         TimeSpan t   = TimeSpan.FromHours(SettingsManager.MotdUpdatePeriodHours);
         DateTime now = DateTime.Now;
         if (now >= SettingsManager.MotdLastUpdateTime + t)
         {
             SettingsManager.MotdLastUpdateTime = now;
             Log.Information("Downloading MOTD");
             AnalyticsManager.LogEvent("[MotdManager] Downloading MOTD", new AnalyticsParameter("Time", DateTime.Now.ToString("HH:mm:ss.fff")));
             string url = GetMotdUrl();
             WebManager.Get(url, null, null, null, delegate(byte[] result)
             {
                 try
                 {
                     string motdLastDownloadedData = UnpackMotd(result);
                     MessageOfTheDay = null;
                     SettingsManager.MotdLastDownloadedData = motdLastDownloadedData;
                     Log.Information("Downloaded MOTD");
                     AnalyticsManager.LogEvent("[MotdManager] Downloaded MOTD", new AnalyticsParameter("Time", DateTime.Now.ToString("HH:mm:ss.fff")), new AnalyticsParameter("Url", url));
                     SettingsManager.MotdUseBackupUrl = false;
                 }
                 catch (Exception ex)
                 {
                     Log.Error("Failed processing MOTD string. Reason: " + ex.Message);
                     SettingsManager.MotdUseBackupUrl = !SettingsManager.MotdUseBackupUrl;
                 }
             }, delegate(Exception error)
             {
                 Log.Error("Failed downloading MOTD. Reason: {0}", error.Message);
                 SettingsManager.MotdUseBackupUrl = !SettingsManager.MotdUseBackupUrl;
             });
         }
     }
     if (MessageOfTheDay == null && !string.IsNullOrEmpty(SettingsManager.MotdLastDownloadedData))
     {
         MessageOfTheDay = ParseMotd(SettingsManager.MotdLastDownloadedData);
         if (MessageOfTheDay == null)
         {
             SettingsManager.MotdLastDownloadedData = string.Empty;
         }
     }
 }
Exemple #11
0
 public static void Download(string address, string name, ExternalContentType type, string userId, CancellableProgress progress, Action success, Action <Exception> failure)
 {
     progress = (progress ?? new CancellableProgress());
     if (!WebManager.IsInternetConnectionAvailable())
     {
         failure(new InvalidOperationException("Internet connection is unavailable."));
     }
     else
     {
         WebManager.Get(address, null, null, progress, delegate(byte[] data)
         {
             string hash = CalculateContentHashString(data);
             ExternalContentManager.ImportExternalContent(new MemoryStream(data), type, name, delegate(string downloadedName)
             {
                 m_idToAddressMap[MakeContentIdString(type, downloadedName)] = address;
                 Feedback(address, "Success", null, hash, data.Length, userId, progress, delegate
                 {
                 }, delegate
                 {
                 });
                 AnalyticsManager.LogEvent("[CommunityContentManager] Download Success", new AnalyticsParameter("Name", name));
                 success();
             }, delegate(Exception error)
             {
                 Feedback(address, "ImportFailure", null, hash, data.Length, userId, null, delegate
                 {
                 }, delegate
                 {
                 });
                 AnalyticsManager.LogEvent("[CommunityContentManager] Import Failure", new AnalyticsParameter("Name", name), new AnalyticsParameter("Error", error.Message.ToString()));
                 failure(error);
             });
         }, delegate(Exception error)
         {
             Feedback(address, "DownloadFailure", null, null, 0L, userId, null, delegate
             {
             }, delegate
             {
             });
             AnalyticsManager.LogEvent("[CommunityContentManager] Download Failure", new AnalyticsParameter("Name", name), new AnalyticsParameter("Error", error.Message.ToString()));
             failure(error);
         });
     }
 }
Exemple #12
0
 public void Upload(string path, Stream stream, CancellableProgress progress, Action <string> success, Action <Exception> failure)
 {
     try
     {
         Dictionary <string, string> dictionary = new Dictionary <string, string>();
         dictionary.Add("Content-Type", "application/octet-stream");
         WebManager.Put("https://transfer.sh/" + path, null, dictionary, stream, progress, delegate(byte[] result)
         {
             string obj2 = Encoding.UTF8.GetString(result, 0, result.Length).Trim();
             success(obj2);
         }, delegate(Exception error)
         {
             failure(error);
         });
     }
     catch (Exception obj)
     {
         failure(obj);
     }
 }
        public void HandleUri(Uri uri)
        {
            if (m_loginProcessData == null)
            {
                m_loginProcessData             = new LoginProcessData();
                m_loginProcessData.IsTokenFlow = true;
            }
            LoginProcessData loginProcessData = m_loginProcessData;

            m_loginProcessData = null;
            if (loginProcessData.IsTokenFlow)
            {
                try
                {
                    if (!(uri != null) || string.IsNullOrEmpty(uri.Fragment))
                    {
                        goto IL_00a5;
                    }
                    Dictionary <string, string> dictionary = WebManager.UrlParametersFromString(uri.Fragment.TrimStart('#'));
                    if (!dictionary.ContainsKey("access_token"))
                    {
                        if (dictionary.ContainsKey("error"))
                        {
                            throw new Exception(dictionary["error"]);
                        }
                        goto IL_00a5;
                    }
                    SettingsManager.DropboxAccessToken = dictionary["access_token"];
                    loginProcessData.Succeed(this);
                    goto end_IL_0038;
IL_00a5:
                    throw new Exception("Could not retrieve Dropbox access token.");
                    end_IL_0038 :;
                }
                catch (Exception error)
                {
                    loginProcessData.Fail(this, error);
                }
            }
        }
Exemple #14
0
 public static void LogError(string message, Exception error)
 {
     try
     {
         double realTime = Time.RealTime;
         if (!(realTime - LastSendTime < 15.0))
         {
             LastSendTime = realTime;
             Dictionary <string, string> dictionary = new Dictionary <string, string>();
             dictionary.Add("Platform", VersionsManager.Platform.ToString());
             dictionary.Add("BuildConfiguration", VersionsManager.BuildConfiguration.ToString());
             dictionary.Add("DeviceModel", DeviceManager.DeviceModel);
             dictionary.Add("OSVersion", DeviceManager.OperatingSystemVersion);
             dictionary.Add("Is64bit", (Marshal.SizeOf <IntPtr>() == 8).ToString());
             dictionary.Add("FreeSpace", (Storage.FreeSpace / 1024 / 1024).ToString() + "MB");
             dictionary.Add("TotalAvailableMemory", (Utilities.GetTotalAvailableMemory() / 1024).ToString() + "kB");
             dictionary.Add("RealTime", Time.RealTime.ToString("0.000") + "s");
             dictionary.Add("WindowSize", Window.Size.ToString());
             dictionary.Add("FullErrorMessage", ExceptionManager.MakeFullErrorMessage(message, error));
             dictionary.Add("ExceptionType", error.GetType().ToString());
             dictionary.Add("ExceptionStackTrace", AbbreviateStackTrace(error.StackTrace));
             MemoryStream  memoryStream  = new MemoryStream();
             DeflateStream deflateStream = new DeflateStream(memoryStream, CompressionLevel.Optimal, leaveOpen: true);
             BinaryWriter  binaryWriter  = new BinaryWriter(deflateStream);
             binaryWriter.Write(3735928559u);
             binaryWriter.Write((byte)dictionary.Count);
             foreach (KeyValuePair <string, string> item in dictionary)
             {
                 binaryWriter.Write(item.Key);
                 binaryWriter.Write(item.Value);
             }
             deflateStream.Dispose();
             memoryStream.Position = 0L;
             WebManager.Post(string.Format("{0}:{1}/{2}/{3}/{4}/{5}", "http://quality.kaalus.com", 30099, 1, "Survivalcraft", VersionsManager.Version, "Error"), null, null, memoryStream, null, null, null);
         }
     }
     catch
     {
     }
 }
Exemple #15
0
 public void Download(string path, CancellableProgress progress, Action <Stream> success, Action <Exception> failure)
 {
     try
     {
         VerifyLoggedIn();
         JsonObject jsonObject = new JsonObject();
         jsonObject.Add("path", NormalizePath(path));
         Dictionary <string, string> dictionary = new Dictionary <string, string>();
         dictionary.Add("Authorization", "Bearer " + SettingsManager.ScpboxAccessToken);
         dictionary.Add("Dropbox-API-Arg", jsonObject.ToString());
         WebManager.Get(m_redirectUri + "/com/files/download", null, dictionary, progress, delegate(byte[] result)
         {
             success(new MemoryStream(result));
         }, delegate(Exception error)
         {
             failure(error);
         });
     }
     catch (Exception obj)
     {
         failure(obj);
     }
 }
Exemple #16
0
        public void HandleUri(Uri uri)
        {
            if (m_loginProcessData == null)
            {
                m_loginProcessData             = new LoginProcessData();
                m_loginProcessData.IsTokenFlow = true;
            }
            LoginProcessData loginProcessData = m_loginProcessData;

            m_loginProcessData = null;
            if (loginProcessData.IsTokenFlow)
            {
                try
                {
                    if (!(uri != null) || string.IsNullOrEmpty(uri.Fragment))
                    {
                        throw new Exception("不能接收来自SPMBox的身份验证信息");
                    }
                    Dictionary <string, string> dictionary = WebManager.UrlParametersFromString(uri.Fragment.TrimStart('#'));
                    if (!dictionary.ContainsKey("access_token"))
                    {
                        if (dictionary.ContainsKey("error"))
                        {
                            throw new Exception(dictionary["error"]);
                        }
                        throw new Exception("不能接收来自SPMBox的身份验证信息");
                    }
                    SettingsManager.ScpboxAccessToken = dictionary["access_token"];
                    loginProcessData.Succeed(this);
                }
                catch (Exception error)
                {
                    loginProcessData.Fail(this, error);
                }
            }
        }
Exemple #17
0
 public void List(string path, CancellableProgress progress, Action <ExternalContentEntry> success, Action <Exception> failure)
 {
     try
     {
         VerifyLoggedIn();
         Dictionary <string, string> dictionary = new Dictionary <string, string>();
         dictionary.Add("Authorization", "Bearer " + SettingsManager.ScpboxAccessToken);
         dictionary.Add("Content-Type", "application/json");
         JsonObject jsonObject = new JsonObject();
         jsonObject.Add("path", NormalizePath(path));
         jsonObject.Add("recursive", false);
         jsonObject.Add("include_media_info", false);
         jsonObject.Add("include_deleted", false);
         jsonObject.Add("include_has_explicit_shared_members", false);
         MemoryStream data = new MemoryStream(Encoding.UTF8.GetBytes(jsonObject.ToString()));
         WebManager.Post(m_redirectUri + "/com/files/list_folder", null, dictionary, data, progress, delegate(byte[] result)
         {
             try
             {
                 JsonObject jsonObject2 = (JsonObject)WebManager.JsonFromBytes(result);
                 success(JsonObjectToEntry(jsonObject2));
             }
             catch (Exception obj2)
             {
                 failure(obj2);
             }
         }, delegate(Exception error)
         {
             failure(error);
         });
     }
     catch (Exception obj)
     {
         failure(obj);
     }
 }
        public override void Update()
        {
            string text = m_linkTextBoxWidget.Text.Trim();
            string name = m_nameTextBoxWidget.Text.Trim();

            m_typeLabelWidget.Text      = ExternalContentManager.GetEntryTypeDescription(m_type);
            m_typeIconWidget.Subtexture = ExternalContentManager.GetEntryTypeIcon(m_type);
            if (ExternalContentManager.DoesEntryTypeRequireName(m_type))
            {
                m_nameTextBoxWidget.IsEnabled    = true;
                m_downloadButtonWidget.IsEnabled = (text.Length > 0 && name.Length > 0 && m_type != ExternalContentType.Unknown);
                if (m_updateContentName)
                {
                    m_nameTextBoxWidget.Text = GetNameFromLink(m_linkTextBoxWidget.Text);
                    m_updateContentName      = false;
                }
            }
            else
            {
                m_nameTextBoxWidget.IsEnabled    = false;
                m_nameTextBoxWidget.Text         = string.Empty;
                m_downloadButtonWidget.IsEnabled = (text.Length > 0 && m_type != ExternalContentType.Unknown);
            }
            if (m_updateContentType)
            {
                m_type = GetTypeFromLink(m_linkTextBoxWidget.Text);
                m_updateContentType = false;
            }
            if (m_changeTypeButtonWidget.IsClicked)
            {
                DialogsManager.ShowDialog(base.ParentWidget, new SelectExternalContentTypeDialog("Select Content Type", delegate(ExternalContentType item)
                {
                    m_type = item;
                    m_updateContentName = true;
                }));
            }
            else if (base.Input.Cancel || m_cancelButtonWidget.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
            else if (m_downloadButtonWidget.IsClicked)
            {
                CancellableBusyDialog busyDialog = new CancellableBusyDialog("Downloading", autoHideOnCancel: false);
                DialogsManager.ShowDialog(base.ParentWidget, busyDialog);
                WebManager.Get(text, null, null, busyDialog.Progress, delegate(byte[] data)
                {
                    ExternalContentManager.ImportExternalContent(new MemoryStream(data), m_type, name, delegate
                    {
                        DialogsManager.HideDialog(busyDialog);
                        DialogsManager.HideDialog(this);
                    }, delegate(Exception error)
                    {
                        DialogsManager.HideDialog(busyDialog);
                        DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Error", error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                    });
                }, delegate(Exception error)
                {
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Error", error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                });
            }
        }
 public void LoginLaunchBrowser()
 {
     try
     {
         m_loginProcessData.IsTokenFlow = true;
         Dictionary <string, string> dictionary = new Dictionary <string, string>();
         dictionary.Add("response_type", "token");
         dictionary.Add("client_id", "1unnzwkb8igx70k");
         dictionary.Add("redirect_uri", "com.candyrufusgames.survivalcraft2://redirect");
         WebBrowserManager.LaunchBrowser("https://www.dropbox.com/oauth2/authorize?" + WebManager.UrlParametersToString(dictionary));
     }
     catch (Exception error)
     {
         m_loginProcessData.Fail(this, error);
     }
 }
Exemple #20
0
 public static void Publish(string address, string name, ExternalContentType type, string userId, CancellableProgress progress, Action success, Action <Exception> failure)
 {
     progress = (progress ?? new CancellableProgress());
     if (MarketplaceManager.IsTrialMode)
     {
         failure(new InvalidOperationException("Cannot publish links in trial mode."));
     }
     else if (!WebManager.IsInternetConnectionAvailable())
     {
         failure(new InvalidOperationException("Internet connection is unavailable."));
     }
     else
     {
         VerifyLinkContent(address, name, type, progress, delegate(byte[] data)
         {
             string value = CalculateContentHashString(data);
             WebManager.Post(m_scResDirAddress, null, null, WebManager.UrlParametersToStream(new Dictionary <string, string>
             {
                 {
                     "Action",
                     "publish"
                 },
                 {
                     "UserId",
                     userId
                 },
                 {
                     "Name",
                     name
                 },
                 {
                     "Url",
                     address
                 },
                 {
                     "Type",
                     type.ToString()
                 },
                 {
                     "Hash",
                     value
                 },
                 {
                     "Size",
                     data.Length.ToString(CultureInfo.InvariantCulture)
                 },
                 {
                     "Platform",
                     VersionsManager.Platform.ToString()
                 },
                 {
                     "Version",
                     VersionsManager.Version
                 }
             }), progress, delegate
             {
                 success();
                 AnalyticsManager.LogEvent("[CommunityContentManager] Publish Success", new AnalyticsParameter("Name", name), new AnalyticsParameter("Type", type.ToString()), new AnalyticsParameter("Size", data.Length.ToString()), new AnalyticsParameter("User", userId));
             }, delegate(Exception error)
             {
                 failure(error);
                 AnalyticsManager.LogEvent("[CommunityContentManager] Publish Failure", new AnalyticsParameter("Name", name), new AnalyticsParameter("Type", type.ToString()), new AnalyticsParameter("Size", data.Length.ToString()), new AnalyticsParameter("User", userId), new AnalyticsParameter("Error", error.Message.ToString()));
             });
         }, failure);
     }
 }