Beispiel #1
0
PhoneCall::PhoneCall(SessionManager *_sManager, unsigned int _id, unsigned int _client, unsigned int _translator, string lang)
: Call(_sManager, _id, _client, _translator, lang),
  accepted(false),
  request_time(0), confirm_time(0)
{
	client_phone[0] = 0;
	translator_phone[0] = 0;
	Session *cs = sManager->findSessionByUser(client);
	if (!cs)
		throw std::logic_error("Client session not found.");
	Client *c = dynamic_cast<Client *>(cs->getUser());
	if (!c ||
		(!TRANSLATORS_CALL && dynamic_cast<Translator *>(cs->getUser())))
		throw std::logic_error("Client not found.");
	setClientCountry(c->getCountry());
	Session *ts = sManager->findSessionByUser(translator);
	if (!ts)
		throw std::logic_error("Translator session not found.");
	Translator *t = dynamic_cast<Translator *>(ts->getUser());
	if (!t)
		throw std::logic_error("Translator not found.");
	setTranslatorCountry(t->getCountry());
}