home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / CASilenceDetect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-26  |  4.0 KB  |  142 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    CASilenceDetect                                                                */
  4. /*                                                                                                */
  5. /*    File Name:        CASilenceDetect.c                                                            */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1994-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1994-07-15    Jaakko Railo        Original version                                        */
  15. /*                                                                                                */
  16. /************************************************************************************************/
  17.  
  18. /****************************************** DESCRIPTION ******************************************
  19.  
  20. *************************************************************************************************/
  21.  
  22. /******************************************** HEADERS *******************************************/
  23.  
  24. #include "TextUtils.h"
  25.  
  26. #ifndef __TELEPHONES__
  27. #include "Telephones.h"
  28. #endif
  29.  
  30. #include "TestModule.h"
  31.  
  32. /****************************************** DEFINITIONS *****************************************/
  33.  
  34. #define    rDisplaySilenceDetectDLOG    10000
  35. #define    kSilenceDetectOnItem        2
  36. #define    kSilenceDetectOffItem        3
  37. #define    kSilencePeriodItem            5
  38. #define    kSilenceDetectOn            1
  39. #define    kSilenceDetectOff            0
  40.  
  41. /****************************************** PROTOTYPES ******************************************/
  42.  
  43. short    DisplaySilenceDetect (long * silencePeriod);
  44. void     DoTest (CHRSPtr paramPtr);
  45.  
  46. /************************************************************************************************/
  47. /************************************************************************************************/
  48.  
  49.  
  50. pascal short TestModule (CHRSPtr paramPtr)
  51. {
  52.     short    returnValue = noErr;
  53.     
  54.     if (paramPtr->version <= kTestModuleVersion) {
  55.         
  56.         DoTest (paramPtr);
  57.         
  58.     }
  59.     else
  60.         returnValue = kWrongVersion;
  61.         
  62.     return (returnValue);
  63. }
  64.  
  65.  
  66. short DisplaySilenceDetect (long * silencePeriod)
  67. {
  68.     short        itemKind;
  69.     Handle        itemHand;
  70.     Rect        itemRect;
  71.     short        itemHit;
  72.     DialogPtr    theDialog;
  73.     Str255        itemStr;
  74.     long        tlong;
  75.     
  76.     if ((theDialog = GetNewDialog (rDisplaySilenceDetectDLOG, nil, (WindowPtr)(-1L))) != nil) {
  77.         GetDItem (theDialog, kSilencePeriodItem, &itemKind, &itemHand, &itemRect);
  78.         SelIText (theDialog, kSilencePeriodItem, 0, 32767);
  79.         
  80.         ShowWindow (theDialog);
  81.         
  82.         ModalDialog (nil, &itemHit);
  83.         
  84.         if ((itemHit == kSilenceDetectOnItem) || (itemHit == kSilenceDetectOffItem)) {
  85.             GetDItem (theDialog, kSilencePeriodItem, &itemKind, &itemHand, &itemRect);
  86.             GetIText (itemHand, itemStr);
  87.             StringToNum (itemStr, &tlong);
  88.             *silencePeriod = tlong;
  89.         }
  90.         
  91.         DisposeDialog (theDialog);
  92.     }
  93.     else
  94.         itemHit = -1;
  95.     
  96.     return (itemHit);
  97. }
  98.  
  99.  
  100. void DoTest (CHRSPtr paramPtr)
  101. {
  102.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  103.     TELDNHandle    dnHand;
  104.     short        numOfCAs;
  105.     TELCAHandle caHand;
  106.     short        itemHit;
  107.     OSErr        errCode;
  108.     Boolean        silenceDetect;
  109.     long        silencePeriod;
  110.     
  111.     if ((dnHand = GetDNHandle (paramPtr)) != nil) {
  112.  
  113.         if ((numOfCAs = TELCountCAs (dnHand, telAllCallOrigins)) > 0) {
  114.         
  115.             if ((caHand = GetCAHandle (paramPtr)) != nil) {
  116.                 itemHit = DisplaySilenceDetect (&silencePeriod);
  117.                 if ((itemHit == kSilenceDetectOnItem) || (itemHit == kSilenceDetectOffItem)) {
  118.                     
  119.                     silenceDetect = (itemHit == kSilenceDetectOnItem)?kSilenceDetectOn:kSilenceDetectOff;
  120.                     
  121.                     if ((errCode = TELCASilenceDetect (caHand, silenceDetect, silencePeriod)) == noErr)
  122.                         Print (paramPtr, "TELCASilenceDetect --> SilenceDetect = %s", 
  123.                                 ((silenceDetect==kSilenceDetectOn)?"SilenceDetectOn":"SilenceDetectOff"));
  124.                     else
  125.                         Print (paramPtr, "### TELCASilenceDetect failed : %d", errCode);
  126.                 }
  127.                 else
  128.                     if (itemHit == -1)
  129.                         Print (paramPtr, "### Unable to get a DLOG resource");
  130.             }
  131.             else
  132.                 Print (paramPtr, "### Unable to retrieve the CA handle");
  133.         }
  134.         else
  135.             Print (paramPtr, "### Number of CAs is %d", numOfCAs);
  136.     }
  137.     else
  138.         Print (paramPtr, "### Unable to retrieve the DN handle");
  139. }
  140.  
  141.  
  142.