OSDN Git Service

1002にしてみた。
authorkiri_feather <kiri_feather@users.sourceforge.jp>
Sun, 27 Mar 2011 14:02:14 +0000 (14:02 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:19:19 +0000 (23:19 +0900)
SavedSearchesのAPIを追加。(使用予定はなし。)
NoRetweetIdsのAPIを追加。Followers取得のタイミングでコール。ブロックしているRTを表示しないように。発言にRT者のユーザーIDを保持するよう変更
DataModelのFollowers名をIdsに変更して汎用的に使えるように。
EventViewerDialogのSaveボタンのアンカー設定
短縮URL解決のキャッシュでキー重複例外が起きないように対処
タブ追加時にタブダイアログにタブ名が追加されないバグ修正

git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@1499 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/Connection/HttpTwitter.vb
Tween/DataModel.vb
Tween/EventViewerDialog.resx
Tween/FilterDialog.vb
Tween/My Project/AssemblyInfo.vb
Tween/ShortUrl.vb
Tween/StatusDictionary.vb
Tween/Tween.vb
Tween/Twitter.vb

index 3fbd33e..283023d 100644 (file)
@@ -540,6 +540,15 @@ Public Class HttpTwitter
                                         "Tween")
     End Function
 
+    Public Function SavedSearches(ByRef content As String) As HttpStatusCode
+        Return httpCon.GetContent(GetMethod, _
+                                        CreateTwitterUri("/1/saved_searches.json"), _
+                                        Nothing, _
+                                        content, _
+                                        Nothing, _
+                                        AddressOf GetApiCallback)
+    End Function
+
     Public Function FollowerIds(ByVal cursor As Long, ByRef content As String) As HttpStatusCode
         Dim param As New Dictionary(Of String, String)
         param.Add("cursor", cursor.ToString())
@@ -552,6 +561,18 @@ Public Class HttpTwitter
                             AddressOf GetApiCallback)
     End Function
 
