Hi,

I'm having a little difficulty with the usage of nspi_SeekEntries. I an
calling it apparently successfully in that it does not return an error, but
a subsequent call to GetGalTable always seems to return data from the
beginning. FWIW, the code is equivalent to:

key.ulPropTag = (MAPITAGS)PR_DISPLAY_NAME_UNICODE;
key.dwAlignPad = 0;
key.value.lpszW = talloc_strdup(mem.ctx(), displayName.toUtf8().data());
if (MAPI_E_SUCCESS != nspi_SeekEntries(nspi, mem.ctx(),
SortTypeDisplayName, &key, tags, NULL, results)) {
error() << "cannot seek to GAL entry" << displayName << mapiError();
return false;
}
if (MAPI_E_SUCCESS != GetGALTable(m_session, tags, results, requestedCount,
TABLE_CUR)) {
error() << "cannot read GAL entries" << mapiError();
return false;
}

[ Interestingly, note that the "results" value from the first call is
always NULL, rather than the relevant row, but I'm not sure if that is
another problem or not. ]

Now, looking at the implementation of GetGALTable, when TABLE_CUR is
specified, I think it expects to use the values previously stored in
the nspi->pStat to do the fetch. And indeed, after the fetch, it updates
the stored value. But AFAICS, nspi_SeekEntries does not update the stored
value - that seems like the problem to me. In other words, the bottom of
this function should look like the bottom of GetGALTable:

          OPENCHANGE_RETVAL_IF(!NT_STATUS_IS_OK(status), retval, NULL);
          OPENCHANGE_RETVAL_IF(retval, retval, NULL);

+         nspi_ctx->pStat->CurrentRec = r.out.pStat->CurrentRec;
+         nspi_ctx->pStat->Delta = r.out.pStat->Delta;
+         nspi_ctx->pStat->NumPos = r.out.pStat->NumPos;
+         nspi_ctx->pStat->TotalRecs = r.out.pStat->TotalRecs;

          return MAPI_E_SUCCESS;

Assuming that sounds reasonable, would a patch be acceptable?

Thanks, Shaheed
_______________________________________________
devel mailing list
devel@lists.openchange.org
http://mailman.openchange.org/listinfo/devel

Reply via email to