OSDN Git Service

AppendSettingDialog.Instanceの代替としてSettingCommon.Instanceから設定値を取得できるようにする
[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         public static SettingCommon Instance { get; internal set; }
38
39         static SettingCommon()
40         {
41             Instance = new SettingCommon();
42         }
43
44         #region "Settingクラス基本"
45         public static SettingCommon Load()
46         {
47             return LoadSettings();
48         }
49
50         public void Save()
51         {
52             SaveSettings(this);
53         }
54         #endregion
55
56         public List<UserAccount> UserAccounts;
57         public string UserName = "";
58
59         [XmlIgnore]
60         public string Password = "";
61         public string EncryptPassword
62         {
63             get { return Encrypt(Password); }
64             set { Password = Decrypt(value); }
65         }
66
67         public string Token = "";
68         [XmlIgnore]
69         public string TokenSecret = "";
70         public string EncryptTokenSecret
71         {
72             get { return Encrypt(TokenSecret); }
73             set { TokenSecret = Decrypt(value); }
74         }
75
76         private string Encrypt(string password)
77         {
78             if (String.IsNullOrEmpty(password)) password = "";
79             if (password.Length > 0)
80             {
81                 try
82                 {
83                     return MyCommon.EncryptString(password);
84                 }
85                 catch (Exception)
86                 {
87                     return "";
88                 }
89             }
90             else
91             {
92                 return "";
93             }
94         }
95         private string Decrypt(string password)
96         {
97             if (String.IsNullOrEmpty(password)) password = "";
98             if (password.Length > 0)
99             {
100                 try
101                 {
102                     password = MyCommon.DecryptString(password);
103                 }
104                 catch (Exception)
105                 {
106                     password = "";
107                 }
108             }
109             return password;
110         }
111
112         public long UserId = 0;
113         public List<string> TabList;
114         public int TimelinePeriod = 90;
115         public int ReplyPeriod = 180;
116         public int DMPeriod = 600;
117         public int PubSearchPeriod = 180;
118         public int ListsPeriod = 180;
119         public bool Read = true;
120         public bool ListLock = false;
121         public MyCommon.IconSizes IconSize = MyCommon.IconSizes.Icon16;
122         public bool NewAllPop = true;
123         public bool EventNotifyEnabled = true;
124         public MyCommon.EVENTTYPE EventNotifyFlag = MyCommon.EVENTTYPE.All;
125         public MyCommon.EVENTTYPE IsMyEventNotifyFlag = MyCommon.EVENTTYPE.All;
126         public bool ForceEventNotify = false;
127         public bool FavEventUnread = true;
128         public string TranslateLanguage = Properties.Resources.TranslateDefaultLanguage;
129         public string EventSoundFile = "";
130         public bool PlaySound = false;
131         public bool UnreadManage = true;
132         public bool OneWayLove = true;
133         public MyCommon.NameBalloonEnum NameBalloon = MyCommon.NameBalloonEnum.NickName;
134         public bool PostCtrlEnter = false;
135         public bool PostShiftEnter = false;
136         public int CountApi = 60;
137         public int CountApiReply = 40;
138         public bool PostAndGet = true;
139         public bool DispUsername = false;
140         public bool MinimizeToTray = false;
141         public bool CloseToExit = false;
142         public MyCommon.DispTitleEnum DispLatestPost = MyCommon.DispTitleEnum.Post;
143         public bool SortOrderLock = false;
144
145         /// <summary>
146         /// タブを下部に表示するかどうか
147         /// </summary>
148         public bool ViewTabBottom = true;
149
150         public bool TinyUrlResolve = true;
151         public bool StartupVersion = true;
152         public bool StartupFollowers = true;
153         public bool RestrictFavCheck = false;
154         public bool AlwaysTop = false;
155         public string CultureCode = "";
156         public bool UrlConvertAuto = false;
157         public int SortColumn = 3;
158         public int SortOrder = 1;
159         public bool IsMonospace = false;
160         public bool ReadOldPosts = false;
161         public string Language = "OS";
162         public bool Nicoms = false;
163         public List<string> HashTags = new List<string>();
164         public string HashSelected = "";
165         public bool HashIsPermanent = false;
166         public bool HashIsHead = false;
167         public bool HashIsNotAddToAtReply = true;
168         public bool PreviewEnable = true;
169         public bool StatusAreaAtBottom = true;
170
171         public MyCommon.UrlConverter AutoShortUrlFirst = MyCommon.UrlConverter.Uxnu;
172         public bool UseUnreadStyle = true;
173         public string DateTimeFormat = "yyyy/MM/dd H:mm:ss";
174         public int DefaultTimeOut = 20;
175         public bool RetweetNoConfirm = false;
176         public bool LimitBalloon = false;
177         public bool TabIconDisp = true;
178         public MyCommon.REPLY_ICONSTATE ReplyIconState = MyCommon.REPLY_ICONSTATE.StaticIcon;
179         public bool WideSpaceConvert = true;
180         public bool ReadOwnPost = false;
181         public bool GetFav = true;
182         public string BilyUser = "";
183         public string BitlyPwd = "";
184         public bool ShowGrid = false;
185         public bool UseAtIdSupplement = true;
186         public bool UseHashSupplement = true;
187         public string TwitterUrl = "api.twitter.com";
188         public bool HotkeyEnabled = false;
189         public Keys HotkeyModifier = Keys.None;
190         public Keys HotkeyKey = Keys.None;
191         public int HotkeyValue = 0;
192         public bool BlinkNewMentions = false;
193         public bool FocusLockToStatusText = false;
194         public bool UseAdditionalCount = false;
195         public int MoreCountApi = 200;
196         public int FirstCountApi = 100;
197         public int SearchCountApi = 100;
198         public int FavoritesCountApi = 40;
199         public string TrackWord = "";
200         public bool AllAtReply = false;
201         public bool UserstreamStartup = true;
202         public int UserstreamPeriod = 0;
203         public int UserTimelineCountApi = 20;
204         public int UserTimelinePeriod = 600;
205         public bool OpenUserTimeline = true;
206         public int ListCountApi = 100;
207         public int UseImageService = 0;
208         public string UseImageServiceName = "";
209         public int ListDoubleClickAction = 0;
210         public string UserAppointUrl = "";
211         public bool HideDuplicatedRetweets = false;
212         public bool EnableImgAzyobuziNet = true;
213         public bool ImgAzyobuziNetDisabledInDM = true;
214         public int MapThumbnailHeight = 200;
215         public int MapThumbnailWidth = 200;
216         public int MapThumbnailZoom = 15;
217         public MapProvider MapThumbnailProvider = MapProvider.OpenStreetMap;
218         public bool IsListsIncludeRts = false;
219         public bool TabMouseLock = false;
220         public bool IsRemoveSameEvent = false;
221         public bool IsUseNotifyGrowl = false;
222     }
223
224     public class UserAccount
225     {
226         public string Username = "";
227         public long UserId = 0;
228         public string Token = "";
229         [XmlIgnore]
230         public string TokenSecret = "";
231         public string EncryptTokenSecret
232         {
233             get { return Encrypt(TokenSecret); }
234             set { TokenSecret = Decrypt(value); }
235         }
236         private string Encrypt(string password)
237         {
238             if (String.IsNullOrEmpty(password)) password = "";
239             if (password.Length > 0)
240             {
241                 try
242                 {
243                     return MyCommon.EncryptString(password);
244                 }
245                 catch (Exception)
246                 {
247                     return "";
248                 }
249             }
250             else
251             {
252                 return "";
253             }
254         }
255         private string Decrypt(string password)
256         {
257             if (String.IsNullOrEmpty(password)) password = "";
258             if (password.Length > 0)
259             {
260                 try
261                 {
262                     password = MyCommon.DecryptString(password);
263                 }
264                 catch (Exception)
265                 {
266                     password = "";
267                 }
268             }
269             return password;
270         }
271         public override string ToString()
272         {
273             return this.Username;
274         }
275     }
276 }