OSDN Git Service

AppendSettingDialog.TwitterConfigurationをTwitter.Configurationに移動
authorKimura Youichi <kim.upsilon@bucyou.net>
Fri, 1 Aug 2014 17:09:32 +0000 (02:09 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Fri, 1 Aug 2014 17:20:40 +0000 (02:20 +0900)
OpenTween/AppendSettingDialog.cs
OpenTween/Tween.cs
OpenTween/Twitter.cs

index 0b37067..67d3371 100644 (file)
@@ -51,8 +51,6 @@ namespace OpenTween
 
         private long? InitialUserId;
 
-        public TwitterConfiguration TwitterConfiguration = TwitterConfiguration.DefaultConfiguration();
-
         private string _pin;
 
         public event EventHandler<IntervalChangedEventArgs> IntervalChanged;
index d88c1bf..641268f 100644 (file)
@@ -899,7 +899,7 @@ namespace OpenTween
             AllrepliesToolStripMenuItem.Checked = tw.AllAtReply;
 
             //画像投稿サービス
-            ImageSelector.Initialize(tw, SettingDialog.TwitterConfiguration, _cfgCommon.UseImageServiceName, _cfgCommon.UseImageService);
+            ImageSelector.Initialize(tw, this.tw.Configuration, _cfgCommon.UseImageServiceName, _cfgCommon.UseImageService);
 
             //ウィンドウ設定
             this.ClientSize = _cfgLocal.FormSize;
@@ -2434,7 +2434,7 @@ namespace OpenTween
                 case MyCommon.WORKERTYPE.Configuration:
                     try
                     {
-                        this.SettingDialog.TwitterConfiguration = tw.ConfigurationApi();
+                        this.tw.RefreshConfiguration();
                     }
                     catch (WebApiException ex) { ret = ex.Message; }
                     break;
@@ -2929,11 +2929,11 @@ namespace OpenTween
                     break;
                 case MyCommon.WORKERTYPE.Configuration:
                     //_waitFollower = false
-                    if (SettingDialog.TwitterConfiguration.PhotoSizeLimit != 0)
+                    if (this.tw.Configuration.PhotoSizeLimit != 0)
                     {
                         foreach (var service in this.ImageSelector.GetServices())
                         {
-                            service.UpdateTwitterConfiguration(this.SettingDialog.TwitterConfiguration);
+                            service.UpdateTwitterConfiguration(this.tw.Configuration);
                         }
                     }
                     this.PurgeListViewItemCache();
@@ -3793,7 +3793,7 @@ namespace OpenTween
                         this._cfgLocal.ProxyAddress, this._cfgLocal.ProxyPort,
                         this._cfgLocal.ProxyUser, this._cfgLocal.ProxyPassword);
 
-                    ImageSelector.Reset(tw, SettingDialog.TwitterConfiguration);
+                    ImageSelector.Reset(tw, this.tw.Configuration);
 
                     try
                     {
@@ -4898,7 +4898,7 @@ namespace OpenTween
                         last_url_invalid_match = Regex.IsMatch(lasturl, Twitter.url_invalid_short_domain, RegexOptions.IgnoreCase);
                         if (!last_url_invalid_match)
                         {
-                            pLen += lasturl.Length - SettingDialog.TwitterConfiguration.ShortUrlLength;
+                            pLen += lasturl.Length - this.tw.Configuration.ShortUrlLength;
                         }
                     }
 
@@ -4906,7 +4906,7 @@ namespace OpenTween
                     {
                         if (last_url_invalid_match)
                         {
-                            pLen += lasturl.Length - SettingDialog.TwitterConfiguration.ShortUrlLength;
+                            pLen += lasturl.Length - this.tw.Configuration.ShortUrlLength;
                         }
                         pLen += path.Length;
                     }
@@ -4914,8 +4914,8 @@ namespace OpenTween
                 else
                 {
                     int shortUrlLength = protocol == "https://"
-                        ? SettingDialog.TwitterConfiguration.ShortUrlLengthHttps
-                        : SettingDialog.TwitterConfiguration.ShortUrlLength;
+                        ? this.tw.Configuration.ShortUrlLengthHttps
+                        : this.tw.Configuration.ShortUrlLength;
 
                     pLen += url.Length - shortUrlLength;
                 }
@@ -4927,7 +4927,7 @@ namespace OpenTween
             }
             if (ImageSelector.Visible && !string.IsNullOrEmpty(ImageSelector.ServiceName))
             {
-                pLen -= SettingDialog.TwitterConfiguration.CharactersReservedPerMedia;
+                pLen -= this.tw.Configuration.CharactersReservedPerMedia;
             }
             return pLen;
         }
@@ -10673,7 +10673,7 @@ namespace OpenTween
                     GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, "");
 
                 // 取得失敗の場合は再試行する
-                if (SettingDialog.TwitterConfiguration.PhotoSizeLimit == 0)
+                if (this.tw.Configuration.PhotoSizeLimit == 0)
                     GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, "");
 
                 // 権限チェック read/write権限(xAuthで取得したトークン)の場合は再認証を促す
@@ -11233,10 +11233,10 @@ namespace OpenTween
 
         public bool IsTwitterId(string name)
         {
-            if (SettingDialog.TwitterConfiguration.NonUsernamePaths == null || SettingDialog.TwitterConfiguration.NonUsernamePaths.Length == 0)
+            if (this.tw.Configuration.NonUsernamePaths == null || this.tw.Configuration.NonUsernamePaths.Length == 0)
                 return !Regex.Match(name, @"^(about|jobs|tos|privacy|who_to_follow|download|messages)$", RegexOptions.IgnoreCase).Success;
             else
-                return !SettingDialog.TwitterConfiguration.NonUsernamePaths.Contains(name.ToLower());
+                return !this.tw.Configuration.NonUsernamePaths.Contains(name.ToLower());
         }
 
         private string GetUserId()
index fdce3d2..6ffb634 100644 (file)
@@ -136,6 +136,8 @@ namespace OpenTween
 | frtrt\.net/solo_status\.php\?status=          # RtRT
 )(?<StatusId>[0-9]+)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
 
+        public TwitterConfiguration Configuration { get; private set; }
+
         delegate void GetIconImageDelegate(PostClass post);
         private readonly object LockObj = new object();
         private List<long> followerId = new List<long>();
@@ -169,6 +171,11 @@ namespace OpenTween
 
         //private List<PostClass> _deletemessages = new List<PostClass>();
 
+        public Twitter()
+        {
+            this.Configuration = TwitterConfiguration.DefaultConfiguration();
+        }
+
         public TwitterApiAccessLevel AccessLevel
         {
             get
@@ -2502,10 +2509,15 @@ namespace OpenTween
         }
 
         /// <summary>
-        /// t.co の文字列長などの設定情報を取得します
+        /// t.co の文字列長などの設定情報を更新します
         /// </summary>
         /// <exception cref="WebApiException"/>
-        public TwitterConfiguration ConfigurationApi()
+        public void RefreshConfiguration()
+        {
+            this.Configuration = this.ConfigurationApi();
+        }
+
+        private TwitterConfiguration ConfigurationApi()
         {
             HttpStatusCode res;
             var content = "";