From 0222aa3e58f5ed04b50c3a0359e2ec0928b4fdea Mon Sep 17 00:00:00 2001 From: kiri_feather Date: Thu, 16 Dec 2010 10:15:55 +0000 Subject: [PATCH] =?utf8?q?Stream=E9=96=A2=E9=80=A3=E3=81=AEAPI=E4=BB=95?= =?utf8?q?=E6=A7=98=E6=9B=B8=E3=81=AB=E5=90=88=E3=82=8F=E3=81=9B=E3=81=9F?= =?utf8?q?=E4=BF=AE=E6=AD=A3=EF=BC=88UserAgent,420=E3=82=A8=E3=83=A9?= =?utf8?q?=E3=83=BC=EF=BC=89=20Stream=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88?= =?utf8?q?=E3=81=A7user=5Fupdate=E3=82=92=E5=AE=9F=E8=A3=85=20=E3=82=AB?= =?utf8?q?=E3=83=A9=E3=83=A0=E8=87=AA=E5=8B=95=E8=AA=BF=E6=95=B4=E3=82=92?= =?utf8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=A2=E3=82=A6=E3=83=88?= =?utf8?q?=EF=BC=88=E8=A6=81=E6=A4=9C=E8=A8=8E=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@1213 e39ad16e-3079-482e-bb30-4b4d378143b6 --- Tween/Connection/HttpConnectionBasic.vb | 5 ++++- Tween/Connection/HttpConnectionOAuth.vb | 6 +++++- Tween/Connection/HttpTwitter.vb | 8 ++++++-- Tween/Connection/IHttpConnection.vb | 3 ++- Tween/Tween.vb | 14 +++++++------- Tween/Twitter.vb | 7 ++++++- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Tween/Connection/HttpConnectionBasic.vb b/Tween/Connection/HttpConnectionBasic.vb index dd0a0c89..0d973b61 100644 --- a/Tween/Connection/HttpConnectionBasic.vb +++ b/Tween/Connection/HttpConnectionBasic.vb @@ -116,11 +116,14 @@ Public Class HttpConnectionBasic Public Function GetContent(ByVal method As String, _ ByVal requestUri As Uri, _ ByVal param As Dictionary(Of String, String), _ - ByRef content As Stream) As HttpStatusCode Implements IHttpConnection.GetContent + ByRef content As Stream, + ByVal userAgent As String) As HttpStatusCode Implements IHttpConnection.GetContent '認証済かチェック If String.IsNullOrEmpty(Me.credential) Then Return HttpStatusCode.Unauthorized streamReq = CreateRequest(method, requestUri, param, False) + 'User-Agent指定がある場合は付加 + If Not String.IsNullOrEmpty(userAgent) Then streamReq.UserAgent = userAgent 'BASIC認証用ヘッダを付加 AppendApiInfo(streamReq) diff --git a/Tween/Connection/HttpConnectionOAuth.vb b/Tween/Connection/HttpConnectionOAuth.vb index eaa082ff..c8c06781 100644 --- a/Tween/Connection/HttpConnectionOAuth.vb +++ b/Tween/Connection/HttpConnectionOAuth.vb @@ -145,11 +145,15 @@ Public Class HttpConnectionOAuth Public Function GetContent(ByVal method As String, _ ByVal requestUri As Uri, _ ByVal param As Dictionary(Of String, String), _ - ByRef content As Stream) As HttpStatusCode Implements IHttpConnection.GetContent + ByRef content As Stream, + ByVal userAgent As String) As HttpStatusCode Implements IHttpConnection.GetContent '認証済かチェック If String.IsNullOrEmpty(token) Then Return HttpStatusCode.Unauthorized streamReq = CreateRequest(method, requestUri, param, False) + 'User-Agent指定がある場合は付加 + If Not String.IsNullOrEmpty(userAgent) Then streamReq.UserAgent = userAgent + 'OAuth認証ヘッダを付加 AppendOAuthInfo(streamReq, param, token, tokenSecret) diff --git a/Tween/Connection/HttpTwitter.vb b/Tween/Connection/HttpTwitter.vb index d8f16d87..aa9a37c7 100644 --- a/Tween/Connection/HttpTwitter.vb +++ b/Tween/Connection/HttpTwitter.vb @@ -722,7 +722,10 @@ Public Class HttpTwitter End If End Sub - Public Function UserStream(ByRef content As Stream, ByVal allAtReplies As Boolean, ByVal trackwords As String) As HttpStatusCode + Public Function UserStream(ByRef content As Stream, + ByVal allAtReplies As Boolean, + ByVal trackwords As String, + ByVal userAgent As String) As HttpStatusCode Dim param As New Dictionary(Of String, String) If allAtReplies Then @@ -736,7 +739,8 @@ Public Class HttpTwitter Return httpCon.GetContent(GetMethod, _ CreateTwitterStreamUri("/2/user.json"), _ param, _ - content) + content, + userAgent) End Function Public Sub RequestAbort() diff --git a/Tween/Connection/IHttpConnection.vb b/Tween/Connection/IHttpConnection.vb index 19bc9718..c11625fe 100644 --- a/Tween/Connection/IHttpConnection.vb +++ b/Tween/Connection/IHttpConnection.vb @@ -6,7 +6,8 @@ Public Interface IHttpConnection Function GetContent(ByVal method As String, _ ByVal requestUri As Uri, _ ByVal param As Dictionary(Of String, String), _ - ByRef content As Stream) As HttpStatusCode + ByRef content As Stream, + ByVal userAgent As String) As HttpStatusCode Function GetContent(ByVal method As String, _ ByVal requestUri As Uri, _ diff --git a/Tween/Tween.vb b/Tween/Tween.vb index cd2b9eda..4be5dc92 100644 --- a/Tween/Tween.vb +++ b/Tween/Tween.vb @@ -2559,13 +2559,13 @@ Public Class TweenMain Me.Visible AndAlso _ Me.WindowState = FormWindowState.Normal Then - Dim colNo As Integer = 2 - If _iconCol Then colNo = 1 - Dim widthDiff As Integer = Me.ClientSize.Width - Me._mySize.Width - Dim listView As DetailsListView = CType(Me._curTab.Tag, DetailsListView) - Dim column As ColumnHeader = listView.Columns(colNo) - column.Width += widthDiff - Me.MyList_ColumnWidthChanged(listView, New ColumnWidthChangedEventArgs(colNo)) + 'Dim colNo As Integer = 2 + 'If _iconCol Then colNo = 1 + 'Dim widthDiff As Integer = Me.ClientSize.Width - Me._mySize.Width + 'Dim listView As DetailsListView = CType(Me._curTab.Tag, DetailsListView) + 'Dim column As ColumnHeader = listView.Columns(colNo) + 'column.Width += widthDiff + 'Me.MyList_ColumnWidthChanged(listView, New ColumnWidthChangedEventArgs(colNo)) _mySize = Me.ClientSize _mySpDis = Me.SplitContainer1.SplitterDistance diff --git a/Tween/Twitter.vb b/Tween/Twitter.vb index 97cda1c2..fefe1a29 100644 --- a/Tween/Twitter.vb +++ b/Tween/Twitter.vb @@ -2930,6 +2930,8 @@ Public Class Twitter evt.Target = eventData.TargetObject.Name Case "block" evt.Target = "" + Case "user_update" + evt.Target = "" Case Else TraceOut("Unknown Event:" + evt.Event + Environment.NewLine + content) End Select @@ -3047,7 +3049,7 @@ Public Class Twitter RaiseEvent Started() - twCon.UserStream(st, _allAtreplies, _trackwords) + twCon.UserStream(st, _allAtreplies, _trackwords, My.Application.Info.ProductName + " v" + fileVersion) sr = New StreamReader(st) Do While _streamActive AndAlso Not sr.EndOfStream @@ -3069,6 +3071,9 @@ Public Class Twitter RaiseEvent Stopped() TraceOut("Stop:Timeout") Thread.Sleep(10 * 1000) + ElseIf CType(ex.Response, HttpWebResponse).StatusCode = 420 Then + TraceOut("Stop:Connection Limit") + Exit Do Else RaiseEvent Stopped() TraceOut("Stop:WebException " & ex.Status.ToString) -- 2.11.0