-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mailit/emailhandler.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mailit/mailitwindow.cpp | 22 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailhandler.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/mailit/mailitwindow.cpp | 22 |
6 files changed, 42 insertions, 34 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 2102ba7..da1226c 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp @@ -448,52 +448,52 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) } } bool found=false; if (!fromDisk) { Email *mailPtr; item = (EmailListItem *) inboxView->firstChild(); while ((item != NULL)&&(!found)) { mailPtr = item->getMail(); if (mailPtr->id == newMail.id) { item->setMail(newMail); emit mailUpdated(item->getMail()); found = true; } item = (EmailListItem *) item->nextSibling(); } } if ((!found)||(fromDisk)) { item = new EmailListItem(inboxView, newMail, TRUE); } - if (item->getMail()->files.count()>0) - { - item->setPixmap(0, Resource::loadPixmap("mailit/attach")); - } +// if (item->getMail()->files.count()>0) +// { +// item->setPixmap(0, Resource::loadPixmap("mailit/attach")); +// } /*if (!newMail.downloaded) mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ mailboxView->setCurrentTab(0); } void EmailClient::allMailArrived(int count) { // not previewing means all mailtransfer has been done /*if (!previewingMail) {*/ if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { emit newCaption("Mailit - " + currentAccount->accountName); getNewMail(); return; } else { allAccounts = FALSE; receiving = FALSE; getMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); selectAccountMenu->setEnabled(TRUE); status1Label->setText("Idle"); progressBar->reset(); diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index 59ccd90..39f693d 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp @@ -154,50 +154,52 @@ bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mai int pos; QString delimiter, header, body, mimeHeader, mimeBody; QString content, contentType, contentAttribute, id, encoding; QString fileName, storedName; int enclosureId = 0; mail->rawMail = in; mail->received = TRUE; mail->files.setAutoDelete(TRUE); temp = lineShift + "." + lineShift; if (in.right(temp.length()) != temp) { mail->rawMail += temp; } delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" pos = in.find(delimiter, 0, FALSE); header = in.left(pos); body = in.right(in.length() - pos - delimiter.length()); if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) body.truncate(body.length()-2); - TextParser p(header, lineShift); - + // TextParser p(header, lineShift); + TextParser * lp = new TextParser(header, lineShift); +#define p (*lp) + if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { pos++; if (p.separatorAt(pos) == ' ') { mail->from = p.getString(&pos, '<', false); mail->from = mail->from.stripWhiteSpace(); if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { mail->from = mail->from.left(mail->from.length() - 1); mail->from = mail->from.right(mail->from.length() - 1); } pos++; mail->fromMail = p.getString(&pos, '>', false); } else { if (p.separatorAt(pos) == '<') //No name.. nasty pos++; //pos++; mail->fromMail = p.getString(&pos, 'z', TRUE); if (mail->fromMail.at(mail->fromMail.length()-1) == '>') mail->fromMail.truncate(mail->fromMail.length() - 1); mail->from=mail->fromMail; } } pos=0; @@ -249,48 +251,49 @@ bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mai if ( (p.wordAt(pos).upper() == "VERSION") && (p.separatorAt(pos) == ':') ) { pos++; if (p.getString(&pos, 'z', true) == "1.0") { mail->mimeType = 1; } } } if (mail->mimeType == 1) { boundary = ""; if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { pos++; boundary = p.getString(&pos, 'z', true); if (boundary[0] == '"') { boundary = boundary.left(boundary.length() - 1); //strip " boundary = boundary.right(boundary.length() - 1); //strip " } boundary = "--" + boundary; //create boundary field } if (boundary == "") { //fooled by Mime-Version mail->body = body; mail->bodyPlain = body; + delete lp; return mail; } while (body.length() > 0) { pos = body.find(boundary, 0, FALSE); pos = body.find(delimiter, pos, FALSE); mimeHeader = body.left(pos); mimeBody = body.right(body.length() - pos - delimiter.length()); TextParser bp(mimeHeader, lineShift); contentType = ""; contentAttribute = ""; fileName = ""; if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { pos++; if ( (bp.wordAt(pos).upper() == "TYPE") && (bp.separatorAt(pos) == ':') ) { contentType = bp.nextWord().upper(); if (bp.nextSeparator() == '/') contentAttribute = bp.nextWord().upper(); content = contentType + "/" + contentAttribute; } if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { pos++; @@ -317,48 +320,49 @@ bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mai e.id = enclosureId; e.originalName = fileName; e.contentType = contentType; e.contentAttribute = contentAttribute; e.encoding = encoding; e.body = mimeBody; e.saved = FALSE; mail->addEnclosure(&e); enclosureId++; } else if (contentType == "TEXT") { if (contentAttribute == "PLAIN") { mail->body = mimeBody; mail->bodyPlain = mimeBody; } if (contentAttribute == "HTML") { mail->body = mimeBody; } } } } else { mail->bodyPlain = body; mail->body = body; } + delete lp; return TRUE; } bool EmailHandler::getEnclosure(Enclosure *ePtr) { QFile f(ePtr->path + ePtr->name); char src[4]; char *destPtr; QByteArray buffer; uint bufCount, pos, decodedCount, size, x; if (! f.open(IO_WriteOnly) ) { qWarning("could not save: " + ePtr->path + ePtr->name); return FALSE; } if (ePtr->encoding.upper() == "BASE64") { size = (ePtr->body.length() * 3 / 4); //approximate size (always above) buffer.resize(size); bufCount = 0; pos = 0; destPtr = buffer.data(); while (pos < ePtr->body.length()) { diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp index a111241..f945a0f 100644 --- a/noncore/net/mailit/mailitwindow.cpp +++ b/noncore/net/mailit/mailitwindow.cpp @@ -101,67 +101,67 @@ void MailItWindow::composeForward(Email &mail) { compose(); writeMail->forward(mail) ; } void MailItWindow::showEmailClient() { viewingMail = FALSE; writeMail->hide(); readMail->hide(); views->raiseWidget(emailClient); setCaption( tr(currentCaption) ); } void MailItWindow::viewMail(QListView *view, Email *mail) { viewingMail = TRUE; emailClient->hide(); int result=0; if ((mail->received)&&(!mail->downloaded)) { - QMessageBox mb( tr("Mail not downloaded"), + QMessageBox mb( tr("Mail not downloaded"), tr("The mail you have clicked \n" - "has not been downloaded yet.\n " - "Would you like to do it now ?"), + "has not been downloaded yet.\n " + "Would you like to do it now ?"), QMessageBox::Information, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape,0 ); - - result=mb.exec(); - - if (result==QMessageBox::Yes) - { - emailClient->download(mail); - } + + result=mb.exec(); + + if (result==QMessageBox::Yes) + { + emailClient->download(mail); + } } readMail->update(view, mail); views->raiseWidget(readMail); - setCaption( tr( "Examine mail" ) ); + setCaption( tr( "Read Mail" ) ); } void MailItWindow::updateMailView(Email *mail) { if (viewingMail) { readMail->mailUpdated(mail); } } void MailItWindow::updateCaption(const QString &newCaption) { currentCaption = newCaption; setCaption(tr(currentCaption)); } void MailItWindow::setDocument(const QString &_address) { // strip leading 'mailto:' QString address = _address; if (address.startsWith("mailto:")) address = address.mid(6); compose(); writeMail->setRecipient(address); diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 2102ba7..da1226c 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp @@ -448,52 +448,52 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) } } bool found=false; if (!fromDisk) { Email *mailPtr; item = (EmailListItem *) inboxView->firstChild(); while ((item != NULL)&&(!found)) { mailPtr = item->getMail(); if (mailPtr->id == newMail.id) { item->setMail(newMail); emit mailUpdated(item->getMail()); found = true; } item = (EmailListItem *) item->nextSibling(); } } if ((!found)||(fromDisk)) { item = new EmailListItem(inboxView, newMail, TRUE); } - if (item->getMail()->files.count()>0) - { - item->setPixmap(0, Resource::loadPixmap("mailit/attach")); - } +// if (item->getMail()->files.count()>0) +// { +// item->setPixmap(0, Resource::loadPixmap("mailit/attach")); +// } /*if (!newMail.downloaded) mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ mailboxView->setCurrentTab(0); } void EmailClient::allMailArrived(int count) { // not previewing means all mailtransfer has been done /*if (!previewingMail) {*/ if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { emit newCaption("Mailit - " + currentAccount->accountName); getNewMail(); return; } else { allAccounts = FALSE; receiving = FALSE; getMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); selectAccountMenu->setEnabled(TRUE); status1Label->setText("Idle"); progressBar->reset(); diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index 59ccd90..39f693d 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp @@ -154,50 +154,52 @@ bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mai int pos; QString delimiter, header, body, mimeHeader, mimeBody; QString content, contentType, contentAttribute, id, encoding; QString fileName, storedName; int enclosureId = 0; mail->rawMail = in; mail->received = TRUE; mail->files.setAutoDelete(TRUE); temp = lineShift + "." + lineShift; if (in.right(temp.length()) != temp) { mail->rawMail += temp; } delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" pos = in.find(delimiter, 0, FALSE); header = in.left(pos); body = in.right(in.length() - pos - delimiter.length()); if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) body.truncate(body.length()-2); - TextParser p(header, lineShift); - + // TextParser p(header, lineShift); + TextParser * lp = new TextParser(header, lineShift); +#define p (*lp) + if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { pos++; if (p.separatorAt(pos) == ' ') { mail->from = p.getString(&pos, '<', false); mail->from = mail->from.stripWhiteSpace(); if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { mail->from = mail->from.left(mail->from.length() - 1); mail->from = mail->from.right(mail->from.length() - 1); } pos++; mail->fromMail = p.getString(&pos, '>', false); } else { if (p.separatorAt(pos) == '<') //No name.. nasty pos++; //pos++; mail->fromMail = p.getString(&pos, 'z', TRUE); if (mail->fromMail.at(mail->fromMail.length()-1) == '>') mail->fromMail.truncate(mail->fromMail.length() - 1); mail->from=mail->fromMail; } } pos=0; @@ -249,48 +251,49 @@ bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mai if ( (p.wordAt(pos).upper() == "VERSION") && (p.separatorAt(pos) == ':') ) { pos++; if (p.getString(&pos, 'z', true) == "1.0") { mail->mimeType = 1; } } } if (mail->mimeType == 1) { boundary = ""; if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { pos++; boundary = p.getString(&pos, 'z', true); if (boundary[0] == '"') { boundary = boundary.left(boundary.length() - 1); //strip " boundary = boundary.right(boundary.length() - 1); //strip " } boundary = "--" + boundary; //create boundary field } if (boundary == "") { //fooled by Mime-Version mail->body = body; mail->bodyPlain = body; + delete lp; return mail; } while (body.length() > 0) { pos = body.find(boundary, 0, FALSE); pos = body.find(delimiter, pos, FALSE); mimeHeader = body.left(pos); mimeBody = body.right(body.length() - pos - delimiter.length()); TextParser bp(mimeHeader, lineShift); contentType = ""; contentAttribute = ""; fileName = ""; if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { pos++; if ( (bp.wordAt(pos).upper() == "TYPE") && (bp.separatorAt(pos) == ':') ) { contentType = bp.nextWord().upper(); if (bp.nextSeparator() == '/') contentAttribute = bp.nextWord().upper(); content = contentType + "/" + contentAttribute; } if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { pos++; @@ -317,48 +320,49 @@ bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mai e.id = enclosureId; e.originalName = fileName; e.contentType = contentType; e.contentAttribute = contentAttribute; e.encoding = encoding; e.body = mimeBody; e.saved = FALSE; mail->addEnclosure(&e); enclosureId++; } else if (contentType == "TEXT") { if (contentAttribute == "PLAIN") { mail->body = mimeBody; mail->bodyPlain = mimeBody; } if (contentAttribute == "HTML") { mail->body = mimeBody; } } } } else { mail->bodyPlain = body; mail->body = body; } + delete lp; return TRUE; } bool EmailHandler::getEnclosure(Enclosure *ePtr) { QFile f(ePtr->path + ePtr->name); char src[4]; char *destPtr; QByteArray buffer; uint bufCount, pos, decodedCount, size, x; if (! f.open(IO_WriteOnly) ) { qWarning("could not save: " + ePtr->path + ePtr->name); return FALSE; } if (ePtr->encoding.upper() == "BASE64") { size = (ePtr->body.length() * 3 / 4); //approximate size (always above) buffer.resize(size); bufCount = 0; pos = 0; destPtr = buffer.data(); while (pos < ePtr->body.length()) { diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp index a111241..f945a0f 100644 --- a/noncore/unsupported/mailit/mailitwindow.cpp +++ b/noncore/unsupported/mailit/mailitwindow.cpp @@ -101,67 +101,67 @@ void MailItWindow::composeForward(Email &mail) { compose(); writeMail->forward(mail) ; } void MailItWindow::showEmailClient() { viewingMail = FALSE; writeMail->hide(); readMail->hide(); views->raiseWidget(emailClient); setCaption( tr(currentCaption) ); } void MailItWindow::viewMail(QListView *view, Email *mail) { viewingMail = TRUE; emailClient->hide(); int result=0; if ((mail->received)&&(!mail->downloaded)) { - QMessageBox mb( tr("Mail not downloaded"), + QMessageBox mb( tr("Mail not downloaded"), tr("The mail you have clicked \n" - "has not been downloaded yet.\n " - "Would you like to do it now ?"), + "has not been downloaded yet.\n " + "Would you like to do it now ?"), QMessageBox::Information, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape,0 ); - - result=mb.exec(); - - if (result==QMessageBox::Yes) - { - emailClient->download(mail); - } + + result=mb.exec(); + + if (result==QMessageBox::Yes) + { + emailClient->download(mail); + } } readMail->update(view, mail); views->raiseWidget(readMail); - setCaption( tr( "Examine mail" ) ); + setCaption( tr( "Read Mail" ) ); } void MailItWindow::updateMailView(Email *mail) { if (viewingMail) { readMail->mailUpdated(mail); } } void MailItWindow::updateCaption(const QString &newCaption) { currentCaption = newCaption; setCaption(tr(currentCaption)); } void MailItWindow::setDocument(const QString &_address) { // strip leading 'mailto:' QString address = _address; if (address.startsWith("mailto:")) address = address.mid(6); compose(); writeMail->setRecipient(address); |