Пример #1
0
        public void HubicListFolders(HubicFolderInfo fileInfo)
        {
            lvHubicFolders.Items.Clear();

            if (!OAuth2Info.CheckOAuth(Config.HubicOAuth2Info))
            {
                MessageBox.Show(Resources.UploadersConfigForm_ListFolders_Authentication_required_, Resources.UploadersConfigForm_HubicListFolders_Hubic_refresh_folders_list_failed,
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                Hubic hubic = new Hubic(Config.HubicOAuth2Info, Config.HubicOpenstackAuthInfo);
                List<HubicFolderInfo> folders = hubic.GetFiles(fileInfo);
                if (folders != null && folders.Count != 0)
                {
                    foreach (HubicFolderInfo folder in folders.Where(x => x.content_type == "application/directory" && x.name[0] != '.'))
                    {
                        HubicAddFolder(folder);
                    }
                }
            }
        }
Пример #2
0
        public void HubicAuthOpen()
        {
            try
            {
                OAuth2Info oauth = new OAuth2Info(APIKeys.HubicClientID, APIKeys.HubicClientSecret);
                HubicOpenstackAuthInfo osauth = new HubicOpenstackAuthInfo();

                string url = new Hubic(oauth, osauth).GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    Config.HubicOAuth2Info = oauth;
                    Config.HubicOpenstackAuthInfo = osauth;
                    URLHelpers.OpenURL(url);
                    DebugHelper.WriteLine("HubicAuthOpen - Authorization URL is opened: " + url);
                }
                else
                {
                    DebugHelper.WriteLine("HubicAuthOpen - Authorization URL is empty.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        public void HubicAuthRefresh()
        {
            try
            {
                if (OAuth2Info.CheckOAuth(Config.HubicOAuth2Info))
                {
                    bool result = new Hubic(Config.HubicOAuth2Info, Config.HubicOpenstackAuthInfo).RefreshAccessToken();

                    if (result)
                    {
                        oauth2Hubic.Status = OAuthLoginStatus.LoginSuccessful;
                        MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        oauth2Hubic.Status = OAuthLoginStatus.LoginFailed;
                        MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
        public void HubicAuthComplete(string code)
        {
            try
            {
                if (!string.IsNullOrEmpty(code) && Config.HubicOAuth2Info != null)
                {
                    bool result = new Hubic(Config.HubicOAuth2Info, Config.HubicOpenstackAuthInfo).GetAccessToken(code);

                    if (result)
                    {
                        oauth2Hubic.Status = OAuthLoginStatus.LoginSuccessful;
                        MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        oauth2Hubic.Status = OAuthLoginStatus.LoginFailed;
                        MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    btnHubicRefreshFolders.Enabled = result;
                    btnHubicRefreshFolders.PerformClick();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }