summaryrefslogtreecommitdiffstats
path: root/mailnews/base/src/nsMsgRDFUtils.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-11-03 00:17:46 -0400
committerMatt A. Tobin <email@mattatobin.com>2019-11-03 00:17:46 -0400
commit302bf1b523012e11b60425d6eee1221ebc2724eb (patch)
treeb191a895f8716efcbe42f454f37597a545a6f421 /mailnews/base/src/nsMsgRDFUtils.cpp
parent21b3f6247403c06f85e1f45d219f87549862198f (diff)
downloadUXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.gz
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.lz
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.xz
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.zip
Issue #1258 - Part 1: Import mailnews, ldap, and mork from comm-esr52.9.1
Diffstat (limited to 'mailnews/base/src/nsMsgRDFUtils.cpp')
-rw-r--r--mailnews/base/src/nsMsgRDFUtils.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/mailnews/base/src/nsMsgRDFUtils.cpp b/mailnews/base/src/nsMsgRDFUtils.cpp
new file mode 100644
index 000000000..3202c73c9
--- /dev/null
+++ b/mailnews/base/src/nsMsgRDFUtils.cpp
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+#include "nsMsgRDFUtils.h"
+#include "nsIServiceManager.h"
+#include "prprf.h"
+#include "nsCOMPtr.h"
+#include "nsMemory.h"
+
+nsresult createNode(const char16_t *str, nsIRDFNode **node, nsIRDFService *rdfService)
+{
+ nsresult rv;
+ nsCOMPtr<nsIRDFLiteral> value;
+
+ NS_ASSERTION(rdfService, "rdfService is null");
+ if (!rdfService) return NS_OK;
+
+ if (str) {
+ rv = rdfService->GetLiteral(str, getter_AddRefs(value));
+ }
+ else {
+ rv = rdfService->GetLiteral(EmptyString().get(), getter_AddRefs(value));
+ }
+
+ if (NS_SUCCEEDED(rv)) {
+ *node = value;
+ NS_IF_ADDREF(*node);
+ }
+ return rv;
+}
+
+nsresult createIntNode(int32_t value, nsIRDFNode **node, nsIRDFService *rdfService)
+{
+ *node = nullptr;
+ nsresult rv;
+ if (!rdfService) return NS_ERROR_NULL_POINTER;
+ nsCOMPtr<nsIRDFInt> num;
+ rv = rdfService->GetIntLiteral(value, getter_AddRefs(num));
+ if(NS_SUCCEEDED(rv)) {
+ *node = num;
+ NS_IF_ADDREF(*node);
+ }
+ return rv;
+}
+
+nsresult createBlobNode(uint8_t *value, uint32_t &length, nsIRDFNode **node, nsIRDFService *rdfService)
+{
+ NS_ENSURE_ARG_POINTER(node);
+ NS_ENSURE_ARG_POINTER(rdfService);
+
+ *node = nullptr;
+ nsCOMPtr<nsIRDFBlob> blob;
+ nsresult rv = rdfService->GetBlobLiteral(value, length, getter_AddRefs(blob));
+ NS_ENSURE_SUCCESS(rv,rv);
+ NS_IF_ADDREF(*node = blob);
+ return rv;
+}
+
+nsresult GetTargetHasAssertion(nsIRDFDataSource *dataSource, nsIRDFResource* folderResource,
+ nsIRDFResource *property,bool tv, nsIRDFNode *target,bool* hasAssertion)
+{
+ NS_ENSURE_ARG_POINTER(hasAssertion);
+
+ nsCOMPtr<nsIRDFNode> currentTarget;
+
+ nsresult rv = dataSource->GetTarget(folderResource, property,tv, getter_AddRefs(currentTarget));
+ if(NS_SUCCEEDED(rv))
+ {
+ nsCOMPtr<nsIRDFLiteral> value1(do_QueryInterface(target));
+ nsCOMPtr<nsIRDFLiteral> value2(do_QueryInterface(currentTarget));
+ if(value1 && value2)
+ //If the two values are equal then it has this assertion
+ *hasAssertion = (value1 == value2);
+ }
+ else
+ rv = NS_NOINTERFACE;
+
+ return rv;
+
+}
+