mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 13:33:27 -07:00
Refactored to use Ini Configuration
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@820 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
287c33c4f4
commit
6e0ba92385
10 changed files with 161 additions and 99 deletions
42
GreenshotJiraPlugin/Forms/LoginForm.Designer.cs
generated
42
GreenshotJiraPlugin/Forms/LoginForm.Designer.cs
generated
|
@ -54,14 +54,16 @@ namespace GreenshotJiraPlugin {
|
||||||
this.textBoxUser = new System.Windows.Forms.TextBox();
|
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.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// textBoxPassword
|
// textBoxPassword
|
||||||
//
|
//
|
||||||
this.textBoxPassword.Location = new System.Drawing.Point(118, 73);
|
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.Name = "textBoxPassword";
|
||||||
this.textBoxPassword.PasswordChar = '*';
|
this.textBoxPassword.PasswordChar = '*';
|
||||||
this.textBoxPassword.Size = new System.Drawing.Size(190, 20);
|
this.textBoxPassword.Size = new System.Drawing.Size(276, 20);
|
||||||
this.textBoxPassword.TabIndex = 0;
|
this.textBoxPassword.TabIndex = 0;
|
||||||
this.textBoxPassword.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TextBoxPasswordKeyUp);
|
this.textBoxPassword.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TextBoxPasswordKeyUp);
|
||||||
//
|
//
|
||||||
|
@ -69,13 +71,14 @@ namespace GreenshotJiraPlugin {
|
||||||
//
|
//
|
||||||
this.label_password.Location = new System.Drawing.Point(12, 73);
|
this.label_password.Location = new System.Drawing.Point(12, 73);
|
||||||
this.label_password.Name = "label_password";
|
this.label_password.Name = "label_password";
|
||||||
this.label_password.Size = new System.Drawing.Size(100, 20);
|
this.label_password.Size = new System.Drawing.Size(84, 20);
|
||||||
this.label_password.TabIndex = 1;
|
this.label_password.TabIndex = 1;
|
||||||
this.label_password.Text = "Password";
|
this.label_password.Text = "Password";
|
||||||
//
|
//
|
||||||
// buttonOK
|
// buttonOK
|
||||||
//
|
//
|
||||||
this.buttonOK.Location = new System.Drawing.Point(152, 102);
|
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonOK.Location = new System.Drawing.Point(222, 139);
|
||||||
this.buttonOK.Name = "buttonOK";
|
this.buttonOK.Name = "buttonOK";
|
||||||
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonOK.TabIndex = 2;
|
this.buttonOK.TabIndex = 2;
|
||||||
|
@ -85,7 +88,8 @@ namespace GreenshotJiraPlugin {
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(233, 102);
|
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(303, 139);
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonCancel.TabIndex = 3;
|
this.buttonCancel.TabIndex = 3;
|
||||||
|
@ -97,37 +101,50 @@ namespace GreenshotJiraPlugin {
|
||||||
//
|
//
|
||||||
this.label_user.Location = new System.Drawing.Point(12, 47);
|
this.label_user.Location = new System.Drawing.Point(12, 47);
|
||||||
this.label_user.Name = "label_user";
|
this.label_user.Name = "label_user";
|
||||||
this.label_user.Size = new System.Drawing.Size(100, 20);
|
this.label_user.Size = new System.Drawing.Size(84, 20);
|
||||||
this.label_user.TabIndex = 5;
|
this.label_user.TabIndex = 5;
|
||||||
this.label_user.Text = "User";
|
this.label_user.Text = "User";
|
||||||
//
|
//
|
||||||
// textBoxUser
|
// textBoxUser
|
||||||
//
|
//
|
||||||
this.textBoxUser.Location = new System.Drawing.Point(118, 47);
|
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.Name = "textBoxUser";
|
||||||
this.textBoxUser.Size = new System.Drawing.Size(190, 20);
|
this.textBoxUser.Size = new System.Drawing.Size(276, 20);
|
||||||
this.textBoxUser.TabIndex = 4;
|
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);
|
||||||
this.label_url.Name = "label_url";
|
this.label_url.Name = "label_url";
|
||||||
this.label_url.Size = new System.Drawing.Size(100, 20);
|
this.label_url.Size = new System.Drawing.Size(84, 20);
|
||||||
this.label_url.TabIndex = 7;
|
this.label_url.TabIndex = 7;
|
||||||
this.label_url.Text = "Url";
|
this.label_url.Text = "Url";
|
||||||
//
|
//
|
||||||
// textBoxUrl
|
// textBoxUrl
|
||||||
//
|
//
|
||||||
this.textBoxUrl.Location = new System.Drawing.Point(118, 21);
|
this.textBoxUrl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.textBoxUrl.Location = new System.Drawing.Point(102, 21);
|
||||||
this.textBoxUrl.Name = "textBoxUrl";
|
this.textBoxUrl.Name = "textBoxUrl";
|
||||||
this.textBoxUrl.Size = new System.Drawing.Size(190, 20);
|
this.textBoxUrl.Size = new System.Drawing.Size(276, 20);
|
||||||
this.textBoxUrl.TabIndex = 6;
|
this.textBoxUrl.TabIndex = 6;
|
||||||
//
|
//
|
||||||
|
// checkBoxDoNotStorePassword
|
||||||
|
//
|
||||||
|
this.checkBoxDoNotStorePassword.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.checkBoxDoNotStorePassword.Location = new System.Drawing.Point(102, 99);
|
||||||
|
this.checkBoxDoNotStorePassword.Name = "checkBoxDoNotStorePassword";
|
||||||
|
this.checkBoxDoNotStorePassword.Size = new System.Drawing.Size(276, 24);
|
||||||
|
this.checkBoxDoNotStorePassword.TabIndex = 8;
|
||||||
|
this.checkBoxDoNotStorePassword.Text = "Do not store the password";
|
||||||
|
this.checkBoxDoNotStorePassword.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// LoginForm
|
// LoginForm
|
||||||
//
|
//
|
||||||
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(320, 139);
|
this.ClientSize = new System.Drawing.Size(387, 174);
|
||||||
|
this.Controls.Add(this.checkBoxDoNotStorePassword);
|
||||||
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.label_user);
|
||||||
|
@ -141,6 +158,7 @@ namespace GreenshotJiraPlugin {
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
}
|
}
|
||||||
|
private System.Windows.Forms.CheckBox checkBoxDoNotStorePassword;
|
||||||
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.TextBox textBoxUser;
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace GreenshotJiraPlugin {
|
||||||
this.label_password.Text = lang.GetString(LangKey.label_password);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +64,11 @@ namespace GreenshotJiraPlugin {
|
||||||
set {textBoxPassword.Text = value;}
|
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) {
|
||||||
this.DialogResult = DialogResult.OK;
|
this.DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
<DependentUpon>LoginForm.cs</DependentUpon>
|
<DependentUpon>LoginForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Jira.cs" />
|
<Compile Include="Jira.cs" />
|
||||||
|
<Compile Include="JiraConfiguration.cs" />
|
||||||
<Compile Include="JiraPluginBase.cs" />
|
<Compile Include="JiraPluginBase.cs" />
|
||||||
<Compile Include="Language.cs" />
|
<Compile Include="Language.cs" />
|
||||||
<Compile Include="LanguageKeys.cs" />
|
<Compile Include="LanguageKeys.cs" />
|
||||||
|
@ -83,6 +84,9 @@
|
||||||
<Generator>MSDiscoCodeGenerator</Generator>
|
<Generator>MSDiscoCodeGenerator</Generator>
|
||||||
<LastGenOutput>Reference.cs</LastGenOutput>
|
<LastGenOutput>Reference.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
|
<EmbeddedResource Include="Forms\LoginForm.resx">
|
||||||
|
<DependentUpon>LoginForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Forms" />
|
<Folder Include="Forms" />
|
||||||
|
|
|
@ -99,118 +99,59 @@ namespace Jira {
|
||||||
private const string JIRA_USER_PROPERTY = "user";
|
private const string JIRA_USER_PROPERTY = "user";
|
||||||
private const string JIRA_PASSWORD_PROPERTY = "password";
|
private const string JIRA_PASSWORD_PROPERTY = "password";
|
||||||
private const int DEFAULT_TIMEOUT = 29;
|
private const int DEFAULT_TIMEOUT = 29;
|
||||||
public const string CONFIG_FILENAME = "jira.properties";
|
|
||||||
private const string DEFAULT_JIRA_URL = "http://jira/rpc/soap/jirasoapservice-v2?wsdl";
|
|
||||||
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.jira.rpc.exception.RemoteAuthenticationException";
|
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.jira.rpc.exception.RemoteAuthenticationException";
|
||||||
private string configurationPath = null;
|
|
||||||
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 string tmpPassword = null;
|
private JiraConfiguration config;
|
||||||
private Properties config;
|
|
||||||
private JiraSoapServiceService jira;
|
private JiraSoapServiceService jira;
|
||||||
private Dictionary<string, string> userMap = new Dictionary<string, string>();
|
private Dictionary<string, string> userMap = new Dictionary<string, string>();
|
||||||
|
|
||||||
public JiraConnector(string configurationPath) {
|
public JiraConnector() {
|
||||||
this.configurationPath = configurationPath;
|
this.config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||||
this.config = LoadConfig();
|
|
||||||
jira = new JiraSoapServiceService();
|
jira = new JiraSoapServiceService();
|
||||||
jira.Url = config.GetProperty(JIRA_URL_PROPERTY);
|
jira.Url = config.Url;
|
||||||
}
|
}
|
||||||
|
|
||||||
~JiraConnector() {
|
~JiraConnector() {
|
||||||
logout();
|
logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasPassword() {
|
|
||||||
return config.ContainsKey(JIRA_PASSWORD_PROPERTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetTmpPassword(string password) {
|
|
||||||
tmpPassword = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Properties LoadConfig() {
|
|
||||||
Properties config = null;
|
|
||||||
string filename = Path.Combine(configurationPath, CONFIG_FILENAME);
|
|
||||||
if (File.Exists(filename)) {
|
|
||||||
LOG.Debug("Loading configuration from: " + filename);
|
|
||||||
config = Properties.read(filename);
|
|
||||||
}
|
|
||||||
bool changed = false;
|
|
||||||
if (config == null) {
|
|
||||||
config = new Properties();
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
if (!config.ContainsKey(JIRA_URL_PROPERTY)) {
|
|
||||||
config.AddProperty(JIRA_URL_PROPERTY, DEFAULT_JIRA_URL);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
if (!config.ContainsKey(JIRA_USER_PROPERTY)) {
|
|
||||||
config.AddProperty(JIRA_USER_PROPERTY, Environment.UserName);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
if (changed) {
|
|
||||||
SaveConfig(config);
|
|
||||||
}
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveConfig(Properties config) {
|
|
||||||
string filename = Path.Combine(configurationPath, CONFIG_FILENAME);
|
|
||||||
LOG.Debug("Saving configuration to: " + filename);
|
|
||||||
StringBuilder comment = new StringBuilder();
|
|
||||||
comment.AppendLine("# The configuration file for the JIRA Plugin");
|
|
||||||
comment.AppendLine("#");
|
|
||||||
comment.AppendLine("# Example settings:");
|
|
||||||
comment.AppendLine("# " + JIRA_URL_PROPERTY + "=" + DEFAULT_JIRA_URL);
|
|
||||||
comment.AppendLine("# " + JIRA_USER_PROPERTY + "=Username");
|
|
||||||
config.write(filename, comment.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void login() {
|
public void login() {
|
||||||
logout();
|
logout();
|
||||||
try {
|
try {
|
||||||
if (HasPassword()) {
|
if (config.HasPassword()) {
|
||||||
this.credentials = jira.login(config.GetProperty(JIRA_USER_PROPERTY), config.GetProperty(JIRA_PASSWORD_PROPERTY));
|
this.credentials = jira.login(config.User, config.Password);
|
||||||
} else if (tmpPassword != null) {
|
} else if (config.HasTmpPassword()) {
|
||||||
this.credentials = jira.login(config.GetProperty(JIRA_USER_PROPERTY), tmpPassword);
|
this.credentials = jira.login(config.User, config.TmpPassword);
|
||||||
} else {
|
} else {
|
||||||
LoginForm pwForm = new LoginForm();
|
if (config.ShowConfigDialog()) {
|
||||||
pwForm.User = config.GetProperty(JIRA_USER_PROPERTY);
|
if (config.HasPassword()) {
|
||||||
pwForm.Url = config.GetProperty(JIRA_URL_PROPERTY);
|
this.credentials = jira.login(config.User, config.Password);
|
||||||
DialogResult result = pwForm.ShowDialog();
|
} else if (config.HasTmpPassword()) {
|
||||||
if (result == DialogResult.OK) {
|
this.credentials = jira.login(config.User, config.TmpPassword);
|
||||||
tmpPassword = pwForm.Password;
|
|
||||||
if (!pwForm.User.Equals(config.GetProperty(JIRA_USER_PROPERTY)) ||!pwForm.Url.Equals(config.GetProperty(JIRA_URL_PROPERTY))) {
|
|
||||||
config.ChangeProperty(JIRA_USER_PROPERTY, pwForm.User);
|
|
||||||
config.ChangeProperty(JIRA_URL_PROPERTY, pwForm.Url);
|
|
||||||
jira.Url = config.GetProperty(JIRA_URL_PROPERTY);
|
|
||||||
SaveConfig(config);
|
|
||||||
}
|
}
|
||||||
this.credentials = jira.login(config.GetProperty(JIRA_USER_PROPERTY), tmpPassword);
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("User pressed cancel!");
|
throw new Exception("User pressed cancel!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
this.loggedInTime = DateTime.Now;
|
this.loggedInTime = DateTime.Now;
|
||||||
this.loggedIn = true;
|
this.loggedIn = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.loggedIn = false;
|
this.loggedIn = false;
|
||||||
this.credentials = null;
|
this.credentials = null;
|
||||||
e.Data.Add("user",config.GetProperty(JIRA_USER_PROPERTY));
|
e.Data.Add("user",config.User);
|
||||||
e.Data.Add("url",config.GetProperty(JIRA_URL_PROPERTY));
|
e.Data.Add("url",config.Url);
|
||||||
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
||||||
// Login failed due to wrong user or password, password should be removed!
|
// Login failed due to wrong user or password, password should be removed!
|
||||||
this.tmpPassword = null;
|
config.Password = null;
|
||||||
|
config.TmpPassword = null;
|
||||||
throw new Exception(e.Message.Replace(AUTH_FAILED_EXCEPTION_NAME+ ": ",""));
|
throw new Exception(e.Message.Replace(AUTH_FAILED_EXCEPTION_NAME+ ": ",""));
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void logout() {
|
public void logout() {
|
||||||
if (credentials != null) {
|
if (credentials != null) {
|
||||||
jira.logout(credentials);
|
jira.logout(credentials);
|
||||||
|
|
84
GreenshotJiraPlugin/JiraConfiguration.cs
Normal file
84
GreenshotJiraPlugin/JiraConfiguration.cs
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* Greenshot - a free and open source screenshot tool
|
||||||
|
* Copyright (C) 2007-2010 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using Greenshot.Core;
|
||||||
|
|
||||||
|
namespace GreenshotJiraPlugin {
|
||||||
|
/// <summary>
|
||||||
|
/// Description of CoreConfiguration.
|
||||||
|
/// </summary>
|
||||||
|
[IniSection("JIRA", Description="Greenshot JIRA Plugin configuration")]
|
||||||
|
public class JiraConfiguration : IniSection {
|
||||||
|
[IniProperty("Url", Description="Url to Jira system, including wsdl.", DefaultValue="http://jira/rpc/soap/jirasoapservice-v2?wsdl")]
|
||||||
|
public string Url;
|
||||||
|
[IniProperty("Timeout", Description="Session timeout in minutes", DefaultValue="30")]
|
||||||
|
public int Timeout;
|
||||||
|
[IniProperty("User", Description="User for the JIRA System")]
|
||||||
|
public string User;
|
||||||
|
[IniProperty("Password", Description="Password for the JIRA 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() {
|
||||||
|
return (TmpPassword != null && TmpPassword.Length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A form for username/password
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>bool true if OK was pressed, false if cancel</returns>
|
||||||
|
public bool ShowConfigDialog() {
|
||||||
|
LoginForm pwForm = new LoginForm();
|
||||||
|
if (User == null || User.Length == 0) {
|
||||||
|
User = Environment.UserName;
|
||||||
|
}
|
||||||
|
pwForm.User = User;
|
||||||
|
pwForm.Url = Url;
|
||||||
|
DialogResult result = pwForm.ShowDialog();
|
||||||
|
if (result == DialogResult.OK) {
|
||||||
|
if (pwForm.DoNotStorePassword) {
|
||||||
|
TmpPassword = pwForm.Password;
|
||||||
|
Password = null;
|
||||||
|
} else {
|
||||||
|
Password = pwForm.Password;
|
||||||
|
TmpPassword = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pwForm.User.Equals(User) ||!pwForm.Url.Equals(Url)) {
|
||||||
|
User = pwForm.User;
|
||||||
|
Url = pwForm.Url;
|
||||||
|
}
|
||||||
|
IniConfig.Save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -58,8 +58,6 @@ namespace GreenshotJiraPlugin {
|
||||||
this.captureHost = captureHost;
|
this.captureHost = captureHost;
|
||||||
this.myAttributes = myAttributes;
|
this.myAttributes = myAttributes;
|
||||||
host.OnImageEditorOpen += new OnImageEditorOpenHandler(ImageEditorOpened);
|
host.OnImageEditorOpen += new OnImageEditorOpenHandler(ImageEditorOpened);
|
||||||
|
|
||||||
this.jiraConnector = new JiraConnector(host.ConfigurationPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Shutdown() {
|
public virtual void Shutdown() {
|
||||||
|
@ -72,10 +70,7 @@ namespace GreenshotJiraPlugin {
|
||||||
/// Implementation of the IPlugin.Configure
|
/// Implementation of the IPlugin.Configure
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Configure() {
|
public virtual void Configure() {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
IniConfig.GetIniSection<JiraConfiguration>().ShowConfigDialog();
|
||||||
stringBuilder.AppendLine("This plugin doesn't have a configuration screen.");
|
|
||||||
stringBuilder.AppendLine("Configuration is stored at: " + Path.Combine(host.ConfigurationPath, JiraConnector.CONFIG_FILENAME));
|
|
||||||
MessageBox.Show(stringBuilder.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -109,6 +104,10 @@ namespace GreenshotJiraPlugin {
|
||||||
ToolStripMenuItem item = (ToolStripMenuItem)sender;
|
ToolStripMenuItem item = (ToolStripMenuItem)sender;
|
||||||
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
||||||
|
|
||||||
|
if (jiraConnector == null) {
|
||||||
|
this.jiraConnector = new JiraConnector();
|
||||||
|
}
|
||||||
|
|
||||||
JiraForm jiraForm = new JiraForm(jiraConnector);
|
JiraForm jiraForm = new JiraForm(jiraConnector);
|
||||||
if (jiraConnector.isLoggedIn()) {
|
if (jiraConnector.isLoggedIn()) {
|
||||||
//jiraForm.setFilename(host.GetFilename("png"));
|
//jiraForm.setFilename(host.GetFilename("png"));
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace GreenshotJiraPlugin {
|
||||||
label_url,
|
label_url,
|
||||||
label_user,
|
label_user,
|
||||||
label_password,
|
label_password,
|
||||||
|
label_no_password_store,
|
||||||
OK,
|
OK,
|
||||||
CANCEL,
|
CANCEL,
|
||||||
upload_success,
|
upload_success,
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
<resource name="label_password">
|
<resource name="label_password">
|
||||||
Password
|
Password
|
||||||
</resource>
|
</resource>
|
||||||
|
<resource name="label_no_password_store">
|
||||||
|
Kennwort nicht speichern
|
||||||
|
</resource>
|
||||||
<resource name="OK">
|
<resource name="OK">
|
||||||
OK
|
OK
|
||||||
</resource>
|
</resource>
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
<resource name="label_password">
|
<resource name="label_password">
|
||||||
Password
|
Password
|
||||||
</resource>
|
</resource>
|
||||||
|
<resource name="label_no_password_store">
|
||||||
|
Do not store the password
|
||||||
|
</resource>
|
||||||
<resource name="login_title">
|
<resource name="login_title">
|
||||||
Please enter your Jira login data
|
Please enter your Jira login data
|
||||||
</resource>
|
</resource>
|
||||||
|
|
|
@ -38,7 +38,10 @@
|
||||||
Gebruiker
|
Gebruiker
|
||||||
</resource>
|
</resource>
|
||||||
<resource name="label_password">
|
<resource name="label_password">
|
||||||
Password
|
Wachtwoord
|
||||||
|
</resource>
|
||||||
|
<resource name="label_no_password_store">
|
||||||
|
Het wachtwoord niet opslaan
|
||||||
</resource>
|
</resource>
|
||||||
<resource name="login_title">
|
<resource name="login_title">
|
||||||
Geef uw Jira login data
|
Geef uw Jira login data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue