home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************************/
- /* */
- /* Module Name: SetHooksw */
- /* */
- /* File Name: SetHooksw.c */
- /* */
- /* © Apple Computer, Inc. 1991-1995 */
- /* All Rights Reserved */
- /* */
- /* Revision History: */
- /* */
- /* Date Who Modification */
- /* */
- /* 1991-08-14 Chris Halim Original version */
- /* 1995-06-26 Jaakko Railo Version 2.0 */
- /* */
- /************************************************************************************************/
-
- /****************************************** DESCRIPTION ******************************************
-
- *************************************************************************************************/
-
- /******************************************** HEADERS *******************************************/
-
- #include "TextUtils.h"
-
- #ifndef __TELEPHONES__
- #include "Telephones.h"
- #endif
-
- #include "TestModule.h"
-
- /****************************************** DEFINITIONS *****************************************/
-
- #define rDisplayHookswDLOG 10000
- #define kNumber 3
- #define kOnHookItem 1
- #define kOffHookItem 5
-
- /****************************************** PROTOTYPES ******************************************/
-
- short DisplayHooksw (short * htype);
- void DoTest (CHRSPtr paramPtr);
-
- /************************************************************************************************/
- /************************************************************************************************/
-
-
- pascal short TestModule (CHRSPtr paramPtr)
- {
- short returnValue = noErr;
-
- if (paramPtr->version <= kTestModuleVersion) {
-
- DoTest (paramPtr);
-
- }
- else
- returnValue = kWrongVersion;
-
- return (returnValue);
- }
-
-
- short DisplayHooksw (short * number)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
- short itemHit;
- DialogPtr theDialog;
- Str255 itemStr;
- long tlong;
-
- if ((theDialog = GetNewDialog (rDisplayHookswDLOG, nil, (WindowPtr)(-1L))) != nil) {
- GetDItem (theDialog, kNumber, &itemKind, &itemHand, &itemRect);
- SelIText (theDialog, kNumber, 0, 32767);
-
- ShowWindow (theDialog);
-
- ModalDialog (nil, &itemHit);
-
- if ((itemHit == kOnHookItem) || (itemHit == kOffHookItem)) {
- GetDItem (theDialog, kNumber, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, itemStr);
- StringToNum (itemStr, &tlong);
- *number = tlong;
- }
-
- DisposeDialog (theDialog);
- }
- else
- itemHit = -1;
-
- return (itemHit);
- }
-
-
- void DoTest (CHRSPtr paramPtr)
- {
- TELHandle termHand = GetCurrentTELHandle (paramPtr);
- short itemHit, htype;
- OSErr errCode;
- Boolean onHook;
-
- itemHit = DisplayHooksw (&htype);
- if ((itemHit == kOnHookItem) || (itemHit == kOffHookItem)) {
-
- onHook = (itemHit == kOnHookItem)?telDeviceOnHook:telDeviceOffHook;
-
- if ((errCode = TELSetHooksw (termHand, htype, onHook)) == noErr)
- Print (paramPtr, "TELSetHooksw --> hookState = %s",
- ((onHook==telDeviceOnHook)?"telDeviceOnHook":"telDeviceOffHook"));
- else
- Print (paramPtr, "### TELSetHooksw failed : %d", errCode);
- }
- else
- if (itemHit == -1)
- Print (paramPtr, "### Unable to get a DLOG resource");
- }
-
-
-