www.pudn.com > acdx.rar > Endpoint.cpp
/*============================================================= Function: Author: Leon Wang==============================================================*/ // Endpoint.cpp: implementation of the Endpoint class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "Endpoint.h" #include "sha1.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// //##ModelId=424BB64601CD int Endpoint::AVAILABLE = 0; //##ModelId=424BB64601DC int Endpoint::TALKING = 1; //##ModelId=424BB646017F Endpoint::Endpoint() { } /** * Initialize the Endpoint object. * @param _epid endpoint ID * @param _alias first H.323 alias */ //##ModelId=424BB6460180 Endpoint::Endpoint(CString _epid, CString _alias) { epid = _epid; alias = _alias; state = AVAILABLE; } //##ModelId=424BB6460190 Endpoint::~Endpoint() { } /** * make sure endpoints are compared only by endpoint ID. * @param other endpoint to compare with * @return T / F */ //##ModelId=424BB6460192 BOOL Endpoint::equals(Endpoint* other) { return this->getEpid()==other->getEpid(); } /** * Return hash code of unique identifier. * @return hash code */ //int //##ModelId=424BB64601BF void Endpoint::hashCode(CString & hashString) { hashString = epid; LPTSTR p = hashString.GetBuffer(hashString.GetLength()); SHA1HashCode(p);// care it !! test it hashString = p; hashString.ReleaseBuffer(); // return epid.hashCode(); } //##ModelId=424BB64601C1 void Endpoint::SHA1HashCode(char* &str) { CSHA1 sha1; sha1.Reset(); sha1.Update((UINT_8 *)str, strlen(str)); sha1.Final(); sha1.ReportHash(str, CSHA1::REPORT_DIGIT); } /** * Access to endpoint ID. * @return endpoint ID */ //##ModelId=424BB646019E CString Endpoint::getEpid() { return epid; } /** * Change the endpoint ID. Rarely usefull! * @param epid new endpoint ID */ //##ModelId=424BB646019F void Endpoint::setEpid(CString epid) { this->epid = epid; } /** * Access the first alias. * @return H.323 alias */ //##ModelId=424BB64601A1 CString Endpoint::getAlias() { return alias; } /** * Change the endpoint alias. * @param alias H.323 alias */ //##ModelId=424BB64601AD void Endpoint::setAlias(CString alias) { this->alias = alias; } /** * Access the endpoint state. * @return endpoint state (see constants) */ //##ModelId=424BB64601AF int Endpoint::getState() { return state; } /** * Change the endpoint state. * @param state new state (see constants) */ //##ModelId=424BB64601B0 void Endpoint::setState(int state) { this->state = state; } /** * Printable representation. * @return string */ //##ModelId=424BB64601BE CString Endpoint::toString() { return getAlias() + "(" + getEpid() + ")"; }