summaryrefslogtreecommitdiffstats
path: root/mailnews/addrbook/src/nsAbBooleanExpression.cpp
blob: a1a39c1faa38ee2248aa6128efbf8ae3fca89623 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 "nsAbBooleanExpression.h"
#include "nsComponentManagerUtils.h"

NS_IMPL_ISUPPORTS(nsAbBooleanConditionString, nsIAbBooleanConditionString)

nsAbBooleanConditionString::nsAbBooleanConditionString() :
    mCondition (nsIAbBooleanConditionTypes::Exists)
{
}

nsAbBooleanConditionString::~nsAbBooleanConditionString()
{
}

/* attribute nsAbBooleanConditionType condition; */
NS_IMETHODIMP nsAbBooleanConditionString::GetCondition(nsAbBooleanConditionType *aCondition)
{
    if (!aCondition)
        return NS_ERROR_NULL_POINTER;

    *aCondition = mCondition;

    return NS_OK;
}
NS_IMETHODIMP nsAbBooleanConditionString::SetCondition(nsAbBooleanConditionType aCondition)
{
    mCondition = aCondition;

    return NS_OK;
}

/* attribute string name; */
NS_IMETHODIMP nsAbBooleanConditionString::GetName(char** aName)
{
    if (!aName)
        return NS_ERROR_NULL_POINTER;

    *aName = mName.IsEmpty() ? 0 : ToNewCString(mName);

    return NS_OK;

}
NS_IMETHODIMP nsAbBooleanConditionString::SetName(const char* aName)
{
    if (!aName)
        return NS_ERROR_NULL_POINTER;

    mName = aName;

    return NS_OK;
}

/* attribute wstring value; */
NS_IMETHODIMP nsAbBooleanConditionString::GetValue(char16_t** aValue)
{
    if (!aValue)
        return NS_ERROR_NULL_POINTER;

    *aValue = ToNewUnicode(mValue);

    return NS_OK;
}
NS_IMETHODIMP nsAbBooleanConditionString::SetValue(const char16_t * aValue)
{
    if (!aValue)
        return NS_ERROR_NULL_POINTER;

    mValue = aValue;

    return NS_OK;
}

NS_IMPL_ISUPPORTS(nsAbBooleanExpression, nsIAbBooleanExpression)

nsAbBooleanExpression::nsAbBooleanExpression() :
    mOperation (nsIAbBooleanOperationTypes::AND)
{
}

nsAbBooleanExpression::~nsAbBooleanExpression()
{
}

/* attribute nsAbBooleanOperationType operation; */
NS_IMETHODIMP nsAbBooleanExpression::GetOperation(nsAbBooleanOperationType *aOperation)
{
    if (!aOperation)
        return NS_ERROR_NULL_POINTER;

    *aOperation = mOperation;

    return NS_OK;
}
NS_IMETHODIMP nsAbBooleanExpression::SetOperation(nsAbBooleanOperationType aOperation)
{
    mOperation = aOperation;

    return NS_OK;
}

/* attribute nsIArray expressions; */
NS_IMETHODIMP nsAbBooleanExpression::GetExpressions(nsIArray **aExpressions)
{
  if (!aExpressions)
    return NS_ERROR_NULL_POINTER;

  if (!mExpressions)
  {
    mExpressions = do_CreateInstance(NS_ARRAY_CONTRACTID);

    if (!mExpressions)
      return NS_ERROR_OUT_OF_MEMORY;
  }

  NS_ADDREF(*aExpressions = mExpressions);
  return NS_OK;
}

NS_IMETHODIMP nsAbBooleanExpression::SetExpressions(nsIArray *aExpressions)
{
  if (!aExpressions)
    return NS_ERROR_NULL_POINTER;

  mExpressions = aExpressions;

  return NS_OK;
}