mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 21:43:24 -07:00
Added a plugin for the office communicator, this allows you to export an image to open conversations. The plugin will use other destinations for the storage, and use the result "URI" to send a text message. Can be used for a quicker (less overhead) image sharing as using mail.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2036 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
897623f1e2
commit
c037b99d6e
14 changed files with 982 additions and 0 deletions
187
GreenshotOfficeCommunicatorPlugin/Communicator.cs
Normal file
187
GreenshotOfficeCommunicatorPlugin/Communicator.cs
Normal file
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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 CommunicatorAPI;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotOfficeCommunicatorPlugin {
|
||||
|
||||
public class Communicator {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(Communicator));
|
||||
private bool connected = false;
|
||||
|
||||
private CommunicatorAPI.Messenger communicator = null;
|
||||
private Dictionary<long, CommunicatorConversation> communicatorConversations = new Dictionary<long, CommunicatorConversation>();
|
||||
public Communicator() {
|
||||
}
|
||||
public bool isConnected {
|
||||
get {
|
||||
return connected;
|
||||
}
|
||||
}
|
||||
|
||||
public bool hasConversations {
|
||||
get {
|
||||
return communicatorConversations.Count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<CommunicatorConversation> Conversations {
|
||||
get {
|
||||
foreach (CommunicatorConversation conversation in communicatorConversations.Values) {
|
||||
yield return conversation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A simple implementation of signing in.
|
||||
public void Signin(string account, string passwd) {
|
||||
if (connected)
|
||||
return;
|
||||
|
||||
if (communicator == null) {
|
||||
// Create a Messenger object, if necessary
|
||||
communicator = new CommunicatorAPI.Messenger();
|
||||
|
||||
// Register event handlers for OnSignin and Signout events
|
||||
communicator.OnSignin += new DMessengerEvents_OnSigninEventHandler(communicator_OnSignin);
|
||||
communicator.OnSignout += new DMessengerEvents_OnSignoutEventHandler(communicator_OnSignout);
|
||||
communicator.OnIMWindowCreated += new DMessengerEvents_OnIMWindowCreatedEventHandler(communicator_OnIMWindowCreated);
|
||||
communicator.OnIMWindowDestroyed += new DMessengerEvents_OnIMWindowDestroyedEventHandler(communicator_OnIMWindowDestroyed);
|
||||
}
|
||||
|
||||
if (account == null) {
|
||||
communicator.AutoSignin();
|
||||
} else {
|
||||
communicator.Signin(0, account, passwd);
|
||||
}
|
||||
}
|
||||
|
||||
// Event handler for OnSignin event.
|
||||
void communicator_OnSignin(int hr) {
|
||||
if (hr != 0) {
|
||||
Console.WriteLine("Signin failed.");
|
||||
return;
|
||||
}
|
||||
connected = true;
|
||||
}
|
||||
|
||||
void communicator_OnSignout() {
|
||||
connected = false;
|
||||
|
||||
// Release the unmanaged resource.
|
||||
Marshal.ReleaseComObject(communicator);
|
||||
communicator = null;
|
||||
}
|
||||
|
||||
// Register for IMWindowCreated event to receive the
|
||||
// conversation window object. Other window objects can
|
||||
// received via this event handling as well.
|
||||
void communicator_OnIMWindowCreated(object pIMWindow) {
|
||||
try {
|
||||
IMessengerConversationWndAdvanced imWindow = (IMessengerConversationWndAdvanced)pIMWindow;
|
||||
CommunicatorConversation conversation = null;
|
||||
if (communicatorConversations.ContainsKey(imWindow.HWND)) {
|
||||
conversation = communicatorConversations[imWindow.HWND];
|
||||
} else {
|
||||
conversation = new CommunicatorConversation(imWindow.HWND);
|
||||
communicatorConversations.Add(imWindow.HWND, conversation);
|
||||
}
|
||||
conversation.ImWindow = imWindow;
|
||||
} catch (Exception exception) {
|
||||
LOG.Error(exception);
|
||||
}
|
||||
}
|
||||
|
||||
void communicator_OnIMWindowDestroyed(object pIMWindow) {
|
||||
try {
|
||||
IMessengerConversationWndAdvanced imWindow = (IMessengerConversationWndAdvanced)pIMWindow;
|
||||
CommunicatorConversation foundConversation = null;
|
||||
long foundHwnd = 0;
|
||||
foreach (long hwndKey in communicatorConversations.Keys) {
|
||||
if (imWindow.Equals(communicatorConversations[hwndKey].ImWindow)) {
|
||||
foundConversation = communicatorConversations[hwndKey];
|
||||
foundConversation.ImWindow = null;
|
||||
foundHwnd = hwndKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundConversation != null) {
|
||||
communicatorConversations.Remove(foundHwnd);
|
||||
}
|
||||
Marshal.ReleaseComObject(pIMWindow);
|
||||
} catch (Exception exception) {
|
||||
LOG.Error(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public CommunicatorConversation StartConversation(string account) {
|
||||
object[] sipUris = { account };
|
||||
CommunicatorAPI.IMessengerAdvanced msgrAdv = communicator as CommunicatorAPI.IMessengerAdvanced;
|
||||
CommunicatorConversation communicatorConversation = null;
|
||||
if (msgrAdv != null) {
|
||||
try {
|
||||
object obj = msgrAdv.StartConversation(
|
||||
CONVERSATION_TYPE.CONVERSATION_TYPE_IM, // Type of conversation
|
||||
sipUris, // object array of signin names for having multiple conversations
|
||||
null,
|
||||
"Testing",
|
||||
"1",
|
||||
null);
|
||||
long hwnd = long.Parse(obj.ToString());
|
||||
if (!communicatorConversations.ContainsKey(hwnd)) {
|
||||
communicatorConversations.Add(hwnd, new CommunicatorConversation(hwnd));
|
||||
}
|
||||
communicatorConversation = communicatorConversations[hwnd];
|
||||
} catch (Exception ex) {
|
||||
LOG.Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return communicatorConversation;
|
||||
}
|
||||
|
||||
|
||||
public void ShowContacts() {
|
||||
// Display contacts to a console window(for illustration only).
|
||||
foreach (IMessengerContact contact in communicator.MyContacts as IMessengerContacts) {
|
||||
if (!contact.IsSelf) {
|
||||
Console.WriteLine("{0} ({1})", contact.SigninName, contact.Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A simple implementation of signing out.
|
||||
public void Signout() {
|
||||
if (!connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (communicator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
communicator.Signout();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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.Text;
|
||||
using CommunicatorAPI;
|
||||
using System.Runtime.InteropServices;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotOfficeCommunicatorPlugin {
|
||||
public class CommunicatorConversation {
|
||||
private IMessengerConversationWndAdvanced imWindow = null;
|
||||
private long hwnd = 0;
|
||||
private Queue<string> queuedText = new Queue<string>();
|
||||
|
||||
public CommunicatorConversation(long hwnd) {
|
||||
this.hwnd = hwnd;
|
||||
}
|
||||
|
||||
public bool isActive {
|
||||
get {
|
||||
return imWindow != null;
|
||||
}
|
||||
}
|
||||
|
||||
public IMessengerConversationWndAdvanced ImWindow {
|
||||
get {
|
||||
return imWindow;
|
||||
}
|
||||
set {
|
||||
imWindow = value;
|
||||
if (imWindow != null) {
|
||||
while (queuedText.Count > 0 && imWindow != null) {
|
||||
SendTextMessage(queuedText.Dequeue());
|
||||
}
|
||||
} else {
|
||||
hwnd = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send text only if the window object matches the desired window handle
|
||||
public void SendTextMessage(string msg) {
|
||||
if (imWindow != null) {
|
||||
imWindow.SendText(msg);
|
||||
} else {
|
||||
queuedText.Enqueue(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public string History {
|
||||
get {
|
||||
return imWindow.History;
|
||||
}
|
||||
}
|
||||
|
||||
public string Title {
|
||||
get {
|
||||
if (imWindow != null) {
|
||||
return new WindowDetails(new IntPtr(hwnd)).Text;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
GreenshotOfficeCommunicatorPlugin/DLL/CommunicatorAPI.dll
Normal file
BIN
GreenshotOfficeCommunicatorPlugin/DLL/CommunicatorAPI.dll
Normal file
Binary file not shown.
BIN
GreenshotOfficeCommunicatorPlugin/DLL/CommunicatorPrivate.dll
Normal file
BIN
GreenshotOfficeCommunicatorPlugin/DLL/CommunicatorPrivate.dll
Normal file
Binary file not shown.
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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;
|
||||
|
||||
namespace GreenshotOfficeCommunicatorPlugin {
|
||||
/// <summary>
|
||||
/// This class is needed for design-time resolving of the language files
|
||||
/// </summary>
|
||||
public class OfficeCommunicatorForm : GreenshotPlugin.Controls.GreenshotForm {
|
||||
public OfficeCommunicatorForm() : base() {
|
||||
}
|
||||
}
|
||||
}
|
96
GreenshotOfficeCommunicatorPlugin/Forms/SettingsForm.Designer.cs
generated
Normal file
96
GreenshotOfficeCommunicatorPlugin/Forms/SettingsForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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/>.
|
||||
*/
|
||||
namespace GreenshotOfficeCommunicatorPlugin {
|
||||
partial class SettingsForm {
|
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the form.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing) {
|
||||
if (components != null) {
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonOK = new GreenshotPlugin.Controls.GreenshotButton();
|
||||
this.buttonCancel = new GreenshotPlugin.Controls.GreenshotButton();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonOK.LanguageKey = "officecommunicator.OK";
|
||||
this.buttonOK.Location = new System.Drawing.Point(222, 11);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonOK.TabIndex = 2;
|
||||
this.buttonOK.Text = "OK";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.ButtonOKClick);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.LanguageKey = "officecommunicator.CANCEL";
|
||||
this.buttonCancel.Location = new System.Drawing.Point(303, 11);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 3;
|
||||
this.buttonCancel.Text = "Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick);
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(387, 46);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.LanguageKey = "officecommunicator.settings_title";
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SettingsForm";
|
||||
this.Text = "Office Communicator settings";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
private GreenshotPlugin.Controls.GreenshotButton buttonCancel;
|
||||
private GreenshotPlugin.Controls.GreenshotButton buttonOK;
|
||||
}
|
||||
}
|
47
GreenshotOfficeCommunicatorPlugin/Forms/SettingsForm.cs
Normal file
47
GreenshotOfficeCommunicatorPlugin/Forms/SettingsForm.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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.Windows.Forms;
|
||||
using GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Controls;
|
||||
|
||||
namespace GreenshotOfficeCommunicatorPlugin {
|
||||
/// <summary>
|
||||
/// Description of PasswordRequestForm.
|
||||
/// </summary>
|
||||
public partial class SettingsForm : OfficeCommunicatorForm {
|
||||
public SettingsForm(OfficeCommunicatorConfiguration config) : base() {
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent();
|
||||
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
|
||||
}
|
||||
|
||||
void ButtonOKClick(object sender, EventArgs e) {
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
void ButtonCancelClick(object sender, System.EventArgs e) {
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{C1050323-F237-43E2-90F9-1D620F29252F}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>GreenshotOfficeCommunicatorPlugin</RootNamespace>
|
||||
<AssemblyName>GreenshotOfficeCommunicatorPlugin</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||
<NoStdLib>False</NoStdLib>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
<TargetFrameworkProfile />
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>Full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<BaseAddress>4194304</BaseAddress>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<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>Off</GenerateSerializationAssemblies>
|
||||
<BaseAddress>4194304</BaseAddress>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||
<ItemGroup>
|
||||
<Reference Include="CommunicatorAPI, Version=2.0.6362.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
<HintPath>DLL\CommunicatorAPI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="CommunicatorPrivate, Version=2.0.6362.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
<HintPath>DLL\CommunicatorPrivate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\Greenshot\Lib\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Communicator.cs" />
|
||||
<Compile Include="CommunicatorConversation.cs" />
|
||||
<Compile Include="Forms\OfficeCommunicatorForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\SettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\SettingsForm.Designer.cs">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="OfficeCommunicatorDestination.cs" />
|
||||
<Compile Include="OfficeCommunicatorPlugin.cs" />
|
||||
<Compile Include="OfficeCommunicatorConfiguration.cs" />
|
||||
<Compile Include="LanguageKeys.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<None Include="Languages\language_officecommunicatorplugin-en-US.xml">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Properties\AssemblyInfo.cs.template" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj">
|
||||
<Project>{5B924697-4DCD-4F98-85F1-105CB84B7341}</Project>
|
||||
<Name>GreenshotPlugin</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Forms\SettingsForm.resx">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="DLL\CommunicatorPrivate.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="DLL\CommunicatorAPI.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<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"
|
||||
copy "$(ProjectDir)\DLL\*.dll" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)
|
||||
|
||||
mkdir "$(SolutionDir)bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
42
GreenshotOfficeCommunicatorPlugin/LanguageKeys.cs
Normal file
42
GreenshotOfficeCommunicatorPlugin/LanguageKeys.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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;
|
||||
|
||||
namespace GreenshotOfficeCommunicatorPlugin {
|
||||
public enum LangKey {
|
||||
upload_menu_item,
|
||||
settings_title,
|
||||
label_url,
|
||||
label_upload_format,
|
||||
label_clear,
|
||||
OK,
|
||||
CANCEL,
|
||||
upload_success,
|
||||
upload_failure,
|
||||
communication_wait,
|
||||
delete_question,
|
||||
clear_question,
|
||||
delete_title,
|
||||
use_page_link,
|
||||
history,
|
||||
configure
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<language description="English" ietf="en-US" version="1.0.0">
|
||||
<resources>
|
||||
<resource name="upload_menu_item">
|
||||
Upload to Office Communicator
|
||||
</resource>
|
||||
<resource name="settings_title">
|
||||
Office Communicator settings
|
||||
</resource>
|
||||
<resource name="OK">
|
||||
OK
|
||||
</resource>
|
||||
<resource name="CANCEL">
|
||||
Cancel
|
||||
</resource>
|
||||
<resource name="upload_success">
|
||||
Successfully uploaded image to Office Communicator!
|
||||
</resource>
|
||||
<resource name="upload_failure">
|
||||
An error occured while uploading to Office Communicator:
|
||||
</resource>
|
||||
<resource name="label_upload_format">
|
||||
Image format
|
||||
</resource>
|
||||
<resource name="communication_wait">
|
||||
Communicating with Office Communicator. Please wait...
|
||||
</resource>
|
||||
<resource name="configure">
|
||||
Configure
|
||||
</resource>
|
||||
</resources>
|
||||
</language>
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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 GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
|
||||
namespace GreenshotOfficeCommunicatorPlugin {
|
||||
/// <summary>
|
||||
/// Description of OfficeCommunicatorConfiguration.
|
||||
/// </summary>
|
||||
[IniSection("OfficeCommunicator", Description="Greenshot OfficeCommunicator Plugin configuration")]
|
||||
public class OfficeCommunicatorConfiguration : IniSection {
|
||||
[IniProperty("Destination", Description = "The designation of the destination which is used to export via, the returned URL is used in the message.", DefaultValue = "FileDialog")]
|
||||
public string DestinationDesignation;
|
||||
|
||||
/// <summary>
|
||||
/// A form for username/password
|
||||
/// </summary>
|
||||
/// <returns>bool true if OK was pressed, false if cancel</returns>
|
||||
public bool ShowConfigDialog() {
|
||||
SettingsForm settingsForm = null;
|
||||
|
||||
new PleaseWaitForm().ShowAndWait(OfficeCommunicatorPlugin.Attributes.Name, Language.GetString("officecommunicator", LangKey.communication_wait),
|
||||
delegate() {
|
||||
settingsForm = new SettingsForm(this);
|
||||
}
|
||||
);
|
||||
DialogResult result = settingsForm.ShowDialog();
|
||||
if (result == DialogResult.OK) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
|
||||
namespace GreenshotOfficeCommunicatorPlugin {
|
||||
/// <summary>
|
||||
/// Description of OfficeCommunicatorDestination.
|
||||
/// </summary>
|
||||
public class OfficeCommunicatorDestination : AbstractDestination {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OfficeCommunicatorDestination));
|
||||
private static OfficeCommunicatorConfiguration config = IniConfig.GetIniSection<OfficeCommunicatorConfiguration>();
|
||||
private OfficeCommunicatorPlugin plugin = null;
|
||||
private static string exePath = null;
|
||||
private static Image applicationIcon = null;
|
||||
private CommunicatorConversation conversation = null;
|
||||
|
||||
static OfficeCommunicatorDestination() {
|
||||
exePath = GetExePath("communicator.exe");
|
||||
if (exePath != null && File.Exists(exePath)) {
|
||||
applicationIcon = GetExeIcon(exePath, 0);
|
||||
} else {
|
||||
exePath = null;
|
||||
}
|
||||
}
|
||||
public OfficeCommunicatorDestination(OfficeCommunicatorPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public OfficeCommunicatorDestination(OfficeCommunicatorPlugin plugin, CommunicatorConversation conversation) : this(plugin) {
|
||||
this.conversation = conversation;
|
||||
}
|
||||
|
||||
public override string Designation {
|
||||
get {
|
||||
return "OfficeCommunicator";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
if (conversation == null) {
|
||||
return Language.GetString("officecommunicator", LangKey.upload_menu_item);
|
||||
} else {
|
||||
return Language.GetString("officecommunicator", LangKey.upload_menu_item) + " - " + conversation.Title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Image DisplayIcon {
|
||||
get {
|
||||
return applicationIcon;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool isActive {
|
||||
get {
|
||||
return base.isActive && exePath != null && ((conversation == null && plugin.Communicator.hasConversations) || (conversation != null && conversation.isActive));
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<IDestination> DynamicDestinations() {
|
||||
foreach (CommunicatorConversation conversation in plugin.Communicator.Conversations) {
|
||||
if (conversation.isActive) {
|
||||
yield return new OfficeCommunicatorDestination(plugin, conversation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool isDynamic {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool useDynamicsOnly {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
|
||||
if (conversation != null) {
|
||||
ExportInformation internalExportInformation = plugin.Host.ExportCapture(false, config.DestinationDesignation, surface, captureDetails);
|
||||
if (internalExportInformation != null && internalExportInformation.ExportMade) {
|
||||
exportInformation.ExportMade = true;
|
||||
if (!string.IsNullOrEmpty(internalExportInformation.Uri)) {
|
||||
conversation.SendTextMessage("Greenshot sends you: " + internalExportInformation.Uri);
|
||||
} else if (!string.IsNullOrEmpty(internalExportInformation.Filepath)) {
|
||||
conversation.SendTextMessage(@"Greenshot sends you: file://" + internalExportInformation.Filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
109
GreenshotOfficeCommunicatorPlugin/OfficeCommunicatorPlugin.cs
Normal file
109
GreenshotOfficeCommunicatorPlugin/OfficeCommunicatorPlugin.cs
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
using CommunicatorAPI;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace GreenshotOfficeCommunicatorPlugin {
|
||||
/// <summary>
|
||||
/// This is the OfficeCommunicatorPlugin
|
||||
/// </summary>
|
||||
public class OfficeCommunicatorPlugin : IGreenshotPlugin {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OfficeCommunicatorPlugin));
|
||||
public static PluginAttribute Attributes;
|
||||
private OfficeCommunicatorConfiguration config = IniConfig.GetIniSection<OfficeCommunicatorConfiguration>();
|
||||
private IGreenshotHost host;
|
||||
private Communicator communicator;
|
||||
public IGreenshotHost Host {
|
||||
get {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
|
||||
public Communicator Communicator {
|
||||
get {
|
||||
return communicator;
|
||||
}
|
||||
set {
|
||||
communicator = value;
|
||||
}
|
||||
}
|
||||
|
||||
public OfficeCommunicatorPlugin() {
|
||||
}
|
||||
|
||||
public IEnumerable<IDestination> Destinations() {
|
||||
yield return new OfficeCommunicatorDestination(this);
|
||||
}
|
||||
|
||||
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>
|
||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
this.host = (IGreenshotHost)pluginHost;
|
||||
Attributes = myAttributes;
|
||||
|
||||
communicator = new Communicator();
|
||||
communicator.Signin(null, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("OfficeCommunicator Plugin shutdown.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IPlugin.Configure
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, de-registering OfficeCommunicator Plugin!");
|
||||
Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 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("Greenshot-OfficeCommunicator-Plugin")]
|
||||
[assembly: AssemblyDescription("A plugin to upload images to office communicator")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Greenshot")]
|
||||
[assembly: AssemblyProduct("OfficeCommunicator Plugin")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2007-2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
// The PluginAttribute describes the "entryType" and if the plugin is configurable
|
||||
[assembly: PluginAttribute("GreenshotOfficeCommunicatorPlugin.OfficeCommunicatorPlugin", true)]
|
||||
|
||||
// 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.2.$WCREV$")]
|
Loading…
Add table
Add a link
Reference in a new issue