]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
FaxParams.c++, FaxParams.h:
authorAidan Van Dyk <aidan@ifax.com>
Mon, 31 Jan 2005 20:13:17 +0000 (20:13 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Mon, 31 Jan 2005 20:13:17 +0000 (20:13 +0000)
     Some fixes/update to FaxParams
     1) Some more abstraction for the sake of sub-classes
        setupT30(...) that are protected
        Making constructors use the abstracted setupT30 functions
     2) Virtual ~FaxParams() so we can control it
     3) Virtual void update (void) function so that subclasses that
        chagne things can let us know that want us to update.  For instance
        if Class2Params changes stuff, it needs to "update" the T30 bits.

util/FaxParams.c++
util/FaxParams.h

index 8bab9bfdf945f5740bab1b7e4d210b5c0dc4ef19..11c5abe3e650d7a24fc77f0375be88ad0235a4ad 100644 (file)
@@ -65,8 +65,11 @@ FaxParams::FaxParams()
 
 FaxParams::FaxParams(u_char* pBits, int length)
 {
-    initializeBitString();
-    copyBytes(pBits, length);
+    setupT30(pBits, length);
+}
+
+FaxParams::~FaxParams (void)
+{
 }
 
 /*
@@ -74,15 +77,7 @@ FaxParams::FaxParams(u_char* pBits, int length)
  */
 FaxParams::FaxParams(u_int disDcs, u_int xinfo)
 {
-    initializeBitString();
-    m_bits[0] = (disDcs&0xFF0000) >> 16;
-    m_bits[1] = (disDcs&0x00FF00) >>  8;
-    m_bits[2] = (disDcs&0x0000FF) >>  0;
-
-    m_bits[3] = (xinfo&0xFF000000) >> 24;
-    m_bits[4] = (xinfo&0x00FF0000) >> 16;
-    m_bits[5] = (xinfo&0x0000FF00) >>  8;
-    m_bits[6] = (xinfo&0x000000FF) >>  0;
+    setupT30(disDcs, xinfo);
 }
 
 /*
@@ -209,9 +204,18 @@ FaxParams::FaxParams(Class2Params modemParams)
     if (modemParams.ec & BIT(EC_ENABLE64) && !(modemParams.ec & BIT(EC_ENABLE256))) setBit(BITNUM_FRAMESIZE, true);
 }
 
+/*
+ * Set all bits to zero.  According to Table 2 T.30 NOTE 1, reserved
+ * bits should also be set to zero.
+ */
+void FaxParams::initializeBitString()
+{
+    for (int i = 0; i < MAX_BITSTRING_BYTES; i++) m_bits[i] = 0;
+}
 
-void FaxParams::copyBytes(u_char* pBits, int length)
+void FaxParams::setupT30(u_char* pBits, int length)
 {
+    initializeBitString();
     bool lastbyte = false;
 
     for (int byte = 0; byte < MAX_BITSTRING_BYTES && byte < length; byte++) {
@@ -225,15 +229,20 @@ void FaxParams::copyBytes(u_char* pBits, int length)
     m_bits[MAX_BITSTRING_BYTES-1] = m_bits[MAX_BITSTRING_BYTES-1] & 0xFE;
 }
 
-/*
- * Set all bits to zero.  According to Table 2 T.30 NOTE 1, reserved
- * bits should also be set to zero.
- */
-void FaxParams::initializeBitString()
+void FaxParams::setupT30 (u_int disDcs, u_int xinfo)
 {
-    for (int i = 0; i < MAX_BITSTRING_BYTES; i++) m_bits[i] = 0;
+    initializeBitString();
+    m_bits[0] = (disDcs&0xFF0000) >> 16;
+    m_bits[1] = (disDcs&0x00FF00) >>  8;
+    m_bits[2] = (disDcs&0x0000FF) >>  0;
+
+    m_bits[3] = (xinfo&0xFF000000) >> 24;
+    m_bits[4] = (xinfo&0x00FF0000) >> 16;
+    m_bits[5] = (xinfo&0x0000FF00) >>  8;
+    m_bits[6] = (xinfo&0x000000FF) >>  0;
 }
 
+
 /*
  * Table 2 T.30  defines bit numbers 1 ... 127.  
  * Anything else is invalid and should not be used.
@@ -349,3 +358,7 @@ FaxParams& FaxParams::assign(const FaxParams& operand)
 
     return *this;
 }
+
+void FaxParams::update (void)
+{
+}
index c401c169eee21daa0de67d90b724fdbf7da35673..8219b40ff36f36558be9644b614d111f01f22730 100644 (file)
@@ -48,6 +48,10 @@ class FaxParams
        FaxParams(u_char* pBits, int length);
        FaxParams(Class2Params modemParams);
 
+       virtual ~FaxParams (void);
+
+       virtual void update (void);
+
        void setBit(int bitNum, bool val);
        bool isBitEnabled(int bitNum);
 
@@ -59,6 +63,9 @@ class FaxParams
        FaxParams& operator=(const FaxParams& operand);
 
     protected:
+       void setupT30(u_char* pBits, int length);
+       void setupT30(u_int dcs_dis, u_int xinfo);
+
        static const int BITNUM_V8_CAPABLE;  //06
        static const int BITNUM_FRAMESIZE;   //07
        static const int BITNUM_T4XMTR;      //09
@@ -96,7 +103,6 @@ class FaxParams
 
     private:
        void initializeBitString();
-       void copyBytes(u_char* pBits, int length);
        int calculateByteNumber(int bitNum);
        u_char calculateMask(int bitNum);
        void setExtendBits(int byteNum);