void TMailMessage::parse(const QString &str) { QRegExp rx("(\\n\\n|\\r\\n\\r\\n)", Qt::CaseSensitive, QRegExp::RegExp2); int idx = rx.indexIn(str, 0); int bdidx = idx + rx.matchedLength(); if (idx < 0) { tError("Not found mail headers"); setBody(str); } else { QString header = str.left(idx); QByteArray ba; ba.reserve((int)(header.length() * 1.2)); int i = 0; while (i < header.length()) { char c = header[i].toLatin1(); if (c > 0) { ba += c; ++i; } else { // not Latin-1 char int j = indexOfUsAscii(header, i); if (j < 0) { j = header.length(); } ba += THttpUtility::toMimeEncoded(header.mid(i, j - i), textCodec); i = j; } } // Parses header TInternetMessageHeader::parse(ba); addRecipients(addresses("To")); addRecipients(addresses("Cc")); addRecipients(addresses("Bcc")); // Sets body QString body = str.mid(bdidx); setBody(body); } }
void multipleCheckDialog::on_pushButton_2_clicked() { QList<QRecipientWidget*> l; for(int x = 0; x < ui->listWidget->count(); ++x) { contactWidgetFastBook *w = static_cast<contactWidgetFastBook*>(ui->listWidget->itemWidget(ui->listWidget->item(x))); if (w->isChecked()) { QRecipientWidget *wi = new QRecipientWidget(w->getContact().getName(), w->getContact().getAccount(), w->getContact().getPhone(), w->getIcon()); l.push_back(wi); } } emit addRecipients(l); close(); }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool MEmailPlugin::init(const Config::Config& cfg) { if ( !MonitorPluginInterface::init(cfg) ) return false; try { std::vector<std::string> recipients = cfg.getStrings(name() + ".recipients"); addRecipients(recipients); } catch( Config::Exception& e ) { SEISCOMP_ERROR("MEmailPlugin could not be initialized due to missing recipients list: %s", e.what()); setOperational(false); } try { _template = cfg.getString(name() + ".template"); } catch ( Config::Exception& e ) { SEISCOMP_DEBUG("%s", e.what()); } try { std::vector<std::string> requiredClients = cfg.getStrings(name() + ".requiredClients"); for (size_t i = 0; i < requiredClients.size(); ++i) { _requiredClients.insert(std::make_pair(requiredClients[i], false)); } } catch ( Config::Exception& e ) { SEISCOMP_DEBUG("%s", e.what()); } try { _reportSilentClients = cfg.getBool(name() + ".reportSilentClients"); } catch ( Config::Exception& e ) { SEISCOMP_DEBUG("%s", e.what()); } try { _reportSilentClientsTimeSpan = Core::TimeSpan(cfg.getDouble(name() + ".reportSilentClientsTimeSpan") * 60); } catch ( Config::Exception& e ) { SEISCOMP_DEBUG("%s", e.what()); } try { double filterMeanInterval = cfg.getDouble(name() + ".filterMeanInterval"); setFilterMeanInterval(filterMeanInterval); } catch (Config::Exception& e) { SEISCOMP_DEBUG("%s", e.what()); } try { _reportRequiredClientsTimeSpan = cfg.getDouble(name() + ".reportRequiredClients") * 60; } catch ( Config::Exception& e ) { SEISCOMP_DEBUG("%s", e.what()); } try { _sendEmail = cfg.getBool(name() + ".sendEmail"); } catch ( Config::Exception& e ) { SEISCOMP_DEBUG("%s", e.what()); } _sender= std::auto_ptr<EmailSender>(EmailSender::Create()); if ( !_sender.get() ) { SEISCOMP_ERROR("MEmailPlugin could not be initialized. Email service not available!"); setOperational(false); } std::stringstream ss; ss << "This message has been automatically generated by scm on host: " << Core::getHostname() << " for master: master@" << SCCoreApp->connection()->masterAddress() << std::endl; _message.setHeader(ss.str()); ss.str(std::string()); ss << "The following clients match the given filter condition:" << std::endl; ss << filterString(); _message.setHeaderFilteredClients(ss.str()); ss.str(std::string()); ss << "Some of the connected have been silent for more than " << _reportRequiredClientsTimeSpan << " seconds" << std::endl; ss << "'-' denotes a silent and '+' a recovered client."; _message.setHeaderSilentClients(ss.str()); ss.str(std::string()); ss << "Some required clients are disconnected (-) or reconnected (+)" << std::endl; ss << "Required clients: "; RequiredClients::iterator it = _requiredClients.begin(); for ( ; it != _requiredClients.end(); ++it ) { if ( it != _requiredClients.begin() ) ss << ", "; ss << it->first; } _message.setHeaderRequiredClients(ss.str()); return true; }