Skip to content

Commit

Permalink
smuxi: Add Pastebin feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaxl committed Feb 5, 2015
1 parent be8843f commit 10ca45c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Common/BernamyBinPaste.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -100,7 +101,22 @@ public void Fpaste(string content, string nick, string language ,string expiry)
throw new ArgumentException("Check URL");
}
}

public void CtrlV(string filePath)
{
if (String.IsNullOrEmpty(filePath))
throw new System.ArgumentNullException("Parameter cannot be null or empty", "filePath");

var message = Session.UploadFile ("http://ctrlv.in//do/upload_from_file.php", "POST", filePath);
var url = ASCIIEncoding.Default.GetString(message);
var match = Regex.Match(url, @"\[url=(http://ctrlv.in/[0-9a-zA-Z]+)\]",RegexOptions.IgnoreCase);
if (match.Success) {
url = match.Groups [1].Value;
GetUrl = url;
} else {
GetUrl = ("Check URL");
}
}
}
}


33 changes: 33 additions & 0 deletions src/Frontend-GNOME/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,39 @@ protected virtual void ProcessKey(Gtk.KeyPressEventArgs e)
case Gdk.Key.End:
ChatViewManager.CurrentChatView.ScrollToEnd();
break;
case Gdk.Key.i:
case Gdk.Key.I:
string msg = String.Format(_("You are going To uplaod an Image on http://picpaste.com/."));
Gtk.MessageDialog md = new Gtk.MessageDialog(
Frontend.MainWindow,
Gtk.DialogFlags.Modal,
Gtk.MessageType.Info,
Gtk.ButtonsType.YesNo,
msg);
var res = (Gtk.ResponseType) md.Run();
md.Destroy();
if (res == Gtk.ResponseType.Yes) {
var filechooser = new Gtk.FileChooserDialog("Chose an Image", null,
Gtk.FileChooserAction.Open,
"Cancel", Gtk.ResponseType.Cancel,
"Open", Gtk.ResponseType.Accept);
var filter = new Gtk.FileFilter();
filter.Name = "PNG and JPEG images";
filter.AddMimeType("image/png");
filter.AddPattern("*.png");
filter.AddMimeType("image/jpeg");
filter.AddPattern("*.jpg");
filechooser.AddFilter(filter);

if (filechooser.Run() == (int)Gtk.ResponseType.Accept)
{
PasteBinProviders.CtrlV(filechooser.Filename);
Text = PasteBinProviders.GetUrl;
}

filechooser.Destroy();
}
break;
// anything else we let GTK+ handle
default:
e.RetVal = false;
Expand Down

0 comments on commit 10ca45c

Please sign in to comment.