diff --git a/GreenshotPhotobucketPlugin/Forms/PhotobucketForm.cs b/GreenshotPhotobucketPlugin/Forms/PhotobucketForm.cs new file mode 100644 index 000000000..f32174343 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Forms/PhotobucketForm.cs @@ -0,0 +1,30 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace GreenshotPhotobucketPlugin { + /// + /// This class is needed for design-time resolving of the language files + /// + public class PhotobucketForm : GreenshotPlugin.Controls.GreenshotForm { + public PhotobucketForm() : base() { + } + } +} diff --git a/GreenshotPhotobucketPlugin/Forms/SettingsForm.Designer.cs b/GreenshotPhotobucketPlugin/Forms/SettingsForm.Designer.cs new file mode 100644 index 000000000..f1c29c50b --- /dev/null +++ b/GreenshotPhotobucketPlugin/Forms/SettingsForm.Designer.cs @@ -0,0 +1,134 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +namespace GreenshotPhotobucketPlugin { + partial class SettingsForm { + /// + /// Designer variable used to keep track of non-visual components. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Disposes resources used by the form. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) { + if (components != null) { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// + private void InitializeComponent() + { + this.buttonOK = new GreenshotPlugin.Controls.GreenshotButton(); + this.buttonCancel = new GreenshotPlugin.Controls.GreenshotButton(); + this.combobox_uploadimageformat = new GreenshotPlugin.Controls.GreenshotComboBox(); + this.label_upload_format = new GreenshotPlugin.Controls.GreenshotLabel(); + this.checkbox_usepagelink = new GreenshotPlugin.Controls.GreenshotCheckBox(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.LanguageKey = "OK"; + this.buttonOK.Location = new System.Drawing.Point(222, 129); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 2; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOKClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.LanguageKey = "CANCEL"; + this.buttonCancel.Location = new System.Drawing.Point(303, 129); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); + // + // combobox_uploadimageformat + // + this.combobox_uploadimageformat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.combobox_uploadimageformat.FormattingEnabled = true; + this.combobox_uploadimageformat.Location = new System.Drawing.Point(102, 47); + this.combobox_uploadimageformat.Name = "combobox_uploadimageformat"; + this.combobox_uploadimageformat.PropertyName = "UploadFormat"; + this.combobox_uploadimageformat.SectionName = "Photobucket"; + this.combobox_uploadimageformat.Size = new System.Drawing.Size(276, 21); + this.combobox_uploadimageformat.TabIndex = 8; + // + // label_upload_format + // + this.label_upload_format.LanguageKey = "photobucket.label_upload_format"; + this.label_upload_format.Location = new System.Drawing.Point(12, 50); + this.label_upload_format.Name = "label_upload_format"; + this.label_upload_format.Size = new System.Drawing.Size(84, 20); + this.label_upload_format.TabIndex = 9; + // + // checkbox_usepagelink + // + this.checkbox_usepagelink.AutoSize = true; + this.checkbox_usepagelink.LanguageKey = "photobucket.use_page_link"; + this.checkbox_usepagelink.Location = new System.Drawing.Point(15, 97); + this.checkbox_usepagelink.Name = "checkbox_usepagelink"; + this.checkbox_usepagelink.PropertyName = "UsePageLink"; + this.checkbox_usepagelink.SectionName = "Photobucket"; + this.checkbox_usepagelink.Size = new System.Drawing.Size(297, 17); + this.checkbox_usepagelink.TabIndex = 13; + this.checkbox_usepagelink.UseVisualStyleBackColor = true; + // + // SettingsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.ClientSize = new System.Drawing.Size(387, 168); + this.Controls.Add(this.checkbox_usepagelink); + this.Controls.Add(this.label_upload_format); + this.Controls.Add(this.combobox_uploadimageformat); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.LanguageKey = "photobucket.settings_title"; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SettingsForm"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + private GreenshotPlugin.Controls.GreenshotComboBox combobox_uploadimageformat; + private GreenshotPlugin.Controls.GreenshotLabel label_upload_format; + private GreenshotPlugin.Controls.GreenshotButton buttonCancel; + private GreenshotPlugin.Controls.GreenshotButton buttonOK; + private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_usepagelink; + } +} diff --git a/GreenshotPhotobucketPlugin/Forms/SettingsForm.cs b/GreenshotPhotobucketPlugin/Forms/SettingsForm.cs new file mode 100644 index 000000000..8c04847f5 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Forms/SettingsForm.cs @@ -0,0 +1,47 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System; +using System.Windows.Forms; +using GreenshotPlugin.Core; +using GreenshotPlugin.Controls; + +namespace GreenshotPhotobucketPlugin { + /// + /// Description of PasswordRequestForm. + /// + public partial class SettingsForm : PhotobucketForm { + public SettingsForm(PhotobucketConfiguration config) : base() { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); + } + + void ButtonOKClick(object sender, EventArgs e) { + this.DialogResult = DialogResult.OK; + } + + void ButtonCancelClick(object sender, System.EventArgs e) { + this.DialogResult = DialogResult.Cancel; + } + } +} diff --git a/GreenshotPhotobucketPlugin/GreenshotPhotobucketPlugin.csproj b/GreenshotPhotobucketPlugin/GreenshotPhotobucketPlugin.csproj new file mode 100644 index 000000000..edcd37131 --- /dev/null +++ b/GreenshotPhotobucketPlugin/GreenshotPhotobucketPlugin.csproj @@ -0,0 +1,88 @@ + + + + + {9C0ECC4C-7807-4111-916A-4F57BB29788A} + Library + GreenshotPhotobucketPlugin + GreenshotPhotobucketPlugin + v2.0 + Properties + False + False + 4 + false + OnBuildSuccess + + + + + + + + + + + + Form + + + Form + + + SettingsForm.cs + + + + + + + + + + + Never + + + Never + + + Never + + + Never + + + + + PhotobucketPlugin.cs + Designer + + + + + {5B924697-4DCD-4F98-85F1-105CB84B7341} + GreenshotPlugin + + + + +if exist "$(ProjectDir)PhotobucketCredentials.private.cs" ( + rename "$(ProjectDir)PhotobucketCredentials.cs" "PhotobucketCredentials.orig.cs" + rename "$(ProjectDir)PhotobucketCredentials.private.cs" "PhotobucketCredentials.cs" +) +"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs" + + +if exist "$(ProjectDir)PhotobucketCredentials.orig.cs" ( + rename "$(ProjectDir)PhotobucketCredentials.cs" "PhotobucketCredentials.private.cs" + rename "$(ProjectDir)PhotobucketCredentials.orig.cs" "PhotobucketCredentials.cs" +) +mkdir "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)" +copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp" +copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\" +mkdir "$(SolutionDir)bin\$(Configuration)\Languages\Plugins\$(ProjectName)" +copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)bin\$(Configuration)\Languages\Plugins\$(ProjectName)\" + + + \ No newline at end of file diff --git a/GreenshotPhotobucketPlugin/LanguageKeys.cs b/GreenshotPhotobucketPlugin/LanguageKeys.cs new file mode 100644 index 000000000..2fbd8ff67 --- /dev/null +++ b/GreenshotPhotobucketPlugin/LanguageKeys.cs @@ -0,0 +1,34 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace GreenshotPhotobucketPlugin { + public enum LangKey { + upload_menu_item, + settings_title, + label_upload_format, + label_clear, + upload_success, + upload_failure, + communication_wait, + use_page_link, + configure + } +} diff --git a/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-de-DE.xml b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-de-DE.xml new file mode 100644 index 000000000..13a0a619f --- /dev/null +++ b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-de-DE.xml @@ -0,0 +1,35 @@ + + + + + Zu Photobucket hochladen + + + Photobucket Einstellungen + + + OK + + + Cancel + + + Das Hochladen zu Photobucket war erfolgreich. + + + Es gab einen Fehler beim Hochladen zu Photobucket: + + + Bildformat + + + Übermittle Daten zu Photobucket. Bitte warten... + + + Benutze der Seite-URL statt Bild-URL im Zwischenablage + + + Einstellungen + + + \ No newline at end of file diff --git a/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-en-US.xml b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-en-US.xml new file mode 100644 index 000000000..bb1518799 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-en-US.xml @@ -0,0 +1,35 @@ + + + + + Upload to Photobucket + + + Photobucket settings + + + OK + + + Cancel + + + Successfully uploaded image to Photobucket! + + + An error occured while uploading to Photobucket: + + + Image format + + + Communicating with Photobucket. Please wait... + + + Use page link instead of image link on clipboard + + + Configure + + + \ No newline at end of file diff --git a/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-fr_FR.xml b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-fr_FR.xml new file mode 100644 index 000000000..abf41c2c2 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-fr_FR.xml @@ -0,0 +1,29 @@ + + + + + Téléverser vers Photobucket + + + Paramètres Photobucket + + + Utiliser proxy + + + L'image a été téléversée vers Photobucket avec succès ! + + + Une erreur est survenue lors du téléversement vers Photobucket: + + + Format d'image + + + Téléversement vers Photobucket, veuillez patienter... + + + Configurer + + + \ No newline at end of file diff --git a/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-it-IT.xml b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-it-IT.xml new file mode 100644 index 000000000..f3bb72df1 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-it-IT.xml @@ -0,0 +1,50 @@ + + + + + Carica su Imgur + + + Impostazioni Imgur + + + Url + + + OK + + + Annulla + + + Immagine caricata correttamente su Imgur! + + + Si è verificato un problema durante il collegamento: + + + Formato immagine + + + Comunicazione con Imgur. Attendere prego... + + + Sei sicuro si voler eliminare l'immagine {0} da Imgur? + + + Sei sicuro si voler eliminare la cronologia locale di Imgur? + + + Elimina Imgur {0} + + + Usa il collegamento alla pagina invece di quello all'immagine su appunti + + + Cronologia + + + Configurazione + + + \ No newline at end of file diff --git a/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-nl-NL.xml b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-nl-NL.xml new file mode 100644 index 000000000..cb05d4e00 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-nl-NL.xml @@ -0,0 +1,29 @@ + + + + + Naar Photobucket uploaden + + + Photobucket instellingen + + + Het uploaden naar Photobucket is geslaagt! + + + Tijdens het uploaden naar Photobucket is een fout opgetreden: + + + Beeld formaat + + + Data overdraging naar Photobucket, wachten AUB... + + + Kopieer de pagina link in plaats van de beeld link in het klembord + + + Instellingen + + + \ No newline at end of file diff --git a/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-ru-RU.xml b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-ru-RU.xml new file mode 100644 index 000000000..8b238ac90 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-ru-RU.xml @@ -0,0 +1,50 @@ + + + + + Загрузить на Imgur + + + Imgur параметры + + + Url + + + OK + + + Отмена + + + Изображение успешно загружено на Imgur! + + + Произошла ошибка при загрузке на Imgur: + + + Формат изображения + + + Общение с Imgur. Подождите... + + + Вы действительно хотите удалить изображение {0} из Imgur? + + + Вы действительно хотите удалить местную историю Imgur? + + + Удалить Imgur {0} + + + Использовать ссылку страницы, вместо ссылки изображения в буфере обмена + + + История + + + Настройка + + + \ No newline at end of file diff --git a/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-uk-UA.xml b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-uk-UA.xml new file mode 100644 index 000000000..509fd0d68 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-uk-UA.xml @@ -0,0 +1,20 @@ + + + + Вивантажити на Imgur + Параметри Imgur + Посилання + Гаразд + Скасувати + Зображення вдало вивантажено на Imgur! + Відбулась помилка при вивантаженні зображення на Imgur: + Формат зображення + З’єднання з Imgur. Будь ласка, зачекайте... + Чи дійсно Ви хочете видалити зображення {0} з Imgur? + Чи дійсно Ви хочете видалити локальну історію Imgur? + Видалити Imgur {0} + Використовувати посилання на сторінку замість посилання на зображення + Історія + Налаштувати + + diff --git a/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-zh-CN.xml b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-zh-CN.xml new file mode 100644 index 000000000..522424a35 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Languages/language_photobucketplugin-zh-CN.xml @@ -0,0 +1,23 @@ + + + + + 上传到 Photobucket + + + Photobucket 设置 + + + 已成功上传图片到 Photobucket ! + + + 上传到 Photobucket 时出现错误: + + + 图片格式 + + + 连接到 Photobucket,请稍候... + + + \ No newline at end of file diff --git a/GreenshotPhotobucketPlugin/PhotobucketConfiguration.cs b/GreenshotPhotobucketPlugin/PhotobucketConfiguration.cs new file mode 100644 index 000000000..4eab6e458 --- /dev/null +++ b/GreenshotPhotobucketPlugin/PhotobucketConfiguration.cs @@ -0,0 +1,73 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System.Windows.Forms; +using Greenshot.IniFile; +using GreenshotPlugin.Controls; +using GreenshotPlugin.Core; + +namespace GreenshotPhotobucketPlugin { + /// + /// Description of PhotobucketConfiguration. + /// + [IniSection("Photobucket", Description="Greenshot Photobucket Plugin configuration")] + public class PhotobucketConfiguration : IniSection { + [IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")] + public OutputFormat UploadFormat; + [IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")] + public int UploadJpegQuality; + [IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")] + public bool UploadReduceColors; + [IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")] + public bool UsePageLink; + [IniProperty("Token", Description = "The Photobucket token", Encrypted=true, ExcludeIfNull=true)] + public string Token; + [IniProperty("TokenSecret", Description = "The Photobucket token secret", Encrypted=true, ExcludeIfNull=true)] + public string TokenSecret; + [IniProperty("SubDomain", Description = "The Photobucket api subdomain", Encrypted = true, ExcludeIfNull = true)] + public string SubDomain; + [IniProperty("Username", Description = "The Photobucket api username", ExcludeIfNull = true)] + public string Username; + + public int Credits { + get; + set; + } + + /// + /// A form for username/password + /// + /// bool true if OK was pressed, false if cancel + public bool ShowConfigDialog() { + SettingsForm settingsForm = null; + + new PleaseWaitForm().ShowAndWait(PhotobucketPlugin.Attributes.Name, Language.GetString("photobucket", LangKey.communication_wait), + delegate() { + settingsForm = new SettingsForm(this); + } + ); + DialogResult result = settingsForm.ShowDialog(); + if (result == DialogResult.OK) { + return true; + } + return false; + } + } +} diff --git a/GreenshotPhotobucketPlugin/PhotobucketCredentials.cs b/GreenshotPhotobucketPlugin/PhotobucketCredentials.cs new file mode 100644 index 000000000..a1020b93d --- /dev/null +++ b/GreenshotPhotobucketPlugin/PhotobucketCredentials.cs @@ -0,0 +1,31 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace GreenshotPhotobucketPlugin { + /// + /// This class is merely a placeholder for the file keeping the API key and secret for photobucket integration. + /// Copy this file to PhotobucketCredentials.private.cs and fill in valid credentials. (Or empty strings, but of course you won't be able to use the Photobucket plugin then.) + /// + public static class PhotobucketCredentials { + public static string ConsumerKey = empty; + public static string ConsumerSecret = empty; + } +} diff --git a/GreenshotPhotobucketPlugin/PhotobucketDestination.cs b/GreenshotPhotobucketPlugin/PhotobucketDestination.cs new file mode 100644 index 000000000..34595e4a6 --- /dev/null +++ b/GreenshotPhotobucketPlugin/PhotobucketDestination.cs @@ -0,0 +1,73 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System.ComponentModel; +using System.Drawing; +using Greenshot.IniFile; +using Greenshot.Plugin; +using GreenshotPlugin.Core; + +namespace GreenshotPhotobucketPlugin { + /// + /// Description of PhotobucketDestination. + /// + public class PhotobucketDestination : AbstractDestination { + private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PhotobucketDestination)); + private static PhotobucketConfiguration config = IniConfig.GetIniSection(); + private PhotobucketPlugin plugin = null; + + public PhotobucketDestination(PhotobucketPlugin plugin) { + this.plugin = plugin; + } + + public override string Designation { + get { + return "Photobucket"; + } + } + + public override string Description { + get { + return Language.GetString("photobucket", LangKey.upload_menu_item); + } + } + + public override Image DisplayIcon { + get { + ComponentResourceManager resources = new ComponentResourceManager(typeof(PhotobucketPlugin)); + return (Image)resources.GetObject("Photobucket"); + } + } + + public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { + ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description); + using (Image image = surface.GetImageForExport()) { + string uploadURL = null; + bool uploaded = plugin.Upload(captureDetails, image, out uploadURL); + if (uploaded) { + exportInformation.ExportMade = true; + exportInformation.Uri = uploadURL; + } + } + ProcessExport(exportInformation, surface); + return exportInformation; + } + } +} diff --git a/GreenshotPhotobucketPlugin/PhotobucketInfo.cs b/GreenshotPhotobucketPlugin/PhotobucketInfo.cs new file mode 100644 index 000000000..9f639aab5 --- /dev/null +++ b/GreenshotPhotobucketPlugin/PhotobucketInfo.cs @@ -0,0 +1,97 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System; +using System.Xml; + +namespace GreenshotPhotobucketPlugin +{ + /// + /// Description of PhotobucketInfo. + /// + public class PhotobucketInfo : IDisposable { + private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PhotobucketInfo)); + + private string original; + public string Original { + get {return original;} + set {original = value;} + } + + private string page; + public string Page { + get {return page;} + set {page = value;} + } + + private string thumbnail; + public string Thumbnail { + get {return thumbnail;} + set {thumbnail = value;} + } + + public PhotobucketInfo() { + } + + /// + /// The public accessible Dispose + /// Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice + /// + public void Dispose() { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// This Dispose is called from the Dispose and the Destructor. + /// When disposing==true all non-managed resources should be freed too! + /// + /// + protected virtual void Dispose(bool disposing) { + if (disposing) { + } + } + + public static PhotobucketInfo ParseResponse(string response) { + LOG.Debug(response); + PhotobucketInfo PhotobucketInfo = new PhotobucketInfo(); + try { + XmlDocument doc = new XmlDocument(); + doc.LoadXml(response); + XmlNodeList nodes; + nodes = doc.GetElementsByTagName("url"); + if(nodes.Count > 0) { + PhotobucketInfo.Original = nodes.Item(0).InnerText; + } + nodes = doc.GetElementsByTagName("browseurl"); + if(nodes.Count > 0) { + PhotobucketInfo.Page = nodes.Item(0).InnerText; + } + nodes = doc.GetElementsByTagName("thumb"); + if(nodes.Count > 0) { + PhotobucketInfo.Thumbnail = nodes.Item(0).InnerText; + } + } catch(Exception e) { + LOG.ErrorFormat("Could not parse Photobucket response due to error {0}, response was: {1}", e.Message, response); + } + return PhotobucketInfo; + } + } +} diff --git a/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs b/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs new file mode 100644 index 000000000..fd9a6141b --- /dev/null +++ b/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs @@ -0,0 +1,144 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.IO; +using System.Windows.Forms; +using Greenshot.IniFile; +using Greenshot.Plugin; +using GreenshotPlugin.Controls; +using GreenshotPlugin.Core; + +namespace GreenshotPhotobucketPlugin { + /// + /// This is the GreenshotPhotobucketPlugin base code + /// + public class PhotobucketPlugin : IGreenshotPlugin { + private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PhotobucketPlugin)); + private static PhotobucketConfiguration config; + public static PluginAttribute Attributes; + private IGreenshotHost host; + private ComponentResourceManager resources; + + public PhotobucketPlugin() { + } + + public IEnumerable Destinations() { + yield return new PhotobucketDestination(this); + } + + public IEnumerable Processors() { + yield break; + } + + /// + /// Implementation of the IGreenshotPlugin.Initialize + /// + /// Use the IGreenshotPluginHost interface to register events + /// Use the ICaptureHost interface to register in the MainContextMenu + /// My own attributes + /// true if plugin is initialized, false if not (doesn't show) + public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) { + this.host = (IGreenshotHost)pluginHost; + Attributes = myAttributes; + + // Get configuration + config = IniConfig.GetIniSection(); + resources = new ComponentResourceManager(typeof(PhotobucketPlugin)); + + ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem("Photobucket " + Language.GetString("photobucket", LangKey.configure)); + itemPlugInConfig.Tag = host; + itemPlugInConfig.Click += delegate { + config.ShowConfigDialog(); + }; + itemPlugInConfig.Image = (Image)resources.GetObject("Photobucket"); + + PluginUtils.AddToContextMenu(host, itemPlugInConfig); + + return true; + } + + public virtual void Shutdown() { + LOG.Debug("Photobucket Plugin shutdown."); + } + + /// + /// Implementation of the IPlugin.Configure + /// + public virtual void Configure() { + config.ShowConfigDialog(); + } + + /// + /// This will be called when Greenshot is shutting down + /// + /// + /// + public void Closing(object sender, FormClosingEventArgs e) { + LOG.Debug("Application closing, de-registering Photobucket Plugin!"); + Shutdown(); + } + + /// + /// Upload the capture to Photobucket + /// + /// + /// + /// out string for the url + /// true if the upload succeeded + public bool Upload(ICaptureDetails captureDetails, Image image, out string uploadURL) { + OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors); + try { + string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails)); + PhotobucketInfo photobucketInfo = null; + + // Run upload in the background + new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("photobucket", LangKey.communication_wait), + delegate() { + photobucketInfo = PhotobucketUtils.UploadToPhotobucket(image, outputSettings, captureDetails.Title, filename); + } + ); + // This causes an exeption if the upload failed :) + LOG.DebugFormat("Uploaded to Photobucket page: " + photobucketInfo.Page); + uploadURL = null; + try { + if (config.UsePageLink) { + uploadURL = photobucketInfo.Page; + Clipboard.SetText(photobucketInfo.Page); + } else { + uploadURL = photobucketInfo.Original; + Clipboard.SetText(photobucketInfo.Original); + } + } catch (Exception ex) { + LOG.Error("Can't write to clipboard: ", ex); + } + return true; + } catch (Exception e) { + LOG.Error(e); + MessageBox.Show(Language.GetString("photobucket", LangKey.upload_failure) + " " + e.Message); + } + uploadURL = null; + return false; + } + } +} diff --git a/GreenshotPhotobucketPlugin/PhotobucketPlugin.resx b/GreenshotPhotobucketPlugin/PhotobucketPlugin.resx new file mode 100644 index 000000000..1727301b6 --- /dev/null +++ b/GreenshotPhotobucketPlugin/PhotobucketPlugin.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAIsSURBVDhPjZLfT1JhHMbP39DOUcKy0LpptRi57hC6YToTwzIsl26tm35dJl2oQaiX0axs1ECE + xC1CLHWzBZLVlKy2qDZFsqX/xrl4ep+XaK6rc/GMd9/383nO+x6O0tQdsllcg5vW8/d1a/eYsQiWzsme + BzbF4hoqByKrGHhSgG98xVDI0qGr1LeM6oe8z2DumEDdmZihkKVDV9FOjejmjpgoiMHknkBte1SW7RXr + o5emZbjmrMpVf+mKgmFZcOLyczzOfMfL979w494ylta2kZz/hqm5InJrv3Ez9A59wzkZsnToKpozqPMJ + 4+kiQokCMtl1vMqXUO9+CmtvElMLP+APf5CzTG5DMmTp0FVU511Z8OhFEc7rM3j7ZQcHOytXMLmjUFvC + uDa6iGCkgPznHcmQ5T5dRXUExBUqBZ2355Fe2kTN6agEqqlpi2D69TpS2ZJkyNKhKwvqPDE59PjmkM6X + ZQFfaDW17eKFXoiL8rJkyNL5V7DfMymHzVfTyH/aRsO5BExC2h3OuEeGLJ2/BX79wNlJPEx9xViqiIy4 + wuJHUdIVhyqOznDNGffIkKWjOvziCs1+vaErgWMX4/D6ZuHtn8WVwALerPzEzPKWTHZ1S864R4YsHbqi + 4I5+WHxVvPfu7HGFYRF/JcP1//t06CqafVA/0pOEJo6qtUUNJgLpCFfZ5+gvN/XFcby38tkaCVk6dJXG + 1qDNbL9V0uwDuiaOZCiCpdPYOmL7A+GxSANdcOqRAAAAAElFTkSuQmCC + + + \ No newline at end of file diff --git a/GreenshotPhotobucketPlugin/PhotobucketUtils.cs b/GreenshotPhotobucketPlugin/PhotobucketUtils.cs new file mode 100644 index 000000000..bf5d103e6 --- /dev/null +++ b/GreenshotPhotobucketPlugin/PhotobucketUtils.cs @@ -0,0 +1,118 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System; +using System.Collections.Generic; +using System.Drawing; +using Greenshot.IniFile; +using Greenshot.Plugin; +using GreenshotPlugin.Core; + +namespace GreenshotPhotobucketPlugin { + /// + /// Description of PhotobucketUtils. + /// + public class PhotobucketUtils { + private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PhotobucketUtils)); + private static PhotobucketConfiguration config = IniConfig.GetIniSection(); + + private PhotobucketUtils() { + } + + /// + /// Do the actual upload to Photobucket + /// For more details on the available parameters, see: http://api.Photobucket.com/resources_anon + /// + /// byte[] with image data + /// PhotobucketResponse + public static PhotobucketInfo UploadToPhotobucket(Image image, OutputSettings outputSettings, string title, string filename) { + string responseString; + + OAuthSession oAuth = new OAuthSession(PhotobucketCredentials.ConsumerKey, PhotobucketCredentials.ConsumerSecret); + oAuth.CheckVerifier = false; + // This url is configured in the Photobucket API settings in the Photobucket site!! + oAuth.CallbackUrl = "http://getgreenshot.org"; + oAuth.AccessTokenUrl = "http://api.photobucket.com/login/access"; + oAuth.AuthorizeUrl = "http://photobucket.com/apilogin/login"; + oAuth.RequestTokenUrl = "http://api.photobucket.com/login/request"; + oAuth.BrowserSize = new Size(1010, 400); + // Photobucket is very particular about the used methods! + oAuth.RequestTokenMethod = HTTPMethod.POST; + oAuth.AccessTokenMethod = HTTPMethod.POST; + + oAuth.LoginTitle = "Photobucket authorization"; + if (string.IsNullOrEmpty(config.SubDomain) || string.IsNullOrEmpty(config.Token) || string.IsNullOrEmpty(config.Username)) { + if (!oAuth.Authorize()) { + return null; + } + if (!string.IsNullOrEmpty(oAuth.Token)) { + config.Token = oAuth.Token; + } + if (!string.IsNullOrEmpty(oAuth.TokenSecret)) { + config.TokenSecret = oAuth.TokenSecret; + } + if (oAuth.AccessTokenResponseParameters != null && oAuth.AccessTokenResponseParameters["subdomain"] != null) { + config.SubDomain = oAuth.AccessTokenResponseParameters["subdomain"]; + } + if (oAuth.AccessTokenResponseParameters != null && oAuth.AccessTokenResponseParameters["username"] != null) { + config.Username = oAuth.AccessTokenResponseParameters["username"]; + } + IniConfig.Save(); + } + oAuth.Token = config.Token; + oAuth.TokenSecret = config.TokenSecret; + + IDictionary signedParameters = new Dictionary(); + // add album + signedParameters.Add("id", config.Username); + // add type + signedParameters.Add("type", "image"); + // add title + if (title != null) { + signedParameters.Add("title", title); + } + // add filename + if (filename != null) { + signedParameters.Add("filename", filename); + } + IDictionary unsignedParameters = new Dictionary(); + // Add image + unsignedParameters.Add("uploadfile", new ImageContainer(image, outputSettings, filename)); + try { + string apiUrl = "http://api.photobucket.com/album/!/upload"; + responseString = oAuth.MakeOAuthRequest(HTTPMethod.POST, apiUrl, apiUrl.Replace("api.photobucket.com", config.SubDomain), signedParameters, unsignedParameters, null); + } catch (Exception ex) { + LOG.Error("Error uploading to Photobucket.", ex); + throw ex; + } finally { + if (!string.IsNullOrEmpty(oAuth.Token)) { + config.Token = oAuth.Token; + } + if (!string.IsNullOrEmpty(oAuth.TokenSecret)) { + config.TokenSecret = oAuth.TokenSecret; + } + } + LOG.Info(responseString); + PhotobucketInfo PhotobucketInfo = PhotobucketInfo.ParseResponse(responseString); + LOG.Debug("Upload to Photobucket was finished"); + return PhotobucketInfo; + } + } +} diff --git a/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs.template b/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs.template new file mode 100644 index 000000000..2ee070be2 --- /dev/null +++ b/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs.template @@ -0,0 +1,54 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#region Using directives + +using System; +using System.Reflection; +using System.Runtime.InteropServices; +using Greenshot.Plugin; + +#endregion + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Greenshot-Photobucket-Plugin")] +[assembly: AssemblyDescription("A plugin to upload images to Photobucket")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Greenshot")] +[assembly: AssemblyProduct("Photobucket Plugin")] +[assembly: AssemblyCopyright("Copyright (C) 2007-2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// The PluginAttribute describes the "entryType" and if the plugin is configurable +[assembly: PluginAttribute("GreenshotPhotobucketPlugin.PhotobucketPlugin", true)] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all the values or you can use the default the Revision and +// Build Numbers by using the '*' as shown below: +[assembly: AssemblyVersion("1.1.0.$WCREV$")]