예제 #1
0
void ColorKeeperModel::deleteCalibRequestFile(string screenFullName,
		const unsigned int &screenIndex) {
	QFile calibRequestFile(
			QString::fromStdString(
					ColorKeeperModel::getCalibRequestFilePath(screenFullName)));
	if (calibRequestFile.exists()) {
		calibRequestFile.remove();
		const ILocalHost &host = ColorKeeperModel::Instance().getDeviceInfo();

		QString osName;
#ifdef __WIN32__
		osName = "Windows";
#endif
#ifdef __linux__
		osName = "Linux";
#endif
#ifdef __APPLE__
		osName = "MacOSX";
#endif

		QString hostname = QString(host.getHostName().c_str());
		QString domain = QString(host.getDomainName().c_str());
		bool isHighPriority = false;

		map<unsigned int, HealerCalibModel>::iterator calibIt =
				ColorKeeperModel::Instance()._calib.find(screenIndex);
		if (calibIt != ColorKeeperModel::Instance()._calib.end()) {
			isHighPriority = (*calibIt).second.isHighPriority();
		}

		MailSender* mailer = ColorKeeperModel::Instance().getMailer();
		if (mailer == NULL)
			return;

		//CalibRequest
		QString title = "CalibRequest For " + hostname + " on " + osName;
		if (isHighPriority)
			title = "URGENT " + title;
		QString message =
				"[CLOSED]\nMessage send by ColorKeeper after a calibration with ColorHealer.";
		mailer->send(QString::fromLocal8Bit(title.toStdString().c_str()),
				QString::fromLocal8Bit(message.toStdString().c_str()));

	}
}
예제 #2
0
void ColorKeeperModel::sendAMailCalibrationRequest() {

	MailSender* mailer = ColorKeeperModel::Instance().getMailer();
	if (mailer == NULL) {
		ostringstream os;
		os << "\nCoudn't find mailer configuration.\n" << endl;
		ColorKeeperModel::logMessage(os.str());
		return;
	}
	const ILocalHost &host = getDeviceInfo();
	const vector<unsigned int> & screenOrder = getScreenResOrder();
	QStringList screensToCalibrate;
	QStringList screensToCalibrateFullNames;
	bool isHighPriority = false;
	for (unsigned int i = 0; i < screenOrder.size(); i++) {
		const ZooperDisplayDevice & dispDev = host.getCalibrableDisplayDevice(
				screenOrder[i]);
		string fullname = dispDev.getFullName(false);
		if (isCalibResquestAsked(fullname)
				|| isScreenModelInvalidate(dispDev.getManufacturerName(),
						dispDev.getModelName()) || isMachineInvalidate())
			continue;
		int isHasBeen = isScreenCorrectionHasBeen(dispDev.getOSIndex());
		bool isNotCorrected = !isScreenCorrected(dispDev.getOSIndex());

		if (isHasBeen > 0) {
			QString message = "";
			message += "Average Priority : "
					+ QString(dispDev.getFullName().c_str()) + " has a "
					+ QString::number(isHasBeen)
					+ " days obsolete profile and need to be re-calibrate.";
			//			QString message = "";
			//			message
			//					+= "" + QString(
			//							dispDev.getFullName().c_str())
			//							+ " has no calibration profile and need to be calibrate very quickly.";

			screensToCalibrate << message;
			screensToCalibrateFullNames << QString::fromStdString(fullname);
		} else if (isNotCorrected) {
			QString message = "";
			message +=
					"High Priority : " + QString(dispDev.getFullName().c_str())
							+ " has no calibration profile and need to be calibrate very quickly.";

			screensToCalibrate << message;
			screensToCalibrateFullNames << QString::fromStdString(fullname);
			isHighPriority = true;
		}

	}

	int nbScreensToCalibrate = screensToCalibrate.size();
	if (nbScreensToCalibrate > 0) {

		QString osName;
#ifdef __WIN32__
		osName = "Windows";
#endif
#ifdef __linux__
		osName = "Linux";
#endif
#ifdef __APPLE__
		osName = "MacOSX";
#endif

		QString hostname = QString(host.getHostName().c_str());
		QString domain = QString(host.getDomainName().c_str());
		QString message =
				"Dear calibrators,\n\nColorKeeper has detected a lack of calibration for machine "
						+ hostname + " (domain : " + domain + ", user : "******" ) on "
						+ osName + " : \n";
		//CalibRequest
		QString title = "CalibRequest For " + hostname + " on " + osName;
		if (isHighPriority)
			title = "URGENT " + title;

		for (int i = 0; i < nbScreensToCalibrate; i++) {
			message += "- " + screensToCalibrate.at(i) + "\n";
			ColorKeeperModel::createCalibRequestAskedFile(
					screensToCalibrateFullNames.at(i).toStdString(),
					message.toStdString());
		}
		message += "\nThanks !\n\n";

#ifdef __linux__
		message += "Reminder : on Linux, only one screen can be calibrated, ColorKeeper choose the primary screen in Nvidia-settings.\nSo when you're calibrating a dual screen linux station, check first that the primary screen if the best of the two (if not change the primary screen setting in Nivdia-settings).\n\n";
#endif

		mailer->send(QString::fromLocal8Bit(title.toStdString().c_str()),
				QString::fromLocal8Bit(message.toStdString().c_str()));

		ColorKeeperModel::logMessage("\nA request calib mail was sent.\n");

	}

}