OSDN Git Service

Merge branch 'bitly-oauth2'
[opentween/open-tween.git] / OpenTween / Setting / SettingCommon.cs
1 // OpenTween - Client of Twitter
2 // Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 //           (c) 2008-2011 Moz (@syo68k)
4 //           (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 //           (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 //           (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
7 //           (c) 2011      kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
8 // All rights reserved.
9 // 
10 // This file is part of OpenTween.
11 // 
12 // This program is free software; you can redistribute it and/or modify it
13 // under the terms of the GNU General Public License as published by the Free
14 // Software Foundation; either version 3 of the License, or (at your option)
15 // any later version.
16 // 
17 // This program is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 // for more details. 
21 // 
22 // You should have received a copy of the GNU General Public License along
23 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
24 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
25 // Boston, MA 02110-1301, USA.
26
27 using System;
28 using System.Xml.Serialization;
29 using System.Collections.Generic;
30 using System.Windows.Forms;
31 using OpenTween.Thumbnail;
32
33 namespace OpenTween
34 {
35     public class SettingCommon : SettingBase<SettingCommon>
36     {
37         #region "Settingクラス基本"
38         public static SettingCommon Load()
39         {
40             return LoadSettings();
41         }
42
43         public void Save()
44         {
45             SaveSettings(this);
46         }
47         #endregion
48
49         public List<UserAccount> UserAccounts;
50         public string UserName = "";
51
52         [XmlIgnore]
53         public string Password = "";
54         public string EncryptPassword
55         {
56             get => Encrypt(Password);
57             set => Password = Decrypt(value);
58         }
59
60         public string Token = "";
61         [XmlIgnore]
62         public string TokenSecret = "";
63         public string EncryptTokenSecret
64         {
65             get => Encrypt(TokenSecret);
66             set => TokenSecret = Decrypt(value);
67         }
68
69         private string Encrypt(string password)
70         {
71             if (String.IsNullOrEmpty(password)) password = "";
72             if (password.Length > 0)
73             {
74                 try
75                 {
76                     return MyCommon.EncryptString(password);
77                 }
78                 catch (Exception)
79                 {
80                     return "";
81                 }
82             }
83             else
84             {
85                 return "";
86             }
87         }
88         private string Decrypt(string password)
89         {
90             if (String.IsNullOrEmpty(password)) password = "";
91             if (password.Length > 0)
92             {
93                 try
94                 {
95                     password = MyCommon.DecryptString(password);
96                 }
97                 catch (Exception)
98                 {
99                     password = "";
100                 }
101             }
102             return password;
103         }
104
105         public long UserId = 0;
106         public List<string> TabList;
107         public int TimelinePeriod = 90;
108         public int ReplyPeriod = 180;
109         public int DMPeriod = 600;
110         public int PubSearchPeriod = 180;
111         public int ListsPeriod = 180;
112
113         /// <summary>
114         /// 起動時読み込み分を既読にするか。trueなら既読として処理
115         /// </summary>
116         public bool Read = true;
117
118         public bool ListLock = false;
119         public MyCommon.IconSizes IconSize = MyCommon.IconSizes.Icon16;
120         public bool NewAllPop = true;
121         public bool EventNotifyEnabled = true;
122         public MyCommon.EVENTTYPE EventNotifyFlag = MyCommon.EVENTTYPE.All;
123         public MyCommon.EVENTTYPE IsMyEventNotifyFlag = MyCommon.EVENTTYPE.All;
124         public bool ForceEventNotify = false;
125         public bool FavEventUnread = true;
126         public string TranslateLanguage = Properties.Resources.TranslateDefaultLanguage;
127         public string EventSoundFile = "";
128
129         /// <summary>
130         /// サウンド再生(タブ別設定より優先)
131         /// </summary>
132         public bool PlaySound = false;
133
134         /// <summary>
135         /// 未読管理。trueなら未読管理する
136         /// </summary>
137         public bool UnreadManage = true;
138
139         /// <summary>
140         /// 片思い表示。trueなら片思い表示する
141         /// </summary>
142         public bool OneWayLove = true;
143
144         public MyCommon.NameBalloonEnum NameBalloon = MyCommon.NameBalloonEnum.NickName;
145         public bool PostCtrlEnter = false;
146         public bool PostShiftEnter = false;
147         public int CountApi = 60;
148         public int CountApiReply = 40;
149         public bool PostAndGet = true;
150         public bool DispUsername = false;
151         public bool MinimizeToTray = false;
152         public bool CloseToExit = false;
153         public MyCommon.DispTitleEnum DispLatestPost = MyCommon.DispTitleEnum.Post;
154         public bool SortOrderLock = false;
155
156         /// <summary>
157         /// タブを下部に表示するかどうか
158         /// </summary>
159         public bool ViewTabBottom = true;
160
161         public bool TinyUrlResolve = true;
162         public bool StartupVersion = true;
163         public bool StartupFollowers = true;
164         public bool RestrictFavCheck = false;
165         public bool AlwaysTop = false;
166         public string CultureCode = "";
167         public bool UrlConvertAuto = false;
168         public int SortColumn = 3;
169         public int SortOrder = 1;
170         public bool IsMonospace = false;
171         public bool ReadOldPosts = false;
172         public string Language = "OS";
173         public bool Nicoms = false;
174         public List<string> HashTags = new List<string>();
175         public string HashSelected = "";
176         public bool HashIsPermanent = false;
177         public bool HashIsHead = false;
178         public bool HashIsNotAddToAtReply = true;
179         public bool PreviewEnable = true;
180         public bool StatusAreaAtBottom = true;
181
182         public MyCommon.UrlConverter AutoShortUrlFirst = MyCommon.UrlConverter.Uxnu;
183         public bool UseUnreadStyle = true;
184         public string DateTimeFormat = "yyyy/MM/dd H:mm:ss";
185         public int DefaultTimeOut = 20;
186
187         /// <summary>画像アップロードのタイムアウト設定 (秒)</summary>
188         public int UploadImageTimeout { get; set; } = 60;
189
190         public bool RetweetNoConfirm = false;
191         public bool LimitBalloon = false;
192         public bool TabIconDisp = true;
193         public MyCommon.REPLY_ICONSTATE ReplyIconState = MyCommon.REPLY_ICONSTATE.StaticIcon;
194         public bool WideSpaceConvert = true;
195         public bool ReadOwnPost = false;
196         public bool GetFav = true;
197         public string BilyUser = "";
198         public string BitlyPwd = "";
199
200         /// <summary>Bitly API アクセストークン</summary>
201         public string BitlyAccessToken { get; set; } = "";
202
203         public bool ShowGrid = false;
204         public bool UseAtIdSupplement = true;
205         public bool UseHashSupplement = true;
206
207         [XmlElement(ElementName = "TwitterUrl")]
208         public string TwitterApiHost = "api.twitter.com";
209
210         public bool HotkeyEnabled = false;
211         public Keys HotkeyModifier = Keys.None;
212         public Keys HotkeyKey = Keys.None;
213         public int HotkeyValue = 0;
214         public bool BlinkNewMentions = false;
215         public bool FocusLockToStatusText = false;
216         public bool UseAdditionalCount = false;
217         public int MoreCountApi = 200;
218         public int FirstCountApi = 100;
219         public int SearchCountApi = 100;
220         public int FavoritesCountApi = 40;
221         public string TrackWord = "";
222         public bool AllAtReply = false;
223         public bool UserstreamStartup = true;
224         public int UserstreamPeriod = 0;
225         public int UserTimelineCountApi = 20;
226         public int UserTimelinePeriod = 600;
227         public bool OpenUserTimeline = true;
228         public int ListCountApi = 100;
229         public int UseImageService = 0;
230         public string UseImageServiceName = "";
231         public int ListDoubleClickAction = 0;
232         public string UserAppointUrl = "";
233         public bool HideDuplicatedRetweets = false;
234         public bool EnableImgAzyobuziNet = true;
235         public bool ImgAzyobuziNetDisabledInDM = true;
236         public int MapThumbnailHeight = 200;
237         public int MapThumbnailWidth = 200;
238         public int MapThumbnailZoom = 15;
239         public MapProvider MapThumbnailProvider = MapProvider.OpenStreetMap;
240         public bool IsListsIncludeRts = false;
241         public bool TabMouseLock = false;
242         public bool IsRemoveSameEvent = false;
243         public bool IsUseNotifyGrowl = false;
244         public bool ForceIPv4 = false;
245         public bool ErrorReportAnonymous = true;
246
247         /// <summary>pic.twitter.com への画像アップロード時に JPEG への変換を回避する</summary>
248         public bool AlphaPNGWorkaround { get; set; } = false;
249     }
250
251     public class UserAccount
252     {
253         public string Username = "";
254         public long UserId = 0;
255         public string Token = "";
256         [XmlIgnore]
257         public string TokenSecret = "";
258         public string EncryptTokenSecret
259         {
260             get => Encrypt(TokenSecret);
261             set => TokenSecret = Decrypt(value);
262         }
263         private string Encrypt(string password)
264         {
265             if (String.IsNullOrEmpty(password)) password = "";
266             if (password.Length > 0)
267             {
268                 try
269                 {
270                     return MyCommon.EncryptString(password);
271                 }
272                 catch (Exception)
273                 {
274                     return "";
275                 }
276             }
277             else
278             {
279                 return "";
280             }
281         }
282         private string Decrypt(string password)
283         {
284             if (String.IsNullOrEmpty(password)) password = "";
285             if (password.Length > 0)
286             {
287                 try
288                 {
289                     password = MyCommon.DecryptString(password);
290                 }
291                 catch (Exception)
292                 {
293                     password = "";
294                 }
295             }
296             return password;
297         }
298         public override string ToString()
299         {
300             return this.Username;
301         }
302     }
303 }