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;
}
Example #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();
}
Example #3
0
void ReadMail::updateView()
{
	Enclosure *ePtr;
	QString mailStringSize;
	QString text, temp;

	mail->read = TRUE;			//mark as read
	inbox = mail->received;

	replyButton->setEnabled(false);
	/*replyButton->removeFrom(bar);
	forwardButton->removeFrom(mailMenu);
	forwardButton->removeFrom(bar);*/
	downloadButton->removeFrom(bar);

	//downloadButton->setEnabled(!mail->downloaded);


	if (inbox == TRUE) {
		replyButton->setEnabled(true);
		/*replyButton->addTo(mailMenu);
		forwardButton->addTo(bar);
		forwardButton->addTo(mailMenu);*/


		if (!mail->downloaded) {

			downloadButton->addTo(bar);

			//report currently viewed mail so that it will be
			//placed first in the queue of new mails to download
			emit viewingMail(mail);

			double mailSize = (double) mail->size;
			if (mailSize < 1024) {
				mailStringSize.setNum(mailSize);
				mailStringSize += " Bytes";
			} else if (mailSize < 1024*1024) {
				mailStringSize.setNum( (mailSize / 1024), 'g', 2 );
				mailStringSize += " Kb";
			} else {
				mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3);
				mailStringSize += " Mb";
			}
		}
	}

	QMimeSourceFactory *mime = emailView->mimeSourceFactory();

	if (! plainTxt) {						//use RichText, inline pics etc.
		emailView->setTextFormat(QTextView::RichText);
		text = "<b><big><center><font color=\"blue\">" + mail->subject
			+"</font></center></big></b><br>";
		text += "<b>From: </b>" + mail->from + " <i>" +
			mail->fromMail + "</i><br>";

		text +="<b>To: </b>";
	        for (QStringList::Iterator it = mail->recipients.begin();
	        	it != mail->recipients.end(); ++it ) {
			text += *it + " ";
		}

		text +="<br><b>CC: </b>";
	        for (QStringList::Iterator it = mail->carbonCopies.begin();
	        	it != mail->carbonCopies.end(); ++it ) {
			text += *it + " ";
		}

		text += "<br>"  + mail->date;

		if (mail->files.count() > 0) {
			text += "<br><b>Attatchments: </b>";

			for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
				text += ePtr->originalName + " ";
			}
			text += "<hr><br>" + mail->body;

			if (inbox) {
				for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {

					text += "<br><hr><b>Attatchment: </b>" +
						ePtr->originalName + "<hr>";

					if (ePtr->contentType == "TEXT") {
						QFile f(ePtr->path + ePtr->name);

						if (f.open(IO_ReadOnly) ) {
							QTextStream t(&f);
							temp = t.read();
							text += temp + "<br>";
							f.close();
						} else {
							text += "<b>Could not locate file</b><br>";
						}

					}
					if (ePtr->contentType == "IMAGE") {
//						temp.setNum(emailView->width());	//get display width
//						text += "<img width=" + temp +" src =""" +
//							ePtr->originalName + """> </img>";
						text += "<img src =""" +
							ePtr->originalName + """> </img>";
						mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) ));
					}
				}
			}
		} else {
			if (mail->downloaded || !inbox) {
				text += "<hr><br>" + mail->body;
			} else {
				text += "<hr><br><b> Awaiting download </b><br>";
				text += "Size of mail: " + mailStringSize;
			}
		}
		emailView->setText(text);
	} else {										// show plain txt mail
		emailView->setTextFormat(QTextView::PlainText);
		text = "Subject: " + mail->subject + "\n";
		text += "From: " + mail->from + " " + mail->fromMail + "\n";
		text += "To: ";
	        for (QStringList::Iterator it = mail->recipients.begin();
	        	it != mail->recipients.end(); ++it ) {
			text += *it + " ";
		}

		text += "\nCC: ";
	        for (QStringList::Iterator it = mail->carbonCopies.begin();
	        	it != mail->carbonCopies.end(); ++it ) {
			text += *it + " ";
		}


		text += "\nDate: " + mail->date + "\n";
		if (mail->files.count() > 0) {
			text += "Attatchments: ";
			for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
				text += ePtr->originalName + " ";
			}
			text += "\n\n";
		} else text += "\n";

		if (!inbox) {
			text += mail->body;
		} else if (mail->downloaded) {
			text += mail->bodyPlain;
		} else {
			text += "\nAwaiting download\n";
			text += "Size of mail: " + mailStringSize;
		}

		emailView->setText(text);
	}

	if (mail->files.count() == 0)
		attachmentButton->setEnabled(FALSE);
	else attachmentButton->setEnabled(TRUE);

	setCaption("Examining mail: " + mail->subject);
}