2 * Copyright 2005-2014, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
6 * Augustin Cavalier <waddlesplash>
7 * DarkWyrm <bpmagic@columbus.rr.com>
9 * Wim van der Meer <WPJvanderMeer@gmail.com>
22 #include <AppFileInfo.h>
23 #include <Application.h>
25 #include <DateTimeFormat.h>
26 #include <DurationFormat.h>
28 #include <FindDirectory.h>
31 #include <LayoutBuilder.h>
32 #include <MessageFormat.h>
33 #include <MessageRunner.h>
34 #include <Messenger.h>
35 #include <ObjectList.h>
38 #include <PathFinder.h>
39 #include <Resources.h>
41 #include <ScrollView.h>
43 #include <StringList.h>
44 #include <StringView.h>
45 #include <TranslationUtils.h>
46 #include <TranslatorFormats.h>
49 #include <VolumeRoster.h>
53 #include <AutoDeleter.h>
55 #include <parsedate.h>
56 #include <system_revision.h>
61 #include <LocaleRoster.h>
63 #include "HyperTextActions.h"
64 #include "HyperTextView.h"
65 #include "Utilities.h"
73 #define SCROLL_CREDITS_VIEW 'mviv'
75 #undef B_TRANSLATION_CONTEXT
76 #define B_TRANSLATION_CONTEXT "AboutWindow"
80 static const char* UptimeToString(char string
[], size_t size
);
81 static const char* MemSizeToString(char string
[], size_t size
,
83 static const char* MemUsageToString(char string
[], size_t size
,
87 static const rgb_color kDarkGrey
= { 100, 100, 100, 255 };
88 static const rgb_color kHaikuGreen
= { 42, 131, 36, 255 };
89 static const rgb_color kHaikuOrange
= { 255, 69, 0, 255 };
90 static const rgb_color kHaikuYellow
= { 255, 176, 0, 255 };
91 static const rgb_color kLinkBlue
= { 80, 80, 200, 255 };
92 static const rgb_color kBeOSBlue
= { 0, 0, 200, 255 };
93 static const rgb_color kBeOSRed
= { 200, 0, 0, 255 };
95 static const char* kBSDTwoClause
= B_TRANSLATE_MARK("BSD (2-clause)");
96 static const char* kBSDThreeClause
= B_TRANSLATE_MARK("BSD (3-clause)");
97 static const char* kBSDFourClause
= B_TRANSLATE_MARK("BSD (4-clause)");
98 static const char* kGPLv2
= B_TRANSLATE_MARK("GNU GPL v2");
99 static const char* kGPLv3
= B_TRANSLATE_MARK("GNU GPL v3");
100 static const char* kLGPLv2
= B_TRANSLATE_MARK("GNU LGPL v2");
101 static const char* kLGPLv21
= B_TRANSLATE_MARK("GNU LGPL v2.1");
102 static const char* kPublicDomain
= B_TRANSLATE_MARK("Public Domain");
104 static const char* kIntel2xxxFirmware
= B_TRANSLATE_MARK("Intel (2xxx firmware)");
105 static const char* kIntelFirmware
= B_TRANSLATE_MARK("Intel (firmware)");
106 static const char* kMarvellFirmware
= B_TRANSLATE_MARK("Marvell (firmware)");
107 static const char* kRalinkFirmware
= B_TRANSLATE_MARK("Ralink (firmware)");
112 TranslationComparator(const void* left
, const void* right
)
114 const Translation
* leftTranslation
= *(const Translation
**)left
;
115 const Translation
* rightTranslation
= *(const Translation
**)right
;
119 if (BLocaleRoster::Default()->GetLanguage(leftTranslation
->languageCode
,
120 &language
) == B_OK
) {
121 language
->GetName(leftName
);
124 leftName
= leftTranslation
->languageCode
;
127 if (BLocaleRoster::Default()->GetLanguage(rightTranslation
->languageCode
,
128 &language
) == B_OK
) {
129 language
->GetName(rightName
);
132 rightName
= rightTranslation
->languageCode
;
135 BLocale::Default()->GetCollator(&collator
);
136 return collator
.Compare(leftName
.String(), rightName
.String());
140 class AboutApp
: public BApplication
{
143 void MessageReceived(BMessage
* message
);
149 class AboutWindow
: public BWindow
{
153 virtual bool QuitRequested();
155 AboutView
* fAboutView
;
159 class LogoView
: public BView
{
164 virtual BSize
MinSize();
165 virtual BSize
MaxSize();
167 virtual void Draw(BRect updateRect
);
174 class CropView
: public BView
{
176 CropView(BView
* target
, int32 left
, int32 top
,
177 int32 right
, int32 bottom
);
180 virtual BSize
MinSize();
181 virtual BSize
MaxSize();
183 virtual void DoLayout();
194 class AboutView
: public BView
{
199 virtual void AttachedToWindow();
200 virtual void AllAttached();
201 virtual void Pulse();
203 virtual void MessageReceived(BMessage
* msg
);
204 virtual void MouseDown(BPoint point
);
206 void AddCopyrightEntry(const char* name
,
208 const StringVector
& licenses
,
209 const StringVector
& sources
,
211 void AddCopyrightEntry(const char* name
,
212 const char* text
, const char* url
= NULL
);
213 void PickRandomHaiku();
216 void _AdjustTextColors();
218 typedef std::map
<std::string
, PackageCredit
*> PackageCreditMap
;
221 BView
* _CreateLabel(const char* name
, const char* label
);
222 BView
* _CreateCreditsView();
223 status_t
_GetLicensePath(const char* license
,
225 void _AddCopyrightsFromAttribute();
226 void _AddPackageCredit(const PackageCredit
& package
);
227 void _AddPackageCreditEntries();
229 BStringView
* fMemView
;
230 BStringView
* fUptimeView
;
232 HyperTextView
* fCreditsView
;
234 BObjectList
<BView
> fTextViews
;
235 BObjectList
<BView
> fSubTextViews
;
239 bigtime_t fLastActionTime
;
240 BMessageRunner
* fScrollRunner
;
241 PackageCreditMap fPackageCredits
;
249 : BApplication("application/x-vnd.Haiku-About")
251 B_TRANSLATE_MARK_SYSTEM_NAME_VOID("AboutSystem");
253 AboutWindow
*window
= new(std::nothrow
) AboutWindow();
260 AboutApp::MessageReceived(BMessage
* message
)
262 switch (message
->what
) {
263 case B_SILENT_RELAUNCH
:
264 WindowAt(0)->Activate();
268 BApplication::MessageReceived(message
);
275 AboutWindow::AboutWindow()
276 : BWindow(BRect(0, 0, 500, 300), B_TRANSLATE("About this system"),
277 B_TITLED_WINDOW
, B_AUTO_UPDATE_SIZE_LIMITS
| B_NOT_ZOOMABLE
)
279 SetLayout(new BGroupLayout(B_VERTICAL
));
280 fAboutView
= new AboutView();
281 AddChild(fAboutView
);
283 // Make sure we take the minimal window size into account when centering
284 BSize size
= GetLayout()->MinSize();
285 ResizeTo(max_c(size
.width
, Bounds().Width()),
286 max_c(size
.height
, Bounds().Height()));
293 AboutWindow::QuitRequested()
295 be_app
->PostMessage(B_QUIT_REQUESTED
);
300 // #pragma mark - LogoView
304 : BView("logo", B_WILL_DRAW
)
306 fLogo
= BTranslationUtils::GetBitmap(B_PNG_FORMAT
, "logo.png");
307 SetViewColor(255, 255, 255);
311 LogoView::~LogoView()
323 return BSize(fLogo
->Bounds().Width(), fLogo
->Bounds().Height());
333 return BSize(B_SIZE_UNLIMITED
, fLogo
->Bounds().Height());
338 LogoView::Draw(BRect updateRect
)
342 BPoint((Bounds().Width() - fLogo
->Bounds().Width()) / 2, 0));
347 // #pragma mark - CropView
350 CropView::CropView(BView
* target
, int32 left
, int32 top
, int32 right
,
352 : BView("crop view", 0),
363 CropView::~CropView()
374 BSize size
= fTarget
->MinSize();
375 if (size
.width
!= B_SIZE_UNSET
)
376 size
.width
-= fCropLeft
+ fCropRight
;
377 if (size
.height
!= B_SIZE_UNSET
)
378 size
.height
-= fCropTop
+ fCropBottom
;
390 BSize size
= fTarget
->MaxSize();
391 if (size
.width
!= B_SIZE_UNSET
)
392 size
.width
-= fCropLeft
+ fCropRight
;
393 if (size
.height
!= B_SIZE_UNSET
)
394 size
.height
-= fCropTop
+ fCropBottom
;
408 fTarget
->MoveTo(-fCropLeft
, -fCropTop
);
409 fTarget
->ResizeTo(Bounds().Width() + fCropLeft
+ fCropRight
,
410 Bounds().Height() + fCropTop
+ fCropBottom
);
414 // #pragma mark - AboutView
416 #undef B_TRANSLATION_CONTEXT
417 #define B_TRANSLATION_CONTEXT "AboutView"
419 AboutView::AboutView()
420 : BView("aboutview", B_WILL_DRAW
| B_PULSE_NEEDED
),
421 fLastActionTime(system_time()),
424 // Begin Construction of System Information controls
425 system_info systemInfo
;
426 get_system_info(&systemInfo
);
428 // Create all the various labels for system infomation
433 strlcpy(string
, B_TRANSLATE("Unknown"), sizeof(string
));
435 // the version is stored in the BEOS:APP_VERSION attribute of libbe.so
437 if (find_directory(B_BEOS_LIB_DIRECTORY
, &path
) == B_OK
) {
438 path
.Append("libbe.so");
440 BAppFileInfo appFileInfo
;
441 version_info versionInfo
;
443 if (file
.SetTo(path
.Path(), B_READ_ONLY
) == B_OK
444 && appFileInfo
.SetTo(&file
) == B_OK
445 && appFileInfo
.GetVersionInfo(&versionInfo
,
446 B_APP_VERSION_KIND
) == B_OK
447 && versionInfo
.short_info
[0] != '\0')
448 strlcpy(string
, versionInfo
.short_info
, sizeof(string
));
451 // Add system revision
452 const char* haikuRevision
= __get_haiku_revision();
453 if (haikuRevision
!= NULL
) {
454 strlcat(string
, " (", sizeof(string
));
455 strlcat(string
, B_TRANSLATE("Revision"), sizeof(string
));
456 strlcat(string
, " ", sizeof(string
));
457 strlcat(string
, haikuRevision
, sizeof(string
));
458 strlcat(string
, ")", sizeof(string
));
461 BStringView
* versionView
= new BStringView("ostext", string
);
462 fSubTextViews
.AddItem(versionView
);
463 versionView
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
464 B_ALIGN_VERTICAL_UNSET
));
466 BStringView
* abiView
= new BStringView("abitext", B_HAIKU_ABI_NAME
);
467 fSubTextViews
.AddItem(abiView
);
468 abiView
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
469 B_ALIGN_VERTICAL_UNSET
));
471 // CPU count, type and clock speed
472 static BMessageFormat
format(B_TRANSLATE_COMMENT(
473 "{0, plural, one{Processor:} other{# Processors:}}",
474 "\"Processor:\" or \"2 Processors:\""));
476 BString processorLabel
;
477 format
.Format(processorLabel
, systemInfo
.cpu_count
);
479 uint32 topologyNodeCount
= 0;
480 cpu_topology_node_info
* topology
= NULL
;
481 get_cpu_topology_info(NULL
, &topologyNodeCount
);
482 if (topologyNodeCount
!= 0)
483 topology
= new cpu_topology_node_info
[topologyNodeCount
];
484 get_cpu_topology_info(topology
, &topologyNodeCount
);
486 enum cpu_platform platform
= B_CPU_UNKNOWN
;
487 enum cpu_vendor cpuVendor
= B_CPU_VENDOR_UNKNOWN
;
489 for (uint32 i
= 0; i
< topologyNodeCount
; i
++) {
490 switch (topology
[i
].type
) {
491 case B_TOPOLOGY_ROOT
:
492 platform
= topology
[i
].data
.root
.platform
;
495 case B_TOPOLOGY_PACKAGE
:
496 cpuVendor
= topology
[i
].data
.package
.vendor
;
499 case B_TOPOLOGY_CORE
:
500 cpuModel
= topology
[i
].data
.core
.model
;
511 cpuType
<< get_cpu_vendor_string(cpuVendor
)
512 << " " << get_cpu_model_string(platform
, cpuVendor
, cpuModel
);
514 BStringView
* cpuView
= new BStringView("cputext", cpuType
.String());
515 fSubTextViews
.AddItem(cpuView
);
516 cpuView
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
517 B_ALIGN_VERTICAL_UNSET
));
519 int32 clockSpeed
= get_rounded_cpu_speed();
520 if (clockSpeed
< 1000)
521 snprintf(string
, sizeof(string
), B_TRANSLATE("%ld MHz"), clockSpeed
);
523 snprintf(string
, sizeof(string
), B_TRANSLATE("%.2f GHz"),
524 clockSpeed
/ 1000.0f
);
526 BStringView
* frequencyView
= new BStringView("frequencytext", string
);
527 fSubTextViews
.AddItem(frequencyView
);
528 frequencyView
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
529 B_ALIGN_VERTICAL_UNSET
));
532 BStringView
*memSizeView
= new BStringView("ramsizetext",
533 MemSizeToString(string
, sizeof(string
), &systemInfo
));
534 fSubTextViews
.AddItem(memSizeView
);
535 memSizeView
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
536 B_ALIGN_VERTICAL_UNSET
));
538 fMemView
= new BStringView("ramtext",
539 MemUsageToString(string
, sizeof(string
), &systemInfo
));
540 fSubTextViews
.AddItem(fMemView
);
541 fMemView
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
542 B_ALIGN_VERTICAL_UNSET
));
544 // Kernel build time/date
545 BString kernelTimeDate
;
546 kernelTimeDate
<< systemInfo
.kernel_build_date
547 << " " << systemInfo
.kernel_build_time
;
548 BString buildTimeDate
;
550 time_t buildTimeDateStamp
= parsedate(kernelTimeDate
, -1);
551 if (buildTimeDateStamp
> 0) {
552 if (BDateTimeFormat().Format(buildTimeDate
, buildTimeDateStamp
,
553 B_LONG_DATE_FORMAT
, B_MEDIUM_TIME_FORMAT
) != B_OK
)
554 buildTimeDate
.SetTo(kernelTimeDate
);
556 buildTimeDate
.SetTo(kernelTimeDate
);
558 BStringView
* kernelView
= new BStringView("kerneltext", buildTimeDate
);
559 fSubTextViews
.AddItem(kernelView
);
560 kernelView
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
561 B_ALIGN_VERTICAL_UNSET
));
564 fUptimeView
= new BStringView("uptimetext", "...");
565 fSubTextViews
.AddItem(fUptimeView
);
566 fUptimeView
->SetText(UptimeToString(string
, sizeof(string
)));
568 const float offset
= 5;
570 SetLayout(new BGroupLayout(B_HORIZONTAL
, 0));
571 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
573 BLayoutBuilder::Group
<>((BGroupLayout
*)GetLayout())
574 .AddGroup(B_VERTICAL
, 0)
576 .AddGroup(B_VERTICAL
, 0)
577 .Add(_CreateLabel("oslabel", B_TRANSLATE("Version:")))
581 .Add(_CreateLabel("cpulabel", processorLabel
.String()))
585 .Add(_CreateLabel("memlabel", B_TRANSLATE("Memory:")))
589 .Add(_CreateLabel("kernellabel", B_TRANSLATE("Kernel:")))
592 .Add(_CreateLabel("uptimelabel",
593 B_TRANSLATE("Time running:")))
595 .SetInsets(5, 5, 5, 5)
597 // TODO: investigate: adding this causes the time to be cut
600 .Add(_CreateCreditsView());
602 float min
= fMemView
->MinSize().width
* 1.1f
;
603 fCreditsView
->SetExplicitMinSize(BSize(min
, min
));
607 AboutView::~AboutView()
609 for (PackageCreditMap::iterator it
= fPackageCredits
.begin();
610 it
!= fPackageCredits
.end(); it
++) {
615 delete fScrollRunner
;
620 AboutView::AttachedToWindow()
622 BView::AttachedToWindow();
623 Window()->SetPulseRate(500000);
624 SetEventMask(B_POINTER_EVENTS
);
630 AboutView::AllAttached()
637 AboutView::MouseDown(BPoint point
)
639 BRect
r(92, 26, 105, 31);
640 if (r
.Contains(point
))
641 BMessenger(this).SendMessage('eegg');
643 if (Bounds().Contains(point
)) {
644 fLastActionTime
= system_time();
645 delete fScrollRunner
;
646 fScrollRunner
= NULL
;
656 get_system_info(&info
);
657 fUptimeView
->SetText(UptimeToString(string
, sizeof(string
)));
658 fMemView
->SetText(MemUsageToString(string
, sizeof(string
), &info
));
660 if (fScrollRunner
== NULL
661 && system_time() > fLastActionTime
+ 10000000) {
662 BMessage
message(SCROLL_CREDITS_VIEW
);
663 //fScrollRunner = new BMessageRunner(this, &message, 25000, -1);
669 AboutView::MessageReceived(BMessage
* msg
)
672 case B_COLORS_UPDATED
:
674 if (msg
->HasColor(ui_color_name(B_PANEL_TEXT_COLOR
)))
679 case SCROLL_CREDITS_VIEW
:
681 BScrollBar
* scrollBar
=
682 fCreditsView
->ScrollBar(B_VERTICAL
);
683 if (scrollBar
== NULL
)
686 scrollBar
->GetRange(&min
, &max
);
687 if (scrollBar
->Value() < max
)
688 fCreditsView
->ScrollBy(0, 1);
695 printf("Easter egg\n");
701 BView::MessageReceived(msg
);
708 AboutView::AddCopyrightEntry(const char* name
, const char* text
,
711 AddCopyrightEntry(name
, text
, StringVector(), StringVector(), url
);
716 AboutView::AddCopyrightEntry(const char* name
, const char* text
,
717 const StringVector
& licenses
, const StringVector
& sources
,
720 BFont
font(be_bold_font
);
721 //font.SetSize(be_bold_font->Size());
722 font
.SetFace(B_BOLD_FACE
| B_ITALIC_FACE
);
724 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuYellow
);
725 fCreditsView
->Insert(name
);
726 fCreditsView
->Insert("\n");
727 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
728 fCreditsView
->Insert(text
);
729 fCreditsView
->Insert("\n");
731 if (licenses
.CountStrings() > 0) {
732 if (licenses
.CountStrings() > 1)
733 fCreditsView
->Insert(B_TRANSLATE("Licenses: "));
735 fCreditsView
->Insert(B_TRANSLATE("License: "));
737 for (int32 i
= 0; i
< licenses
.CountStrings(); i
++) {
738 const char* license
= licenses
.StringAt(i
);
741 fCreditsView
->Insert(", ");
745 parse_named_url(license
, licenseName
, licenseURL
);
748 if (_GetLicensePath(licenseURL
, licensePath
) == B_OK
) {
749 fCreditsView
->InsertHyperText(B_TRANSLATE_NOCOLLECT(licenseName
),
750 new OpenFileAction(licensePath
.Path()));
752 fCreditsView
->Insert(licenseName
);
755 fCreditsView
->Insert("\n");
758 if (sources
.CountStrings() > 0) {
759 fCreditsView
->Insert(B_TRANSLATE("Source Code: "));
761 for (int32 i
= 0; i
< sources
.CountStrings(); i
++) {
762 const char* source
= sources
.StringAt(i
);
765 fCreditsView
->Insert(", ");
769 parse_named_url(source
, urlName
, urlAddress
);
771 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
,
773 fCreditsView
->InsertHyperText(urlName
,
774 new URLAction(urlAddress
));
777 fCreditsView
->Insert("\n");
783 parse_named_url(url
, urlName
, urlAddress
);
785 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
,
787 fCreditsView
->InsertHyperText(urlName
,
788 new URLAction(urlAddress
));
789 fCreditsView
->Insert("\n");
791 fCreditsView
->Insert("\n");
796 AboutView::PickRandomHaiku()
799 if (find_directory(B_SYSTEM_DATA_DIRECTORY
, &path
) != B_OK
)
800 path
= "/system/data";
801 path
.Append("fortunes");
802 path
.Append("Haiku");
804 BFile
fortunes(path
.Path(), B_READ_ONLY
);
806 if (fortunes
.InitCheck() < B_OK
)
808 if (fortunes
.GetStat(&st
) < B_OK
)
811 char* buff
= (char*)malloc((size_t)st
.st_size
+ 1);
814 buff
[(size_t)st
.st_size
] = '\0';
816 if (fortunes
.Read(buff
, (size_t)st
.st_size
) == (ssize_t
)st
.st_size
) {
819 char* e
= strchr(p
, '%');
820 BString
* s
= new BString(p
, e
? (e
- p
) : -1);
821 haikuList
.AddItem(s
);
823 if (p
&& (*p
== '%'))
825 if (p
&& (*p
== '\n'))
830 if (haikuList
.CountItems() < 1)
833 BString
* s
= (BString
*)haikuList
.ItemAt(rand() % haikuList
.CountItems());
834 BFont
font(be_bold_font
);
835 font
.SetSize(be_bold_font
->Size());
836 font
.SetFace(B_BOLD_FACE
| B_ITALIC_FACE
);
837 fCreditsView
->SelectAll();
838 fCreditsView
->Delete();
839 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kDarkGrey
);
840 fCreditsView
->Insert(s
->String());
841 fCreditsView
->Insert("\n");
842 while ((s
= (BString
*)haikuList
.RemoveItem((int32
)0))) {
849 AboutView::_AdjustTextColors()
851 rgb_color textColor
= ui_color(B_PANEL_TEXT_COLOR
);
852 rgb_color color
= mix_color(ViewColor(), textColor
, 192);
855 for (int32 index
= 0; index
< fSubTextViews
.CountItems(); ++index
) {
856 view
= fSubTextViews
.ItemAt(index
);
857 view
->SetHighColor(color
);
862 for (int32 index
= 0; index
< fTextViews
.CountItems(); ++index
) {
863 view
= fTextViews
.ItemAt(index
);
864 view
->SetHighColor(textColor
);
871 AboutView::_CreateLabel(const char* name
, const char* label
)
873 BStringView
* labelView
= new BStringView(name
, label
);
874 labelView
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
875 B_ALIGN_VERTICAL_UNSET
));
876 labelView
->SetFont(be_bold_font
);
877 fTextViews
.AddItem(labelView
);
883 AboutView::_CreateCreditsView()
885 // Begin construction of the credits view
886 fCreditsView
= new HyperTextView("credits");
887 fCreditsView
->SetFlags(fCreditsView
->Flags() | B_FRAME_EVENTS
);
888 fCreditsView
->SetStylable(true);
889 fCreditsView
->MakeEditable(false);
890 fCreditsView
->SetWordWrap(true);
891 fCreditsView
->SetInsets(5, 5, 5, 5);
892 fCreditsView
->SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR
);
894 BScrollView
* creditsScroller
= new BScrollView("creditsScroller",
895 fCreditsView
, B_WILL_DRAW
| B_FRAME_EVENTS
, false, true,
899 BFont
font(be_bold_font
);
900 font
.SetSize(font
.Size() + 4);
902 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuGreen
);
903 fCreditsView
->Insert("Haiku\n");
906 time_t time
= ::time(NULL
);
907 struct tm
* tm
= localtime(&time
);
908 int32 year
= tm
->tm_year
+ 1900;
911 snprintf(string
, sizeof(string
),
912 COPYRIGHT_STRING
"2001-%" B_PRId32
" The Haiku project. ", year
);
914 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
915 fCreditsView
->Insert(string
);
917 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
918 fCreditsView
->Insert(B_TRANSLATE("The copyright to the Haiku code is "
919 "property of Haiku, Inc. or of the respective authors where expressly "
920 "noted in the source. Haiku" B_UTF8_REGISTERED
921 " and the HAIKU logo" B_UTF8_REGISTERED
922 " are registered trademarks of Haiku, Inc."
925 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kLinkBlue
);
926 fCreditsView
->InsertHyperText("https://www.haiku-os.org",
927 new URLAction("https://www.haiku-os.org"));
928 fCreditsView
->Insert("\n\n");
930 font
.SetSize(be_bold_font
->Size());
931 font
.SetFace(B_BOLD_FACE
| B_ITALIC_FACE
);
933 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuOrange
);
934 fCreditsView
->Insert(B_TRANSLATE("Current maintainers:\n"));
936 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
937 fCreditsView
->Insert(kCurrentMaintainers
);
939 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuOrange
);
940 fCreditsView
->Insert(B_TRANSLATE("Past maintainers:\n"));
942 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
943 fCreditsView
->Insert(kPastMaintainers
);
945 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuOrange
);
946 fCreditsView
->Insert(B_TRANSLATE("Website & marketing:\n"));
948 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
949 fCreditsView
->Insert(kWebsiteTeam
);
951 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuOrange
);
952 fCreditsView
->Insert(B_TRANSLATE("Past website & marketing:\n"));
954 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
955 fCreditsView
->Insert(kPastWebsiteTeam
);
957 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuOrange
);
958 fCreditsView
->Insert(B_TRANSLATE("Contributors:\n"));
960 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
961 fCreditsView
->Insert(kContributors
);
962 fCreditsView
->Insert(
963 B_TRANSLATE("\n" B_UTF8_ELLIPSIS
964 "and probably some more we forgot to mention (sorry!)"
967 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuOrange
);
968 fCreditsView
->Insert(B_TRANSLATE("Translations:\n"));
973 BList sortedTranslations
;
974 for (uint32 i
= 0; i
< kNumberOfTranslations
; i
++) {
975 const Translation
* translation
= &kTranslations
[i
];
976 sortedTranslations
.AddItem((void*)translation
);
978 sortedTranslations
.SortItems(TranslationComparator
);
980 for (uint32 i
= 0; i
< kNumberOfTranslations
; i
++) {
981 const Translation
& translation
982 = *(const Translation
*)sortedTranslations
.ItemAt(i
);
984 langName
.Truncate(0);
985 if (BLocaleRoster::Default()->GetLanguage(translation
.languageCode
,
987 lang
->GetName(langName
);
990 // We failed to get the localized readable name,
991 // go with what we have.
992 langName
.Append(translation
.languageCode
);
995 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuGreen
);
996 fCreditsView
->Insert("\n");
997 fCreditsView
->Insert(langName
);
998 fCreditsView
->Insert("\n");
999 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
1000 fCreditsView
->Insert(translation
.names
);
1003 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuOrange
);
1004 fCreditsView
->Insert(B_TRANSLATE("\n\nSpecial thanks to:\n"));
1006 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
1007 BString
beosCredits(B_TRANSLATE(
1008 "Be Inc. and its developer team, for having created BeOS!\n\n"));
1009 int32 beosOffset
= beosCredits
.FindFirst("BeOS");
1010 fCreditsView
->Insert(beosCredits
.String(),
1011 (beosOffset
< 0) ? beosCredits
.Length() : beosOffset
);
1012 if (beosOffset
> -1) {
1013 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kBeOSBlue
);
1014 fCreditsView
->Insert("B");
1015 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kBeOSRed
);
1016 fCreditsView
->Insert("e");
1017 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
1018 beosCredits
.Remove(0, beosOffset
+ 2);
1019 fCreditsView
->Insert(beosCredits
.String(), beosCredits
.Length());
1021 fCreditsView
->Insert(
1022 B_TRANSLATE("Travis Geiselbrecht (and his NewOS kernel)\n"));
1023 fCreditsView
->Insert(
1024 B_TRANSLATE("Michael Phipps (project founder)\n\n"));
1025 fCreditsView
->Insert(
1026 B_TRANSLATE("The HaikuPorts team\n"));
1027 fCreditsView
->Insert(
1028 B_TRANSLATE("The Haikuware team and their bounty program\n"));
1029 fCreditsView
->Insert(
1030 B_TRANSLATE("The BeGeistert team\n"));
1031 fCreditsView
->Insert(
1032 B_TRANSLATE("Google and their Google Summer of Code and Google Code In "
1034 fCreditsView
->Insert(
1035 B_TRANSLATE("The University of Auckland and Christof Lutteroth\n\n"));
1036 fCreditsView
->Insert(
1037 B_TRANSLATE(B_UTF8_ELLIPSIS
"and the many people making donations!\n\n"));
1039 // copyrights for various projects we use
1042 _GetLicensePath("MIT", mitPath
);
1044 _GetLicensePath("GNU LGPL v2.1", lgplPath
);
1046 font
.SetSize(be_bold_font
->Size() + 4);
1047 font
.SetFace(B_BOLD_FACE
);
1048 fCreditsView
->SetFontAndColor(&font
, B_FONT_ALL
, &kHaikuGreen
);
1049 fCreditsView
->Insert(B_TRANSLATE("\nCopyrights\n\n"));
1051 fCreditsView
->SetFontAndColor(be_plain_font
, B_FONT_ALL
, &kDarkGrey
);
1052 fCreditsView
->Insert(B_TRANSLATE("[Click a license name to read the "
1053 "respective license.]\n\n"));
1056 BString haikuLicense
= B_TRANSLATE_COMMENT("The code that is unique to "
1057 "Haiku, especially the kernel and all code that applications may link "
1058 "against, is distributed under the terms of the <MIT license>. "
1059 "Some system libraries contain third party code distributed under the "
1060 "<LGPL license>. You can find the copyrights to third party code below."
1061 "\n\n", "<MIT license> and <LGPL license> aren't variables and can be "
1062 "translated. However, please, don't remove < and > as they're needed "
1063 "as placeholders for proper hypertext functionality.");
1064 int32 licensePart1
= haikuLicense
.FindFirst("<");
1065 int32 licensePart2
= haikuLicense
.FindFirst(">");
1066 int32 licensePart3
= haikuLicense
.FindLast("<");
1067 int32 licensePart4
= haikuLicense
.FindLast(">");
1069 haikuLicense
.CopyInto(part
, 0, licensePart1
);
1070 fCreditsView
->Insert(part
);
1073 haikuLicense
.CopyInto(part
, licensePart1
+ 1, licensePart2
- 1
1075 fCreditsView
->InsertHyperText(part
, new OpenFileAction(mitPath
.Path()));
1078 haikuLicense
.CopyInto(part
, licensePart2
+ 1, licensePart3
- 1
1080 fCreditsView
->Insert(part
);
1083 haikuLicense
.CopyInto(part
, licensePart3
+ 1, licensePart4
- 1
1085 fCreditsView
->InsertHyperText(part
, new OpenFileAction(lgplPath
.Path()));
1088 haikuLicense
.CopyInto(part
, licensePart4
+ 1, haikuLicense
.Length() - 1
1090 fCreditsView
->Insert(part
);
1093 AddCopyrightEntry("The GNU Project",
1094 B_TRANSLATE("Contains software from the GNU Project, "
1095 "released under the GPL and LGPL licenses:\n"
1097 "GNU coretools, diffutils, findutils, "
1098 "sharutils, gawk, bison, m4, make, "
1099 "wget, ncurses, termcap, "
1100 "Bourne Again Shell.\n"
1101 COPYRIGHT_STRING
"The Free Software Foundation."),
1102 StringVector(kLGPLv21
, kGPLv2
, kGPLv3
, NULL
),
1104 "https://www.gnu.org");
1106 // FreeBSD copyrights
1107 AddCopyrightEntry("The FreeBSD Project",
1108 B_TRANSLATE("Contains software from the FreeBSD Project, "
1109 "released under the BSD license:\n"
1110 "ftpd, ping, telnet, telnetd, traceroute\n"
1111 COPYRIGHT_STRING
"1994-2008 The FreeBSD Project. "
1112 "All rights reserved."),
1113 StringVector(kBSDTwoClause
, kBSDThreeClause
, kBSDFourClause
,
1116 "https://www.freebsd.org");
1118 // NetBSD copyrights
1119 AddCopyrightEntry("The NetBSD Project",
1120 B_TRANSLATE("Contains software developed by the NetBSD "
1121 "Foundation, Inc. and its contributors:\n"
1123 COPYRIGHT_STRING
"1996-2008 The NetBSD Foundation, Inc. "
1124 "All rights reserved."),
1125 "https://www.netbsd.org");
1128 // FFmpeg copyrights
1129 _AddPackageCredit(PackageCredit("FFmpeg")
1130 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2000-2014 Fabrice "
1132 .SetLicenses(kLGPLv21
, kLGPLv2
, NULL
)
1133 .SetURL("https://www.ffmpeg.org"));
1136 _AddPackageCredit(PackageCredit("AntiGrain Geometry")
1137 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2002-2006 Maxim "
1138 "Shemanarev (McSeem)."))
1139 .SetLicenses("Anti-Grain Geometry", kBSDThreeClause
, NULL
)
1140 .SetURL("http://www.antigrain.com"));
1142 // FreeType copyrights
1143 _AddPackageCredit(PackageCredit("FreeType2")
1144 .SetCopyrights(B_TRANSLATE(COPYRIGHT_STRING
"1996-2002, 2006 "
1145 "David Turner, Robert Wilhelm and Werner Lemberg."),
1146 COPYRIGHT_STRING
"2014 The FreeType Project. "
1147 "All rights reserved.",
1149 .SetLicense("FreeType")
1150 .SetURL("http://www.freetype.org"));
1152 // Mesa3D (http://www.mesa3d.org) copyrights
1153 _AddPackageCredit(PackageCredit("Mesa")
1154 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1999-2006 Brian Paul. "
1155 "Mesa3D Project. All rights reserved."))
1157 .SetURL("http://www.mesa3d.org"));
1159 // SGI's GLU implementation copyrights
1160 _AddPackageCredit(PackageCredit("GLU")
1161 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1991-2000 "
1162 "Silicon Graphics, Inc. All rights reserved."))
1163 .SetLicense("SGI Free B")
1164 .SetURL("http://www.sgi.com/products/software/opengl"));
1166 // GLUT implementation copyrights
1167 _AddPackageCredit(PackageCredit("GLUT")
1168 .SetCopyrights(B_TRANSLATE(COPYRIGHT_STRING
"1994-1997 Mark Kilgard. "
1169 "All rights reserved."),
1170 COPYRIGHT_STRING
"1997 Be Inc.",
1171 COPYRIGHT_STRING
"1999 Jake Hamby.",
1174 .SetURL("http://www.opengl.org/resources/libraries/glut"));
1176 // OpenGroup & DEC (BRegion backend) copyright
1177 _AddPackageCredit(PackageCredit("BRegion backend (XFree86)")
1178 .SetCopyrights(COPYRIGHT_STRING
"1987-1988, 1998 The Open Group.",
1179 B_TRANSLATE(COPYRIGHT_STRING
"1987-1988 Digital Equipment "
1180 "Corporation, Maynard, Massachusetts.\n"
1181 "All rights reserved."),
1183 .SetLicenses("OpenGroup", "DEC", NULL
));
1186 // Bitstream Charter font
1187 _AddPackageCredit(PackageCredit("Bitstream Charter font")
1188 .SetCopyrights(COPYRIGHT_STRING
"1989-1992 Bitstream Inc.,"
1190 B_TRANSLATE("BITSTREAM CHARTER is a registered trademark of "
1193 .SetLicense("Bitstream Charter")
1194 .SetURL("http://www.bitstream.com/"));
1196 // Noto fonts copyright
1197 _AddPackageCredit(PackageCredit("Noto fonts")
1198 .SetCopyrights(B_TRANSLATE(COPYRIGHT_STRING
1199 "2012-2016 Google Internationalization team."),
1201 .SetLicense("SIL Open Font Licence v1.1")
1202 .SetURL("http://www.google.com/get/noto/"));
1205 _AddPackageCredit(PackageCredit("expat")
1206 .SetCopyrights(B_TRANSLATE(COPYRIGHT_STRING
"1998-2000 Thai "
1207 "Open Source Software Center Ltd and Clark Cooper."),
1208 B_TRANSLATE(COPYRIGHT_STRING
"2001-2003 Expat maintainers."),
1210 .SetLicense("Expat")
1211 .SetURL("http://expat.sourceforge.net"));
1214 _AddPackageCredit(PackageCredit("zlib")
1215 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1995-2004 Jean-loup "
1216 "Gailly and Mark Adler."))
1218 .SetURL("http://www.zlib.net"));
1221 _AddPackageCredit(PackageCredit("Info-ZIP")
1222 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1990-2002 Info-ZIP. "
1223 "All rights reserved."))
1224 .SetLicense("Info-ZIP")
1225 .SetURL("http://www.info-zip.org"));
1228 _AddPackageCredit(PackageCredit("bzip2")
1229 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1996-2005 Julian R "
1230 "Seward. All rights reserved."))
1231 .SetLicense(kBSDFourClause
)
1232 .SetURL("http://bzip.org"));
1234 // OpenEXR copyrights
1235 _AddPackageCredit(PackageCredit("OpenEXR")
1236 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2002-2014 Industrial "
1237 "Light & Magic, a division of Lucas Digital Ltd. LLC."))
1238 .SetLicense(kBSDThreeClause
)
1239 .SetURL("http://www.openexr.com"));
1241 // Netcat copyrights
1242 _AddPackageCredit(PackageCredit("Netcat")
1243 .SetCopyright(COPYRIGHT_STRING
"1996 Hobbit.")
1244 .SetLicense(kPublicDomain
)
1245 .SetURL("http://nc110.sourceforge.net/"));
1247 // acpica copyrights
1248 _AddPackageCredit(PackageCredit("acpica")
1249 .SetCopyright(COPYRIGHT_STRING
"1999-2014 Intel Corp.")
1250 .SetLicense("Intel (ACPICA)")
1251 .SetURL("https://www.acpica.org"));
1253 // libpng copyrights
1254 _AddPackageCredit(PackageCredit("libpng")
1255 .SetCopyright(COPYRIGHT_STRING
"2004, 2006-2008 Glenn "
1257 .SetLicense("LibPNG")
1258 .SetURL("http://www.libpng.org"));
1260 // libjpeg copyrights
1261 _AddPackageCredit(PackageCredit("libjpeg")
1262 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1994-2009, Thomas G. "
1263 "Lane, Guido Vollbeding. This software is based in part on the "
1264 "work of the Independent JPEG Group."))
1265 .SetLicense("LibJPEG")
1266 .SetURL("http://www.ijg.org"));
1268 // libprint copyrights
1269 _AddPackageCredit(PackageCredit("libprint")
1270 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1999-2000 Y.Takagi. "
1271 "All rights reserved.")));
1274 // cortex copyrights
1275 _AddPackageCredit(PackageCredit("Cortex")
1276 .SetCopyright(COPYRIGHT_STRING
"1999-2000 Eric Moon.")
1277 .SetLicense(kBSDThreeClause
)
1278 .SetURL("http://cortex.sourceforge.net/documentation"));
1280 // FluidSynth copyrights
1281 _AddPackageCredit(PackageCredit("FluidSynth")
1282 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2003 Peter Hanappe "
1284 .SetLicense(kLGPLv2
)
1285 .SetURL("http://www.fluidsynth.org"));
1287 // Xiph.org Foundation copyrights
1288 _AddPackageCredit(PackageCredit("Xiph.org Foundation")
1289 .SetCopyrights("libvorbis, libogg, libtheora, libspeex",
1290 B_TRANSLATE(COPYRIGHT_STRING
"1994-2008 Xiph.Org. "
1291 "All rights reserved."), NULL
)
1292 .SetLicense(kBSDThreeClause
)
1293 .SetURL("http://www.xiph.org"));
1295 // The Tcpdump Group
1296 _AddPackageCredit(PackageCredit("The Tcpdump Group")
1297 .SetCopyright("tcpdump, libpcap")
1298 .SetLicense(kBSDThreeClause
)
1299 .SetURL("http://www.tcpdump.org"));
1302 _AddPackageCredit(PackageCredit("libmatroska")
1303 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2002-2003 Steve Lhomme. "
1304 "All rights reserved."))
1305 .SetLicense(kLGPLv21
)
1306 .SetURL("http://www.matroska.org"));
1308 // BColorQuantizer (originally CQuantizer code)
1309 _AddPackageCredit(PackageCredit("CQuantizer")
1310 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1996-1997 Jeff Prosise. "
1311 "All rights reserved."))
1312 .SetLicense("CQuantizer")
1313 .SetURL("http://www.xdp.it"));
1315 // MAPM (Mike's Arbitrary Precision Math Library) used by DeskCalc
1316 _AddPackageCredit(PackageCredit("MAPM")
1317 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1999-2007 Michael C. "
1318 "Ring. All rights reserved."))
1320 .SetURL("http://tc.umn.edu/~ringx004"));
1322 // MkDepend 1.7 copyright (Makefile dependency generator)
1323 _AddPackageCredit(PackageCredit("MkDepend")
1324 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1995-2001 Lars DĂ¼ning. "
1325 "All rights reserved."))
1327 .SetURL("http://bearnip.com/lars/be"));
1329 // libhttpd copyright (used as Poorman backend)
1330 _AddPackageCredit(PackageCredit("libhttpd")
1331 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"1995, 1998-2001 "
1332 "Jef Poskanzer. All rights reserved."))
1333 .SetLicense(kBSDTwoClause
)
1334 .SetURL("http://www.acme.com/software/thttpd/"));
1337 // Udis86 copyrights
1338 _AddPackageCredit(PackageCredit("Udis86")
1339 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2002-2004 "
1340 "Vivek Mohan. All rights reserved."))
1341 .SetLicense(kBSDTwoClause
)
1342 .SetURL("http://udis86.sourceforge.net"));
1344 // Intel PRO/Wireless 2100 Firmware
1345 _AddPackageCredit(PackageCredit("Intel PRO/Wireless 2100 Firmware")
1346 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2003-2006 "
1347 "Intel Corporation. All rights reserved."))
1348 .SetLicense(kIntel2xxxFirmware
)
1349 .SetURL("http://ipw2100.sourceforge.net/"));
1351 // Intel PRO/Wireless 2200BG Firmware
1352 _AddPackageCredit(PackageCredit("Intel PRO/Wireless 2200BG Firmware")
1353 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2004-2005 "
1354 "Intel Corporation. All rights reserved."))
1355 .SetLicense(kIntel2xxxFirmware
)
1356 .SetURL("http://ipw2200.sourceforge.net/"));
1358 // Intel PRO/Wireless 3945ABG/BG Network Connection Adapter Firmware
1361 "Intel PRO/Wireless 3945ABG/BG Network Connection Adapter Firmware")
1362 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2006-2007 "
1363 "Intel Corporation. All rights reserved."))
1364 .SetLicense(kIntelFirmware
)
1365 .SetURL("http://www.intellinuxwireless.org/"));
1367 // Intel Wireless WiFi Link 4965AGN Adapter Firmware
1369 PackageCredit("Intel Wireless WiFi Link 4965AGN Adapter Firmware")
1370 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2006-2007 "
1371 "Intel Corporation. All rights reserved."))
1372 .SetLicense(kIntelFirmware
)
1373 .SetURL("http://www.intellinuxwireless.org/"));
1376 _AddPackageCredit(PackageCredit("Marvell 88w8363")
1377 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2007-2009 "
1378 "Marvell Semiconductor, Inc. All rights reserved."))
1379 .SetLicense(kMarvellFirmware
)
1380 .SetURL("http://www.marvell.com/"));
1382 // Ralink Firmware RT2501/RT2561/RT2661
1383 _AddPackageCredit(PackageCredit("Ralink Firmware RT2501/RT2561/RT2661")
1384 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2007 "
1385 "Ralink Technology Corporation. All rights reserved."))
1386 .SetLicense(kRalinkFirmware
)
1387 .SetURL("http://www.ralinktech.com/"));
1391 _AddPackageCredit(PackageCredit("Gutenprint")
1392 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
1393 "1999-2010 by the authors of Gutenprint. All rights reserved."))
1395 .SetURL("http://gutenprint.sourceforge.net/"));
1398 _AddPackageCredit(PackageCredit("libwebp")
1399 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
1400 "2010-2011 Google Inc. All rights reserved."))
1401 .SetLicense(kBSDThreeClause
)
1402 .SetURL("http://www.webmproject.org/code/#libwebp_webp_image_library"));
1405 _AddPackageCredit(PackageCredit("GTF")
1406 .SetCopyright(B_TRANSLATE("2001 by Andy Ritger based on the "
1407 "Generalized Timing Formula"))
1408 .SetLicense(kBSDThreeClause
)
1409 .SetURL("http://gtf.sourceforge.net/"));
1412 _AddPackageCredit(PackageCredit("libqrencode")
1413 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2006-2012 Kentaro Fukuchi"))
1414 .SetLicense(kLGPLv21
)
1415 .SetURL("http://fukuchi.org/works/qrencode/"));
1417 _AddCopyrightsFromAttribute();
1418 _AddPackageCreditEntries();
1421 _AddPackageCredit(PackageCredit("scrypt")
1422 .SetCopyright(B_TRANSLATE(COPYRIGHT_STRING
"2009 Colin Percival"))
1423 .SetLicense(kBSDTwoClause
)
1424 .SetURL("https://tarsnap.com/scrypt.html"));
1426 _AddCopyrightsFromAttribute();
1427 _AddPackageCreditEntries();
1429 return new CropView(creditsScroller
, 0, 1, 1, 1);
1434 AboutView::_GetLicensePath(const char* license
, BPath
& path
)
1436 BPathFinder pathFinder
;
1440 status_t error
= pathFinder
.FindPaths(B_FIND_PATH_DATA_DIRECTORY
,
1443 for (int i
= 0; i
< paths
.CountStrings(); ++i
) {
1444 if (error
== B_OK
&& path
.SetTo(paths
.StringAt(i
)) == B_OK
1445 && path
.Append(license
) == B_OK
1446 && lstat(path
.Path(), &st
) == 0) {
1452 return B_ENTRY_NOT_FOUND
;
1457 AboutView::_AddCopyrightsFromAttribute()
1460 // open the app executable file
1461 char appPath
[B_PATH_NAME_LENGTH
];
1463 if (BPrivate::get_app_path(appPath
) != B_OK
1464 || (appFD
= open(appPath
, O_RDONLY
)) < 0) {
1468 // open the attribute
1469 int attrFD
= fs_fopen_attr(appFD
, "COPYRIGHTS", B_STRING_TYPE
, O_RDONLY
);
1474 // attach it to a FILE
1475 FILE* attrFile
= fdopen(attrFD
, "r");
1476 if (attrFile
== NULL
) {
1480 CObjectDeleter
<FILE, int> _(attrFile
, fclose
);
1482 // read and parse the copyrights
1486 char lineBuffer
[LINE_MAX
];
1487 while (char* line
= fgets(lineBuffer
, sizeof(lineBuffer
), attrFile
)) {
1488 // chop off line break
1489 size_t lineLen
= strlen(line
);
1490 if (lineLen
> 0 && line
[lineLen
- 1] == '\n')
1491 line
[--lineLen
] = '\0';
1493 // flush previous field, if a new field begins, otherwise append
1494 if (lineLen
== 0 || !isspace(line
[0])) {
1495 // new field -- flush the previous one
1496 if (fieldName
.Length() > 0) {
1497 fieldValue
= trim_string(fieldValue
.String(),
1498 fieldValue
.Length());
1499 package
.AddString(fieldName
.String(), fieldValue
);
1502 } else if (fieldName
.Length() > 0) {
1503 // append to current field
1507 // bogus line -- ignore
1515 char* colon
= strchr(line
, ':');
1516 if (colon
== NULL
) {
1517 // bogus line -- ignore
1521 fieldName
.SetTo(line
, colon
- line
);
1522 fieldName
= trim_string(line
, colon
- line
);
1523 if (fieldName
.Length() == 0) {
1524 // invalid field name
1528 fieldValue
= colon
+ 1;
1530 if (fieldName
== "Package") {
1531 // flush the current package
1532 _AddPackageCredit(PackageCredit(package
));
1533 package
.MakeEmpty();
1537 // flush current package
1538 _AddPackageCredit(PackageCredit(package
));
1544 AboutView::_AddPackageCreditEntries()
1546 // sort the packages case-insensitively
1547 PackageCredit
* packages
[fPackageCredits
.size()];
1549 for (PackageCreditMap::iterator it
= fPackageCredits
.begin();
1550 it
!= fPackageCredits
.end(); ++it
) {
1551 packages
[count
++] = it
->second
;
1555 std::sort(packages
, packages
+ count
,
1556 &PackageCredit::NameLessInsensitive
);
1560 for (int32 i
= 0; i
< count
; i
++) {
1561 PackageCredit
* package
= packages
[i
];
1563 BString
text(package
->CopyrightAt(0));
1564 int32 count
= package
->CountCopyrights();
1565 for (int32 i
= 1; i
< count
; i
++)
1566 text
<< "\n" << package
->CopyrightAt(i
);
1568 AddCopyrightEntry(package
->PackageName(), text
.String(),
1569 package
->Licenses(), package
->Sources(), package
->URL());
1575 AboutView::_AddPackageCredit(const PackageCredit
& package
)
1577 if (!package
.IsValid())
1580 PackageCreditMap::iterator it
= fPackageCredits
.find(package
.PackageName());
1581 if (it
!= fPackageCredits
.end()) {
1582 // If the new package credit isn't "better" than the old one, ignore it.
1583 PackageCredit
* oldPackage
= it
->second
;
1584 if (!package
.IsBetterThan(*oldPackage
))
1587 // replace the old credit
1588 fPackageCredits
.erase(it
);
1592 fPackageCredits
[package
.PackageName()] = new PackageCredit(package
);
1600 MemSizeToString(char string
[], size_t size
, system_info
* info
)
1602 int inaccessibleMemory
= int(info
->ignored_pages
1603 * (B_PAGE_SIZE
/ 1048576.0f
) + 0.5f
);
1604 if (inaccessibleMemory
> 0) {
1605 BString
message(B_TRANSLATE("%total MiB total, %inaccessible MiB "
1608 snprintf(string
, size
, "%d", int((info
->max_pages
1609 + info
->ignored_pages
) * (B_PAGE_SIZE
/ 1048576.0f
) + 0.5f
));
1610 message
.ReplaceFirst("%total", string
);
1612 snprintf(string
, size
, "%d", inaccessibleMemory
);
1613 message
.ReplaceFirst("%inaccessible", string
);
1614 strncpy(string
, message
.String(), size
);
1616 snprintf(string
, size
, B_TRANSLATE("%d MiB total"),
1617 int(info
->max_pages
* (B_PAGE_SIZE
/ 1048576.0f
) + 0.5f
));
1625 MemUsageToString(char string
[], size_t size
, system_info
* info
)
1627 snprintf(string
, size
, B_TRANSLATE("%d MiB used (%d%%)"),
1628 int(info
->used_pages
* (B_PAGE_SIZE
/ 1048576.0f
) + 0.5f
),
1629 int(100 * info
->used_pages
/ info
->max_pages
));
1636 UptimeToString(char string
[], size_t size
)
1638 BDurationFormat formatter
;
1641 bigtime_t uptime
= system_time();
1642 bigtime_t now
= (bigtime_t
)time(NULL
) * 1000000;
1643 formatter
.Format(str
, now
- uptime
, now
);
1644 str
.CopyInto(string
, 0, size
);
1645 string
[std::min((size_t)str
.Length(), size
)] = '\0';