From 9437a53accc5be7680922356f8035ccad4ab53ba Mon Sep 17 00:00:00 2001 From: f_swallow Date: Thu, 31 Mar 2011 18:59:23 +0900 Subject: [PATCH] =?utf8?q?blocking/ids=E3=82=92=E5=8F=96=E5=BE=97=E3=81=97?= =?utf8?q?=E3=81=A6=E8=A9=B2=E5=BD=93=E3=81=99=E3=82=8B=E3=83=A6=E3=83=BC?= =?utf8?q?=E3=82=B6=E3=83=BC=E3=81=AE=E7=99=BA=E8=A8=80=E3=81=AFAddPost?= =?utf8?q?=E6=99=82=E3=81=AB=E5=BC=BE=E3=81=8F=E3=82=88=E3=81=86=E3=81=AB?= =?utf8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Tween/Connection/HttpTwitter.vb | 8 ++++++++ Tween/My Project/Resources.Designer.vb | 29 +++++++++++++++++++++++++- Tween/My Project/Resources.resx | 9 +++++++++ Tween/MyCommon.vb | 1 + Tween/StatusDictionary.vb | 3 +++ Tween/Tween.vb | 12 ++++++++++- Tween/Tween.vbproj | 1 + Tween/Twitter.vb | 37 ++++++++++++++++++++++++++++++++++ 8 files changed, 98 insertions(+), 2 deletions(-) diff --git a/Tween/Connection/HttpTwitter.vb b/Tween/Connection/HttpTwitter.vb index bcded2c1..bc238fb0 100644 --- a/Tween/Connection/HttpTwitter.vb +++ b/Tween/Connection/HttpTwitter.vb @@ -794,6 +794,14 @@ Public Class HttpTwitter AddressOf GetApiCallback) End Function + Public Function GetBlockUserIds(ByRef content As String) As HttpStatusCode + Return httpCon.GetContent(GetMethod, _ + CreateTwitterUri("/1/blocks/blocking/ids.json"), _ + Nothing, _ + content, _ + TwitterApiInfo.HttpHeaders, _ + AddressOf GetApiCallback) + End Function #Region "Proxy API" Private Shared _twitterUrl As String = "api.twitter.com" diff --git a/Tween/My Project/Resources.Designer.vb b/Tween/My Project/Resources.Designer.vb index 70266ef3..68f3ece0 100644 --- a/Tween/My Project/Resources.Designer.vb +++ b/Tween/My Project/Resources.Designer.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' このコードはツールによって生成されました。 -' ランタイム バージョン:4.0.30319.1 +' ランタイム バージョン:4.0.30319.225 ' ' このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 ' コードが再生成されるときに損失したりします。 @@ -2787,6 +2787,33 @@ Namespace My.Resources End Property ''' + ''' BlockIds取得中... に類似しているローカライズされた文字列を検索します。 + ''' + Friend ReadOnly Property UpdateBlockUserText1() As String + Get + Return ResourceManager.GetString("UpdateBlockUserText1", resourceCulture) + End Get + End Property + + ''' + ''' BlockIds取得エラー : に類似しているローカライズされた文字列を検索します。 + ''' + Friend ReadOnly Property UpdateBlockUserText2() As String + Get + Return ResourceManager.GetString("UpdateBlockUserText2", resourceCulture) + End Get + End Property + + ''' + ''' BlockIds取得完了 に類似しているローカライズされた文字列を検索します。 + ''' + Friend ReadOnly Property UpdateBlockUserText3() As String + Get + Return ResourceManager.GetString("UpdateBlockUserText3", resourceCulture) + End Get + End Property + + ''' ''' Followers取得中... に類似しているローカライズされた文字列を検索します。 ''' Friend ReadOnly Property UpdateFollowersMenuItem1_ClickText1() As String diff --git a/Tween/My Project/Resources.resx b/Tween/My Project/Resources.resx index 6bf742df..8c3d92ac 100644 --- a/Tween/My Project/Resources.resx +++ b/Tween/My Project/Resources.resx @@ -1081,4 +1081,13 @@ 現在のタブに表示されているイベントログを保存しますか?{0} 「はい」  :現在タブに表示されているイベントログを保存する{0} 「いいえ」 :全てのイベントログを保存する{0}「キャンセル」:保存処理をキャンセル{0}(タブ区切りのテキストファイル形式で保存します) + + BlockIds取得中... + + + BlockIds取得エラー : + + + BlockIds取得完了 + \ No newline at end of file diff --git a/Tween/MyCommon.vb b/Tween/MyCommon.vb index 97134b07..036ffa7f 100644 --- a/Tween/MyCommon.vb +++ b/Tween/MyCommon.vb @@ -123,6 +123,7 @@ Public Module MyCommon Related '関連発言 UserStream 'UserStream UserTimeline 'UserTimeline + BlockIds 'Blocking/ids ''' ErrorState 'エラー表示のみで後処理終了(認証エラー時など) End Enum diff --git a/Tween/StatusDictionary.vb b/Tween/StatusDictionary.vb index e141a35a..f880f528 100644 --- a/Tween/StatusDictionary.vb +++ b/Tween/StatusDictionary.vb @@ -453,6 +453,8 @@ Public NotInheritable Class TabInformations Private _retweets As New Dictionary(Of Long, PostClass) Private _removedTab As New Stack(Of TabClass) + Public BlockIds As New List(Of Long) + '発言の追加 'AddPost(複数回) -> DistributePosts -> SubmitUpdate @@ -1037,6 +1039,7 @@ Public NotInheritable Class TabInformations Not Item.IsMe AndAlso Me._retweets.ContainsKey(Item.RetweetedId) AndAlso Me._retweets(Item.RetweetedId).RetweetedCount > 0 Then Exit Sub + If BlockIds.Contains(Item.UserId) Then Exit Sub _statuses.Add(Item.StatusId, Item) End If If Item.RetweetedId > 0 Then diff --git a/Tween/Tween.vb b/Tween/Tween.vb index e327a8ca..19071b35 100644 --- a/Tween/Tween.vb +++ b/Tween/Tween.vb @@ -2144,6 +2144,12 @@ Public Class TweenMain Dim tb As TabClass = _statuses.GetTabByName(args.tName) ret = tw.GetRelatedResult(read, tb) rslt.addCount = _statuses.DistributePosts() + Case WORKERTYPE.BlockIds + bw.ReportProgress(50, My.Resources.UpdateBlockUserText1) + ret = tw.GetBlockUserIds() + If TabInformations.GetInstance.BlockIds.Count = 0 Then + tw.GetBlockUserIds() + End If End Select 'キャンセル要求 If bw.CancellationPending Then @@ -2257,6 +2263,8 @@ Public Class TweenMain smsg = "Related refreshed" Case WORKERTYPE.UserTimeline smsg = "UserTimeline refreshed" + Case WORKERTYPE.BlockIds + smsg = My.Resources.UpdateBlockUserText3 End Select End If Return smsg @@ -2331,7 +2339,8 @@ Public Class TweenMain rslt.type = WORKERTYPE.FavAdd OrElse _ rslt.type = WORKERTYPE.FavRemove OrElse _ rslt.type = WORKERTYPE.Related OrElse _ - rslt.type = WORKERTYPE.UserTimeline Then + rslt.type = WORKERTYPE.UserTimeline OrElse _ + rslt.type = WORKERTYPE.BlockIds Then RefreshTimeline(False) 'リスト反映 End If @@ -8391,6 +8400,7 @@ RETRY: NotifyIcon1.Visible = True If IsNetworkAvailable() Then + GetTimeline(WORKERTYPE.BlockIds, 0, 0, "") If SettingDialog.StartupFollowers Then GetTimeline(WORKERTYPE.Follower, 0, 0, "") End If diff --git a/Tween/Tween.vbproj b/Tween/Tween.vbproj index c716d984..9ae585ed 100644 --- a/Tween/Tween.vbproj +++ b/Tween/Tween.vbproj @@ -48,6 +48,7 @@ 42353,42354,42355 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 true + x86 pdbonly diff --git a/Tween/Twitter.vb b/Tween/Twitter.vb index d90d48bb..d7ab6c26 100644 --- a/Tween/Twitter.vb +++ b/Tween/Twitter.vb @@ -2851,6 +2851,43 @@ Public Class Twitter Return False End Try End Function + Public Function GetBlockUserIds() As String + If Twitter.AccountState <> ACCOUNT_STATE.Valid Then Return "" + + Dim res As HttpStatusCode + Dim content As String = "" + + Try + res = twCon.GetBlockUserIds(content) + Catch ex As Exception + Return "Err:" + ex.Message + "(" + GetCurrentMethod.Name + ")" + End Try + + Select Case res + Case HttpStatusCode.OK + Twitter.AccountState = ACCOUNT_STATE.Valid + Case HttpStatusCode.Unauthorized + Twitter.AccountState = ACCOUNT_STATE.Invalid + Return "Check your Username/Password." + Case HttpStatusCode.BadRequest + Return "Err:API Limits?" + Case Else + Return "Err:" + res.ToString() + "(" + GetCurrentMethod.Name + ")" + End Select + + Try + Dim Ids = CreateDataFromJson(Of Long())(content) + TabInformations.GetInstance.BlockIds.AddRange(Ids) + Return ("") + Catch ex As SerializationException + TraceOut(ex.Message + Environment.NewLine + content) + Return "Err:Json Parse Error(DataContractJsonSerializer)" + Catch ex As Exception + TraceOut(ex, GetCurrentMethod.Name & " " & content) + Return "Err:Invalid Json!" + End Try + + End Function Public Function GetHashList() As String() Dim hashArray As String() -- 2.11.0