예제 #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 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);
}