static void sendEmailAlert(std::string emailTo, std::string body, std::string subject = "PerfCheck - Email Alert") {
	std::string emailFrom = "*****@*****.**";
	
	Email *email = new PocoEmail(emailFrom, "Fanion Newsome", "", "", emailTo, "", "", subject, body);
	email->SendEmail();
	delete email;
}
Beispiel #2
0
void EmailAdapter::ParseRecipients(const MojObject& recipients, Email& email)
{
	MojErr err;
	
	EmailAddressListPtr to_list(new EmailAddressList);
	EmailAddressListPtr cc_list(new EmailAddressList);
	EmailAddressListPtr bcc_list(new EmailAddressList);
	
	MojObject::ConstArrayIterator it = recipients.arrayBegin();

	for (; it != recipients.arrayEnd(); ++it) {
		const MojObject& recipient = *it;

		MojString type;
		err = recipient.getRequired(Part::TYPE, type);
		ErrorToException(err);
		
		EmailAddressPtr addr = ParseAddress(recipient);

		if(type.compareCaseless("to") == 0)
			to_list->push_back(addr);
		else if(type.compareCaseless("cc") == 0)
			cc_list->push_back(addr);
		else if(type.compareCaseless("bcc") == 0)
			bcc_list->push_back(addr);
		else // not a valid recipient type
			throw MailException("invalid recipient type", __FILE__, __LINE__);
	}
	
	email.SetTo(to_list);
	email.SetCc(cc_list);
	email.SetBcc(bcc_list);
}
void InitEmail(Email& email)
{
	// Minimal email headers
	EmailAddressPtr from( new EmailAddress("test", "*****@*****.**") );
	email.SetFrom(from);
	email.SetSubject("Test email");
	email.SetDateReceived(1234567890000LL); // Friday 13 Feb 2009
}
Beispiel #4
0
bool operator>(Email& em1, Email& em2)
{
	char* t1 = em1.get_sent();
	char* t2 = em2.get_sent();

	int cmp = strcmp(t1, t2);

	if(0>=cmp) return true;
	else return false;
}
Beispiel #5
0
void
EmailTerminateEvent(ClassAd * job_ad, bool   /*exit_status_known*/)
{
    if ( !job_ad ) {
        dprintf(D_ALWAYS,
                "email_terminate_event called with invalid ClassAd\n");
        return;
    }

    Email email;
    email.sendExit(job_ad, JOB_EXITED);
}
Beispiel #6
0
void EmailAdapter::SerializeFlags(const Email& email, MojObject& flags)
{
	MojErr err;

	err = flags.putBool(Flags::READ, email.IsRead());
	ErrorToException(err);

	err = flags.putBool(Flags::REPLIED, email.IsReplied());
	ErrorToException(err);

	err = flags.putBool(Flags::FLAGGED, email.IsFlagged());
	ErrorToException(err);
}
ArrayElement * Email::clone() {
    Email* ret = new Email();

    if (p) {
        ret->setProperty(*p);
    }

    if (t) {
        ret->setType(t);
    }

    return (ArrayElement *)ret;
}
Beispiel #8
0
QtEnumEmailType::Type QtEnumEmailType::toEmailType(const QString & emailType) {
	init();
	for (Email::const_iterator it = _type.begin();
		it != _type.end();
		++it) {

		if ((*it).second == emailType) {
			return (*it).first;
		}
	}

	LOG_FATAL("unknown Email");
	return Unknown;
}
bool EmailHeaderFieldParser::ParseEmailHeaderField(Email& email, const string& fieldNameLower, const string& fieldValue)
{
	if (fieldNameLower == "subject") {
		// decode subject
		string subject;
		ParseTextField(fieldValue, subject);
		email.SetSubject(subject);
	} else if (fieldNameLower == "date") {
		time_t date;
		ParseDateField(fieldValue, date);

		// Technically this is the date sent, not received
		email.SetDateReceived( MojInt64(date) * 1000L);
	} else if (fieldNameLower == "from" || fieldNameLower == "reply-to" || fieldNameLower == "to" || fieldNameLower == "cc" || fieldNameLower == "bcc") {
		EmailAddressListPtr addressListPtr(new EmailAddressList());
		ParseAddressListField(fieldValue, *addressListPtr);

		if (fieldNameLower == "to") {
			email.SetTo(addressListPtr);
		} else if (fieldNameLower == "cc") {
			email.SetCc(addressListPtr);
		} else if (fieldNameLower == "bcc") {
			email.SetBcc(addressListPtr);
		} else if (fieldNameLower == "from") {
			// get first address
			if (!addressListPtr->empty()) {
				email.SetFrom(addressListPtr->at(0));
			}
		} else if (fieldNameLower == "reply-to") {
			// get first address
			if (!addressListPtr->empty()) {
				email.SetReplyTo(addressListPtr->at(0));
			}
		}
	} else if (fieldNameLower == "in-reply-to") {
		email.SetInReplyTo( StringUtils::GetSanitizedASCII(fieldValue) );
	} else if (fieldNameLower == "x-priority") {
		if(fieldValue == "1" || fieldValue == "2") {
			email.SetPriority(Email::Priority_High);
		} else if (fieldValue == "4" || fieldValue == "5") {
			email.SetPriority(Email::Priority_Low);
		}
	} else {
		// no match
		return false;
	}

	return true;
}
Beispiel #10
0
void addCommunications(MobilePhone* mobilePhone)
{
    Call* call;
    SMS* sms;
    Email* email;
    PhoneNumber* phoneNumber;
    EmailAddress* emailAddress;

    call = new Call(1);
    call->setDuration(QTime(0, 1, 0));
    call->setDate(QDate::currentDate());
    call->setStatus(AbstractCommunication::DIALLED_STATUS);
    call->setIncoming(true);
    phoneNumber = mobilePhone->getAddressBook().findPhoneNumber("0000000000");

    if(phoneNumber != NULL)
	call->addPhoneNumber(phoneNumber);

    mobilePhone->getCommunicationManager().addCommunication(call);

    sms = new SMS(2);
    sms->setContent("Hello SMS !!");
    sms->setDate(QDate::currentDate());
    sms->setStatus(AbstractCommunication::SENT_STATUS);
    sms->setIncoming(false);
    sms->addPhoneNumber(new PhoneNumber("0000000001"));
    mobilePhone->getCommunicationManager().addCommunication(sms);

    email = new Email(3);
    email->setSubject("Super Hello");
    email->setBody("Hello Email !!");
    email->setDate(QDate::currentDate());
    email->setStatus(AbstractCommunication::RECEIVED_STATUS);
    email->setIncoming(true);
    emailAddress = mobilePhone->getAddressBook().findEmailAddress("*****@*****.**");

    if(emailAddress != NULL)
	email->addInFromList(emailAddress);

    email->addInCCList(new EmailAddress("*****@*****.**"));
    email->addInCCIList(new EmailAddress("*****@*****.**"));
    email->addInToList(new EmailAddress("*****@*****.**"));

    mobilePhone->getCommunicationManager().addCommunication(email);
}
Beispiel #11
0
static void init() {
	if (!_type.empty()) {
		return;
	}
	_type[QtEnumEmailType::Personal] = "personal";
	_type[QtEnumEmailType::Work] = "work";
	_type[QtEnumEmailType::Other] = "other";
	
}
Beispiel #12
0
bool Database::matches(Email& email, DateCriteria& dateCriteria)
{
    if(dateCriteria.getEquals()!=nullptr){
        if(email.getDate().compareByDay(*dateCriteria.getEquals())==0)
            return true;
        else
            return false;
    }
    if(dateCriteria.getLess()!=nullptr){
        if(email.getDate().compareByDay(*dateCriteria.getLess())<0)
            return false;
    }
    if(dateCriteria.getGreater()!=nullptr){
        if(email.getDate().compareByDay(*dateCriteria.getGreater())>0)
            return false;
    }
    return true;
}
Beispiel #13
0
bool Database::matches(Email& email, StringCriteria& stringCriteria)
{
    switch(stringCriteria.getSearchKey()){
    case E_EMAIL:
        if(email.getFrom()->getAddress().find(stringCriteria.getName())!=string::npos || email.getTo()->getAddress().find(stringCriteria.getName())!=string::npos)
            return true;
        return false;
    case E_SUBJECT:
        if(email.getSubject().find(stringCriteria.getName())!=string::npos)
            return true;
        return false;
    case E_CONTENT:
        if(email.getContent().find(stringCriteria.getName())!=string::npos)
            return true;
        return false;
    default:
        return false;
    }
}
void fillEmail(std::vector<Email>& emailList) {
    system("ls emailData > temp.txt");
    std::ifstream readFile("temp.txt");
    std::string line;
    int counter1 = 0;

    while(std::getline(readFile, line)) {
        line = "/home/sandeep/Networks_lab/ass4/emailData/" + line;
        int size1 = line.size();
        std::cout << line << "\n";

        if(line[size1 - 1] == 'l' && line[size1 - 2] == 'i' && line[size1 - 3] == 'a' && line[size1 - 4] == 'm' && line[size1 - 5] == 'e') {
            Email email;
            email.deserialiseEmail(line);
            //std::cout<<email.getBody()<<"\n";
            emailList.push_back(email);
            counter1++;
        }
    }
}
Beispiel #15
0
void EmailAdapter::ParseFlags(const MojObject& flags, Email& email)
{
	bool editedOriginal;
	if (flags.get(Flags::EDITEDORIGINAL, editedOriginal)) {
		email.SetEditedOriginal( editedOriginal );
	}

	// TODO: flagged
	// TODO: replied
	// TODO: forwarded
	// TODO: editedDraft
}
emailListElementRenderComponent::emailListElementRenderComponent(sf::Font& f, Email& email, int boxX, int boxY, int boxWidth, int boxHeight, int x, int y, int size) : font(f) {
	
	x += 128;

	this->subjectText = new sf::Text();
	subjectText->setFont(font);
	subjectText->setColor(sf::Color::Black);
	subjectText->setPosition(float(x), float(y));
	subjectText->setCharacterSize(size);
	subjectText->setString(email.getAbbrevSubjectField());

	this->fromText = new sf::Text();
	fromText->setFont(font);
	fromText->setColor(sf::Color(127,127,127, 255));
	fromText->setPosition(float(x+indent), float(y+size));
	fromText->setCharacterSize(size-4);
	fromText->setString(email.getFromField());

	emailListElementBox.setPosition(sf::Vector2f(float(boxX), float(boxY)));
	emailListElementBox.setSize(sf::Vector2f(float(boxWidth), float(boxHeight)));
	emailListElementBox.setFillColor(sf::Color::White);
	
}
int main() {
    Email email;
    email.setFromId("*****@*****.**");
    email.setToId("*****@*****.**");
    email.setSubject("hi there");
    email.setBody("This is a test\nFucked up at that :v ");
    email.setTimeNow();
    email.serialiseEmail();
    std::cout << email.getFromId() << " " << email.getToId() << " ";
    printf("\n");
    std::vector<Email> emailList;
    fillEmail(emailList);

    for(int i = 0; i < emailList.size(); i++) {
        std::cout << emailList[i].getFromId() << "\n";
        std::cout << emailList[i].getToId() << "\n";
        std::cout << emailList[i].getSubject() << "\n";
        std::cout << emailList[i].getBody() << "\n";
    }
}
Beispiel #18
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    a.setApplicationName("Jupiter Reporter");
    a.setOrganizationName("XE-QT Solutions");
    a.setOrganizationDomain("xe-qt-solutions.com");

    QxtCommandOptions options;
    options.add("version", "show version number and build date");
    options.alias("version", "ver");
    options.add("help", "show this help text");

    options.addSection("printing and PDF");
    options.add("print", "print a report to a specific printer (blank for default)", QxtCommandOptions::ValueOptional);
    options.add("pdf", "save a report as a PDF file", QxtCommandOptions::ValueRequired);

    options.addSection("email");
    options.add("to", "list of email recipients", QxtCommandOptions::ValueRequired);
    options.add("cc", "list of email cc recipients", QxtCommandOptions::ValueRequired);
    options.add("subject", "the email subject", QxtCommandOptions::ValueRequired);
    options.add("body", "the body of the email message", QxtCommandOptions::ValueRequired);
    options.add("server", "the email smtp server", QxtCommandOptions::ValueRequired);
    options.add("port", "the smtp server port", QxtCommandOptions::ValueRequired);
    options.add("ssl", "use a secure socket when sending email");
    options.add("account", "the name of the smtp account", QxtCommandOptions::ValueRequired);
    options.add("password", "the smtp account password", QxtCommandOptions::ValueRequired);
    options.add("from", "the email address of the email sender", QxtCommandOptions::ValueRequired);

    options.addSection("licensing");
    options.add("lic", "display license details");
    options.add("name", "the licensee name", QxtCommandOptions::ValueRequired);
    options.add("email", "the licensee email address", QxtCommandOptions::ValueRequired);
    options.add("expires", "the license expiry date (YYYY-MM-DD format)", QxtCommandOptions::ValueRequired);
    options.add("key", "the activation key to unlock advanced features", QxtCommandOptions::ValueRequired);
    options.parse(a.arguments());

    if (options.count("version"))
    {
	std::cout << "Jupiter Reporter v" << VER_MAJOR << "." << VER_MINOR << ", built on " << __DATE__ << " at " << __TIME__ << std::endl;
	std::cout << "Copyright (c) 2010 XE-QT Solutions Ltd., All rights reserved." << std::endl;
	return 0;
    }

    QSettings settings(QString("%1/license.ini").arg(QDesktopServices::storageLocation(QDesktopServices::DataLocation)), QSettings::IniFormat);

    // Generate license?
    if (options.count("name") || options.count("email") || options.count("expires"))
    {
	const QString name = options.value("name").toString();
	const QString email = options.value("email").toString();
	const QString expires = options.value("expires").toString();

	if (name.isEmpty() || email.isEmpty() || expires.isEmpty())
	{
	    options.showUsage();
	    return 0;
	}

	settings.setValue("License/name", name);
	settings.setValue("License/email", email);
	settings.setValue("License/expires", expires);
	settings.setValue("License/license", NodeLockedLicense::licenseFile(name, email, QDate::fromString(expires, Qt::ISODate)));

	std::cout << "Generated " << qPrintable(settings.fileName()) << std::endl;

	return 0;
    }

    if (options.count("key"))
    {
	settings.setValue("License/key", options.value("key").toString());
	settings.remove("License/license");
	std::cout << "Updated " << qPrintable(settings.fileName()) << std::endl;
	return 0;
    }

    // Read license
    const QString name = settings.value("License/name").toString();
    const QString email = settings.value("License/email").toString();
    const QDate expires = QDate::fromString(settings.value("License/expires").toString(), Qt::ISODate);
    const QString key = settings.value("License/key").toString();

    bool isLicensed = NodeLockedLicense::isValid(name, email, expires, key);

    if (options.count("lic"))
    {
	std::cout << "License: " << qPrintable(settings.fileName()) << std::endl;

	if (!isLicensed)
	{
	    std::cout << "No valid license exists.  Advanced functionality will be disabled." << std::endl;
	}
	else
	{
	    std::cout << "Licensed to " << qPrintable(name) << " (" << qPrintable(email) << "), expires on " << qPrintable(expires.toString()) << std::endl;
	}
	return 0;
    }

    if (options.positional().isEmpty() || options.count("help") || options.showUnrecognizedWarning() ||
	(options.count("print") == 0 && options.count("pdf") == 0 && options.count("to") == 0))
    {
	options.showUsage();
	return 0;
    }

    const QString fileName = options.positional().first();
    Q_ASSERT(fileName != "");

    if (options.count("print"))
    {
	Print print;
	QObject::connect(&print, SIGNAL(finished()), &a, SLOT(quit()));
	print.print(fileName, options.value("print").toString());
	return a.exec();
    }

    if (options.count("pdf"))
    {
	if (isLicensed)
	{
	    Pdf pdf;
	    QObject::connect(&pdf, SIGNAL(finished()), &a, SLOT(quit()));
	    pdf.create(fileName, options.value("pdf").toString());
	    return a.exec();
	}
	else
	{
	    std::cout << "PDF support requires a license!" << std::endl;
	    return 0;
	}
    }

    if (options.count("to") || options.count("cc"))
    {
	if (isLicensed)
	{
	    Email email;
	    email.send(fileName, parseSendSettings(options), parseEmailSettings(options));
	    QObject::connect(&email, SIGNAL(finished()), &a, SLOT(quit()));
	    return a.exec();
	}
	else
	{
	    std::cout << "Email support requires a license!" << std::endl;
	    return 0;
	}
    }

    return 0;
}
Beispiel #19
0
void
BaseShadow::emailRemoveEvent( const char* reason ) 
{
	Email mailer;
	mailer.sendRemove( jobAd, reason );
}
Beispiel #20
0
void
BaseShadow::emailHoldEvent( const char* reason ) 
{
	Email mailer;
	mailer.sendHold( jobAd, reason );
}
Beispiel #21
0
// NOTE: This should currently only be used for new emails
void EmailAdapter::SerializeToDatabaseObject(const Email& email, MojObject& obj)
{
	MojErr err;
	
	// Set the object kind
	err = obj.putString(KIND, Kind::EMAIL);
	ErrorToException(err);
	
	// FIXME object ID
	
	// Set the folder ID
	err = obj.put(FOLDER_ID, email.GetFolderId());
	ErrorToException(err);
	
	// Set flags
	MojObject flags;
	SerializeFlags(email, flags);

	err = obj.put(FLAGS, flags);
	ErrorToException(err);
	
	// The following fields only exist for a new e-mail to be added to the DB
	// If the e-mail object already exists in the DB, we shouldn't overwrite these fields
	// FIXME: Except for drafts. Maybe this logic should be moved elsewhere?
	if (true /*!obj.Exists()*/) {
		// Subject
		err = obj.putString(SUBJECT, email.GetSubject().c_str());
		ErrorToException(err);

		// Preview text
		err = obj.putString(SUMMARY, email.GetPreviewText().c_str());
		ErrorToException(err);
		
		// Timestamp in UTC milliseconds
		err = obj.put(TIMESTAMP, email.GetDateReceived());
		ErrorToException(err);
		
		// From address
		MojObject from;
		if(email.GetFrom().get()) // may not have a from address
			SerializeAddress(Address::Type::FROM, email.GetFrom(), from);
		err = obj.put(FROM, from);
		ErrorToException(err);
		
		// Reply-To address
		MojObject replyTo;
		if(email.GetReplyTo().get()) { // may not have a reply-to address
			SerializeAddress(Address::Type::REPLY_TO, email.GetReplyTo(), replyTo);
			err = obj.put(REPLY_TO, replyTo);
			ErrorToException(err);
		}

		// Recipients
		MojObject recipients;
		SerializeRecipients(Address::Type::TO, email.GetTo(), recipients);
		SerializeRecipients(Address::Type::CC, email.GetCc(), recipients);
		SerializeRecipients(Address::Type::BCC, email.GetBcc(), recipients);
		err = obj.put(RECIPIENTS, recipients);
		ErrorToException(err);
		
		// Parts
		MojObject parts;
		SerializeParts(email.GetPartList(), parts);
		err = obj.put(PARTS, parts);
		ErrorToException(err);

		// MessageId and InReplyTo
		DatabaseAdapter::PutOptionalString(obj, MESSAGE_ID, email.GetMessageId());
		DatabaseAdapter::PutOptionalString(obj, IN_REPLY_TO, email.GetInReplyTo());

		// Priority
		Email::Priority priority = email.GetPriority();
		if(priority == Email::Priority_High) {
			err = obj.putString(PRIORITY, PRIORITY_HIGH);
			ErrorToException(err);
		} else if(priority == Email::Priority_Low) {
			err = obj.putString(PRIORITY, PRIORITY_LOW);
			ErrorToException(err);
		}
	}
}
Beispiel #22
0
/**
 * A job is exiting the Starter and we need to take necessary
 * actions. First we will update the job's ad file with various
 * information about what the job did. Next, if the job completed on
 * its own, we'll want to call the StarterUserPolicy's checkAtExit(),
 * which handles setting the right exit status to control the job's
 * final state in the job queue. If the job is being killed from "unnatural"
 * causes, such as a condor_rm, then we will figure out the right
 * update type is for the job and write an EVICT event to the user log.
 * 
 * @param exit_status - the exit status of the job from wait()
 * This is not used currently
 * @param reason - the Condor-defined reason why the job is exiting
 * @param user_proc - the Proc object for this job
 * @return true if the job was set to exit properly
 * @see h/exit.h
 **/
