home *** CD-ROM | disk | FTP | other *** search
- /*
- * This sourcecode is part of FileSpy, a logfile observing utility.
- * Copyright (C) 1996 Felix Rauch
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Notice that this program may not be possessed, used, copied,
- * distributed or modified by people having to do with nuclear
- * weapons. See the file CONDITIONS for details.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * To contact the original author, try:
- * e-mail: Felix.Rauch@nice.ch
- * Traditional mail: Felix Rauch
- * Sempacherstrasse 33
- * 8032 Zurich
- * Switzerland
- */
-
- #import <appkit/appkit.h>
- #import <objc/List.h>
- #import <objc/Storage.h>
- #import <defaults/defaults.h>
- #import <dpsclient/dpsNeXT.h>
- #import <soundkit/Sound.h>
- #import <sys/stat.h>
- #import <sys/types.h>
- #import <pwd.h>
- #import <stdio.h>
- #import <ansi/stdlib.h>
- #import <limits.h>
-
- #ifdef DEBUG
- #include <assert.h>
- #endif
-
- #import "SpyTextFieldCell.h"
- #import "MyScrollView.h"
- #import "Finder.h"
- #import "MyMatrix.h"
- #import "ExistenceTextFieldCell.h"
- #import "SimpleMatrix.h"
-
- #define FILTER_DONTCOPY 0
- #define FILTER_DONTBEEP 1
-
- #define SPY_CONTENTS 1
- #define SPY_EXISTENCE 2
-
- #define MAXSTRLEN 256
-
- extern const char versionString[];
-
- @interface Controller:Object
- {
- id myScrollView;
- id myTextField;
- id myWindow;
- id myMatrix;
- id myAddButton;
- id radioMatrix;
- id popupSwitch;
- id superlogSwitch; // superlog is the old name for multilog
- id filterSwitch;
- id dontCopySwitch;
- id superFilenameButton; // tri-state button for how-is-filename-in-superlog
- id spytypeButton; // tri-state button about what to spy
- id infoPanel;
- id preferencesPanel;
- id inspectorPanel;
- id findPanel;
- id finder;
- id secsTextField;
- id secsScroller;
- id maxLinesTextField;
- id maxLinesScroller;
- id maxLinesMatrix;
- id soundButton;
- id fileListButton;
- id prefPopupSwitch;
- id prefSoundButton;
- id prefSuperlogSwitch;
- id prefRadioMatrix;
- id prefFilterSwitch;
- id prefDontCopySwitch;
- id prefSuperFilenameButton; // wether filenames should be copied
- id prefSpytypeButton; // what to spy
- id superPopupSwitch;
- id superSoundSwitch;
- id superFilterSwitch;
- id superDupSwitch; // 'No duplicated lines'
- id timeSwitch; // print timestamp in log?
- id prefTimeSwitch; // same for preferences
- id showTimeSwitch; // show duration of change in Existencelog?
- id filterWindow;
- id filterText;
- id filterModeMatrix;
- id keySwitch;
- id stateSwitch;
- id infoPanelName;
- id infoPanelAddress;
- id prefGenView; // for the preferences panel handling
- id prefNewView;
- id prefSuperView;
- id prefSwapfileView;
- id prefSwapfileTextField;
- char *swapfilename;
- id prefSwapfileSizeTextField;
- long int swapfilesize;
- BOOL swapfileTooBig, swapfileError;
- id multiView;
- id popButton;
- id versionTextField;
- id superColorWell;
- id prefColorWell;
- id fontTextField; // preview-textfield in inspector
- id prefFontTextField; // preview-textfield in preferences
- id fontButton; // 'Set...' button in inspector
- id prefFontButton; // 'Set...' button in preferences
- id myFontManager; // the Fontmanager object
- id inspectorMultiView; // the inspectorPanel's view
- id inspectorNormalView; // the usual inspectorView
- id inspectorNoView; // 'No Inspector'
- id inspectorName; // textField for file's name
- id inspectorFile; // textField for "File[s]"
- id existencelogWindow;
- id myExistenceScrollView;
- id myExistenceMatrix;
- unsigned fileCount, oldFileCount;
- double secs;
- DPSTimedEntry alarmTimedEntry;
- BOOL running, saveFileList;
- BOOL prefPopup, prefBeepOnChange, prefSuperlog, prefUseFilter;
- BOOL prefDontCopySuperlog; // don't copy to superlog on startup
- int prefFileMode, filterMode;
- NXCoord winx, winy;
- id superFont, superDoc, superWindow, superScrollView, superText;
- id lastSuperlogUser;
- Storage *filterStore;
- BOOL superPopup, superBeepOnChange, superUseFilter, useFilter;
- BOOL displayCurWindow, whileInit, becomeKey, saveState, newFileOffset;
- BOOL filterIsUpToDate;
- BOOL prefTimeStamp; // print time in log?
- unsigned int prefSuperCopyFilename;
- char frameStr[NX_MAXFRAMESTRINGLENGTH];
- id firstFileStore;
- NXColor prefColor;
- id prefFont;
- int maxLines; // how many lines in a log window?
- BOOL maxLineState; // do we use this feature anyway?
- BOOL myWindowIsVisible; // set to NO as soon as it willClose
- BOOL noDuplicatedLines;
- unsigned short int prefSpytype; // check for existence-Flags;
- char *inspectorFrame; // frame of inspectorPanel
- // Next line is no longer needed, as we're geting that text directly from the Text object.
- // char *lastSuperlogString; // the last line which was logged in superlog
- unsigned int nrOpenWindows; // number of open windows
- List *tmpList;
- BOOL existenceSeen;
- id mySound;
- id soundTextField;
- id commandTextField;
- BOOL showTime; // show duration of change in ExistenceLog?
- id conditionsWindow;
- id copyingWindow;
- id helpWindow;
- id helpText;
- }
-
- - showPreferences:sender;
-
- - appWillInit:sender;
- - appDidInit:sender;
- - appWillTerminate:sender;
- - app:sender powerOffIn:(int)ms andSave:(int)aFlag;
- - free;
- - (BOOL)appAcceptsAnotherFile:sender;
- - (int)app:sender openFile:(const char *)filename type:(const char *)aType;
- - addFileWithName:(const char *)name;
- - addFile:sender;
- - deleteFile:sender;
- - chooseFile:sender;
- - singleClick:sender;
- - doubleClick:sender;
- - radioClick:sender;
- - superlogClick:sender;
- - autoPopUpClick:sender;
- - beepOnChangeClick:sender;
- - useFilterClick:sender;
- - superFilenameClick:sender; // wether filenames should be copied in superlog
- - prefSuperFilenameClick:sender;// .. same in preferences
- - timeClick:sender;
- - prefTimeClick:sender;
- - spytypeClick:sender; // spy for existence?
- - prefSpytypeClick:sender; // .. same in preferences
- - colorChanged:sender; // textcolor for superlog
- - prefColorChanged:sender; // .. same in preferences
- - (NXColor)prefColor; // color in preferences, not used yet
- - changeFont:sender; // received from FontManager?
- - filterModeClick:sender;
- - prefRadioClick:sender;
- - prefSuperlogClick:sender;
- - prefAutoPopUpClick:sender;
- - prefBeepOnChangeClick:sender;
- - prefUseFilterClick:sender;
- - superAutoPopUpClick:sender;
- - superBeepOnChangeClick:sender;
- - superUseFilterClick:sender;
- - superDupLinesClick:sender;
- - copySuperlogClick:sender;
- - prefCopySuperlogClick:sender;
- - keyClick:sender;
- - stateClick:sender;
- - saveFileListClick:sender;
- - setShowTimeClick:sender;
- - (BOOL)showTime;
- - changeUpdatePeriod:sender;
- - setPref:sender;
- - setPrefToView:sender;
- - savePreferences:sender;
- - saveFilter:sender;
- - loadPreferences:sender;
- - startSpy; // start DPSTimedEntry anyway
- - startSpyIfNeeded; // start DPSTimedEntry if there is at least 1 File to spy
- - stopSpy; // stop TimedEntry
- - stopSpyIfNeeded; // stop TimedEntry if there's no file left to spy
- - checkFiles; // check the files for changes
- - changeUpdatePeriod:sender;
- - changeBeepState:sender;
- - showSuperlog:sender;
- - updateSuperlog:sender:(char *)newText :(BOOL)changed :(BOOL)beepThis :(BOOL)popThis;
- - setupSuperlog;
- - setupFilter;
- - showFilter:sender;
- - applyFilter:sender;
- - (BOOL)filterString:(char *)str andRemove:(BOOL)rm who:sender;
- // (returns YES if something passes the filter)
- - (int)filterMode;
- - (BOOL)superUsesFilter;
- - (BOOL)becomeKey;
- - unhideApp:sender;
- - clearBuffer:sender;
- - windowDidBecomeKey:sender;
- - windowWillClose:sender;
- - showInspectorPanel:sender;
- - setInspectorToView:theView;
- - showFindPanel:sender;
- - findNext:sender;
- - findPrevious:sender;
- - enterSelection:sender;
- - jumpToSelection:sender;
- - findTexts:(BOOL)all; // return list with all text-objects to scan with find
- - showFontPanel:sender; // send orderFrontFontPanel from myFontmanager
- - setMaxLines:sender;
- - (int)maxLines;
- - shortSuperText;
- - addWindow:sender; // for counting the visible windows
- - existenceMatrix;
- - showExistencelogRegardless;
- - window;
- @end
-
- // C functions
-
- void alarmHandler(DPSTimedEntry te, double timeNow, void *data);
-
- @interface Controller(Services)
- - registerServices:sender;
- - validRequestorForSendType:(NXAtom)typeSent andReturnType:(NXAtom)typeReturned;
- - (BOOL)writeSelectionToPasteboard:(Pasteboard *)pboard types:(NXAtom *)types;
- - spyFileFromService:pasteboard userData:(const char *)userData error:(char **)msg;
- @end
-
- @interface Controller(Sounds)
- - soundClick:sender;
- - setSoundClick:sender;
- - setSound:(const char *)file;
- - nxbeep;
- - (const char *)soundName;
- @end
-
- @interface Controller(Info)
- - loadInfo;
- - showInfo:sender;
- - showConditions:sender;
- - showCopying:sender;
- - showHelp:sender;
- @end
-
- @interface Controller(Swapfile)
- - swapfilenameClick:sender;
- - swapfileSetNameClick:sender;
- - swapfilesizeClick:sender;
- - updateSwapfile;
- @end
-