mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
Fallback commit, some files were missed
This commit is contained in:
parent
2f0e46f18d
commit
629bfd371b
@ -35,6 +35,7 @@ namespace Acacia.Features
|
||||
typeof(Notes.FeatureNotes),
|
||||
typeof(SecondaryContacts.FeatureSecondaryContacts),
|
||||
typeof(SendAs.FeatureSendAs),
|
||||
typeof(Signatures.FeatureSignatures),
|
||||
typeof(DebugSupport.FeatureDebugSupport)
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
using Acacia.Native.MAPI;
|
||||
using Acacia.Stubs;
|
||||
/// Copyright 2016 Kopano b.v.
|
||||
///
|
||||
/// This program is free software: you can redistribute it and/or modify
|
||||
@ -81,21 +80,13 @@ namespace Acacia.Features.WebApp
|
||||
if (account == null)
|
||||
return;
|
||||
|
||||
using (IFolder reminders = account.Account.Store.GetSpecialFolder(SpecialFolder.Reminders))
|
||||
{
|
||||
Logger.Instance.Trace(this, "REMINDERS:\n{0}", reminders.SearchCriteria);
|
||||
using (RestrictionEncoder res = reminders.SearchCriteria.ToRestriction())
|
||||
Logger.Instance.Trace(this, "REMINDERS2:\n{0}", res.Restriction);
|
||||
|
||||
}
|
||||
/*
|
||||
// Get the url
|
||||
string url = AutoDiscover(account);
|
||||
if (url == null)
|
||||
return;
|
||||
|
||||
// Open the browser
|
||||
System.Diagnostics.Process.Start(url);*/
|
||||
System.Diagnostics.Process.Start(url);
|
||||
}
|
||||
|
||||
private string AutoDiscover(ZPushAccount account)
|
||||
|
@ -52,7 +52,7 @@ namespace Acacia.Native.MAPI
|
||||
|
||||
public SearchQuery.PropertyIdentifier ToPropertyIdentifier()
|
||||
{
|
||||
return new SearchQuery.PropertyIdentifier(this);
|
||||
return SearchQuery.PropertyIdentifier.FromTag(prop, (ushort)type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,10 +131,5 @@ namespace Acacia.Native.MAPI
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PropValue* FromObject(NativeEncoder encoder, object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
using Acacia.Stubs;
|
||||
using Acacia.Utils;
|
||||
/// Copyright 2017 Kopano b.v.
|
||||
///
|
||||
/// This program is free software: you can redistribute it and/or modify
|
||||
@ -70,14 +69,14 @@ namespace Acacia.Native.MAPI
|
||||
|
||||
unsafe public struct ContentRestriction
|
||||
{
|
||||
public FuzzyLevel ulFuzzyLevel;
|
||||
public FuzzyLevel fuzzy;
|
||||
public PropTag ulPropTag;
|
||||
public PropValue* prop;
|
||||
|
||||
public string ToString(int depth)
|
||||
{
|
||||
string indent = new string(' ', depth);
|
||||
string s = indent + ulFuzzyLevel + ":" + ulPropTag.ToString();
|
||||
string s = indent + fuzzy + ":" + ulPropTag.ToString();
|
||||
s += ":" + prop->ToString();
|
||||
s += "\n";
|
||||
return s;
|
||||
@ -86,8 +85,7 @@ namespace Acacia.Native.MAPI
|
||||
public SearchQuery ToSearchQuery()
|
||||
{
|
||||
return new SearchQuery.PropertyContent(ulPropTag.ToPropertyIdentifier(),
|
||||
(SearchQuery.ContentMatchOperation)((uint)ulFuzzyLevel & 0xF),
|
||||
(SearchQuery.ContentMatchModifiers)(((uint)ulFuzzyLevel & 0xF0000) >> 16),
|
||||
(uint)fuzzy, // TODO
|
||||
prop->ToObject());
|
||||
}
|
||||
}
|
||||
@ -176,7 +174,7 @@ namespace Acacia.Native.MAPI
|
||||
|
||||
public SearchQuery ToSearchQuery()
|
||||
{
|
||||
return new SearchQuery.PropertyBitMask(prop.ToPropertyIdentifier(), (SearchQuery.BitMaskOperation)(int)bmr, mask);
|
||||
return new SearchQuery.PropertyBitMask(prop.ToPropertyIdentifier(), bmr == BMR.EQZ, mask);
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,145 +304,6 @@ namespace Acacia.Native.MAPI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encodes a search as an SRestriction. Note that as memory needs to be managed for the miscellaneous structures,
|
||||
/// the SRestriction is only valid until RestrictionEncoder is disposed.
|
||||
/// </summary>
|
||||
unsafe public class RestrictionEncoder : NativeEncoder, ISearchEncoder
|
||||
{
|
||||
private class EncodingStack
|
||||
{
|
||||
public SRestriction[] array;
|
||||
public int index;
|
||||
public SRestriction* ptr;
|
||||
|
||||
public EncodingStack(int count, Allocation<SRestriction[]> alloc)
|
||||
{
|
||||
array = alloc.Object;
|
||||
index = 0;
|
||||
ptr = (SRestriction*)alloc.Pointer;
|
||||
}
|
||||
}
|
||||
private readonly Stack<EncodingStack> _current = new Stack<EncodingStack>();
|
||||
private readonly EncodingStack _root;
|
||||
|
||||
public RestrictionEncoder()
|
||||
{
|
||||
// Create an object for the root element
|
||||
_root = Begin(1);
|
||||
}
|
||||
|
||||
protected override void DoRelease()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public SRestriction Restriction
|
||||
{
|
||||
get { return _root.array[0]; }
|
||||
}
|
||||
|
||||
private SRestriction* Current
|
||||
{
|
||||
get
|
||||
{
|
||||
EncodingStack top = _current.Peek();
|
||||
return top.ptr + top.index;
|
||||
}
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.PropertyExists part)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.Or part)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.PropertyIdentifier part)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.Not part)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.And part)
|
||||
{
|
||||
Current->rt = RestrictionType.AND;
|
||||
Current->sub.cb = (uint)part.Operands.Count;
|
||||
Current->sub.ptr = EncodePointer(part.Operands);
|
||||
}
|
||||
|
||||
private SRestriction* EncodePointer(IEnumerable<SearchQuery> operands)
|
||||
{
|
||||
EncodingStack alloc = Begin(operands.Count());
|
||||
try
|
||||
{
|
||||
foreach (SearchQuery operand in operands)
|
||||
{
|
||||
operand.Encode(this);
|
||||
++alloc.index;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
End();
|
||||
}
|
||||
return alloc.ptr;
|
||||
}
|
||||
|
||||
private EncodingStack Begin(int count)
|
||||
{
|
||||
// Allocate and push the array
|
||||
EncodingStack alloc = new EncodingStack(count, Allocate(new SRestriction[count]));
|
||||
_current.Push(alloc);
|
||||
|
||||
return alloc;
|
||||
}
|
||||
|
||||
private void End()
|
||||
{
|
||||
_current.Pop();
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.PropertyContent part)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.PropertyCompare part)
|
||||
{
|
||||
Current->rt = RestrictionType.PROPERTY;
|
||||
Current->prop.relop = (SearchOperation)part.Operation;
|
||||
Current->prop.ulPropTag = part.Property.Tag;
|
||||
Current->prop.prop = PropValue.FromObject(this, part.Value);
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.PropertyBitMask part)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public static class RestrictionExensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Encodes the search as an SRestriction.
|
||||
/// </summary>
|
||||
/// <returns>The encoder containing the restriction. The caller is responsible for disposing.</returns>
|
||||
public static RestrictionEncoder ToRestriction(this SearchQuery search)
|
||||
{
|
||||
RestrictionEncoder encoder = new RestrictionEncoder();
|
||||
search.Encode(encoder);
|
||||
return encoder;
|
||||
}
|
||||
}
|
||||
|
||||
/* Example search code
|
||||
{
|
||||
MAPIFolder folder = (MAPIFolder)account.Store.GetSpecialFolder(Microsoft.Office.Interop.Outlook.OlSpecialFolders.olSpecialFolderReminders);
|
||||
|
@ -32,7 +32,6 @@ namespace Acacia
|
||||
void Encode(SearchQuery.And part);
|
||||
void Encode(SearchQuery.Or part);
|
||||
void Encode(SearchQuery.Not part);
|
||||
void Encode(SearchQuery.PropertyIdentifier part);
|
||||
}
|
||||
|
||||
public class ToStringEncoder : ISearchEncoder
|
||||
@ -47,20 +46,21 @@ namespace Acacia
|
||||
|
||||
public void Encode(SearchQuery.And part)
|
||||
{
|
||||
EncodeMulti("AND", part.Operands);
|
||||
EncodeMulti(part, "AND");
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.Or part)
|
||||
{
|
||||
EncodeMulti("OR", part.Operands);
|
||||
EncodeMulti(part, "OR");
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.Not part)
|
||||
{
|
||||
EncodeMulti("NOT", new[] { part.Operand });
|
||||
_builder.Append("NOT ");
|
||||
part.Operand.Encode(this);
|
||||
}
|
||||
|
||||
private void EncodeMulti(string oper, IEnumerable<SearchQuery> parts)
|
||||
private void EncodeMulti(SearchQuery.MultiOperator part, string oper)
|
||||
{
|
||||
Indent();
|
||||
_builder.Append(oper).Append("\n");
|
||||
@ -69,7 +69,7 @@ namespace Acacia
|
||||
|
||||
++_indent;
|
||||
|
||||
foreach (SearchQuery operand in parts)
|
||||
foreach (SearchQuery operand in part.Operands)
|
||||
operand.Encode(this);
|
||||
|
||||
--_indent;
|
||||
@ -80,59 +80,22 @@ namespace Acacia
|
||||
|
||||
public void Encode(SearchQuery.PropertyBitMask part)
|
||||
{
|
||||
Indent();
|
||||
_builder.Append("BITMASK{");
|
||||
part.Property.Encode(this);
|
||||
_builder.Append(" ").Append(part.Operation).Append(" ");
|
||||
_builder.Append(part.Mask.ToString("X8"));
|
||||
_builder.Append("}\n");
|
||||
_builder.Append("BITMASK:").Append(part.Property); // TODO: operator/value
|
||||
}
|
||||
|
||||
private static readonly string[] COMPARISON_OPERATORS = {"<", "<=", ">", ">=", "==", "!=", "LIKE"};
|
||||
|
||||
public void Encode(SearchQuery.PropertyCompare part)
|
||||
{
|
||||
Indent();
|
||||
_builder.Append("COMPARE{");
|
||||
part.Property.Encode(this);
|
||||
_builder.Append(" ").Append(COMPARISON_OPERATORS[(int)part.Operation]).Append(" ");
|
||||
_builder.Append(part.Value);
|
||||
_builder.Append("}\n");
|
||||
_builder.Append("COMPARE:").Append(part.Property); // TODO: operator/value
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.PropertyContent part)
|
||||
{
|
||||
Indent();
|
||||
_builder.Append("CONTENT{");
|
||||
part.Property.Encode(this);
|
||||
|
||||
List<string> options = new List<string>();
|
||||
if (part.Operation != SearchQuery.ContentMatchOperation.Full)
|
||||
options.Add(part.Operation.ToString());
|
||||
|
||||
if (part.Modifiers != SearchQuery.ContentMatchModifiers.None)
|
||||
{
|
||||
options.Add(part.Modifiers.ToString());
|
||||
}
|
||||
|
||||
string optionsString = options.Count == 0 ? "" : ("(" + string.Join(",", options) + ")");
|
||||
|
||||
_builder.Append(" ==").Append(optionsString).Append(" ");
|
||||
_builder.Append(part.Content);
|
||||
_builder.Append("}\n");
|
||||
_builder.Append("CONTENT:").Append(part.Property); // TODO: operator/value
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.PropertyExists part)
|
||||
{
|
||||
Indent();
|
||||
_builder.Append("EXISTS{");
|
||||
part.Property.Encode(this);
|
||||
_builder.Append("}\n");
|
||||
}
|
||||
|
||||
public void Encode(SearchQuery.PropertyIdentifier part)
|
||||
{
|
||||
_builder.Append(part.Id);
|
||||
_builder.Append("EXISTS:").Append(part.Property);
|
||||
}
|
||||
|
||||
public string GetValue()
|
||||
@ -170,7 +133,7 @@ namespace Acacia
|
||||
_operands.Add(operand);
|
||||
}
|
||||
|
||||
public ICollection<SearchQuery> Operands
|
||||
public IEnumerable<SearchQuery> Operands
|
||||
{
|
||||
get { return _operands; }
|
||||
}
|
||||
@ -217,23 +180,16 @@ namespace Acacia
|
||||
/// </summary>
|
||||
public class PropertyIdentifier
|
||||
{
|
||||
public string Id { get; private set; }
|
||||
public PropTag Tag { get; private set; }
|
||||
private string _id;
|
||||
|
||||
public PropertyIdentifier(PropTag tag)
|
||||
public PropertyIdentifier(string id)
|
||||
{
|
||||
this.Tag = tag;
|
||||
Id = string.Format("{0:X4}{1:X4}", tag.prop, (int)tag.type);
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public void Encode(ISearchEncoder encoder)
|
||||
public static PropertyIdentifier FromTag(ushort prop, ushort type)
|
||||
{
|
||||
encoder.Encode(this);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Id;
|
||||
return new PropertyIdentifier(string.Format("{0:4X}{1:4X}", prop, type));
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,44 +247,11 @@ namespace Acacia
|
||||
}
|
||||
}
|
||||
|
||||
public enum ContentMatchOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// Match full content
|
||||
/// </summary>
|
||||
Full,
|
||||
|
||||
/// <summary>
|
||||
/// Match part of the content
|
||||
/// </summary>
|
||||
SubString,
|
||||
|
||||
/// <summary>
|
||||
/// Match the start of the content
|
||||
/// </summary>
|
||||
Prefix
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ContentMatchModifiers
|
||||
{
|
||||
None = 0,
|
||||
CaseInsensitive = 1,
|
||||
IgnoreNonSpace = 2,
|
||||
Loose = 4
|
||||
}
|
||||
|
||||
public class PropertyContent : PropertyQuery
|
||||
{
|
||||
public ContentMatchOperation Operation { get; set; }
|
||||
public ContentMatchModifiers Modifiers { get; set; }
|
||||
public object Content { get; set; }
|
||||
|
||||
public PropertyContent(PropertyIdentifier property, ContentMatchOperation operation, ContentMatchModifiers modifiers, object content) : base(property)
|
||||
public PropertyContent(PropertyIdentifier property, uint options, object content) : base(property)
|
||||
{
|
||||
this.Operation = operation;
|
||||
this.Modifiers = modifiers;
|
||||
this.Content = content;
|
||||
// TODO
|
||||
}
|
||||
|
||||
public override void Encode(ISearchEncoder encoder)
|
||||
@ -337,20 +260,11 @@ namespace Acacia
|
||||
}
|
||||
}
|
||||
|
||||
public enum BitMaskOperation
|
||||
{
|
||||
EQZ, NEZ
|
||||
}
|
||||
|
||||
public class PropertyBitMask : PropertyQuery
|
||||
{
|
||||
public BitMaskOperation Operation { get; set; }
|
||||
public uint Mask { get; set; }
|
||||
|
||||
public PropertyBitMask(PropertyIdentifier property, BitMaskOperation operation, uint mask) : base(property)
|
||||
public PropertyBitMask(PropertyIdentifier property, bool wantZero, uint mask) : base(property)
|
||||
{
|
||||
this.Operation = operation;
|
||||
this.Mask = mask;
|
||||
// TODO
|
||||
}
|
||||
|
||||
public override void Encode(ISearchEncoder encoder)
|
||||
|
Loading…
Reference in New Issue
Block a user