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