OSDN Git Service

画像アップロード成功時はファイル情報クリアし、投稿のみリトライする。失敗時はアップロードからリトライするよう変更。
authorkiri_feather <kiri_feather@users.sourceforge.jp>
Wed, 14 Jul 2010 12:00:57 +0000 (12:00 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:14:01 +0000 (23:14 +0900)
BASIC認証時はTwitPicを選べないように変更

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

Tween/PictureService.vb
Tween/Tween.vb

index c03f666..ff0d9ee 100644 (file)
@@ -5,20 +5,23 @@ Imports System.Xml
 Public Class PictureService
     Private tw As Twitter
 
-    Public Function Upload(ByVal filePath As String, ByRef message As String, ByVal service As String) As String
+    Public Function Upload(ByRef filePath As String, ByRef message As String, ByVal service As String) As String
         Dim file As New FileInfo(filePath)
         If Not file.Exists Then Return "Err:File isn't exists."
         Dim st As Setting = Setting.Instance
+        Dim ret As String = ""
+        Dim upResult As Boolean = False
         Select Case service
             Case "TwitPic"
-                Return UpToTwitPic(file, message)
+                ret = UpToTwitPic(file, message, upResult)
             Case "TwitVideo"
-                Return UpToTwitVideo(file, message)
+                ret = UpToTwitVideo(file, message, upResult)
         End Select
-        Return ""
+        If upResult Then filePath = ""
+        Return ret
     End Function
 
-    Private Function UpToTwitPic(ByVal file As FileInfo, ByRef message As String) As String
+    Private Function UpToTwitPic(ByVal file As FileInfo, ByRef message As String, ByVal resultUpload As Boolean) As String
         Dim content As String = ""
         Dim ret As HttpStatusCode
         'TwitPicへの投稿
@@ -41,6 +44,8 @@ Public Class PictureService
         Else
             Return "Err:" + ret.ToString
         End If
+        'アップロードまでは成功
+        resultUpload = True
         'Twitterへの投稿
         '投稿メッセージの再構成
         If message.Length + url.Length + 1 > 140 Then
@@ -51,7 +56,7 @@ Public Class PictureService
         Return tw.PostStatus(message, 0)
     End Function
 
-    Private Function UpToTwitVideo(ByVal file As FileInfo, ByRef message As String) As String
+    Private Function UpToTwitVideo(ByVal file As FileInfo, ByRef message As String, ByVal resultUpload As Boolean) As String
         Dim content As String = ""
         Dim ret As HttpStatusCode
         'TwitVideoへの投稿
@@ -79,6 +84,8 @@ Public Class PictureService
         Else
             Return "Err:" + ret.ToString
         End If
+        'アップロードまでは成功
+        resultUpload = True
         'Twitterへの投稿
         '投稿メッセージの再構成
         If message.Length + url.Length + 1 > 140 Then
index 7711144..1a234bf 100644 (file)
@@ -254,8 +254,6 @@ Public Class TweenMain
         Public ids As List(Of Long)               'Fav追加・削除時のItemIndex
         Public sIds As List(Of Long)              'Fav追加・削除成功分のItemIndex
         Public tName As String = ""            'Fav追加・削除時のタブ名
-        Public imageService As String = ""      '画像投稿サービス名
-        Public imagePath As String = ""
     End Class
 
     '検索処理タイプ
@@ -269,6 +267,8 @@ Public Class TweenMain
         Public status As String = ""
         Public inReplyToId As Long = 0
         Public inReplyToName As String = ""
+        Public imageService As String = ""      '画像投稿サービス名
+        Public imagePath As String = ""
     End Class
 
     Private Class SpaceKeyCanceler
@@ -924,6 +924,9 @@ Public Class TweenMain
                 Outputz.OutUrl = "http://twitter.com/" + tw.Username
         End Select
 
+        '画像投稿サービス
+        SetImageServiceCombo()
+
         'ウィンドウ設定
         Me.ClientSize = _cfgLocal.FormSize
         _mySize = _cfgLocal.FormSize                     'サイズ保持(最小化・最大化されたまま終了した場合の対応用)
@@ -1877,8 +1880,8 @@ Public Class TweenMain
                     TimelinePanel.Visible = True
                     Exit Sub
                 End If
-                args.imageService = ImageServiceCombo.Text
-                args.imagePath = ImagefilePathText.Text
+                args.status.imageService = ImageServiceCombo.Text
+                args.status.imagePath = ImagefilePathText.Text
                 ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage
                 ImagefilePathText.Text = ""
                 ImageSelectionPanel.Visible = False
@@ -2077,7 +2080,7 @@ Public Class TweenMain
                 rslt.sIds = args.sIds
             Case WORKERTYPE.PostMessage
                 bw.ReportProgress(200)
-                If String.IsNullOrEmpty(args.imagePath) Then
+                If String.IsNullOrEmpty(args.status.imagePath) Then
                     For i As Integer = 0 To 1
                         ret = tw.PostStatus(args.status.status, args.status.inReplyToId)
                         If ret = "" OrElse _
@@ -2092,7 +2095,7 @@ Public Class TweenMain
                     Next
                 Else
                     Dim picSvc As New PictureService(tw)
-                    ret = picSvc.Upload(args.imagePath, args.status.status, args.imageService)
+                    ret = picSvc.Upload(args.status.imagePath, args.status.status, args.status.imageService)
                 End If
                 bw.ReportProgress(300)
                 rslt.status = args.status
@@ -3151,6 +3154,8 @@ Public Class TweenMain
                 End If
 
                 If uid <> tw.Username Then Me.doGetFollowersMenu()
+
+                SetImageServiceCombo()
             End SyncLock
         End If
 
@@ -9365,4 +9370,12 @@ RETRY:
             TimelinePanel.Visible = True
         End If
     End Sub
+
+    Private Sub SetImageServiceCombo()
+        ImageServiceCombo.Items.Clear()
+        If SettingDialog.IsOAuth Then
+            ImageServiceCombo.Items.Add("TwitPic")
+        End If
+        ImageServiceCombo.Items.Add("TwitVideo")
+    End Sub
 End Class