sbLocalDatabaseSchemaInfo.h
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 #ifndef __SBLOCALDATABASESCHEMAINFO_H__
28 #define __SBLOCALDATABASESCHEMAINFO_H__
29 
30 #include <nsComponentManagerUtils.h>
31 
32 #include <sbISQLBuilder.h>
33 #include <sbIDatabaseQuery.h>
34 #include <sbIDatabaseResult.h>
35 #include <sbStandardProperties.h>
36 #include <sbSQLBuilderCID.h>
37 #include <sbILocalDatabasePropertyCache.h>
38 
39 #define MAX_IN_LENGTH 5000
40 
42  const char* mPropertyID;
43  const char* mColumn;
44  PRUint32 mColumnType;
45  PRUint32 mDBID;
46 };
47 const PRUint32 SB_COLUMN_TYPE_TEXT = 0;
48 const PRUint32 SB_COLUMN_TYPE_INTEGER = 1;
49 
50 // Top-level media item properties should not be registered using
51 // sbITextPropertyInfo, as the media_items table does not contain
52 // obj_searchable and obj_sortable columns with the transformed
53 // strings expected when searching for and sorting on entries in
54 // the resource_properties table.
56  {
58  "guid",
61  },
62  {
64  "created",
66  PR_UINT32_MAX - 1,
67  },
68  {
70  "updated",
72  PR_UINT32_MAX - 2,
73  },
74  {
76  "content_url",
78  PR_UINT32_MAX - 3,
79  },
80  {
82  "content_mime_type",
84  PR_UINT32_MAX - 4,
85  },
86  {
88  "content_length",
90  PR_UINT32_MAX - 5,
91  },
92  {
94  "hidden",
96  PR_UINT32_MAX - 6,
97  },
98  {
100  "media_list_type_id",
102  PR_UINT32_MAX - 7,
103  },
104  {
106  "content_hash",
108  PR_UINT32_MAX - 8,
109  },
110  {
112  "is_list",
114  PR_UINT32_MAX - 9,
115  },
116  {
118  "metadata_hash_identity",
120  PR_UINT32_MAX - 10,
121  },
122 };
123 
124 static const PRUint32 sStaticPropertyCount = 11;
125 
126 static inline PRBool
127 SB_IsTopLevelProperty(PRUint32 aPropertyDBID)
128 {
129  for(PRUint32 i = 0; i < sStaticPropertyCount; i++) {
130  if(sStaticProperties[i].mDBID == aPropertyDBID)
131  return PR_TRUE;
132  }
133  return PR_FALSE;
134 }
135 
136 static inline PRBool
137 SB_IsTopLevelProperty(const nsAString& aProperty)
138 {
139  for(PRUint32 i = 0; i < sStaticPropertyCount; i++) {
140  if(aProperty.EqualsLiteral(sStaticProperties[i].mPropertyID))
141  return PR_TRUE;
142  }
143  return PR_FALSE;
144 }
145 
146 static inline nsresult
147 SB_GetTopLevelPropertyColumn(const nsAString& aProperty,
148  nsAString& aColumnName)
149 {
150  for(PRUint32 i = 0; i < sStaticPropertyCount; i++) {
151  if(aProperty.EqualsLiteral(sStaticProperties[i].mPropertyID)) {
152  aColumnName.AssignLiteral(sStaticProperties[i].mColumn);
153  return NS_OK;
154  }
155  }
156  return NS_ERROR_NOT_AVAILABLE;
157 }
158 
159 static inline nsresult
160 SB_GetTopLevelPropertyColumnType(const nsAString& aProperty,
161  PRUint32 &aColumnType)
162 {
163  for(PRUint32 i = 0; i < sStaticPropertyCount; i++) {
164  if(aProperty.EqualsLiteral(sStaticProperties[i].mPropertyID)) {
165  aColumnType = sStaticProperties[i].mColumnType;
166  return NS_OK;
167  }
168  }
169  return NS_ERROR_NOT_AVAILABLE;
170 }
171 
172 static inline nsresult
173 SB_GetTopLevelPropertyColumnType(const PRUint32 aPropertyDBID,
174  PRUint32 &aColumnType)
175 {
176  for(PRUint32 i = 0; i < sStaticPropertyCount; i++) {
177  if(aPropertyDBID == sStaticProperties[i].mDBID) {
178  aColumnType = sStaticProperties[i].mColumnType;
179  return NS_OK;
180  }
181  }
182  return NS_ERROR_NOT_AVAILABLE;
183 }
184 
185 static inline nsresult
186 SB_GetTopLevelPropertyColumn(const PRUint32 aPropertyDBID,
187  nsAString& aColumnName)
188 {
189  for(PRUint32 i = 0; i < sStaticPropertyCount; i++) {
190  if(aPropertyDBID == sStaticProperties[i].mDBID) {
191  aColumnName.AssignLiteral(sStaticProperties[i].mColumn);
192  return NS_OK;
193  }
194  }
195  return NS_ERROR_NOT_AVAILABLE;
196 }
197 
198 static inline PRInt32
199 SB_GetPropertyId(const nsAString& aProperty,
200  sbILocalDatabasePropertyCache* aPropertyCache)
201 {
202  nsresult rv;
203  PRUint32 id;
204 
205  rv = aPropertyCache->GetPropertyDBID(aProperty, &id);
206  if (NS_FAILED(rv)) {
207  return -1;
208  }
209 
210  return id;
211 }
212 
213 #endif // __SBLOCALDATABASESCHEMAINFO_H__
214 
return NS_OK
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
#define SB_PROPERTY_HASH
menuItem id
Definition: FeedWriter.js:971
static const PRUint32 sStaticPropertyCount
#define SB_PROPERTY_HIDDEN
static nsresult SB_GetTopLevelPropertyColumnType(const nsAString &aProperty, PRUint32 &aColumnType)
static nsresult SB_GetTopLevelPropertyColumn(const nsAString &aProperty, nsAString &aColumnName)
static PRBool SB_IsTopLevelProperty(PRUint32 aPropertyDBID)
#define SB_PROPERTY_METADATA_HASH_IDENTITY
#define SB_PROPERTY_CONTENTLENGTH
#define SB_PROPERTY_CREATED
#define SB_PROPERTY_UPDATED
#define SB_PROPERTY_CONTENTTYPE
const PRUint32 SB_COLUMN_TYPE_TEXT
static PRInt32 SB_GetPropertyId(const nsAString &aProperty, sbILocalDatabasePropertyCache *aPropertyCache)
#define SB_PROPERTY_GUID
const PRUint32 SB_COLUMN_TYPE_INTEGER
const PR_UINT32_MAX
Definition: httpd.js:55
#define SB_PROPERTY_LISTTYPE
static sbStaticProperty sStaticProperties[]
#define SB_PROPERTY_ISLIST
#define SB_PROPERTY_CONTENTURL
_getSelectedPageStyle s i