home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Utilities / FileSpy-1.1-MIHS / Controller.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-22  |  9.0 KB  |  307 lines

  1. /*
  2.  *   This sourcecode is part of FileSpy, a logfile observing utility.
  3.  *   Copyright (C) 1996  Felix Rauch
  4.  *
  5.  *   This program is free software; you can redistribute it and/or modify
  6.  *   it under the terms of the GNU General Public License as published by
  7.  *   the Free Software Foundation; either version 2 of the License, or
  8.  *   (at your option) any later version.
  9.  *   
  10.  *   Notice that this program may not be possessed, used, copied,
  11.  *   distributed or modified by people having to do with nuclear
  12.  *   weapons. See the file CONDITIONS for details.
  13.  *
  14.  *   This program is distributed in the hope that it will be useful,
  15.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  *   GNU General Public License for more details.
  18.  *
  19.  *   You should have received a copy of the GNU General Public License
  20.  *   along with this program; if not, write to the Free Software
  21.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  *
  23.  *   To contact the original author, try:
  24.  *   e-mail: Felix.Rauch@nice.ch
  25.  *   Traditional mail:    Felix Rauch
  26.  *            Sempacherstrasse 33
  27.  *            8032 Zurich
  28.  *            Switzerland
  29.  */
  30.  
  31. #import <appkit/appkit.h>
  32. #import <objc/List.h>
  33. #import <objc/Storage.h>
  34. #import <defaults/defaults.h>
  35. #import <dpsclient/dpsNeXT.h>
  36. #import <soundkit/Sound.h>
  37. #import <sys/stat.h>
  38. #import <sys/types.h>
  39. #import <pwd.h>
  40. #import <stdio.h>
  41. #import <ansi/stdlib.h>
  42. #import <limits.h>
  43.  
  44. #ifdef DEBUG
  45.     #include <assert.h>
  46. #endif
  47.  
  48. #import "SpyTextFieldCell.h"
  49. #import "MyScrollView.h"
  50. #import "Finder.h"
  51. #import "MyMatrix.h"
  52. #import "ExistenceTextFieldCell.h"
  53. #import "SimpleMatrix.h"
  54.  
  55. #define FILTER_DONTCOPY 0
  56. #define FILTER_DONTBEEP 1
  57.  
  58. #define SPY_CONTENTS 1
  59. #define SPY_EXISTENCE 2
  60.  
  61. #define MAXSTRLEN 256
  62.  
  63. extern const char versionString[];
  64.  
  65. @interface Controller:Object
  66. {
  67.     id myScrollView;
  68.     id myTextField;
  69.     id myWindow;
  70.     id myMatrix;
  71.     id myAddButton;
  72.     id radioMatrix;
  73.     id popupSwitch;
  74.     id superlogSwitch;        // superlog is the old name for multilog
  75.     id filterSwitch;
  76.     id dontCopySwitch;
  77.     id superFilenameButton;        // tri-state button for how-is-filename-in-superlog
  78.     id spytypeButton;        // tri-state button about what to spy
  79.     id infoPanel;
  80.     id preferencesPanel;
  81.     id inspectorPanel;
  82.     id findPanel;
  83.     id finder;
  84.     id secsTextField;
  85.     id secsScroller;
  86.     id maxLinesTextField;
  87.     id maxLinesScroller;
  88.     id maxLinesMatrix;
  89.     id soundButton;
  90.     id fileListButton;
  91.     id prefPopupSwitch;
  92.     id prefSoundButton;
  93.     id prefSuperlogSwitch;
  94.     id prefRadioMatrix;
  95.     id prefFilterSwitch;
  96.     id prefDontCopySwitch;
  97.     id prefSuperFilenameButton;    // wether filenames should be copied
  98.     id prefSpytypeButton;        // what to spy
  99.     id superPopupSwitch;
  100.     id superSoundSwitch;
  101.     id superFilterSwitch;
  102.     id superDupSwitch;        // 'No duplicated lines'
  103.     id timeSwitch;            // print timestamp in log?
  104.     id prefTimeSwitch;        // same for preferences
  105.     id showTimeSwitch;        // show duration of change in Existencelog?
  106.     id filterWindow;
  107.     id filterText;
  108.     id filterModeMatrix;
  109.     id keySwitch;
  110.     id stateSwitch;
  111.     id infoPanelName;
  112.     id infoPanelAddress;
  113.     id prefGenView;        // for the preferences panel handling
  114.     id prefNewView;
  115.     id prefSuperView;
  116.     id prefSwapfileView;
  117.     id prefSwapfileTextField;
  118.     char *swapfilename;
  119.     id prefSwapfileSizeTextField;
  120.     long int swapfilesize;
  121.     BOOL swapfileTooBig, swapfileError;
  122.     id multiView;
  123.     id popButton;
  124.     id versionTextField;
  125.     id superColorWell;
  126.     id prefColorWell;
  127.     id fontTextField;        // preview-textfield in inspector
  128.     id prefFontTextField;        // preview-textfield in preferences
  129.     id fontButton;            // 'Set...' button in inspector
  130.     id prefFontButton;        // 'Set...' button in preferences
  131.     id myFontManager;        // the Fontmanager object
  132.     id inspectorMultiView;        // the inspectorPanel's view
  133.     id inspectorNormalView;        // the usual inspectorView
  134.     id inspectorNoView;        // 'No Inspector'
  135.     id inspectorName;        // textField for file's name
  136.     id inspectorFile;        // textField for "File[s]"
  137.     id existencelogWindow;
  138.     id myExistenceScrollView;
  139.     id myExistenceMatrix;
  140.     unsigned fileCount, oldFileCount;
  141.     double secs;
  142.     DPSTimedEntry alarmTimedEntry;
  143.     BOOL running, saveFileList;
  144.     BOOL prefPopup, prefBeepOnChange, prefSuperlog, prefUseFilter;
  145.     BOOL prefDontCopySuperlog;    // don't copy to superlog on startup
  146.     int prefFileMode, filterMode;
  147.     NXCoord winx, winy;
  148.     id superFont, superDoc, superWindow, superScrollView, superText;
  149.     id lastSuperlogUser;
  150.     Storage *filterStore;
  151.     BOOL superPopup, superBeepOnChange, superUseFilter, useFilter;
  152.     BOOL displayCurWindow, whileInit, becomeKey, saveState, newFileOffset;
  153.     BOOL filterIsUpToDate;
  154.     BOOL prefTimeStamp;        // print time in log?
  155.     unsigned int prefSuperCopyFilename;
  156.     char frameStr[NX_MAXFRAMESTRINGLENGTH];
  157.     id firstFileStore;
  158.     NXColor prefColor;
  159.     id prefFont;
  160.     int maxLines;        // how many lines in a log window?
  161.     BOOL maxLineState;    // do we use this feature anyway?
  162.     BOOL myWindowIsVisible;    // set to NO as soon as it willClose
  163.     BOOL noDuplicatedLines;
  164.     unsigned short int prefSpytype;    // check for existence-Flags;
  165.     char *inspectorFrame;        // frame of inspectorPanel
  166. // Next line is no longer needed, as we're geting that text directly from the Text object.
  167. //    char *lastSuperlogString;    // the last line which was logged in superlog
  168.     unsigned int nrOpenWindows;    // number of open windows
  169.     List *tmpList;
  170.     BOOL existenceSeen;
  171.     id mySound;
  172.     id soundTextField;
  173.     id commandTextField;
  174.     BOOL showTime;        // show duration of change in ExistenceLog?
  175.     id conditionsWindow;
  176.     id copyingWindow;
  177.     id helpWindow;
  178.     id helpText;
  179. }
  180.  
  181. - showPreferences:sender;
  182.  
  183. - appWillInit:sender;
  184. - appDidInit:sender;
  185. - appWillTerminate:sender;
  186. - app:sender powerOffIn:(int)ms andSave:(int)aFlag;
  187. - free;
  188. - (BOOL)appAcceptsAnotherFile:sender;
  189. - (int)app:sender openFile:(const char *)filename type:(const char *)aType;
  190. - addFileWithName:(const char *)name;
  191. - addFile:sender;
  192. - deleteFile:sender;
  193. - chooseFile:sender;
  194. - singleClick:sender;
  195. - doubleClick:sender;
  196. - radioClick:sender;
  197. - superlogClick:sender;
  198. - autoPopUpClick:sender;
  199. - beepOnChangeClick:sender;
  200. - useFilterClick:sender;
  201. - superFilenameClick:sender;    // wether filenames should be copied in superlog
  202. - prefSuperFilenameClick:sender;// .. same in preferences
  203. - timeClick:sender;
  204. - prefTimeClick:sender;
  205. - spytypeClick:sender;        // spy for existence?
  206. - prefSpytypeClick:sender;    // .. same in preferences
  207. - colorChanged:sender;        // textcolor for superlog
  208. - prefColorChanged:sender;    // .. same in preferences
  209. - (NXColor)prefColor;        // color in preferences, not used yet
  210. - changeFont:sender;        // received from FontManager?
  211. - filterModeClick:sender;
  212. - prefRadioClick:sender;
  213. - prefSuperlogClick:sender;
  214. - prefAutoPopUpClick:sender;
  215. - prefBeepOnChangeClick:sender;
  216. - prefUseFilterClick:sender;
  217. - superAutoPopUpClick:sender;
  218. - superBeepOnChangeClick:sender;
  219. - superUseFilterClick:sender;
  220. - superDupLinesClick:sender;
  221. - copySuperlogClick:sender;
  222. - prefCopySuperlogClick:sender;
  223. - keyClick:sender;
  224. - stateClick:sender;
  225. - saveFileListClick:sender;
  226. - setShowTimeClick:sender;
  227. - (BOOL)showTime;
  228. - changeUpdatePeriod:sender;
  229. - setPref:sender;
  230. - setPrefToView:sender;
  231. - savePreferences:sender;
  232. - saveFilter:sender;
  233. - loadPreferences:sender;
  234. - startSpy;        // start DPSTimedEntry anyway
  235. - startSpyIfNeeded;    // start DPSTimedEntry if there is at least 1 File to spy
  236. - stopSpy;        // stop TimedEntry
  237. - stopSpyIfNeeded;    // stop TimedEntry if there's no file left to spy
  238. - checkFiles;        // check the files for changes
  239. - changeUpdatePeriod:sender;
  240. - changeBeepState:sender;
  241. - showSuperlog:sender;
  242. - updateSuperlog:sender:(char *)newText :(BOOL)changed :(BOOL)beepThis :(BOOL)popThis;
  243. - setupSuperlog;
  244. - setupFilter;
  245. - showFilter:sender;
  246. - applyFilter:sender;
  247. - (BOOL)filterString:(char *)str andRemove:(BOOL)rm who:sender;
  248.             // (returns YES if something passes the filter)
  249. - (int)filterMode;
  250. - (BOOL)superUsesFilter;
  251. - (BOOL)becomeKey;
  252. - unhideApp:sender;
  253. - clearBuffer:sender;
  254. - windowDidBecomeKey:sender;
  255. - windowWillClose:sender;
  256. - showInspectorPanel:sender;
  257. - setInspectorToView:theView;
  258. - showFindPanel:sender;
  259. - findNext:sender;
  260. - findPrevious:sender;
  261. - enterSelection:sender;
  262. - jumpToSelection:sender;
  263. - findTexts:(BOOL)all;        // return list with all text-objects to scan with find
  264. - showFontPanel:sender;        // send orderFrontFontPanel from myFontmanager
  265. - setMaxLines:sender;
  266. - (int)maxLines;
  267. - shortSuperText;
  268. - addWindow:sender;        // for counting the visible windows
  269. - existenceMatrix;
  270. - showExistencelogRegardless;
  271. - window;
  272. @end
  273.  
  274. // C functions
  275.  
  276. void alarmHandler(DPSTimedEntry te, double timeNow, void *data);
  277.  
  278. @interface Controller(Services)
  279. - registerServices:sender;
  280. - validRequestorForSendType:(NXAtom)typeSent andReturnType:(NXAtom)typeReturned;
  281. - (BOOL)writeSelectionToPasteboard:(Pasteboard *)pboard types:(NXAtom *)types;
  282. - spyFileFromService:pasteboard userData:(const char *)userData error:(char **)msg;
  283. @end
  284.  
  285. @interface Controller(Sounds)
  286. - soundClick:sender;
  287. - setSoundClick:sender;
  288. - setSound:(const char *)file;
  289. - nxbeep;
  290. - (const char *)soundName;
  291. @end
  292.  
  293. @interface Controller(Info)
  294. - loadInfo;
  295. - showInfo:sender;
  296. - showConditions:sender;
  297. - showCopying:sender;
  298. - showHelp:sender;
  299. @end
  300.  
  301. @interface Controller(Swapfile)
  302. - swapfilenameClick:sender;
  303. - swapfileSetNameClick:sender;
  304. - swapfilesizeClick:sender;
  305. - updateSwapfile;
  306. @end
  307.