This file is indexed.

/usr/include/thunderbird-11.0.1/nsMsgSearchAdapter.h is in thunderbird-dev 11.0.1+build1-0ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is mozilla.org code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 1999
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#ifndef _nsMsgSearchAdapter_H_
#define _nsMsgSearchAdapter_H_

#include "nsMsgSearchCore.h"

#include "nsIMsgSearchAdapter.h"
#include "nsIMsgSearchValidityTable.h"
#include "nsIMsgSearchValidityManager.h"
#include "nsIMsgSearchTerm.h"
#include "nsINntpIncomingServer.h"

class nsIMsgSearchScopeTerm;

//-----------------------------------------------------------------------------
// These Adapter classes contain the smarts to convert search criteria from
// the canonical structures in msg_srch.h into whatever format is required
// by their protocol.
//
// There is a separate Adapter class for area (pop, imap, nntp, ldap) to contain
// the special smarts for that protocol.
//-----------------------------------------------------------------------------

class nsMsgSearchAdapter : public nsIMsgSearchAdapter
{
public:
  nsMsgSearchAdapter (nsIMsgSearchScopeTerm*, nsISupportsArray *);
  virtual ~nsMsgSearchAdapter ();

  NS_DECL_ISUPPORTS
  NS_DECL_NSIMSGSEARCHADAPTER

  nsIMsgSearchScopeTerm        *m_scope;
  nsCOMPtr<nsISupportsArray>  m_searchTerms;       /* linked list of criteria terms */

  bool m_abortCalled;
  nsString  m_defaultCharset;
  bool m_forceAsciiSearch;

  static nsresult EncodeImap (char **ppEncoding,
           nsISupportsArray *searchTerms,
           const PRUnichar *srcCharset,
           const PRUnichar *destCharset,
           bool reallyDredd = false);

  static nsresult EncodeImapValue(char *encoding, const char *value, bool useQuotes, bool reallyDredd);

  static char *GetImapCharsetParam(const PRUnichar *destCharset);
  static PRUnichar *EscapeSearchUrl (const PRUnichar *nntpCommand);
  static PRUnichar *EscapeImapSearchProtocol(const PRUnichar *imapCommand);
  static PRUnichar *EscapeQuoteImapSearchProtocol(const PRUnichar *imapCommand);
  static char *UnEscapeSearchUrl (const char *commandSpecificData);
  // This stuff lives in the base class because the IMAP search syntax
  // is used by the Dredd SEARCH command as well as IMAP itself
  static const char *m_kImapBefore;
  static const char *m_kImapBody;
  static const char *m_kImapCC;
  static const char *m_kImapFrom;
  static const char *m_kImapNot;
  static const char *m_kImapOr;
  static const char *m_kImapSince;
  static const char *m_kImapSubject;
  static const char *m_kImapTo;
  static const char *m_kImapHeader;
  static const char *m_kImapAnyText;
  static const char *m_kImapKeyword;
  static const char *m_kNntpKeywords;
  static const char *m_kImapSentOn;
  static const char *m_kImapSeen;
  static const char *m_kImapAnswered;
  static const char *m_kImapNotSeen;
  static const char *m_kImapNotAnswered;
  static const char *m_kImapCharset;
  static const char *m_kImapUnDeleted;
  static const char *m_kImapSizeSmaller;
  static const char *m_kImapSizeLarger;
  static const char *m_kImapNew;
  static const char *m_kImapNotNew;
  static const char *m_kImapFlagged;
  static const char *m_kImapNotFlagged;
protected:
  typedef enum _msg_TransformType
  {
    kOverwrite,    /* "John Doe" -> "John*Doe",   simple contains   */
    kInsert,       /* "John Doe" -> "John* Doe",  name completion   */
    kSurround      /* "John Doe" -> "John* *Doe", advanced contains */
  } msg_TransformType;

  char *TransformSpacesToStars (const char *, msg_TransformType transformType);
  nsresult OpenNewsResultInUnknownGroup (nsMsgResultElement*);

  static nsresult EncodeImapTerm (nsIMsgSearchTerm *, bool reallyDredd, const PRUnichar *srcCharset, const PRUnichar *destCharset, char **ppOutTerm);
};

//-----------------------------------------------------------------------------
// Validity checking for attrib/op pairs. We need to know what operations are
// legal in three places:
//   1. when the FE brings up the dialog box and needs to know how to build
//      the menus and enable their items
//   2. when the FE fires off a search, we need to check their lists for
//      correctness
//   3. for on-the-fly capability negotion e.g. with XSEARCH-capable news
//      servers
//-----------------------------------------------------------------------------

class nsMsgSearchValidityTable : public nsIMsgSearchValidityTable
{
public:
  nsMsgSearchValidityTable ();
  NS_DECL_NSIMSGSEARCHVALIDITYTABLE
  NS_DECL_ISUPPORTS

protected:
  int m_numAvailAttribs;        // number of rows with at least one available operator
  typedef struct vtBits
  {
    PRUint16 bitEnabled : 1;
    PRUint16 bitAvailable : 1;
    PRUint16 bitValidButNotShown : 1;
  } vtBits;
  vtBits m_table [nsMsgSearchAttrib::kNumMsgSearchAttributes][nsMsgSearchOp::kNumMsgSearchOperators];
private:
  nsMsgSearchAttribValue m_defaultAttrib;
};

