releases-comm-central/mailnews/addrbook/modules/LDAPDirectoryQuery.sys.mjs

209 строки
5.8 KiB
JavaScript
Исходник Обычный вид История

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Bug 1824260 - esmify mailnews/. r=freaktechnik Differential Revision: https://phabricator.services.mozilla.com/D204279 --HG-- rename : mailnews/addrbook/modules/AddrBookDirectory.jsm => mailnews/addrbook/modules/AddrBookDirectory.sys.mjs rename : mailnews/addrbook/modules/AddrBookMailingList.jsm => mailnews/addrbook/modules/AddrBookMailingList.sys.mjs rename : mailnews/addrbook/modules/AddrBookUtils.jsm => mailnews/addrbook/modules/AddrBookUtils.sys.mjs rename : mailnews/addrbook/modules/CardDAVUtils.jsm => mailnews/addrbook/modules/CardDAVUtils.sys.mjs rename : mailnews/addrbook/modules/LDAPClient.jsm => mailnews/addrbook/modules/LDAPClient.sys.mjs rename : mailnews/addrbook/modules/LDAPListenerBase.jsm => mailnews/addrbook/modules/LDAPListenerBase.sys.mjs rename : mailnews/addrbook/modules/LDAPMessage.jsm => mailnews/addrbook/modules/LDAPMessage.sys.mjs rename : mailnews/addrbook/modules/QueryStringToExpression.jsm => mailnews/addrbook/modules/QueryStringToExpression.sys.mjs rename : mailnews/addrbook/test/CardDAVServer.jsm => mailnews/addrbook/test/CardDAVServer.sys.mjs rename : mailnews/addrbook/test/LDAPServer.jsm => mailnews/addrbook/test/LDAPServer.sys.mjs rename : mailnews/base/src/ABQueryUtils.jsm => mailnews/base/src/ABQueryUtils.sys.mjs rename : mailnews/base/src/FolderUtils.jsm => mailnews/base/src/FolderUtils.sys.mjs rename : mailnews/base/src/JXON.jsm => mailnews/base/src/JXON.sys.mjs rename : mailnews/base/src/LineReader.jsm => mailnews/base/src/LineReader.sys.mjs rename : mailnews/base/src/MailAuthenticator.jsm => mailnews/base/src/MailAuthenticator.sys.mjs rename : mailnews/base/src/MailCryptoUtils.jsm => mailnews/base/src/MailCryptoUtils.sys.mjs rename : mailnews/base/src/MailServices.jsm => mailnews/base/src/MailServices.sys.mjs rename : mailnews/base/src/MailStringUtils.jsm => mailnews/base/src/MailStringUtils.sys.mjs rename : mailnews/base/src/MailnewsMigrator.jsm => mailnews/base/src/MailnewsMigrator.sys.mjs rename : mailnews/base/src/MsgDBCacheManager.jsm => mailnews/base/src/MsgDBCacheManager.sys.mjs rename : mailnews/base/src/MsgIncomingServer.jsm => mailnews/base/src/MsgIncomingServer.sys.mjs rename : mailnews/base/src/MsgKeySet.jsm => mailnews/base/src/MsgKeySet.sys.mjs rename : mailnews/base/src/OAuth2.jsm => mailnews/base/src/OAuth2.sys.mjs rename : mailnews/base/src/OAuth2Providers.jsm => mailnews/base/src/OAuth2Providers.sys.mjs rename : mailnews/base/src/TemplateUtils.jsm => mailnews/base/src/TemplateUtils.sys.mjs rename : mailnews/base/src/VirtualFolderWrapper.jsm => mailnews/base/src/VirtualFolderWrapper.sys.mjs rename : mailnews/base/src/WinUnreadBadge.jsm => mailnews/base/src/WinUnreadBadge.sys.mjs rename : mailnews/base/src/hostnameUtils.jsm => mailnews/base/src/hostnameUtils.sys.mjs rename : mailnews/base/src/mailstoreConverter.jsm => mailnews/base/src/mailstoreConverter.sys.mjs rename : mailnews/compose/src/MimeEncoder.jsm => mailnews/compose/src/MimeEncoder.sys.mjs rename : mailnews/compose/src/MimeMessage.jsm => mailnews/compose/src/MimeMessage.sys.mjs rename : mailnews/compose/src/MimeMessageUtils.jsm => mailnews/compose/src/MimeMessageUtils.sys.mjs rename : mailnews/compose/src/MimePart.jsm => mailnews/compose/src/MimePart.sys.mjs rename : mailnews/compose/src/SmtpClient.jsm => mailnews/compose/src/SmtpClient.sys.mjs rename : mailnews/db/gloda/modules/Collection.jsm => mailnews/db/gloda/modules/Collection.sys.mjs rename : mailnews/db/gloda/modules/Everybody.jsm => mailnews/db/gloda/modules/Everybody.sys.mjs rename : mailnews/db/gloda/modules/Facet.jsm => mailnews/db/gloda/modules/Facet.sys.mjs rename : mailnews/db/gloda/modules/Gloda.jsm => mailnews/db/gloda/modules/Gloda.sys.mjs rename : mailnews/db/gloda/modules/GlodaConstants.jsm => mailnews/db/gloda/modules/GlodaConstants.sys.mjs rename : mailnews/db/gloda/modules/GlodaContent.jsm => mailnews/db/gloda/modules/GlodaContent.sys.mjs rename : mailnews/db/gloda/modules/GlodaDataModel.jsm => mailnews/db/gloda/modules/GlodaDataModel.sys.mjs rename : mailnews/db/gloda/modules/GlodaDatabind.jsm => mailnews/db/gloda/modules/GlodaDatabind.sys.mjs rename : mailnews/db/gloda/modules/GlodaDatastore.jsm => mailnews/db/gloda/modules/GlodaDatastore.sys.mjs rename : mailnews/db/gloda/modules/GlodaExplicitAttr.jsm => mailnews/db/gloda/modules/GlodaExplicitAttr.sys.mjs rename : mailnews/db/gloda/modules/GlodaFundAttr.jsm => mailnews/db/gloda/modules/GlodaFundAttr.sys.mjs rename : mailnews/db/gloda/modules/GlodaIndexer.jsm => mailnews/db/gloda/modules/GlodaIndexer.sys.mjs rename : mailnews/db/gloda/modules/GlodaMsgIndexer.jsm => mailnews/db/gloda/modules/GlodaMsgIndexer.sys.mjs rename : mailnews/db/gloda/modules/GlodaMsgSearcher.jsm => mailnews/db/gloda/modules/GlodaMsgSearcher.sys.mjs rename : mailnews/db/gloda/modules/GlodaPublic.jsm => mailnews/db/gloda/modules/GlodaPublic.sys.mjs rename : mailnews/db/gloda/modules/GlodaQueryClassFactory.jsm => mailnews/db/gloda/modules/GlodaQueryClassFactory.sys.mjs rename : mailnews/db/gloda/modules/GlodaSyntheticView.jsm => mailnews/db/gloda/modules/GlodaSyntheticView.sys.mjs rename : mailnews/db/gloda/modules/GlodaUtils.jsm => mailnews/db/gloda/modules/GlodaUtils.sys.mjs rename : mailnews/db/gloda/modules/IndexMsg.jsm => mailnews/db/gloda/modules/IndexMsg.sys.mjs rename : mailnews/db/gloda/modules/MimeMessage.jsm => mailnews/db/gloda/modules/MimeMessage.sys.mjs rename : mailnews/db/gloda/modules/NounFreetag.jsm => mailnews/db/gloda/modules/NounFreetag.sys.mjs rename : mailnews/db/gloda/modules/NounMimetype.jsm => mailnews/db/gloda/modules/NounMimetype.sys.mjs rename : mailnews/db/gloda/modules/NounTag.jsm => mailnews/db/gloda/modules/NounTag.sys.mjs rename : mailnews/db/gloda/modules/SuffixTree.jsm => mailnews/db/gloda/modules/SuffixTree.sys.mjs rename : mailnews/db/gloda/test/unit/resources/GlodaQueryHelper.jsm => mailnews/db/gloda/test/unit/resources/GlodaQueryHelper.sys.mjs rename : mailnews/db/gloda/test/unit/resources/GlodaTestHelper.jsm => mailnews/db/gloda/test/unit/resources/GlodaTestHelper.sys.mjs rename : mailnews/db/gloda/test/unit/resources/GlodaTestHelperFunctions.jsm => mailnews/db/gloda/test/unit/resources/GlodaTestHelperFunctions.sys.mjs rename : mailnews/export/modules/ProfileExporter.jsm => mailnews/export/modules/ProfileExporter.sys.mjs rename : mailnews/extensions/newsblog/Feed.jsm => mailnews/extensions/newsblog/Feed.sys.mjs rename : mailnews/extensions/newsblog/FeedItem.jsm => mailnews/extensions/newsblog/FeedItem.sys.mjs rename : mailnews/extensions/newsblog/FeedParser.jsm => mailnews/extensions/newsblog/FeedParser.sys.mjs rename : mailnews/extensions/newsblog/FeedUtils.jsm => mailnews/extensions/newsblog/FeedUtils.sys.mjs rename : mailnews/imap/src/ImapChannel.jsm => mailnews/imap/src/ImapChannel.sys.mjs rename : mailnews/imap/src/ImapClient.jsm => mailnews/imap/src/ImapClient.sys.mjs rename : mailnews/imap/src/ImapIncomingServer.jsm => mailnews/imap/src/ImapIncomingServer.sys.mjs rename : mailnews/imap/src/ImapMessageService.jsm => mailnews/imap/src/ImapMessageService.sys.mjs rename : mailnews/imap/src/ImapProtocolHandler.jsm => mailnews/imap/src/ImapProtocolHandler.sys.mjs rename : mailnews/imap/src/ImapProtocolInfo.jsm => mailnews/imap/src/ImapProtocolInfo.sys.mjs rename : mailnews/imap/src/ImapResponse.jsm => mailnews/imap/src/ImapResponse.sys.mjs rename : mailnews/imap/src/ImapService.jsm => mailnews/imap/src/ImapService.sys.mjs rename : mailnews/imap/src/ImapUtils.jsm => mailnews/imap/src/ImapUtils.sys.mjs rename : mailnews/import/modules/AddrBookFileImporter.jsm => mailnews/import/modules/AddrBookFileImporter.sys.mjs rename : mailnews/import/modules/AppleMailProfileImporter.jsm => mailnews/import/modules/AppleMailProfileImporter.sys.mjs rename : mailnews/import/modules/BaseProfileImporter.jsm => mailnews/import/modules/BaseProfileImporter.sys.mjs rename : mailnews/import/modules/BeckyProfileImporter.jsm => mailnews/import/modules/BeckyProfileImporter.sys.mjs rename : mailnews/import/modules/CalendarFileImporter.jsm => mailnews/import/modules/CalendarFileImporter.sys.mjs rename : mailnews/import/modules/OutlookProfileImporter.jsm => mailnews/import/modules/OutlookProfileImporter.sys.mjs rename : mailnews/import/modules/SeamonkeyProfileImporter.jsm => mailnews/import/modules/SeamonkeyProfileImporter.sys.mjs rename : mailnews/import/modules/ThunderbirdProfileImporter.jsm => mailnews/import/modules/ThunderbirdProfileImporter.sys.mjs rename : mailnews/jsaccount/modules/JSAccountUtils.jsm => mailnews/jsaccount/modules/JSAccountUtils.sys.mjs rename : mailnews/jsaccount/modules/JaBaseUrl.jsm => mailnews/jsaccount/modules/JaBaseUrl.sys.mjs rename : mailnews/jsaccount/test/unit/resources/testJaBaseIncomingServer.jsm => mailnews/jsaccount/test/unit/resources/testJaBaseIncomingServer.sys.mjs rename : mailnews/jsaccount/test/unit/resources/testJaBaseMsgFolder.jsm => mailnews/jsaccount/test/unit/resources/testJaBaseMsgFolder.sys.mjs rename : mailnews/local/src/Pop3Channel.jsm => mailnews/local/src/Pop3Channel.sys.mjs rename : mailnews/local/src/Pop3Client.jsm => mailnews/local/src/Pop3Client.sys.mjs rename : mailnews/mime/src/jsmime.jsm => mailnews/mime/src/jsmime.sys.mjs rename : mailnews/mime/src/mimeParser.jsm => mailnews/mime/src/mimeParser.sys.mjs rename : mailnews/news/src/NntpChannel.jsm => mailnews/news/src/NntpChannel.sys.mjs rename : mailnews/news/src/NntpClient.jsm => mailnews/news/src/NntpClient.sys.mjs rename : mailnews/news/src/NntpNewsGroup.jsm => mailnews/news/src/NntpNewsGroup.sys.mjs rename : mailnews/news/src/NntpUtils.jsm => mailnews/news/src/NntpUtils.sys.mjs rename : mailnews/search/src/PeriodicFilterManager.jsm => mailnews/search/src/PeriodicFilterManager.sys.mjs extra : rebase_source : 0d95b8d8e0eb6134fe513fab1793e34bab974206
2024-03-12 18:01:01 +03:00
import { LDAPListenerBase } from "resource:///modules/LDAPListenerBase.sys.mjs";
/**
* Convert a nsIAbBooleanExpression to a filter string.
*
* @param {nsIAbLDAPAttributeMap} attrMap - A mapping between address book
* properties and ldap attributes.
* @param {nsIAbBooleanExpression} exp - The expression to convert.
* @returns {string}
*/
function boolExpressionToFilter(attrMap, exp) {
let filter = "(";
filter +=
{
[Ci.nsIAbBooleanOperationTypes.AND]: "&",
[Ci.nsIAbBooleanOperationTypes.OR]: "|",
[Ci.nsIAbBooleanOperationTypes.NOT]: "!",
}[exp.operation] || "";
if (exp.expressions) {
for (const childExp of exp.expressions) {
if (childExp instanceof Ci.nsIAbBooleanExpression) {
filter += boolExpressionToFilter(attrMap, childExp);
} else if (childExp instanceof Ci.nsIAbBooleanConditionString) {
filter += boolConditionToFilter(attrMap, childExp);
}
}
}
filter += ")";
return filter;
}
/**
* Convert a nsIAbBooleanConditionString to a filter string.
*
* @param {nsIAbLDAPAttributeMap} attrMap - A mapping between addressbook
* properties and ldap attributes.
* @param {nsIAbBooleanConditionString} exp - The expression to convert.
* @returns {string}
*/
function boolConditionToFilter(attrMap, exp) {
const attr = attrMap.getFirstAttribute(exp.name);
if (!attr) {
return "";
}
switch (exp.condition) {
case Ci.nsIAbBooleanConditionTypes.DoesNotExist:
return `(!(${attr}=*))`;
case Ci.nsIAbBooleanConditionTypes.Exists:
return `(${attr}=*)`;
case Ci.nsIAbBooleanConditionTypes.Contains:
return `(${attr}=*${exp.value}*)`;
case Ci.nsIAbBooleanConditionTypes.DoesNotContain:
return `(!(${attr}=*${exp.value}*))`;
case Ci.nsIAbBooleanConditionTypes.Is:
return `(${attr}=${exp.value})`;
case Ci.nsIAbBooleanConditionTypes.IsNot:
return `(!(${attr}=${exp.value}))`;
case Ci.nsIAbBooleanConditionTypes.BeginsWith:
return `(${attr}=${exp.value}*)`;
case Ci.nsIAbBooleanConditionTypes.EndsWith:
return `(${attr}=*${exp.value})`;
case Ci.nsIAbBooleanConditionTypes.LessThan:
return `(${attr}<=${exp.value})`;
case Ci.nsIAbBooleanConditionTypes.GreaterThan:
return `(${attr}>=${exp.value})`;
case Ci.nsIAbBooleanConditionTypes.SoundsLike:
return `(${attr}~=${exp.value})`;
default:
return "";
}
}
/**
* @implements {nsIAbDirectoryQuery}
* @implements {nsILDAPMessageListener}
*/
Bug 1881745 - Convert all registered components from JSM to ESM. r=thunderbird-reviewers,ikey Differential Revision: https://phabricator.services.mozilla.com/D202568 --HG-- rename : calendar/base/src/CalAlarm.jsm => calendar/base/src/CalAlarm.sys.mjs rename : calendar/base/src/CalAlarmMonitor.jsm => calendar/base/src/CalAlarmMonitor.sys.mjs rename : calendar/base/src/CalAlarmService.jsm => calendar/base/src/CalAlarmService.sys.mjs rename : calendar/base/src/CalAttachment.jsm => calendar/base/src/CalAttachment.sys.mjs rename : calendar/base/src/CalAttendee.jsm => calendar/base/src/CalAttendee.sys.mjs rename : calendar/base/src/CalCalendarManager.jsm => calendar/base/src/CalCalendarManager.sys.mjs rename : calendar/base/src/CalDateTime.jsm => calendar/base/src/CalDateTime.sys.mjs rename : calendar/base/src/CalDefaultACLManager.jsm => calendar/base/src/CalDefaultACLManager.sys.mjs rename : calendar/base/src/CalDeletedItems.jsm => calendar/base/src/CalDeletedItems.sys.mjs rename : calendar/base/src/CalDuration.jsm => calendar/base/src/CalDuration.sys.mjs rename : calendar/base/src/CalEvent.jsm => calendar/base/src/CalEvent.sys.mjs rename : calendar/base/src/CalFreeBusyService.jsm => calendar/base/src/CalFreeBusyService.sys.mjs rename : calendar/base/src/CalICSService.jsm => calendar/base/src/CalICSService.sys.mjs rename : calendar/base/src/CalIcsParser.jsm => calendar/base/src/CalIcsParser.sys.mjs rename : calendar/base/src/CalIcsSerializer.jsm => calendar/base/src/CalIcsSerializer.sys.mjs rename : calendar/base/src/CalItipItem.jsm => calendar/base/src/CalItipItem.sys.mjs rename : calendar/base/src/CalMimeConverter.jsm => calendar/base/src/CalMimeConverter.sys.mjs rename : calendar/base/src/CalPeriod.jsm => calendar/base/src/CalPeriod.sys.mjs rename : calendar/base/src/CalProtocolHandler.jsm => calendar/base/src/CalProtocolHandler.sys.mjs rename : calendar/base/src/CalRecurrenceDate.jsm => calendar/base/src/CalRecurrenceDate.sys.mjs rename : calendar/base/src/CalRecurrenceInfo.jsm => calendar/base/src/CalRecurrenceInfo.sys.mjs rename : calendar/base/src/CalRecurrenceRule.jsm => calendar/base/src/CalRecurrenceRule.sys.mjs rename : calendar/base/src/CalRelation.jsm => calendar/base/src/CalRelation.sys.mjs rename : calendar/base/src/CalStartupService.jsm => calendar/base/src/CalStartupService.sys.mjs rename : calendar/base/src/CalTimezoneService.jsm => calendar/base/src/CalTimezoneService.sys.mjs rename : calendar/base/src/CalTodo.jsm => calendar/base/src/CalTodo.sys.mjs rename : calendar/base/src/CalWeekInfoService.jsm => calendar/base/src/CalWeekInfoService.sys.mjs rename : calendar/import-export/CalHtmlExport.jsm => calendar/import-export/CalHtmlExport.sys.mjs rename : calendar/import-export/CalIcsImportExport.jsm => calendar/import-export/CalIcsImportExport.sys.mjs rename : calendar/itip/CalItipEmailTransport.jsm => calendar/itip/CalItipEmailTransport.sys.mjs rename : calendar/itip/CalItipProtocolHandler.jsm => calendar/itip/CalItipProtocolHandler.sys.mjs rename : calendar/providers/caldav/CalDavCalendar.jsm => calendar/providers/caldav/CalDavCalendar.sys.mjs rename : calendar/providers/composite/CalCompositeCalendar.jsm => calendar/providers/composite/CalCompositeCalendar.sys.mjs rename : calendar/providers/memory/CalMemoryCalendar.jsm => calendar/providers/memory/CalMemoryCalendar.sys.mjs rename : calendar/providers/storage/CalStorageCalendar.jsm => calendar/providers/storage/CalStorageCalendar.sys.mjs rename : mail/components/AboutRedirector.jsm => mail/components/AboutRedirector.sys.mjs rename : mail/components/MailGlue.jsm => mail/components/MailGlue.sys.mjs rename : mail/components/StartupRecorder.jsm => mail/components/StartupRecorder.sys.mjs rename : mail/components/activity/Activity.jsm => mail/components/activity/Activity.sys.mjs rename : mail/components/activity/ActivityManager.jsm => mail/components/activity/ActivityManager.sys.mjs rename : mail/components/activity/ActivityManagerUI.jsm => mail/components/activity/ActivityManagerUI.sys.mjs rename : mail/components/devtools/devtools-loader.jsm => mail/components/devtools/devtools-loader.sys.mjs rename : mail/components/migration/src/ThunderbirdProfileMigrator.jsm => mail/components/migration/src/ThunderbirdProfileMigrator.sys.mjs rename : mail/components/prompts/PromptCollection.jsm => mail/components/prompts/PromptCollection.sys.mjs rename : mail/extensions/am-e2e/AME2E.jsm => mail/extensions/am-e2e/AME2E.sys.mjs rename : mailnews/addrbook/modules/AddrBookCard.jsm => mailnews/addrbook/modules/AddrBookCard.sys.mjs rename : mailnews/addrbook/modules/AddrBookManager.jsm => mailnews/addrbook/modules/AddrBookManager.sys.mjs rename : mailnews/addrbook/modules/CardDAVDirectory.jsm => mailnews/addrbook/modules/CardDAVDirectory.sys.mjs rename : mailnews/addrbook/modules/LDAPConnection.jsm => mailnews/addrbook/modules/LDAPConnection.sys.mjs rename : mailnews/addrbook/modules/LDAPDirectory.jsm => mailnews/addrbook/modules/LDAPDirectory.sys.mjs rename : mailnews/addrbook/modules/LDAPDirectoryQuery.jsm => mailnews/addrbook/modules/LDAPDirectoryQuery.sys.mjs rename : mailnews/addrbook/modules/LDAPOperation.jsm => mailnews/addrbook/modules/LDAPOperation.sys.mjs rename : mailnews/addrbook/modules/LDAPProtocolHandler.jsm => mailnews/addrbook/modules/LDAPProtocolHandler.sys.mjs rename : mailnews/addrbook/modules/LDAPReplicationService.jsm => mailnews/addrbook/modules/LDAPReplicationService.sys.mjs rename : mailnews/addrbook/modules/LDAPService.jsm => mailnews/addrbook/modules/LDAPService.sys.mjs rename : mailnews/addrbook/modules/LDAPSyncQuery.jsm => mailnews/addrbook/modules/LDAPSyncQuery.sys.mjs rename : mailnews/addrbook/modules/LDAPURLParser.jsm => mailnews/addrbook/modules/LDAPURLParser.sys.mjs rename : mailnews/addrbook/modules/SQLiteDirectory.jsm => mailnews/addrbook/modules/SQLiteDirectory.sys.mjs rename : mailnews/addrbook/modules/VCardUtils.jsm => mailnews/addrbook/modules/VCardUtils.sys.mjs rename : mailnews/addrbook/src/AbAutoCompleteMyDomain.jsm => mailnews/addrbook/src/AbAutoCompleteMyDomain.sys.mjs rename : mailnews/addrbook/src/AbAutoCompleteSearch.jsm => mailnews/addrbook/src/AbAutoCompleteSearch.sys.mjs rename : mailnews/addrbook/src/AbLDAPAttributeMap.jsm => mailnews/addrbook/src/AbLDAPAttributeMap.sys.mjs rename : mailnews/addrbook/src/AbLDAPAutoCompleteSearch.jsm => mailnews/addrbook/src/AbLDAPAutoCompleteSearch.sys.mjs rename : mailnews/base/src/FolderLookupService.jsm => mailnews/base/src/FolderLookupService.sys.mjs rename : mailnews/base/src/MailNotificationManager.jsm => mailnews/base/src/MailNotificationManager.sys.mjs rename : mailnews/base/src/MailNotificationService.jsm => mailnews/base/src/MailNotificationService.sys.mjs rename : mailnews/base/src/MsgAsyncPrompter.jsm => mailnews/base/src/MsgAsyncPrompter.sys.mjs rename : mailnews/base/src/OAuth2Module.jsm => mailnews/base/src/OAuth2Module.sys.mjs rename : mailnews/compose/src/MailtoProtocolHandler.jsm => mailnews/compose/src/MailtoProtocolHandler.sys.mjs rename : mailnews/compose/src/MessageSend.jsm => mailnews/compose/src/MessageSend.sys.mjs rename : mailnews/compose/src/SMTPProtocolHandler.jsm => mailnews/compose/src/SMTPProtocolHandler.sys.mjs rename : mailnews/compose/src/SmtpServer.jsm => mailnews/compose/src/SmtpServer.sys.mjs rename : mailnews/compose/src/SmtpService.jsm => mailnews/compose/src/SmtpService.sys.mjs rename : mailnews/db/gloda/components/GlodaAutoComplete.jsm => mailnews/db/gloda/components/GlodaAutoComplete.sys.mjs rename : mailnews/db/gloda/components/MimeMessageEmitter.jsm => mailnews/db/gloda/components/MimeMessageEmitter.sys.mjs rename : mailnews/extensions/mdn/MDNService.jsm => mailnews/extensions/mdn/MDNService.sys.mjs rename : mailnews/extensions/newsblog/NewsBlog.jsm => mailnews/extensions/newsblog/NewsBlog.sys.mjs rename : mailnews/extensions/offline-startup/OfflineStartup.jsm => mailnews/extensions/offline-startup/OfflineStartup.sys.mjs rename : mailnews/imap/src/ImapModuleLoader.jsm => mailnews/imap/src/ImapModuleLoader.sys.mjs rename : mailnews/import/src/SeamonkeyImport.jsm => mailnews/import/src/SeamonkeyImport.sys.mjs rename : mailnews/import/src/ThunderbirdImport.jsm => mailnews/import/src/ThunderbirdImport.sys.mjs rename : mailnews/jsaccount/test/unit/resources/TestJaMsgProtocolInfoComponent.jsm => mailnews/jsaccount/test/unit/resources/TestJaMsgProtocolInfoComponent.sys.mjs rename : mailnews/local/src/Pop3IncomingServer.jsm => mailnews/local/src/Pop3IncomingServer.sys.mjs rename : mailnews/local/src/Pop3ProtocolHandler.jsm => mailnews/local/src/Pop3ProtocolHandler.sys.mjs rename : mailnews/local/src/Pop3ProtocolInfo.jsm => mailnews/local/src/Pop3ProtocolInfo.sys.mjs rename : mailnews/local/src/Pop3Service.jsm => mailnews/local/src/Pop3Service.sys.mjs rename : mailnews/mime/src/MimeJSComponents.jsm => mailnews/mime/src/MimeJSComponents.sys.mjs rename : mailnews/news/src/NewsAutoCompleteSearch.jsm => mailnews/news/src/NewsAutoCompleteSearch.sys.mjs rename : mailnews/news/src/NntpIncomingServer.jsm => mailnews/news/src/NntpIncomingServer.sys.mjs rename : mailnews/news/src/NntpMessageService.jsm => mailnews/news/src/NntpMessageService.sys.mjs rename : mailnews/news/src/NntpProtocolHandler.jsm => mailnews/news/src/NntpProtocolHandler.sys.mjs rename : mailnews/news/src/NntpProtocolInfo.jsm => mailnews/news/src/NntpProtocolInfo.sys.mjs rename : mailnews/news/src/NntpService.jsm => mailnews/news/src/NntpService.sys.mjs rename : mailnews/search/src/MsgTraitService.jsm => mailnews/search/src/MsgTraitService.sys.mjs extra : moz-landing-system : lando
2024-02-23 15:50:48 +03:00
export class LDAPDirectoryQuery extends LDAPListenerBase {
QueryInterface = ChromeUtils.generateQI([
"nsIAbDirectoryQuery",
"nsILDAPMessageListener",
]);
i = 0;
doQuery(directory, args, listener, limit, timeout) {
this._directory = directory.QueryInterface(Ci.nsIAbLDAPDirectory);
this._listener = listener;
this._attrMap = args.typeSpecificArg;
this._filter =
args.filter || boolExpressionToFilter(this._attrMap, args.expression);
this._limit = limit;
this._timeout = timeout;
let urlFilter = this._directory.lDAPURL.filter;
// If urlFilter is empty or the default "(objectclass=*)", do nothing.
if (urlFilter && urlFilter != "(objectclass=*)") {
if (!urlFilter.startsWith("(")) {
urlFilter = `(${urlFilter})`;
}
this._filter = `(&${urlFilter}${this._filter})`;
}
this._connection = Cc[
"@mozilla.org/network/ldap-connection;1"
].createInstance(Ci.nsILDAPConnection);
this._operation = Cc[
"@mozilla.org/network/ldap-operation;1"
].createInstance(Ci.nsILDAPOperation);
this._connection.init(directory.lDAPURL, directory.authDn, this);
return this.i++;
}
stopQuery() {
this._operation?.abandonExt();
}
/**
* @see nsILDAPMessageListener
*/
onLDAPMessage(msg) {
switch (msg.type) {
case Ci.nsILDAPMessage.RES_BIND:
this._onLDAPBind(msg);
break;
case Ci.nsILDAPMessage.RES_SEARCH_ENTRY:
this._onLDAPSearchEntry(msg);
break;
case Ci.nsILDAPMessage.RES_SEARCH_RESULT:
this._onLDAPSearchResult(msg);
break;
default:
break;
}
}
/**
* @see nsILDAPMessageListener
*/
onLDAPError(status, secInfo, location) {
this._onSearchFinished(status, secInfo, location);
}
/**
* @see LDAPListenerBase
*/
_actionOnBindSuccess() {
const ldapUrl = this._directory.lDAPURL;
this._operation.searchExt(
ldapUrl.dn,
ldapUrl.scope,
this._filter,
ldapUrl.attributes,
this._timeout,
this._limit
);
}
/**
* @see LDAPListenerBase
*/
_actionOnBindFailure() {
this._onSearchFinished(Cr.NS_ERROR_FAILURE);
}
/**
* Handler of nsILDAPMessage.RES_SEARCH_ENTRY message.
*
* @param {nsILDAPMessage} msg - The received LDAP message.
*/
_onLDAPSearchEntry(msg) {
const newCard = Cc[
"@mozilla.org/addressbook/cardproperty;1"
].createInstance(Ci.nsIAbCard);
this._attrMap.setCardPropertiesFromLDAPMessage(msg, newCard);
newCard.directoryUID = this._directory.UID;
this._listener.onSearchFoundCard(newCard);
}
/**
* Handler of nsILDAPMessage.RES_SEARCH_RESULT message.
*
* @param {nsILDAPMessage} msg - The received LDAP message.
*/
_onLDAPSearchResult(msg) {
this._onSearchFinished(
[Ci.nsILDAPErrors.SUCCESS, Ci.nsILDAPErrors.SIZELIMIT_EXCEEDED].includes(
msg.errorCode
)
? Cr.NS_OK
: Cr.NS_ERROR_FAILURE
);
}
_onSearchFinished(status, secInfo, location) {
this._listener.onSearchFinished(status, false, secInfo, location);
}
}
LDAPDirectoryQuery.prototype.classID = Components.ID(
"{5ad5d311-1a50-43db-a03c-63d45f443903}"
);