mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Moving back to trunk!
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1602 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
ad265b2c54
commit
8d458998a1
332 changed files with 17647 additions and 9466 deletions
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src='jquery-1.7.1.min.js' type='text/javascript'></script>
|
||||
<script src='background.js' type='text/javascript'></script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
function sendCaptureToGreenshot(dataURL) {
|
||||
window.console.info('Sending data...');
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST",
|
||||
contentType: "image/png;base64",
|
||||
dataType: "text",
|
||||
processData: false,
|
||||
data: dataURL,
|
||||
url: 'http://localhost:11234',
|
||||
success : function (text) {
|
||||
window.console.info('Got: ' + text);
|
||||
},
|
||||
error : function () {
|
||||
alert("Couldn't send capture, please check if Greenshot is running!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function capture() {
|
||||
window.console.info('Starting capture');
|
||||
try {
|
||||
chrome.tabs.captureVisibleTab(null, {format:'png'}, captureTaken);
|
||||
} catch(exception) {
|
||||
alert( exception.toString());
|
||||
}
|
||||
}
|
||||
|
||||
chrome.browserAction.onClicked.addListener(function(tab) {capture();});
|
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
4
GreenshotNetworkImportPlugin/Browser-Plugins/Chrome/jquery-1.7.1.min.js
vendored
Normal file
4
GreenshotNetworkImportPlugin/Browser-Plugins/Chrome/jquery-1.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "Greenshot",
|
||||
"version": "1.0",
|
||||
"description": "Adds a Greenshot capture button",
|
||||
"icons": { "128": "greenshot.png" },
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"clipboardRead",
|
||||
"clipboardWrite",
|
||||
"http://*/*"
|
||||
],
|
||||
"background_page": "background.html",
|
||||
"browser_action": {
|
||||
"default_icon": "greenshot.png",
|
||||
"default_title": "Greenshot"
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
content greenshot content/
|
||||
skin greenshot greenshotskin skin/
|
||||
overlay chrome://browser/content/browser.xul chrome://greenshot/content/overlay.xul
|
4
GreenshotNetworkImportPlugin/Browser-Plugins/Firefox/greenshot/content/jquery-1.7.1.min.js
vendored
Normal file
4
GreenshotNetworkImportPlugin/Browser-Plugins/Firefox/greenshot/content/jquery-1.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,182 @@
|
|||
/// Javscript logic for the Greenshot extension
|
||||
var greenshotPrefObserver = {
|
||||
register: function() {
|
||||
// First we'll need the preference services to look for preferences.
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
|
||||
// For this._branch we ask that the preferences for extensions.myextension. and children
|
||||
this._branch = prefService.getBranch("extensions.greenshot.");
|
||||
// Now we queue the interface called nsIPrefBranch2. This interface is described as:
|
||||
// "nsIPrefBranch2 allows clients to observe changes to pref values."
|
||||
this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||
// Finally add the observer.
|
||||
this._branch.addObserver("", this, false);
|
||||
},
|
||||
unregister: function() {
|
||||
if (!this._branch) return;
|
||||
this._branch.removeObserver("", this);
|
||||
},
|
||||
readDestination: function() {
|
||||
return "http://" + this._branch.getCharPref("host") + ":" + this._branch.getIntPref("port");
|
||||
},
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if(aTopic != "nsPref:changed") return;
|
||||
// aSubject is the nsIPrefBranch we're observing (after appropriate QI)
|
||||
// aData is the name of the pref that's been changed (relative to aSubject)
|
||||
switch (aData) {
|
||||
case "host":
|
||||
this.readDestination();
|
||||
break;
|
||||
case "port":
|
||||
this.readDestination();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
greenshotPrefObserver.register();
|
||||
|
||||
function doMenuClick() {
|
||||
capture();
|
||||
}
|
||||
function doStatusbarClick() {
|
||||
capture();
|
||||
}
|
||||
|
||||
function sendImage(dataUrl, title) {
|
||||
var destination = greenshotPrefObserver.readDestination();
|
||||
try {
|
||||
// Send the image via a HTTP Request to our localhost
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST",
|
||||
contentType: "image/png;base64",
|
||||
dataType: "text",
|
||||
processData: false,
|
||||
data: dataUrl,
|
||||
url: destination + '?title=' + escape(encodeUTF8(title)),
|
||||
success : function (text) {
|
||||
alert("Sent image to: " + destination);
|
||||
//document.getElementById("statusbar-display").label = "Greenshot: " + text;
|
||||
},
|
||||
error : function () {
|
||||
alert("Couldn't send image to '" + destination + "' please check if Greenshot is running!");
|
||||
}
|
||||
});
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}
|
||||
///
|
||||
/// Capture the current opened window
|
||||
/// and send it to Greenshot
|
||||
///
|
||||
function capture() {
|
||||
// Used variables
|
||||
var width;
|
||||
var height;
|
||||
var xOffset;
|
||||
var yOffset;
|
||||
var context;
|
||||
|
||||
try {
|
||||
// Get document width & height
|
||||
width = $(window.content.document).width();
|
||||
height = $(window.content.document).height();
|
||||
|
||||
// Create canvas
|
||||
var canvas = window.content.document.createElement('canvas');
|
||||
|
||||
// change the canvas size to the document size
|
||||
canvas.setAttribute('width', width);
|
||||
canvas.setAttribute('height', height);
|
||||
|
||||
// Get the drawing context
|
||||
context = canvas.getContext("2d");
|
||||
|
||||
// Set the scroll location to top-left, so we don't have problems with funny banners that move while scrolling
|
||||
xOffset = window.content.window.scrollX;
|
||||
yOffset = window.content.window.scrollY;
|
||||
window.content.window.scrollTo(0,0);
|
||||
|
||||
} catch (exception) {
|
||||
}
|
||||
// continue after timeout, so the page is scrolled correctly and has time to move it's items, e.g. for Jira
|
||||
setTimeout( function(){
|
||||
try {
|
||||
// Draw the window to the context
|
||||
context.drawWindow(window.content.window, 0, 0, width, height, 'rgb(255,255,255)');
|
||||
window.content.window.scrollTo(xOffset,yOffset);
|
||||
|
||||
// Send the canvas
|
||||
|
||||
sendImage(canvas.toDataURL("image/png"), window.content.document.title);
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
function captureImage(imageToCapture) {
|
||||
try {
|
||||
var canvas = window.content.document.createElement('canvas');
|
||||
|
||||
// change the canvas size to the document size
|
||||
canvas.setAttribute('width', imageToCapture.width);
|
||||
canvas.setAttribute('height', imageToCapture.height);
|
||||
|
||||
// Get the drawing context
|
||||
context = canvas.getContext("2d");
|
||||
context.drawImage(imageToCapture, 0, 0);
|
||||
|
||||
// Get filename from url
|
||||
var title
|
||||
if (imageToCapture.alt) {
|
||||
title =imageToCapture.alt;
|
||||
} else {
|
||||
title = imageToCapture.src.replace(/\?.*/,'').replace(/^.*(\\|\/|\:)/, '').replace(/\.[^.]*/,'');
|
||||
}
|
||||
// Send the canvas
|
||||
sendImage(canvas.toDataURL("image/png"), title);
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}
|
||||
|
||||
// private method for UTF-8 encoding
|
||||
function encodeUTF8(string) {
|
||||
string = string.replace(/\r\n/g,"\n");
|
||||
var utftext = "";
|
||||
for (var n = 0; n < string.length; n++) {
|
||||
var c = string.charCodeAt(n);
|
||||
if (c < 128) {
|
||||
utftext += String.fromCharCode(c);
|
||||
} else if((c > 127) && (c < 2048)) {
|
||||
utftext += String.fromCharCode((c >> 6) | 192);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
} else {
|
||||
utftext += String.fromCharCode((c >> 12) | 224);
|
||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
}
|
||||
return utftext;
|
||||
}
|
||||
|
||||
function ShowHideGreenshotMenuItem(event) {
|
||||
try {
|
||||
gContextMenu.showItem("greenshot-menu-item", gContextMenu.onImage);
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}
|
||||
|
||||
function InitializeGreenshotExtension() {
|
||||
try {
|
||||
var contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
if (contextMenu) {
|
||||
contextMenu.addEventListener("popupshowing", ShowHideGreenshotMenuItem, false);
|
||||
}
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}
|
||||
window.addEventListener("load", InitializeGreenshotExtension, false);
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0"?>
|
||||
<overlay id="greenshotOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
|
||||
<script type="text/javascript" src="jquery-1.7.1.min.js"/>
|
||||
<script type="text/javascript" src="overlay.js"/>
|
||||
<menupopup id="menu_ToolsPopup">
|
||||
<menuitem id="greenshotPopupMenuitem" label="Capture with Greenshot" insertbefore="sanitizeSeparator" oncommand="doMenuClick();"/>
|
||||
</menupopup>
|
||||
<statusbar id="status-bar">
|
||||
<statusbarpanel class="statusbarpanel-iconic" id="greenshot_statusbar" onclick="doStatusbarClick();" src="chrome://greenshot/skin/greenshot16.png" />
|
||||
</statusbar>
|
||||
<popup id="contentAreaContextMenu">
|
||||
<menuitem id="greenshot-menu-item" label="Send image to Greenshot" oncommand="captureImage(gContextMenu.target);"/>
|
||||
</popup>
|
||||
</overlay>
|
|
@ -0,0 +1,4 @@
|
|||
// Port number to post the screenshot to
|
||||
pref("extensions.greenshot.port", 11234);
|
||||
// hostname to post the screenshot to
|
||||
pref("extensions.greenshot.host", "localhost");
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0"?>
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<!-- Unique ID for extension. Can be in e-mail address format or GUID format -->
|
||||
<em:id>greenshot@getgreenshot.org</em:id>
|
||||
<!-- Indicates that this add-on is an extension -->
|
||||
<em:type>2</em:type>
|
||||
<!-- Extension name displayed in Add-on Manager -->
|
||||
<em:name>Greenshot</em:name>
|
||||
<!-- Extension version number. There is a version numbering scheme you must follow -->
|
||||
<em:version>0.1</em:version>
|
||||
<!-- Brief description displayed in Add-on Manager -->
|
||||
<em:description>A simple capture to Greenshot extension.</em:description>
|
||||
<!-- Name of extension's primary developer. Change to your name -->
|
||||
<em:creator>Lakritzator</em:creator>
|
||||
<!-- Web page address through which extension is distributed -->
|
||||
<em:homepageURL>http://getgreenshot.org</em:homepageURL>
|
||||
<!-- This section gives details of the target application for the extension (in this case: Firefox 2) -->
|
||||
<em:iconURL>chrome://greenshot/skin/greenshot90.png</em:iconURL>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>3.5.*</em:minVersion>
|
||||
<em:maxVersion>10.*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</RDF>
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{0D0B7F80-5B8E-4829-8523-E1AC0551E836}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>GreenshotNetworkImportPlugin</RootNamespace>
|
||||
<AssemblyName>GreenshotNetworkImportPlugin</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||
<NoStdLib>False</NoStdLib>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>Full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<DebugType>None</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
<BaseAddress>4194304</BaseAddress>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\Greenshot\Lib\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="HTTPReceiver.cs" />
|
||||
<Compile Include="NetworkImportPlugin.cs" />
|
||||
<Compile Include="NetworkImportPluginConfiguration.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj">
|
||||
<Project>{5B924697-4DCD-4F98-85F1-105CB84B7341}</Project>
|
||||
<Name>GreenshotPlugin</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AssemblyInfo.cs.template" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"</PreBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
147
GreenshotNetworkImportPlugin/HTTPReceiver.cs
Normal file
147
GreenshotNetworkImportPlugin/HTTPReceiver.cs
Normal file
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2011 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.Threading;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
|
||||
namespace GreenshotNetworkImportPlugin {
|
||||
public class HTTPReceiver {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(HTTPReceiver));
|
||||
|
||||
private string url;
|
||||
private volatile bool keepGoing = true;
|
||||
private HttpListener listener = null;
|
||||
private IGreenshotHost host;
|
||||
|
||||
public HTTPReceiver(string url, IGreenshotHost host) {
|
||||
this.url = url;
|
||||
this.host = host;
|
||||
}
|
||||
public void StartListening() {
|
||||
Thread serverThread = new Thread(Listen);
|
||||
serverThread.SetApartmentState(ApartmentState.STA);
|
||||
serverThread.Start();
|
||||
}
|
||||
|
||||
public void StopListening() {
|
||||
keepGoing = false;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Listen() {
|
||||
listener = new HttpListener();
|
||||
|
||||
//listener.AuthenticationSchemes = AuthenticationSchemes.Ntlm;
|
||||
if (!listener.Prefixes.Contains(url)) {
|
||||
listener.Prefixes.Add(url);
|
||||
}
|
||||
listener.Start();
|
||||
|
||||
while (true) {
|
||||
IAsyncResult result = listener.BeginGetContext(new AsyncCallback(ListenerCallback), listener);
|
||||
while (!result.AsyncWaitHandle.WaitOne(1000)) {
|
||||
if (!keepGoing) {
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!keepGoing) {
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Close() {
|
||||
if (listener != null) {
|
||||
listener.Stop();
|
||||
if (listener.Prefixes != null) {
|
||||
listener.Prefixes.Remove(url);
|
||||
}
|
||||
listener.Close();
|
||||
listener = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ListenerCallback(IAsyncResult result) {
|
||||
if (listener == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
HttpListenerContext context = listener.EndGetContext(result);
|
||||
new Thread(ProcessRequest).Start(context);
|
||||
} catch (HttpListenerException httpE) {
|
||||
LOG.Error(httpE);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessRequest(object data) {
|
||||
const string basePrefix = "data:image/png;base64,";
|
||||
HttpListenerContext context = data as HttpListenerContext;
|
||||
HttpListenerRequest request = context.Request;
|
||||
HttpListenerResponse response = context.Response;
|
||||
LOG.DebugFormat("Content type: {0}", request.ContentType);
|
||||
if (!request.HasEntityBody) {
|
||||
LOG.DebugFormat("Empty request to {0}", request.Url);
|
||||
return;
|
||||
}
|
||||
LOG.DebugFormat("Post request to {0}", request.Url);
|
||||
string possibleImage = null;
|
||||
using (Stream body = request.InputStream) {
|
||||
using (StreamReader reader = new StreamReader(body, request.ContentEncoding)) {
|
||||
possibleImage = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
string title = request.QueryString["title"];
|
||||
LOG.DebugFormat("Title={0}", title);
|
||||
LOG.DebugFormat("Image={0}", possibleImage.Substring(0,30));
|
||||
|
||||
if (possibleImage != null && possibleImage.StartsWith(basePrefix)) {
|
||||
byte[] imageBytes = Convert.FromBase64String(possibleImage.Substring(basePrefix.Length));
|
||||
using (MemoryStream memoryStream = new MemoryStream(imageBytes, 0, imageBytes.Length)) {
|
||||
// Convert byte[] to Image
|
||||
memoryStream.Write(imageBytes, 0, imageBytes.Length);
|
||||
Image image = Image.FromStream(memoryStream, true);
|
||||
ICapture capture = host.GetCapture(image);
|
||||
capture.CaptureDetails.Title = title;
|
||||
host.ImportCapture(capture);
|
||||
response.StatusCode = (int)HttpStatusCode.OK;
|
||||
byte[] content = Encoding.UTF8.GetBytes("Greenshot-OK");
|
||||
response.ContentType = "text";
|
||||
response.ContentLength64 = content.Length;
|
||||
response.OutputStream.Write(content, 0, content.Length);
|
||||
response.OutputStream.Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||
byte[] b = Encoding.UTF8.GetBytes("Greenshot-NOTOK");
|
||||
response.ContentLength64 = b.Length;
|
||||
response.OutputStream.Write(b, 0, b.Length);
|
||||
response.OutputStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
105
GreenshotNetworkImportPlugin/NetworkImportPlugin.cs
Normal file
105
GreenshotNetworkImportPlugin/NetworkImportPlugin.cs
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2011 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.IO;
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Core;
|
||||
using IniFile;
|
||||
|
||||
namespace GreenshotNetworkImportPlugin {
|
||||
/// <summary>
|
||||
/// NetworkImportPlugin can receive images via the network
|
||||
/// </summary>
|
||||
public class NetworkImportPlugin : IGreenshotPlugin {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(NetworkImportPlugin));
|
||||
private IGreenshotHost host;
|
||||
private PluginAttribute myAttributes;
|
||||
private HTTPReceiver httpReceiver = null;
|
||||
private NetworkImportPluginConfiguration config;
|
||||
|
||||
public NetworkImportPlugin() {
|
||||
}
|
||||
|
||||
public IEnumerable<IDestination> Destinations() {
|
||||
yield break;
|
||||
}
|
||||
public IEnumerable<IProcessor> Processors() {
|
||||
yield break;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Initialize
|
||||
/// </summary>
|
||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
||||
/// <param name="pluginAttribute">My own attributes</param>
|
||||
public bool Initialize(IGreenshotHost host, PluginAttribute myAttributes) {
|
||||
LOG.Debug("Initialize called of " + myAttributes.Name);
|
||||
this.host = (IGreenshotHost)host;
|
||||
this.myAttributes = myAttributes;
|
||||
|
||||
// Load configuration
|
||||
config = IniConfig.GetIniSection<NetworkImportPluginConfiguration>();
|
||||
|
||||
// check validity
|
||||
if (!config.ListenerURL.EndsWith("/")) {
|
||||
config.ListenerURL = config.ListenerURL + "/";
|
||||
config.IsDirty = true;
|
||||
IniConfig.Save();
|
||||
}
|
||||
|
||||
IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);
|
||||
ReloadConfiguration(null, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ReloadConfiguration(object source, FileSystemEventArgs e) {
|
||||
if (httpReceiver != null) {
|
||||
httpReceiver.StopListening();
|
||||
httpReceiver = null;
|
||||
}
|
||||
if (config.RemoteEnabled) {
|
||||
httpReceiver = new HTTPReceiver(config.ListenerURL, host);
|
||||
httpReceiver.StartListening();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Shutdown
|
||||
/// </summary>
|
||||
public void Shutdown() {
|
||||
LOG.Debug("Shutdown of " + myAttributes.Name);
|
||||
if (httpReceiver != null) {
|
||||
httpReceiver.StopListening();
|
||||
httpReceiver = null;
|
||||
}
|
||||
IniConfig.IniChanged -= new FileSystemEventHandler(ReloadConfiguration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IPlugin.Configure
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2011 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 GreenshotPlugin.Core;
|
||||
using IniFile;
|
||||
|
||||
namespace GreenshotNetworkImportPlugin {
|
||||
/// <summary>
|
||||
/// Description of NetworkImportPluginConfiguration.
|
||||
/// </summary>
|
||||
[IniSection("NetworkImport", Description="Greenshot Network Import Plugin configuration")]
|
||||
public class NetworkImportPluginConfiguration : IniSection {
|
||||
[IniProperty("RemoteEnabled", Description="Is remote access enabled", DefaultValue="False")]
|
||||
public bool RemoteEnabled;
|
||||
[IniProperty("ListenerURL", Description="The URL to listen on", DefaultValue="http://localhost:11234/")]
|
||||
public string ListenerURL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2011 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/>.
|
||||
*/
|
||||
#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("GreenshotNetworkImportPlugin")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("GreenshotNetworkImportPlugin")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2007-2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: PluginAttribute("GreenshotNetworkImportPlugin.NetworkImportPlugin", false)]
|
||||
|
||||
// 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.0.0.$WCREV$")]
|
Loading…
Add table
Add a link
Reference in a new issue