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