vfs: check userland buffers before reading them.
[haiku.git] / headers / private / interface / DecorInfo.h
blobcb2cb52a74e2734a99fa99ac5ac51302248dedd7
1 /*
2 * Public domain source code.
4 * Author:
5 * Joseph "looncraz" Groover <looncraz@satx.rr.com>
6 */
7 #ifndef DECOR_INFO_H
8 #define DECOR_INFO_H
11 #include <Directory.h>
12 #include <Entry.h>
13 #include <Locker.h>
14 #include <ObjectList.h>
15 #include <String.h>
18 class BWindow;
21 namespace BPrivate {
24 // NOTE: DecorInfo itself is not thread-safe
25 class DecorInfo {
26 public:
27 DecorInfo();
28 DecorInfo(const BString& path);
29 DecorInfo(const entry_ref& ref);
30 ~DecorInfo();
32 status_t SetTo(const entry_ref& ref);
33 status_t SetTo(BString path);
34 status_t InitCheck() const;
35 void Unset();
37 bool IsDefault() const;
39 BString Path() const;
40 // Returns "Default" for the default decorator
42 const entry_ref* Ref() const;
43 // Returns NULL if virtual (default) or InitCheck() != B_OK
44 // The ref returned may NOT be the same as the one given to
45 // SetTo or the constructor - we may have traversed a Symlink!
47 BString Name() const;
48 BString ShortcutName() const;
50 BString Authors() const;
51 BString ShortDescription() const;
52 BString LongDescription() const;
53 BString LicenseURL() const;
54 BString LicenseName() const;
55 BString SupportURL() const;
57 float Version() const;
58 time_t ModificationTime() const;
60 bool CheckForChanges(bool &deleted);
62 private:
63 void _Init(bool is_update = false);
65 private:
66 entry_ref fRef;
68 BString fPath;
69 BString fName;
70 BString fAuthors;
71 BString fShortDescription;
72 BString fLongDescription;
73 BString fLicenseURL;
74 BString fLicenseName;
75 BString fSupportURL;
77 float fVersion;
79 time_t fModificationTime;
81 status_t fInitStatus;
85 class DecorInfoUtility {
86 public:
87 DecorInfoUtility(bool scanNow = true);
88 // NOTE: When scanNow is passed false,
89 // scanning will be performed lazily, such
90 // as in CountDecorators() and other
91 // methods.
93 ~DecorInfoUtility();
95 status_t ScanDecorators();
96 // Can also be used to rescan for changes.
97 // Warning: potentially destructive as we
98 // will remove all DecorInfo objects which
99 // no longer have a file system cousin.
100 // TODO: Would a call-back mechanism be
101 // worthwhile here?
103 int32 CountDecorators();
105 DecorInfo* DecoratorAt(int32);
107 DecorInfo* FindDecorator(const BString& string);
108 // Checks for ref.name, path, fName, and
109 // "Default," an empty-string returns the
110 // current decorator NULL on match failure
112 DecorInfo* CurrentDecorator();
113 DecorInfo* DefaultDecorator();
115 bool IsCurrentDecorator(DecorInfo* decor);
117 status_t SetDecorator(DecorInfo* decor);
118 status_t SetDecorator(int32);
120 status_t Preview(DecorInfo* decor, BWindow* window);
122 private:
123 DecorInfo* _FindDecor(const BString& path);
125 status_t _ScanDecorators(BDirectory decoratorDirectory);
127 private:
128 BObjectList<DecorInfo> fList;
129 BLocker fLock;
130 bool fHasScanned;
134 } // namespace BPrivate
137 using BPrivate::DecorInfo;
138 using BPrivate::DecorInfoUtility;
141 #endif // DECOR_INFO_H