예제 #1
0
void ServerController::addMember(sf::Packet &packet, sf::TcpSocket &client, Account::AccessLevel level)
{
	sf::Packet response;
	std::string username, conference, targetUser;
	packet >> username >> conference >> targetUser;
	
	bool success = false;
	
	int findIndex = checkAccount(username);
	int targetIndex = checkAccount(targetUser);
	int confIndex = checkConference(conference);
	if (findIndex == -1 || targetIndex == -1 || confIndex == -1)
	{
		success = false;
		response << success;
		client.send(response);
		return;
	}
	// add access to the conference in the target user's accessmap
	data.accounts[targetIndex].addAccess(conference, level);
	if (level == Account::Access_Reviewer)
	{
		data.conferences[confIndex].addReviewer(targetUser);
	}
	// add welcome notification to the user
	addNotification(targetUser, "Welcome to " + conference + "!");
	success = true;
	response << success;
	client.send(response);
	data.saveAccounts();
	data.saveConferences();
}
예제 #2
0
void ServerController::checkPaperAlloc(sf::Packet &packet, sf::TcpSocket &client)
{
	sf::Packet response;
	std::string conference, paperTitle;
	int rev_count;
	bool result = false;
	
	packet >> conference >> paperTitle;
	
	int confIndex = checkConference(conference);
	if(confIndex == -1)
	{
		return;
	}
	int max_rev = data.conferences[confIndex].getMaxPaperReviewers();
	
	for (int i = 0; i < (int)data.submissions.size(); i++)
	{
		if (data.submissions[i].getConference() == conference)
		{
			if(data.submissions[i].getTitle() == paperTitle)
			{
				rev_count = data.submissions[i].getReviewerCount();
				if (rev_count < max_rev)
				{
					result = true;
					break;
				}
			}
		}
	}
	response << result;
	client.send(response);	
}
예제 #3
0
void ServerController::getReview(sf::Packet &packet, sf::TcpSocket &client)
{
	sf::Packet response;
	std::string username, conf, id;
	Review aReview;
	bool found = false;
	packet >> username >> conf >> id;
	// authenticate request
	if (checkAccount(username) == -1)
	{
		return;
	}
	// authenticate conference
	if (checkConference(conf) == -1)
	{
		return;
	}
	// find review with id
	std::vector<Review>::iterator it;
	for (it = data.reviews.begin(); it != data.reviews.end(); ++it)
	{
		if (it->getReviewID() == id)
		{
			aReview = *it;
			found = true;
			break;
		}
	}
	response << found;
	if (found)
	{
		response << aReview;
	}
	client.send(response);
}
예제 #4
0
void ServerController::getLimit(sf::Packet &packet, sf::TcpSocket &client, const std::string &mode)
{
	sf::Packet response;
	std::string username, conference;
	sf::Int16 limit;
	packet >> username >> conference >> limit;
	// authenticate request
	int accIndex = checkAccount(username);
	if (accIndex == -1)
	{
		return;
	}
	// authenticate conference
	int confIndex = checkConference(conference);
	if (confIndex == -1)
	{
		return;
	}
	if (mode == "ALLOCATED")
	{
		limit = data.conferences[confIndex].getMaxReviewedPapers();
	}
	else if (mode == "PAPERREV")
	{
		limit = data.conferences[confIndex].getMaxPaperReviewers();
	}
	response << limit;
	client.send(response);
}
예제 #5
0
void ServerController::assignReviewer(sf::Packet &packet, sf::TcpSocket &client)
{
	std::string conference, paperTitle, targetUsername;
	std::string firstname, lastname;
	
	packet >> conference >> paperTitle >> targetUsername;
	int findIndex = checkAccount(targetUsername);
	firstname = data.accounts[findIndex].getFirstName();
	lastname = data.accounts[findIndex].getLastName();
	int confIndex = checkConference(conference);
	int maxReviewers = data.conferences[confIndex].getMaxPaperReviewers();
	
	for (int i = 0; i < (int)data.submissions.size(); i++)
	{
		if (data.submissions[i].getConference() == conference);
		{
			if (data.submissions[i].getTitle() == paperTitle)
			{
				if (!data.submissions[i].isAuthorIncluded(firstname, lastname)
					&& !data.submissions[i].hasReviewer(targetUsername))
				{
					data.submissions[i].addReviewer(targetUsername);
					data.accounts[findIndex].incrementAllocated(conference, maxReviewers);
				}
			}
		}
	}	
	data.saveAccounts();
	data.saveSubmissions();			
}
예제 #6
0
void ServerController::paperSubmission(sf::Packet &packet, sf::TcpSocket &client)
{
	sf::Packet response;
	Submission sub;
	bool exists = false;
	std::string username, conference, title;
	
	packet >> username;
	int findIndex = checkAccount(username);		//get Account index
	if (findIndex == -1)
	{
		return;		// ignore request if user is not found
	}
	packet >> sub;
	conference = sub.getConference();
	title = sub.getTitle();
	int confIndex = checkConference(conference);
	if (confIndex == -1)
	{
		return; 	// ignore request if conference is not found
	}
	if (data.accounts[findIndex].getAccess(conference) < Account::Access_Author)
	{
		return;		// ignore request if user is not at least an author of that conference
	}
	
	// check conference is in submission phase
	if (data.conferences[confIndex].getCurrentPhase() != "Submission")
	{
		return;		// ignore request if conference is not accepting submissions
	}
	
	// check that the paper does not already exist
	if (checkSubmission(title, conference) == -1)
	{
		// set the papers university to the submitting author
		sub.setUniversity(data.accounts[findIndex].getUniversity());
		// add the submitting author as an author
		std::string firstname = data.accounts[findIndex].getFirstName();
		std::string lastname = data.accounts[findIndex].getLastName();
		
		sub.addAuthor(firstname, lastname);
		data.submissions.push_back(sub);
		data.saveSubmissions();
		
		data.addLog("Paper was submitted: " + title + " by " + username + " for conference " + conference);
		addNotification(username, "You submitted a paper '" + title + "' to " + conference);
		notifyConference(conference, 
			username + " submitted a paper '" + title + "' to " + conference, 
				Account::Access_Chairman);
	}
	else
	{
		exists = true;
	}
	response << exists;
	client.send(response);
}
예제 #7
0
void ServerController::changeLimit(sf::Packet &packet, sf::TcpSocket &client, const std::string &mode)
{
	std::string username, conference;
	sf::Int16 val;
	packet >> username >> conference >> val;
	int setVal = val;
	// authenticate request
	int accIndex = checkAccount(username);
	if (accIndex == -1)
	{
		return;
	}
	// authenticate conference
	int confIndex = checkConference(conference);
	if (confIndex == -1)
	{
		return;
	}
	// authenticate privileges
	if (data.accounts[accIndex].getAccess(conference) < Account::Access_Chairman)
	{
		return;
	}
	if (val > 0 && val < MAXIMUM_USEABLEINT_LIMIT)
	{
		if (mode == "ALLOCATED")
		{
			data.conferences[confIndex].setMaxReviewedPapers(setVal);
			notifyConference(conference, 
				username + " has changed the max papers per reviewer limit for " + conference, 
					Account::Access_Chairman);
		}
		else if (mode == "PAPERREV")
		{
			data.conferences[confIndex].setMaxPaperReviewers(setVal);
			notifyConference(conference, 
				username + " has changed the max reviewers per paper limit for " + conference, 
					Account::Access_Chairman);
		}
		data.saveConferences();
	}
}
예제 #8
0
void ServerController::getFinalReview(sf::Packet &packet, sf::TcpSocket &client)
{
	sf::Packet response;
	std::string username, conference, paper;
	std::string finalRev;
	bool exists = false;
	packet >> username >> conference >> paper;
	// authenticate request
	int accIndex = checkAccount(username);
	if (accIndex == -1)
	{
		return;
	}
	// authenticate conference
	int confIndex = checkConference(conference);
	if (confIndex == -1)
	{
		return;
	}
	if (data.accounts[accIndex].getAccess(conference))
	{
		for (int i = 0; i < (int)data.reviews.size(); ++i)
		{
			if (data.reviews[i].getConference() == conference &&
				data.reviews[i].getTitle() == paper &&
					data.reviews[i].getFinal())
			{
				finalRev = data.reviews[i].getReviewID();
				exists = true;
				break;
			}
		}
		response << exists << finalRev;
	}
	else
	{
		response << exists;
	}
	client.send(response);
}
예제 #9
0
void ServerController::getFreeReviewers(sf::Packet &packet, sf::TcpSocket &client)
{
	sf::Packet response;
	std::string conference;
	std::vector<std::string> reviewerList;
	std::vector<std::string> freeList;
	
	packet >> conference;
	
	int confIndex = checkConference(conference);
	if (confIndex == -1)
	{
		return;
	}
	data.conferences[confIndex].getReviewers(reviewerList);
	int maxReviewers = data.conferences[confIndex].getMaxPaperReviewers();
	
	std::cout << "Getting a list of free reviewers for conference " << conference << std::endl;
	for (int i = 0; i < (int)reviewerList.size(); i++)
	{
		int findIndex = checkAccount(reviewerList[i]);
		if (findIndex != -1)
		{
			std::cout << "Displaying Reviewers: " << reviewerList[i] << std::endl;
			if (data.accounts[findIndex].checkAllocation(conference, maxReviewers))
			{
				std::cout << "Pushing" << std::endl;
				freeList.push_back(reviewerList[i]);
			}
		}
	}
	
	response << (int)freeList.size();
	for (int i = 0; i < (int)freeList.size(); i++)
	{
		response << freeList[i];
	}
	
	client.send(response);
} 
예제 #10
0
void ServerController::sendSubDetail(sf::Packet &packet, sf::TcpSocket &client)
{
	sf::Packet response;
	std::string conf, paperTitle;
	packet >> conf >> paperTitle;
	
	int confIndex = checkConference(conf);
	if (confIndex == -1)
	{
		return; 	// ignore request if conference is not found
	}
	
	int subIndex = checkSubmission(paperTitle, conf);
	if (subIndex == -1)
	{
		return;		// ignore request if paper is not found
	}
	
	Submission result = data.submissions[subIndex]; 
	response << result;
	client.send(response);
}
예제 #11
0
void ServerController::decidePaper(sf::Packet &packet, sf::TcpSocket &client, const bool approved)
{
	std::string username, conference, paper;
	packet >> username >> conference >> paper;
	// authenticate request
	int accIndex = checkAccount(username);
	if (accIndex == -1)
	{
		return;
	}
	// authenticate conference
	int confIndex = checkConference(conference);
	if (confIndex == -1)
	{
		return;
	}
	// authenticate privileges
	if (data.accounts[accIndex].getAccess(conference) < Account::Access_Chairman)
	{
		return;
	}
	// authenticate paper
	int paperIndex = checkSubmission(paper, conference);
	if (paperIndex == -1)
	{
		return;		// ignore request if submission does not exist
	}
	if (approved)
	{
		data.submissions[paperIndex].accept();
	}
	else
	{
		data.submissions[paperIndex].reject();
	}
}
예제 #12
0
void ServerController::getReviewers(sf::Packet &packet, sf::TcpSocket &client)
{
	sf::Packet response;
	std::string username, conference;
	std::vector<std::string> reviewer;
	
	packet >> username >> conference;	

	int confIndex = checkConference(conference);
	if(confIndex == -1)
	{
		return;
	}
	data.conferences[confIndex].getReviewers(reviewer);
	
	response << (int)reviewer.size();
	
	for (int i = 0; i < (int)reviewer.size(); i++)
	{
		response << reviewer[i];
	}
	
	client.send(response);
}
예제 #13
0
파일: firewall.cpp 프로젝트: partition/kadu
void Firewall::filterIncomingMessage(Chat chat, Contact sender, QString &message, time_t time, bool &ignore)
{
    Q_UNUSED(time)

    Account account = chat.chatAccount();

    Protocol *protocol = account.protocolHandler();
    if (!protocol)
        return;

// emotikony s± sprawdzane nawet przy ³±czeniu
    const int min_interval_notify = 2000;

    if (CheckFloodingEmoticons)
    {
        if ((!EmoticonsAllowKnown || sender.ownerBuddy().isAnonymous()) && checkEmoticons(message))
        {
            ignore = true;
            if (LastNotify.elapsed() > min_interval_notify)
            {
                FirewallNotification::notify(chat, sender, tr("flooding DoS attack with emoticons!"));

                writeLog(sender, message);

                LastNotify.restart();
            }
            kdebugf2();
            return;
        }
    }

// atak floodem
    if (checkFlood())
    {
        ignore = true;
        if (LastNotify.elapsed() > min_interval_notify)
        {
            FirewallNotification::notify(chat, sender, tr("flooding DoS attack!"));

            writeLog(sender, message);

            LastNotify.restart();
        }
        kdebugf2();
        return;
    }

// ochrona przed anonimami
    if (checkChat(chat, sender, message, ignore))
        ignore = true;

// ochrona przed konferencjami
    if (checkConference(chat))
        ignore = true;

// wiadomosc zatrzymana. zapisz do loga i wyswietl dymek
    if (ignore)
    {
        if (message.length() > 50)
            FirewallNotification::notify(chat, sender, message.left(50).append("..."));
        else
            FirewallNotification::notify(chat, sender, message);

        writeLog(sender, message);

        if (WriteInHistory)
        {
            if (History::instance()->currentStorage())
            {
                Message msg = Message::create();
                msg.setContent(message);
                msg.setType(Message::TypeReceived);
                msg.setReceiveDate(QDateTime::currentDateTime());
                msg.setSendDate(QDateTime::fromTime_t(time));
                History::instance()->currentStorage()->appendMessage(msg);
            }
        }
    }

    kdebugf2();
}