/** This function tells the h.323 stack to either 
    answer or deny an incoming call  */
int h323_answering_call(const char *token, int busy) 
{
	const PString currentToken(token);
	H323Connection * connection;
	
	connection = endPoint->FindConnectionWithLock(currentToken);
	
	if (!connection) {
		cout << "No connection found for " << token << endl;
		return -1;
	}
	if (!busy) {
		if (h323debug) {
			cout << "\tAnswering call " << token << endl;
		}
		connection->AnsweringCall(H323Connection::AnswerCallNow);
	} else {
		if (h323debug) {
			cout << "\tdenying call " << token << endl;
		}
		connection->AnsweringCall(H323Connection::AnswerCallDenied);
	}
	connection->Unlock();
	return 0;
}
/* Send Progress PDU to H.323 caller */
int h323_send_progress(const char *token)
{
        const PString currentToken(token);
        H323Connection * connection;

        connection = endPoint->FindConnectionWithLock(currentToken);
        if (!connection) {
                cout << "No connection found for " << token << endl;
                return -1;
        }
        connection->AnsweringCall(H323Connection::AnswerCallDeferredWithMedia);
        connection->Unlock();
        return 0;  
}
/* Send Alerting PDU to H.323 caller */
int h323_send_alerting(const char *token)
{
        const PString currentToken(token);
        H323Connection * connection;

        if (h323debug) {
        	cout << "\tSending alerting\n" << endl;
        }
        connection = endPoint->FindConnectionWithLock(currentToken);
        if (!connection) {
                cout << "No connection found for " << token << endl;
                return -1;
        }
        connection->AnsweringCall(H323Connection::AnswerCallPending);
        connection->Unlock();
        return 0; 

}