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 <Alert.h> 40 #include <Directory.h> 41 #include <InterfaceDefs.h> 42 #include <Message.h> 43 #include <Node.h> 44 #include <Path.h> 45 #include <Screen.h> 46 #include <VolumeRoster.h> 47 48 #include <fs_attr.h> 49 #include <fs_index.h> 50 51 #include "pr_server.h" 52 53 #include "Attributes.h" 54 #include "AttributeStream.h" 55 #include "BackgroundImage.h" 56 #include "Bitmaps.h" 57 #include "ContainerWindow.h" 58 #include "MimeTypes.h" 59 #include "FSUtils.h" 60 #include "QueryContainerWindow.h" 61 #include "Tracker.h" 62 63 enum { 64 kForceLargeIcon = 0x1, 65 kForceMiniIcon = 0x2, 66 kForceShortDescription = 0x4, 67 kForceLongDescription = 0x8, 68 kForcePreferredApp = 0x10 69 }; 70 71 72 const char *kAttrName = "META:name"; 73 const char *kAttrCompany = "META:company"; 74 const char *kAttrAddress = "META:address"; 75 const char *kAttrCity = "META:city"; 76 const char *kAttrState = "META:state"; 77 const char *kAttrZip = "META:zip"; 78 const char *kAttrCountry = "META:country"; 79 const char *kAttrHomePhone = "META:hphone"; 80 const char *kAttrWorkPhone = "META:wphone"; 81 const char *kAttrFax = "META:fax"; 82 const char *kAttrEmail = "META:email"; 83 const char *kAttrURL = "META:url"; 84 const char *kAttrGroup = "META:group"; 85 const char *kAttrNickname = "META:nickname"; 86 87 const char *kNetPositiveSignature = "application/x-vnd.Be-NPOS"; 88 const char *kPeopleSignature = "application/x-vnd.Be-PEPL"; 89 90 // the following templates are in big endian and we rely on the Tracker 91 // translation support to swap them on little endian machines 92 // 93 // in case there is an attribute (B_RECT_TYPE) that gets swapped by the media (unzip, 94 // file system endianness swapping, etc., the correct endianness for the 95 // correct machine has to be used here 96 97 const BRect kDefaultFrame(40, 40, 500, 350); 98 const int32 kDefaultQueryTemplateCount = 3; 99 100 const AttributeTemplate kDefaultQueryTemplate[] = 101 /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_octet-stream */ 102 { 103 { /* default frame */ 104 kAttrWindowFrame, 105 B_RECT_TYPE, 106 16, 107 (const char *)&kDefaultFrame 108 }, 109 { /* attr: _trk/viewstate */ 110 kAttrViewState_be, 111 B_RAW_TYPE, 112 49, 113 "o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000" 114 "\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000\000" 115 "\000\000\000\000\000\000" 116 }, 117 { /* attr: _trk/columns */ 118 kAttrColumns_be, 119 B_RAW_TYPE, 120 223, 121 "O\362VR\000\000\000\025\000\000\000\004Name\000B \000\000C\021\000" 122 "\000\000\000\000\000\000\000\000\012_stat/name\000\357\323\335RCST" 123 "R\001\001O\362VR\000\000\000\025\000\000\000\004Path\000CH\000\000" 124 "Ca\000\000\000\000\000\000\000\000\000\011_trk/path\000\357_\174RC" 125 "STR\000\000O\362VR\000\000\000\025\000\000\000\004Size\000C\334\000" 126 "\000B$\000\000\000\000\000\001\000\000\000\012_stat/size\000\317\317" 127 "\306TOFFT\001\000O\362VR\000\000\000\025\000\000\000\010Modified\000" 128 "C\370\000\000C\012\000\000\000\000\000\000\000\000\000\016_stat/mo" 129 "dified\000]KmETIME\001\000" 130 } 131 }; 132 133 const AttributeTemplate kBookmarkQueryTemplate[] = 134 /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_x-vnd.Be-bookmark */ 135 { 136 { /* default frame */ 137 kAttrWindowFrame, 138 B_RECT_TYPE, 139 16, 140 (const char *)&kDefaultFrame 141 }, 142 { /* attr: _trk/viewstate */ 143 kAttrViewState_be, 144 B_RAW_TYPE, 145 49, 146 "o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000" 147 "\000\000\000\000\000\000\000\000\000\000w\373\175RCSTR\000\000\000" 148 "\000\000\000\000\000\000" 149 }, 150 { /* attr: _trk/columns */ 151 kAttrColumns_be, 152 B_RAW_TYPE, 153 163, 154 "O\362VR\000\000\000\025\000\000\000\005Title\000B \000\000C+\000\000" 155 "\000\000\000\000\000\000\000\012META:title\000w\373\175RCSTR\000\001" 156 "O\362VR\000\000\000\025\000\000\000\003URL\000Cb\000\000C\217\200\000" 157 "\000\000\000\000\000\000\000\010META:url\000\343[TRCSTR\000\001O\362" 158 "VR\000\000\000\025\000\000\000\010Keywords\000D\004\000\000C\002\000" 159 "\000\000\000\000\000\000\000\000\011META:keyw\000\333\363\334RCSTR" 160 "\000\001" 161 } 162 }; 163 164 const AttributeTemplate kPersonQueryTemplate[] = 165 /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_x-vnd.Be-bookmark */ 166 { 167 { /* default frame */ 168 kAttrWindowFrame, 169 B_RECT_TYPE, 170 16, 171 (const char *)&kDefaultFrame 172 }, 173 { /* attr: _trk/viewstate */ 174 kAttrViewState_be, 175 B_RAW_TYPE, 176 49, 177 "o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000" 178 "\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000\000" 179 "\000\000\000\000\000\000" 180 }, 181 { /* attr: _trk/columns */ 182 kAttrColumns_be, 183 B_RAW_TYPE, 184 230, 185 "O\362VR\000\000\000\025\000\000\000\004Name\000B \000\000B\346\000" 186 "\000\000\000\000\000\000\000\000\012_stat/name\000\357\323\335RCST" 187 "R\001\001O\362VR\000\000\000\025\000\000\000\012Work Phone\000C*\000" 188 "\000B\264\000\000\000\000\000\000\000\000\000\013META:wphone\000C_" 189 "uRCSTR\000\001O\362VR\000\000\000\025\000\000\000\006E-mail\000C\211" 190 "\200\000B\272\000\000\000\000\000\000\000\000\000\012META:email\000" 191 "sW\337RCSTR\000\001O\362VR\000\000\000\025\000\000\000\007Company\000" 192 "C\277\200\000B\360\000\000\000\000\000\000\000\000\000\014META:com" 193 "pany\000CS\174RCSTR\000\001" 194 }, 195 }; 196 197 const AttributeTemplate kEmailQueryTemplate[] = 198 /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/text_x-email */ 199 { 200 { /* default frame */ 201 kAttrWindowFrame, 202 B_RECT_TYPE, 203 16, 204 (const char *)&kDefaultFrame 205 }, 206 { /* attr: _trk/viewstate */ 207 kAttrViewState_be, 208 B_RAW_TYPE, 209 49, 210 "o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000" 211 "\000\000\000\000\000\000\000\000\000\000\366_\377ETIME\000\000\000" 212 "\000\000\000\000\000\000" 213 }, 214 { /* attr: _trk/columns */ 215 kAttrColumns_be, 216 B_RAW_TYPE, 217 222, 218 "O\362VR\000\000\000\025\000\000\000\007Subject\000B \000\000B\334\000" 219 "\000\000\000\000\000\000\000\000\014MAIL:subject\000\343\173\337RC" 220 "STR\000\000O\362VR\000\000\000\025\000\000\000\004From\000C%\000\000" 221 "C\031\000\000\000\000\000\000\000\000\000\011MAIL:from\000\317s_RC" 222 "STR\000\000O\362VR\000\000\000\025\000\000\000\004When\000C\246\200" 223 "\000B\360\000\000\000\000\000\000\000\000\000\011MAIL:when\000\366" 224 "_\377ETIME\000\000O\362VR\000\000\000\025\000\000\000\006Status\000" 225 "C\352\000\000BH\000\000\000\000\000\001\000\000\000\013MAIL:status" 226 "\000G\363\134RCSTR\000\001" 227 }, 228 }; 229 230 231 namespace BPrivate { 232 233 class ExtraAttributeLazyInstaller { 234 public: 235 ExtraAttributeLazyInstaller(const char *type); 236 ~ExtraAttributeLazyInstaller(); 237 238 bool AddExtraAttribute(const char *publicName, const char *name, 239 uint32 type, bool viewable, bool editable, float width, 240 int32 alignment, bool extra); 241 242 status_t InitCheck() const; 243 public: 244 BMimeType fMimeType; 245 BMessage fExtraAttrs; 246 bool fDirty; 247 }; 248 249 } // namespace BPrivate 250 251 252 ExtraAttributeLazyInstaller::ExtraAttributeLazyInstaller(const char *type) 253 : 254 fMimeType(type), 255 fDirty(false) 256 { 257 if (fMimeType.InitCheck() == B_OK) 258 fMimeType.GetAttrInfo(&fExtraAttrs); 259 } 260 261 262 ExtraAttributeLazyInstaller::~ExtraAttributeLazyInstaller() 263 { 264 if (fMimeType.InitCheck() == B_OK && fDirty) 265 fMimeType.SetAttrInfo(&fExtraAttrs); 266 } 267 268 269 bool 270 ExtraAttributeLazyInstaller::AddExtraAttribute(const char *publicName, 271 const char *name, uint32 type, bool viewable, bool editable, float width, 272 int32 alignment, bool extra) 273 { 274 for (int32 index = 0; ; index++) { 275 const char *oldPublicName; 276 if (fExtraAttrs.FindString("attr:public_name", index, &oldPublicName) != B_OK) 277 break; 278 279 if (strcmp(oldPublicName, publicName) == 0) 280 // already got this extra atribute, no work left 281 return false; 282 } 283 284 fExtraAttrs.AddString("attr:public_name", publicName); 285 fExtraAttrs.AddString("attr:name", name); 286 fExtraAttrs.AddInt32("attr:type", (int32)type); 287 fExtraAttrs.AddBool("attr:viewable", viewable); 288 fExtraAttrs.AddBool("attr:editable", editable); 289 fExtraAttrs.AddInt32("attr:width", (int32)width); 290 fExtraAttrs.AddInt32("attr:alignment", alignment); 291 fExtraAttrs.AddBool("attr:extra", extra); 292 293 fDirty = true; 294 return true; 295 } 296 297 298 // #pragma mark - 299 300 301 static void 302 InstallTemporaryBackgroundImages(BNode* node, BMessage* message) 303 { 304 int32 size = message->FlattenedSize(); 305 306 try { 307 char* buffer = new char[size]; 308 message->Flatten(buffer, size); 309 node->WriteAttr(kBackgroundImageInfo, B_MESSAGE_TYPE, 0, buffer, 310 (size_t)size); 311 delete[] buffer; 312 } catch (...) { 313 } 314 } 315 316 317 static void 318 AddTemporaryBackgroundImages(BMessage *message, const char *imagePath, 319 BackgroundImage::Mode mode, BPoint offset, uint32 workspaces, 320 bool textWidgetOutlines) 321 { 322 message->AddString(kBackgroundImageInfoPath, imagePath); 323 message->AddInt32(kBackgroundImageInfoWorkspaces, (int32)workspaces); 324 message->AddInt32(kBackgroundImageInfoMode, mode); 325 message->AddBool(kBackgroundImageInfoTextOutline, textWidgetOutlines); 326 message->AddPoint(kBackgroundImageInfoOffset, offset); 327 } 328 329 330 // #pragma mark - 331 332 333 bool 334 TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID, 335 const char *shortDescription, const char *longDescription, 336 const char *preferredAppSignature, uint32 forceMask) 337 { 338 // used by InitMimeTypes - checks if a metamime of a given <type> is 339 // installed and if it has all the specified attributes; if not, the 340 // whole mime type is installed and all attributes are set; nulls can 341 // be passed for attributes that don't matter; returns true if anything 342 // had to be changed 343 344 BBitmap vectorIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_RGBA32); 345 BBitmap largeIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_CMAP8); 346 BBitmap miniIcon(BRect(0, 0, 15, 15), B_BITMAP_NO_SERVER_LINK, B_CMAP8); 347 char tmp[B_MIME_TYPE_LENGTH]; 348 349 BMimeType mime(type); 350 bool installed = mime.IsInstalled(); 351 352 if (!installed 353 || (bitsID >= 0 && ((forceMask & kForceLargeIcon) 354 || mime.GetIcon(&vectorIcon, B_LARGE_ICON) != B_OK)) 355 || (bitsID >= 0 && ((forceMask & kForceLargeIcon) 356 || mime.GetIcon(&largeIcon, B_LARGE_ICON) != B_OK)) 357 || (bitsID >= 0 && ((forceMask & kForceMiniIcon) 358 || mime.GetIcon(&miniIcon, B_MINI_ICON) != B_OK)) 359 || (shortDescription && ((forceMask & kForceShortDescription) 360 || mime.GetShortDescription(tmp) != B_OK)) 361 || (longDescription && ((forceMask & kForceLongDescription) 362 || mime.GetLongDescription(tmp) != B_OK)) 363 || (preferredAppSignature && ((forceMask & kForcePreferredApp) 364 || mime.GetPreferredApp(tmp) != B_OK))) { 365 366 if (!installed) 367 mime.Install(); 368 369 if (bitsID >= 0) { 370 const uint8* iconData; 371 size_t iconSize; 372 if (GetTrackerResources()-> 373 GetIconResource(bitsID, &iconData, &iconSize) == B_OK) 374 mime.SetIcon(iconData, iconSize); 375 376 if (GetTrackerResources()-> 377 GetIconResource(bitsID, B_LARGE_ICON, &largeIcon) == B_OK) 378 mime.SetIcon(&largeIcon, B_LARGE_ICON); 379 380 if (GetTrackerResources()-> 381 GetIconResource(bitsID, B_MINI_ICON, &miniIcon) == B_OK) 382 mime.SetIcon(&miniIcon, B_MINI_ICON); 383 } 384 385 if (shortDescription) 386 mime.SetShortDescription(shortDescription); 387 388 if (longDescription) 389 mime.SetLongDescription(longDescription); 390 391 if (preferredAppSignature) 392 mime.SetPreferredApp(preferredAppSignature); 393 394 return true; 395 } 396 return false; 397 } 398 399 400 void 401 TTracker::InitMimeTypes() 402 { 403 InstallMimeIfNeeded(B_APP_MIME_TYPE, R_AppIcon, "Be Application", 404 "Generic Be application executable.", kTrackerSignature); 405 406 InstallMimeIfNeeded(B_FILE_MIMETYPE, R_FileIcon, 407 "Generic file", "Generic document file.", kTrackerSignature); 408 409 InstallMimeIfNeeded(B_VOLUME_MIMETYPE, R_HardDiskIcon, 410 "Be Volume", "Disk volume.", kTrackerSignature); 411 412 InstallMimeIfNeeded(B_QUERY_MIMETYPE, R_QueryDirIcon, 413 "Be Query", "Query to locate items on disks.", kTrackerSignature); 414 415 InstallMimeIfNeeded(B_QUERY_TEMPLATE_MIMETYPE, R_QueryTemplateIcon, 416 "Be Query template", "", kTrackerSignature); 417 418 InstallMimeIfNeeded(B_LINK_MIMETYPE, R_BrokenLinkIcon, "Symbolic link", 419 "Link to another item in the file system.", kTrackerSignature); 420 421 InstallMimeIfNeeded(B_ROOT_MIMETYPE, R_RootIcon, 422 "Be Root", "File system root.", kTrackerSignature); 423 424 InstallMimeIfNeeded(B_BOOKMARK_MIMETYPE, R_BookmarkIcon, 425 "Bookmark", "Bookmark for a web page.", kNetPositiveSignature); 426 427 { 428 // install a couple of extra fields for bookmark 429 430 ExtraAttributeLazyInstaller installer(B_BOOKMARK_MIMETYPE); 431 installer.AddExtraAttribute("URL", "META:url", B_STRING_TYPE, true, true, 432 170, B_ALIGN_LEFT, false); 433 installer.AddExtraAttribute("Keywords", "META:keyw", B_STRING_TYPE, true, true, 434 130, B_ALIGN_LEFT, false); 435 installer.AddExtraAttribute("Title", "META:title", B_STRING_TYPE, true, true, 436 130, B_ALIGN_LEFT, false); 437 } 438 439 InstallMimeIfNeeded(B_PERSON_MIMETYPE, R_PersonIcon, 440 "Person", "Contact information for a person.", kPeopleSignature); 441 442 { 443 ExtraAttributeLazyInstaller installer(B_PERSON_MIMETYPE); 444 installer.AddExtraAttribute("Contact name", kAttrName, B_STRING_TYPE, true, true, 445 120, B_ALIGN_LEFT, false); 446 installer.AddExtraAttribute("Company", kAttrCompany, B_STRING_TYPE, true, true, 447 120, B_ALIGN_LEFT, false); 448 installer.AddExtraAttribute("Address", kAttrAddress, B_STRING_TYPE, true, true, 449 120, B_ALIGN_LEFT, false); 450 installer.AddExtraAttribute("City", kAttrCity, B_STRING_TYPE, true, true, 451 90, B_ALIGN_LEFT, false); 452 installer.AddExtraAttribute("State", kAttrState, B_STRING_TYPE, true, true, 453 50, B_ALIGN_LEFT, false); 454 installer.AddExtraAttribute("Zip", kAttrZip, B_STRING_TYPE, true, true, 455 50, B_ALIGN_LEFT, false); 456 installer.AddExtraAttribute("Country", kAttrCountry, B_STRING_TYPE, true, true, 457 120, B_ALIGN_LEFT, false); 458 installer.AddExtraAttribute("E-mail", kAttrEmail, B_STRING_TYPE, true, true, 459 120, B_ALIGN_LEFT, false); 460 installer.AddExtraAttribute("Home phone", kAttrHomePhone, B_STRING_TYPE, true, true, 461 90, B_ALIGN_LEFT, false); 462 installer.AddExtraAttribute("Work phone", kAttrWorkPhone, B_STRING_TYPE, true, true, 463 90, B_ALIGN_LEFT, false); 464 installer.AddExtraAttribute("Fax", kAttrFax, B_STRING_TYPE, true, true, 465 90, B_ALIGN_LEFT, false); 466 installer.AddExtraAttribute("URL", kAttrURL, B_STRING_TYPE, true, true, 467 120, B_ALIGN_LEFT, false); 468 installer.AddExtraAttribute("Group", kAttrGroup, B_STRING_TYPE, true, true, 469 120, B_ALIGN_LEFT, false); 470 installer.AddExtraAttribute("Nickname", kAttrNickname, B_STRING_TYPE, true, true, 471 120, B_ALIGN_LEFT, false); 472 } 473 474 InstallMimeIfNeeded(B_PRINTER_SPOOL_MIMETYPE, R_SpoolFileIcon, 475 "Printer spool", "Printer spool file.", "application/x-vnd.Be-PRNT"); 476 477 { 478 #if B_BEOS_VERSION_DANO 479 ExtraAttributeLazyInstaller installer(B_PRINTER_SPOOL_MIMETYPE); 480 installer.AddExtraAttribute("Status", PSRV_SPOOL_ATTR_STATUS, B_STRING_TYPE, true, false, 481 60, B_ALIGN_LEFT, false); 482 installer.AddExtraAttribute("Page count", PSRV_SPOOL_ATTR_PAGECOUNT, B_INT32_TYPE, true, false, 483 40, B_ALIGN_RIGHT, false); 484 installer.AddExtraAttribute("Description", PSRV_SPOOL_ATTR_DESCRIPTION, B_STRING_TYPE, true, true, 485 100, B_ALIGN_LEFT, false); 486 installer.AddExtraAttribute("Printer name", PSRV_SPOOL_ATTR_PRINTER, B_STRING_TYPE, true, false, 487 80, B_ALIGN_LEFT, false); 488 installer.AddExtraAttribute("Job creator type", PSRV_SPOOL_ATTR_MIMETYPE, B_ASCII_TYPE, true, false, 489 60, B_ALIGN_LEFT, false); 490 #else 491 ExtraAttributeLazyInstaller installer(B_PRINTER_SPOOL_MIMETYPE); 492 installer.AddExtraAttribute("Page count", "_spool/Page Count", B_INT32_TYPE, true, false, 493 40, B_ALIGN_RIGHT, false); 494 installer.AddExtraAttribute("Description", "_spool/Description", B_ASCII_TYPE, true, true, 495 100, B_ALIGN_LEFT, false); 496 installer.AddExtraAttribute("Printer name", "_spool/Printer", B_ASCII_TYPE, true, false, 497 80, B_ALIGN_LEFT, false); 498 installer.AddExtraAttribute("Job creator type", "_spool/MimeType", B_ASCII_TYPE, true, false, 499 60, B_ALIGN_LEFT, false); 500 #endif 501 } 502 503 InstallMimeIfNeeded(B_PRINTER_MIMETYPE, R_GenericPrinterIcon, 504 "Printer", "Printer queue.", kTrackerSignature /*application/x-vnd.Be-PRNT*/); 505 // for now set tracker as a default handler for the printer because we 506 // just want to open it as a folder 507 #if B_BEOS_VERSION_DANO 508 { 509 ExtraAttributeLazyInstaller installer(B_PRINTER_MIMETYPE); 510 installer.AddExtraAttribute("Driver", PSRV_PRINTER_ATTR_DRV_NAME, B_STRING_TYPE, true, false, 511 120, B_ALIGN_LEFT, false); 512 installer.AddExtraAttribute("Transport", PSRV_PRINTER_ATTR_TRANSPORT, B_STRING_TYPE, true, false, 513 60, B_ALIGN_RIGHT, false); 514 installer.AddExtraAttribute("Connection", PSRV_PRINTER_ATTR_CNX, B_STRING_TYPE, true, false, 515 40, B_ALIGN_LEFT, false); 516 installer.AddExtraAttribute("Description", PSRV_PRINTER_ATTR_COMMENTS, B_STRING_TYPE, true, true, 517 140, B_ALIGN_LEFT, false); 518 } 519 #endif 520 } 521 522 523 void 524 TTracker::InstallIndices() 525 { 526 BVolumeRoster roster; 527 BVolume volume; 528 529 roster.Rewind(); 530 while (roster.GetNextVolume(&volume) == B_OK) { 531 if (volume.IsReadOnly() || !volume.IsPersistent() 532 || !volume.KnowsAttr() || !volume.KnowsQuery()) 533 continue; 534 InstallIndices(volume.Device()); 535 } 536 } 537 538 539 void 540 TTracker::InstallIndices(dev_t device) 541 { 542 status_t error = fs_create_index(device, kAttrQueryLastChange, B_INT32_TYPE, 0); 543 error = fs_create_index(device, "_trk/recentQuery", B_INT32_TYPE, 0); 544 } 545 546 547 void 548 TTracker::InstallDefaultTemplates() 549 { 550 BNode node; 551 BString query(kQueryTemplates); 552 query += "/application_octet-stream"; 553 554 if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false)) 555 if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) { 556 AttributeStreamFileNode fileNode(&node); 557 AttributeStreamTemplateNode tmp(kDefaultQueryTemplate, 3); 558 fileNode << tmp; 559 } 560 561 (query = kQueryTemplates) += "/application_x-vnd.Be-bookmark"; 562 if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false)) 563 if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) { 564 AttributeStreamFileNode fileNode(&node); 565 AttributeStreamTemplateNode tmp(kBookmarkQueryTemplate, 3); 566 fileNode << tmp; 567 } 568 569 (query = kQueryTemplates) += "/application_x-person"; 570 if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false)) 571 if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) { 572 AttributeStreamFileNode fileNode(&node); 573 AttributeStreamTemplateNode tmp(kPersonQueryTemplate, 3); 574 fileNode << tmp; 575 } 576 577 (query = kQueryTemplates) += "/text_x-email"; 578 if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false)) 579 if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) { 580 AttributeStreamFileNode fileNode(&node); 581 AttributeStreamTemplateNode tmp(kEmailQueryTemplate, 3); 582 fileNode << tmp; 583 } 584 } 585 586 587 void 588 TTracker::InstallTemporaryBackgroundImages() 589 { 590 // make the large Haiku Logo the default background 591 592 BPath path; 593 status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path); 594 if (status < B_OK) { 595 BString errorMessage; 596 errorMessage << "At " << __PRETTY_FUNCTION__ << "\n"; 597 errorMessage << "find_directory() failed. \nReason: "; 598 errorMessage << strerror(status); 599 (new BAlert("AlertError", errorMessage.String(), "OK", NULL, NULL, 600 B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); 601 return; 602 } 603 path.Append("artwork"); 604 605 BString defaultBackgroundImage("/HAIKU logo - white on blue - big.png"); 606 607 BDirectory dir; 608 if (FSGetBootDeskDir(&dir) == B_OK) { 609 // install a default background if there is no background defined yet 610 attr_info info; 611 if (dir.GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) { 612 BScreen screen(B_MAIN_SCREEN_ID); 613 BPoint logoPos; 614 logoPos.x 615 = floorf((screen.Frame().Width() - 605) * (sqrtf(5) - 1) / 2); 616 logoPos.y = floorf((screen.Frame().Height() - 190) * 0.9); 617 BMessage message; 618 AddTemporaryBackgroundImages(&message, 619 (BString(path.Path()) << defaultBackgroundImage).String(), 620 BackgroundImage::kAtOffset, logoPos, 0xffffffff, false); 621 ::InstallTemporaryBackgroundImages(&dir, &message); 622 } 623 } 624 } 625