Пример #1
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);
     }
 }
Пример #2
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);
     }
 }
Пример #3
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);
     }
 }