3
// GNOME Do is the legal property of its developers, whose names are too
4
// numerous to list here. Please refer to the COPYRIGHT file distributed with
5
// this source distribution.
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)
12
// This program is distributed in the hope that it will be useful, but WITHOUT
13
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17
// You should have received a copy of the GNU General Public License along with
18
// this program. If not, see <http://www.gnu.org/licenses/>.
23
using System.Collections.Generic;
24
using System.Collections.Specialized;
28
public class PastebinCA : IPastebinProvider
30
private const string urlRoot = "http://pastebin.ca";
32
private NameValueCollection parameters;
33
private List<TextSyntaxItem> supportedLanguages;
37
parameters = new NameValueCollection();
38
parameters["api"] = "4xPQUdtxHQ9wxlAJ9t/ztpv36MM/ZE9G";
39
parameters["type"] = "1";
40
parameters["description"] = "";
41
parameters["content"] = "";
42
parameters["name"] = "";
43
parameters["expiry"] = "1 month";
45
supportedLanguages = new List<TextSyntaxItem>();
46
supportedLanguages.Add (new TextSyntaxItem ("Plain Text", "Plain Text", "file", "1"));
47
supportedLanguages.Add (new TextSyntaxItem ("Actionscript", "Actionscript", "file", "18"));
48
supportedLanguages.Add (new TextSyntaxItem ("Ada", "Ada", "file", "19"));
49
supportedLanguages.Add (new TextSyntaxItem ("Apache Config", "Apache Config", "file", "20"));
50
supportedLanguages.Add (new TextSyntaxItem ("ASP", "ASP", "file", "22"));
51
supportedLanguages.Add (new TextSyntaxItem ("Bash", "Bash", "file", "23"));
52
supportedLanguages.Add (new TextSyntaxItem ("C", "C", "file", "3"));
53
supportedLanguages.Add (new TextSyntaxItem ("C++", "C++", "file", "4"));
54
supportedLanguages.Add (new TextSyntaxItem ("C#", "C#", "file", "9"));
55
supportedLanguages.Add (new TextSyntaxItem ("CSS", "CSS", "file", "24"));
56
supportedLanguages.Add (new TextSyntaxItem ("Delphi", "Delphi", "file", "25"));
57
supportedLanguages.Add (new TextSyntaxItem ("Diff / Patch", "Diff / Patch", "file", "34"));
58
supportedLanguages.Add (new TextSyntaxItem ("HTML 4 Strict", "HTML 4 Strict", "file", "26"));
59
supportedLanguages.Add (new TextSyntaxItem ("Java", "Java", "file", "7"));
60
supportedLanguages.Add (new TextSyntaxItem ("Javascript", "Javascript", "file", "27"));
61
supportedLanguages.Add (new TextSyntaxItem ("LISP", "LISP", "file", "28"));
62
supportedLanguages.Add (new TextSyntaxItem ("Lua", "Lua", "file", "29"));
63
supportedLanguages.Add (new TextSyntaxItem ("Microprocessor ASM", "Microprocessor ASM", "file", "30"));
64
supportedLanguages.Add (new TextSyntaxItem ("mIRC Script", "mIRC SCript", "file", "13"));
65
supportedLanguages.Add (new TextSyntaxItem ("Objective C", "Objective C", "file", "31"));
66
supportedLanguages.Add (new TextSyntaxItem ("Perl", "Perl", "file", "6"));
67
supportedLanguages.Add (new TextSyntaxItem ("PHP", "PHP", "file", "5"));
68
supportedLanguages.Add (new TextSyntaxItem ("PL/I", "PL/I", "file", "14"));
69
supportedLanguages.Add (new TextSyntaxItem ("Python", "Python", "file", "11"));
70
supportedLanguages.Add (new TextSyntaxItem ("Ruby", "Ruby", "file", "10"));
71
supportedLanguages.Add (new TextSyntaxItem ("SQL", "SQL", "file", "16"));
72
supportedLanguages.Add (new TextSyntaxItem ("Scheme", "Scheme", "file", "17"));
73
supportedLanguages.Add (new TextSyntaxItem ("Script Log", "Script Log", "file", "33"));
74
supportedLanguages.Add (new TextSyntaxItem ("Visual BASIC", "Visual BASIC", "file", "8"));
75
supportedLanguages.Add (new TextSyntaxItem ("VB.NET", "VB.NET", "file", "32"));
76
supportedLanguages.Add (new TextSyntaxItem ("XML", "XML", "file", "15"));
79
public PastebinCA(string content, string syntax)
82
parameters["type"] = syntax;
83
parameters["content"] = content;
86
public PastebinCA(string content)
89
parameters["content"] = content;
92
public bool ShouldAllowAutoRedirect
99
get { return urlRoot + "/quiet-paste.php"; }
102
public NameValueCollection Parameters
104
get { return parameters; }
107
public string GetPasteUrlFromResponse(HttpWebResponse response)
110
using (Stream responseStream = response.GetResponseStream ()) {
111
using (StreamReader reader = new StreamReader (responseStream)) {
112
responseText = reader.ReadToEnd ();
116
string url = String.Empty;
117
if (responseText.Contains ("SUCCESS")) {
118
url = urlRoot + "/" + responseText.Split (new string[]{":"}, StringSplitOptions.RemoveEmptyEntries)[1];
124
public List<TextSyntaxItem> SupportedLanguages
126
get { return supportedLanguages; }
b'\\ No newline at end of file'