mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Refactored ConfluencePlugin to be like the JiraPlugin
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@897 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
0b3a36892d
commit
c8184d1a76
9 changed files with 142 additions and 181 deletions
|
@ -25,8 +25,9 @@ using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using GreenshotConfluencePlugin;
|
|
||||||
using Greenshot.Core;
|
using Greenshot.Core;
|
||||||
|
using Greenshot.Helpers;
|
||||||
|
using GreenshotConfluencePlugin;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For details see the Confluence API site
|
/// For details see the Confluence API site
|
||||||
|
@ -52,53 +53,75 @@ namespace Confluence {
|
||||||
private string credentials = null;
|
private string credentials = null;
|
||||||
private DateTime loggedInTime = DateTime.Now;
|
private DateTime loggedInTime = DateTime.Now;
|
||||||
private bool loggedIn = false;
|
private bool loggedIn = false;
|
||||||
private ConfluenceConfiguration config;
|
|
||||||
private ConfluenceSoapServiceService confluence;
|
private ConfluenceSoapServiceService confluence;
|
||||||
|
private int timeout;
|
||||||
|
private string url;
|
||||||
private Dictionary<string, string> userMap = new Dictionary<string, string>();
|
private Dictionary<string, string> userMap = new Dictionary<string, string>();
|
||||||
|
|
||||||
public ConfluenceConnector() {
|
public ConfluenceConnector(string url, int timeout) {
|
||||||
this.config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
this.url = url;
|
||||||
|
this.timeout = timeout;
|
||||||
confluence = new ConfluenceSoapServiceService();
|
confluence = new ConfluenceSoapServiceService();
|
||||||
confluence.Url = config.Url;
|
confluence.Url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ConfluenceConnector() {
|
~ConfluenceConnector() {
|
||||||
logout();
|
logout();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Internal login which catches the exceptions
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>true if login was done sucessfully</returns>
|
||||||
|
private bool doLogin(string user, string password) {
|
||||||
|
try {
|
||||||
|
this.credentials = confluence.login(user, password);
|
||||||
|
this.loggedInTime = DateTime.Now;
|
||||||
|
this.loggedIn = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// check if auth failed
|
||||||
|
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Not an authentication issue
|
||||||
|
this.loggedIn = false;
|
||||||
|
this.credentials = null;
|
||||||
|
e.Data.Add("user", user);
|
||||||
|
e.Data.Add("url", url);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void login() {
|
public void login() {
|
||||||
logout();
|
logout();
|
||||||
try {
|
try {
|
||||||
if (config.HasPassword()) {
|
// Get the system name, so the user knows where to login to
|
||||||
this.credentials = confluence.login(config.User, config.Password);
|
string systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX,"");
|
||||||
} else if (config.HasTmpPassword()) {
|
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
||||||
this.credentials = confluence.login(config.User, config.TmpPassword);
|
dialog.Name = null;
|
||||||
} else {
|
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||||
if (config.ShowConfigDialog()) {
|
if (doLogin(dialog.Name, dialog.Password)) {
|
||||||
if (config.HasPassword()) {
|
if (dialog.SaveChecked) {
|
||||||
this.credentials = confluence.login(config.User, config.Password);
|
dialog.Confirm(true);
|
||||||
} else if (config.HasTmpPassword()) {
|
}
|
||||||
this.credentials = confluence.login(config.User, config.TmpPassword);
|
return;
|
||||||
}
|
} else {
|
||||||
} else {
|
try {
|
||||||
throw new Exception("User pressed cancel!");
|
dialog.Confirm(false);
|
||||||
}
|
} catch (ApplicationException e) {
|
||||||
}
|
// exception handling ...
|
||||||
this.loggedInTime = DateTime.Now;
|
LOG.Error("Problem using the credentials dialog", e);
|
||||||
this.loggedIn = true;
|
}
|
||||||
} catch (Exception e) {
|
// For every windows version after XP show an incorrect password baloon
|
||||||
this.loggedIn = false;
|
dialog.IncorrectPassword = true;
|
||||||
this.credentials = null;
|
// Make sure the dialog is display, the password was false!
|
||||||
e.Data.Add("user",config.User);
|
dialog.AlwaysDisplay = true;
|
||||||
e.Data.Add("url",config.Url);
|
}
|
||||||
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
}
|
||||||
// Login failed due to wrong user or password, password should be removed!
|
} catch (ApplicationException e) {
|
||||||
config.Password = null;
|
// exception handling ...
|
||||||
config.TmpPassword = null;
|
LOG.Error("Problem using the credentials dialog", e);
|
||||||
throw new Exception(e.Message.Replace(AUTH_FAILED_EXCEPTION_NAME+ ": ",""));
|
}
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logout() {
|
public void logout() {
|
||||||
|
@ -111,7 +134,7 @@ namespace Confluence {
|
||||||
|
|
||||||
private void checkCredentials() {
|
private void checkCredentials() {
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
if (loggedInTime.AddMinutes(config.Timeout-1).CompareTo(DateTime.Now) < 0) {
|
if (loggedInTime.AddMinutes(timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||||
logout();
|
logout();
|
||||||
login();
|
login();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,50 +30,33 @@ namespace GreenshotConfluencePlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[IniSection("Confluence", Description="Greenshot Confluence Plugin configuration")]
|
[IniSection("Confluence", Description="Greenshot Confluence Plugin configuration")]
|
||||||
public class ConfluenceConfiguration : IniSection {
|
public class ConfluenceConfiguration : IniSection {
|
||||||
[IniProperty("Url", Description="Url to Confluence system, including wsdl.", DefaultValue="http://confluence/rpc/soap-axis/confluenceservice-v1?wsdl")]
|
public const string DEFAULT_POSTFIX = "/rpc/soap-axis/confluenceservice-v1?wsdl";
|
||||||
|
public const string DEFAULT_PREFIX = "http://";
|
||||||
|
private const string DEFAULT_URL = DEFAULT_PREFIX + "confluence" + DEFAULT_POSTFIX;
|
||||||
|
|
||||||
|
[IniProperty("Url", Description="Url to Confluence system, including wsdl.", DefaultValue=DEFAULT_URL)]
|
||||||
public string Url;
|
public string Url;
|
||||||
[IniProperty("Timeout", Description="Session timeout in minutes", DefaultValue="30")]
|
[IniProperty("Timeout", Description="Session timeout in minutes", DefaultValue="30")]
|
||||||
public int Timeout;
|
public int Timeout;
|
||||||
[IniProperty("User", Description="User for the Confluence System")]
|
|
||||||
public string User;
|
|
||||||
[IniProperty("Password", Description="Password for the Confluence System, belonging to user.")]
|
|
||||||
public string Password;
|
|
||||||
|
|
||||||
// This will not be stored
|
|
||||||
public string TmpPassword;
|
|
||||||
|
|
||||||
public bool HasPassword() {
|
|
||||||
return (Password != null && Password.Length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasTmpPassword() {
|
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="Png")]
|
||||||
return (TmpPassword != null && TmpPassword.Length > 0);
|
public OutputFormat UploadFormat;
|
||||||
}
|
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||||
|
public int UploadJpegQuality;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A form for username/password
|
/// A form for username/password
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>bool true if OK was pressed, false if cancel</returns>
|
/// <returns>bool true if OK was pressed, false if cancel</returns>
|
||||||
public bool ShowConfigDialog() {
|
public bool ShowConfigDialog() {
|
||||||
LoginForm pwForm = new LoginForm();
|
SettingsForm settingsForm = new SettingsForm();
|
||||||
if (User == null || User.Length == 0) {
|
settingsForm.Url = Url;
|
||||||
User = Environment.UserName;
|
settingsForm.UploadFormat = UploadFormat.ToString();
|
||||||
}
|
DialogResult result = settingsForm.ShowDialog();
|
||||||
pwForm.User = User;
|
|
||||||
pwForm.Url = Url;
|
|
||||||
DialogResult result = pwForm.ShowDialog();
|
|
||||||
if (result == DialogResult.OK) {
|
if (result == DialogResult.OK) {
|
||||||
if (pwForm.DoNotStorePassword) {
|
if (!settingsForm.Url.Equals(Url) || !settingsForm.UploadFormat.Equals(UploadFormat.ToString())) {
|
||||||
TmpPassword = pwForm.Password;
|
Url = settingsForm.Url;
|
||||||
Password = null;
|
UploadFormat = (OutputFormat)Enum.Parse(typeof(OutputFormat), settingsForm.UploadFormat);
|
||||||
} else {
|
|
||||||
Password = pwForm.Password;
|
|
||||||
TmpPassword = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pwForm.User.Equals(User) ||!pwForm.Url.Equals(Url)) {
|
|
||||||
User = pwForm.User;
|
|
||||||
Url = pwForm.Url;
|
|
||||||
}
|
}
|
||||||
IniConfig.Save();
|
IniConfig.Save();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
private ICaptureHost captureHost = null;
|
private ICaptureHost captureHost = null;
|
||||||
private ConfluenceConnector confluenceConnector = null;
|
private ConfluenceConnector confluenceConnector = null;
|
||||||
private PluginAttribute myAttributes;
|
private PluginAttribute myAttributes;
|
||||||
|
private ConfluenceConfiguration config = null;
|
||||||
|
|
||||||
public ConfluencePlugin() {
|
public ConfluencePlugin() {
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,10 @@ namespace GreenshotConfluencePlugin {
|
||||||
host.OnImageEditorOpen += new OnImageEditorOpenHandler(ImageEditorOpened);
|
host.OnImageEditorOpen += new OnImageEditorOpenHandler(ImageEditorOpened);
|
||||||
|
|
||||||
// Register configuration (don't need the configuration itself)
|
// Register configuration (don't need the configuration itself)
|
||||||
IniConfig.GetIniSection<ConfluenceConfiguration>();
|
config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
||||||
|
if(config.IsDirty) {
|
||||||
|
IniConfig.Save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Shutdown() {
|
public virtual void Shutdown() {
|
||||||
|
@ -75,7 +79,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
/// Implementation of the IPlugin.Configure
|
/// Implementation of the IPlugin.Configure
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Configure() {
|
public virtual void Configure() {
|
||||||
IniConfig.GetIniSection<ConfluenceConfiguration>().ShowConfigDialog();
|
config.ShowConfigDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -110,21 +114,24 @@ namespace GreenshotConfluencePlugin {
|
||||||
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
||||||
|
|
||||||
if (confluenceConnector == null) {
|
if (confluenceConnector == null) {
|
||||||
this.confluenceConnector = new ConfluenceConnector();
|
confluenceConnector = new ConfluenceConnector(config.Url, config.Timeout);
|
||||||
}
|
}
|
||||||
ConfluenceForm confluenceForm = new ConfluenceForm(confluenceConnector);
|
|
||||||
confluenceForm.setFilename(host.GetFilename(OutputFormat.Png, imageEditor.CaptureDetails));
|
if (confluenceConnector.isLoggedIn()) {
|
||||||
DialogResult result = confluenceForm.ShowDialog();
|
ConfluenceForm confluenceForm = new ConfluenceForm(confluenceConnector);
|
||||||
if (result == DialogResult.OK) {
|
confluenceForm.setFilename(host.GetFilename(config.UploadFormat, imageEditor.CaptureDetails));
|
||||||
using (MemoryStream stream = new MemoryStream()) {
|
DialogResult result = confluenceForm.ShowDialog();
|
||||||
imageEditor.SaveToStream(stream, OutputFormat.Png, 100);
|
if (result == DialogResult.OK) {
|
||||||
byte [] buffer = stream.GetBuffer();
|
using (MemoryStream stream = new MemoryStream()) {
|
||||||
try {
|
imageEditor.SaveToStream(stream, config.UploadFormat, config.UploadJpegQuality);
|
||||||
confluenceForm.upload(buffer);
|
byte [] buffer = stream.GetBuffer();
|
||||||
LOG.Debug("Uploaded to Confluence.");
|
try {
|
||||||
MessageBox.Show(lang.GetString(LangKey.upload_success));
|
confluenceForm.upload(buffer);
|
||||||
} catch(Exception e) {
|
LOG.Debug("Uploaded to Confluence.");
|
||||||
MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.Message);
|
MessageBox.Show(lang.GetString(LangKey.upload_success));
|
||||||
|
} catch(Exception e) {
|
||||||
|
MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace GreenshotConfluencePlugin {
|
namespace GreenshotConfluencePlugin {
|
||||||
partial class LoginForm {
|
partial class SettingsForm {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Designer variable used to keep track of non-visual components.
|
/// Designer variable used to keep track of non-visual components.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -46,35 +46,14 @@ namespace GreenshotConfluencePlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.textBoxPassword = new System.Windows.Forms.TextBox();
|
|
||||||
this.label_password = new System.Windows.Forms.Label();
|
|
||||||
this.buttonOK = new System.Windows.Forms.Button();
|
this.buttonOK = new System.Windows.Forms.Button();
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
this.label_user = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxUser = new System.Windows.Forms.TextBox();
|
|
||||||
this.label_url = new System.Windows.Forms.Label();
|
this.label_url = new System.Windows.Forms.Label();
|
||||||
this.textBoxUrl = new System.Windows.Forms.TextBox();
|
this.textBoxUrl = new System.Windows.Forms.TextBox();
|
||||||
this.checkBoxDoNotStorePassword = new System.Windows.Forms.CheckBox();
|
this.combobox_uploadimageformat = new System.Windows.Forms.ComboBox();
|
||||||
|
this.label_upload_format = new System.Windows.Forms.Label();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// textBoxPassword
|
|
||||||
//
|
|
||||||
this.textBoxPassword.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.textBoxPassword.Location = new System.Drawing.Point(102, 73);
|
|
||||||
this.textBoxPassword.Name = "textBoxPassword";
|
|
||||||
this.textBoxPassword.PasswordChar = '*';
|
|
||||||
this.textBoxPassword.Size = new System.Drawing.Size(276, 20);
|
|
||||||
this.textBoxPassword.TabIndex = 0;
|
|
||||||
this.textBoxPassword.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TextBoxPasswordKeyUp);
|
|
||||||
//
|
|
||||||
// label_password
|
|
||||||
//
|
|
||||||
this.label_password.Location = new System.Drawing.Point(12, 73);
|
|
||||||
this.label_password.Name = "label_password";
|
|
||||||
this.label_password.Size = new System.Drawing.Size(84, 20);
|
|
||||||
this.label_password.TabIndex = 1;
|
|
||||||
this.label_password.Text = "Password";
|
|
||||||
//
|
|
||||||
// buttonOK
|
// buttonOK
|
||||||
//
|
//
|
||||||
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
@ -97,22 +76,6 @@ namespace GreenshotConfluencePlugin {
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick);
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick);
|
||||||
//
|
//
|
||||||
// label_user
|
|
||||||
//
|
|
||||||
this.label_user.Location = new System.Drawing.Point(12, 47);
|
|
||||||
this.label_user.Name = "label_user";
|
|
||||||
this.label_user.Size = new System.Drawing.Size(84, 20);
|
|
||||||
this.label_user.TabIndex = 5;
|
|
||||||
this.label_user.Text = "User";
|
|
||||||
//
|
|
||||||
// textBoxUser
|
|
||||||
//
|
|
||||||
this.textBoxUser.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.textBoxUser.Location = new System.Drawing.Point(102, 47);
|
|
||||||
this.textBoxUser.Name = "textBoxUser";
|
|
||||||
this.textBoxUser.Size = new System.Drawing.Size(276, 20);
|
|
||||||
this.textBoxUser.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// label_url
|
// label_url
|
||||||
//
|
//
|
||||||
this.label_url.Location = new System.Drawing.Point(12, 21);
|
this.label_url.Location = new System.Drawing.Point(12, 21);
|
||||||
|
@ -129,44 +92,43 @@ namespace GreenshotConfluencePlugin {
|
||||||
this.textBoxUrl.Size = new System.Drawing.Size(276, 20);
|
this.textBoxUrl.Size = new System.Drawing.Size(276, 20);
|
||||||
this.textBoxUrl.TabIndex = 6;
|
this.textBoxUrl.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// checkBoxDoNotStorePassword
|
// combobox_uploadimageformat
|
||||||
//
|
//
|
||||||
this.checkBoxDoNotStorePassword.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.combobox_uploadimageformat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.checkBoxDoNotStorePassword.Checked = true;
|
this.combobox_uploadimageformat.FormattingEnabled = true;
|
||||||
this.checkBoxDoNotStorePassword.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.combobox_uploadimageformat.Location = new System.Drawing.Point(102, 47);
|
||||||
this.checkBoxDoNotStorePassword.Location = new System.Drawing.Point(102, 99);
|
this.combobox_uploadimageformat.Name = "combobox_uploadimageformat";
|
||||||
this.checkBoxDoNotStorePassword.Name = "checkBoxDoNotStorePassword";
|
this.combobox_uploadimageformat.Size = new System.Drawing.Size(276, 21);
|
||||||
this.checkBoxDoNotStorePassword.Size = new System.Drawing.Size(276, 24);
|
this.combobox_uploadimageformat.TabIndex = 8;
|
||||||
this.checkBoxDoNotStorePassword.TabIndex = 8;
|
|
||||||
this.checkBoxDoNotStorePassword.Text = "Do not store the password";
|
|
||||||
this.checkBoxDoNotStorePassword.UseVisualStyleBackColor = true;
|
|
||||||
//
|
//
|
||||||
// LoginForm
|
// 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;
|
||||||
|
this.label_upload_format.Text = "Upload format";
|
||||||
|
//
|
||||||
|
// SettingsForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(387, 174);
|
this.ClientSize = new System.Drawing.Size(387, 174);
|
||||||
this.Controls.Add(this.checkBoxDoNotStorePassword);
|
this.Controls.Add(this.label_upload_format);
|
||||||
|
this.Controls.Add(this.combobox_uploadimageformat);
|
||||||
this.Controls.Add(this.label_url);
|
this.Controls.Add(this.label_url);
|
||||||
this.Controls.Add(this.textBoxUrl);
|
this.Controls.Add(this.textBoxUrl);
|
||||||
this.Controls.Add(this.label_user);
|
|
||||||
this.Controls.Add(this.textBoxUser);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
this.Controls.Add(this.buttonCancel);
|
||||||
this.Controls.Add(this.buttonOK);
|
this.Controls.Add(this.buttonOK);
|
||||||
this.Controls.Add(this.label_password);
|
this.Name = "SettingsForm";
|
||||||
this.Controls.Add(this.textBoxPassword);
|
|
||||||
this.Name = "LoginForm";
|
|
||||||
this.Text = "Please enter your Confluence data";
|
this.Text = "Please enter your Confluence data";
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
}
|
}
|
||||||
private System.Windows.Forms.CheckBox checkBoxDoNotStorePassword;
|
private System.Windows.Forms.ComboBox combobox_uploadimageformat;
|
||||||
|
private System.Windows.Forms.Label label_upload_format;
|
||||||
private System.Windows.Forms.TextBox textBoxUrl;
|
private System.Windows.Forms.TextBox textBoxUrl;
|
||||||
private System.Windows.Forms.Label label_url;
|
private System.Windows.Forms.Label label_url;
|
||||||
private System.Windows.Forms.TextBox textBoxUser;
|
|
||||||
private System.Windows.Forms.Label label_password;
|
|
||||||
private System.Windows.Forms.Label label_user;
|
|
||||||
private System.Windows.Forms.TextBox textBoxPassword;
|
|
||||||
private System.Windows.Forms.Button buttonCancel;
|
private System.Windows.Forms.Button buttonCancel;
|
||||||
private System.Windows.Forms.Button buttonOK;
|
private System.Windows.Forms.Button buttonOK;
|
||||||
}
|
}
|
|
@ -28,25 +28,28 @@ namespace GreenshotConfluencePlugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of PasswordRequestForm.
|
/// Description of PasswordRequestForm.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class LoginForm : Form {
|
public partial class SettingsForm : Form {
|
||||||
private ILanguage lang = Language.GetInstance();
|
private ILanguage lang = Language.GetInstance();
|
||||||
|
|
||||||
public LoginForm() {
|
public SettingsForm() {
|
||||||
//
|
//
|
||||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||||
//
|
//
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
InitializeTexts();
|
InitializeTexts();
|
||||||
|
|
||||||
|
combobox_uploadimageformat.Items.Clear();
|
||||||
|
foreach(OutputFormat format in Enum.GetValues(typeof(OutputFormat))) {
|
||||||
|
combobox_uploadimageformat.Items.Add(format.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeTexts() {
|
private void InitializeTexts() {
|
||||||
this.label_url.Text = lang.GetString(LangKey.label_url);
|
this.label_url.Text = lang.GetString(LangKey.label_url);
|
||||||
this.label_user.Text = lang.GetString(LangKey.label_user);
|
|
||||||
this.label_password.Text = lang.GetString(LangKey.label_password);
|
|
||||||
this.buttonOK.Text = lang.GetString(LangKey.OK);
|
this.buttonOK.Text = lang.GetString(LangKey.OK);
|
||||||
this.buttonCancel.Text = lang.GetString(LangKey.CANCEL);
|
this.buttonCancel.Text = lang.GetString(LangKey.CANCEL);
|
||||||
this.checkBoxDoNotStorePassword.Text = lang.GetString(LangKey.label_no_password_store);
|
|
||||||
this.Text = lang.GetString(LangKey.login_title);
|
this.Text = lang.GetString(LangKey.login_title);
|
||||||
|
this.label_upload_format.Text = lang.GetString(LangKey.label_upload_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Url {
|
public string Url {
|
||||||
|
@ -54,19 +57,9 @@ namespace GreenshotConfluencePlugin {
|
||||||
set {textBoxUrl.Text = value;}
|
set {textBoxUrl.Text = value;}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string User {
|
public string UploadFormat {
|
||||||
get {return textBoxUser.Text;}
|
get {return combobox_uploadimageformat.Text;}
|
||||||
set {textBoxUser.Text = value;}
|
set {combobox_uploadimageformat.Text = value;}
|
||||||
}
|
|
||||||
|
|
||||||
public string Password {
|
|
||||||
get {return textBoxPassword.Text;}
|
|
||||||
set {textBoxPassword.Text = value;}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DoNotStorePassword {
|
|
||||||
get {return checkBoxDoNotStorePassword.Checked;}
|
|
||||||
set {checkBoxDoNotStorePassword.Checked = value;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonOKClick(object sender, EventArgs e) {
|
void ButtonOKClick(object sender, EventArgs e) {
|
||||||
|
@ -76,11 +69,5 @@ namespace GreenshotConfluencePlugin {
|
||||||
void ButtonCancelClick(object sender, System.EventArgs e) {
|
void ButtonCancelClick(object sender, System.EventArgs e) {
|
||||||
this.DialogResult = DialogResult.Cancel;
|
this.DialogResult = DialogResult.Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBoxPasswordKeyUp(object sender, KeyEventArgs e) {
|
|
||||||
if (e.KeyCode == Keys.Enter) {
|
|
||||||
this.DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -56,9 +56,9 @@
|
||||||
<Compile Include="Forms\ConfluenceForm.Designer.cs">
|
<Compile Include="Forms\ConfluenceForm.Designer.cs">
|
||||||
<DependentUpon>ConfluenceForm.cs</DependentUpon>
|
<DependentUpon>ConfluenceForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Forms\LoginForm.cs" />
|
<Compile Include="Forms\SettingsForm.cs" />
|
||||||
<Compile Include="Forms\LoginForm.Designer.cs">
|
<Compile Include="Forms\SettingsForm.Designer.cs">
|
||||||
<DependentUpon>LoginForm.cs</DependentUpon>
|
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Confluence.cs" />
|
<Compile Include="Confluence.cs" />
|
||||||
<Compile Include="Language.cs" />
|
<Compile Include="Language.cs" />
|
||||||
|
|
|
@ -25,9 +25,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
login_error,
|
login_error,
|
||||||
login_title,
|
login_title,
|
||||||
label_url,
|
label_url,
|
||||||
label_user,
|
label_upload_format,
|
||||||
label_password,
|
|
||||||
label_no_password_store,
|
|
||||||
OK,
|
OK,
|
||||||
CANCEL,
|
CANCEL,
|
||||||
upload_success,
|
upload_success,
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace GreenshotJiraPlugin {
|
||||||
public string Url;
|
public string Url;
|
||||||
[IniProperty("Timeout", Description="Session timeout in minutes", DefaultValue="30")]
|
[IniProperty("Timeout", Description="Session timeout in minutes", DefaultValue="30")]
|
||||||
public int Timeout;
|
public int Timeout;
|
||||||
|
|
||||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="Png")]
|
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="Png")]
|
||||||
public OutputFormat UploadFormat;
|
public OutputFormat UploadFormat;
|
||||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace GreenshotJiraPlugin {
|
||||||
public virtual void Configure() {
|
public virtual void Configure() {
|
||||||
config.ShowConfigDialog();
|
config.ShowConfigDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This will be called when Greenshot is shutting down
|
/// This will be called when Greenshot is shutting down
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -114,11 +114,11 @@ namespace GreenshotJiraPlugin {
|
||||||
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
||||||
|
|
||||||
if (jiraConnector == null) {
|
if (jiraConnector == null) {
|
||||||
this.jiraConnector = new JiraConnector(config.Url, config.Timeout);
|
jiraConnector = new JiraConnector(config.Url, config.Timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
JiraForm jiraForm = new JiraForm(jiraConnector);
|
|
||||||
if (jiraConnector.isLoggedIn()) {
|
if (jiraConnector.isLoggedIn()) {
|
||||||
|
JiraForm jiraForm = new JiraForm(jiraConnector);
|
||||||
jiraForm.setFilename(host.GetFilename(config.UploadFormat, imageEditor.CaptureDetails));
|
jiraForm.setFilename(host.GetFilename(config.UploadFormat, imageEditor.CaptureDetails));
|
||||||
DialogResult result = jiraForm.ShowDialog();
|
DialogResult result = jiraForm.ShowDialog();
|
||||||
if (result == DialogResult.OK) {
|
if (result == DialogResult.OK) {
|
||||||
|
@ -127,6 +127,7 @@ namespace GreenshotJiraPlugin {
|
||||||
byte [] buffer = stream.GetBuffer();
|
byte [] buffer = stream.GetBuffer();
|
||||||
try {
|
try {
|
||||||
jiraForm.upload(buffer);
|
jiraForm.upload(buffer);
|
||||||
|
LOG.Debug("Uploaded to Jira.");
|
||||||
MessageBox.Show(lang.GetString(LangKey.upload_success));
|
MessageBox.Show(lang.GetString(LangKey.upload_success));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.Message);
|
MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.Message);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue