2011-05-19 19:25:54 +04:00
|
|
|
/*
|
|
|
|
* Public domain source code.
|
|
|
|
*
|
|
|
|
* Author:
|
|
|
|
* Joseph "looncraz" Groover <looncraz@satx.rr.com>
|
|
|
|
*/
|
|
|
|
#ifndef DECOR_INFO_H
|
|
|
|
#define DECOR_INFO_H
|
|
|
|
|
|
|
|
|
2014-02-21 04:23:45 +04:00
|
|
|
#include <Directory.h>
|
2011-05-19 19:25:54 +04:00
|
|
|
#include <Entry.h>
|
|
|
|
#include <Locker.h>
|
|
|
|
#include <ObjectList.h>
|
2011-05-21 22:12:25 +04:00
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BWindow;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPrivate {
|
2011-05-19 19:25:54 +04:00
|
|
|
|
|
|
|
|
|
|
|
// NOTE: DecorInfo itself is not thread-safe
|
|
|
|
class DecorInfo {
|
|
|
|
public:
|
|
|
|
DecorInfo();
|
|
|
|
DecorInfo(const BString& path);
|
|
|
|
DecorInfo(const entry_ref& ref);
|
|
|
|
~DecorInfo();
|
|
|
|
|
|
|
|
status_t SetTo(const entry_ref& ref);
|
|
|
|
status_t SetTo(BString path);
|
|
|
|
status_t InitCheck() const;
|
|
|
|
void Unset();
|
|
|
|
|
|
|
|
bool IsDefault() const;
|
|
|
|
|
|
|
|
BString Path() const;
|
|
|
|
// Returns "Default" for the default decorator
|
|
|
|
|
|
|
|
const entry_ref* Ref() const;
|
|
|
|
// Returns NULL if virtual (default) or InitCheck() != B_OK
|
|
|
|
// The ref returned may NOT be the same as the one given to
|
|
|
|
// SetTo or the constructor - we may have traversed a Symlink!
|
|
|
|
|
|
|
|
BString Name() const;
|
|
|
|
BString ShortcutName() const;
|
|
|
|
|
|
|
|
BString Authors() const;
|
|
|
|
BString ShortDescription() const;
|
|
|
|
BString LongDescription() const;
|
|
|
|
BString LicenseURL() const;
|
|
|
|
BString LicenseName() const;
|
|
|
|
BString SupportURL() const;
|
|
|
|
|
|
|
|
float Version() const;
|
|
|
|
time_t ModificationTime() const;
|
|
|
|
|
|
|
|
bool CheckForChanges(bool &deleted);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void _Init(bool is_update = false);
|
|
|
|
|
|
|
|
private:
|
|
|
|
entry_ref fRef;
|
|
|
|
|
|
|
|
BString fPath;
|
|
|
|
BString fName;
|
|
|
|
BString fAuthors;
|
|
|
|
BString fShortDescription;
|
|
|
|
BString fLongDescription;
|
|
|
|
BString fLicenseURL;
|
|
|
|
BString fLicenseName;
|
|
|
|
BString fSupportURL;
|
|
|
|
|
|
|
|
float fVersion;
|
|
|
|
|
|
|
|
time_t fModificationTime;
|
|
|
|
|
|
|
|
status_t fInitStatus;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-05-21 22:12:25 +04:00
|
|
|
class DecorInfoUtility {
|
2011-05-19 19:25:54 +04:00
|
|
|
public:
|
|
|
|
DecorInfoUtility(bool scanNow = true);
|
|
|
|
// NOTE: When scanNow is passed false,
|
|
|
|
// scanning will be performed lazily, such
|
|
|
|
// as in CountDecorators() and other
|
|
|
|
// methods.
|
|
|
|
|
|
|
|
~DecorInfoUtility();
|
|
|
|
|
|
|
|
status_t ScanDecorators();
|
|
|
|
// Can also be used to rescan for changes.
|
|
|
|
// Warning: potentially destructive as we
|
|
|
|
// will remove all DecorInfo objects which
|
|
|
|
// no longer have a file system cousin.
|
|
|
|
// TODO: Would a call-back mechanism be
|
|
|
|
// worthwhile here?
|
|
|
|
|
|
|
|
int32 CountDecorators();
|
|
|
|
|
|
|
|
DecorInfo* DecoratorAt(int32);
|
|
|
|
|
|
|
|
DecorInfo* FindDecorator(const BString& string);
|
|
|
|
// Checks for ref.name, path, fName, and
|
|
|
|
// "Default," an empty-string returns the
|
|
|
|
// current decorator NULL on match failure
|
|
|
|
|
|
|
|
DecorInfo* CurrentDecorator();
|
|
|
|
DecorInfo* DefaultDecorator();
|
|
|
|
|
2011-05-21 22:12:25 +04:00
|
|
|
bool IsCurrentDecorator(DecorInfo* decor);
|
2011-05-19 19:25:54 +04:00
|
|
|
|
2011-05-21 22:12:25 +04:00
|
|
|
status_t SetDecorator(DecorInfo* decor);
|
2011-05-19 19:25:54 +04:00
|
|
|
status_t SetDecorator(int32);
|
|
|
|
|
|
|
|
status_t Preview(DecorInfo* decor, BWindow* window);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DecorInfo* _FindDecor(const BString& path);
|
|
|
|
|
2014-02-21 04:23:45 +04:00
|
|
|
status_t _ScanDecorators(BDirectory decoratorDirectory);
|
|
|
|
|
2011-05-19 19:25:54 +04:00
|
|
|
private:
|
2011-05-21 22:12:25 +04:00
|
|
|
BObjectList<DecorInfo> fList;
|
|
|
|
BLocker fLock;
|
|
|
|
bool fHasScanned;
|
2011-05-19 19:25:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-05-21 22:12:25 +04:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
|
|
|
|
using BPrivate::DecorInfo;
|
|
|
|
using BPrivate::DecorInfoUtility;
|
|
|
|
|
|
|
|
|
|
|
|
#endif // DECOR_INFO_H
|