// Using getters and setters seems a little nicer then dumping the 2-D array
// syntax all over the code
#define CHECK_AO if (a < 0 || \
                     a >= nsMsgSearchAttrib::kNumMsgSearchAttributes || \
                     o < 0 || \
                     o >= nsMsgSearchOp::kNumMsgSearchOperators) \
                   return NS_ERROR_ILLEGAL_VALUE;
inline nsresult nsMsgSearchValidityTable::SetAvailable (int a, int o, bool b)
{ CHECK_AO; m_table [a][o].bitAvailable = b; return NS_OK;}
inline nsresult nsMsgSearchValidityTable::SetEnabled (int a, int o, bool b)
{ CHECK_AO; m_table [a][o].bitEnabled = b; return NS_OK; }
inline nsresult nsMsgSearchValidityTable::SetValidButNotShown (int a, int o, bool b)
{ CHECK_AO; m_table [a][o].bitValidButNotShown = b; return NS_OK;}

inline nsresult nsMsgSearchValidityTable::GetAvailable (int a, int o, bool *aResult)
{ CHECK_AO; *aResult = m_table [a][o].bitAvailable; return NS_OK;}
inline nsresult nsMsgSearchValidityTable::GetEnabled (int a, int o, bool *aResult)
{ CHECK_AO; *aResult = m_table [a][o].bitEnabled; return NS_OK;}
inline nsresult nsMsgSearchValidityTable::GetValidButNotShown (int a, int o, bool *aResult)
{ CHECK_AO; *aResult = m_table [a][o].bitValidButNotShown; return NS_OK;}
#undef CHECK_AO

class nsMsgSearchValidityManager : public nsIMsgSearchValidityManager
{
public:
  nsMsgSearchValidityManager ();

protected:
  virtual ~nsMsgSearchValidityManager ();

public:
  NS_DECL_NSIMSGSEARCHVALIDITYMANAGER
  NS_DECL_ISUPPORTS

  nsresult GetTable (int, nsMsgSearchValidityTable**);

protected:

  // There's one global validity manager that everyone uses. You *could* do
  // this with static members of the adapter classes, but having a dedicated
  // object makes cleanup of these tables (at shutdown-time) automagic.

  nsCOMPtr<nsIMsgSearchValidityTable> m_offlineMailTable;
  nsCOMPtr<nsIMsgSearchValidityTable> m_offlineMailFilterTable;
  nsCOMPtr<nsIMsgSearchValidityTable> m_onlineMailTable;
  nsCOMPtr<nsIMsgSearchValidityTable> m_onlineMailFilterTable;
  nsCOMPtr<nsIMsgSearchValidityTable> m_onlineManualFilterTable;

  nsCOMPtr<nsIMsgSearchValidityTable> m_newsTable;      // online news

  // Local news tables, used for local news searching or offline.
  nsCOMPtr<nsIMsgSearchValidityTable> m_localNewsTable;         // base table
  nsCOMPtr<nsIMsgSearchValidityTable> m_localNewsJunkTable;     // base + junk
  nsCOMPtr<nsIMsgSearchValidityTable> m_localNewsBodyTable;     // base + body
  nsCOMPtr<nsIMsgSearchValidityTable> m_localNewsJunkBodyTable; // base + junk + body
  nsCOMPtr<nsIMsgSearchValidityTable> m_ldapTable;
  nsCOMPtr<nsIMsgSearchValidityTable> m_ldapAndTable;
  nsCOMPtr<nsIMsgSearchValidityTable> m_localABTable;
  nsCOMPtr<nsIMsgSearchValidityTable> m_localABAndTable;
  nsCOMPtr<nsIMsgSearchValidityTable> m_newsFilterTable;

  nsresult NewTable (nsIMsgSearchValidityTable **);

  nsresult InitOfflineMailTable();
  nsresult InitOfflineMailFilterTable();
  nsresult InitOnlineMailTable();
  nsresult InitOnlineMailFilterTable();
  nsresult InitOnlineManualFilterTable();
  nsresult InitNewsTable();
  nsresult InitLocalNewsTable();
  nsresult InitLocalNewsJunkTable();
  nsresult InitLocalNewsBodyTable();
  nsresult InitLocalNewsJunkBodyTable();
  nsresult InitNewsFilterTable();

  //set the custom headers in the table, changes whenever "mailnews.customHeaders" pref changes.
  nsresult SetOtherHeadersInTable(nsIMsgSearchValidityTable *table, const char *customHeaders);

  nsresult InitLdapTable();
  nsresult InitLdapAndTable();
  nsresult InitLocalABTable();
  nsresult InitLocalABAndTable();
  nsresult SetUpABTable(nsIMsgSearchValidityTable *aTable, bool isOrTable);
  nsresult EnableDirectoryAttribute(nsIMsgSearchValidityTable *table, nsMsgSearchAttribValue aSearchAttrib);
};

#endif