mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
Made Search manage returned items, like Folder.Items
This commit is contained in:
parent
10d2bd4d65
commit
f687ee9f22
@ -273,16 +273,12 @@ namespace Acacia.Features.GAB
|
||||
search.AddField(PROP_SEQUENCE, true).SetOperation(SearchOperation.Equal, index.numberOfChunks);
|
||||
search.AddField(PROP_CHUNK, true).SetOperation(SearchOperation.Equal, index.chunk);
|
||||
foreach (IItem oldItem in search.Search())
|
||||
{
|
||||
// TODO: Search should handle this, like folder enumeration
|
||||
using (oldItem)
|
||||
{
|
||||
Logger.Instance.Trace(this, "Deleting GAB entry: {0}", oldItem.Subject);
|
||||
oldItem.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the new contacts
|
||||
ProcessChunkBody(item, index);
|
||||
|
@ -176,19 +176,26 @@ namespace Acacia.Stubs.OutlookWrappers
|
||||
|
||||
public IEnumerable<ItemType> Search(int maxResults)
|
||||
{
|
||||
List<ItemType> values = new List<ItemType>();
|
||||
string filter = MakeFilter();
|
||||
|
||||
int count = 0;
|
||||
object value = _item.Find(filter);
|
||||
while(value != null)
|
||||
{
|
||||
if (values.Count < maxResults)
|
||||
if (count < maxResults)
|
||||
{
|
||||
// Wrap and add if it returns an object. If not, WrapOrDefault will release it
|
||||
ItemType wrapped = Mapping.WrapOrDefault<ItemType>(value);
|
||||
if (wrapped != null)
|
||||
{
|
||||
values.Add(wrapped);
|
||||
try
|
||||
{
|
||||
yield return wrapped;
|
||||
}
|
||||
finally
|
||||
{
|
||||
wrapped.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -197,8 +204,8 @@ namespace Acacia.Stubs.OutlookWrappers
|
||||
ComRelease.Release(value);
|
||||
}
|
||||
value = _item.FindNext();
|
||||
++count;
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
public ItemType SearchOne()
|
||||
|
@ -231,15 +231,12 @@ namespace Acacia.UI
|
||||
oper.AddField("urn:schemas:contacts:customerid").SetOperation(SearchOperation.Like, text + "%");
|
||||
|
||||
// Fetch the results up to the limit.
|
||||
// TODO: make limit a property
|
||||
// TODO: make limit a property?
|
||||
List<GABUser> users = new List<GABUser>();
|
||||
foreach (IContactItem result in search.Search(max))
|
||||
{
|
||||
using (result)
|
||||
{
|
||||
users.Add(new GABUser(result.FullName, result.CustomerID));
|
||||
}
|
||||
}
|
||||
|
||||
return users;
|
||||
}
|
||||
@ -254,15 +251,13 @@ namespace Acacia.UI
|
||||
search.AddField("urn:schemas:contacts:customerid").SetOperation(SearchOperation.Equal, username);
|
||||
|
||||
// Fetch the result, if any.
|
||||
// TODO: make a SearchOne method?
|
||||
List<GABUser> users = new List<GABUser>();
|
||||
foreach (IContactItem result in search.Search(1))
|
||||
{
|
||||
using (result)
|
||||
{
|
||||
return new GABUser(result.FullName, result.CustomerID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new GABUser(username);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user