xref: /haiku/headers/os/package/RepositoryInfo.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright 2011-2018, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__REPOSITORY_INFO_H_
6 #define _PACKAGE__REPOSITORY_INFO_H_
7 
8 
9 #include <Archivable.h>
10 #include <Entry.h>
11 #include <StringList.h>
12 #include <String.h>
13 
14 #include <package/PackageArchitecture.h>
15 
16 
17 namespace BPackageKit {
18 
19 
20 class BRepositoryInfo : public BArchivable {
21 	typedef	BArchivable			inherited;
22 
23 public:
24 								BRepositoryInfo();
25 								BRepositoryInfo(BMessage* data);
26 								BRepositoryInfo(const BEntry& entry);
27 	virtual						~BRepositoryInfo();
28 
29 	virtual	status_t			Archive(BMessage* data, bool deep = true) const;
30 
31 			status_t			SetTo(const BMessage* data);
32 			status_t			SetTo(const BEntry& entry);
33 			status_t			InitCheck() const;
34 
35 			const BString&		Name() const;
36 			const BString&		BaseURL() const;
37 			const BString&		Identifier() const;
38 			const BString&		Vendor() const;
39 			const BString&		Summary() const;
40 			uint8				Priority() const;
41 			BPackageArchitecture	Architecture() const;
42 			const BStringList&	LicenseNames() const;
43 			const BStringList&	LicenseTexts() const;
44 
45 			void				SetName(const BString& name);
46 			void				SetBaseURL(const BString& url);
47 			void				SetIdentifier(const BString& url);
48 			void				SetVendor(const BString& vendor);
49 			void				SetSummary(const BString& summary);
50 			void				SetPriority(uint8 priority);
51 			void				SetArchitecture(BPackageArchitecture arch);
52 
53 			status_t			AddLicense(const BString& licenseName,
54 									const BString& licenseText);
55 			void				ClearLicenses();
56 
57 public:
58 	static	BRepositoryInfo*	Instantiate(BMessage* data);
59 
60 	static	const uint8			kDefaultPriority;
61 
62 	static	const char* const	kNameField;
63 	static	const char* const	kURLField;
64 	static	const char* const	kIdentifierField;
65 	static	const char* const	kBaseURLField;
66 	static	const char* const	kVendorField;
67 	static	const char*	const	kSummaryField;
68 	static	const char*	const	kPriorityField;
69 	static	const char*	const	kArchitectureField;
70 	static	const char*	const	kLicenseNameField;
71 	static	const char*	const	kLicenseTextField;
72 
73 private:
74 			status_t			_SetTo(const BMessage* data);
75 			status_t			_SetTo(const BEntry& entry);
76 
77 private:
78 			status_t			fInitStatus;
79 
80 			BString				fName;
81 			BString				fBaseURL;
82 				// This is the URL to a single mirror.  This field is optional.
83 			BString				fIdentifier;
84 				// This is an identifier in the form of an URI for the
85 				// repository, that applies across mirrors. Good choices of
86 				// URI schemes are tag: and uuid:, for example.
87 			BString				fVendor;
88 			BString				fSummary;
89 			uint8				fPriority;
90 			BPackageArchitecture	fArchitecture;
91 			BStringList			fLicenseNames;
92 			BStringList			fLicenseTexts;
93 };
94 
95 
96 }	// namespace BPackageKit
97 
98 
99 #endif // _PACKAGE__REPOSITORY_INFO_H_
100