OSDN Git Service

HttpTwitter.SendDirectMessageメソッドをTwitterApiクラスに置き換え
[opentween/open-tween.git] / OpenTween / Connection / IHttpConnection.cs
1 // OpenTween - Client of Twitter
2 // Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 //           (c) 2008-2011 Moz (@syo68k)
4 //           (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 //           (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 //           (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
7 //           (c) 2011      Egtra (@egtra) <http://dev.activebasic.com/egtra/>
8 // All rights reserved.
9 //
10 // This file is part of OpenTween.
11 //
12 // This program is free software; you can redistribute it and/or modify it
13 // under the terms of the GNU General Public License as published by the Free
14 // Software Foundation; either version 3 of the License, or (at your option)
15 // any later version.
16 //
17 // This program is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 // for more details.
21 //
22 // You should have received a copy of the GNU General Public License along
23 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
24 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
25 // Boston, MA 02110-1301, USA.
26
27 using System;
28 using System.Collections.Generic;
29 using System.IO;
30 using System.Net;
31
32 namespace OpenTween
33 {
34     public interface IHttpConnection
35     {
36         HttpStatusCode GetContent(string method,
37                 Uri requestUri,
38                 Dictionary<string, string> param,
39                 ref Stream content,
40                 string userAgent);
41
42         HttpStatusCode GetContent(string method,
43                 Uri requestUri,
44                 Dictionary<string, string> param,
45                 ref string content,
46                 Dictionary<string, string> headerInfo,
47                 CallbackDelegate callback);
48
49         HttpStatusCode GetContent(string method,
50                 Uri requestUri,
51                 Dictionary<string, string> param,
52                 List<KeyValuePair<string, IMediaItem>> binary,
53                 ref string content,
54                 Dictionary<string, string> headerInfo,
55                 CallbackDelegate callback);
56
57         void RequestAbort();
58
59         HttpStatusCode Authenticate(Uri url, string username, string password, ref string content);
60
61         string AuthUsername { get; }
62         long AuthUserId { get; set; }
63     }
64
65     /// <summary>
66     /// APIメソッドの処理が終了し呼び出し元へ戻る直前に呼ばれるデリゲート
67     /// </summary>
68     /// <param name="sender">メソッド名</param>
69     /// <param name="code">APIメソッドの返したHTTPステータスコード</param>
70     /// <param name="headerInfo">HTTPヘッダー情報</param>
71     /// <param name="content">APIメソッドの処理結果</param>
72     /// <remarks>contentはNothingになることがあるのでチェックを必ず行うこと</remarks>
73     public delegate void CallbackDelegate(object sender, HttpStatusCode code, IDictionary<string, string> headerInfo, string content);
74 }