aboutsummaryrefslogtreecommitdiffstats
path: root/gpgwin.cpp
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-05-10 21:28:13 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-05-10 21:28:13 +0000
commit00bebcf42b3cd9cfdba11442d34ac2e3ed7da3bd (patch)
tree1d758444bc55f273226ecbff43862a742d836274 /gpgwin.cpp
parentupdated TODO (diff)
downloadgpg4usb-00bebcf42b3cd9cfdba11442d34ac2e3ed7da3bd.tar.gz
gpg4usb-00bebcf42b3cd9cfdba11442d34ac2e3ed7da3bd.zip
add mime-parser and basic attachment-recognise and show functionality
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@322 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'gpgwin.cpp')
-rw-r--r--gpgwin.cpp51
1 files changed, 43 insertions, 8 deletions
diff --git a/gpgwin.cpp b/gpgwin.cpp
index ea17627..633e3b8 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -44,10 +44,7 @@ GpgWin::GpgWin()
mKeyList = new KeyList(mCtx, iconPath);
/* List of binary Attachments */
- mAttachments = new Attachments();
- mAttachments->setIconPath(iconPath);
- mAttachments->setContext(mCtx);
- mAttachments->setKeyList(mKeyList);
+ mAttachments = new Attachments(iconPath);
createActions();
createMenus();
@@ -302,10 +299,16 @@ void GpgWin::createDockWindows()
dock->setWidget(mKeyList);
viewMenu->addAction(dock->toggleViewAction());
- /*dock = new QDockWidget(tr("Attached files:"), this);
- dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea );
- addDockWidget(Qt::BottomDockWidgetArea, dock);
- dock->setWidget(mAttachments);*/
+ /** Attachments-Dockwindow
+ */
+ aDock = new QDockWidget(tr("Attached files:"), this);
+ aDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea );
+ addDockWidget(Qt::BottomDockWidgetArea, aDock);
+ aDock->setWidget(mAttachments);
+ // hide till attachmendt is decrypted
+ aDock->hide();
+
+
}
void GpgWin::closeEvent(QCloseEvent *event)
@@ -499,11 +502,43 @@ void GpgWin::decrypt()
preventNoDataErr(&text);
mCtx->decrypt(text, tmp);
if (!tmp->isEmpty()) {
+ // is it mime? TODO: parseMime should be optional by setting
+ parseMime(tmp);
edit->setPlainText(QString::fromUtf8(*tmp));
}
}
/**
+ * if this is mime, split text and attachents...
+ * message contains only text afterwards
+ */
+void GpgWin::parseMime(QByteArray *message) {
+
+ if( ! Mime::isMultipart(message) ) {
+ qDebug() << "no multipart";
+ return;
+ }
+ qDebug() << "multipart";
+
+ QString pText;
+ bool showmadock = false;
+
+ Mime *mime = new Mime(message);
+ foreach(MimePart tmp, mime->parts()) {
+ if(tmp.getValue("Content-Type")=="text/plain") {
+ pText.append(QString(tmp.body));
+ }
+ else {
+ (mAttachments->addMimePart(&tmp));
+ showmadock=true;
+ }
+ }
+
+ *message = pText.toAscii();
+ if(showmadock) aDock->show();
+}
+
+/**
* if there is no '\n' before the PGP-Begin-Block, but for example a whitespace,
* GPGME doesn't recognise the Message as encrypted. This function adds '\n'
* before the PGP-Begin-Block, if missing.