mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Added upload file settings, fixed missing filename, refactored the configuration out of the jiraConnector.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@888 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
6a0d928bd4
commit
19038c7c2b
3 changed files with 24 additions and 14 deletions
|
@ -100,14 +100,16 @@ namespace Jira {
|
||||||
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 JiraConfiguration config;
|
|
||||||
private JiraSoapServiceService jira;
|
private JiraSoapServiceService jira;
|
||||||
|
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 JiraConnector() {
|
public JiraConnector(string url, int timeout) {
|
||||||
this.config = IniConfig.GetIniSection<JiraConfiguration>();
|
this.url = url;
|
||||||
|
this.timeout = timeout;
|
||||||
jira = new JiraSoapServiceService();
|
jira = new JiraSoapServiceService();
|
||||||
jira.Url = config.Url;
|
jira.Url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
~JiraConnector() {
|
~JiraConnector() {
|
||||||
|
@ -132,7 +134,7 @@ namespace Jira {
|
||||||
this.loggedIn = false;
|
this.loggedIn = false;
|
||||||
this.credentials = null;
|
this.credentials = null;
|
||||||
e.Data.Add("user", user);
|
e.Data.Add("user", user);
|
||||||
e.Data.Add("url", config.Url);
|
e.Data.Add("url", url);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -142,7 +144,7 @@ namespace Jira {
|
||||||
logout();
|
logout();
|
||||||
try {
|
try {
|
||||||
// Get the system name, so the user knows where to login to
|
// Get the system name, so the user knows where to login to
|
||||||
string systemName = config.Url.Replace(JiraConfiguration.DEFAULT_POSTFIX,"");
|
string systemName = url.Replace(JiraConfiguration.DEFAULT_POSTFIX,"");
|
||||||
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
||||||
dialog.Name = null;
|
dialog.Name = null;
|
||||||
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||||
|
@ -180,7 +182,7 @@ namespace Jira {
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,17 @@ namespace GreenshotJiraPlugin {
|
||||||
public const string DEFAULT_POSTFIX = "/rpc/soap/jirasoapservice-v2?wsdl";
|
public const string DEFAULT_POSTFIX = "/rpc/soap/jirasoapservice-v2?wsdl";
|
||||||
public const string DEFAULT_PREFIX = "http://";
|
public const string DEFAULT_PREFIX = "http://";
|
||||||
private const string DEFAULT_URL = DEFAULT_PREFIX + "jira" + DEFAULT_POSTFIX;
|
private const string DEFAULT_URL = DEFAULT_PREFIX + "jira" + DEFAULT_POSTFIX;
|
||||||
|
|
||||||
[IniProperty("Url", Description="Url to Jira system, including wsdl.", DefaultValue=DEFAULT_URL)]
|
[IniProperty("Url", Description="Url to Jira 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("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;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A form for username/password
|
/// A form for username/password
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace GreenshotJiraPlugin {
|
||||||
private ICaptureHost captureHost = null;
|
private ICaptureHost captureHost = null;
|
||||||
private JiraConnector jiraConnector = null;
|
private JiraConnector jiraConnector = null;
|
||||||
private PluginAttribute myAttributes;
|
private PluginAttribute myAttributes;
|
||||||
|
private JiraConfiguration config = null;
|
||||||
|
|
||||||
public JiraPlugin() {
|
public JiraPlugin() {
|
||||||
}
|
}
|
||||||
|
@ -60,8 +61,10 @@ namespace GreenshotJiraPlugin {
|
||||||
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<JiraConfiguration>();
|
config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||||
|
if(config.IsDirty) {
|
||||||
|
IniConfig.Save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Shutdown() {
|
public virtual void Shutdown() {
|
||||||
|
@ -76,7 +79,7 @@ namespace GreenshotJiraPlugin {
|
||||||
/// Implementation of the IPlugin.Configure
|
/// Implementation of the IPlugin.Configure
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Configure() {
|
public virtual void Configure() {
|
||||||
IniConfig.GetIniSection<JiraConfiguration>().ShowConfigDialog();
|
config.ShowConfigDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -111,16 +114,16 @@ namespace GreenshotJiraPlugin {
|
||||||
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
||||||
|
|
||||||
if (jiraConnector == null) {
|
if (jiraConnector == null) {
|
||||||
this.jiraConnector = new JiraConnector();
|
this.jiraConnector = new JiraConnector(config.Url, config.Timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
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(config.UploadFormat, imageEditor.CaptureDetails));
|
||||||
DialogResult result = jiraForm.ShowDialog();
|
DialogResult result = jiraForm.ShowDialog();
|
||||||
if (result == DialogResult.OK) {
|
if (result == DialogResult.OK) {
|
||||||
using (MemoryStream stream = new MemoryStream()) {
|
using (MemoryStream stream = new MemoryStream()) {
|
||||||
imageEditor.SaveToStream(stream, OutputFormat.Png, 100);
|
imageEditor.SaveToStream(stream, config.UploadFormat, config.UploadJpegQuality);
|
||||||
byte [] buffer = stream.GetBuffer();
|
byte [] buffer = stream.GetBuffer();
|
||||||
try {
|
try {
|
||||||
jiraForm.upload(buffer);
|
jiraForm.upload(buffer);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue