10f11a95aSJérôme Duval /* 20f11a95aSJérôme Duval * Copyright 2004-2006, Jérôme Duval. All rights reserved. 30f11a95aSJérôme Duval * Distributed under the terms of the MIT License. 40f11a95aSJérôme Duval */ 555a5a6bdSJérôme Duval 62cf916cbSIngo Weinhold 7*e326cef6SJohn Scipione #ifndef _EXPANDER_RULES_H 8*e326cef6SJohn Scipione #define _EXPANDER_RULES_H 955a5a6bdSJérôme Duval 1055a5a6bdSJérôme Duval #include <File.h> 1155a5a6bdSJérôme Duval #include <FilePanel.h> 122cf916cbSIngo Weinhold #include <List.h> 132cf916cbSIngo Weinhold #include <Mime.h> 142cf916cbSIngo Weinhold #include <String.h> 152cf916cbSIngo Weinhold 1655a5a6bdSJérôme Duval 1755a5a6bdSJérôme Duval class ExpanderRule { 1855a5a6bdSJérôme Duval public: 192cf916cbSIngo Weinhold ExpanderRule(const char* mimetype, 20301f4b46SIngo Weinhold const BString& filenameExtension, 21*e326cef6SJohn Scipione const BString& listingCommand, 22*e326cef6SJohn Scipione const BString& expandCommand); 232cf916cbSIngo Weinhold MimeType()242cf916cbSIngo Weinhold const BMimeType& MimeType() const 252cf916cbSIngo Weinhold { return fMimeType; } FilenameExtension()262cf916cbSIngo Weinhold const BString& FilenameExtension() const 272cf916cbSIngo Weinhold { return fFilenameExtension; } ListingCmd()282cf916cbSIngo Weinhold const BString& ListingCmd() const 292cf916cbSIngo Weinhold { return fListingCmd; } ExpandCmd()302cf916cbSIngo Weinhold const BString& ExpandCmd() const 312cf916cbSIngo Weinhold { return fExpandCmd; } 322cf916cbSIngo Weinhold 3355a5a6bdSJérôme Duval private: 3455a5a6bdSJérôme Duval BMimeType fMimeType; 3555a5a6bdSJérôme Duval BString fFilenameExtension; 3655a5a6bdSJérôme Duval BString fListingCmd; 3755a5a6bdSJérôme Duval BString fExpandCmd; 3855a5a6bdSJérôme Duval }; 3955a5a6bdSJérôme Duval 4055a5a6bdSJérôme Duval 4155a5a6bdSJérôme Duval class ExpanderRules { 4255a5a6bdSJérôme Duval public: 4355a5a6bdSJérôme Duval ExpanderRules(); 4455a5a6bdSJérôme Duval ~ExpanderRules(); 4555a5a6bdSJérôme Duval 462cf916cbSIngo Weinhold ExpanderRule* MatchingRule(BString& fileName, 472cf916cbSIngo Weinhold const char* filetype); 482cf916cbSIngo Weinhold ExpanderRule* MatchingRule(const entry_ref* ref); 492cf916cbSIngo Weinhold 502cf916cbSIngo Weinhold private: 51301f4b46SIngo Weinhold void _LoadRulesFiles(); 52301f4b46SIngo Weinhold void _LoadRulesFile(const char* path); 53301f4b46SIngo Weinhold 54301f4b46SIngo Weinhold bool _AddRule(const char* mimetype, 55301f4b46SIngo Weinhold const BString& filenameExtension, 56*e326cef6SJohn Scipione const BString& listingCommand, 57*e326cef6SJohn Scipione const BString& expandCommand); 582cf916cbSIngo Weinhold 592cf916cbSIngo Weinhold private: 6055a5a6bdSJérôme Duval BList fList; 6155a5a6bdSJérôme Duval }; 6255a5a6bdSJérôme Duval 6355a5a6bdSJérôme Duval 6455a5a6bdSJérôme Duval class RuleRefFilter : public BRefFilter { 6555a5a6bdSJérôme Duval public: 6655a5a6bdSJérôme Duval RuleRefFilter(ExpanderRules& rules); 672cf916cbSIngo Weinhold bool Filter(const entry_ref* ref, BNode* node, 68*e326cef6SJohn Scipione struct stat_beos* stat, 69*e326cef6SJohn Scipione const char* filetype); 70*e326cef6SJohn Scipione 7155a5a6bdSJérôme Duval protected: 7255a5a6bdSJérôme Duval ExpanderRules& fRules; 7355a5a6bdSJérôme Duval }; 7455a5a6bdSJérôme Duval 752cf916cbSIngo Weinhold 76*e326cef6SJohn Scipione #endif // _EXPANDER_RULES_H 77