OSDN Git Service

C# 8.0 のnull許容参照型を有効化
[opentween/open-tween.git] / OpenTween / Connection / IMediaUploadService.cs
1 // OpenTween - Client of Twitter
2 // Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
3 // All rights reserved.
4 //
5 // This file is part of OpenTween.
6 //
7 // This program is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by the Free
9 // Software Foundation; either version 3 of the License, or (at your option)
10 // any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 // for more details.
16 //
17 // You should have received a copy of the GNU General Public License along
18 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 // Boston, MA 02110-1301, USA.
21
22 #nullable enable
23
24 using System;
25 using System.Collections.Generic;
26 using System.IO;
27 using System.Linq;
28 using System.Text;
29 using System.Threading.Tasks;
30 using OpenTween.Api.DataModel;
31
32 namespace OpenTween.Connection
33 {
34     /// <summary>
35     /// Twitterでの画像の共有に使用できるサービスを表すインタフェース
36     /// </summary>
37     public interface IMediaUploadService
38     {
39         /// <summary>
40         /// アップロード可能なメディアの最大枚数
41         /// </summary>
42         int MaxMediaCount { get; }
43
44         /// <summary>
45         /// アップロード可能なファイルの種類を表す文字列 (OpenFileDialog.Filter に使用)
46         /// </summary>
47         string SupportedFormatsStrForDialog { get; }
48
49         /// <summary>
50         /// 代替テキストの設定が可能なサービスであるか
51         /// </summary>
52         bool CanUseAltText { get; }
53
54         /// <summary>
55         /// ファイルの拡張子からアップロード可能なフォーマットであるかを判定します
56         /// </summary>
57         /// <param name="fileExtension">アップロードするファイルの拡張子 (ピリオドを含む)</param>
58         bool CheckFileExtension(string fileExtension);
59
60         /// <summary>
61         /// ファイルサイズがアップロード可能な範囲内であるかを判定します
62         /// </summary>
63         /// <param name="fileExtension">アップロードするファイルの拡張子 (ピリオドを含む)</param>
64         /// <param name="fileSize">アップロードするファイルのサイズ (バイト単位)</param>
65         bool CheckFileSize(string fileExtension, long fileSize);
66
67         /// <summary>
68         /// アップロード可能なファイルサイズの上限を返します
69         /// </summary>
70         /// <param name="fileExtension">アップロードするファイルの拡張子 (ピリオドを含む)</param>
71         /// <returns>ファイルサイズの上限 (バイト単位, nullの場合は上限なし)</returns>
72         long? GetMaxFileSize(string fileExtension);
73
74         /// <summary>
75         /// メディアのアップロードを行い、結果の URL 等を <paramref name="postParams"/> に追加します
76         /// </summary>
77         /// <exception cref="WebApiException"/>
78         Task<PostStatusParams> UploadAsync(IMediaItem[] mediaItems, PostStatusParams postParams);
79
80         /// <summary>
81         /// 画像URLのために確保する必要のある文字数を返します
82         /// </summary>
83         /// <param name="mediaCount">アップロードするメディアの個数</param>
84         int GetReservedTextLength(int mediaCount);
85
86         /// <summary>
87         /// IMediaUploadService で使用する /help/configuration.json の値を更新します
88         /// </summary>
89         void UpdateTwitterConfiguration(TwitterConfiguration config);
90     }
91 }