+    Public Function NoRetweetIds(ByVal cursor As Long, ByRef content As String) As HttpStatusCode
+        Dim param As New Dictionary(Of String, String)
+        param.Add("cursor", cursor.ToString())
+
+        Return httpCon.GetContent(GetMethod, _
+                            CreateTwitterUri("/1/friendships/no_retweet_ids.json"), _
+                            param, _
+                            content, _
+                            TwitterApiInfo.HttpHeaders, _
+                            AddressOf GetApiCallback)
+    End Function
+
     Public Function RateLimitStatus(ByRef content As String) As HttpStatusCode
         Return httpCon.GetContent(GetMethod, _
                             CreateTwitterUri("/1/account/rate_limit_status.json"), _
index 5eb81bc..c4d1136 100644 (file)
@@ -297,7 +297,7 @@ Public Class TwitterDataModel
     End Class
 
     <DataContract()> _
-    Public Class Followers
+    Public Class Ids
         <DataMember(Name:="ids")> Public Id As Long()
         <DataMember(Name:="next_cursor")> Public NextCursor As Long
         <DataMember(Name:="previous_cursor")> Public PreviousCursor As Long
index d520346..77b7329 100644 (file)
   <data name="&gt;&gt;StatusStrip1.ZOrder" xml:space="preserve">
     <value>8</value>
   </data>
+  <data name="SaveLogButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
+    <value>Bottom, Right</value>
+  </data>
   <data name="SaveLogButton.Location" type="System.Drawing.Point, System.Drawing">
     <value>599, 239</value>
   </data>
index 6209e64..d9cebcb 100644 (file)
@@ -797,13 +797,12 @@ Public Class FilterDialog
                     list = listAvail.SelectedList
                 End Using
             End If
-            If Not DirectCast(Me.Owner, TweenMain).AddNewTab(tabName, False, tabType, list) Then
+            If Not _sts.AddTab(tabName, tabType, list) OrElse Not DirectCast(Me.Owner, TweenMain).AddNewTab(tabName, False, tabType, list) Then
                 Dim tmp As String = String.Format(My.Resources.AddTabMenuItem_ClickText1, tabName)
                 MessageBox.Show(tmp, My.Resources.AddTabMenuItem_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                 Exit Sub
             Else
                 '成功
-                _sts.AddTab(tabName, tabType, list)
                 ListTabs.Items.Add(tabName)
                 SetTabnamesToDialog()
             End If
index e4f3d92..e3076e8 100644 (file)
@@ -55,5 +55,5 @@ Imports System.Runtime.InteropServices
 ' <Assembly: AssemblyVersion("1.0.*")> 
 
 <Assembly: AssemblyVersion("0.1.0.0")> 
-<Assembly: AssemblyFileVersion("1.0.0.1")> 
+<Assembly: AssemblyFileVersion("1.0.0.2")> 
 
index 140ceac..79e3656 100644 (file)
@@ -141,7 +141,7 @@ Public Class ShortUrl
                             retUrlStr = retUrlStr.Replace("""", "%22")  'ダブルコーテーションがあるとURL終端と判断されるため、これだけ再エンコード
                             orgData = orgData.Replace("<a href=""" + orgUrl + """", "<a href=""" + retUrlStr + """")
                             SyncLock _lockObj
-                                urlCache.Add(orgUrl, retUrlStr)
+                                If Not urlCache.ContainsKey(orgUrl) Then urlCache.Add(orgUrl, retUrlStr)
                             End SyncLock
                         End If
                     Catch ex As Exception
index f46d9f0..e141a35 100644 (file)
@@ -65,6 +65,7 @@ Public NotInheritable Class PostClass
     Private _IsDeleted As Boolean = False
     Private _InReplyToUserId As Long = 0
     Public Property RetweetedCount As Integer = 0
+    Public Property RetweetedByUserId As Long = 0
 
     <FlagsAttribute()> _
     Private Enum Statuses
@@ -494,11 +495,13 @@ Public NotInheritable Class TabInformations
         End Set
     End Property
 
-    Public Sub AddTab(ByVal TabName As String, ByVal TabType As TabUsageType, ByVal List As ListElement)
+    Public Function AddTab(ByVal TabName As String, ByVal TabType As TabUsageType, ByVal List As ListElement) As Boolean
+        If _tabs.ContainsKey(TabName) Then Return False
         _tabs.Add(TabName, New TabClass(TabName, TabType, List))
         _tabs(TabName).Sorter.Mode = _sorter.Mode
         _tabs(TabName).Sorter.Order = _sorter.Order
-    End Sub
+        Return True
+    End Function
 
     'Public Sub AddTab(ByVal TabName As String, ByVal Tab As TabClass)
     '    _tabs.Add(TabName, Tab)
@@ -1625,7 +1628,7 @@ Public NotInheritable Class TabInformations
     '振り分け可能タブの判定処理
     Public Function IsDistributableTab(ByVal tabName As String) As Boolean
         Return tabName IsNot Nothing AndAlso
-            _tabs.ContainsKey(tabName) AndAlso
+            Me._tabs.ContainsKey(tabName) AndAlso
             (_tabs(tabName).TabType = TabUsageType.Mentions OrElse
              _tabs(tabName).TabType = TabUsageType.UserDefined)
     End Function
index 075414e..9cd1567 100644 (file)
@@ -2050,6 +2050,9 @@ Public Class TweenMain
             Case WORKERTYPE.Follower
                 bw.ReportProgress(50, My.Resources.UpdateFollowersMenuItem1_ClickText1)
                 ret = tw.GetFollowersApi()
+                If String.IsNullOrEmpty(ret) Then
+                    ret = tw.GetNoRetweetIdsApi()
+                End If
             Case WORKERTYPE.OpenUri
                 Dim myPath As String = Convert.ToString(args.url)
 
@@ -3351,8 +3354,8 @@ Public Class TweenMain
             End If
         Next
         'タブ追加
-        AddNewTab(tabName, False, TabUsageType.PublicSearch)
         _statuses.AddTab(tabName, TabUsageType.PublicSearch, Nothing)
+        AddNewTab(tabName, False, TabUsageType.PublicSearch)
         '追加したタブをアクティブに
         ListTab.SelectedIndex = ListTab.TabPages.Count - 1
         '検索条件の設定
@@ -6901,12 +6904,11 @@ RETRY:
                     list = listAvail.SelectedList
                 End Using
             End If
-            If Not AddNewTab(tabName, False, tabUsage, list) Then
+            If Not _statuses.AddTab(tabName, tabUsage, list) OrElse Not AddNewTab(tabName, False, tabUsage, list) Then
                 Dim tmp As String = String.Format(My.Resources.AddTabMenuItem_ClickText1, tabName)
                 MessageBox.Show(tmp, My.Resources.AddTabMenuItem_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
             Else
                 '成功
-                _statuses.AddTab(tabName, tabUsage, list)
                 SaveConfigsTabs()
                 If tabUsage = TabUsageType.PublicSearch Then
                     ListTab.SelectedIndex = ListTab.TabPages.Count - 1
@@ -7127,12 +7129,11 @@ RETRY:
                 End Using
                 Me.TopMost = SettingDialog.AlwaysTop
                 If Not String.IsNullOrEmpty(tabName) Then
-                    If Not AddNewTab(tabName, False, TabUsageType.UserDefined) Then
+                    If Not _statuses.AddTab(tabName, TabUsageType.UserDefined, Nothing) OrElse Not AddNewTab(tabName, False, TabUsageType.UserDefined) Then
                         Dim tmp As String = String.Format(My.Resources.IDRuleMenuItem_ClickText2, tabName)
                         MessageBox.Show(tmp, My.Resources.IDRuleMenuItem_ClickText3, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                         'もう一度タブ名入力
                     Else
-                        _statuses.AddTab(tabName, TabUsageType.UserDefined, Nothing)
                         Return True
                     End If
                 End If
index 90af260..8559a08 100644 (file)
@@ -45,6 +45,8 @@ Public Class Twitter
     Private ReadOnly LockObj As New Object
     Private followerId As New List(Of Long)
     Private _GetFollowerResult As Boolean = False
+    Private noRTId As New List(Of Long)
+    Private _GetNoRetweetResult As Boolean = False
 
     Private _followersCount As Integer = 0
     Private _friendsCount As Integer = 0
@@ -1463,6 +1465,7 @@ Public Class Twitter
 
             'Retweetした人
             post.RetweetedBy = status.User.ScreenName
+            post.RetweetedByUserId = status.User.Id
             post.IsMe = post.RetweetedBy.ToLower.Equals(_uid)
         Else
             post.CreatedAt = DateTimeParse(status.CreatedAt)
@@ -1533,6 +1536,9 @@ Public Class Twitter
                 End If
             End SyncLock
 
+            'RT禁止ユーザーによるもの
+            If post.RetweetedId > 0 AndAlso Me.noRTId.Contains(post.RetweetedByUserId) Then Continue For
+
             post.IsRead = read
             If post.IsMe AndAlso Not read AndAlso _readOwnPost Then post.IsRead = True
 
@@ -2290,7 +2296,7 @@ Public Class Twitter
         End Select
 
         Try
-            Dim followers = CreateDataFromJson(Of TwitterDataModel.Followers)(content)
+            Dim followers = CreateDataFromJson(Of TwitterDataModel.Ids)(content)
             followerId.AddRange(followers.Id)
             cursor = followers.NextCursor
             Return ""
@@ -2303,6 +2309,69 @@ Public Class Twitter
         End Try
     End Function
 
+    Public Function GetNoRetweetIdsApi() As String
+        If _endingFlag Then Return ""
+        Dim cursor As Long = -1
+        Dim tmpIds As New List(Of Long)(noRTId)
+
+        noRTId.Clear()
+        Do
+            Dim ret As String = NoRetweetApi(cursor)
+            If Not String.IsNullOrEmpty(ret) Then
+                noRTId.Clear()
+                noRTId.AddRange(tmpIds)
+                _GetNoRetweetResult = False
+                Return ret
+            End If
+        Loop While cursor > 0
+
+        _GetNoRetweetResult = True
+        Return ""
+    End Function
+
+    Private Function NoRetweetApi(ByRef cursor As Long) As String
+        If Twitter.AccountState <> ACCOUNT_STATE.Valid Then Return ""
+
+        Dim res As HttpStatusCode
+        Dim content As String = ""
+        Try
+            res = twCon.NoRetweetIds(cursor, 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)
+            noRTId.AddRange(ids)
+            cursor = 1  '0より大きければ何でも良い。
+            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 ReadOnly Property GetNoRetweetSuccess() As Boolean
+        Get
+            Return _GetNoRetweetResult
+        End Get
+    End Property
+
     Public Function GetListsApi() As String
         If Twitter.AccountState <> ACCOUNT_STATE.Valid Then Return ""