static gboolean transferFinished(gpointer data) {
	ReceiveFile *receive = (ReceiveFile *) data;
	AbstractUser *user = receive->user();
	std::string filename(receive->filename());
	Log(user->jid(), "trying to send file "<< filename);
	if (user->account()){
		if (user->isConnected()){
			Log(user->jid(), "sending download message");
			std::vector <std::string> dirs = split(filename, '/');
			std::string url = Transport::instance()->getConfiguration().filetransferWeb;
			std::string basename = dirs.back();
			dirs.pop_back();
			url += dirs.back() + "/";
			url += basename;
			Message s(Message::Chat, receive->target(), "This is an automated message generated on behalf of this user. She/he has sent you the file '" + basename + "'. You may download it from " + url);
			s.setFrom(user->jid());
			// TODO: rewrite me to not use GlooxMessageHandler
#ifndef TESTS
			GlooxMessageHandler::instance()->handleMessage(s, NULL);
#endif
			
		}
	}
	receive->dispose();
	return FALSE;
}
static gpointer receiveFileCallback(gpointer data) {
	ReceiveFile *resender = (ReceiveFile *) data;
	while (true) {
		if (!resender->receive())
			break;
	}
	resender->stopped();
	return NULL;
}
示例#3
0
static gboolean transferFinished(gpointer data) {
	ReceiveFile *receive = (ReceiveFile *) data;
	User *user = receive->user();
	std::string filename(receive->filename());
	Log(user->jid(), "trying to send file "<< filename);
	if (user->account()){
		if (user->isConnected()){
			Log(user->jid(), "sending download message");
			std::string basename(g_path_get_basename(filename.c_str()));
			if (user->isVIP()) {
				user->p->sql()->addDownload(basename,"1");
			}
			else {
				user->p->sql()->addDownload(basename,"0");
			}
			Message s(Message::Chat, receive->target(), "Uzivatel Vam poslal soubor '"+basename+"'. Muzete jej stahnout z adresy http://soumar.jabbim.cz/icq/" + basename +" .");
			s.setFrom(user->jid());
			user->receivedMessage(s);
		}
	}
	receive->dispose();
	return FALSE;
}