public PhotobucketConfigViewModel(
     IPhotobucketConfiguration photobucketConfiguration,
     IPhotobucketLanguage photobucketLanguage,
     IGreenshotLanguage greenshotLanguage,
     FileConfigPartViewModel fileConfigPartViewModel)
 {
     PhotobucketConfiguration = photobucketConfiguration;
     PhotobucketLanguage      = photobucketLanguage;
     GreenshotLanguage        = greenshotLanguage;
     FileConfigPartViewModel  = fileConfigPartViewModel;
 }
예제 #2
0
 protected PhotobucketDestination(
     IPhotobucketConfiguration photobucketConfiguration,
     IPhotobucketLanguage photobucketLanguage,
     INetworkConfiguration networkConfiguration,
     IResourceProvider resourceProvider,
     string albumPath,
     ICoreConfiguration coreConfiguration,
     IGreenshotLanguage greenshotLanguage) : this(photobucketConfiguration, photobucketLanguage, networkConfiguration, resourceProvider, coreConfiguration, greenshotLanguage)
 {
     _photobucketConfiguration = photobucketConfiguration;
     _albumPath = albumPath;
 }
        public PhotobucketDestination(IPhotobucketConfiguration photobucketConfiguration, IPhotobucketLanguage photobucketLanguage)
        {
            _photobucketConfiguration = photobucketConfiguration;
            _photobucketLanguage      = photobucketLanguage;

            _oAuthSettings = new OAuth1Settings
            {
                Token                 = photobucketConfiguration,
                ClientId              = photobucketConfiguration.ClientId,
                ClientSecret          = photobucketConfiguration.ClientSecret,
                CloudServiceName      = "Photobucket",
                EmbeddedBrowserWidth  = 1010,
                EmbeddedBrowserHeight = 400,
                AuthorizeMode         = AuthorizeModes.EmbeddedBrowser,
                TokenUrl              = PhotobucketApiUri.AppendSegments("login", "request"),
                TokenMethod           = HttpMethod.Post,
                AccessTokenUrl        = PhotobucketApiUri.AppendSegments("login", "access"),
                AccessTokenMethod     = HttpMethod.Post,
                AuthorizationUri      = PhotobucketApiUri.AppendSegments("apilogin", "login")
                                        .ExtendQuery(new Dictionary <string, string>
                {
                    { OAuth1Parameters.Token.EnumValueOf(), "{RequestToken}" },
                    { OAuth1Parameters.Callback.EnumValueOf(), "{RedirectUrl}" }
                }),
                RedirectUrl   = "http://getgreenshot.org",
                CheckVerifier = false
            };
            var oAuthHttpBehaviour = OAuth1HttpBehaviourFactory.Create(_oAuthSettings);

            // Store the leftover values
            oAuthHttpBehaviour.OnAccessTokenValues = values =>
            {
                if (values != null && values.ContainsKey("subdomain"))
                {
                    photobucketConfiguration.SubDomain = values["subdomain"];
                }
                if (values != null && values.ContainsKey("username"))
                {
                    photobucketConfiguration.Username = values["username"];
                }
            };

            oAuthHttpBehaviour.BeforeSend = httpRequestMessage =>
            {
                if (photobucketConfiguration.SubDomain == null)
                {
                    return;
                }

                var uriBuilder = new UriBuilder(httpRequestMessage.RequestUri)
                {
                    Host = photobucketConfiguration.SubDomain
                };
                httpRequestMessage.RequestUri = uriBuilder.Uri;
            };
            // Reset the OAuth token if there is no subdomain, without this we need to request it again.
            if (photobucketConfiguration.SubDomain == null || photobucketConfiguration.Username == null)
            {
                photobucketConfiguration.OAuthToken       = null;
                photobucketConfiguration.OAuthTokenSecret = null;
            }
            _oAuthHttpBehaviour = oAuthHttpBehaviour;
        }
 /// <summary>
 ///     Create a Photobucket destination, which also has the path to the album in it
 /// </summary>
 /// <param name="photobucketConfiguration">IPhotobucketConfiguration</param>
 /// <param name="photobucketLanguage">IPhotobucketLanguage</param>
 /// <param name="albumPath">path to the album, null for default</param>
 public PhotobucketDestination(IPhotobucketConfiguration photobucketConfiguration, IPhotobucketLanguage photobucketLanguage, string albumPath) : this(photobucketConfiguration, photobucketLanguage)
 {
     _photobucketConfiguration = photobucketConfiguration;
     _albumPath = albumPath;
 }