xref: /haiku/src/kits/tracker/TrackerInitialState.cpp (revision 0c93c0a807b27096abbfad677436afb7d1712d4a)
1 /*
2 Open Tracker License
3 
4 Terms and Conditions
5 
6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7 
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
28 
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
32 All rights reserved.
33 */
34 
35 // ToDo:
36 // add code to initialize a subset of the mime database, including
37 // important sniffer rules
38 
39 #include <Directory.h>
40 #include <InterfaceDefs.h>
41 #include <Message.h>
42 #include <Node.h>
43 #include <Path.h>
44 #include <VolumeRoster.h>
45 
46 #include <fs_attr.h>
47 #include <fs_index.h>
48 
49 #include "pr_server.h"
50 
51 #include "Attributes.h"
52 #include "AttributeStream.h"
53 #include "BackgroundImage.h"
54 #include "Bitmaps.h"
55 #include "ContainerWindow.h"
56 #include "MimeTypes.h"
57 #include "FSUtils.h"
58 #include "QueryContainerWindow.h"
59 #include "Tracker.h"
60 
61 enum {
62 	kForceLargeIcon = 0x1,
63 	kForceMiniIcon = 0x2,
64 	kForceShortDescription = 0x4,
65 	kForceLongDescription = 0x8,
66 	kForcePreferredApp = 0x10
67 };
68 
69 
70 const char *kAttrName = "META:name";
71 const char *kAttrCompany = "META:company";
72 const char *kAttrAddress = "META:address";
73 const char *kAttrCity = "META:city";
74 const char *kAttrState = "META:state";
75 const char *kAttrZip = "META:zip";
76 const char *kAttrCountry = "META:country";
77 const char *kAttrHomePhone = "META:hphone";
78 const char *kAttrWorkPhone = "META:wphone";
79 const char *kAttrFax = "META:fax";
80 const char *kAttrEmail = "META:email";
81 const char *kAttrURL = "META:url";
82 const char *kAttrGroup = "META:group";
83 const char *kAttrNickname = "META:nickname";
84 
85 const char *kNetPositiveSignature = "application/x-vnd.Be-NPOS";
86 const char *kPeopleSignature = "application/x-vnd.Be-PEPL";
87 
88 namespace BPrivate {
89 
90 class ExtraAttributeLazyInstaller {
91 public:
92 	ExtraAttributeLazyInstaller(const char *type);
93 	~ExtraAttributeLazyInstaller();
94 
95 	bool AddExtraAttribute(const char *publicName, const char *name,
96 		uint32 type, bool viewable, bool editable, float width,
97 		int32 alignment, bool extra);
98 
99 	status_t InitCheck() const;
100 public:
101 	BMimeType fMimeType;
102 	BMessage fExtraAttrs;
103 	bool fDirty;
104 };
105 
106 }
107 
108 ExtraAttributeLazyInstaller::ExtraAttributeLazyInstaller(const char *type)
109 	:	fMimeType(type),
110 		fDirty(false)
111 {
112 	if (fMimeType.InitCheck() == B_OK)
113 		fMimeType.GetAttrInfo(&fExtraAttrs);
114 }
115 
116 
117 ExtraAttributeLazyInstaller::~ExtraAttributeLazyInstaller()
118 {
119 	if (fMimeType.InitCheck() == B_OK && fDirty)
120 		fMimeType.SetAttrInfo(&fExtraAttrs);
121 }
122 
123 bool
124 ExtraAttributeLazyInstaller::AddExtraAttribute(const char *publicName, const char *name,
125 	uint32 type, bool viewable, bool editable, float width, int32 alignment,
126 	bool extra)
127 {
128 	for (int32 index = 0; ; index++) {
129 		const char *oldPublicName;
130 		if (fExtraAttrs.FindString("attr:public_name", index, &oldPublicName) != B_OK)
131 			break;
132 
133 		if (strcmp(oldPublicName, publicName) == 0)
134 			// already got this extra atribute, no work left
135 			return false;
136 	}
137 
138 	fExtraAttrs.AddString("attr:public_name", publicName);
139 	fExtraAttrs.AddString("attr:name", name);
140 	fExtraAttrs.AddInt32("attr:type", (int32)type);
141 	fExtraAttrs.AddBool("attr:viewable", viewable);
142 	fExtraAttrs.AddBool("attr:editable", editable);
143 	fExtraAttrs.AddInt32("attr:width", (int32)width);
144 	fExtraAttrs.AddInt32("attr:alignment", alignment);
145 	fExtraAttrs.AddBool("attr:extra", extra);
146 
147 	fDirty = true;
148 	return true;
149 }
150 
151 
152 bool
153 TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID,
154 	const char *shortDescription, const char *longDescription,
155 	const char *preferredAppSignature, uint32 forceMask)
156 {
157 	// used by InitMimeTypes - checks if a metamime of a given <type> is
158 	// installed and if it has all the specified attributes; if not, the
159 	// whole mime type is installed and all attributes are set; nulls can
160 	// be passed for attributes that don't matter; returns true if anything
161 	// had to be changed
162 
163 #ifndef __HAIKU__
164 # define B_BITMAP_NO_SERVER_LINK 0
165 #endif
166 
167 #ifdef __HAIKU__
168 	BBitmap vectorIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_RGB32);
169 #endif
170 	BBitmap largeIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_CMAP8);
171 	BBitmap miniIcon(BRect(0, 0, 15, 15), B_BITMAP_NO_SERVER_LINK, B_CMAP8);
172 	char tmp[B_MIME_TYPE_LENGTH];
173 
174 	BMimeType mime(type);
175 	bool installed = mime.IsInstalled();
176 
177 	if (!installed
178 #ifdef __HAIKU__
179 		|| (bitsID >= 0 && ((forceMask & kForceLargeIcon)
180 			|| mime.GetIcon(&vectorIcon, B_LARGE_ICON) != B_OK))
181 #endif
182 		|| (bitsID >= 0 && ((forceMask & kForceLargeIcon)
183 			|| mime.GetIcon(&largeIcon, B_LARGE_ICON) != B_OK))
184 		|| (bitsID >= 0 && ((forceMask & kForceMiniIcon)
185 			|| mime.GetIcon(&miniIcon, B_MINI_ICON) != B_OK))
186 		|| (shortDescription && ((forceMask & kForceShortDescription)
187 			|| mime.GetShortDescription(tmp) != B_OK))
188 		|| (longDescription && ((forceMask & kForceLongDescription)
189 			|| mime.GetLongDescription(tmp) != B_OK))
190 		|| (preferredAppSignature && ((forceMask & kForcePreferredApp)
191 			|| mime.GetPreferredApp(tmp) != B_OK))) {
192 
193 		if (!installed)
194 			mime.Install();
195 
196 		if (bitsID >= 0) {
197 #ifdef __HAIKU__
198 			const uint8* iconData;
199 			size_t iconSize;
200 			if (GetTrackerResources()->
201 					GetIconResource(bitsID, &iconData, &iconSize) == B_OK)
202 				mime.SetIcon(iconData, iconSize);
203 #endif
204 
205 			if (GetTrackerResources()->
206 					GetIconResource(bitsID, B_LARGE_ICON, &largeIcon) == B_OK)
207 				mime.SetIcon(&largeIcon, B_LARGE_ICON);
208 
209 			if (GetTrackerResources()->
210 					GetIconResource(bitsID, B_MINI_ICON, &miniIcon) == B_OK)
211 				mime.SetIcon(&miniIcon, B_MINI_ICON);
212 		}
213 
214 		if (shortDescription)
215 			mime.SetShortDescription(shortDescription);
216 
217 		if (longDescription)
218 			mime.SetLongDescription(longDescription);
219 
220 		if (preferredAppSignature)
221 			mime.SetPreferredApp(preferredAppSignature);
222 
223 		return true;
224 	}
225 	return false;
226 }
227 
228 void
229 TTracker::InitMimeTypes()
230 {
231 	InstallMimeIfNeeded(B_DIR_MIMETYPE, kResFolderIcon,
232 		"Folder", "Folder container for file system items.", kTrackerSignature);
233 
234 	InstallMimeIfNeeded(B_APP_MIME_TYPE, kResAppIcon,
235 		"Be Application", "Generic Be Application executable.", kTrackerSignature);
236 
237 	InstallMimeIfNeeded(B_FILE_MIMETYPE, kResFileIcon,
238 		"Generic file", "Generic document file.", kTrackerSignature);
239 
240 	InstallMimeIfNeeded(B_VOLUME_MIMETYPE, kResHardDiskIcon,
241 		"Be Volume", "Disk volume.", kTrackerSignature);
242 
243 	InstallMimeIfNeeded(B_QUERY_MIMETYPE, kResQueryIcon,
244 		"Be Query", "Query to locate items on disks.", kTrackerSignature);
245 
246 	InstallMimeIfNeeded(B_QUERY_TEMPLATE_MIMETYPE, kResQueryTemplateIcon,
247 		"Be Query Template", "", kTrackerSignature);
248 
249 	InstallMimeIfNeeded(B_LINK_MIMETYPE, kResBrokenLinkIcon,
250 		"Symbolic Link", "Link to another item in the file system.", kTrackerSignature);
251 
252 	InstallMimeIfNeeded(B_ROOT_MIMETYPE, kResBeBoxIcon,
253 		"Be Root", "File system root.", kTrackerSignature);
254 
255 	InstallMimeIfNeeded(B_BOOKMARK_MIMETYPE, kResBookmarkIcon,
256 		"Bookmark", "Bookmark for a web page.", kNetPositiveSignature);
257 
258 	{
259 		// install a couple of extra fields for bookmark
260 
261 		ExtraAttributeLazyInstaller installer(B_BOOKMARK_MIMETYPE);
262 		installer.AddExtraAttribute("URL", "META:url", B_STRING_TYPE, true, true,
263 			170, B_ALIGN_LEFT, false);
264 		installer.AddExtraAttribute("Keywords", "META:keyw", B_STRING_TYPE, true, true,
265 			130, B_ALIGN_LEFT, false);
266 		installer.AddExtraAttribute("Title", "META:title", B_STRING_TYPE, true, true,
267 			130, B_ALIGN_LEFT, false);
268 	}
269 
270 	InstallMimeIfNeeded(B_PERSON_MIMETYPE, kResPersonIcon,
271 		"Person", "Contact information for a person.", kPeopleSignature);
272 
273 	{
274 		ExtraAttributeLazyInstaller installer(B_PERSON_MIMETYPE);
275 		installer.AddExtraAttribute("Contact Name", kAttrName, B_STRING_TYPE, true, true,
276 			120, B_ALIGN_LEFT, false);
277 		installer.AddExtraAttribute("Company", kAttrCompany, B_STRING_TYPE, true, true,
278 			120, B_ALIGN_LEFT, false);
279 		installer.AddExtraAttribute("Address", kAttrAddress, B_STRING_TYPE, true, true,
280 			120, B_ALIGN_LEFT, false);
281 		installer.AddExtraAttribute("City", kAttrCity, B_STRING_TYPE, true, true,
282 			90, B_ALIGN_LEFT, false);
283 		installer.AddExtraAttribute("State", kAttrState, B_STRING_TYPE, true, true,
284 			50, B_ALIGN_LEFT, false);
285 		installer.AddExtraAttribute("Zip", kAttrZip, B_STRING_TYPE, true, true,
286 			50, B_ALIGN_LEFT, false);
287 		installer.AddExtraAttribute("Country", kAttrCountry, B_STRING_TYPE, true, true,
288 			120, B_ALIGN_LEFT, false);
289 		installer.AddExtraAttribute("E-mail", kAttrEmail, B_STRING_TYPE, true, true,
290 			120, B_ALIGN_LEFT, false);
291 		installer.AddExtraAttribute("Home Phone", kAttrHomePhone, B_STRING_TYPE, true, true,
292 			90, B_ALIGN_LEFT, false);
293 		installer.AddExtraAttribute("Work Phone", kAttrWorkPhone, B_STRING_TYPE, true, true,
294 			90, B_ALIGN_LEFT, false);
295 		installer.AddExtraAttribute("Fax", kAttrFax, B_STRING_TYPE, true, true,
296 			90, B_ALIGN_LEFT, false);
297 		installer.AddExtraAttribute("URL", kAttrURL, B_STRING_TYPE, true, true,
298 			120, B_ALIGN_LEFT, false);
299 		installer.AddExtraAttribute("Group", kAttrGroup, B_STRING_TYPE, true, true,
300 			120, B_ALIGN_LEFT, false);
301 		installer.AddExtraAttribute("Nickname", kAttrNickname, B_STRING_TYPE, true, true,
302 			120, B_ALIGN_LEFT, false);
303 	}
304 
305 	InstallMimeIfNeeded(B_PRINTER_SPOOL_MIMETYPE, kResSpoolFileIcon,
306 		"Printer spool", "Printer spool file.", "application/x-vnd.Be-PRNT");
307 
308 	{
309 #if B_BEOS_VERSION_DANO
310 		ExtraAttributeLazyInstaller installer(B_PRINTER_SPOOL_MIMETYPE);
311 		installer.AddExtraAttribute("Status", PSRV_SPOOL_ATTR_STATUS, B_STRING_TYPE, true, false,
312 			60, B_ALIGN_LEFT, false);
313 		installer.AddExtraAttribute("Page Count", PSRV_SPOOL_ATTR_PAGECOUNT, B_INT32_TYPE, true, false,
314 			40, B_ALIGN_RIGHT, false);
315 		installer.AddExtraAttribute("Description", PSRV_SPOOL_ATTR_DESCRIPTION, B_STRING_TYPE, true, true,
316 			100, B_ALIGN_LEFT, false);
317 		installer.AddExtraAttribute("Printer Name", PSRV_SPOOL_ATTR_PRINTER, B_STRING_TYPE, true, false,
318 			80, B_ALIGN_LEFT, false);
319 		installer.AddExtraAttribute("Job creator type", PSRV_SPOOL_ATTR_MIMETYPE, B_ASCII_TYPE, true, false,
320 			60, B_ALIGN_LEFT, false);
321 #else
322 		ExtraAttributeLazyInstaller installer(B_PRINTER_SPOOL_MIMETYPE);
323 		installer.AddExtraAttribute("Page Count", "_spool/Page Count", B_INT32_TYPE, true, false,
324 			40, B_ALIGN_RIGHT, false);
325 		installer.AddExtraAttribute("Description", "_spool/Description", B_ASCII_TYPE, true, true,
326 			100, B_ALIGN_LEFT, false);
327 		installer.AddExtraAttribute("Printer Name", "_spool/Printer", B_ASCII_TYPE, true, false,
328 			80, B_ALIGN_LEFT, false);
329 		installer.AddExtraAttribute("Job creator type", "_spool/MimeType", B_ASCII_TYPE, true, false,
330 			60, B_ALIGN_LEFT, false);
331 #endif
332 	}
333 
334 	InstallMimeIfNeeded(B_PRINTER_MIMETYPE, kResGenericPrinterIcon,
335 		"Printer", "Printer queue.", kTrackerSignature /*application/x-vnd.Be-PRNT*/);
336 		// for now set tracker as a default handler for the printer because we
337 		// just want to open it as a folder
338 #if B_BEOS_VERSION_DANO
339 	{
340 		ExtraAttributeLazyInstaller installer(B_PRINTER_MIMETYPE);
341 		installer.AddExtraAttribute("Driver", PSRV_PRINTER_ATTR_DRV_NAME, B_STRING_TYPE, true, false,
342 			120, B_ALIGN_LEFT, false);
343 		installer.AddExtraAttribute("Transport", PSRV_PRINTER_ATTR_TRANSPORT, B_STRING_TYPE, true, false,
344 			60, B_ALIGN_RIGHT, false);
345 		installer.AddExtraAttribute("Connection", PSRV_PRINTER_ATTR_CNX, B_STRING_TYPE, true, false,
346 			40, B_ALIGN_LEFT, false);
347 		installer.AddExtraAttribute("Description", PSRV_PRINTER_ATTR_COMMENTS, B_STRING_TYPE, true, true,
348 			140, B_ALIGN_LEFT, false);
349 	}
350 #endif
351 }
352 
353 void
354 TTracker::InstallIndices()
355 {
356 	BVolumeRoster roster;
357 	BVolume volume;
358 
359 	roster.Rewind();
360 	while (roster.GetNextVolume(&volume) == B_OK) {
361 		if (volume.IsReadOnly() || !volume.IsPersistent()
362 			|| !volume.KnowsAttr() || !volume.KnowsQuery())
363 			continue;
364 		InstallIndices(volume.Device());
365 	}
366 }
367 
368 void
369 TTracker::InstallIndices(dev_t device)
370 {
371 	status_t error = fs_create_index(device, kAttrQueryLastChange, B_INT32_TYPE, 0);
372 	error = fs_create_index(device, "_trk/recentQuery", B_INT32_TYPE, 0);
373 }
374 
375 const int32 kDefaultQueryTemplateCount = 3;
376 extern const AttributeTemplate kDefaultQueryTemplate[];
377 extern const AttributeTemplate kBookmarkQueryTemplate[];
378 extern const AttributeTemplate kPersonQueryTemplate[];
379 extern const AttributeTemplate kEmailQueryTemplate[];
380 
381 void
382 TTracker::InstallDefaultTemplates()
383 {
384 	BNode node;
385 	BString query(kQueryTemplates);
386 	query += "/application_octet-stream";
387 
388 	if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false))
389 		if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) {
390 			AttributeStreamFileNode fileNode(&node);
391 			AttributeStreamTemplateNode tmp(kDefaultQueryTemplate, 3);
392 			fileNode << tmp;
393 		}
394 
395 	(query = kQueryTemplates) += "/application_x-vnd.Be-bookmark";
396 	if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false))
397 		if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) {
398 			AttributeStreamFileNode fileNode(&node);
399 			AttributeStreamTemplateNode tmp(kBookmarkQueryTemplate, 3);
400 			fileNode << tmp;
401 		}
402 
403 	(query = kQueryTemplates) += "/application_x-person";
404 	if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false))
405 		if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) {
406 			AttributeStreamFileNode fileNode(&node);
407 			AttributeStreamTemplateNode tmp(kPersonQueryTemplate, 3);
408 			fileNode << tmp;
409 		}
410 
411 	(query = kQueryTemplates) += "/text_x-email";
412 	if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false))
413 		if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) {
414 			AttributeStreamFileNode fileNode(&node);
415 			AttributeStreamTemplateNode tmp(kEmailQueryTemplate, 3);
416 			fileNode << tmp;
417 		}
418 }
419 
420 static void
421 InstallTemporaryBackgroundImages(BNode *node, BMessage *message)
422 {
423 	int32 size = message->FlattenedSize();
424 	char *buffer = new char [size];
425 	message->Flatten(buffer, size);
426 	node->WriteAttr(kBackgroundImageInfo, B_MESSAGE_TYPE, 0, buffer, (size_t)size);
427 	delete [] buffer;
428 }
429 
430 static void
431 AddTemporaryBackgroundImages(BMessage *message, const char *imagePath,
432 	BackgroundImage::Mode mode, BPoint offset, uint32 workspaces, bool eraseTextWidgets)
433 {
434 	message->AddString(kBackgroundImageInfoPath, imagePath);
435 	message->AddInt32(kBackgroundImageInfoWorkspaces, (int32)workspaces);
436 	message->AddInt32(kBackgroundImageInfoMode, mode);
437 	message->AddBool(kBackgroundImageInfoEraseText, eraseTextWidgets);
438 	message->AddPoint(kBackgroundImageInfoOffset, offset);
439 }
440 
441 static void
442 InstallTemporaryBackgroundImagesIfNeeded(BNode *node, const char *imagePath,
443 	BackgroundImage::Mode mode, BPoint offset, uint32 workspaces, bool eraseTextWidgets)
444 {
445 	attr_info info;
446 	if (node->GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) {
447 		BMessage message;
448 		AddTemporaryBackgroundImages(&message, imagePath, mode, offset, workspaces,
449 			eraseTextWidgets);
450 		InstallTemporaryBackgroundImages(node, &message);
451 	}
452 }
453 
454 void
455 TTracker::InstallTemporaryBackgroundImages()
456 {
457 	// TODO: make the large Haiku Logo the default background
458 
459 	BPath path;
460 	FSFindTrackerSettingsDir(&path, false);
461 	BString defaultFolderPath(path.Path());
462 	defaultFolderPath << '/' << kDefaultFolderTemplate << '/';
463 
464 	BNode node;
465 	if (BContainerWindow::DefaultStateSourceNode(kDefaultFolderTemplate, &node, true))
466 		InstallTemporaryBackgroundImagesIfNeeded(&node,
467 			(BString(defaultFolderPath) << "backgroundTexture.tga").String(),
468 			BackgroundImage::kTiled,
469 			BPoint(0, 0), 0xffffffff, false);
470 
471 	BDirectory dir;
472 	if (FSGetBootDeskDir(&dir) == B_OK) {
473 		attr_info info;
474 		if (dir.GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) {
475 
476 			BMessage message;
477 			AddTemporaryBackgroundImages(&message,
478 				(BString(defaultFolderPath) << "bgdefault.tga").String(),
479 				BackgroundImage::kScaledToFit,
480 				BPoint(0, 0), 0xffffffff, true);
481 			AddTemporaryBackgroundImages(&message,
482 				(BString(defaultFolderPath) << "bg1.tga").String(),
483 				BackgroundImage::kScaledToFit,
484 				BPoint(0, 0), 0x00000001, true);
485 			AddTemporaryBackgroundImages(&message,
486 				(BString(defaultFolderPath) << "bg2.tga").String(),
487 				BackgroundImage::kScaledToFit,
488 				BPoint(0, 0), 0x00000002, true);
489 			AddTemporaryBackgroundImages(&message,
490 				(BString(defaultFolderPath) << "bg3.tga").String(),
491 				BackgroundImage::kScaledToFit,
492 				BPoint(0, 0), 0x00000004, true);
493 			AddTemporaryBackgroundImages(&message,
494 				(BString(defaultFolderPath) << "bg4.tga").String(),
495 				BackgroundImage::kScaledToFit,
496 				BPoint(0, 0), 0x00000008, true);
497 			AddTemporaryBackgroundImages(&message,
498 				(BString(defaultFolderPath) << "bg5.tga").String(),
499 				BackgroundImage::kScaledToFit,
500 				BPoint(0, 0), 0x00000010, true);
501 			AddTemporaryBackgroundImages(&message,
502 				(BString(defaultFolderPath) << "bg6.tga").String(),
503 				BackgroundImage::kScaledToFit,
504 				BPoint(0, 0), 0x00000020, true);
505 			AddTemporaryBackgroundImages(&message,
506 				(BString(defaultFolderPath) << "bg7.tga").String(),
507 				BackgroundImage::kScaledToFit,
508 				BPoint(0, 0), 0x00000040, true);
509 			AddTemporaryBackgroundImages(&message,
510 				(BString(defaultFolderPath) << "bg8.tga").String(),
511 				BackgroundImage::kScaledToFit,
512 				BPoint(0, 0), 0x00000080, true);
513 			AddTemporaryBackgroundImages(&message,
514 				(BString(defaultFolderPath) << "bg9.tga").String(),
515 				BackgroundImage::kScaledToFit,
516 				BPoint(0, 0), 0x00000100, true);
517 			AddTemporaryBackgroundImages(&message,
518 				(BString(defaultFolderPath) << "bg10.tga").String(),
519 				BackgroundImage::kScaledToFit,
520 				BPoint(0, 0), 0x00000200, true);
521 			AddTemporaryBackgroundImages(&message,
522 				(BString(defaultFolderPath) << "bg11.tga").String(),
523 				BackgroundImage::kScaledToFit,
524 				BPoint(0, 0), 0x00000400, true);
525 			AddTemporaryBackgroundImages(&message,
526 				(BString(defaultFolderPath) << "bg12.tga").String(),
527 				BackgroundImage::kScaledToFit,
528 				BPoint(0, 0), 0x00000800, true);
529 			AddTemporaryBackgroundImages(&message,
530 				(BString(defaultFolderPath) << "bg12.tga").String(),
531 				BackgroundImage::kScaledToFit,
532 				BPoint(0, 0), 0x00001000, true);
533 			AddTemporaryBackgroundImages(&message,
534 				(BString(defaultFolderPath) << "bg13.tga").String(),
535 				BackgroundImage::kScaledToFit,
536 				BPoint(0, 0), 0x00002000, true);
537 			AddTemporaryBackgroundImages(&message,
538 				(BString(defaultFolderPath) << "bg14.tga").String(),
539 				BackgroundImage::kScaledToFit,
540 				BPoint(0, 0), 0x00002000, true);
541 			AddTemporaryBackgroundImages(&message,
542 				(BString(defaultFolderPath) << "bg15.tga").String(),
543 				BackgroundImage::kScaledToFit,
544 				BPoint(0, 0), 0x00004000, true);
545 			AddTemporaryBackgroundImages(&message,
546 				(BString(defaultFolderPath) << "bg16.tga").String(),
547 				BackgroundImage::kScaledToFit,
548 				BPoint(0, 0), 0x00008000, true);
549 			::InstallTemporaryBackgroundImages(&dir, &message);
550 		}
551 	}
552 }
553 
554 
555 // the following templates are in big endian and we rely on the Tracker
556 // translation support to swap them on little endian machines
557 //
558 // in case there is an attribute (B_RECT_TYPE) that gets swapped by the media (unzip,
559 // file system endianness swapping, etc., the correct endianness for the
560 // correct machine has to be used here
561 
562 const BRect kDefaultFrame(40, 40, 500, 350);
563 
564 const AttributeTemplate kDefaultQueryTemplate[] =
565 	/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_octet-stream */
566 {
567 	{		 /* default frame */
568 		kAttrWindowFrame,
569 		B_RECT_TYPE,
570 		16,
571 		(const char *)&kDefaultFrame
572 	},
573 	{		 /* attr: _trk/viewstate */
574 		kAttrViewState_be,
575 		B_RAW_TYPE,
576 		49,
577 		"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
578 		"\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000\000"
579 		"\000\000\000\000\000\000"
580 	},
581 	{		 /* attr: _trk/columns */
582 		kAttrColumns_be,
583 		B_RAW_TYPE,
584 		223,
585 		"O\362VR\000\000\000\025\000\000\000\004Name\000B \000\000C\021\000"
586 		"\000\000\000\000\000\000\000\000\012_stat/name\000\357\323\335RCST"
587 		"R\001\001O\362VR\000\000\000\025\000\000\000\004Path\000CH\000\000"
588 		"Ca\000\000\000\000\000\000\000\000\000\011_trk/path\000\357_\174RC"
589 		"STR\000\000O\362VR\000\000\000\025\000\000\000\004Size\000C\334\000"
590 		"\000B$\000\000\000\000\000\001\000\000\000\012_stat/size\000\317\317"
591 		"\306TOFFT\001\000O\362VR\000\000\000\025\000\000\000\010Modified\000"
592 		"C\370\000\000C\012\000\000\000\000\000\000\000\000\000\016_stat/mo"
593 		"dified\000]KmETIME\001\000"
594 	}
595 };
596 
597 const AttributeTemplate kBookmarkQueryTemplate[] =
598 	/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_x-vnd.Be-bookmark */
599 {
600 	{		 /* default frame */
601 		kAttrWindowFrame,
602 		B_RECT_TYPE,
603 		16,
604 		(const char *)&kDefaultFrame
605 	},
606 	{		 /* attr: _trk/viewstate */
607 		kAttrViewState_be,
608 		B_RAW_TYPE,
609 		49,
610 		"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
611 		"\000\000\000\000\000\000\000\000\000\000w\373\175RCSTR\000\000\000"
612 		"\000\000\000\000\000\000"
613 	},
614 	{		 /* attr: _trk/columns */
615 		kAttrColumns_be,
616 		B_RAW_TYPE,
617 		163,
618 		"O\362VR\000\000\000\025\000\000\000\005Title\000B \000\000C+\000\000"
619 		"\000\000\000\000\000\000\000\012META:title\000w\373\175RCSTR\000\001"
620 		"O\362VR\000\000\000\025\000\000\000\003URL\000Cb\000\000C\217\200\000"
621 		"\000\000\000\000\000\000\000\010META:url\000\343[TRCSTR\000\001O\362"
622 		"VR\000\000\000\025\000\000\000\010Keywords\000D\004\000\000C\002\000"
623 		"\000\000\000\000\000\000\000\000\011META:keyw\000\333\363\334RCSTR"
624 		"\000\001"
625 	}
626 };
627 
628 const AttributeTemplate kPersonQueryTemplate[] =
629 	/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_x-vnd.Be-bookmark */
630 {
631 	{		 /* default frame */
632 		kAttrWindowFrame,
633 		B_RECT_TYPE,
634 		16,
635 		(const char *)&kDefaultFrame
636 	},
637 	{		 /* attr: _trk/viewstate */
638 		kAttrViewState_be,
639 		B_RAW_TYPE,
640 		49,
641 		"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
642 		"\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000\000"
643 		"\000\000\000\000\000\000"
644 	},
645 	{		 /* attr: _trk/columns */
646 		kAttrColumns_be,
647 		B_RAW_TYPE,
648 		230,
649 		"O\362VR\000\000\000\025\000\000\000\004Name\000B \000\000B\346\000"
650 		"\000\000\000\000\000\000\000\000\012_stat/name\000\357\323\335RCST"
651 		"R\001\001O\362VR\000\000\000\025\000\000\000\012Work Phone\000C*\000"
652 		"\000B\264\000\000\000\000\000\000\000\000\000\013META:wphone\000C_"
653 		"uRCSTR\000\001O\362VR\000\000\000\025\000\000\000\006E-mail\000C\211"
654 		"\200\000B\272\000\000\000\000\000\000\000\000\000\012META:email\000"
655 		"sW\337RCSTR\000\001O\362VR\000\000\000\025\000\000\000\007Company\000"
656 		"C\277\200\000B\360\000\000\000\000\000\000\000\000\000\014META:com"
657 		"pany\000CS\174RCSTR\000\001"
658 	},
659 };
660 
661 const AttributeTemplate kEmailQueryTemplate[] =
662 	/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/text_x-email */
663 {
664 	{		 /* default frame */
665 		kAttrWindowFrame,
666 		B_RECT_TYPE,
667 		16,
668 		(const char *)&kDefaultFrame
669 	},
670 	{		 /* attr: _trk/viewstate */
671 		kAttrViewState_be,
672 		B_RAW_TYPE,
673 		49,
674 		"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
675 		"\000\000\000\000\000\000\000\000\000\000\366_\377ETIME\000\000\000"
676 		"\000\000\000\000\000\000"
677 	},
678 	{		 /* attr: _trk/columns */
679 		kAttrColumns_be,
680 		B_RAW_TYPE,
681 		222,
682 		"O\362VR\000\000\000\025\000\000\000\007Subject\000B \000\000B\334\000"
683 		"\000\000\000\000\000\000\000\000\014MAIL:subject\000\343\173\337RC"
684 		"STR\000\000O\362VR\000\000\000\025\000\000\000\004From\000C%\000\000"
685 		"C\031\000\000\000\000\000\000\000\000\000\011MAIL:from\000\317s_RC"
686 		"STR\000\000O\362VR\000\000\000\025\000\000\000\004When\000C\246\200"
687 		"\000B\360\000\000\000\000\000\000\000\000\000\011MAIL:when\000\366"
688 		"_\377ETIME\000\000O\362VR\000\000\000\025\000\000\000\006Status\000"
689 		"C\352\000\000BH\000\000\000\000\000\001\000\000\000\013MAIL:status"
690 		"\000G\363\134RCSTR\000\001"
691 	},
692 };
693 
694