///
/// Copyright © 2003-2008 JetBrains s.r.o.
/// You may distribute under the terms of the GNU General Public License, as published by the Free Software Foundation, version 2 (see License.txt in the repository root folder).
///
namespace JetBrains.Omea.OpenAPI
{
///
/// Allows a plugin to return custom auto-preview text for a resource.
///
/// 2.0
public interface IPreviewTextProvider
{
///
/// Returns the auto-preview text for the specified resource.
///
/// The resource for which the text is requested.
/// The number of lines of preview text to return. Can be used
/// as a guide to restrict the amount of text extracted from the document.
/// The auto-preview text.
string GetPreviewText( IResource res, int lines );
}
///
/// Provides services for pretty-printing (HTML formatting) and quoting of plain-text messages.
///
public interface IMessageFormatter
{
///
/// Retrieves and pretty-prints the body of the specified resource
/// using default font and attributes.
///
/// The resource for which the body is pretty-printed.
/// The ID of the property holding the resource body.
/// The ID of the property linking the resource to its replies.
/// The string containing the HTML-formatted message.
string GetFormattedBody( IResource resource, int bodyProp, int replyLink );
///
/// Retrieves and pretty-prints the body of the specified resource
/// using given font and attributes.
///
/// The resource for which the body is pretty-printed.
/// The ID of the property holding the resource body.
/// The ID of the property linking the resource to its replies.
/// Name of a font face (family).
/// Size of a font.
/// The string containing the HTML-formatted message.
/// 2.1
string GetFormattedBody( IResource resource, int bodyProp, int replyLink, string fontFace, int fontSize );
///
/// Pretty-prints the specified string which is the body of the specified
/// resource using default font and attributes.
///
/// The resource for which the body is pretty-printed.
/// The text of the resource body.
/// The body of the resource to which the specified resource
/// is a reply, or null if the specified resource is not a reply.
/// The string containing the HTML-formatted message.
string GetFormattedBody( IResource resource, string body, string replyToBody );
///
/// Pretty-prints the specified string which is the body of the specified
/// resource using given font and attributes.
///
/// The resource for which the body is pretty-printed.
/// The text of the resource body.
/// The body of the resource to which the specified resource
/// is a reply, or null if the specified resource is not a reply.
/// Name of a font face (family).
/// Size of a font.
/// The string containing the HTML-formatted message.
/// 2.1
string GetFormattedBody( IResource resource, string body, string replyToBody,
string fontFace, int fontSize );
///
/// Retrieves and pretty-prints the body of the specified resource,
/// using default font and attributes and maintaining a list of offsets in the text.
///
/// The resource for which the body is pretty-printed.
/// The ID of the property holding the resource body.
/// The ID of the property linking the resource to its replies.
/// An array of offsets in the text that should be updated accordingly
/// to the formatting applied to the content so that if the offset points to a specific word
/// before formatting, it would point to the same word after formatting as well. May be null.
/// The string containing the HTML-formatted message.
/// 2.0
string GetFormattedBody( IResource resource, int bodyProp, int replyLink, ref WordPtr[] maintainedOffsets );
///
/// Retrieves and pretty-prints the body of the specified resource,
/// using given font and attributes and maintaining a list of offsets in the text.
///
/// The resource for which the body is pretty-printed.
/// The ID of the property holding the resource body.
/// The ID of the property linking the resource to its replies.
/// An array of offsets in the text that should be updated accordingly
/// to the formatting applied to the content so that if the offset points to a specific word
/// before formatting, it would point to the same word after formatting as well. May be null.
/// Name of a font face (family).
/// Size of a font.
/// The string containing the HTML-formatted message.
/// 2.1
string GetFormattedBody( IResource resource, int bodyProp, int replyLink,
ref WordPtr[] maintainedOffsets, string fontFace, int fontSize );
///
/// Pretty-prints the specified string which is the body of the specified resource,
/// using default font and attributes and maintaining a list of offsets in the text.
///
/// The resource for which the body is pretty-printed.
/// The text of the resource body.
/// The body of the resource to which the specified resource
/// is a reply, or null if the specified resource is not a reply.
/// An array of offsets in the text that should be updated accordingly
/// to the formatting applied to the content so that if the offset points to a specific word
/// before formatting, it would point to the same word after formatting as well. May be null.
/// The string containing the HTML-formatted message.
/// 2.0
string GetFormattedBody( IResource resource, string body, string replyToBody, ref WordPtr[] maintainedOffsets );
///
/// Pretty-prints the specified string which is the body of the specified resource,
/// using given font and attributes and maintaining a list of offsets in the text.
///
/// The resource for which the body is pretty-printed.
/// The text of the resource body.
/// The body of the resource to which the specified resource
/// is a reply, or null if the specified resource is not a reply.
/// An array of offsets in the text that should be updated accordingly
/// to the formatting applied to the content so that if the offset points to a specific word
/// before formatting, it would point to the same word after formatting as well. May be null.
/// Name of a font face (family).
/// Size of a font.
/// The string containing the HTML-formatted message.
/// 2.1
string GetFormattedBody( IResource resource, string body, string replyToBody,
ref WordPtr[] offsets, string fontFace, int fontSize );
/// 2.3
string GetFormattedHtmlBody( IResource res, string body, ref WordPtr[] offsets );
///
/// Retrieves and quotes the body of the specified resource with default settings.
///
/// The resource for which the body is quoted.
/// The ID of the property holding the resource body.
/// The string containing the quoted resource body.
string QuoteMessage( IResource resource, int bodyProp );
///
/// Quotes the specified string which is the body of the specified resource with default
/// settings.
///
/// The resource for which the body is quoted.
/// The text of the resource body.
/// The string containing the quoted resource body.
string QuoteMessage( IResource resource, string body );
///
/// Retrieves and quotes the body of the specified resource with the specified settings.
///
/// The resource for which the body is quoted.
/// The ID of the property holding the resource body.
/// The settings for quoting.
/// The string containing the quoted resource body.
/// 2.0
string QuoteMessage( IResource resource, int bodyProp, QuoteSettings settings );
///
/// Quotes the specified string which is the body of the specified resource
/// with the specified settings
///
/// The resource for which the body is quoted.
/// The text of the resource body.
/// The settings for quoting.
/// The string containing the quoted resource body.
/// 2.0
string QuoteMessage( IResource resource, string body, QuoteSettings settings );
///
/// Returns the preview text of the specified resource (beginning of its full text with no
/// formatting or spacing).
///
/// The resource to get the text for.
/// The number of lines of preview text to return.
/// The preview text, or an empty string if none is available.
/// 2.0
string GetPreviewText( IResource res, int lines );
///
/// Registers a custom preview text provider for the specified resource type.
///
/// The resource type for which the provider is registered.
/// The provider implementation.
/// 2.0
void RegisterPreviewTextProvider( string resourceType, IPreviewTextProvider provider );
/// 2.3
string DualMediaSubjectStyle { get; }
/// 2.3
string StandardStyledHeader( string subject );
}
///
/// Settings for formatting a quoted message.
///
/// 2.0
public class QuoteSettings
{
private bool _prefixInitials;
private bool _greetingInReplies;
private string _greetingString;
private SignaturePosition _signatureInReplies;
private string _signature;
private bool _useSignature;
private int _quoteMargin = 72;
private const string _cstrDefaultGreeting = "Hello";
///
/// Gets or sets the value indicating whether each line of quoting is prefixed with
/// the sender's initials.
///
public bool PrefixInitials
{
get { return _prefixInitials; }
set { _prefixInitials = value; }
}
///
/// Gets or sets the value indicating whether a greeting is included in replies.
///
public bool GreetingInReplies
{
get { return _greetingInReplies; }
set { _greetingInReplies = value; }
}
///
/// Gets or sets the greeting string
///
public string GreetingString
{
get { return _greetingString; }
set { _greetingString = value; }
}
///
/// Gets or sets the value indicating whether a signature is included in outgoing messages.
///
public bool UseSignature
{
get { return _useSignature; }
set { _useSignature = value; }
}
///
/// Gets or sets the position of the signature in reply messages.
///
public SignaturePosition SignatureInReplies
{
get { return _signatureInReplies; }
set { _signatureInReplies = value; }
}
///
/// Gets or sets the text of the signature included in a message.
///
public string Signature
{
get { return _signature; }
set { _signature = value; }
}
///
/// Gets or sets the value indicating the line length at which quoting is wrapped.
///
public int QuoteMargin
{
get { return _quoteMargin; }
set { _quoteMargin = value; }
}
///
/// Returns a copy of the default quote settings loaded from the setting store.
///
public static QuoteSettings Default
{
get
{
QuoteSettings result = new QuoteSettings();
result.PrefixInitials = Core.SettingStore.ReadBool( "MailFormat", "PrefixInitials", false );
result.GreetingInReplies = Core.SettingStore.ReadBool( "MailFormat", "GreetingInReplies", true );
result.GreetingString = Core.SettingStore.ReadString( "MailFormat", "GreetingString", _cstrDefaultGreeting );
result.UseSignature = Core.SettingStore.ReadBool( "MailFormat", "UseSignature", false );
result.SignatureInReplies = (SignaturePosition) Core.SettingStore.ReadInt( "MailFormat", "SignatureInReplies", 1 );
result.Signature = Core.SettingStore.ReadString( "MailFormat", "Signature", "" );
result.QuoteMargin = 72;
return result;
}
}
}
///
/// Defines the possible position of a signature in a quoted message.
///
/// 2.0
public enum SignaturePosition
{
///
/// The signature is not inserted.
///
None,
///
/// The signature is inserted before the quoted section.
///
BeforeQuote,
///
/// The signature is inserted after the quoted section.
///
AfterQuote
};
}