Пример #1
0
const QMimeSource* GofunMimeSourceFactory::data(const QString& abs_name) const
{
	if(abs_name.contains(".png") || abs_name.contains("bslogo"))
	{
	
		if(images.find(abs_name) != images.end())
		{
			QMimeSourceFactory* mf = new QMimeSourceFactory();
			mf->setPixmap(abs_name,*images[abs_name]);
			const QMimeSource* r = mf->data(abs_name);
			return r;
		}
	
		
		http->setHost("www.berlios.de");
		http->get(abs_name);
		
		
		if(!image_countdown[http->currentRequest().path()])
		{
			image_countdown[http->currentRequest().path()] = 2; //We start from 2, because 0 is the default and we will count down to 1.
		}
		else
		{
			++image_countdown[http->currentRequest().path()];
		}
	}
	else //if(abs_name.contains("index.php"))
	{
		if(p_gofun_help)
			p_gofun_help->openLink(abs_name);
	}
	
	const QMimeSource * r = QMimeSourceFactory::data( abs_name );
	return r;
}
Пример #2
0
void FLSmtpClient::startSend()
{
  emit sendStarted();

  emit sendTotalSteps(attachments_.count() + 3);

  int step = 0;

  emit sendStepNumber(++step);

  changeStatus(tr("Componiendo mensaje"), Composing);

  // only send logo when configured
  if (FLUtil::readSettingEntry("email/sendMailLogo", "true").toBool()) {
    QString logo(FLUtil::readSettingEntry("email/mailLogo",
                                          AQ_DATA + "/logo_mail.png").toString());
    if (!QFile::exists(logo)) {
      logo = AQ_DISKCACHE_DIRPATH + "/logo.png";
      QPixmap::fromMimeSource("logo_abanq.png").save(logo, "PNG");
    }

    attachments_ << logo;
    mapAttachCid_.insert(logo, QFileInfo(logo).fileName() + "@3d8b627b6292");
  }

  QString headerStr(QString::fromLatin1("from: ") + from_);
  if (!replyTo_.isEmpty())
    headerStr += QString::fromLatin1("\nreply-to: ") + replyTo_;
  headerStr += QString::fromLatin1("\nto: ") + to_ +
               QString::fromLatin1("\nsubject: ") + subject_;
  if (!cc_.isEmpty())
    headerStr += QString::fromLatin1("\ncc: ") + cc_;
  if (!bcc_.isEmpty())
    headerStr += QString::fromLatin1("\nbcc: ") + bcc_;
  if (!organization_.isEmpty())
    headerStr += QString::fromLatin1("\norganization: ") + organization_;
  if (priority_ > 0)
    headerStr += QString::fromLatin1("\npriority: ") +
                 QString::number(priority_);

  CharSets chS;
  HeaderClass hdr(headerStr.local8Bit());
  MessageClass msg(hdr);
  LocalMailFolder folder(AQ_DISKCACHE_DIRPATH + '/');
  QString idMessage = folder.createMessage(body_.local8Bit(), QCString(), QDateTime::currentDateTime(), "", &msg);
  IndexClass *idx = folder.indexIDict()[ idMessage ];
  MessageDevice msgDev(idx);

  MimePart *part0 = new MimePart();
  part0->charset = chS.getDefaultCharset();

  part0->mimetype = (mimeType_.isEmpty() ? "text/plain" : mimeType_);
  part0->encoding = "quoted-printable";
  part0->name = "body";
  part0->type = "text";
  QByteArray partData0 = body_.local8Bit();
  part0->length = partData0.count();
  int npart0 = idx->addPart(part0, false);
  msgDev.setPartData(npart0, partData0);

  emit sendStepNumber(++step);

  for (uint i = 0; i < textParts_.count(); i += 2) {
    part0 = new MimePart();
    part0->charset = chS.getDefaultCharset();
    part0->mimetype = textParts_[i + 1];
    part0->encoding = "quoted-printable";
    part0->type = "text";
    partData0 = textParts_[i].local8Bit();
    part0->length = partData0.count();
    npart0 = idx->addPart(part0, false);
    msgDev.setPartData(npart0, partData0);

    emit sendStepNumber(++step);
  }

  QStringList::Iterator itAttach;
  QString fileName;
  for (uint i = 0; i < attachments_.count(); i++) {
    itAttach = attachments_.at(i);
    fileName = *itAttach;

    changeStatus(tr("Adjuntando %1").arg(QFileInfo(fileName).fileName()), Attach);

    MimePart *part1 = new MimePart();
    part1->charset = chS.getDefaultCharset();
    QFile f(fileName);
    f.open(IO_Raw | IO_ReadOnly);
    QByteArray partData1 = f.readAll();
    f.close();
    part1->length = partData1.count();
    part1->name = QFileInfo(fileName).fileName();
    if (mapAttachCid_.contains(fileName))
      part1->cid = mapAttachCid_[fileName];
    const QMimeSource *mime = 0;
    QMimeSourceFactory *mimeFactory = mimeSourceFactory();
    if (mimeFactory) {
      mime = mimeFactory->data(fileName);
    } else {
      mime = QMimeSourceFactory::defaultFactory()->data(fileName);
    }
    if (mime && mime->format()) {
      part1->mimetype = mime->format();
      part1->encoding =  "base64";
    }
    int npart1 = idx->addPart(part1, false);
    msgDev.setPartData(npart1, partData1);

    emit sendStepNumber(++step);
  }

  QStringList rcpts(hdr.To.toQStringList());
  rcpts += hdr.Cc.toQStringList();
  rcpts += hdr.Bcc.toQStringList();

  Smtp *smtp = new Smtp(from_, rcpts, msgDev.rfc822Header(),
                        mailServer_, port_, this);

  smtp->setUser(user_);
  smtp->setPassword(password_);
  smtp->setConnectionType(connectionType_);
  smtp->setAuthMethod(authMethod_);

  emit sendStepNumber(++step);

  connect(smtp, SIGNAL(destroyed()),
          this, SIGNAL(sendEnded()));
  connect(smtp, SIGNAL(statusChanged(const QString &, int)),
          this, SLOT(changeStatus(const QString &, int)));
  smtp->init();
}