Commits

HexRx committed 7bf3be4

Added proxy support

Comments (0)

Files changed (4)

KPDataSave/Forms/StateControl.cs

         public StateControl(IPluginHost host)
         {
             _host = host;
-            _dropboxClient = new DropboxClient("hhekhlyshoqxt5s", "h0oh21e8y2seixx");
+            _dropboxClient = new DropboxClientProxy("hhekhlyshoqxt5s", "h0oh21e8y2seixx");
 
             AccountState accountState = AccountState.Deserialize(host);
             // Начальное состояние

KPDataSave/KPDataSave.csproj

   </ItemGroup>
   <ItemGroup>
     <Compile Include="AccountState.cs" />
+    <Compile Include="DropboxClientProxy.cs" />
     <Compile Include="Forms\States\Accept.cs">
       <SubType>Form</SubType>
     </Compile>

KPDataSave/KPDataSaveExt.cs

 using System.Windows.Forms;
 using System.IO;
 using System.Threading;
-using System.Reflection;
 
 // KeePass
 using KeePass.Plugins;
             _mHost.MainWindow.UIBlockInteraction(true);
             // Путь к файлу базы
             string dbFile = _mHost.Database.IOConnectionInfo.Path;
-            DropboxClient client = new DropboxClient("hhekhlyshoqxt5s", "h0oh21e8y2seixx", account.Token, account.Secret);
+            var client = new DropboxClientProxy("hhekhlyshoqxt5s", "h0oh21e8y2seixx", account.Token, account.Secret);
             // Сохранение файла базы на сервере Dropbox
             FileInfo file = new FileInfo(dbFile);
 

KPDataSave/Libs/DropboxAPI/DropboxClient.cs

         private string oauth_token_secret;
         public AccessToken AccessToken { get; set; }
 
+        protected IWebProxy Proxy;
+
         // Токены приложения
         public DropboxClient(string appKey, string appSecret)
         {
             this.AccessToken.TokenSecret = accessTokenSecret;
         }
 
+        private IRestClient CreateRestClient(string baseUrl)
+        {
+            return new RestClient(baseUrl) {Proxy = Proxy};
+        }
+
         public string Login_GetUrlLink()
         {
-            var client = new RestClient(apiBase);
+            var client = CreateRestClient(apiBase);
             var request = new RestRequest(Method.POST);
 
             // request_token
 
         public AccessToken Login_RequestAccessToken()
         {
-            var client = new RestClient(apiBase);
+            var client = CreateRestClient(apiBase);
             var request = new RestRequest(Method.POST);
 
             // access_token
         // Получение информации об аккаунте
         public AccountInfo GetAccountInfo()
         {
-            var client = new RestClient(apiBase);
+            var client = CreateRestClient(apiBase);
             var request = new RestRequest(Method.GET);
 
             client.Authenticator = OAuth1Authenticator.ForProtectedResource(appKey, appSecret, AccessToken.Token, AccessToken.TokenSecret);
         // Отправка файла
         public bool UploadFile(string path, FileInfo localFile)
         {
-            var client = new RestClient(apiContent);
+            var client = CreateRestClient(apiContent);
             var request = new RestRequest(Method.POST);
 
             // Обязательно путь должен начинаться на '/'
         // Получение данных о файлах
         public MetaData GetMetaData(string path)
         {
-            var client = new RestClient(apiBase);
+            var client = CreateRestClient(apiBase);
             var request = new RestRequest(Method.GET);
 
             client.Authenticator = OAuth1Authenticator.ForProtectedResource(appKey, appSecret, AccessToken.Token, AccessToken.TokenSecret);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.