class CacheManagerActionList : public Vector<CacheManagerAction *> {
};
-/// \ingroup CacheManagerInternal
-typedef struct
-{
- StoreEntry *entry;
- char *action;
- char *user_name;
- char *passwd;
-} cachemgrStateData;
-
/**
\ingroup CacheManagerAPI
* a CacheManager - the menu system for interacting with squid.
const char *ActionProtection(const CacheManagerAction * at); //needs to be called from C
protected:
- CacheManager();
- cachemgrStateData* ParseUrl(const char *url);
- void ParseHeaders(cachemgrStateData * mgr, const HttpRequest * request);
- int CheckPassword(cachemgrStateData * mgr);
- char *PasswdGet(cachemgr_passwd *, const char *);
-
// command classes. They are private to the cachemanager because they
// may require access to local data sources, plus we avoid polluting
// the namespace more than needed.
virtual void run (StoreEntry *sentry);
OfflineToggleAction();
};
+ class MenuAction : public CacheManagerAction {
+ public:
+ virtual void run (StoreEntry *sentry);
+ MenuAction();
+ };
+/// \ingroup CacheManagerInternal
+typedef struct
+{
+ StoreEntry *entry;
+ char *action;
+ char *user_name;
+ char *passwd;
+} cachemgrStateData;
+
+
+ CacheManager();
+ cachemgrStateData* ParseUrl(const char *url);
+ void ParseHeaders(cachemgrStateData * mgr, const HttpRequest * request);
+ int CheckPassword(cachemgrStateData * mgr);
+ char *PasswdGet(cachemgr_passwd *, const char *);
private:
static CacheManager* instance;
- //commands need to be static to be able to be referenced as C-style
- //functions. Binding to nonstatic members can be done at runtime
- //via the singleton, but it's syntactic hackery
- //TODO: fix so that ActionTable uses a Command pattern and thus
- // function calls are properly object-wrapped
- static void MenuCommand(StoreEntry *sentry);
-
void StateFree(cachemgrStateData * mgr);
if (ActionsList != NULL)
delete(ActionsList); //TODO: Laaazy. Will be moved to class member
ActionsList = new CacheManagerActionList;
- registerAction("menu", "This Cachemanager Menu", MenuCommand, 0, 1);
- //registerAction("offline_toggle", "Toggle offline_mode setting", OfflineToggleCommand, 1, 1);
registerAction(new OfflineToggleAction);
registerAction(new ShutdownAction);
registerAction(new ReconfigureAction);
+ registerAction(new MenuAction);
}
void
debugs(16, 5, "CacheManager::findAction: looking for action " << action);
for ( a = ActionsList->begin(); a != ActionsList->end(); a++) {
- //debugs(16, 6, " checking against '" << (*a)->action << "'");
if (0 == strcmp((*a)->action, action)) {
debugs(16, 6, " found");
return *a;
}
/// \ingroup CacheManagerInternal
-cachemgrStateData *
+CacheManager::cachemgrStateData *
CacheManager::ParseUrl(const char *url)
{
int t;
/// \ingroup CacheManagerInternal
void
-CacheManager::MenuCommand(StoreEntry * sentry)
+CacheManager::MenuAction::run(StoreEntry * sentry)
{
CacheManagerActionList::iterator a;
(*a)->action, (*a)->desc, CacheManager::GetInstance()->ActionProtection(*a));
}
}
+CacheManager::MenuAction::MenuAction() : CacheManagerAction ("menu", "Cache Manager Menu", 1, 1) { }
/// \ingroup CacheManagerInternal
char *