From: Aidan Van Dyk Date: Mon, 31 Jan 2005 20:13:17 +0000 (+0000) Subject: FaxParams.c++, FaxParams.h: X-Git-Tag: HYLAFAX-4_2_2BETA1~116 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=44b3de809b91aa8ec74371f5798e43d3987e0678;p=thirdparty%2FHylaFAX.git FaxParams.c++, FaxParams.h: 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. --- diff --git a/util/FaxParams.c++ b/util/FaxParams.c++ index 8bab9bfd..11c5abe3 100644 --- a/util/FaxParams.c++ +++ b/util/FaxParams.c++ @@ -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) +{ +} diff --git a/util/FaxParams.h b/util/FaxParams.h index c401c169..8219b40f 100644 --- a/util/FaxParams.h +++ b/util/FaxParams.h @@ -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);