OpenTweenのfork
修订版 | 2e071159cebdcf934eafa43ba76731e929014cac (tree) |
---|---|
时间 | 2012-02-18 23:11:09 |
作者 | kiri_feather <kiri_feather@user...> |
Commiter | Kimura Youichi |
0881開発版。OAuth(xAuth)対応。URL検出正規表現修正。
git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@116 e39ad16e-3079-482e-bb30-4b4d378143b6
@@ -56,7 +56,7 @@ Public Class HttpConnection | ||
56 | 56 | '''<returns>引数で指定された内容を反映したHttpWebRequestオブジェクト</returns> |
57 | 57 | Protected Function CreateRequest(ByVal method As RequestMethod, _ |
58 | 58 | ByVal requestUri As Uri, _ |
59 | - ByVal param As SortedList(Of String, String), _ | |
59 | + ByVal param As Dictionary(Of String, String), _ | |
60 | 60 | ByVal withCookie As Boolean _ |
61 | 61 | ) As HttpWebRequest |
62 | 62 | If Not isInitialize Then Throw New Exception("Sequence error.(not initialized)") |
@@ -166,7 +166,7 @@ Public Class HttpConnection | ||
166 | 166 | End Function |
167 | 167 | |
168 | 168 | Protected Function GetResponse(ByVal webRequest As HttpWebRequest, _ |
169 | - ByVal contentBitmap As Bitmap, _ | |
169 | + ByRef contentBitmap As Bitmap, _ | |
170 | 170 | ByVal headerInfo As Dictionary(Of String, String), _ |
171 | 171 | ByVal withCookie As Boolean _ |
172 | 172 | ) As HttpStatusCode |
@@ -251,7 +251,7 @@ Public Class HttpConnection | ||
251 | 251 | '''クエリコレクションをkey=value形式の文字列に構成して戻す |
252 | 252 | '''</summary> |
253 | 253 | '''<param name="param">クエリ、またはポストデータとなるkey-valueコレクション</param> |
254 | - Protected Function CreateQueryString(ByVal param As SortedList(Of String, String)) As String | |
254 | + Protected Function CreateQueryString(ByVal param As IDictionary(Of String, String)) As String | |
255 | 255 | If param Is Nothing OrElse param.Count = 0 Then Return String.Empty |
256 | 256 | |
257 | 257 | Dim query As New StringBuilder |
@@ -10,7 +10,7 @@ Public Class HttpConnectionApi | ||
10 | 10 | |
11 | 11 | Protected Function GetContent(ByVal method As RequestMethod, _ |
12 | 12 | ByVal requestUri As Uri, _ |
13 | - ByVal param As SortedList(Of String, String), _ | |
13 | + ByVal param As Dictionary(Of String, String), _ | |
14 | 14 | ByRef content As String, _ |
15 | 15 | ByVal headerInfo As Dictionary(Of String, String), _ |
16 | 16 | ByVal authRequired As Boolean) As HttpStatusCode |
@@ -21,24 +21,24 @@ Public Class HttpConnectionOAuth | ||
21 | 21 | '''<summary> |
22 | 22 | '''OAuthのアクセストークン。永続化可能(ユーザー取り消しの可能性はある)。 |
23 | 23 | '''</summary> |
24 | - Private Shared token As String = "" | |
24 | + Private token As String = "" | |
25 | 25 | |
26 | 26 | '''<summary> |
27 | 27 | '''OAuthの署名作成用秘密アクセストークン。永続化可能(ユーザー取り消しの可能性はある)。 |
28 | 28 | '''</summary> |
29 | - Private Shared tokenSecret As String = "" | |
29 | + Private tokenSecret As String = "" | |
30 | 30 | |
31 | 31 | '''<summary> |
32 | 32 | '''OAuthのコンシューマー鍵 |
33 | 33 | '''</summary> |
34 | - Private Shared consumerKey As String | |
34 | + Private consumerKey As String | |
35 | 35 | |
36 | 36 | '''<summary> |
37 | 37 | '''OAuthの署名作成用秘密コンシューマーデータ |
38 | 38 | '''</summary> |
39 | - Private Shared consumerSecret As String | |
39 | + Private consumerSecret As String | |
40 | 40 | |
41 | - Private Shared authorizedUsername As String | |
41 | + Private authorizedUsername As String | |
42 | 42 | '''<summary> |
43 | 43 | '''HTTP通信してコンテンツを取得する(文字列コンテンツ) |
44 | 44 | '''</summary> |
@@ -55,7 +55,7 @@ Public Class HttpConnectionOAuth | ||
55 | 55 | '''<returns>通信結果のHttpStatusCode</returns> |
56 | 56 | Protected Function GetContent(ByVal method As RequestMethod, _ |
57 | 57 | ByVal requestUri As Uri, _ |
58 | - ByVal param As SortedList(Of String, String), _ | |
58 | + ByVal param As Dictionary(Of String, String), _ | |
59 | 59 | ByRef content As String, _ |
60 | 60 | ByVal headerInfo As Dictionary(Of String, String)) As HttpStatusCode |
61 | 61 | '認証済かチェック |
@@ -76,22 +76,21 @@ Public Class HttpConnectionOAuth | ||
76 | 76 | End Function |
77 | 77 | |
78 | 78 | #Region "認証処理" |
79 | - Protected Function AuthorizePinFlow(ByVal requestTokenUrl As String, _ | |
80 | - ByVal accessTokenUrl As String, _ | |
81 | - ByVal authorizeUrl As String) As Boolean | |
79 | + Protected Function AuthorizePinFlowRequest(ByVal requestTokenUrl As String, _ | |
80 | + ByVal authorizeUrl As String, _ | |
81 | + ByRef requestToken As String, _ | |
82 | + ByRef authUri As Uri) As Boolean | |
82 | 83 | 'PIN-based flow |
83 | - Dim requestToken As String = "" | |
84 | - Dim authUri As Uri = GetAuthorizePageUri(requestTokenUrl, authorizeUrl, requestToken) | |
84 | + authUri = GetAuthorizePageUri(requestTokenUrl, authorizeUrl, requestToken) | |
85 | 85 | If authUri Is Nothing Then Return False |
86 | - System.Diagnostics.Process.Start(authUri.PathAndQuery) 'ブラウザで表示 | |
87 | - Dim inputForm As New InputTabName | |
88 | - inputForm.FormTitle = "Input PIN code" | |
89 | - inputForm.FormDescription = "Input the PIN code shown in the browser after you accept OAuth request." | |
90 | - If inputForm.ShowDialog() = DialogResult.OK AndAlso Not String.IsNullOrEmpty(inputForm.TabName) Then | |
91 | - Return GetAccessToken(accessTokenUrl, inputForm.TabName, requestToken) | |
92 | - Else | |
93 | - Return False | |
94 | - End If | |
86 | + Return True | |
87 | + End Function | |
88 | + | |
89 | + Protected Function AuthorizePinFlow(ByVal accessTokenUrl As String, _ | |
90 | + ByVal requestToken As String, _ | |
91 | + ByVal pinCode As String) As Boolean | |
92 | + 'PIN-based flow | |
93 | + Return GetAccessToken(accessTokenUrl, pinCode, requestToken) | |
95 | 94 | End Function |
96 | 95 | |
97 | 96 | Protected Function AuthorizeXAuth(ByVal url As String, ByVal username As String, ByVal password As String) As Boolean |
@@ -99,40 +98,29 @@ Public Class HttpConnectionOAuth | ||
99 | 98 | If String.IsNullOrEmpty(username) OrElse String.IsNullOrEmpty(password) Then |
100 | 99 | Throw New Exception("Sequence error.(username or password is blank)") |
101 | 100 | End If |
102 | - Dim reqUri As New Uri(url) | |
103 | - Dim parameter As New SortedList(Of String, String) | |
101 | + Dim parameter As New Dictionary(Of String, String) | |
104 | 102 | parameter.Add("x_auth_mode", "client_auth") |
105 | 103 | parameter.Add("x_auth_username", username) |
106 | 104 | parameter.Add("x_auth_password", password) |
107 | 105 | |
108 | - webReq = CreateRequest(RequestMethod.ReqPost, reqUri, parameter, False) | |
106 | + Dim accessTokenData As NameValueCollection = GetOAuthToken(New Uri(url), "", "", parameter) | |
109 | 107 | |
110 | - AppendOAuthInfo(webReq, parameter, "", "") | |
111 | - | |
112 | - Try | |
113 | - Dim status As HttpStatusCode | |
114 | - Dim contentText As String = "" | |
115 | - status = GetResponse(webReq, contentText, Nothing, False) | |
116 | - If status = HttpStatusCode.OK Then | |
117 | - Dim tokenData As NameValueCollection = ParseQueryString(contentText) | |
118 | - token = tokenData.Item("oauth_token") | |
119 | - tokenSecret = tokenData.Item("oauth_token_secret") | |
120 | - ''' TODO:その他情報も格納するか検討(user_idなど) | |
121 | - If token = "" Then Return False | |
122 | - Return True | |
123 | - Else | |
124 | - Return False | |
125 | - End If | |
126 | - Catch ex As Exception | |
108 | + If accessTokenData IsNot Nothing Then | |
109 | + token = accessTokenData.Item("oauth_token") | |
110 | + tokenSecret = accessTokenData.Item("oauth_token_secret") | |
111 | + authorizedUsername = accessTokenData.Item("screen_name") | |
112 | + If token = "" Then Return False | |
113 | + Return True | |
114 | + Else | |
127 | 115 | Return False |
128 | - End Try | |
116 | + End If | |
129 | 117 | End Function |
130 | 118 | |
131 | 119 | Private Function GetAuthorizePageUri(ByVal requestTokenUrl As String, _ |
132 | 120 | ByVal authorizeUrl As String, _ |
133 | 121 | ByRef requestToken As String) As Uri |
134 | 122 | Const tokenKey As String = "oauth_token" |
135 | - Dim reqTokenData As NameValueCollection = GetOAuthToken(New Uri(requestTokenUrl), "", "") | |
123 | + Dim reqTokenData As NameValueCollection = GetOAuthToken(New Uri(requestTokenUrl), "", "", Nothing) | |
136 | 124 | If reqTokenData IsNot Nothing Then |
137 | 125 | requestToken = reqTokenData.Item(tokenKey) |
138 | 126 | Dim ub As New UriBuilder(authorizeUrl) |
@@ -146,7 +134,7 @@ Public Class HttpConnectionOAuth | ||
146 | 134 | Private Function GetAccessToken(ByVal accessTokenUrl As String, ByVal pinCode As String, ByVal requestToken As String) As Boolean |
147 | 135 | If String.IsNullOrEmpty(requestToken) Then Throw New Exception("Sequence error.(requestToken is blank)") |
148 | 136 | |
149 | - Dim accessTokenData As NameValueCollection = GetOAuthToken(New Uri(accessTokenUrl), pinCode, requestToken) | |
137 | + Dim accessTokenData As NameValueCollection = GetOAuthToken(New Uri(accessTokenUrl), pinCode, requestToken, Nothing) | |
150 | 138 | |
151 | 139 | If accessTokenData IsNot Nothing Then |
152 | 140 | token = accessTokenData.Item("oauth_token") |
@@ -158,14 +146,19 @@ Public Class HttpConnectionOAuth | ||
158 | 146 | End If |
159 | 147 | End Function |
160 | 148 | |
161 | - Private Function GetOAuthToken(ByVal requestUri As Uri, ByVal pinCode As String, ByVal requestToken As String) As NameValueCollection | |
149 | + Private Function GetOAuthToken(ByVal requestUri As Uri, ByVal pinCode As String, ByVal requestToken As String, ByVal parameter As Dictionary(Of String, String)) As NameValueCollection | |
162 | 150 | Dim webReq As HttpWebRequest = Nothing |
163 | - If String.IsNullOrEmpty(pinCode) Then | |
151 | + If String.IsNullOrEmpty(pinCode) AndAlso parameter Is Nothing Then | |
164 | 152 | webReq = CreateRequest(RequestMethod.ReqGet, requestUri, Nothing, False) |
165 | 153 | Else |
166 | - webReq = CreateRequest(RequestMethod.ReqPost, requestUri, Nothing, False) | |
154 | + webReq = CreateRequest(RequestMethod.ReqPost, requestUri, parameter, False) | |
155 | + End If | |
156 | + Dim query As New Dictionary(Of String, String) | |
157 | + If parameter IsNot Nothing Then | |
158 | + For Each kvp As KeyValuePair(Of String, String) In parameter | |
159 | + query.Add(kvp.Key, kvp.Value) | |
160 | + Next | |
167 | 161 | End If |
168 | - Dim query As New SortedList(Of String, String) | |
169 | 162 | If Not String.IsNullOrEmpty(pinCode) Then query.Add("oauth_verifier", pinCode) |
170 | 163 | AppendOAuthInfo(webReq, query, requestToken, "") |
171 | 164 | Try |
@@ -185,10 +178,10 @@ Public Class HttpConnectionOAuth | ||
185 | 178 | |
186 | 179 | #Region "OAuth認証用ヘッダ作成・付加処理" |
187 | 180 | Private Sub AppendOAuthInfo(ByVal webRequest As HttpWebRequest, _ |
188 | - ByVal query As SortedList(Of String, String), _ | |
181 | + ByVal query As Dictionary(Of String, String), _ | |
189 | 182 | ByVal token As String, _ |
190 | 183 | ByVal tokenSecret As String) |
191 | - Dim parameter As SortedList(Of String, String) = GetOAuthParameter(token) | |
184 | + Dim parameter As Dictionary(Of String, String) = GetOAuthParameter(token) | |
192 | 185 | If query IsNot Nothing Then |
193 | 186 | For Each item As KeyValuePair(Of String, String) In query |
194 | 187 | parameter.Add(item.Key, item.Value) |
@@ -204,8 +197,8 @@ Public Class HttpConnectionOAuth | ||
204 | 197 | webRequest.Headers.Add(HttpRequestHeader.Authorization, sb.ToString) |
205 | 198 | End Sub |
206 | 199 | |
207 | - Private Function GetOAuthParameter(ByVal token As String) As SortedList(Of String, String) | |
208 | - Dim parameter As New SortedList(Of String, String) | |
200 | + Private Function GetOAuthParameter(ByVal token As String) As Dictionary(Of String, String) | |
201 | + Dim parameter As New Dictionary(Of String, String) | |
209 | 202 | parameter.Add("oauth_consumer_key", consumerKey) |
210 | 203 | parameter.Add("oauth_signature_method", "HMAC-SHA1") |
211 | 204 | parameter.Add("oauth_timestamp", GetTimestamp()) |
@@ -218,9 +211,10 @@ Public Class HttpConnectionOAuth | ||
218 | 211 | Private Function CreateSignature(ByVal tokenSecret As String, _ |
219 | 212 | ByVal method As String, _ |
220 | 213 | ByVal uri As Uri, _ |
221 | - ByVal parameter As SortedList(Of String, String) _ | |
214 | + ByVal parameter As Dictionary(Of String, String) _ | |
222 | 215 | ) As String |
223 | - Dim paramString As String = CreateQueryString(parameter) | |
216 | + Dim sorted As New SortedDictionary(Of String, String)(parameter) | |
217 | + Dim paramString As String = CreateQueryString(sorted) | |
224 | 218 | Dim url As String = String.Format("{0}://{1}{2}", uri.Scheme, uri.Host, uri.AbsolutePath) |
225 | 219 | Dim signatureBase As String = String.Format("{0}&{1}&{2}", method, UrlEncode(url), UrlEncode(paramString)) |
226 | 220 | Dim key As String = UrlEncode(consumerSecret) + "&" |
@@ -239,17 +233,17 @@ Public Class HttpConnectionOAuth | ||
239 | 233 | End Function |
240 | 234 | #End Region |
241 | 235 | |
242 | - Protected Shared Sub Initialize(ByVal consumerKeyStr As String, _ | |
236 | + Protected Sub Initialize(ByVal consumerKeyStr As String, _ | |
243 | 237 | ByVal consumerSecretStr As String, _ |
244 | 238 | ByVal accessToken As String, _ |
245 | 239 | ByVal accessTokenSecret As String) |
246 | - consumerKey = consumerKeyStr | |
247 | - consumerSecret = consumerSecretStr | |
248 | - HttpConnectionOAuth.token = accessToken | |
249 | - HttpConnectionOAuth.tokenSecret = accessTokenSecret | |
240 | + Me.consumerKey = consumerKeyStr | |
241 | + Me.consumerSecret = consumerSecretStr | |
242 | + Me.token = accessToken | |
243 | + Me.tokenSecret = accessTokenSecret | |
250 | 244 | End Sub |
251 | 245 | |
252 | - Protected Shared Sub Initialize(ByVal consumerKeyStr As String, _ | |
246 | + Protected Sub Initialize(ByVal consumerKeyStr As String, _ | |
253 | 247 | ByVal consumerSecretStr As String, _ |
254 | 248 | ByVal accessToken As String, _ |
255 | 249 | ByVal accessTokenSecret As String, _ |
@@ -258,21 +252,21 @@ Public Class HttpConnectionOAuth | ||
258 | 252 | authorizedUsername = username |
259 | 253 | End Sub |
260 | 254 | |
261 | - Protected Shared ReadOnly Property AccessToken() As String | |
255 | + Protected ReadOnly Property AccessToken() As String | |
262 | 256 | Get |
263 | - Return HttpConnectionOAuth.token | |
257 | + Return token | |
264 | 258 | End Get |
265 | 259 | End Property |
266 | 260 | |
267 | - Protected Shared ReadOnly Property AccessTokenSecret() As String | |
261 | + Protected ReadOnly Property AccessTokenSecret() As String | |
268 | 262 | Get |
269 | - Return HttpConnectionOAuth.tokenSecret | |
263 | + Return tokenSecret | |
270 | 264 | End Get |
271 | 265 | End Property |
272 | 266 | |
273 | - Protected Shared ReadOnly Property AuthUsername() As String | |
267 | + Protected ReadOnly Property AuthUsername() As String | |
274 | 268 | Get |
275 | - Return HttpConnectionOAuth.authorizedUsername | |
269 | + Return authorizedUsername | |
276 | 270 | End Get |
277 | 271 | End Property |
278 | 272 | End Class |
@@ -7,12 +7,12 @@ Public Class HttpTwitter | ||
7 | 7 | '''<summary> |
8 | 8 | '''OAuthÌRV [}[® |
9 | 9 | '''</summary> |
10 | - Private Const ConsumerKey As String = "EANjQEa5LokuVld682tTDA" | |
10 | + Private Const ConsumerKey As String = "iOQHfiCUsyOyamW8JJ8jg" | |
11 | 11 | |
12 | 12 | '''<summary> |
13 | 13 | '''OAuth̼ì¬pé§RV [}[f[^ |
14 | 14 | '''</summary> |
15 | - Private Const ConsumerSecret As String = "zXfwkzmuO6FcHtoikleV3EVgdh5vVAs6ft6ZxtYTYM" | |
15 | + Private Const ConsumerSecret As String = "5PS2oa5f2VaKMPrlZa7DTbz0aFULKd3Ojxqgsm142Dw" | |
16 | 16 | |
17 | 17 | '''<summary> |
18 | 18 | '''OAuthÌANZXg[Næ¾æURI |
@@ -29,24 +29,24 @@ Public Class HttpTwitter | ||
29 | 29 | Public Overloads Sub Initialize(ByVal accessToken As String, _ |
30 | 30 | ByVal accessTokenSecret As String, _ |
31 | 31 | ByVal username As String) |
32 | - HttpConnectionOAuth.Initialize(ConsumerKey, ConsumerSecret, accessToken, accessTokenSecret, username) | |
32 | + Initialize(ConsumerKey, ConsumerSecret, accessToken, accessTokenSecret, username) | |
33 | 33 | End Sub |
34 | 34 | |
35 | 35 | Public Overloads ReadOnly Property AccessToken() As String |
36 | 36 | Get |
37 | - Return HttpConnectionOAuth.AccessToken | |
37 | + Return MyBase.AccessToken | |
38 | 38 | End Get |
39 | 39 | End Property |
40 | 40 | |
41 | 41 | Public Overloads ReadOnly Property AccessTokenSecret() As String |
42 | 42 | Get |
43 | - Return HttpConnectionOAuth.AccessTokenSecret | |
43 | + Return MyBase.AccessTokenSecret | |
44 | 44 | End Get |
45 | 45 | End Property |
46 | 46 | |
47 | 47 | Public Overloads ReadOnly Property AuthUsername() As String |
48 | 48 | Get |
49 | - Return HttpConnectionOAuth.AuthUsername | |
49 | + Return MyBase.AuthUsername | |
50 | 50 | End Get |
51 | 51 | End Property |
52 | 52 |
@@ -55,7 +55,7 @@ Public Class HttpTwitter | ||
55 | 55 | End Function |
56 | 56 | |
57 | 57 | Public Sub ClearAuthInfo() |
58 | - HttpConnectionOAuth.Initialize(ConsumerKey, ConsumerSecret, "", "", "") | |
58 | + MyBase.Initialize(ConsumerKey, ConsumerSecret, "", "", "") | |
59 | 59 | End Sub |
60 | 60 | |
61 | 61 | Public Shared WriteOnly Property UseSsl() As Boolean |
@@ -75,10 +75,10 @@ Public Class HttpTwitter | ||
75 | 75 | End Property |
76 | 76 | |
77 | 77 | Public Function UpdateStatus(ByVal status As String, ByVal replyToId As Long, ByRef content As String) As HttpStatusCode |
78 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
78 | + If Me.AuthUsername = "" Then | |
79 | 79 | Return HttpStatusCode.Unauthorized |
80 | 80 | End If |
81 | - Dim param As New SortedList(Of String, String) | |
81 | + Dim param As New Dictionary(Of String, String) | |
82 | 82 | param.Add("status", status) |
83 | 83 | If replyToId > 0 Then param.Add("in_reply_to_status_id", replyToId.ToString) |
84 | 84 | Try |
@@ -97,7 +97,7 @@ Public Class HttpTwitter | ||
97 | 97 | End Function |
98 | 98 | |
99 | 99 | Public Function DestroyStatus(ByVal id As Long) As HttpStatusCode |
100 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
100 | + If Me.AuthUsername = "" Then | |
101 | 101 | Return HttpStatusCode.Unauthorized |
102 | 102 | End If |
103 | 103 | Try |
@@ -116,7 +116,7 @@ Public Class HttpTwitter | ||
116 | 116 | End Function |
117 | 117 | |
118 | 118 | Public Function DestroyDirectMessage(ByVal id As Long) As HttpStatusCode |
119 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
119 | + If Me.AuthUsername = "" Then | |
120 | 120 | Return HttpStatusCode.Unauthorized |
121 | 121 | End If |
122 | 122 | Try |
@@ -135,7 +135,7 @@ Public Class HttpTwitter | ||
135 | 135 | End Function |
136 | 136 | |
137 | 137 | Public Function RetweetStatus(ByVal id As Long, ByRef content As String) As HttpStatusCode |
138 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
138 | + If Me.AuthUsername = "" Then | |
139 | 139 | Return HttpStatusCode.Unauthorized |
140 | 140 | End If |
141 | 141 | Try |
@@ -154,10 +154,10 @@ Public Class HttpTwitter | ||
154 | 154 | End Function |
155 | 155 | |
156 | 156 | Public Function CreateFriendships(ByVal screenName As String) As HttpStatusCode |
157 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
157 | + If Me.AuthUsername = "" Then | |
158 | 158 | Return HttpStatusCode.Unauthorized |
159 | 159 | End If |
160 | - Dim param As New SortedList(Of String, String) | |
160 | + Dim param As New Dictionary(Of String, String) | |
161 | 161 | param.Add("screen_name", screenName) |
162 | 162 | Try |
163 | 163 | Return GetContent(RequestMethod.ReqPost, _ |
@@ -175,10 +175,10 @@ Public Class HttpTwitter | ||
175 | 175 | End Function |
176 | 176 | |
177 | 177 | Public Function DestroyFriendships(ByVal screenName As String) As HttpStatusCode |
178 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
178 | + If Me.AuthUsername = "" Then | |
179 | 179 | Return HttpStatusCode.Unauthorized |
180 | 180 | End If |
181 | - Dim param As New SortedList(Of String, String) | |
181 | + Dim param As New Dictionary(Of String, String) | |
182 | 182 | param.Add("screen_name", screenName) |
183 | 183 | Try |
184 | 184 | Return GetContent(RequestMethod.ReqPost, _ |
@@ -196,10 +196,10 @@ Public Class HttpTwitter | ||
196 | 196 | End Function |
197 | 197 | |
198 | 198 | Public Function ShowFriendships(ByVal souceScreenName As String, ByVal targetScreenName As String, ByRef content As String) As HttpStatusCode |
199 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
199 | + If Me.AuthUsername = "" Then | |
200 | 200 | Return HttpStatusCode.Unauthorized |
201 | 201 | End If |
202 | - Dim param As New SortedList(Of String, String) | |
202 | + Dim param As New Dictionary(Of String, String) | |
203 | 203 | param.Add("source_screen_name", souceScreenName) |
204 | 204 | param.Add("target_screen_name", targetScreenName) |
205 | 205 | Try |
@@ -218,7 +218,7 @@ Public Class HttpTwitter | ||
218 | 218 | End Function |
219 | 219 | |
220 | 220 | Public Function ShowStatuses(ByVal id As Long, ByRef content As String) As HttpStatusCode |
221 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
221 | + If Me.AuthUsername = "" Then | |
222 | 222 | Return HttpStatusCode.Unauthorized |
223 | 223 | End If |
224 | 224 | Try |
@@ -237,7 +237,7 @@ Public Class HttpTwitter | ||
237 | 237 | End Function |
238 | 238 | |
239 | 239 | Public Function CreateFavorites(ByVal id As Long) As HttpStatusCode |
240 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
240 | + If Me.AuthUsername = "" Then | |
241 | 241 | Return HttpStatusCode.Unauthorized |
242 | 242 | End If |
243 | 243 | Try |
@@ -256,7 +256,7 @@ Public Class HttpTwitter | ||
256 | 256 | End Function |
257 | 257 | |
258 | 258 | Public Function DestroyFavorites(ByVal id As Long) As HttpStatusCode |
259 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
259 | + If Me.AuthUsername = "" Then | |
260 | 260 | Return HttpStatusCode.Unauthorized |
261 | 261 | End If |
262 | 262 | Try |
@@ -275,10 +275,10 @@ Public Class HttpTwitter | ||
275 | 275 | End Function |
276 | 276 | |
277 | 277 | Public Function HomeTimeline(ByVal count As Integer, ByRef content As String) As HttpStatusCode |
278 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
278 | + If Me.AuthUsername = "" Then | |
279 | 279 | Return HttpStatusCode.Unauthorized |
280 | 280 | End If |
281 | - Dim param As New SortedList(Of String, String) | |
281 | + Dim param As New Dictionary(Of String, String) | |
282 | 282 | If count > 0 Then |
283 | 283 | param.Add("count", count.ToString()) |
284 | 284 | End If |
@@ -298,10 +298,10 @@ Public Class HttpTwitter | ||
298 | 298 | End Function |
299 | 299 | |
300 | 300 | Public Function Mentions(ByVal count As Integer, ByRef content As String) As HttpStatusCode |
301 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
301 | + If Me.AuthUsername = "" Then | |
302 | 302 | Return HttpStatusCode.Unauthorized |
303 | 303 | End If |
304 | - Dim param As New SortedList(Of String, String) | |
304 | + Dim param As New Dictionary(Of String, String) | |
305 | 305 | If count > 0 Then |
306 | 306 | param.Add("count", count.ToString()) |
307 | 307 | End If |
@@ -321,7 +321,7 @@ Public Class HttpTwitter | ||
321 | 321 | End Function |
322 | 322 | |
323 | 323 | Public Function DirectMessages(ByRef content As String) As HttpStatusCode |
324 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
324 | + If Me.AuthUsername = "" Then | |
325 | 325 | Return HttpStatusCode.Unauthorized |
326 | 326 | End If |
327 | 327 | Try |
@@ -340,7 +340,7 @@ Public Class HttpTwitter | ||
340 | 340 | End Function |
341 | 341 | |
342 | 342 | Public Function DirectMessagesSent(ByRef content As String) As HttpStatusCode |
343 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
343 | + If Me.AuthUsername = "" Then | |
344 | 344 | Return HttpStatusCode.Unauthorized |
345 | 345 | End If |
346 | 346 | Try |
@@ -359,10 +359,10 @@ Public Class HttpTwitter | ||
359 | 359 | End Function |
360 | 360 | |
361 | 361 | Public Function Favorites(ByVal count As Integer, ByRef content As String) As HttpStatusCode |
362 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
362 | + If Me.AuthUsername = "" Then | |
363 | 363 | Return HttpStatusCode.Unauthorized |
364 | 364 | End If |
365 | - Dim param As New SortedList(Of String, String) | |
365 | + Dim param As New Dictionary(Of String, String) | |
366 | 366 | If count <> 20 Then param.Add("count", count.ToString()) |
367 | 367 | Try |
368 | 368 | Return GetContent(RequestMethod.ReqGet, _ |
@@ -380,7 +380,7 @@ Public Class HttpTwitter | ||
380 | 380 | End Function |
381 | 381 | |
382 | 382 | Public Function Search(ByVal words As String, ByVal lang As String, ByVal rpp As Integer, ByVal page As Integer, ByRef content As String) As HttpStatusCode |
383 | - Dim param As New SortedList(Of String, String) | |
383 | + Dim param As New Dictionary(Of String, String) | |
384 | 384 | If Not String.IsNullOrEmpty(words) Then param.Add("q", words) |
385 | 385 | If Not String.IsNullOrEmpty(lang) Then param.Add("lang", lang) |
386 | 386 | If rpp > 0 Then param.Add("rpp", rpp.ToString()) |
@@ -405,10 +405,10 @@ Public Class HttpTwitter | ||
405 | 405 | End Function |
406 | 406 | |
407 | 407 | Public Function FollowerIds(ByVal cursor As Long, ByRef content As String) As HttpStatusCode |
408 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
408 | + If Me.AuthUsername = "" Then | |
409 | 409 | Return HttpStatusCode.Unauthorized |
410 | 410 | End If |
411 | - Dim param As New SortedList(Of String, String) | |
411 | + Dim param As New Dictionary(Of String, String) | |
412 | 412 | param.Add("cursor", cursor.ToString()) |
413 | 413 | Try |
414 | 414 | Return GetContent(RequestMethod.ReqGet, _ |
@@ -426,7 +426,7 @@ Public Class HttpTwitter | ||
426 | 426 | End Function |
427 | 427 | |
428 | 428 | Public Function RateLimitStatus(ByRef content As String) As HttpStatusCode |
429 | - If HttpConnectionOAuth.AuthUsername = "" Then | |
429 | + If Me.AuthUsername = "" Then | |
430 | 430 | Return HttpStatusCode.Unauthorized |
431 | 431 | End If |
432 | 432 | Try |
@@ -34,7 +34,7 @@ Public Class HttpVarious | ||
34 | 34 | End Try |
35 | 35 | End Function |
36 | 36 | |
37 | - Public Function PostData(ByVal Url As String, ByVal param As SortedList(Of String, String)) As Boolean | |
37 | + Public Function PostData(ByVal Url As String, ByVal param As Dictionary(Of String, String)) As Boolean | |
38 | 38 | Dim req As HttpWebRequest = CreateRequest(RequestMethod.ReqPost, New Uri(Url), param, False) |
39 | 39 | Try |
40 | 40 | Dim res As HttpStatusCode = Me.GetResponse(req, Nothing, False) |
@@ -45,7 +45,7 @@ Public Class HttpVarious | ||
45 | 45 | End Try |
46 | 46 | End Function |
47 | 47 | |
48 | - Public Function PostData(ByVal Url As String, ByVal param As SortedList(Of String, String), ByRef content As String) As Boolean | |
48 | + Public Function PostData(ByVal Url As String, ByVal param As Dictionary(Of String, String), ByRef content As String) As Boolean | |
49 | 49 | Dim req As HttpWebRequest = CreateRequest(RequestMethod.ReqPost, New Uri(Url), param, False) |
50 | 50 | Try |
51 | 51 | Dim res As HttpStatusCode = Me.GetResponse(req, content, Nothing, False) |
@@ -56,7 +56,7 @@ Public Class HttpVarious | ||
56 | 56 | End Try |
57 | 57 | End Function |
58 | 58 | |
59 | - Public Function GetData(ByVal Url As String, ByVal param As SortedList(Of String, String), ByRef content As String) As Boolean | |
59 | + Public Function GetData(ByVal Url As String, ByVal param As Dictionary(Of String, String), ByRef content As String) As Boolean | |
60 | 60 | Dim req As HttpWebRequest = CreateRequest(RequestMethod.ReqGet, New Uri(Url), param, False) |
61 | 61 | Try |
62 | 62 | Dim res As HttpStatusCode = Me.GetResponse(req, content, Nothing, False) |
@@ -55,5 +55,5 @@ Imports System.Runtime.InteropServices | ||
55 | 55 | ' <Assembly: AssemblyVersion("1.0.*")> |
56 | 56 | |
57 | 57 | <Assembly: AssemblyVersion("0.1.0.0")> |
58 | -<Assembly: AssemblyFileVersion("0.8.8.0")> | |
58 | +<Assembly: AssemblyFileVersion("0.8.8.1")> | |
59 | 59 |
@@ -1,7 +1,7 @@ | ||
1 | 1 | '------------------------------------------------------------------------------ |
2 | 2 | ' <auto-generated> |
3 | 3 | ' このコードはツールによって生成されました。 |
4 | -' ランタイム バージョン:2.0.50727.4927 | |
4 | +' ランタイム バージョン:2.0.50727.3603 | |
5 | 5 | ' |
6 | 6 | ' このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 |
7 | 7 | ' コードが再生成されるときに損失したりします。 |
@@ -1646,6 +1646,15 @@ Namespace My.Resources | ||
1646 | 1646 | End Property |
1647 | 1647 | |
1648 | 1648 | '''<summary> |
1649 | + ''' アカウントが認証されていません。閉じてもよろしいですか? に類似しているローカライズされた文字列を検索します。 | |
1650 | + '''</summary> | |
1651 | + Friend ReadOnly Property Setting_FormClosing1() As String | |
1652 | + Get | |
1653 | + Return ResourceManager.GetString("Setting_FormClosing1", resourceCulture) | |
1654 | + End Get | |
1655 | + End Property | |
1656 | + | |
1657 | + '''<summary> | |
1649 | 1658 | ''' まだあなたのプロフィール情報を取得していません。投稿後に再度お試しください。 に類似しているローカライズされた文字列を検索します。 |
1650 | 1659 | '''</summary> |
1651 | 1660 | Friend ReadOnly Property ShowYourProfileText1() As String |
@@ -756,4 +756,7 @@ | ||
756 | 756 | <data name="AuthorizeButton_Click4" xml:space="preserve"> |
757 | 757 | <value>Not authenticated</value> |
758 | 758 | </data> |
759 | + <data name="Setting_FormClosing1" xml:space="preserve"> | |
760 | + <value>Account is not Validated. Will you close setting dialog?</value> | |
761 | + </data> | |
759 | 762 | </root> |
\ No newline at end of file |
@@ -808,4 +808,7 @@ | ||
808 | 808 | <data name="AuthorizeButton_Click4" xml:space="preserve"> |
809 | 809 | <value>未認証</value> |
810 | 810 | </data> |
811 | + <data name="Setting_FormClosing1" xml:space="preserve"> | |
812 | + <value>アカウントが認証されていません。閉じてもよろしいですか?</value> | |
813 | + </data> | |
811 | 814 | </root> |
\ No newline at end of file |
@@ -75,7 +75,7 @@ Public Module Outputz | ||
75 | 75 | |
76 | 76 | Dim content As String = "" |
77 | 77 | Dim output As String = "http://outputz.com/api/post" |
78 | - Dim param As New SortedList(Of String, String) | |
78 | + Dim param As New Dictionary(Of String, String) | |
79 | 79 | param.Add("key", myApikeyEncoded) |
80 | 80 | param.Add("uri", myOuturlEncoded) |
81 | 81 | param.Add("size", length.ToString) |
@@ -1,5 +1,11 @@ | ||
1 | 1 | 更新履歴 |
2 | 2 | |
3 | +==== Ver 0.8.8.1(2010/03/3) | |
4 | + * Webモード廃止 | |
5 | + * OAuth(xAuth)対応(API上限が350へ) | |
6 | + * URL等のリンク検出ロジックの調整 | |
7 | + * フォロー・アンフォロー等のID指定画面でIDを変更しても、結果画面のIDが変わらないバグ修正 | |
8 | + * 時速表示バグの修正 | |
3 | 9 | ==== Ver 0.8.8.0(2010/02/23) |
4 | 10 | * ふぁぼったーのURLを変更(favotter.matope.com→favotter.netに変更) |
5 | 11 | ==== Ver 0.8.7.0(2010/02/23) |
@@ -127,6 +127,7 @@ Partial Class Setting | ||
127 | 127 | Me.Label47 = New System.Windows.Forms.Label |
128 | 128 | Me.TabControl1 = New System.Windows.Forms.TabControl |
129 | 129 | Me.TabPage1 = New System.Windows.Forms.TabPage |
130 | + Me.AuthClearButton = New System.Windows.Forms.Button | |
130 | 131 | Me.AuthUserLabel = New System.Windows.Forms.Label |
131 | 132 | Me.AuthStateLabel = New System.Windows.Forms.Label |
132 | 133 | Me.Label4 = New System.Windows.Forms.Label |
@@ -217,7 +218,6 @@ Partial Class Setting | ||
217 | 218 | Me.Label59 = New System.Windows.Forms.Label |
218 | 219 | Me.TextBoxOutputzKey = New System.Windows.Forms.TextBox |
219 | 220 | Me.CheckOutputz = New System.Windows.Forms.CheckBox |
220 | - Me.AuthClearButton = New System.Windows.Forms.Button | |
221 | 221 | Me.GroupBox1.SuspendLayout() |
222 | 222 | Me.TabControl1.SuspendLayout() |
223 | 223 | Me.TabPage1.SuspendLayout() |
@@ -889,6 +889,12 @@ Partial Class Setting | ||
889 | 889 | Me.TabPage1.Name = "TabPage1" |
890 | 890 | Me.TabPage1.UseVisualStyleBackColor = True |
891 | 891 | ' |
892 | + 'AuthClearButton | |
893 | + ' | |
894 | + resources.ApplyResources(Me.AuthClearButton, "AuthClearButton") | |
895 | + Me.AuthClearButton.Name = "AuthClearButton" | |
896 | + Me.AuthClearButton.UseVisualStyleBackColor = True | |
897 | + ' | |
892 | 898 | 'AuthUserLabel |
893 | 899 | ' |
894 | 900 | Me.AuthUserLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D |
@@ -1502,12 +1508,6 @@ Partial Class Setting | ||
1502 | 1508 | Me.CheckOutputz.Name = "CheckOutputz" |
1503 | 1509 | Me.CheckOutputz.UseVisualStyleBackColor = True |
1504 | 1510 | ' |
1505 | - 'AuthClearButton | |
1506 | - ' | |
1507 | - resources.ApplyResources(Me.AuthClearButton, "AuthClearButton") | |
1508 | - Me.AuthClearButton.Name = "AuthClearButton" | |
1509 | - Me.AuthClearButton.UseVisualStyleBackColor = True | |
1510 | - ' | |
1511 | 1511 | 'Setting |
1512 | 1512 | ' |
1513 | 1513 | Me.AcceptButton = Me.Save |
@@ -139,30 +139,12 @@ | ||
139 | 139 | <data name="Label3.Text" xml:space="preserve"> |
140 | 140 | <value>Timeline Fetching Interval (sec.)</value> |
141 | 141 | </data> |
142 | - <data name="Label4.Size" type="System.Drawing.Size, System.Drawing"> | |
143 | - <value>153, 12</value> | |
144 | - </data> | |
145 | - <data name="Label4.Text" xml:space="preserve"> | |
146 | - <value>Threshold of Fetching (1-20)</value> | |
147 | - </data> | |
148 | 142 | <data name="Label5.Size" type="System.Drawing.Size, System.Drawing"> |
149 | 143 | <value>144, 12</value> |
150 | 144 | </data> |
151 | 145 | <data name="Label5.Text" xml:space="preserve"> |
152 | 146 | <value>DM Fetching Interval (sec.)</value> |
153 | 147 | </data> |
154 | - <data name="Label6.Size" type="System.Drawing.Size, System.Drawing"> | |
155 | - <value>205, 12</value> | |
156 | - </data> | |
157 | - <data name="Label6.Text" xml:space="preserve"> | |
158 | - <value>Fetching Pages at Once over threshold</value> | |
159 | - </data> | |
160 | - <data name="Label8.Size" type="System.Drawing.Size, System.Drawing"> | |
161 | - <value>142, 12</value> | |
162 | - </data> | |
163 | - <data name="Label8.Text" xml:space="preserve"> | |
164 | - <value>First-time Fetching Pages:</value> | |
165 | - </data> | |
166 | 148 | <data name="Label9.Size" type="System.Drawing.Size, System.Drawing"> |
167 | 149 | <value>135, 12</value> |
168 | 150 | </data> |
@@ -478,12 +460,6 @@ | ||
478 | 460 | <data name="Label44.Text" xml:space="preserve"> |
479 | 461 | <value>Path to Browser</value> |
480 | 462 | </data> |
481 | - <data name="CheckboxReply.Size" type="System.Drawing.Size, System.Drawing"> | |
482 | - <value>95, 16</value> | |
483 | - </data> | |
484 | - <data name="CheckboxReply.Text" xml:space="preserve"> | |
485 | - <value>Fetch Replies</value> | |
486 | - </data> | |
487 | 463 | <data name="CheckDispUsername.Size" type="System.Drawing.Size, System.Drawing"> |
488 | 464 | <value>58, 16</value> |
489 | 465 | </data> |
@@ -529,23 +505,23 @@ | ||
529 | 505 | <data name="Label47.Text" xml:space="preserve"> |
530 | 506 | <value>Apply after restarting</value> |
531 | 507 | </data> |
532 | - <data name="Label7.Size" type="System.Drawing.Size, System.Drawing"> | |
533 | - <value>149, 12</value> | |
508 | + <data name="AuthClearButton.Text" xml:space="preserve"> | |
509 | + <value>Clear</value> | |
534 | 510 | </data> |
535 | - <data name="Label7.Text" xml:space="preserve"> | |
536 | - <value>Public Search Interval (sec.)</value> | |
511 | + <data name="Label4.Size" type="System.Drawing.Size, System.Drawing"> | |
512 | + <value>65, 12</value> | |
537 | 513 | </data> |
538 | - <data name="Label70.Size" type="System.Drawing.Size, System.Drawing"> | |
539 | - <value>176, 12</value> | |
514 | + <data name="Label4.Text" xml:space="preserve"> | |
515 | + <value>Auth status</value> | |
540 | 516 | </data> |
541 | - <data name="Label70.Text" xml:space="preserve"> | |
542 | - <value>Show warning if API isn't enabled</value> | |
517 | + <data name="AuthorizeButton.Text" xml:space="preserve"> | |
518 | + <value>Auth</value> | |
543 | 519 | </data> |
544 | - <data name="CheckStartupAPImodeNoWarning.Size" type="System.Drawing.Size, System.Drawing"> | |
545 | - <value>80, 16</value> | |
520 | + <data name="Label7.Size" type="System.Drawing.Size, System.Drawing"> | |
521 | + <value>149, 12</value> | |
546 | 522 | </data> |
547 | - <data name="CheckStartupAPImodeNoWarning.Text" xml:space="preserve"> | |
548 | - <value>Don't show</value> | |
523 | + <data name="Label7.Text" xml:space="preserve"> | |
524 | + <value>Public Search Interval (sec.)</value> | |
549 | 525 | </data> |
550 | 526 | <data name="Label69.Size" type="System.Drawing.Size, System.Drawing"> |
551 | 527 | <value>156, 12</value> |
@@ -565,30 +541,6 @@ | ||
565 | 541 | <data name="Label67.Text" xml:space="preserve"> |
566 | 542 | <value>Getting number of tweets/mentions in API </value> |
567 | 543 | </data> |
568 | - <data name="Label66.Size" type="System.Drawing.Size, System.Drawing"> | |
569 | - <value>75, 12</value> | |
570 | - </data> | |
571 | - <data name="Label66.Text" xml:space="preserve"> | |
572 | - <value>POST method</value> | |
573 | - </data> | |
574 | - <data name="CheckPostMethod.Size" type="System.Drawing.Size, System.Drawing"> | |
575 | - <value>58, 16</value> | |
576 | - </data> | |
577 | - <data name="CheckPostMethod.Text" xml:space="preserve"> | |
578 | - <value>Enable</value> | |
579 | - </data> | |
580 | - <data name="Label43.Size" type="System.Drawing.Size, System.Drawing"> | |
581 | - <value>59, 12</value> | |
582 | - </data> | |
583 | - <data name="Label43.Text" xml:space="preserve"> | |
584 | - <value>TwitterAPI</value> | |
585 | - </data> | |
586 | - <data name="CheckUseApi.Size" type="System.Drawing.Size, System.Drawing"> | |
587 | - <value>58, 16</value> | |
588 | - </data> | |
589 | - <data name="CheckUseApi.Text" xml:space="preserve"> | |
590 | - <value>Enable</value> | |
591 | - </data> | |
592 | 544 | <data name="Label54.Size" type="System.Drawing.Size, System.Drawing"> |
593 | 545 | <value>131, 12</value> |
594 | 546 | </data> |
@@ -601,18 +553,6 @@ | ||
601 | 553 | <data name="CheckStartupFollowers.Text" xml:space="preserve"> |
602 | 554 | <value>Enable</value> |
603 | 555 | </data> |
604 | - <data name="Label53.Size" type="System.Drawing.Size, System.Drawing"> | |
605 | - <value>169, 12</value> | |
606 | - </data> | |
607 | - <data name="Label53.Text" xml:space="preserve"> | |
608 | - <value>Update Parsing Keys in Starting</value> | |
609 | - </data> | |
610 | - <data name="CheckStartupKey.Size" type="System.Drawing.Size, System.Drawing"> | |
611 | - <value>58, 16</value> | |
612 | - </data> | |
613 | - <data name="CheckStartupKey.Text" xml:space="preserve"> | |
614 | - <value>Enable</value> | |
615 | - </data> | |
616 | 556 | <data name="Label51.Size" type="System.Drawing.Size, System.Drawing"> |
617 | 557 | <value>158, 12</value> |
618 | 558 | </data> |
@@ -273,7 +273,7 @@ | ||
273 | 273 | <value>130, 12</value> |
274 | 274 | </data> |
275 | 275 | <data name="Label3.TabIndex" type="System.Int32, mscorlib"> |
276 | - <value>4</value> | |
276 | + <value>5</value> | |
277 | 277 | </data> |
278 | 278 | <data name="Label3.Text" xml:space="preserve"> |
279 | 279 | <value>タイムライン更新間隔(秒)</value> |
@@ -297,7 +297,7 @@ | ||
297 | 297 | <value>65, 19</value> |
298 | 298 | </data> |
299 | 299 | <data name="TimelinePeriod.TabIndex" type="System.Int32, mscorlib"> |
300 | - <value>5</value> | |
300 | + <value>6</value> | |
301 | 301 | </data> |
302 | 302 | <data name=">>TimelinePeriod.Name" xml:space="preserve"> |
303 | 303 | <value>TimelinePeriod</value> |
@@ -2989,7 +2989,7 @@ | ||
2989 | 2989 | <value>75, 23</value> |
2990 | 2990 | </data> |
2991 | 2991 | <data name="AuthorizeButton.TabIndex" type="System.Int32, mscorlib"> |
2992 | - <value>43</value> | |
2992 | + <value>4</value> | |
2993 | 2993 | </data> |
2994 | 2994 | <data name="AuthorizeButton.Text" xml:space="preserve"> |
2995 | 2995 | <value>認証する</value> |
@@ -3142,7 +3142,7 @@ | ||
3142 | 3142 | <value>84, 16</value> |
3143 | 3143 | </data> |
3144 | 3144 | <data name="CheckPostAndGet.TabIndex" type="System.Int32, mscorlib"> |
3145 | - <value>6</value> | |
3145 | + <value>7</value> | |
3146 | 3146 | </data> |
3147 | 3147 | <data name="CheckPostAndGet.Text" xml:space="preserve"> |
3148 | 3148 | <value>投稿時取得</value> |
@@ -286,6 +286,14 @@ Public Class Setting | ||
286 | 286 | End Try |
287 | 287 | End Sub |
288 | 288 | |
289 | + Private Sub Setting_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing | |
290 | + If Twitter.Username = "" Then | |
291 | + If MessageBox.Show(My.Resources.Setting_FormClosing1, "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then | |
292 | + e.Cancel = True | |
293 | + End If | |
294 | + End If | |
295 | + End Sub | |
296 | + | |
289 | 297 | Private Sub Setting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load |
290 | 298 | 'Username.Text = _MyuserID |
291 | 299 | 'Password.Text = _Mypassword |
@@ -1829,27 +1837,27 @@ Public Class Setting | ||
1829 | 1837 | End Set |
1830 | 1838 | End Property |
1831 | 1839 | |
1832 | - Private Sub Username_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Username.Validating | |
1833 | - If Username.Text.Trim = "" Then | |
1834 | - MessageBox.Show(My.Resources.Save_ClickText1) | |
1835 | - e.Cancel = True | |
1836 | - Exit Sub | |
1837 | - End If | |
1838 | - If Username.Text.Contains("@") Then | |
1839 | - MessageBox.Show(My.Resources.Save_ClickText2) | |
1840 | - e.Cancel = True | |
1841 | - Exit Sub | |
1842 | - End If | |
1840 | + 'Private Sub Username_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Username.Validating | |
1841 | + ' If Username.Text.Trim = "" Then | |
1842 | + ' MessageBox.Show(My.Resources.Save_ClickText1) | |
1843 | + ' e.Cancel = True | |
1844 | + ' Exit Sub | |
1845 | + ' End If | |
1846 | + ' If Username.Text.Contains("@") Then | |
1847 | + ' MessageBox.Show(My.Resources.Save_ClickText2) | |
1848 | + ' e.Cancel = True | |
1849 | + ' Exit Sub | |
1850 | + ' End If | |
1843 | 1851 | |
1844 | - End Sub | |
1852 | + 'End Sub | |
1845 | 1853 | |
1846 | - Private Sub Password_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Password.Validating | |
1847 | - If Password.Text.Trim = "" Then | |
1848 | - MessageBox.Show(My.Resources.Save_ClickText1) | |
1849 | - e.Cancel = True | |
1850 | - Exit Sub | |
1851 | - End If | |
1852 | - End Sub | |
1854 | + 'Private Sub Password_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Password.Validating | |
1855 | + ' If Password.Text.Trim = "" Then | |
1856 | + ' MessageBox.Show(My.Resources.Save_ClickText1) | |
1857 | + ' e.Cancel = True | |
1858 | + ' Exit Sub | |
1859 | + ' End If | |
1860 | + 'End Sub | |
1853 | 1861 | |
1854 | 1862 | Private Sub ComboBoxAutoShortUrlFirst_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxAutoShortUrlFirst.SelectedIndexChanged |
1855 | 1863 | If ComboBoxAutoShortUrlFirst.SelectedIndex = UrlConverter.Bitly OrElse _ |
@@ -1940,5 +1948,6 @@ Public Class Setting | ||
1940 | 1948 | Me.AuthStateLabel.Text = My.Resources.AuthorizeButton_Click4 |
1941 | 1949 | Me.AuthUserLabel.Text = "" |
1942 | 1950 | End Sub |
1951 | + | |
1943 | 1952 | End Class |
1944 | 1953 |
@@ -1813,6 +1813,21 @@ Public Class TweenMain | ||
1813 | 1813 | Me.Activate() |
1814 | 1814 | End Sub |
1815 | 1815 | |
1816 | + Private Shared Function CheckAccountValid() As Boolean | |
1817 | + Static errorCount As Integer = 0 | |
1818 | + If Twitter.AccountState <> ACCOUNT_STATE.Valid Then | |
1819 | + errorCount += 1 | |
1820 | + If errorCount > 5 Then | |
1821 | + errorCount = 0 | |
1822 | + Twitter.AccountState = ACCOUNT_STATE.Valid | |
1823 | + Return True | |
1824 | + End If | |
1825 | + Return False | |
1826 | + End If | |
1827 | + errorCount = 0 | |
1828 | + Return True | |
1829 | + End Function | |
1830 | + | |
1816 | 1831 | Private Sub GetTimelineWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) |
1817 | 1832 | Dim bw As BackgroundWorker = DirectCast(sender, BackgroundWorker) |
1818 | 1833 | If bw.CancellationPending OrElse _endingFlag Then |
@@ -1832,6 +1847,12 @@ Public Class TweenMain | ||
1832 | 1847 | |
1833 | 1848 | Dim args As GetWorkerArg = DirectCast(e.Argument, GetWorkerArg) |
1834 | 1849 | |
1850 | + If Not CheckAccountValid() Then | |
1851 | + rslt.retMsg = "Auth error. Check your account" | |
1852 | + rslt.type = args.type | |
1853 | + rslt.tName = args.tName | |
1854 | + e.Result = rslt | |
1855 | + End If | |
1835 | 1856 | |
1836 | 1857 | If args.type <> WORKERTYPE.OpenUri Then bw.ReportProgress(0, "") 'Notifyアイコンアニメーション開始 |
1837 | 1858 | Select Case args.type |
@@ -4873,121 +4894,104 @@ RETRY: | ||
4873 | 4894 | Private Sub SaveConfigsCommon() |
4874 | 4895 | If _ignoreConfigSave Then Exit Sub |
4875 | 4896 | |
4876 | - If Twitter.Username <> "" Then | |
4877 | - modifySettingCommon = False | |
4878 | - SyncLock _syncObject | |
4879 | - _cfgCommon.UserName = Twitter.Username | |
4880 | - '_cfgCommon.Password = SettingDialog.PasswordStr | |
4881 | - _cfgCommon.Token = Twitter.AccessToken | |
4882 | - _cfgCommon.TokenSecret = Twitter.AccessTokenSecret | |
4883 | - '_cfgCommon.NextPageThreshold = SettingDialog.NextPageThreshold | |
4884 | - '_cfgCommon.NextPages = SettingDialog.NextPagesInt | |
4885 | - _cfgCommon.TimelinePeriod = SettingDialog.TimelinePeriodInt | |
4886 | - _cfgCommon.ReplyPeriod = SettingDialog.ReplyPeriodInt | |
4887 | - _cfgCommon.DMPeriod = SettingDialog.DMPeriodInt | |
4888 | - _cfgCommon.PubSearchPeriod = SettingDialog.PubSearchPeriodInt | |
4889 | - _cfgCommon.MaxPostNum = SettingDialog.MaxPostNum | |
4890 | - '_cfgCommon.ReadPages = SettingDialog.ReadPages | |
4891 | - '_cfgCommon.ReadPagesReply = SettingDialog.ReadPagesReply | |
4892 | - '_cfgCommon.ReadPagesDM = SettingDialog.ReadPagesDM | |
4893 | - _cfgCommon.Read = SettingDialog.Readed | |
4894 | - _cfgCommon.IconSize = SettingDialog.IconSz | |
4895 | - _cfgCommon.UnreadManage = SettingDialog.UnreadManage | |
4896 | - _cfgCommon.PlaySound = SettingDialog.PlaySound | |
4897 | - _cfgCommon.OneWayLove = SettingDialog.OneWayLove | |
4898 | - | |
4899 | - _cfgCommon.NameBalloon = SettingDialog.NameBalloon | |
4900 | - _cfgCommon.PostCtrlEnter = SettingDialog.PostCtrlEnter | |
4901 | - '_cfgCommon.UseApi = SettingDialog.UseAPI | |
4902 | - _cfgCommon.CountApi = SettingDialog.CountApi | |
4903 | - _cfgCommon.CountApiReply = SettingDialog.CountApiReply | |
4904 | - '_cfgCommon.UsePostMethod = False | |
4905 | - _cfgCommon.HubServer = SettingDialog.HubServer | |
4906 | - '_cfgCommon.CheckReply = SettingDialog.CheckReply | |
4907 | - _cfgCommon.PostAndGet = SettingDialog.PostAndGet | |
4908 | - _cfgCommon.DispUsername = SettingDialog.DispUsername | |
4909 | - _cfgCommon.MinimizeToTray = SettingDialog.MinimizeToTray | |
4910 | - _cfgCommon.CloseToExit = SettingDialog.CloseToExit | |
4911 | - _cfgCommon.DispLatestPost = SettingDialog.DispLatestPost | |
4912 | - _cfgCommon.SortOrderLock = SettingDialog.SortOrderLock | |
4913 | - _cfgCommon.TinyUrlResolve = SettingDialog.TinyUrlResolve | |
4914 | - _cfgCommon.PeriodAdjust = SettingDialog.PeriodAdjust | |
4915 | - _cfgCommon.StartupVersion = SettingDialog.StartupVersion | |
4916 | - '_cfgCommon.StartupKey = SettingDialog.StartupKey | |
4917 | - _cfgCommon.StartupFollowers = SettingDialog.StartupFollowers | |
4918 | - '_cfgCommon.StartupApiModeNoWarning = SettingDialog.StartupAPImodeNoWarning | |
4919 | - _cfgCommon.RestrictFavCheck = SettingDialog.RestrictFavCheck | |
4920 | - _cfgCommon.AlwaysTop = SettingDialog.AlwaysTop | |
4921 | - _cfgCommon.UrlConvertAuto = SettingDialog.UrlConvertAuto | |
4922 | - _cfgCommon.Outputz = SettingDialog.OutputzEnabled | |
4923 | - _cfgCommon.OutputzKey = SettingDialog.OutputzKey | |
4924 | - _cfgCommon.OutputzUrlMode = SettingDialog.OutputzUrlmode | |
4925 | - _cfgCommon.UseUnreadStyle = SettingDialog.UseUnreadStyle | |
4926 | - _cfgCommon.DateTimeFormat = SettingDialog.DateTimeFormat | |
4927 | - _cfgCommon.DefaultTimeOut = SettingDialog.DefaultTimeOut | |
4928 | - _cfgCommon.ProtectNotInclude = SettingDialog.ProtectNotInclude | |
4929 | - _cfgCommon.LimitBalloon = SettingDialog.LimitBalloon | |
4930 | - _cfgCommon.AutoShortUrlFirst = SettingDialog.AutoShortUrlFirst | |
4931 | - _cfgCommon.TabIconDisp = SettingDialog.TabIconDisp | |
4932 | - _cfgCommon.ReplyIconState = SettingDialog.ReplyIconState | |
4933 | - _cfgCommon.ReadOwnPost = SettingDialog.ReadOwnPost | |
4934 | - _cfgCommon.GetFav = SettingDialog.GetFav | |
4935 | - _cfgCommon.IsMonospace = SettingDialog.IsMonospace | |
4936 | - If IdeographicSpaceToSpaceToolStripMenuItem IsNot Nothing AndAlso _ | |
4937 | - IdeographicSpaceToSpaceToolStripMenuItem.IsDisposed = False Then | |
4938 | - _cfgCommon.WideSpaceConvert = Me.IdeographicSpaceToSpaceToolStripMenuItem.Checked | |
4939 | - End If | |
4940 | - _cfgCommon.ReadOldPosts = SettingDialog.ReadOldPosts | |
4941 | - _cfgCommon.UseSsl = SettingDialog.UseSsl | |
4942 | - _cfgCommon.BilyUser = SettingDialog.BitlyUser | |
4943 | - _cfgCommon.BitlyPwd = SettingDialog.BitlyPwd | |
4944 | - _cfgCommon.ShowGrid = SettingDialog.ShowGrid | |
4945 | - _cfgCommon.UseAtIdSupplement = SettingDialog.UseAtIdSupplement | |
4946 | - _cfgCommon.UseHashSupplement = SettingDialog.UseHashSupplement | |
4947 | - _cfgCommon.Language = SettingDialog.Language | |
4948 | - | |
4949 | - _cfgCommon.SortOrder = _statuses.SortOrder | |
4950 | - Select Case _statuses.SortMode | |
4951 | - Case IdComparerClass.ComparerMode.Nickname 'ニックネーム | |
4952 | - _cfgCommon.SortColumn = 1 | |
4953 | - Case IdComparerClass.ComparerMode.Data '本文 | |
4954 | - _cfgCommon.SortColumn = 2 | |
4955 | - Case IdComparerClass.ComparerMode.Id '時刻=発言Id | |
4956 | - _cfgCommon.SortColumn = 3 | |
4957 | - Case IdComparerClass.ComparerMode.Name '名前 | |
4958 | - _cfgCommon.SortColumn = 4 | |
4959 | - Case IdComparerClass.ComparerMode.Source 'Source | |
4960 | - _cfgCommon.SortColumn = 7 | |
4961 | - End Select | |
4897 | + modifySettingCommon = False | |
4898 | + SyncLock _syncObject | |
4899 | + _cfgCommon.UserName = Twitter.Username | |
4900 | + '_cfgCommon.Password = SettingDialog.PasswordStr | |
4901 | + _cfgCommon.Token = Twitter.AccessToken | |
4902 | + _cfgCommon.TokenSecret = Twitter.AccessTokenSecret | |
4903 | + '_cfgCommon.NextPageThreshold = SettingDialog.NextPageThreshold | |
4904 | + '_cfgCommon.NextPages = SettingDialog.NextPagesInt | |
4905 | + _cfgCommon.TimelinePeriod = SettingDialog.TimelinePeriodInt | |
4906 | + _cfgCommon.ReplyPeriod = SettingDialog.ReplyPeriodInt | |
4907 | + _cfgCommon.DMPeriod = SettingDialog.DMPeriodInt | |
4908 | + _cfgCommon.PubSearchPeriod = SettingDialog.PubSearchPeriodInt | |
4909 | + _cfgCommon.MaxPostNum = SettingDialog.MaxPostNum | |
4910 | + '_cfgCommon.ReadPages = SettingDialog.ReadPages | |
4911 | + '_cfgCommon.ReadPagesReply = SettingDialog.ReadPagesReply | |
4912 | + '_cfgCommon.ReadPagesDM = SettingDialog.ReadPagesDM | |
4913 | + _cfgCommon.Read = SettingDialog.Readed | |
4914 | + _cfgCommon.IconSize = SettingDialog.IconSz | |
4915 | + _cfgCommon.UnreadManage = SettingDialog.UnreadManage | |
4916 | + _cfgCommon.PlaySound = SettingDialog.PlaySound | |
4917 | + _cfgCommon.OneWayLove = SettingDialog.OneWayLove | |
4918 | + | |
4919 | + _cfgCommon.NameBalloon = SettingDialog.NameBalloon | |
4920 | + _cfgCommon.PostCtrlEnter = SettingDialog.PostCtrlEnter | |
4921 | + '_cfgCommon.UseApi = SettingDialog.UseAPI | |
4922 | + _cfgCommon.CountApi = SettingDialog.CountApi | |
4923 | + _cfgCommon.CountApiReply = SettingDialog.CountApiReply | |
4924 | + '_cfgCommon.UsePostMethod = False | |
4925 | + _cfgCommon.HubServer = SettingDialog.HubServer | |
4926 | + '_cfgCommon.CheckReply = SettingDialog.CheckReply | |
4927 | + _cfgCommon.PostAndGet = SettingDialog.PostAndGet | |
4928 | + _cfgCommon.DispUsername = SettingDialog.DispUsername | |
4929 | + _cfgCommon.MinimizeToTray = SettingDialog.MinimizeToTray | |
4930 | + _cfgCommon.CloseToExit = SettingDialog.CloseToExit | |
4931 | + _cfgCommon.DispLatestPost = SettingDialog.DispLatestPost | |
4932 | + _cfgCommon.SortOrderLock = SettingDialog.SortOrderLock | |
4933 | + _cfgCommon.TinyUrlResolve = SettingDialog.TinyUrlResolve | |
4934 | + _cfgCommon.PeriodAdjust = SettingDialog.PeriodAdjust | |
4935 | + _cfgCommon.StartupVersion = SettingDialog.StartupVersion | |
4936 | + '_cfgCommon.StartupKey = SettingDialog.StartupKey | |
4937 | + _cfgCommon.StartupFollowers = SettingDialog.StartupFollowers | |
4938 | + '_cfgCommon.StartupApiModeNoWarning = SettingDialog.StartupAPImodeNoWarning | |
4939 | + _cfgCommon.RestrictFavCheck = SettingDialog.RestrictFavCheck | |
4940 | + _cfgCommon.AlwaysTop = SettingDialog.AlwaysTop | |
4941 | + _cfgCommon.UrlConvertAuto = SettingDialog.UrlConvertAuto | |
4942 | + _cfgCommon.Outputz = SettingDialog.OutputzEnabled | |
4943 | + _cfgCommon.OutputzKey = SettingDialog.OutputzKey | |
4944 | + _cfgCommon.OutputzUrlMode = SettingDialog.OutputzUrlmode | |
4945 | + _cfgCommon.UseUnreadStyle = SettingDialog.UseUnreadStyle | |
4946 | + _cfgCommon.DateTimeFormat = SettingDialog.DateTimeFormat | |
4947 | + _cfgCommon.DefaultTimeOut = SettingDialog.DefaultTimeOut | |
4948 | + _cfgCommon.ProtectNotInclude = SettingDialog.ProtectNotInclude | |
4949 | + _cfgCommon.LimitBalloon = SettingDialog.LimitBalloon | |
4950 | + _cfgCommon.AutoShortUrlFirst = SettingDialog.AutoShortUrlFirst | |
4951 | + _cfgCommon.TabIconDisp = SettingDialog.TabIconDisp | |
4952 | + _cfgCommon.ReplyIconState = SettingDialog.ReplyIconState | |
4953 | + _cfgCommon.ReadOwnPost = SettingDialog.ReadOwnPost | |
4954 | + _cfgCommon.GetFav = SettingDialog.GetFav | |
4955 | + _cfgCommon.IsMonospace = SettingDialog.IsMonospace | |
4956 | + If IdeographicSpaceToSpaceToolStripMenuItem IsNot Nothing AndAlso _ | |
4957 | + IdeographicSpaceToSpaceToolStripMenuItem.IsDisposed = False Then | |
4958 | + _cfgCommon.WideSpaceConvert = Me.IdeographicSpaceToSpaceToolStripMenuItem.Checked | |
4959 | + End If | |
4960 | + _cfgCommon.ReadOldPosts = SettingDialog.ReadOldPosts | |
4961 | + _cfgCommon.UseSsl = SettingDialog.UseSsl | |
4962 | + _cfgCommon.BilyUser = SettingDialog.BitlyUser | |
4963 | + _cfgCommon.BitlyPwd = SettingDialog.BitlyPwd | |
4964 | + _cfgCommon.ShowGrid = SettingDialog.ShowGrid | |
4965 | + _cfgCommon.UseAtIdSupplement = SettingDialog.UseAtIdSupplement | |
4966 | + _cfgCommon.UseHashSupplement = SettingDialog.UseHashSupplement | |
4967 | + _cfgCommon.Language = SettingDialog.Language | |
4968 | + | |
4969 | + _cfgCommon.SortOrder = _statuses.SortOrder | |
4970 | + Select Case _statuses.SortMode | |
4971 | + Case IdComparerClass.ComparerMode.Nickname 'ニックネーム | |
4972 | + _cfgCommon.SortColumn = 1 | |
4973 | + Case IdComparerClass.ComparerMode.Data '本文 | |
4974 | + _cfgCommon.SortColumn = 2 | |
4975 | + Case IdComparerClass.ComparerMode.Id '時刻=発言Id | |
4976 | + _cfgCommon.SortColumn = 3 | |
4977 | + Case IdComparerClass.ComparerMode.Name '名前 | |
4978 | + _cfgCommon.SortColumn = 4 | |
4979 | + Case IdComparerClass.ComparerMode.Source 'Source | |
4980 | + _cfgCommon.SortColumn = 7 | |
4981 | + End Select | |
4962 | 4982 | |
4963 | - _cfgCommon.Nicoms = SettingDialog.Nicoms | |
4964 | - _cfgCommon.HashTags = HashMgr.HashHistories | |
4965 | - If HashMgr.IsPermanent Then | |
4966 | - _cfgCommon.HashSelected = HashMgr.UseHash | |
4967 | - Else | |
4968 | - _cfgCommon.HashSelected = "" | |
4969 | - End If | |
4970 | - _cfgCommon.HashIsHead = HashMgr.IsHead | |
4971 | - _cfgCommon.HashIsPermanent = HashMgr.IsPermanent | |
4972 | - '_cfgCommon.HashSelected = Me.HashSelectComboBox.Text | |
4973 | - | |
4974 | - ' _cfgCommon.TabList.Clear() | |
4975 | - ' For i As Integer = 0 To ListTab.TabPages.Count - 1 | |
4976 | - ' Dim tnList As String = ListTab.TabPages(i).Text | |
4977 | - ' Dim seq As Integer = 1 | |
4978 | - 'RETRY: | |
4979 | - ' seq += 1 | |
4980 | - ' For Each tn As String In _cfgCommon.TabList | |
4981 | - ' If tn.ToLower() = tnList.ToLower() Then | |
4982 | - ' tnList += "_" + seq.ToString() | |
4983 | - ' End If | |
4984 | - ' Next | |
4985 | - ' _cfgCommon.TabList.Add(ListTab.TabPages(i).Text) | |
4986 | - ' Next | |
4987 | - | |
4988 | - _cfgCommon.Save() | |
4989 | - End SyncLock | |
4990 | - End If | |
4983 | + _cfgCommon.Nicoms = SettingDialog.Nicoms | |
4984 | + _cfgCommon.HashTags = HashMgr.HashHistories | |
4985 | + If HashMgr.IsPermanent Then | |
4986 | + _cfgCommon.HashSelected = HashMgr.UseHash | |
4987 | + Else | |
4988 | + _cfgCommon.HashSelected = "" | |
4989 | + End If | |
4990 | + _cfgCommon.HashIsHead = HashMgr.IsHead | |
4991 | + _cfgCommon.HashIsPermanent = HashMgr.IsPermanent | |
4992 | + | |
4993 | + _cfgCommon.Save() | |
4994 | + End SyncLock | |
4991 | 4995 | End Sub |
4992 | 4996 | |
4993 | 4997 | Private Sub SaveConfigsLocal() |
@@ -6385,15 +6389,20 @@ RETRY: | ||
6385 | 6389 | Private Function UrlConvert(ByVal Converter_Type As UrlConverter) As Boolean |
6386 | 6390 | 'Converter_Type=Nicomsの場合は、nicovideoのみ短縮する |
6387 | 6391 | Dim result As String = "" |
6388 | - Dim url As Regex = New Regex("(?<![0-9A-Za-z])(?:https?|shttp)://(?:(?:[-_.!~*'()a-zA-Z0-9;:&=+$,]|%[0-9A-Fa-f" + _ | |
6389 | - "][0-9A-Fa-f])*@)?(?:(?:[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.)" + _ | |
6390 | - "*[a-zA-Z](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.?|[0-9]+\.[0-9]+\.[0-9]+\." + _ | |
6391 | - "[0-9]+)(?::[0-9]*)?(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f]" + _ | |
6392 | - "[0-9A-Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-" + _ | |
6393 | - "Fa-f])*)*(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f" + _ | |
6394 | - "])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)*)" + _ | |
6395 | - "*)?(?:\?(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])" + _ | |
6396 | - "*)?(?:#(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)?") | |
6392 | + Dim url As Regex = New Regex("(?<before>(?:[^\/""':!=]|^|\:))" + _ | |
6393 | + "(?<url>(?<protocol>https?://|www\.)" + _ | |
6394 | + "(?<domain>(?:[\.-]|[^\p{P}])+\.[a-z]{2,}(?::[0-9]+)?)" + _ | |
6395 | + "(?<path>/[a-z0-9!*'();:&=+$/%#\[\]\-_.,~]*[a-z0-9)=#/]?)?" + _ | |
6396 | + "(?<query>\?[a-z0-9!*'();:&=+$/%#\[\]\-_.,~]*[a-z0-9_&=#])?)", RegexOptions.IgnoreCase Or RegexOptions.Compiled) | |
6397 | + 'Dim url As Regex = New Regex("(?<![0-9A-Za-z])(?:https?|shttp)://(?:(?:[-_.!~*'()a-zA-Z0-9;:&=+$,]|%[0-9A-Fa-f" + _ | |
6398 | + ' "][0-9A-Fa-f])*@)?(?:(?:[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.)" + _ | |
6399 | + ' "*[a-zA-Z](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.?|[0-9]+\.[0-9]+\.[0-9]+\." + _ | |
6400 | + ' "[0-9]+)(?::[0-9]*)?(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f]" + _ | |
6401 | + ' "[0-9A-Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-" + _ | |
6402 | + ' "Fa-f])*)*(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f" + _ | |
6403 | + ' "])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)*)" + _ | |
6404 | + ' "*)?(?:\?(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])" + _ | |
6405 | + ' "*)?(?:#(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)?") | |
6397 | 6406 | Dim nico As Regex = New Regex("^https?://[a-z]+\.(nicovideo|niconicommons)\.jp/[a-z]+/[a-z0-9]+$") |
6398 | 6407 | |
6399 | 6408 | If StatusText.SelectionLength > 0 Then |
@@ -6439,16 +6448,14 @@ RETRY: | ||
6439 | 6448 | End If |
6440 | 6449 | End If |
6441 | 6450 | Else |
6442 | - Dim urls As RegularExpressions.MatchCollection = Nothing | |
6443 | - urls = url.Matches(StatusText.Text) | |
6444 | - | |
6445 | 6451 | ' 正規表現にマッチしたURL文字列をtinyurl化 |
6446 | - For Each tmp2 As Match In urls | |
6447 | - Dim tmp As String = tmp2.ToString | |
6452 | + For Each mt As Match In url.Matches(StatusText.Text) | |
6453 | + Dim tmp As String = mt.Result("${url}") | |
6454 | + If tmp.StartsWith("w", StringComparison.OrdinalIgnoreCase) Then tmp = "http://" + tmp | |
6448 | 6455 | Dim undotmp As New urlUndo |
6449 | 6456 | |
6450 | 6457 | '選んだURLを選択(?) |
6451 | - StatusText.Select(StatusText.Text.IndexOf(tmp, StringComparison.Ordinal), tmp.Length) | |
6458 | + StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length) | |
6452 | 6459 | |
6453 | 6460 | 'nico.ms使用、nicovideoにマッチしたら変換 |
6454 | 6461 | If SettingDialog.Nicoms AndAlso nico.IsMatch(tmp) Then |
@@ -6469,10 +6476,10 @@ RETRY: | ||
6469 | 6476 | End If |
6470 | 6477 | |
6471 | 6478 | If Not result = "" Then |
6472 | - StatusText.Select(StatusText.Text.IndexOf(tmp, StringComparison.Ordinal), tmp.Length) | |
6479 | + StatusText.Select(StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal), mt.Result("${url}").Length) | |
6473 | 6480 | StatusText.SelectedText = result |
6474 | 6481 | 'undoバッファにセット |
6475 | - undotmp.Before = tmp | |
6482 | + undotmp.Before = mt.Result("${url}") | |
6476 | 6483 | undotmp.After = result |
6477 | 6484 | |
6478 | 6485 | If urlUndoBuffer Is Nothing Then |
@@ -2974,7 +2974,7 @@ Public Module Twitter | ||
2974 | 2974 | |
2975 | 2975 | Public Function MakeShortUrl(ByVal ConverterType As UrlConverter, ByVal SrcUrl As String) As String |
2976 | 2976 | Dim src As String = urlEncodeMultibyteChar(SrcUrl) |
2977 | - Dim param As New SortedList(Of String, String) | |
2977 | + Dim param As New Dictionary(Of String, String) | |
2978 | 2978 | Dim content As String = "" |
2979 | 2979 | |
2980 | 2980 | For Each svc As String In _ShortUrlService |
@@ -3236,6 +3236,11 @@ Public Module Twitter | ||
3236 | 3236 | Public WriteOnly Property UseSsl() As Boolean |
3237 | 3237 | Set(ByVal value As Boolean) |
3238 | 3238 | HttpTwitter.UseSsl = value |
3239 | + If value Then | |
3240 | + _protocol = "https://" | |
3241 | + Else | |
3242 | + _protocol = "http://" | |
3243 | + End If | |
3239 | 3244 | End Set |
3240 | 3245 | End Property |
3241 | 3246 |
@@ -3856,40 +3861,32 @@ Public Module Twitter | ||
3856 | 3861 | 'Dim retStr As String = HttpUtility.HtmlDecode(Text) |
3857 | 3862 | Dim retStr As String = "" |
3858 | 3863 | 'uriの正規表現 |
3859 | - Dim rgUrl As Regex = New Regex("(?<![0-9A-Za-z=])(?:https?|shttp|ftps?)://(?:(?:[-_.!~*'()a-zA-Z0-9;:&=+$,]|%[0-9A-Fa-f" + _ | |
3860 | - "][0-9A-Fa-f])*@)?(?:(?:[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.)" + _ | |
3861 | - "*[a-zA-Z](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.?|[0-9]+\.[0-9]+\.[0-9]+\." + _ | |
3862 | - "[0-9]+)(?::[0-9]*)?(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f]" + _ | |
3863 | - "[0-9A-Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-" + _ | |
3864 | - "Fa-f])*)*(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f" + _ | |
3865 | - "])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)*)" + _ | |
3866 | - "*)?(?:\?(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])" + _ | |
3867 | - "*)?(?:#(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)?") | |
3868 | - Dim rgUrl2 As Regex = New Regex("(?<![^\/""':!=]|^|\:)" + _ | |
3869 | - "(?:https?://|www\.)" + _ | |
3870 | - "((?:[\.-]|[^\p{IsGeneralPunctuation}])+\.[a-z]{2,}(?::[0-9]+)?)" + _ | |
3871 | - "(/[a-z0-9!*'();:&=+$/%#\[\]\-_.,~]*[a-z0-9)=#/]?)?" + _ | |
3872 | - "(\?[a-z0-9!*'();:&=+$/%#\[\]\-_.,~]*[a-z0-9_&=#])?)") | |
3864 | + 'Dim rgUrl As Regex = New Regex("(?<![0-9A-Za-z=])(?:https?|shttp|ftps?)://(?:(?:[-_.!~*'()a-zA-Z0-9;:&=+$,]|%[0-9A-Fa-f" + _ | |
3865 | + ' "][0-9A-Fa-f])*@)?(?:(?:[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.)" + _ | |
3866 | + ' "*[a-zA-Z](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.?|[0-9]+\.[0-9]+\.[0-9]+\." + _ | |
3867 | + ' "[0-9]+)(?::[0-9]*)?(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f]" + _ | |
3868 | + ' "[0-9A-Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-" + _ | |
3869 | + ' "Fa-f])*)*(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f" + _ | |
3870 | + ' "])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)*)" + _ | |
3871 | + ' "*)?(?:\?(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])" + _ | |
3872 | + ' "*)?(?:#(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)?") | |
3873 | + Dim rgUrl As Regex = New Regex("(?<before>(?:[^\/""':!=]|^|\:))" + _ | |
3874 | + "(?<url>(?<protocol>https?://|www\.)" + _ | |
3875 | + "(?<domain>(?:[\.-]|[^\p{P}])+\.[a-z]{2,}(?::[0-9]+)?)" + _ | |
3876 | + "(?<path>/[a-z0-9!*'();:&=+$/%#\[\]\-_.,~]*[a-z0-9)=#/]?)?" + _ | |
3877 | + "(?<query>\?[a-z0-9!*'();:&=+$/%#\[\]\-_.,~]*[a-z0-9_&=#])?)", RegexOptions.IgnoreCase Or RegexOptions.Compiled) | |
3873 | 3878 | '絶対パス表現のUriをリンクに置換 |
3874 | - retStr = rgUrl.Replace(Text, "<a href=""$&"">$&</a>") | |
3875 | - 'Dim mts As MatchCollection = rgUrl.Matches(retStr) | |
3876 | - '''半角スペースを置換(Thanks @anis774) | |
3877 | - ''Text = Text.Replace(" ", " ") 'HttpUtility.HtmlEncode()ではスペースが処理されない為 | |
3878 | - | |
3879 | - 'For Each mt As Match In mts | |
3880 | - ' Text = Text.Replace(mt.Result("$&"), "<a href=""" + mt.Result("$&") + """>" + mt.Result("$&") + "</a>") | |
3881 | - 'Next | |
3882 | - 'retStr = Text | |
3879 | + retStr = rgUrl.Replace(Text, New MatchEvaluator(AddressOf AutoLinkUrl)) | |
3883 | 3880 | |
3884 | 3881 | '@返信を抽出し、@先リスト作成 |
3885 | 3882 | 'Dim rg As New Regex("(^|[ -/:-@[-^`{-~])@([a-zA-Z0-9_]{1,20}/[a-zA-Z0-9_\-]{1,24}[a-zA-Z0-9_])") |
3886 | - Dim rg As New Regex("(^|[^a-zA-Z0-9_])[@@]([a-zA-Z0-9_]{1,20}/[a-zA-Z0-9_\-]{1,80}[a-zA-Z0-9_])") | |
3883 | + Dim rg As New Regex("(^|[^a-zA-Z0-9_])[@@]([a-zA-Z0-9_]{1,20}/[a-zA-Z0-9_\-]{1,79}[a-zA-Z0-9_])", RegexOptions.Compiled) | |
3887 | 3884 | Dim m As Match = rg.Match(retStr) |
3888 | 3885 | '@先をリンクに置換 |
3889 | 3886 | retStr = rg.Replace(retStr, "$1@<a href=""/$2"">$2</a>") |
3890 | 3887 | |
3891 | 3888 | 'rg = New Regex("(^|[ -/:-@[-^`{-~])@([a-zA-Z0-9_]{1,20})") |
3892 | - rg = New Regex("(^|[^a-zA-Z0-9_])[@@]([a-zA-Z0-9_]{1,20})") | |
3889 | + rg = New Regex("(^|[^a-zA-Z0-9_])[@@]([a-zA-Z0-9_]{1,20})", RegexOptions.Compiled) | |
3893 | 3890 | m = rg.Match(retStr) |
3894 | 3891 | While m.Success |
3895 | 3892 | AtList.Add(m.Result("$2").ToLower) |
@@ -3900,7 +3897,7 @@ Public Module Twitter | ||
3900 | 3897 | |
3901 | 3898 | 'ハッシュタグを抽出し、リンクに置換 |
3902 | 3899 | 'Dim rgh As New Regex("(^|[ .!,\-:;<>?])#([^] !""#$%&'()*+,.:;<=>?@\-[\^`{|}~\r\n]+)") |
3903 | - Dim rgh As New Regex("(^|[^a-zA-Z0-9_/&])[##]([a-zA-Z0-9_]+)") | |
3900 | + Dim rgh As New Regex("(^|[^a-zA-Z0-9_/&])[##]([a-zA-Z0-9_]+)", RegexOptions.Compiled) | |
3904 | 3901 | Dim mhs As MatchCollection = rgh.Matches(retStr) |
3905 | 3902 | For Each mt As Match In mhs |
3906 | 3903 | If Not IsNumeric(mt.Result("$2")) Then |
@@ -3910,24 +3907,27 @@ Public Module Twitter | ||
3910 | 3907 | End SyncLock |
3911 | 3908 | End If |
3912 | 3909 | Next |
3913 | - retStr = rgh.Replace(retStr, "$1<a href=""" + _protocol + "twitter.com/search?q=%23$2"">#$2</a>") | |
3914 | - '数字のみハッシュタグを戻す | |
3915 | - Dim rgnh As New Regex("<a href=""" + _protocol + "twitter.com/search\?q=%23[0-9]+"">(#[0-9]+)</a>") | |
3916 | - retStr = rgnh.Replace(retStr, "$1") | |
3917 | - 'If mh.Success Then | |
3918 | - ' retStr = rgh.Replace(retStr, "$1<a href=""" + _protocol + "twitter.com/search?q=%23$2"">#$2</a>") | |
3919 | - 'End If | |
3920 | - 'While mh.Success | |
3921 | - ' SyncLock LockObj | |
3922 | - ' _hashList.Add("#" + mh.Result("$2")) | |
3923 | - ' End SyncLock | |
3924 | - ' mh = mh.NextMatch | |
3925 | - 'End While | |
3910 | + retStr = rgh.Replace(retStr, New MatchEvaluator(AddressOf AutoLinkHashtag)) | |
3926 | 3911 | |
3927 | 3912 | retStr = AdjustHtml(ShortUrlResolve(PreProcessUrl(retStr))) 'IDN置換、短縮Uri解決、@リンクを相対→絶対にしてtarget属性付与 |
3928 | 3913 | Return retStr |
3929 | 3914 | End Function |
3930 | 3915 | |
3916 | + Private Function AutoLinkUrl(ByVal m As Match) As String | |
3917 | + Dim sb As New StringBuilder(m.Result("${before}<a href=""")) | |
3918 | + If m.Result("${protocol}").StartsWith("w", StringComparison.OrdinalIgnoreCase) Then | |
3919 | + sb.Append("http://") | |
3920 | + End If | |
3921 | + sb.Append(m.Result("${url}"">")).Append(m.Result("${url}")).Append("</a>") | |
3922 | + Return sb.ToString | |
3923 | + End Function | |
3924 | + | |
3925 | + Private Function AutoLinkHashtag(ByVal m As Match) As String | |
3926 | + If IsNumeric(m.Result("$2")) Then Return m.Result("$1#$2") | |
3927 | + Dim sb As New StringBuilder(m.Result("$1<a href=""")) | |
3928 | + Return sb.Append(_protocol).Append("twitter.com/search?q=%23").Append(m.Result("$2"">#$2</a>")).ToString | |
3929 | + End Function | |
3930 | + | |
3931 | 3931 | Public ReadOnly Property RemainCountApi() As Integer |
3932 | 3932 | Get |
3933 | 3933 | Return twCon.RemainCountApi |
@@ -4044,4 +4044,5 @@ Public Module Twitter | ||
4044 | 4044 | Return twCon.AccessTokenSecret |
4045 | 4045 | End Get |
4046 | 4046 | End Property |
4047 | + | |
4047 | 4048 | End Module |