OSDN Git Service

TweetPrvPanelに対する設定値の設定・取得を LoadConfing/SaveConfig メソッドに移動
[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
120         /// <summary>
121         /// 起動時読み込み分を既読にするか。trueなら既読として処理
122         /// </summary>
123         public bool Read = true;
124
125         public bool ListLock = false;
126         public MyCommon.IconSizes IconSize = MyCommon.IconSizes.Icon16;
127         public bool NewAllPop = true;
128         public bool EventNotifyEnabled = true;
129         public MyCommon.EVENTTYPE EventNotifyFlag = MyCommon.EVENTTYPE.All;
130         public MyCommon.EVENTTYPE IsMyEventNotifyFlag = MyCommon.EVENTTYPE.All;
131         public bool ForceEventNotify = false;
132         public bool FavEventUnread = true;
133         public string TranslateLanguage = Properties.Resources.TranslateDefaultLanguage;
134         public string EventSoundFile = "";
135         public bool PlaySound = false;
136         public bool UnreadManage = true;
137
138         /// <summary>
139         /// 片思い表示。trueなら片思い表示する
140         /// </summary>
141         public bool OneWayLove = true;
142
143         public MyCommon.NameBalloonEnum NameBalloon = MyCommon.NameBalloonEnum.NickName;
144         public bool PostCtrlEnter = false;
145         public bool PostShiftEnter = false;
146         public int CountApi = 60;
147         public int CountApiReply = 40;
148         public bool PostAndGet = true;
149         public bool DispUsername = false;
150         public bool MinimizeToTray = false;
151         public bool CloseToExit = false;
152         public MyCommon.DispTitleEnum DispLatestPost = MyCommon.DispTitleEnum.Post;
153         public bool SortOrderLock = false;
154
155         /// <summary>
156         /// タブを下部に表示するかどうか
157         /// </summary>
158         public bool ViewTabBottom = true;
159
160         public bool TinyUrlResolve = true;
161         public bool StartupVersion = true;
162         public bool StartupFollowers = true;
163         public bool RestrictFavCheck = false;
164         public bool AlwaysTop = false;
165         public string CultureCode = "";
166         public bool UrlConvertAuto = false;
167         public int SortColumn = 3;
168         public int SortOrder = 1;
169         public bool IsMonospace = false;
170         public bool ReadOldPosts = false;
171         public string Language = "OS";
172         public bool Nicoms = false;
173         public List<string> HashTags = new List<string>();
174         public string HashSelected = "";
175         public bool HashIsPermanent = false;
176         public bool HashIsHead = false;
177         public bool HashIsNotAddToAtReply = true;
178         public bool PreviewEnable = true;
179         public bool StatusAreaAtBottom = true;
180
181         public MyCommon.UrlConverter AutoShortUrlFirst = MyCommon.UrlConverter.Uxnu;
182         public bool UseUnreadStyle = true;
183         public string DateTimeFormat = "yyyy/MM/dd H:mm:ss";
184         public int DefaultTimeOut = 20;
185         public bool RetweetNoConfirm = false;
186         public bool LimitBalloon = false;
187         public bool TabIconDisp = true;
188         public MyCommon.REPLY_ICONSTATE ReplyIconState = MyCommon.REPLY_ICONSTATE.StaticIcon;
189         public bool WideSpaceConvert = true;
190         public bool ReadOwnPost = false;
191         public bool GetFav = true;
192         public string BilyUser = "";
193         public string BitlyPwd = "";
194         public bool ShowGrid = false;
195         public bool UseAtIdSupplement = true;
196         public bool UseHashSupplement = true;
197         public string TwitterUrl = "api.twitter.com";
198         public bool HotkeyEnabled = false;
199         public Keys HotkeyModifier = Keys.None;
200         public Keys HotkeyKey = Keys.None;
201         public int HotkeyValue = 0;
202         public bool BlinkNewMentions = false;
203         public bool FocusLockToStatusText = false;
204         public bool UseAdditionalCount = false;
205         public int MoreCountApi = 200;
206         public int FirstCountApi = 100;
207         public int SearchCountApi = 100;
208         public int FavoritesCountApi = 40;
209         public string TrackWord = "";
210         public bool AllAtReply = false;
211         public bool UserstreamStartup = true;
212         public int UserstreamPeriod = 0;
213         public int UserTimelineCountApi = 20;
214         public int UserTimelinePeriod = 600;
215         public bool OpenUserTimeline = true;
216         public int ListCountApi = 100;
217         public int UseImageService = 0;
218         public string UseImageServiceName = "";
219         public int ListDoubleClickAction = 0;
220         public string UserAppointUrl = "";
221         public bool HideDuplicatedRetweets = false;
222         public bool EnableImgAzyobuziNet = true;
223         public bool ImgAzyobuziNetDisabledInDM = true;
224         public int MapThumbnailHeight = 200;
225         public int MapThumbnailWidth = 200;
226         public int MapThumbnailZoom = 15;
227         public MapProvider MapThumbnailProvider = MapProvider.OpenStreetMap;
228         public bool IsListsIncludeRts = false;
229         public bool TabMouseLock = false;
230         public bool IsRemoveSameEvent = false;
231         public bool IsUseNotifyGrowl = false;
232     }
233
234     public class UserAccount
235     {
236         public string Username = "";
237         public long UserId = 0;
238         public string Token = "";
239         [XmlIgnore]
240         public string TokenSecret = "";
241         public string EncryptTokenSecret
242         {
243             get { return Encrypt(TokenSecret); }
244             set { TokenSecret = Decrypt(value); }
245         }
246         private string Encrypt(string password)
247         {
248             if (String.IsNullOrEmpty(password)) password = "";
249             if (password.Length > 0)
250             {
251                 try
252                 {
253                     return MyCommon.EncryptString(password);
254                 }
255                 catch (Exception)
256                 {
257                     return "";
258                 }
259             }
260             else
261             {
262                 return "";
263             }
264         }
265         private string Decrypt(string password)
266         {
267             if (String.IsNullOrEmpty(password)) password = "";
268             if (password.Length > 0)
269             {
270                 try
271                 {
272                     password = MyCommon.DecryptString(password);
273                 }
274                 catch (Exception)
275                 {
276                     password = "";
277                 }
278             }
279             return password;
280         }
281         public override string ToString()
282         {
283             return this.Username;
284         }
285     }
286 }