bool
JICLocalSchedd::notifyJobExit( int, int reason, 
							   UserProc* user_proc )
{
		// Remember what steps we've completed, in case we need to retry.
	static bool did_final_ad_publish = false;
	static bool did_schedd_update = false;
	static bool did_check_at_exit = false;
	static bool did_ulog_event = false;

	m_tried_notify_job_exit = true;
 
	if (!did_final_ad_publish) {
			// Prepare to update the job queue.  In this case, we want
			// to publish all the same attribute we'd otherwise send
			// to the shadow, but instead, just stick them directly
			// into our copy of the job classad.
		Starter->publishPreScriptUpdateAd( job_ad );
		if( user_proc ) {
			user_proc->PublishUpdateAd( job_ad );
		}
		Starter->publishPostScriptUpdateAd( job_ad );
		did_final_ad_publish = true;
	}
	
		// Only check to see what we should do with our job 
		// in the user policy object if the job terminated
		// on its own.  Otherwise, we've already been there
		// and done that.
	if ( reason == JOB_EXITED || reason == JOB_COREDUMPED ) {
		if( !did_check_at_exit ) {
				// What should be the return value for this?
				// Can I just assume that things went well?
			this->starter_user_policy->checkAtExit( );
			did_check_at_exit = true;
		}
	}
	else if( reason == JOB_MISSED_DEFERRAL_TIME ) {
			//
			// This is suppose to be temporary until we have some kind
			// of error handling in place for jobs that never started
			// Andy Pavlo - 01.24.2006 - [email protected]
			//
		exit_code = JOB_MISSED_DEFERRAL_TIME;
	}

	if( !did_ulog_event ) {
			// Use the final exit code to determine what event to log.
			// This may be different from what is indicated by 'reason',
			// because a policy expression evaluted by checkAtExit() may
			// have changed things.
		switch( this->exit_code ) {
		case JOB_EXITED:
			this->u_log->logTerminate( this->job_ad );
			did_ulog_event = true;
			break;
		case JOB_SHOULD_REQUEUE:
			// Following the baseshadow, if the job is being requeued
			// then it is an eviction event
			this->u_log->logRequeueEvent( this->job_ad, false );
			did_ulog_event = true;
			break;
		case JOB_SHOULD_REMOVE:
		case JOB_SHOULD_HOLD:
		case JOB_MISSED_DEFERRAL_TIME:
			// NOTE: The local universe's log actions are not consistent
			// with what the Shadow does. This is because the Shadow is
			// not consistent with itself; for example, a condor_rm
			// will cause an EVICT notice in the user log, but a 
			// periodic remove will not. This is something Derek
			// said he will clean up later on. For now, however, we are
			// going to be consistent with ourself in the local universe
			// and ALWAYS send an eviction notice when the job is 
			// removed
			this->u_log->logEvict( this->job_ad, false );
			did_ulog_event = true;
			break;
		default:
			EXCEPT("Internal error in JICLocalSchedd::notifyJobExit: unexpected exit code %d",this->exit_code);
		}
	}


	if( !did_schedd_update ) {
			// Use the final exit code to determine the update type.
			// This may be different from what is indicated by 'reason',
			// because a policy expression evaluted by checkAtExit() may
			// have changed things.
		update_t up_type = U_TERMINATE;
		switch( this->exit_code ) {
		case JOB_EXITED:
			up_type = U_TERMINATE;
			break;
		case JOB_SHOULD_REQUEUE:
			up_type = U_REQUEUE;
			break;
		case JOB_SHOULD_REMOVE:
			up_type = U_REMOVE;
			break;
		case JOB_SHOULD_HOLD:
		case JOB_MISSED_DEFERRAL_TIME:
			up_type = U_HOLD;
			break;
		default:
			EXCEPT("Internal error in JICLocalSchedd::notifyJobExit: unexpected exit code %d",this->exit_code);
		}

			// Now that we've logged the event, we can update the job queue
			// If we're doing a fast shutdown, don't retry on failure.
		if ( !this->job_updater->updateJob( up_type ) && !fast_exit ) {
			dprintf( D_ALWAYS,
			         "Failed to update job queue - attempting to retry.\n" );
			retryJobCleanup();
			return ( false );
		}

		did_schedd_update = true;
	}

		//
		// Once the job's been updated in the queue, we can also try
		// sending email notification, if desired.
		// This returns void, so there's no way to test for failure.
		// Therefore, we don't bother with retry.
		//
	Email msg;
	switch( this->exit_code ) {
	case JOB_SHOULD_REQUEUE:
	case JOB_EXITED:
		msg.sendExit( job_ad, reason );
		break;
	case JOB_SHOULD_REMOVE: {
		char *remove_reason = NULL;
		this->job_ad->LookupString( ATTR_REMOVE_REASON, &remove_reason );
		msg.sendRemove( this->job_ad, remove_reason ? remove_reason : "" );
		free( remove_reason );
		break;
	}
	case JOB_SHOULD_HOLD: {
		char *hold_reason = NULL;
		this->job_ad->LookupString( ATTR_HOLD_REASON, &hold_reason );
		msg.sendHold( this->job_ad, hold_reason ? hold_reason : "" );
		free( hold_reason );
		break;
	}
	case JOB_MISSED_DEFERRAL_TIME:
		msg.sendHold( this->job_ad, "missed derreral time" );
		break;
	default:
		EXCEPT("Internal error in JICLocalSchedd::notifyJobExit: unexpected exit code %d",this->exit_code);
	}

		//
		// Lastly, we will call to write out the file. This was 
		// originally done in JICLocal::notifyJobExit(), but we no
		// longer call that
		//
	this->writeOutputAdFile( this->job_ad );

		//
		// Once we get here, everything has been successfully
		// wrapped up.
		//
	return true;
}
Beispiel #23
0
void EmailAdapter::ParseDatabaseObject(const MojObject& obj, Email& email)
{
	MojErr err;
	
	MojObject folderId;
	err = obj.getRequired(FOLDER_ID, folderId);
	ErrorToException(err);
	email.SetFolderId(folderId);
	
	MojString subject;
	err = obj.getRequired(SUBJECT, subject);
	ErrorToException(err);
	email.SetSubject( std::string(subject) );
	
	MojObject fromAddress;
	err = obj.getRequired(FROM, fromAddress);
	ErrorToException(err);
	email.SetFrom( ParseAddress(fromAddress) );
	
	// Optional replyTo address
	MojObject replyTo;
	if(obj.get(REPLY_TO, replyTo) && !replyTo.null()) {
		email.SetReplyTo( ParseAddress(replyTo) );
	}

	MojInt64 timestamp;
	err = obj.getRequired(TIMESTAMP, timestamp);
	ErrorToException(err);
	email.SetDateReceived(timestamp);
	
	// Parse recipients
	MojObject recipients;
	err = obj.getRequired(RECIPIENTS, recipients);
	ErrorToException(err);
	ParseRecipients(recipients, email);
	
	// Parse flags
	MojObject flags;
	if (obj.get(FLAGS, flags)) {
		ParseFlags(flags, email);
	}

	// Parse parts
	MojObject parts;
	err = obj.getRequired(PARTS, parts);
	ErrorToException(err);

	EmailPartList partList;
	ParseParts(parts, partList);
	email.SetPartList(partList);

	MojObject originalMsgId;
	if (obj.get(ORIGINAL_MSG_ID, originalMsgId)) {
		email.SetOriginalMsgId(originalMsgId);
	}

	MojString draftType;
	bool hasDraftType = false;
	err = obj.get(DRAFT_TYPE, draftType, hasDraftType);
	ErrorToException(err);
	if (hasDraftType) {
		email.SetDraftType( ParseDraftType(draftType) );
	}

	MojString priority;
	bool hasPriority = false;
	err = obj.get(PRIORITY, priority, hasPriority);
	ErrorToException(err);
	// If no priority exists, this will default to normal
	email.SetPriority(ParsePriority(priority));

	email.SetMessageId( DatabaseAdapter::GetOptionalString(obj, MESSAGE_ID) );
	email.SetInReplyTo( DatabaseAdapter::GetOptionalString(obj, IN_REPLY_TO) );

	// SendStatus
	// NOTE: This is not being serialized back to the database in SerializeToDatabaseObject
	MojObject sendStatus;
	if (obj.get(SEND_STATUS, sendStatus)) {
		bool isSent = false;
		if (sendStatus.get(SendStatus::SENT, isSent)) {
			email.SetSent(isSent);
		}
		bool hasFatalError = false;
		if (sendStatus.get(SendStatus::FATAL_ERROR, hasFatalError)) {
			email.SetHasFatalError(hasFatalError);
		}
		MojInt64 retryCount;
		if (sendStatus.get(SendStatus::RETRY_COUNT, retryCount)) {
			email.SetRetryCount(retryCount);
		}
		MojObject sendError;
		if (sendStatus.get(SendStatus::ERROR, sendError)) {
			MojObject errorCode;
			if (sendError.get(SendStatusError::ERROR_CODE, errorCode) && !errorCode.null() && !errorCode.undefined()) {
				email.SetSendError(static_cast<MailError::ErrorCode>(errorCode.intValue()));
			}
		}
	}
}