📄 alias.cpp
字号:
/*=============================================================
Function:
Author: Leon Wang <wlywly@sina.com giga2@tom.com>
==============================================================*/
// Alias.cpp: implementation of the Alias class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Alias.h"
#include "sha1.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//##ModelId=424BB64602F6
int Alias::AVAILABLE = 0;
//##ModelId=424BB6460305
int Alias::TALKING = 1;
//##ModelId=424BB6460307
Alias::Alias(){
isOK = FALSE;
state = AVAILABLE;
crv = "";
}
//##ModelId=42198D1802D9
/**
* Initialize the Alias object.
* @param _alias H.323 alias
* @param _epid endpoint ID
*/
//##ModelId=424BB6460315
Alias::Alias(CString _alias, CString _epid)
{
isOK = FALSE;
alias = _alias;
epid = _epid;
state = AVAILABLE;
crv = "";
}
//##ModelId=424BB6460318
Alias::~Alias()
{
}
// [3/25/2005] get string hash code--> need test it
//##ModelId=424BB646031A
void Alias::SHA1HashCode(char* &str)
{
CSHA1 sha1;
sha1.Reset();
sha1.Update((UINT_8 *)str, strlen(str));
sha1.Final();
sha1.ReportHash(str, CSHA1::REPORT_DIGIT);
}
/**
* Make sure aliases are compared by alias name and endpoint ID.
* @param o alias to compare with
* @return T / F
*/
//##ModelId=424BB6460325
BOOL Alias::equals(std::vector<Alias> obj)
{
//
Alias other = (Alias)obj[0];
return ((this->getAlias())==(other.getAlias())
&&
(this->getEpid())==(other.getEpid()));
}
/**
* Create unique hash code.
* @return hash code
*/
//##ModelId=424BB6460327
void Alias::hashCode(CString & hashString)
{
hashString = epid + alias;
LPTSTR p = hashString.GetBuffer(hashString.GetLength());
SHA1HashCode(p);// care it !! test it
hashString = p;
hashString.ReleaseBuffer();
}
/**
* Access the alias.
* @return H.323 alias
*/
//##ModelId=424BB6460335
CString Alias::getAlias()
{
return alias;
}
//##ModelId=424BB6460336
void Alias::setAlias(CString _alias)
{
this->alias = _alias;
}
/**
* Access to endpoint ID.
* @return endpoint ID
*/
//##ModelId=424BB6460343
CString Alias::getEpid()
{
return epid;
}
//##ModelId=424BB6460344
void Alias::setEpid(CString _epid)
{
this->epid = _epid;
}
/**
* Access the alias state.
* @return alias state (see constants)
*/
//##ModelId=424BB6460346
int Alias::getState()
{
return state;
}
/**
* Change the alias state.
* @param _state new state (see constants)
*/
//##ModelId=424BB6460353
void Alias::setState(int _state)
{
state = _state;
}
/**
* Access the CRV for a TALKING alias.
* @return CRV
*/
//##ModelId=424BB6460355
CString Alias::getCrv()
{
return crv;
}
/**
* Change the CRV for a TALKING alias.
* @param _crv new CRV
*/
//##ModelId=424BB6460356
void Alias::setCrv(CString _crv)
{
crv = _crv;
}
/**
* Printable representation.
* @return string
*/
//##ModelId=424BB6460364
CString Alias::toString()
{
return getAlias() + "(" + getEpid() + ")";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -