mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -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 DateTime loggedInTime = DateTime.Now;
|
||||
private bool loggedIn = false;
|
||||
private JiraConfiguration config;
|
||||
private JiraSoapServiceService jira;
|
||||
private int timeout;
|
||||
private string url;
|
||||
private Dictionary<string, string> userMap = new Dictionary<string, string>();
|
||||
|
||||
public JiraConnector() {
|
||||
this.config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
public JiraConnector(string url, int timeout) {
|
||||
this.url = url;
|
||||
this.timeout = timeout;
|
||||
jira = new JiraSoapServiceService();
|
||||
jira.Url = config.Url;
|
||||
jira.Url = url;
|
||||
}
|
||||
|
||||
~JiraConnector() {
|
||||
|
@ -132,7 +134,7 @@ namespace Jira {
|
|||
this.loggedIn = false;
|
||||
this.credentials = null;
|
||||
e.Data.Add("user", user);
|
||||
e.Data.Add("url", config.Url);
|
||||
e.Data.Add("url", url);
|
||||
throw e;
|
||||
}
|
||||
return true;
|
||||
|
@ -142,7 +144,7 @@ namespace Jira {
|
|||
logout();
|
||||
try {
|
||||
// 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);
|
||||
dialog.Name = null;
|
||||
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||
|
@ -180,7 +182,7 @@ namespace Jira {
|
|||
|
||||
private void checkCredentials() {
|
||||
if (loggedIn) {
|
||||
if (loggedInTime.AddMinutes(config.Timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||
if (loggedInTime.AddMinutes(timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||
logout();
|
||||
login();
|
||||
}
|
||||
|
|
|
@ -33,12 +33,17 @@ namespace GreenshotJiraPlugin {
|
|||
public const string DEFAULT_POSTFIX = "/rpc/soap/jirasoapservice-v2?wsdl";
|
||||
public const string DEFAULT_PREFIX = "http://";
|
||||
private const string DEFAULT_URL = DEFAULT_PREFIX + "jira" + DEFAULT_POSTFIX;
|
||||
|
||||
[IniProperty("Url", Description="Url to Jira system, including wsdl.", DefaultValue=DEFAULT_URL)]
|
||||
public string Url;
|
||||
[IniProperty("Timeout", Description="Session timeout in minutes", DefaultValue="30")]
|
||||
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>
|
||||
/// A form for username/password
|
||||
/// </summary>
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace GreenshotJiraPlugin {
|
|||
private ICaptureHost captureHost = null;
|
||||
private JiraConnector jiraConnector = null;
|
||||
private PluginAttribute myAttributes;
|
||||
private JiraConfiguration config = null;
|
||||
|
||||
public JiraPlugin() {
|
||||
}
|
||||
|
@ -60,8 +61,10 @@ namespace GreenshotJiraPlugin {
|
|||
host.OnImageEditorOpen += new OnImageEditorOpenHandler(ImageEditorOpened);
|
||||
|
||||
// Register configuration (don't need the configuration itself)
|
||||
IniConfig.GetIniSection<JiraConfiguration>();
|
||||
|
||||
config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
if(config.IsDirty) {
|
||||
IniConfig.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
|
@ -76,7 +79,7 @@ namespace GreenshotJiraPlugin {
|
|||
/// Implementation of the IPlugin.Configure
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
IniConfig.GetIniSection<JiraConfiguration>().ShowConfigDialog();
|
||||
config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -111,16 +114,16 @@ namespace GreenshotJiraPlugin {
|
|||
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
||||
|
||||
if (jiraConnector == null) {
|
||||
this.jiraConnector = new JiraConnector();
|
||||
this.jiraConnector = new JiraConnector(config.Url, config.Timeout);
|
||||
}
|
||||
|
||||
JiraForm jiraForm = new JiraForm(jiraConnector);
|
||||
if (jiraConnector.isLoggedIn()) {
|
||||
//jiraForm.setFilename(host.GetFilename("png"));
|
||||
jiraForm.setFilename(host.GetFilename(config.UploadFormat, imageEditor.CaptureDetails));
|
||||
DialogResult result = jiraForm.ShowDialog();
|
||||
if (result == DialogResult.OK) {
|
||||
using (MemoryStream stream = new MemoryStream()) {
|
||||
imageEditor.SaveToStream(stream, OutputFormat.Png, 100);
|
||||
imageEditor.SaveToStream(stream, config.UploadFormat, config.UploadJpegQuality);
|
||||
byte [] buffer = stream.GetBuffer();
|
||||
try {
|
||||
jiraForm.upload(buffer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue