Example #1
0
 void backend_client::text_edit_edited(ref_id id)
 {
     INVARIANT(mail());
     text_edit_edited_msg m;
     m.id = id;
     mail()->push_inbox(m.to_message());
 }
Example #2
0
 void backend_client::button_clicked(ref_id id)
 {
     INVARIANT(mail());
     button_clicked_msg m;
     m.id = id;
     mail()->push_inbox(m.to_message());
 }
Example #3
0
 void backend_client::run(const std::string& code)
 {
     INVARIANT(mail());
     run_code_msg m;
     m.code = code;
     mail()->push_inbox(m.to_message());
 }
Example #4
0
 void backend_client::timer_triggered(ref_id id)
 {
     INVARIANT(mail());
     timer_triggered_msg m;
     m.id = id;
     mail()->push_inbox(m.to_message());
 }
Example #5
0
 void backend_client::contact_quit(const std::string& id)
 {
     INVARIANT(mail());
     contact_quit_msg m;
     m.id = id;
     mail()->push_inbox(m.to_message());
 }
Example #6
0
 void backend_client::dropdown_selected(ref_id id, int item)
 {
     INVARIANT(mail());
     dropdown_selected_msg m;
     m.id = id;
     m.item = item;
     mail()->push_inbox(m.to_message());
 }
Example #7
0
 void backend_client::got_sound(ref_id id, const util::bytes& d)
 {
     INVARIANT(mail());
     got_sound_msg m;
     m.id = id;
     m.data = d;
     mail()->push_inbox(m.to_message());
 }
Example #8
0
 void backend_client::draw_mouse_moved(ref_id id, int x, int y)
 {
     INVARIANT(mail());
     draw_mouse_moved_msg m;
     m.id = id;
     m.x = x;
     m.y = y;
     mail()->push_inbox(m.to_message());
 }
Example #9
0
/*
 *  anything in <>'s is an address
 */
int
mailin(Fs *f, char *user, int32_t et, char *l, char *e)
{
	int n;
	int rcvrs;
	char *p;
	char addr[256];

	p = 0;
	rcvrs = 0;
	while(l < e){
		switch(*l){
		case '<':
			p = l + 1;
			break;
		case '>':
			if(p == 0)
				break;
			n = l - p;
			if(n > 0 && n <= sizeof(addr) - 2){
				memmove(addr, p, n);
				addr[n] = 0;
				rcvrs += mail(f, addr, user, et);
			}
			p = 0;
			break;
		}
		l++;
	}
	return rcvrs;
}
Example #10
0
void KIWAY::ExpressMail( FRAME_T aDestination,
                MAIL_T aCommand, const std::string& aPayload, wxWindow* aSource )
{
    KIWAY_EXPRESS   mail( aDestination, aCommand, aPayload, aSource );

    ProcessEvent( mail );
}
NS_IMETHODIMP nsAppleMailImportModule::GetImportInterface(const char *aImportType, nsISupports **aInterface)
{
  NS_ENSURE_ARG_POINTER(aImportType);
  NS_ENSURE_ARG_POINTER(aInterface);
  *aInterface = nsnull;
  nsresult rv = NS_ERROR_NOT_AVAILABLE;

  if (!strcmp(aImportType, "mail")) {
    nsCOMPtr<nsIImportMail> mail(do_CreateInstance(NS_APPLEMAILIMPL_CONTRACTID, &rv));
    if (NS_SUCCEEDED(rv)) {
      nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
      if (NS_SUCCEEDED(rv)) {
        nsCOMPtr<nsIImportGeneric> generic;
        rv = impSvc->CreateNewGenericMail(getter_AddRefs(generic));
        if (NS_SUCCEEDED(rv)) {
          nsAutoString name;
          rv = mBundle->GetStringFromID(APPLEMAILIMPORT_NAME, getter_Copies(name));
          NS_ENSURE_SUCCESS(rv, rv);

          nsCOMPtr<nsISupportsString> nameString(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv));
          NS_ENSURE_SUCCESS(rv, rv);
          nameString->SetData(name);

          generic->SetData("name", nameString);
          generic->SetData("mailInterface", mail);

          rv = CallQueryInterface(generic, aInterface);
        }
      }
    }
  }

  return rv;
}
Example #12
0
void MusikApp::OnFatalException ()
{
    wxDebugReportCompress report;

    // add all standard files: currently this means just a minidump and an
    // XML file with system info and stack trace
    report.AddAll(wxDebugReport::Context_Exception);
 
    // create a copy of our preferences file to include it in the report
    wxFileName destfn(report.GetDirectory(), _T("musik.ini"));
    wxCopyFile(wxFileConfig::GetLocalFileName(CONFIG_NAME),destfn.GetFullPath());

    report.AddFile(destfn.GetFullName(), _T("Current Preferences Settings"));

    // calling Show() is not mandatory, but is more polite
    if ( wxDebugReportPreviewStd().Show(report) )
    {
        if ( report.Process() )
        {
#ifdef USE_WXEMAIL
            wxMailMessage mail(GetAppName() +  _T(" Crash-Report"),_T("*****@*****.**"),
                MUSIKAPPNAME_VERSION wxT("crashed."),
                wxEmptyString,report.GetCompressedFileName(),_T("CrashReportZip"));
            if(!wxEmail::Send(mail))
                wxMessageBox(_T("Sending email failed!"));
#endif                
        }
    }
    //else: user cancelled the report
}
bool TSmtpMailer::cmdMail(const QByteArray &from)
{
    if (from.isEmpty())
        return false;

    QByteArray mail("MAIL FROM:<" + from + '>');
    return (cmd(mail) == 250);
}
Example #14
0
_EXPORT status_t
forward_mail(entry_ref *ref, const char *recipients, bool now)
{
	BFile file(ref, O_RDONLY);
	status_t status = file.InitCheck();
	if (status < B_OK)
		return status;

	BEmailMessage mail(&file);
	mail.SetTo(recipients);

	return mail.Send(now);
}
Example #15
0
void CountWriterMail::close ()
{
    for (CounterBase* ptr = CounterBase::head; ptr != 0 && sloth != INVALID_HANDLE_VALUE; ptr = ptr->next)
        if (ptr->key != 0)
            ptr->write(*this);

    mail(RUNSTOP"\0", strlen(RUNSTOP));

    if (sloth != INVALID_HANDLE_VALUE)
    {
        CloseHandle(sloth);
        sloth = INVALID_HANDLE_VALUE;
    }
}
Example #16
0
        void conversation_service::broadcast_message(const message::message& m)
        {
            u::mutex_scoped_lock l(_mutex);
            for(auto p : _conversations)
            {
                auto conversation = p.second;
                CHECK(conversation);

                auto mail = conversation->mail();
                CHECK(mail);

                mail->push_inbox(m);
            }
        }
Example #17
0
//  'server' should be name of the computer to which mail is sent or 0
//
bool CountWriterMail::open (const char* server)
{
    assert(sloth == INVALID_HANDLE_VALUE);

    char slotname[128];
    _snprintf(slotname, sizeof(slotname), "\\\\%s\\mailslot\\"MAILSLOT, (server == 0 || *server == 0) ? "." : server);

    sloth = CreateFile(slotname, GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); 

    mail(RUNSTART"\0", strlen(RUNSTART));

    if (sloth == INVALID_HANDLE_VALUE)
        cerr << "CountWriter failed to write to '" << slotname << "' (server not running?)" << endl;

    return sloth != INVALID_HANDLE_VALUE;
}
Example #18
0
int
smtp_client::mail_transaction(const string_ref& mailfrom,
  const string_ref& rcptto, const string_ref& bdy, posix_error_callback& ec)
{
  /* returns 2xx on success */
  int r = 0;
  if (!is_2xx(r = mail(mailfrom, ec))) {
    return r;
  }
  if (!is_2xx(r = rcpt(rcptto, ec))) {
    return r;
  }
  if (!is_3xx(r = data(ec))) {
    return r; /* asserted that r != 2xx */
  }
  return body(bdy, ec);
}
Example #19
0
CalendarEventStore::iterator CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover)
{
    CalendarEventStore::iterator current;
    CalendarEvent* calendarEvent = GetEvent(eventId, &current);

    if (!calendarEvent)
    {
        SendCalendarCommandResult(remover, CALENDAR_ERROR_EVENT_INVALID);
        return _events.end();
    }

    SendCalendarEventRemovedAlert(*calendarEvent);

    SQLTransaction trans = CharacterDatabase.BeginTransaction();
    PreparedStatement* stmt;
    MailDraft mail(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody());

    CalendarInviteStore& eventInvites = _invites[eventId];
    for (size_t i = 0; i < eventInvites.size(); ++i)
    {
        CalendarInvite* invite = eventInvites[i];
        stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE);
        stmt->setUInt64(0, invite->GetInviteId());
        trans->Append(stmt);

        // guild events only? check invite status here?
        // When an event is deleted, all invited (accepted/declined? - verify) guildies are notified via in-game mail. (wowwiki)
        if (remover && invite->GetInviteeGUID() != remover)
            mail.SendMailTo(trans, MailReceiver(invite->GetInviteeGUID()), calendarEvent, MAIL_CHECK_MASK_COPIED);

        delete invite;
    }

    _invites.erase(eventId);

    stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_EVENT);
    stmt->setUInt64(0, eventId);
    trans->Append(stmt);
    CharacterDatabase.CommitTransaction(trans);

    delete calendarEvent;
    current = _events.erase(current);
    return current;
}
Example #20
0
void TestMailMessage::parse()
{
    QString msg = QString::fromUtf8(
        "From: hoge <*****@*****.**>\n"               \
        "To: <*****@*****.**>\n"                      \
        "Cc: aoyama <*****@*****.**>\n"               \
        "Bcc: <*****@*****.**>, <*****@*****.**>\n" \
        "Date: Wed, 30 Mar 2011 19:53:04 +0900\n"       \
        "\n"                                            \
        "こんにちは");

    TMailMessage mail(msg);
    //qDebug("%s", mail.toByteArray().data());
    //qDebug("%d", mail.recipients().count());
    // foreach(QByteArray ba, mail.recipients()) {
    //     qDebug("recpt: %s", ba.data());
    // }
    QCOMPARE(mail.recipients().count(), 3);
}
Example #21
0
void CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover)
{
    CalendarEvent* calendarEvent = GetEvent(eventId);

    if (!calendarEvent)
    {
        SendCalendarCommandResult(remover, CALENDAR_ERROR_EVENT_INVALID);
        return;
    }

    SendCalendarEventRemovedAlert(*calendarEvent);

    SQLTransaction trans = CharacterDatabase.BeginTransaction();
    PreparedStatement* stmt;
    MailDraft mail(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody());

    std::vector<CalendarInvite*>::iterator itr = _invites[eventId].begin();
    while (itr != _invites[eventId].end())
    {
        stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE);
        stmt->setUInt64(0, (*itr)->GetInviteId());
        trans->Append(stmt);

        // guild events only? check invite status here?
        // When an event is deleted, all invited (accepted/declined? - verify) guildies are notified via in-game mail. (wowwiki)
        if (remover && (*itr)->GetInviteeGUID() != remover)
            mail.SendMailTo(trans, MailReceiver((*itr)->GetInviteeGUID()), calendarEvent, MAIL_CHECK_MASK_COPIED);

        delete *itr;
        _invites[eventId].erase(itr);
    }

    _invites.erase(eventId);

    stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_EVENT);
    stmt->setUInt64(0, eventId);
    trans->Append(stmt);
    CharacterDatabase.CommitTransaction(trans);

    delete calendarEvent;
    _events.erase(calendarEvent);
}
Example #22
0
void S411FeedBack::submit(CCObject * pSender)
{    
    AppDelegate::loadingLabel = CCLabelTTF::create("提交中", s1FontName_macro, 40);
    AppDelegate::loadingLabel->setPosition(ccp(visibleSize.width/2,visibleSize.height/2));
    AppDelegate::loadingLabel->setColor(ccRED);
    this->addChild(AppDelegate::loadingLabel,zNum+1000);
    
    string name(nameBox->getText());
    string sex;
    if (isMale)
    {
        sex = "男";
    }
    else
    {
        sex = "女";
    }
    string tel(telBox->getText());
    if (name.size()==0||tel.size()==0)
    {
        AppDelegate::loadingLabel ->setString("请完整填写必填信息");
        this->schedule(schedule_selector(S411FeedBack::time),1.0f,false,0.0);
        return;
    }
    string mobilePhone(mobilePhoneBox->getText());
    string mail(mailBox->getText());
    string msn(msnBox->getText());
    string address(addressBox->getText());
    //textView->setTextViewString("");
    string yanzheng(yanzhengBox->getText());
    string submitStr(submitBox->getText());
    
    string requestSr = "http://www.jrsp.cn/app/iwant.php?name="+name+"&sex="+sex+"&phone="+tel+"&mobile="+mobilePhone+"&email="+mail+"&qq="+msn+"&address="+address+"&message="+submitStr;
    requestSr = PersonalApi::string_replace(requestSr," ","%20");
     requestSr = PersonalApi::string_replace(requestSr,"\n","%0D");
    PostToUrl(requestSr.c_str(),"name","name");
    
    //setButtonEnabel(true);
}
	void SDTestObject::test<5>()
		// conversion of String to and from UUID, Date and URI.
	{
		SDCleanupCheck check;
		
		LLSD v;
		
		LLUUID nullUUID;
		LLUUID someUUID;
		someUUID.generate();
		
		v = nullUUID;	checkRoundTrip("null uuid", v,
							"00000000-0000-0000-0000-000000000000", nullUUID);
		v = someUUID;	checkRoundTrip("random uuid", v, 0, someUUID);
		
		LLDate epoch;
		LLDate beta("2003-04-30T04:00:00Z");
		LLDate oneOh("2003-06-23T04:00:00Z");
		
		v = epoch;		checkRoundTrip("epoch date", v, 0, epoch);
		v = beta;		checkRoundTrip("beta date", v,
							"2003-04-30T04:00:00Z", beta);
		v = oneOh;		checkRoundTrip("1.0 date", v,
							"2003-06-23T04:00:00Z", oneOh);
		
		LLURI empty;
		LLURI path("http://slurl.com/secondlife/Ambleside/57/104/26/");
		LLURI mail("mailto:[email protected]");
		
		v = empty;		checkRoundTrip("empty URI", v, 0, empty);
		v = path;		checkRoundTrip("path URI", v,
							"http://slurl.com/secondlife/Ambleside/57/104/26/",
							path);
		v = mail;		checkRoundTrip("mail URI", v,
							"mailto:[email protected]", mail);
	}
Example #24
0
PUBLIC int
main(int argc, char *argv[])
{
	jmp_buf jmpbuf;
	struct sigaction sa;
	struct name *to, *cc, *bcc, *smopts;
#ifdef MIME_SUPPORT
	struct name *attach_optargs;
	struct name *attach_end;
#endif
	char *subject;
	const char *ef;
	char nosrc = 0;
	const char *rc;
	int Hflag;
	int i;

	/*
	 * For portability, call setprogname() early, before
	 * getprogname() is called.
	 */
	(void)setprogname(argv[0]);

	/*
	 * Set up a reasonable environment.
	 * Figure out whether we are being run interactively,
	 * start the SIGCHLD catcher, and so forth.
	 * (Other signals are setup later by sig_setup().)
	 */
	(void)sigemptyset(&sa.sa_mask);
	sa.sa_flags = SA_RESTART;
	sa.sa_handler = sigchild;
	(void)sigaction(SIGCHLD, &sa, NULL);

	if (isatty(0))
		assign(ENAME_INTERACTIVE, "");
	image = -1;

	/*
	 * Now, determine how we are being used.
	 * We successively pick off - flags.
	 * If there is anything left, it is the base of the list
	 * of users to mail to.  Argp will be set to point to the
	 * first of these users.
	 */
	rc = NULL;
	ef = NULL;
	to = NULL;
	cc = NULL;
	bcc = NULL;
	smopts = NULL;
	subject = NULL;
	Hflag = 0;
#ifdef MIME_SUPPORT
	attach_optargs = NULL;
	attach_end = NULL;
	while ((i = getopt(argc, argv, ":~EH:INT:a:b:c:dfinr:s:u:v")) != -1)
#else
	while ((i = getopt(argc, argv, ":~EH:INT:b:c:dfinr:s:u:v")) != -1)
#endif
	{
		switch (i) {
		case 'T':
			/*
			 * Next argument is temp file to write which
			 * articles have been read/deleted for netnews.
			 */
			Tflag = optarg;
			if ((i = creat(Tflag, 0600)) < 0) {
				warn("%s", Tflag);
				exit(1);
			}
			(void)close(i);
			break;
#ifdef MIME_SUPPORT
		case 'a': {
			struct name *np;
			np = nalloc(optarg, 0);
			if (attach_end == NULL)
				attach_optargs = np;
			else {
				np->n_blink = attach_end;
				attach_end->n_flink = np;
			}
			attach_end = np;
			break;
		}
#endif
		case 'u':
			/*
			 * Next argument is person to pretend to be.
			 */
			myname = optarg;
			(void)unsetenv("MAIL");
			break;
		case 'i':
			/*
			 * User wants to ignore interrupts.
			 * Set the variable "ignore"
			 */
			assign(ENAME_IGNORE, "");
			break;
		case 'd':
			debug++;
			break;
		case 'r':
			rc = optarg;
			break;
		case 's':
			/*
			 * Give a subject field for sending from
			 * non terminal
			 */
			subject = optarg;
			break;
		case 'f':
			/*
			 * User is specifying file to "edit" with Mail,
			 * as opposed to reading system mailbox.
			 * If no argument is given after -f, we read his
			 * mbox file.
			 *
			 * getopt() can't handle optional arguments, so here
			 * is an ugly hack to get around it.
			 */
			if ((argv[optind]) && (argv[optind][0] != '-'))
				ef = argv[optind++];
			else
				ef = "&";
			break;
		case 'H':
			/*
			 * Print out the headers and quit.
			 */
			Hflag = get_Hflag(argv);
			break;
		case 'n':
			/*
			 * User doesn't want to source /usr/lib/Mail.rc
			 */
			nosrc++;
			break;
		case 'N':
			/*
			 * Avoid initial header printing.
			 */
			assign(ENAME_NOHEADER, "");
			break;
		case 'v':
			/*
			 * Send mailer verbose flag
			 */
			assign(ENAME_VERBOSE, "");
			break;
		case 'I':
		case '~':
			/*
			 * We're interactive
			 */
			assign(ENAME_INTERACTIVE, "");
			break;
		case 'c':
			/*
			 * Get Carbon Copy Recipient list
			 */
			cc = cat(cc, lexpand(optarg, GCC));
			break;
		case 'b':
			/*
			 * Get Blind Carbon Copy Recipient list
			 */
			bcc = cat(bcc, lexpand(optarg, GBCC));

			break;
		case 'E':
			/*
			 * Don't send empty files.
			 */
			assign(ENAME_DONTSENDEMPTY, "");
			break;
		case ':':
			/*
			 * An optarg was expected but not found.
			 */
			if (optopt == 'H') {
				Hflag = get_Hflag(NULL);
				break;
			}
			(void)fprintf(stderr,
			    "%s: option requires an argument -- %c\n",
			    getprogname(), optopt);

			/* FALLTHROUGH */
		case '?':
			/*
			 * An unknown option flag.  We need to do the
			 * error message.
			 */
			if (optopt != '?')
				(void)fprintf(stderr,
				    "%s: unknown option -- %c\n", getprogname(),
				    optopt);
			usage();	/* print usage message and die */
			/*NOTREACHED*/
		}
	}
	for (i = optind; (argv[i]) && (*argv[i] != '-'); i++)
		to = cat(to, nalloc(argv[i], GTO));
	for (/*EMPTY*/; argv[i]; i++)
		smopts = cat(smopts, nalloc(argv[i], GSMOPTS));
	/*
	 * Check for inconsistent arguments.
	 */
	if (to == NULL && (subject != NULL || cc != NULL || bcc != NULL))
		errx(EXIT_FAILURE, "You must specify direct recipients with -s, -c, or -b.");
	if (ef != NULL && to != NULL) {
		errx(EXIT_FAILURE, "Cannot give -f and people to send to.");
	}
	if (Hflag != 0 && to != NULL)
		errx(EXIT_FAILURE, "Cannot give -H and people to send to.");
#ifdef MIME_SUPPORT
	if (attach_optargs != NULL && to == NULL)
		errx(EXIT_FAILURE, "Cannot give -a without people to send to.");
#endif
	tinit();	/* must be done before loading the rcfile */
	input = stdin;
	mailmode = Hflag ? mm_hdrsonly :
	    to ? mm_sending : mm_receiving;

	spreserve();
	if (!nosrc)
		load(_PATH_MASTER_RC);
	/*
	 * Expand returns a savestr, but load only uses the file name
	 * for fopen, so it's safe to do this.
	 */
	if (rc == NULL && (rc = getenv("MAILRC")) == NULL)
		rc = "~/.mailrc";
	load(expand(rc));
	setscreensize();	/* do this after loading the rcfile */

#ifdef USE_EDITLINE
	/*
	 * This is after loading the MAILRC so we can use value().
	 * Avoid editline in mm_hdrsonly mode or pipelines will screw
	 * up.  XXX - there must be a better way!
	 */
	if (mailmode != mm_hdrsonly)
		init_editline();
#endif

	sig_setup();

	switch (mailmode) {
	case mm_sending:
		(void)mail(to, cc, bcc, smopts, subject,
		    mime_attach_optargs(attach_optargs));
		/*
		 * why wait?
		 */
		exit(senderr);
		break;	/* XXX - keep lint happy */

	case mm_receiving:
	case mm_hdrsonly:
		/*
		 * Ok, we are reading mail.
		 * Decide whether we are editing a mailbox or reading
		 * the system mailbox, and open up the right stuff.
		 */
		if (ef == NULL)
			ef = "%";
		if (setfile(ef) < 0)
			exit(1);		/* error already reported */
		if (value(ENAME_QUIET) == NULL)
			(void)printf("Mail version %s.  Type ? for help.\n",
			    version);
		if (mailmode == mm_hdrsonly)
			show_headers_and_exit(Hflag);	/* NORETURN */
		announce();
		(void)fflush(stdout);

		if (setjmp(jmpbuf) != 0) {
			/* Return here if quit() fails below. */
			(void)printf("Use 'exit' to quit without saving changes.\n");
		}
		commands();

		/* Ignore these signals from now on! */
		(void)signal(SIGHUP, SIG_IGN);
		(void)signal(SIGINT, SIG_IGN);
		(void)signal(SIGQUIT, SIG_IGN);
		quit(jmpbuf);
		break;

	default:
		assert(/*CONSTCOND*/0);
		break;
	}

	return 0;
}
Example #25
0
void CountWriterMail::write (const char* key, double value)
{
    char buff[128];
    mail(buff, _snprintf(buff, sizeof(buff), "%s=%G", key, value));
}
Example #26
0
void Donations::sendEmail() {
	QSettings settings;
	Section sec;
	PPSPerson pers;
	QString subject, message, email;
	QString attachment = tr("Donations_%1.qif").arg(QDate::currentDate().toString("yyyy-MM-dd"));
	
	Smtp mail(settings.value("smtp/host", "localhost").toString(), settings.value("smtp/port", 587).toInt());
	if (settings.value("smtp/authentication", "login").toString() == "login") {
		mail.authLogin(settings.value("smtp/username", "").toString(), settings.value("smtp/password", "").toString());
	} else {
		mail.authPlain(settings.value("smtp/username", "").toString(), settings.value("smtp/password", "").toString());
	}
	
	// Send the Donations by EMail
	createQif();
	QList<QString>::const_iterator section;
	QList<QString> keys = sectionQif.keys();
	for (section = keys.constBegin(); section != keys.constEnd(); section++) {
		// Create a tmp file form the QIF
		char fname [L_tmpnam];
		tmpnam(fname);
		QString fileName(fname);
		QFile f(fileName);
		if (f.open(QFile::WriteOnly | QFile::Truncate)) {
			QTextStream out(&f);
			out << sectionQif.value(*section);
			out.flush();
			f.close();
		}
		mail.clearAttachments();
		mail.attach(fileName, attachment);
		
		// Load the treasurer of the current Section
		sec.load(*section);
		pers.load(sec.treasurer());
		
		// TODO: Load Subject and Texts
		subject = QString("Donations for %1").arg(*section);
		message = "Ahoi Treasurer,\n"
			"This time still in a not verry beautifull Mailing.\n"
			"In future you will also receive an additional PDF-Evidence with all information included. This time, the evidence from your Bank has to be be enough.\n\n"
			"Attatched you'l find the contribution of the donations of the Pirate Party Switzerland for your section as a Quicken-Interchange File. This you can easily import with GnuCash in your accounting through 'File' -> 'Import' -> 'Import QIF...'.\n"
			"You will receive the settlement during next days, change the valuta after in the imported booking.\n\n"
			"Greetings,\nLukas Zurschmiede\nTreasurer Pirate Party Switzerland\n";
		
		// Set the Mailtext and send the mail
		mail.setTextMessage(message);
		email = settings.value("smtp/from", "").toString();
		if (pers.email().length() > 0) {
			email = pers.email().at(0);
		}
		
		// If sending was not successfull (or no treasurer was found), let the user save the QIF
		if (email.isEmpty() || !mail.send(settings.value("smtp/from", "*****@*****.**").toString(), email, subject)) {
			QString fileName = QFileDialog::getSaveFileName(this, tr("Save donations for the section"), "", tr("Quicken Interchange Format (*.qif)"));
			if (!fileName.isEmpty()) {
				if (QFile::exists(fileName)) {
					QFile::remove(fileName);
				}
				if (!QFile::copy(fname, fileName)) {
					qDebug() << "Error while copying the QIF: " << fname << " to " << fileName;
				}
			}
		}
		
		// remove the tmp file
		remove(fname);
	}
}
/*!
  Delivers an email generated by setting variables to the specified template.
*/
bool TActionMailer::deliver(const QString &templateName)
{
    // Creates the view-object
    TDispatcher<TActionView> viewDispatcher(viewClassName(CONTROLLER_NAME, templateName));
    TActionView *view = viewDispatcher.object();
    if (!view) {
        tSystemError("no such template : %s", qPrintable(templateName));
        return false;
    }

    view->setVariantMap(allVariants());
    QString msg = view->toString();
    if (msg.isEmpty()) {
        tSystemError("Mail Message Empty: template name:%s", qPrintable(templateName));
        return false;
    }

    TMailMessage mail(msg, Tf::appSettings()->value(Tf::ActionMailerCharacterSet, "UTF-8").toByteArray());

    // Sets SMTP settings
    bool delay = Tf::appSettings()->value(Tf::ActionMailerDelayedDelivery, false).toBool();

    QByteArray dm = Tf::appSettings()->value(Tf::ActionMailerDeliveryMethod).toByteArray().toLower();
    if (dm == "smtp") {
        // SMTP
        TSmtpMailer *mailer = new TSmtpMailer;
        mailer->setHostName(Tf::appSettings()->value(Tf::ActionMailerSmtpHostName).toByteArray());
        mailer->setPort(Tf::appSettings()->value(Tf::ActionMailerSmtpPort).toUInt());
        mailer->setAuthenticationEnabled(Tf::appSettings()->value(Tf::ActionMailerSmtpAuthentication).toBool());
        mailer->setUserName(Tf::appSettings()->value(Tf::ActionMailerSmtpUserName).toByteArray());
        mailer->setPassword(Tf::appSettings()->value(Tf::ActionMailerSmtpPassword).toByteArray());
        tSystemDebug("%s", mail.toByteArray().data());

        // POP before SMTP
        if ( Tf::appSettings()->value(Tf::ActionMailerSmtpEnablePopBeforeSmtp, false).toBool() ) {
            QByteArray popSvr = Tf::appSettings()->value(Tf::ActionMailerSmtpPopServerHostName).toByteArray();
            quint16 popPort = Tf::appSettings()->value(Tf::ActionMailerSmtpPopServerPort).toInt();
            bool apop = Tf::appSettings()->value(Tf::ActionMailerSmtpPopServerEnableApop, false).toBool();

            mailer->setPopBeforeSmtpAuthEnabled(popSvr, popPort, apop, true);
        }

        // Sends email
        if (delay) {
            mailer->sendLater(mail);
        } else {
            mailer->send(mail);
            mailer->deleteLater();
        }

    } else if (dm == "sendmail") {
        // Command location of 'sendmail'
        QString cmd = Tf::appSettings()->value(Tf::ActionMailerSendmailCommandLocation).toString().trimmed();
        if (cmd.isEmpty()) {
            cmd = Tf::appSettings()->value(Tf::ActionMailerSendmailCommandLocation).toString().trimmed();
        }

        if (!cmd.isEmpty()) {
            TSendmailMailer *mailer = new TSendmailMailer(cmd);
            QByteArray rawmail = mail.toByteArray();
            QList<QByteArray> recipients = mail.recipients();

            if (delay) {
                mailer->sendLater(mail);
            } else {
                mailer->send(mail);
                mailer->deleteLater();
            }
        }

    } else if (dm.isEmpty()) {
        // not send
    } else {
        // Bad parameter
        tSystemError("SMTP: Bad Parameter: ActionMailer.DeliveryMethod: %s", dm.data());
        return false;
    }
    return true;
}
Example #28
0
static void mail_func_read(t_connection * c, std::istream& istr)
{
	if (!c) {
		ERROR0("got NULL connection");
		return;
	}

	std::string token;
	istr >> token;

	t_account * user = conn_get_account(c);
	Mailbox mbox(account_get_uid(user));

	if (token.empty()) { /* user wants to see the mail summary */
		if (mbox.empty()) {
			message_send_text(c,message_type_info,c,"You have no mail.");
			return;
		}

		MailList mlist;
		mbox.readAll(mlist);

		std::ostringstream ostr;
		ostr << "You have " << mbox.size() << " messages. Your mail quote is set to " << get_mail_quota(user) << '.';
		message_send_text(c, message_type_info, c, ostr.str().c_str());
		message_send_text(c, message_type_info, c, "ID    Sender          Date");
		message_send_text(c, message_type_info, c, "-------------------------------------");

		for(MailList::const_iterator it(mlist.begin()); it != mlist.end(); ++it) {
			ostr.str("");
			ostr << std::setfill('0') << std::setw(2) << std::right << (it - mlist.begin()) << "    "
			     << std::setfill(' ') << std::setw(14) << std::left << it->sender() << ' ';
			char buff[128];
			std::strftime(buff, sizeof(buff), "%a %b %d %H:%M:%S %Y", std::localtime(&it->timestamp()));
			ostr << buff;
			message_send_text(c, message_type_info, c, ostr.str().c_str());
		}

		message_send_text(c,message_type_info,c,"Use /mail read <ID> to read the content of any message");
	} else { /* user wants to read a message */
		if (std::find_if(token.begin(), token.end(), NonNumericChar) != token.end()) {
			message_send_text(c,message_type_error,c,"Invalid index. Please use /mail read <index> where <index> is a number.");
			return;
		}

		try {
			unsigned idx = std::atoi(token.c_str());
			Mail mail(mbox.read(idx));

			std::ostringstream ostr;
			ostr << "Message #" << idx << " from " << mail.sender() << " on ";
			char buff[128];
			std::strftime(buff, sizeof(buff), "%a %b %d %H:%M:%S %Y", std::localtime(&mail.timestamp()));
			ostr << buff << ':';
			message_send_text(c, message_type_info, c, ostr.str().c_str());
			message_send_text(c, message_type_info, c, mail.message().c_str());
		} catch (const Mailbox::ReadError&) {
			message_send_text(c,message_type_error,c,"There was an error completing your request.");
		}
	}
}
Example #29
0
/*
 *  check for expiration
 */
void
douser(Fs *f, char *user)
{
	int n, nwarn;
	char buf[128];
	int32_t rcvrs, et, now;
	char *l;

	snprint(buf, sizeof buf, "%s/expire", user);
	et = readnumfile(buf);
	now = time(0);

	/* start warning 2 weeks ahead of time */
	if(et <= now || et > now+14*24*60*60)
		return;

	snprint(buf, sizeof buf, "%s/warnings", user);
	nwarn = readnumfile(buf);
	if(et <= now+14*24*60*60 && et > now+7*24*60*60){
		/* one warning 2 weeks before expiration */
		if(nwarn > 0)
			return;
		nwarn = 1;
	} else {
		/* one warning 1 week before expiration */
		if(nwarn > 1)
			return;
		nwarn = 2;
	}

	/*
	 *  if we can't open the who file, just mail to the user and hope
 	 *  for it makes it.
	 */
	if(f->b){
		if(Bseek(f->b, 0, 0) < 0){
			Bterm(f->b);
			f->b = 0;
		}
	}
	if(f->b == 0){
		f->b = Bopen(f->who, OREAD);
		if(f->b == 0){
			if(mail(f, user, user, et) > 0)
				writenumfile(buf, nwarn);
			return;
		}
	}

	/*
	 *  look for matches in the who file and mail to every address on
	 *  matching lines
	 */
	rcvrs = 0;
	while((l = Brdline(f->b, '\n')) != nil){
		n = strlen(user);
		if(strncmp(l, user, n) == 0 && (l[n] == ' ' || l[n] == '\t'))
			rcvrs += mailin(f, user, et, l, l+Blinelen(f->b));
	}

	/*
	 *  if no matches, try the user directly
	 */
	if(rcvrs == 0)
		rcvrs = mail(f, user, user, et);
	rcvrs += mail(f, "netkeys", user, et);
	if(rcvrs)
		writenumfile(buf, nwarn);
}
Example #30
0
 void backend_client::reset()
 {
     INVARIANT(mail());
     reset_msg m;
     mail()->push_inbox(m.to_message());
 }