From 3b37149813d940535b12ba3b1edd938c41804a1b Mon Sep 17 00:00:00 2001 From: harlekin Date: Mon, 08 Dec 2003 13:37:32 +0000 Subject: beginning of the new mailer --- (limited to 'noncore/net/mail') diff --git a/noncore/net/mail/TODO b/noncore/net/mail/TODO new file mode 100644 index 0000000..044dbb1 --- a/dev/null +++ b/noncore/net/mail/TODO @@ -0,0 +1,11 @@ +- crosscompile libEtPan! +- do at least some error checking and report them to the user +- thread the whole send/recieve thing +- add mail recieve support +- queue mails for sending +- check source for memory leaks (there is a whole bunch out there) +- make bigger (64x64) desktop icon +- rename app to "mail" +- opie taskbar plugin +- integrate in opie pim +- get some sleep diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp new file mode 100644 index 0000000..c6a44ab --- a/dev/null +++ b/noncore/net/mail/accountview.cpp @@ -0,0 +1,110 @@ +#include "accountview.h" +#include "defines.h" + +IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) + : AccountViewItem( parent ) +{ + account = a; + wrapper = new IMAPwrapper( account ); + setPixmap( 0, PIXMAP_IMAPFOLDER ); + setText( 0, account->getAccountName() ); + setOpen( true ); +} + +IMAPviewItem::~IMAPviewItem() +{ + delete wrapper; +} + +IMAPwrapper *IMAPviewItem::getWrapper() +{ + return wrapper; +} + +void IMAPviewItem::refresh(Maillist&) +{ + QList *folders = wrapper->listFolders(); + + QListViewItem *child = firstChild(); + while ( child ) { + QListViewItem *tmp = child; + child = child->nextSibling(); + delete tmp; + } + + IMAPFolder *it; + for ( it = folders->first(); it; it = folders->next() ) { + (void) new IMAPfolderItem( it, this ); + } +} + + +IMAPfolderItem::~IMAPfolderItem() +{ + delete folder; +} + +IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent ) + : AccountViewItem( parent ) +{ + folder = folderInit; + imap = parent; + setPixmap( 0, PIXMAP_IMAPFOLDER ); + setText( 0, folder->getDisplayName() ); +} + +void IMAPfolderItem::refresh(Maillist&target) +{ + imap->getWrapper()->listMessages( folder->getName(),target ); +} + +QString IMAPfolderItem::fetchBody(const RecMail&aMail) +{ + return imap->getWrapper()->fetchBody(folder->getName(),aMail); +} + +AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) + : QListView( parent, name, flags ) +{ + connect( this, SIGNAL( clicked( QListViewItem * ) ), + SLOT( refresh( QListViewItem * ) ) ); +} + +void AccountView::populate( QList list ) +{ + clear(); + + Account *it; + for ( it = list.first(); it; it = list.next() ) { + if ( it->getType().compare( "IMAP" ) == 0 ) { + IMAPaccount *imap = static_cast(it); + qDebug( "added IMAP " + imap->getAccountName() ); + (void) new IMAPviewItem( imap, this ); + } + } +} + +void AccountView::refresh(QListViewItem *item) { + qDebug("AccountView refresh..."); + if ( item ) { + Maillist headerlist; + headerlist.setAutoDelete(true); + AccountViewItem *view = static_cast(item); + view->refresh(headerlist); + emit refreshMailview(&headerlist); + } +} + +void AccountView::refreshAll() +{ + +} + +QString AccountView::fetchBody(const RecMail&aMail) +{ + QString Body; + QListViewItem*item = selectedItem (); + if (!item) return Body; + AccountViewItem *view = static_cast(item); + return view->fetchBody(aMail); +} diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h new file mode 100644 index 0000000..14d8efa --- a/dev/null +++ b/noncore/net/mail/accountview.h @@ -0,0 +1,67 @@ +#ifndef ACCOUNTVIEW_H +#define ACCOUNTVIEW_H + +#include + +#include "settings.h" +#include "mailwrapper.h" + +class AccountViewItem : public QListViewItem +{ + +public: + AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} + AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} + virtual void refresh(Maillist&)=0; + virtual QString fetchBody(const RecMail&)=0; +}; + +class IMAPviewItem : public AccountViewItem +{ + +public: + IMAPviewItem( IMAPaccount *a, QListView *parent ); + ~IMAPviewItem(); + virtual void refresh(Maillist&); + virtual QString fetchBody(const RecMail&){return "";} + IMAPwrapper *getWrapper(); + +private: + IMAPaccount *account; + IMAPwrapper *wrapper; + +}; + +class IMAPfolderItem : public AccountViewItem +{ + +public: + IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent ); + ~IMAPfolderItem(); + virtual void refresh(Maillist&); + virtual QString fetchBody(const RecMail&); + +private: + IMAPFolder *folder; + IMAPviewItem *imap; + +}; + +class AccountView : public QListView +{ + Q_OBJECT + +public: + AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); + void populate( QList list ); + QString fetchBody(const RecMail&aMail); + +public slots: + void refreshAll(); + void refresh(QListViewItem *item); + +signals: + void refreshMailview(Maillist*); +}; + +#endif diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp new file mode 100644 index 0000000..2c15bb4 --- a/dev/null +++ b/noncore/net/mail/addresspicker.cpp @@ -0,0 +1,130 @@ +#include +#include +#include +#include +#include + +#include + +#include + +#include "composemail.h" + +AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) + : AddressPickerUI( parent, name, modal, flags ) +{ + okButton->setIconSet( Resource::loadPixmap( "enter" ) ); + cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); + + connect(okButton, SIGNAL(clicked()), SLOT(accept())); + connect(cancelButton, SIGNAL(clicked()), SLOT(close())); + + QFile f((QString) getenv("HOME") + "/Applications/" + + "addressbook/addressbook.xml"); + + if ( f.open( IO_ReadOnly ) ) { + QTextStream stream( &f ); + stream.setEncoding( QTextStream::UnicodeUTF8 ); + QString content; + while ( !f.atEnd() ) { + content += stream.readLine() + "\n"; + } + QStringList lines = QStringList::split( QRegExp( "\\n" ), content ); + QStringList::Iterator it; + for ( it = lines.begin(); it != lines.end(); it++ ) { + if ( (*it).find( QRegExp( "^"); + } + if ( !email.isEmpty() ) { + addressList->insertItem( tname + temail ); + } + } + } + } + if ( addressList->count() <= 0 ) { + addressList->insertItem( + tr( "There are no entries in the addressbook." ) ); + addressList->setEnabled( false ); + okButton->setEnabled( false ); + } +} + +void AddressPicker::accept() +{ + QListBoxItem *item = addressList->firstItem(); + QString names; + + while ( item ) { + if ( item->selected() ) + names += item->text() + ", "; + item = item->next(); + } + names.replace( names.length() - 2, 2, "" ); + + if ( names.isEmpty() ) { + QMessageBox::information(this, tr("Error"), tr("

You have to select" + " at least one address entry.

"), tr("Ok")); + return; + } + + selectedNames = names; + QDialog::accept(); +} + +QString AddressPicker::getNames() +{ + QString names = 0; + + AddressPicker picker(0, 0, true); + picker.showMaximized(); + picker.show(); + + int ret = picker.exec(); + if ( QDialog::Accepted == ret ) { + return picker.selectedNames; + } + + return 0; +} + diff --git a/noncore/net/mail/addresspickerui.ui b/noncore/net/mail/addresspickerui.ui new file mode 100644 index 0000000..2e37eac --- a/dev/null +++ b/noncore/net/mail/addresspickerui.ui @@ -0,0 +1,86 @@ + +AddressPickerUI + + QDialog + + name + AddressPickerUI + + + geometry + + 0 + 0 + 282 + 320 + + + + caption + Address Picker + + + layoutMargin + + + layoutSpacing + + + + margin + 4 + + + spacing + 3 + + + QListBox + + name + addressList + + + selectionMode + Multi + + + + QPushButton + + name + okButton + + + minimumSize + + 10 + 0 + + + + text + Ok + + + + QPushButton + + name + cancelButton + + + minimumSize + + 10 + 0 + + + + text + Cancel + + + + + diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp new file mode 100644 index 0000000..a17ccb3 --- a/dev/null +++ b/noncore/net/mail/composemail.cpp @@ -0,0 +1,180 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "composemail.h" +#include "mailwrapper.h" + +ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) + : ComposeMailUI( parent, name, modal, flags ) +{ + settings = s; + + attList->addColumn( tr( "Name" ) ); + attList->addColumn( tr( "Size" ) ); + + QList accounts = settings->getAccounts(); + Account *it; + for ( it = accounts.first(); it; it = accounts.next() ) { + if ( it->getType().compare( "SMTP" ) == 0 ) { + SMTPaccount *smtp = static_cast(it); + fromBox->insertItem( smtp->getMail() ); + smtpAccounts.append( smtp ); + } + } + + if ( smtpAccounts.count() > 0 ) { + fillValues( fromBox->currentItem() ); + } else { + QMessageBox::information( this, tr( "Problem" ), + tr( "

Please create an SMTP account first.

" ), + tr( "Ok" ) ); + } + + connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); + connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); + connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); + connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); + connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); + connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); + connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); +} + +void ComposeMail::pickAddress( QLineEdit *line ) +{ + QString names = AddressPicker::getNames(); + if ( line->text().isEmpty() ) { + line->setText( names ); + } else if ( !names.isEmpty() ) { + line->setText( line->text() + ", " + names ); + } +} + +void ComposeMail::pickAddressTo() +{ + pickAddress( toLine ); +} + +void ComposeMail::pickAddressCC() +{ + pickAddress( ccLine ); +} + +void ComposeMail::pickAddressBCC() +{ + pickAddress( bccLine ); +} + +void ComposeMail::pickAddressReply() +{ + pickAddress( replyLine ); +} + +void ComposeMail::fillValues( int current ) +{ + SMTPaccount *smtp = smtpAccounts.at( current ); + + ccLine->clear(); + if ( smtp->getUseCC() ) { + ccLine->setText( smtp->getCC() ); + } + bccLine->clear(); + if ( smtp->getUseBCC() ) { + bccLine->setText( smtp->getBCC() ); + } + replyLine->clear(); + if ( smtp->getUseReply() ) { + replyLine->setText( smtp->getReply() ); + } + + sigMultiLine->setText( smtp->getSignature() ); +} + +void ComposeMail::slotAdjustColumns() +{ + int currPage = tabWidget->currentPageIndex(); + + tabWidget->showPage( attachTab ); + attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); + attList->setColumnWidth( 1, 80 ); + + tabWidget->setCurrentPage( currPage ); +} + +void ComposeMail::addAttachment() +{ + DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); + if ( !lnk.name().isEmpty() ) { + Attachment *att = new Attachment( lnk ); + (void) new AttachViewItem( attList, att ); + } +} + +void ComposeMail::removeAttachment() +{ + if ( !attList->currentItem() ) { + QMessageBox::information( this, tr( "Error" ), + tr( "

Please select a File.

" ), + tr( "Ok" ) ); + } else { + attList->takeItem( attList->currentItem() ); + } +} + +void ComposeMail::accept() +{ + qDebug( "Sending Mail with " + + smtpAccounts.at( fromBox->currentItem() )->getAccountName() ); + Mail *mail = new Mail(); + SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); + mail->setMail( smtp->getMail() ); + mail->setName( smtp->getName() ); + + if ( !toLine->text().isEmpty() ) { + mail->setTo( toLine->text() ); + } else { + qDebug( "No Reciever spezified -> returning" ); + return; + } + + mail->setCC( ccLine->text() ); + mail->setBCC( bccLine->text() ); + mail->setReply( replyLine->text() ); + mail->setSubject( subjectLine->text() ); + QString txt = message->text(); + if ( !sigMultiLine->text().isEmpty() ) { + txt.append( "\n--\n" ); + txt.append( sigMultiLine->text() ); + } + mail->setMessage( txt ); + AttachViewItem *it = (AttachViewItem *) attList->firstChild(); + while ( it != NULL ) { + mail->addAttachment( it->getAttachment() ); + it = (AttachViewItem *) it->itemBelow(); + } + + MailWrapper wrapper( settings ); + wrapper.sendMail( *mail ); + + QDialog::accept(); +} + +AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) + : QListViewItem( parent ) +{ + attachment = att; + qDebug( att->getMimeType() ); + setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? + Resource::loadPixmap( "UnknownDocument-14" ) : + attachment->getDocLnk().pixmap() ); + setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); + setText( 1, QString::number( att->getSize() ) ); +} + diff --git a/noncore/net/mail/composemail.h b/noncore/net/mail/composemail.h new file mode 100644 index 0000000..c7ae22a --- a/dev/null +++ b/noncore/net/mail/composemail.h @@ -0,0 +1,68 @@ +#ifndef COMPOSEMAIL_H +#define COMPOSEMAIL_H + +#include +#include + +#include "composemailui.h" +#include "addresspickerui.h" +#include "settings.h" +#include "mailwrapper.h" + + +class AddressPicker : public AddressPickerUI +{ + Q_OBJECT + +public: + AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); + static QString getNames(); + +protected: + QString selectedNames; + void accept(); + +}; + + +class ComposeMail : public ComposeMailUI +{ + Q_OBJECT + +public: + ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); + +public slots: + void slotAdjustColumns(); + +protected slots: + void accept(); + +private slots: + void fillValues( int current ); + void pickAddress( QLineEdit *line ); + void pickAddressTo(); + void pickAddressCC(); + void pickAddressBCC(); + void pickAddressReply(); + void addAttachment(); + void removeAttachment(); + +private: + Settings *settings; + QList smtpAccounts; + +}; + +class AttachViewItem : public QListViewItem +{ +public: + AttachViewItem( QListView *parent, Attachment *att ); + Attachment *getAttachment() { return attachment; } + +private: + Attachment *attachment; + +}; + +#endif diff --git a/noncore/net/mail/composemailui.ui b/noncore/net/mail/composemailui.ui new file mode 100644 index 0000000..9f5feb9 --- a/dev/null +++ b/noncore/net/mail/composemailui.ui @@ -0,0 +1,328 @@ + +ComposeMailUI + + QDialog + + name + ComposeMailUI + + + geometry + + 0 + 0 + 264 + 360 + + + + caption + Compose Message + + + layoutMargin + + + layoutSpacing + + + + margin + 0 + + + spacing + 0 + + + QTabWidget + + name + tabWidget + + + layoutMargin + + + layoutSpacing + + + QWidget + + name + mailTab + + + title + Mail + + + + margin + 4 + + + spacing + 3 + + + QLineEdit + + name + subjectLine + + + + QMultiLineEdit + + name + message + + + + QLabel + + name + subjectLabel + + + text + Subject + + + + QLabel + + name + fromLabel + + + text + From + + + + QLineEdit + + name + toLine + + + + QComboBox + + name + fromBox + + + + QPushButton + + name + toButton + + + text + To + + + + + + QWidget + + name + optionsTab + + + title + Options + + + + margin + 4 + + + spacing + 3 + + + QPushButton + + name + replyButton + + + text + Reply-To + + + + QPushButton + + name + bccButton + + + text + BCC + + + + QLineEdit + + name + ccLine + + + + QLineEdit + + name + bccLine + + + + QLineEdit + + name + replyLine + + + + QMultiLineEdit + + name + sigMultiLine + + + + QLabel + + name + sigLabel + + + text + Signature + + + + + name + Spacer3 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + ccButton + + + text + CC + + + + + + QWidget + + name + attachTab + + + title + Attachment + + + + margin + 4 + + + spacing + 3 + + + QListView + + name + attList + + + selectionMode + Single + + + allColumnsShowFocus + true + + + showSortIndicator + true + + + + QPushButton + + name + deleteButton + + + text + Delete File + + + + QPushButton + + name + addButton + + + text + Add File + + + + + + + + + fromBox + toButton + toLine + subjectLine + message + tabWidget + ccButton + ccLine + bccButton + bccLine + replyButton + replyLine + sigMultiLine + attList + addButton + deleteButton + + diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h new file mode 100644 index 0000000..853454d --- a/dev/null +++ b/noncore/net/mail/defines.h @@ -0,0 +1,36 @@ +#ifndef DEFINE_CONSTANTS_H +#define DEFINE_CONSTANTS_H + +#include + +#define USER_AGENT "OpieMail v0.0.1-alpha" + +#define PIC_COMPOSEMAIL "opiemail/composemail" +#define PIC_SENDQUEUED "opiemail/sendqueued" +#define PIC_SHOWFOLDERS "opiemail/showfolders" +#define PIC_SEARCHMAILS "opiemail/searchmails" +#define PIC_EDITSETTINGS "opiemail/editsettings" +#define PIC_EDITACCOUNTS "opiemail/editaccounts" +#define PIC_SYNC "opiemail/sync" +#define PIC_IMAPFOLDER "opiemail/imapfolder" + +#define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) +#define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) +#define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) +#define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) +#define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) +#define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) +#define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) + +#define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) + +#define IMAP_PORT "143" +#define IMAP_SSL_PORT "993" +#define SMTP_PORT "25" +#define SMTP_SSL_PORT "465" +#define POP3_PORT "110" +#define POP3_SSL_PORT "995" +#define NNTP_PORT "119" +#define NNTP_SSL_PORT "563" + +#endif diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp new file mode 100644 index 0000000..7e2dd24 --- a/dev/null +++ b/noncore/net/mail/editaccounts.cpp @@ -0,0 +1,471 @@ +#include +#include + +#include "defines.h" +#include "editaccounts.h" + +AccountListItem::AccountListItem( QListView *parent, Account *a) + : QListViewItem( parent ) +{ + account = a; + setText( 0, account->getAccountName() ); + setText( 1, account->getType() ); +} + +EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) + : EditAccountsUI( parent, name, modal, flags ) +{ + qDebug( "New Account Configuration Widget" ); + settings = s; + + mailList->addColumn( tr( "Account" ) ); + mailList->addColumn( tr( "Type" ) ); + + newsList->addColumn( tr( "Account" ) ); + + connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); + connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); + connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); + connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); + connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); + connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); + + slotFillLists(); +} + +void EditAccounts::slotFillLists() +{ + mailList->clear(); + newsList->clear(); + + QList accounts = settings->getAccounts(); + Account *it; + for ( it = accounts.first(); it; it = accounts.next() ) { + if ( it->getType().compare( "NNTP" ) == 0 ) { + (void) new AccountListItem( newsList, it ); + } else { + (void) new AccountListItem( mailList, it ); + } + } +} + +void EditAccounts::slotNewMail() +{ + qDebug( "New Mail Account" ); + QString *selection = new QString(); + SelectMailType selType( selection, this, 0, true ); + selType.show(); + if ( QDialog::Accepted == selType.exec() ) { + slotNewAccount( *selection ); + } +} + +void EditAccounts::slotNewAccount( const QString &type ) +{ + if ( type.compare( "IMAP" ) == 0 ) { + qDebug( "-> config IMAP" ); + IMAPaccount *account = new IMAPaccount(); + IMAPconfig imap( account, this, 0, true ); + imap.showMaximized(); + if ( QDialog::Accepted == imap.exec() ) { + settings->addAccount( account ); + account->save(); + slotFillLists(); + } else { + account->remove(); + } + } else if ( type.compare( "POP3" ) == 0 ) { + qDebug( "-> config POP3" ); + POP3account *account = new POP3account(); + POP3config pop3( account, this, 0, true ); + pop3.showMaximized(); + if ( QDialog::Accepted == pop3.exec() ) { + settings->addAccount( account ); + account->save(); + slotFillLists(); + } else { + account->remove(); + } + } else if ( type.compare( "SMTP" ) == 0 ) { + qDebug( "-> config SMTP" ); + SMTPaccount *account = new SMTPaccount(); + SMTPconfig smtp( account, this, 0, true ); + smtp.showMaximized(); + if ( QDialog::Accepted == smtp.exec() ) { + settings->addAccount( account ); + account->save(); + slotFillLists(); + } else { + account->remove(); + } + } else if ( type.compare( "NNTP" ) == 0 ) { + qDebug( "-> config NNTP" ); + NNTPaccount *account = new NNTPaccount(); + NNTPconfig nntp( account, this, 0, true ); + nntp.showMaximized(); + if ( QDialog::Accepted == nntp.exec() ) { + settings->addAccount( account ); + account->save(); + slotFillLists(); + } else { + account->remove(); + } + } +} + +void EditAccounts::slotEditAccount( Account *account ) +{ + if ( account->getType().compare( "IMAP" ) == 0 ) { + IMAPaccount *imapAcc = static_cast(account); + IMAPconfig imap( imapAcc, this, 0, true ); + imap.showMaximized(); + if ( QDialog::Accepted == imap.exec() ) { + slotFillLists(); + } + } else if ( account->getType().compare( "POP3" ) == 0 ) { + POP3account *pop3Acc = static_cast(account); + POP3config pop3( pop3Acc, this, 0, true ); + pop3.showMaximized(); + if ( QDialog::Accepted == pop3.exec() ) { + slotFillLists(); + } + } else if ( account->getType().compare( "SMTP" ) == 0 ) { + SMTPaccount *smtpAcc = static_cast(account); + SMTPconfig smtp( smtpAcc, this, 0, true ); + smtp.showMaximized(); + if ( QDialog::Accepted == smtp.exec() ) { + slotFillLists(); + } + } else if ( account->getType().compare( "NNTP" ) == 0 ) { + NNTPaccount *nntpAcc = static_cast(account); + NNTPconfig nntp( nntpAcc, this, 0, true ); + nntp.showMaximized(); + if ( QDialog::Accepted == nntp.exec() ) { + slotFillLists(); + } + } +} + +void EditAccounts::slotDeleteAccount( Account *account ) +{ + if ( QMessageBox::information( this, tr( "Question" ), + tr( "

Do you really want to delete the selected Account?

" ), + tr( "Yes" ), tr( "No" ) ) == 0 ) { + settings->delAccount( account ); + slotFillLists(); + } +} + +void EditAccounts::slotEditMail() +{ + qDebug( "Edit Mail Account" ); + if ( !mailList->currentItem() ) { + QMessageBox::information( this, tr( "Error" ), + tr( "

Please select an account.

" ), + tr( "Ok" ) ); + return; + } + + Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); + slotEditAccount( a ); +} + +void EditAccounts::slotDeleteMail() +{ + if ( !mailList->currentItem() ) { + QMessageBox::information( this, tr( "Error" ), + tr( "

Please select an account.

" ), + tr( "Ok" ) ); + return; + } + + Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); + slotDeleteAccount( a ); +} + +void EditAccounts::slotNewNews() +{ + qDebug( "New News Account" ); + slotNewAccount( "NNTP" ); +} + +void EditAccounts::slotEditNews() +{ + qDebug( "Edit News Account" ); + if ( !newsList->currentItem() ) { + QMessageBox::information( this, tr( "Error" ), + tr( "

Please select an account.

" ), + tr( "Ok" ) ); + return; + } + + Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); + slotEditAccount( a ); +} + +void EditAccounts::slotDeleteNews() +{ + qDebug( "Delete News Account" ); + if ( !newsList->currentItem() ) { + QMessageBox::information( this, tr( "Error" ), + tr( "

Please select an account.

" ), + tr( "Ok" ) ); + return; + } + + Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); + slotDeleteAccount( a ); +} + +void EditAccounts::slotAdjustColumns() +{ + int currPage = configTab->currentPageIndex(); + + configTab->showPage( mailTab ); + mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); + mailList->setColumnWidth( 1, 50 ); + + configTab->showPage( newsTab ); + newsList->setColumnWidth( 0, newsList->visibleWidth() ); + + configTab->setCurrentPage( currPage ); +} + +void EditAccounts::accept() +{ + settings->saveAccounts(); + + QDialog::accept(); +} + +/** + * SelectMailType + */ + +SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) + : SelectMailTypeUI( parent, name, modal, flags ) +{ + selected = selection; + selected->replace( 0, selected->length(), typeBox->currentText() ); + connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) ); +} + +void SelectMailType::slotSelection( const QString &sel ) +{ + selected->replace( 0, selected->length(), sel ); +} + +/** + * IMAPconfig + */ + +IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) + : IMAPconfigUI( parent, name, modal, flags ) +{ + data = account; + + fillValues(); + + connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); +} + +void IMAPconfig::slotSSL( bool enabled ) +{ + if ( enabled ) { + portLine->setText( IMAP_SSL_PORT ); + } else { + portLine->setText( IMAP_PORT ); + } +} + +void IMAPconfig::fillValues() +{ + accountLine->setText( data->getAccountName() ); + serverLine->setText( data->getServer() ); + portLine->setText( data->getPort() ); + sslBox->setChecked( data->getSSL() ); + userLine->setText( data->getUser() ); + passLine->setText( data->getPassword() ); + prefixLine->setText(data->getPrefix()); +} + +void IMAPconfig::accept() +{ + data->setAccountName( accountLine->text() ); + data->setServer( serverLine->text() ); + data->setPort( portLine->text() ); + data->setSSL( sslBox->isChecked() ); + data->setUser( userLine->text() ); + data->setPassword( passLine->text() ); + data->setPrefix(prefixLine->text()); + + QDialog::accept(); +} + +/** + * POP3config + */ + +POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) + : POP3configUI( parent, name, modal, flags ) +{ + data = account; + fillValues(); + + connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); +} + +void POP3config::slotSSL( bool enabled ) +{ + if ( enabled ) { + portLine->setText( POP3_SSL_PORT ); + } else { + portLine->setText( POP3_PORT ); + } +} + +void POP3config::fillValues() +{ + accountLine->setText( data->getAccountName() ); + serverLine->setText( data->getServer() ); + portLine->setText( data->getPort() ); + sslBox->setChecked( data->getSSL() ); + userLine->setText( data->getUser() ); + passLine->setText( data->getPassword() ); +} + +void POP3config::accept() +{ + data->setAccountName( accountLine->text() ); + data->setServer( serverLine->text() ); + data->setPort( portLine->text() ); + data->setSSL( sslBox->isChecked() ); + data->setUser( userLine->text() ); + data->setPassword( passLine->text() ); + + QDialog::accept(); +} + +/** + * SMTPconfig + */ + +SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) + : SMTPconfigUI( parent, name, modal, flags ) +{ + data = account; + + connect( ccBox, SIGNAL( toggled( bool ) ), ccLine, SLOT( setEnabled( bool ) ) ); + connect( bccBox, SIGNAL( toggled( bool ) ), bccLine, SLOT( setEnabled( bool ) ) ); + connect( replyBox, SIGNAL( toggled( bool ) ), replyLine, SLOT( setEnabled( bool ) ) ); + connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); + connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); + + fillValues(); + + connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); +} + +void SMTPconfig::slotSSL( bool enabled ) +{ + if ( enabled ) { + portLine->setText( SMTP_SSL_PORT ); + } else { + portLine->setText( SMTP_PORT ); + } +} + +void SMTPconfig::fillValues() +{ + accountLine->setText( data->getAccountName() ); + serverLine->setText( data->getServer() ); + portLine->setText( data->getPort() ); + sslBox->setChecked( data->getSSL() ); + loginBox->setChecked( data->getLogin() ); + userLine->setText( data->getUser() ); + passLine->setText( data->getPassword() ); + nameLine->setText( data->getName() ); + mailLine->setText( data->getMail() ); + orgLine->setText( data->getOrg() ); + ccBox->setChecked( data->getUseCC() ); + ccLine->setText( data->getCC() ); + bccBox->setChecked( data->getUseBCC() ); + bccLine->setText( data->getBCC() ); + replyBox->setChecked( data->getUseReply() ); + replyLine->setText( data->getReply() ); + sigMultiLine->setText( data->getSignature() ); +} + +void SMTPconfig::accept() +{ + data->setAccountName( accountLine->text() ); + data->setServer( serverLine->text() ); + data->setPort( portLine->text() ); + data->setSSL( sslBox->isChecked() ); + data->setLogin( loginBox->isChecked() ); + data->setUser( userLine->text() ); + data->setPassword( passLine->text() ); + data->setName( nameLine->text() ); + data->setMail( mailLine->text() ); + data->setOrg( orgLine->text() ); + data->setCC( ccLine->text() ); + data->setUseCC( ccBox->isChecked() ); + data->setBCC( bccLine->text() ); + data->setUseBCC( bccBox->isChecked() ); + data->setReply( replyLine->text() ); + data->setUseReply( replyBox->isChecked() ); + data->setSignature( sigMultiLine->text() ); + + QDialog::accept(); +} + +/** + * NNTPconfig + */ + +NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) + : NNTPconfigUI( parent, name, modal, flags ) +{ + data = account; + + connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); + connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); + + fillValues(); + + connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); +} + +void NNTPconfig::slotSSL( bool enabled ) +{ + if ( enabled ) { + portLine->setText( NNTP_SSL_PORT ); + } else { + portLine->setText( NNTP_PORT ); + } +} + +void NNTPconfig::fillValues() +{ + accountLine->setText( data->getAccountName() ); + serverLine->setText( data->getServer() ); + portLine->setText( data->getPort() ); + sslBox->setChecked( data->getSSL() ); + loginBox->setChecked( data->getLogin() ); + userLine->setText( data->getUser() ); + passLine->setText( data->getPassword() ); +} + +void NNTPconfig::accept() +{ + data->setAccountName( accountLine->text() ); + data->setServer( serverLine->text() ); + data->setPort( portLine->text() ); + data->setSSL( sslBox->isChecked() ); + data->setLogin( loginBox->isChecked() ); + data->setUser( userLine->text() ); + data->setPassword( passLine->text() ); + + QDialog::accept(); +} + diff --git a/noncore/net/mail/editaccounts.h b/noncore/net/mail/editaccounts.h new file mode 100644 index 0000000..10ed8b8 --- a/dev/null +++ b/noncore/net/mail/editaccounts.h @@ -0,0 +1,146 @@ +#ifndef EDITACCOUNTS_H +#define EDITACCOUNTS_H + +#include +#include + +#include "editaccountsui.h" +#include "selectmailtypeui.h" +#include "imapconfigui.h" +#include "pop3configui.h" +#include "smtpconfigui.h" +#include "nntpconfigui.h" +#include "settings.h" + +class AccountListItem : public QListViewItem +{ + +public: + AccountListItem( QListView *parent, Account *a); + Account *getAccount() { return account; } + +private: + Account *account; + +}; + +class EditAccounts : public EditAccountsUI +{ + Q_OBJECT + +public: + EditAccounts( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); + +public slots: + void slotNewAccount( const QString &type ); + void slotEditAccount( Account *account ); + void slotDeleteAccount( Account * account ); + void slotAdjustColumns(); + +protected slots: + void slotFillLists(); + void slotNewMail(); + void slotEditMail(); + void slotDeleteMail(); + void slotNewNews(); + void slotEditNews(); + void slotDeleteNews(); + void accept(); + +private: + Settings *settings; + +}; + +class SelectMailType : public SelectMailTypeUI +{ + Q_OBJECT + +public: + SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); + +private slots: + void slotSelection( const QString &sel ); + +private: + QString *selected; + +}; + +class IMAPconfig : public IMAPconfigUI +{ + Q_OBJECT + +public: + IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); + +public slots: + void fillValues(); + +protected slots: + void slotSSL( bool enabled ); + void accept(); + +private: + IMAPaccount *data; + +}; + +class POP3config : public POP3configUI +{ + Q_OBJECT + +public: + POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); + +public slots: + void fillValues(); + +protected slots: + void slotSSL( bool enabled ); + void accept(); + +private: + POP3account *data; + +}; + +class SMTPconfig : public SMTPconfigUI +{ + Q_OBJECT + +public: + SMTPconfig( SMTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); + +public slots: + void slotSSL( bool enabled ); + void fillValues(); + +protected slots: + void accept(); + +private: + SMTPaccount *data; + +}; + +class NNTPconfig : public NNTPconfigUI +{ + Q_OBJECT + +public: + NNTPconfig( NNTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); + +public slots: + void fillValues(); + +protected slots: + void slotSSL( bool enabled ); + void accept(); + +private: + NNTPaccount *data; + +}; + +#endif diff --git a/noncore/net/mail/editaccountsui.ui b/noncore/net/mail/editaccountsui.ui new file mode 100644 index 0000000..d86f145 --- a/dev/null +++ b/noncore/net/mail/editaccountsui.ui @@ -0,0 +1,223 @@ + +EditAccountsUI + + QDialog + + name + EditAccountsUI + + + geometry + + 0 + 0 + 260 + 320 + + + + caption + Configure Accounts + + + layoutMargin + + + layoutSpacing + + + + margin + 0 + + + spacing + 0 + + + QTabWidget + + name + configTab + + + layoutMargin + + + layoutSpacing + + + QWidget + + name + mailTab + + + title + Mail + + + + margin + 4 + + + spacing + 3 + + + QPushButton + + name + deleteMail + + + text + Delete + + + + QPushButton + + name + newMail + + + text + New + + + + QListView + + name + mailList + + + sizePolicy + + 7 + 7 + + + + resizePolicy + Manual + + + allColumnsShowFocus + true + + + showSortIndicator + true + + + toolTip + Name of the Account + + + + QPushButton + + name + editMail + + + text + Edit + + + + + + QWidget + + name + newsTab + + + title + News + + + + margin + 4 + + + spacing + 3 + + + QPushButton + + name + deleteNews + + + sizePolicy + + 1 + 0 + + + + text + Delete + + + + QPushButton + + name + editNews + + + text + Edit + + + + QListView + + name + newsList + + + allColumnsShowFocus + true + + + showSortIndicator + true + + + + QPushButton + + name + newNews + + + text + New + + + + + + + + + mailList + newMail + editMail + deleteMail + configTab + newsList + newNews + editNews + deleteNews + + diff --git a/noncore/net/mail/imapconfigui.ui b/noncore/net/mail/imapconfigui.ui new file mode 100644 index 0000000..ac0297f --- a/dev/null +++ b/noncore/net/mail/imapconfigui.ui @@ -0,0 +1,242 @@ + +IMAPconfigUI + + QDialog + + name + IMAPconfigUI + + + geometry + + 0 + 0 + 228 + 320 + + + + caption + Configure IMAP + + + layoutMargin + + + layoutSpacing + + + + margin + 3 + + + spacing + 2 + + + QLabel + + name + userLabel + + + text + User + + + + QCheckBox + + name + sslBox + + + text + Use SSL + + + + QLineEdit + + name + serverLine + + + + QLineEdit + + name + userLine + + + + QLabel + + name + passLabel + + + text + Password + + + + QLabel + + name + portLabel + + + text + Port + + + + QLabel + + name + serverLabel + + + text + Server + + + + QLineEdit + + name + portLine + + + + QLineEdit + + name + passLine + + + echoMode + Password + + + + + name + spacer + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLineEdit + + name + accountLine + + + toolTip + Name of the Account + + + + QLabel + + name + accountLabel + + + text + Account + + + + Line + + name + line1 + + + orientation + Horizontal + + + + QLineEdit + + name + prefixLine + + + + QLabel + + name + prefixLabel + + + text + Prefix + + + + Line + + name + line2 + + + enabled + true + + + caption + + + + orientation + Horizontal + + + layoutMargin + + + layoutSpacing + + + + Line + + name + Line3 + + + orientation + Horizontal + + + + + + accountLine + serverLine + portLine + sslBox + userLine + passLine + + diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp new file mode 100644 index 0000000..16f4565 --- a/dev/null +++ b/noncore/net/mail/imapwrapper.cpp @@ -0,0 +1,411 @@ + +#include + +#include "mailwrapper.h" + + +IMAPwrapper::IMAPwrapper( IMAPaccount *a ) +{ + account = a; +} + +void imap_progress( size_t current, size_t maximum ) +{ + qDebug( "IMAP: %i of %i", current, maximum ); +} + +void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) +{ + const char *server, *user, *pass, *mb; + uint16_t port; + int err = MAILIMAP_NO_ERROR; + clist *result; + clistcell *current; + mailimap_fetch_att *fetchAtt,*fetchAttFlags; + mailimap_fetch_type *fetchType; + mailimap_set *set; + + mb = mailbox.latin1(); + server = account->getServer().latin1(); + port = account->getPort().toUInt(); + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + + mailimap *imap = mailimap_new( 20, &imap_progress ); + if ( imap == NULL ) { + qDebug("IMAP Memory error"); + return; + } + + /* connect */ + err = mailimap_socket_connect( imap, (char*)server, port ); + if ( err != MAILIMAP_NO_ERROR && + err != MAILIMAP_NO_ERROR_AUTHENTICATED && + err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { + qDebug("error connecting server: %s",imap->response); + mailimap_free( imap ); + return; + } + + /* login */ + err = mailimap_login_simple( imap, (char*)user, (char*)pass ); + if ( err != MAILIMAP_NO_ERROR ) { + qDebug("error logging in imap: %s",imap->response); + err = mailimap_close( imap ); + mailimap_free( imap ); + return; + } + + /* select mailbox READONLY for operations */ + err = mailimap_examine( imap, (char*)mb); + if ( err != MAILIMAP_NO_ERROR ) { + qDebug("error selecting mailbox: %s",imap->response); + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + return; + } + + int last = imap->selection_info->exists; + if (last == 0) { + qDebug("mailbox has no mails"); + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + return; + } + + + result = clist_new(); + /* the range has to start at 1!!! not with 0!!!! */ + set = mailimap_set_new_interval( 1, last ); + fetchAtt = mailimap_fetch_att_new_envelope(); + fetchAttFlags = mailimap_fetch_att_new_flags(); + + //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); + fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); + mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt); + mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags); + + err = mailimap_fetch( imap, set, fetchType, &result ); + mailimap_set_free( set ); + mailimap_fetch_type_free( fetchType ); + + QString date,subject,from; + + if ( err == MAILIMAP_NO_ERROR ) { + current = clist_begin(result); + mailimap_msg_att * msg_att; + int i = 0; + while ( current != 0 ) { + ++i; + msg_att = (mailimap_msg_att*)current->data; + RecMail*m = parse_list_result(msg_att); + if (m) { + m->setNumber(i); + target.append(m); + } + current = current->next; + } + } else { + qDebug("Error fetching headers: %s",imap->response); + } + + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + clist_free(result); + mailimap_free( imap ); +} + +QList* IMAPwrapper::listFolders() +{ + const char *server, *user, *pass, *path, *mask; + uint16_t port; + int err = MAILIMAP_NO_ERROR; + clist *result; + clistcell *current; + + QList * folders = new QList(); + folders->setAutoDelete( true ); + + server = account->getServer().latin1(); + port = account->getPort().toUInt(); + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + path = account->getPrefix().latin1(); + + mailimap *imap = mailimap_new( 20, &imap_progress ); + if ( imap == NULL ) { + qDebug("error mailimap_new"); + return folders; + } + + err = mailimap_socket_connect( imap, (char*)server, port ); + if ( err != MAILIMAP_NO_ERROR && + err != MAILIMAP_NO_ERROR_AUTHENTICATED && + err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { + mailimap_free(imap); + qDebug("error imap_socket_connect: %s",imap->response); + return folders; + } + + err = mailimap_login_simple( imap, (char*)user, (char*)pass ); + if ( err != MAILIMAP_NO_ERROR ) { + mailimap_free(imap); + qDebug("error logging in: %s",imap->response); + return folders; + } +/* + * First we have to check for INBOX 'cause it sometimes it's not inside the path. + * We must not forget to filter them out in next loop! + * it seems like ugly code. and yes - it is ugly code. but the best way. + */ + QString temp; + mask = "INBOX" ; + result = clist_new(); + mailimap_mailbox_list *list; + err = mailimap_list( imap, (char*)"", (char*)mask, &result ); + if ( err == MAILIMAP_NO_ERROR ) { + current = result->first; + for ( int i = result->count; i > 0; i-- ) { + list = (mailimap_mailbox_list *) current->data; + // it is better use the deep copy mechanism of qt itself + // instead of using strdup! + temp = list->mb; + folders->append( new IMAPFolder(temp)); + current = current->next; + } + } else { + qDebug("error fetching folders: %s",imap->response); + } + mailimap_list_result_free( result ); + +/* + * second stage - get the other then inbox folders + */ + mask = "*" ; + result = clist_new(); + err = mailimap_list( imap, (char*)path, (char*)mask, &result ); + if ( err == MAILIMAP_NO_ERROR ) { + current = result->first; + for ( int i = result->count; i > 0; i-- ) { + list = (mailimap_mailbox_list *) current->data; + // it is better use the deep copy mechanism of qt itself + // instead of using strdup! + temp = list->mb; + current = current->next; + if (temp.lower()=="inbox") + continue; + folders->append(new IMAPFolder(temp)); + + } + } else { + qDebug("error fetching folders"); + } + mailimap_list_result_free( result ); + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + return folders; +} + +RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) +{ + RecMail * m = 0; + mailimap_msg_att_item *item=0; + bool named_from = false; + QString from,date,subject; + date = from = subject = ""; + clistcell *current,*c,*cf, *current_from = NULL; + mailimap_address * current_address = NULL; + mailimap_msg_att_dynamic*flist; + mailimap_flag_fetch*cflag; + QBitArray mFlags(7); + + if (!m_att) { + return m; + } + +#if 0 + MAILIMAP_FLAG_KEYWORD, /* keyword flag */ + MAILIMAP_FLAG_EXTENSION, /* \extension flag */ +#endif + c = clist_begin(m_att->list); + while ( c ) { + current = c; + c = c->next; + item = (mailimap_msg_att_item*)current->data; + if (item->type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { + flist = (mailimap_msg_att_dynamic*)item->msg_att_dyn; + if (!flist->list) { + continue; + } + cf = flist->list->first; + while (cf) { + cflag = (mailimap_flag_fetch*)cf->data; + if (cflag->type==MAILIMAP_FLAG_FETCH_OTHER && cflag->flag!=0) { + switch (cflag->flag->type) { + case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ + mFlags.setBit(FLAG_ANSWERED); + break; + case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ + mFlags.setBit(FLAG_FLAGGED); + break; + case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ + mFlags.setBit(FLAG_DELETED); + break; + case MAILIMAP_FLAG_SEEN: /* \Seen flag */ + mFlags.setBit(FLAG_SEEN); + break; + case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ + mFlags.setBit(FLAG_DRAFT); + break; + case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ + break; + case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ + break; + default: + break; + } + } else if (cflag->type==MAILIMAP_FLAG_FETCH_RECENT) { + mFlags.setBit(FLAG_RECENT); + } + + cf = cf->next; + } + continue; + } + if ( item->msg_att_static->type == MAILIMAP_MSG_ATT_RFC822_HEADER ) { + qDebug( "header: \n%s", item->msg_att_static->rfc822_header ); + } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_ENVELOPE) { + mailimap_envelope * head = item->msg_att_static->env; + date = head->date; + subject = head->subject; + if (head->from!=NULL) + current_from = head->from->list->first; + while (current_from != NULL) { + from = ""; + named_from = false; + current_address=(mailimap_address*)current_from->data; + current_from = current_from->next; + if (current_address->personal_name){ + from+=QString(current_address->personal_name); + from+=" "; + named_from = true; + } + if (named_from && (current_address->mailbox_name || current_address->host_name)) { + from+="<"; + } + if (current_address->mailbox_name) { + from+=QString(current_address->mailbox_name); + from+="@"; + } + if (current_address->host_name) { + from+=QString(current_address->host_name); + } + if (named_from && (current_address->mailbox_name || current_address->host_name)) { + from+=">"; + } + } + qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s", + from.latin1(), + subject.latin1(),date.latin1()); + m = new RecMail(); + m->setSubject(subject); + m->setFrom(from); + m->setDate(date); + } else { + qDebug("Another type"); + } + } + /* msg is already deleted */ + if (mFlags.testBit(FLAG_DELETED) && m) { + delete m; + m = 0; + } + if (m) { + m->setFlags(mFlags); + } + return m; +} + +QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) +{ + QString body = ""; + const char *server, *user, *pass, *mb; + uint16_t port; + int err = MAILIMAP_NO_ERROR; + clist *result; + clistcell *current; + mailimap_fetch_att *fetchAtt; + mailimap_fetch_type *fetchType; + mailimap_set *set; + + mb = mailbox.latin1(); + server = account->getServer().latin1(); + port = account->getPort().toUInt(); + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + + mailimap *imap = mailimap_new( 20, &imap_progress ); + if ( imap == NULL ) { + qDebug("IMAP Memory error"); + return body; + } + + /* connect */ + err = mailimap_socket_connect( imap, (char*)server, port ); + if ( err != MAILIMAP_NO_ERROR && + err != MAILIMAP_NO_ERROR_AUTHENTICATED && + err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { + qDebug("error connecting server: %s",imap->response); + mailimap_free( imap ); + return body; + } + + /* login */ + err = mailimap_login_simple( imap, (char*)user, (char*)pass ); + if ( err != MAILIMAP_NO_ERROR ) { + qDebug("error logging in imap: %s",imap->response); + err = mailimap_close( imap ); + mailimap_free( imap ); + return body; + } + + /* select mailbox READONLY for operations */ + err = mailimap_examine( imap, (char*)mb); + if ( err != MAILIMAP_NO_ERROR ) { + qDebug("error selecting mailbox: %s",imap->response); + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + return body; + } + result = clist_new(); + /* the range has to start at 1!!! not with 0!!!! */ + set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); + fetchAtt = mailimap_fetch_att_new_rfc822_text(); + fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); + err = mailimap_fetch( imap, set, fetchType, &result ); + mailimap_set_free( set ); + mailimap_fetch_type_free( fetchType ); + + if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { + mailimap_msg_att * msg_att; + msg_att = (mailimap_msg_att*)current->data; + mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; + + if (item->msg_att_static && item->msg_att_static->rfc822_text) { + body = item->msg_att_static->rfc822_text; + } + } else { + qDebug("error fetching text: %s",imap->response); + } + + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + clist_free(result); + + return body; +} diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp new file mode 100644 index 0000000..16f4565 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -0,0 +1,411 @@ + +#include + +#include "mailwrapper.h" + + +IMAPwrapper::IMAPwrapper( IMAPaccount *a ) +{ + account = a; +} + +void imap_progress( size_t current, size_t maximum ) +{ + qDebug( "IMAP: %i of %i", current, maximum ); +} + +void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) +{ + const char *server, *user, *pass, *mb; + uint16_t port; + int err = MAILIMAP_NO_ERROR; + clist *result; + clistcell *current; + mailimap_fetch_att *fetchAtt,*fetchAttFlags; + mailimap_fetch_type *fetchType; + mailimap_set *set; + + mb = mailbox.latin1(); + server = account->getServer().latin1(); + port = account->getPort().toUInt(); + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + + mailimap *imap = mailimap_new( 20, &imap_progress ); + if ( imap == NULL ) { + qDebug("IMAP Memory error"); + return; + } + + /* connect */ + err = mailimap_socket_connect( imap, (char*)server, port ); + if ( err != MAILIMAP_NO_ERROR && + err != MAILIMAP_NO_ERROR_AUTHENTICATED && + err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { + qDebug("error connecting server: %s",imap->response); + mailimap_free( imap ); + return; + } + + /* login */ + err = mailimap_login_simple( imap, (char*)user, (char*)pass ); + if ( err != MAILIMAP_NO_ERROR ) { + qDebug("error logging in imap: %s",imap->response); + err = mailimap_close( imap ); + mailimap_free( imap ); + return; + } + + /* select mailbox READONLY for operations */ + err = mailimap_examine( imap, (char*)mb); + if ( err != MAILIMAP_NO_ERROR ) { + qDebug("error selecting mailbox: %s",imap->response); + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + return; + } + + int last = imap->selection_info->exists; + if (last == 0) { + qDebug("mailbox has no mails"); + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + return; + } + + + result = clist_new(); + /* the range has to start at 1!!! not with 0!!!! */ + set = mailimap_set_new_interval( 1, last ); + fetchAtt = mailimap_fetch_att_new_envelope(); + fetchAttFlags = mailimap_fetch_att_new_flags(); + + //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); + fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); + mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt); + mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags); + + err = mailimap_fetch( imap, set, fetchType, &result ); + mailimap_set_free( set ); + mailimap_fetch_type_free( fetchType ); + + QString date,subject,from; + + if ( err == MAILIMAP_NO_ERROR ) { + current = clist_begin(result); + mailimap_msg_att * msg_att; + int i = 0; + while ( current != 0 ) { + ++i; + msg_att = (mailimap_msg_att*)current->data; + RecMail*m = parse_list_result(msg_att); + if (m) { + m->setNumber(i); + target.append(m); + } + current = current->next; + } + } else { + qDebug("Error fetching headers: %s",imap->response); + } + + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + clist_free(result); + mailimap_free( imap ); +} + +QList* IMAPwrapper::listFolders() +{ + const char *server, *user, *pass, *path, *mask; + uint16_t port; + int err = MAILIMAP_NO_ERROR; + clist *result; + clistcell *current; + + QList * folders = new QList(); + folders->setAutoDelete( true ); + + server = account->getServer().latin1(); + port = account->getPort().toUInt(); + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + path = account->getPrefix().latin1(); + + mailimap *imap = mailimap_new( 20, &imap_progress ); + if ( imap == NULL ) { + qDebug("error mailimap_new"); + return folders; + } + + err = mailimap_socket_connect( imap, (char*)server, port ); + if ( err != MAILIMAP_NO_ERROR && + err != MAILIMAP_NO_ERROR_AUTHENTICATED && + err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { + mailimap_free(imap); + qDebug("error imap_socket_connect: %s",imap->response); + return folders; + } + + err = mailimap_login_simple( imap, (char*)user, (char*)pass ); + if ( err != MAILIMAP_NO_ERROR ) { + mailimap_free(imap); + qDebug("error logging in: %s",imap->response); + return folders; + } +/* + * First we have to check for INBOX 'cause it sometimes it's not inside the path. + * We must not forget to filter them out in next loop! + * it seems like ugly code. and yes - it is ugly code. but the best way. + */ + QString temp; + mask = "INBOX" ; + result = clist_new(); + mailimap_mailbox_list *list; + err = mailimap_list( imap, (char*)"", (char*)mask, &result ); + if ( err == MAILIMAP_NO_ERROR ) { + current = result->first; + for ( int i = result->count; i > 0; i-- ) { + list = (mailimap_mailbox_list *) current->data; + // it is better use the deep copy mechanism of qt itself + // instead of using strdup! + temp = list->mb; + folders->append( new IMAPFolder(temp)); + current = current->next; + } + } else { + qDebug("error fetching folders: %s",imap->response); + } + mailimap_list_result_free( result ); + +/* + * second stage - get the other then inbox folders + */ + mask = "*" ; + result = clist_new(); + err = mailimap_list( imap, (char*)path, (char*)mask, &result ); + if ( err == MAILIMAP_NO_ERROR ) { + current = result->first; + for ( int i = result->count; i > 0; i-- ) { + list = (mailimap_mailbox_list *) current->data; + // it is better use the deep copy mechanism of qt itself + // instead of using strdup! + temp = list->mb; + current = current->next; + if (temp.lower()=="inbox") + continue; + folders->append(new IMAPFolder(temp)); + + } + } else { + qDebug("error fetching folders"); + } + mailimap_list_result_free( result ); + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + return folders; +} + +RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) +{ + RecMail * m = 0; + mailimap_msg_att_item *item=0; + bool named_from = false; + QString from,date,subject; + date = from = subject = ""; + clistcell *current,*c,*cf, *current_from = NULL; + mailimap_address * current_address = NULL; + mailimap_msg_att_dynamic*flist; + mailimap_flag_fetch*cflag; + QBitArray mFlags(7); + + if (!m_att) { + return m; + } + +#if 0 + MAILIMAP_FLAG_KEYWORD, /* keyword flag */ + MAILIMAP_FLAG_EXTENSION, /* \extension flag */ +#endif + c = clist_begin(m_att->list); + while ( c ) { + current = c; + c = c->next; + item = (mailimap_msg_att_item*)current->data; + if (item->type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { + flist = (mailimap_msg_att_dynamic*)item->msg_att_dyn; + if (!flist->list) { + continue; + } + cf = flist->list->first; + while (cf) { + cflag = (mailimap_flag_fetch*)cf->data; + if (cflag->type==MAILIMAP_FLAG_FETCH_OTHER && cflag->flag!=0) { + switch (cflag->flag->type) { + case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ + mFlags.setBit(FLAG_ANSWERED); + break; + case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ + mFlags.setBit(FLAG_FLAGGED); + break; + case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ + mFlags.setBit(FLAG_DELETED); + break; + case MAILIMAP_FLAG_SEEN: /* \Seen flag */ + mFlags.setBit(FLAG_SEEN); + break; + case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ + mFlags.setBit(FLAG_DRAFT); + break; + case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ + break; + case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ + break; + default: + break; + } + } else if (cflag->type==MAILIMAP_FLAG_FETCH_RECENT) { + mFlags.setBit(FLAG_RECENT); + } + + cf = cf->next; + } + continue; + } + if ( item->msg_att_static->type == MAILIMAP_MSG_ATT_RFC822_HEADER ) { + qDebug( "header: \n%s", item->msg_att_static->rfc822_header ); + } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_ENVELOPE) { + mailimap_envelope * head = item->msg_att_static->env; + date = head->date; + subject = head->subject; + if (head->from!=NULL) + current_from = head->from->list->first; + while (current_from != NULL) { + from = ""; + named_from = false; + current_address=(mailimap_address*)current_from->data; + current_from = current_from->next; + if (current_address->personal_name){ + from+=QString(current_address->personal_name); + from+=" "; + named_from = true; + } + if (named_from && (current_address->mailbox_name || current_address->host_name)) { + from+="<"; + } + if (current_address->mailbox_name) { + from+=QString(current_address->mailbox_name); + from+="@"; + } + if (current_address->host_name) { + from+=QString(current_address->host_name); + } + if (named_from && (current_address->mailbox_name || current_address->host_name)) { + from+=">"; + } + } + qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s", + from.latin1(), + subject.latin1(),date.latin1()); + m = new RecMail(); + m->setSubject(subject); + m->setFrom(from); + m->setDate(date); + } else { + qDebug("Another type"); + } + } + /* msg is already deleted */ + if (mFlags.testBit(FLAG_DELETED) && m) { + delete m; + m = 0; + } + if (m) { + m->setFlags(mFlags); + } + return m; +} + +QString IMAPwrapper::fetchBody(const QString & mailbox,const RecMail&mail) +{ + QString body = ""; + const char *server, *user, *pass, *mb; + uint16_t port; + int err = MAILIMAP_NO_ERROR; + clist *result; + clistcell *current; + mailimap_fetch_att *fetchAtt; + mailimap_fetch_type *fetchType; + mailimap_set *set; + + mb = mailbox.latin1(); + server = account->getServer().latin1(); + port = account->getPort().toUInt(); + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + + mailimap *imap = mailimap_new( 20, &imap_progress ); + if ( imap == NULL ) { + qDebug("IMAP Memory error"); + return body; + } + + /* connect */ + err = mailimap_socket_connect( imap, (char*)server, port ); + if ( err != MAILIMAP_NO_ERROR && + err != MAILIMAP_NO_ERROR_AUTHENTICATED && + err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { + qDebug("error connecting server: %s",imap->response); + mailimap_free( imap ); + return body; + } + + /* login */ + err = mailimap_login_simple( imap, (char*)user, (char*)pass ); + if ( err != MAILIMAP_NO_ERROR ) { + qDebug("error logging in imap: %s",imap->response); + err = mailimap_close( imap ); + mailimap_free( imap ); + return body; + } + + /* select mailbox READONLY for operations */ + err = mailimap_examine( imap, (char*)mb); + if ( err != MAILIMAP_NO_ERROR ) { + qDebug("error selecting mailbox: %s",imap->response); + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + return body; + } + result = clist_new(); + /* the range has to start at 1!!! not with 0!!!! */ + set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); + fetchAtt = mailimap_fetch_att_new_rfc822_text(); + fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); + err = mailimap_fetch( imap, set, fetchType, &result ); + mailimap_set_free( set ); + mailimap_fetch_type_free( fetchType ); + + if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { + mailimap_msg_att * msg_att; + msg_att = (mailimap_msg_att*)current->data; + mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; + + if (item->msg_att_static && item->msg_att_static->rfc822_text) { + body = item->msg_att_static->rfc822_text; + } + } else { + qDebug("error fetching text: %s",imap->response); + } + + err = mailimap_logout( imap ); + err = mailimap_close( imap ); + mailimap_free( imap ); + clist_free(result); + + return body; +} diff --git a/noncore/net/mail/libmailwrapper/logindialog.cpp b/noncore/net/mail/libmailwrapper/logindialog.cpp new file mode 100644 index 0000000..d2c6a07 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/logindialog.cpp @@ -0,0 +1,26 @@ +#include + +#include "logindialog.h" + +LoginDialog::LoginDialog( QString user, QString pass, QWidget *parent, const char *name, bool modal, WFlags flags ) + : LoginDialogUI( parent, name, modal, flags ) +{ + userLine->setText( user ); + passLine->setText( pass ); + _user = user; + _pass = pass; + + if ( user.isEmpty() ) { + userLine->setFocus(); + } else { + passLine->setFocus(); + } +} + +void LoginDialog::accept() +{ + _user.replace( 0, _user.length(), userLine->text() ); + _pass.replace( 0, _pass.length(), passLine->text() ); + + QDialog::accept(); +} diff --git a/noncore/net/mail/libmailwrapper/logindialog.h b/noncore/net/mail/libmailwrapper/logindialog.h new file mode 100644 index 0000000..7a0d1b0 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/logindialog.h @@ -0,0 +1,23 @@ +#ifndef LOGINDIALOG_H +#define LOGINDIALOG_H + +#include "logindialogui.h" + +class LoginDialog : public LoginDialogUI +{ + Q_OBJECT + +public: + LoginDialog( QString user, QString pass, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); + QString getUser() { return _user; } + QString getPassword() { return _pass; } + +protected slots: + void accept(); + +private: + QString _user, _pass; + +}; + +#endif diff --git a/noncore/net/mail/libmailwrapper/logindialogui.ui b/noncore/net/mail/libmailwrapper/logindialogui.ui new file mode 100644 index 0000000..565f777 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/logindialogui.ui @@ -0,0 +1,83 @@ + +LoginDialogUI + + QDialog + + name + LoginDialogUI + + + geometry + + 0 + 0 + 196 + 110 + + + + caption + Login + + + layoutMargin + + + layoutSpacing + + + + margin + 4 + + + spacing + 3 + + + QLabel + + name + userLabel + + + text + User + + + + QLineEdit + + name + userLine + + + + QLineEdit + + name + passLine + + + echoMode + Password + + + + QLabel + + name + passLabel + + + text + Password + + + + + + userLine + passLine + + diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp new file mode 100644 index 0000000..17bed65 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp @@ -0,0 +1,643 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mailwrapper.h" +#include "logindialog.h" +#include "mail.h" +#include "defines.h" + +Attachment::Attachment( DocLnk lnk ) +{ + doc = lnk; + size = QFileInfo( doc.file() ).size(); +} + +Folder::Folder(const QString&tmp_name ) +{ + name = tmp_name; + nameDisplay = name; + + for ( int pos = nameDisplay.find( '&' ); pos != -1; + pos = nameDisplay.find( '&' ) ) { + int end = nameDisplay.find( '-' ); + if ( end == -1 || end <= pos ) break; + QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); + // TODO: do real base64 decoding here ! + if ( str64.compare( "APw" ) == 0 ) { + nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); + } else if ( str64.compare( "APY" ) == 0 ) { + nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); + } + } + + qDebug( "folder " + name + " - displayed as " + nameDisplay ); +} + +MailWrapper::MailWrapper( Settings *s ) + : QObject() +{ + settings = s; +} + +QString MailWrapper::mailsmtpError( int errnum ) +{ + switch ( errnum ) { + case MAILSMTP_NO_ERROR: + return tr( "No error" ); + case MAILSMTP_ERROR_UNEXPECTED_CODE: + return tr( "Unexpected error code" ); + case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: + return tr( "Service not available" ); + case MAILSMTP_ERROR_STREAM: + return tr( "Stream error" ); + case MAILSMTP_ERROR_HOSTNAME: + return tr( "gethostname() failed" ); + case MAILSMTP_ERROR_NOT_IMPLEMENTED: + return tr( "Not implemented" ); + case MAILSMTP_ERROR_ACTION_NOT_TAKEN: + return tr( "Error, action not taken" ); + case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: + return tr( "Data exceeds storage allocation" ); + case MAILSMTP_ERROR_IN_PROCESSING: + return tr( "Error in processing" ); + // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: + // return tr( "Insufficient system storage" ); + case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: + return tr( "Mailbox unavailable" ); + case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: + return tr( "Mailbox name not allowed" ); + case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: + return tr( "Bad command sequence" ); + case MAILSMTP_ERROR_USER_NOT_LOCAL: + return tr( "User not local" ); + case MAILSMTP_ERROR_TRANSACTION_FAILED: + return tr( "Transaction failed" ); + case MAILSMTP_ERROR_MEMORY: + return tr( "Memory error" ); + case MAILSMTP_ERROR_CONNECTION_REFUSED: + return tr( "Connection refused" ); + default: + return tr( "Unknown error code" ); + } +} + +mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail ) +{ + return mailimf_mailbox_new( strdup( name.latin1() ), + strdup( mail.latin1() ) ); +} + +mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) +{ + mailimf_address_list *addresses; + + if ( addr.isEmpty() ) return NULL; + + addresses = mailimf_address_list_new_empty(); + + QStringList list = QStringList::split( ',', addr ); + QStringList::Iterator it; + for ( it = list.begin(); it != list.end(); it++ ) { + char *str = strdup( (*it).latin1() ); + int err = mailimf_address_list_add_parse( addresses, str ); + if ( err != MAILIMF_NO_ERROR ) { + qDebug( "Error parsing" ); + qDebug( *it ); + free( str ); + } else { + qDebug( "Parse success! :)" ); + } + } + + return addresses; +} + +mailimf_fields *MailWrapper::createImfFields( Mail *mail ) +{ + mailimf_fields *fields; + mailimf_field *xmailer; + mailimf_mailbox *sender, *fromBox; + mailimf_mailbox_list *from; + mailimf_address_list *to, *cc, *bcc, *reply; + char *subject = strdup( mail->getSubject().latin1() ); + int err; + + sender = newMailbox( mail->getName(), mail->getMail() ); + if ( sender == NULL ) goto err_free; + + fromBox = newMailbox( mail->getName(), mail->getMail() ); + if ( fromBox == NULL ) goto err_free_sender; + + from = mailimf_mailbox_list_new_empty(); + if ( from == NULL ) goto err_free_fromBox; + + err = mailimf_mailbox_list_add( from, fromBox ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_from; + + to = parseAddresses( mail->getTo() ); + if ( to == NULL ) goto err_free_from; + + cc = parseAddresses( mail->getCC() ); + bcc = parseAddresses( mail->getBCC() ); + reply = parseAddresses( mail->getReply() ); + + fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, + NULL, NULL, subject ); + if ( fields == NULL ) goto err_free_reply; + + xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), + strdup( USER_AGENT ) ); + if ( xmailer == NULL ) goto err_free_fields; + + err = mailimf_fields_add( fields, xmailer ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; + + return fields; // Success :) + +err_free_xmailer: + mailimf_field_free( xmailer ); +err_free_fields: + mailimf_fields_free( fields ); +err_free_reply: + mailimf_address_list_free( reply ); + mailimf_address_list_free( bcc ); + mailimf_address_list_free( cc ); + mailimf_address_list_free( to ); +err_free_from: + mailimf_mailbox_list_free( from ); +err_free_fromBox: + mailimf_mailbox_free( fromBox ); +err_free_sender: + mailimf_mailbox_free( sender ); +err_free: + free( subject ); + qDebug( "createImfFields - error" ); + + return NULL; // Error :( +} + +mailmime *MailWrapper::buildTxtPart( QString str ) +{ + mailmime *txtPart; + mailmime_fields *fields; + mailmime_content *content; + mailmime_parameter *param; + char *txt = strdup( str.latin1() ); + int err; + + param = mailmime_parameter_new( strdup( "charset" ), + strdup( "iso-8859-1" ) ); + if ( param == NULL ) goto err_free; + + content = mailmime_content_new_with_str( "text/plain" ); + if ( content == NULL ) goto err_free_param; + + err = clist_append( content->parameters, param ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_content; + + fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); + if ( fields == NULL ) goto err_free_content; + + txtPart = mailmime_new_empty( content, fields ); + if ( txtPart == NULL ) goto err_free_fields; + + err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; + + return txtPart; // Success :) + +err_free_txtPart: + mailmime_free( txtPart ); +err_free_fields: + mailmime_fields_free( fields ); +err_free_content: + mailmime_content_free( content ); +err_free_param: + mailmime_parameter_free( param ); +err_free: + free( txt ); + qDebug( "buildTxtPart - error" ); + + return NULL; // Error :( +} + +mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) +{ + mailmime * filePart; + mailmime_fields * fields; + mailmime_content * content; + mailmime_parameter * param = NULL; + int err; + + int pos = filename.findRev( '/' ); + QString tmp = filename.right( filename.length() - ( pos + 1 ) ); + char *name = strdup( tmp.latin1() ); // just filename + char *file = strdup( filename.latin1() ); // full name with path + char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain + + fields = mailmime_fields_new_filename( + MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, + MAILMIME_MECHANISM_BASE64 ); + if ( fields == NULL ) goto err_free; + + content = mailmime_content_new_with_str( mime ); + if ( content == NULL ) goto err_free_fields; + + if ( mimetype.compare( "text/plain" ) == 0 ) { + param = mailmime_parameter_new( strdup( "charset" ), + strdup( "iso-8859-1" ) ); + if ( param == NULL ) goto err_free_content; + + err = clist_append( content->parameters, param ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_param; + } + + filePart = mailmime_new_empty( content, fields ); + if ( filePart == NULL ) goto err_free_param; + + err = mailmime_set_body_file( filePart, file ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; + + return filePart; // Success :) + +err_free_filePart: + mailmime_free( filePart ); +err_free_param: + if ( param != NULL ) mailmime_parameter_free( param ); +err_free_content: + mailmime_content_free( content ); +err_free_fields: + mailmime_fields_free( fields ); +err_free: + free( name ); + free( mime ); + free( file ); + qDebug( "buildFilePart - error" ); + + return NULL; // Error :( +} + +void MailWrapper::addFileParts( mailmime *message, QList files ) +{ + Attachment *it; + for ( it = files.first(); it; it = files.next() ) { + qDebug( "Adding file" ); + mailmime *filePart; + int err; + + filePart = buildFilePart( it->getFileName(), it->getMimeType() ); + if ( filePart == NULL ) goto err_free; + + err = mailmime_smart_add_part( message, filePart ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; + + continue; // Success :) + + err_free_filePart: + mailmime_free( filePart ); + err_free: + qDebug( "addFileParts: error adding file:" ); + qDebug( it->getFileName() ); + } +} + +mailmime *MailWrapper::createMimeMail( Mail *mail ) +{ + mailmime *message, *txtPart; + mailimf_fields *fields; + int err; + + fields = createImfFields( mail ); + if ( fields == NULL ) goto err_free; + + message = mailmime_new_message_data( NULL ); + if ( message == NULL ) goto err_free_fields; + + mailmime_set_imf_fields( message, fields ); + + txtPart = buildTxtPart( mail->getMessage() ); + if ( txtPart == NULL ) goto err_free_message; + + err = mailmime_smart_add_part( message, txtPart ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; + + addFileParts( message, mail->getAttachments() ); + + return message; // Success :) + +err_free_txtPart: + mailmime_free( txtPart ); +err_free_message: + mailmime_free( message ); +err_free_fields: + mailimf_fields_free( fields ); +err_free: + qDebug( "createMimeMail: error" ); + + return NULL; // Error :( +} + +mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type ) +{ + mailimf_field *field; + clistiter *it; + + it = clist_begin( fields->list ); + while ( it ) { + field = (mailimf_field *) it->data; + if ( field->type == type ) { + return field; + } + it = it->next; + } + + return NULL; +} + +static void addRcpts( clist *list, mailimf_address_list *addr_list ) +{ + clistiter *it, *it2; + + for ( it = clist_begin( addr_list->list ); it; it = it->next ) { + mailimf_address *addr; + addr = (mailimf_address *) it->data; + + if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { + esmtp_address_list_add( list, addr->mailbox->addr_spec, 0, NULL ); + } else if ( addr->type == MAILIMF_ADDRESS_GROUP ) { + clist *l = addr->group->mb_list->list; + for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { + mailimf_mailbox *mbox; + mbox = (mailimf_mailbox *) it2->data; + esmtp_address_list_add( list, mbox->addr_spec, 0, NULL ); + } + } + } +} + +clist *MailWrapper::createRcptList( mailimf_fields *fields ) +{ + clist *rcptList; + mailimf_field *field; + + rcptList = esmtp_address_list_new(); + + field = getField( fields, MAILIMF_FIELD_TO ); + if ( field && (field->type == MAILIMF_FIELD_TO) + && field->field.to->addr_list ) { + addRcpts( rcptList, field->field.to->addr_list ); + } + + field = getField( fields, MAILIMF_FIELD_CC ); + if ( field && (field->type == MAILIMF_FIELD_CC) + && field->field.cc->addr_list ) { + addRcpts( rcptList, field->field.cc->addr_list ); + } + + field = getField( fields, MAILIMF_FIELD_BCC ); + if ( field && (field->type == MAILIMF_FIELD_BCC) + && field->field.bcc->addr_list ) { + addRcpts( rcptList, field->field.bcc->addr_list ); + } + + return rcptList; +} + +char *MailWrapper::getFrom( mailmime *mail ) +{ + char *from = NULL; + + mailimf_field *ffrom; + ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); + if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) + && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { + clist *cl = ffrom->field.from->mb_list->list; + clistiter *it; + for ( it = clist_begin( cl ); it; it = it->next ) { + mailimf_mailbox *mb = (mailimf_mailbox *) it->data; + from = strdup( mb->addr_spec ); + } + } + + return from; +} + +SMTPaccount *MailWrapper::getAccount( QString from ) +{ + SMTPaccount *smtp; + + QList list = settings->getAccounts(); + Account *it; + for ( it = list.first(); it; it = list.next() ) { + if ( it->getType().compare( "SMTP" ) == 0 ) { + smtp = static_cast(it); + if ( smtp->getMail().compare( from ) == 0 ) { + qDebug( "SMTPaccount found for" ); + qDebug( from ); + return smtp; + } + } + } + + return NULL; +} + +QString MailWrapper::getTmpFile() { + int num = 0; + QString unique; + + QDir dir( "/tmp" ); + QStringList::Iterator it; + + QStringList list = dir.entryList( "opiemail-tmp-*" ); + do { + unique.setNum( num++ ); + } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); + + return "/tmp/opiemail-tmp-" + unique; +} + +void MailWrapper::writeToFile( QString file, mailmime *mail ) +{ + FILE *f; + int err, col = 0; + + f = fopen( file.latin1(), "w" ); + if ( f == NULL ) { + qDebug( "writeToFile: error opening file" ); + return; + } + + err = mailmime_write( f, &col, mail ); + if ( err != MAILIMF_NO_ERROR ) { + fclose( f ); + qDebug( "writeToFile: error writing mailmime" ); + return; + } + + fclose( f ); +} + +void MailWrapper::readFromFile( QString file, char **data, size_t *size ) +{ + char *buf; + struct stat st; + int fd, count = 0, total = 0; + + fd = open( file.latin1(), O_RDONLY, 0 ); + if ( fd == -1 ) return; + + if ( fstat( fd, &st ) != 0 ) goto err_close; + if ( !st.st_size ) goto err_close; + + buf = (char *) malloc( st.st_size ); + if ( !buf ) goto err_close; + + while ( ( total < st.st_size ) && ( count >= 0 ) ) { + count = read( fd, buf + total, st.st_size - total ); + total += count; + } + if ( count < 0 ) goto err_free; + + *data = buf; + *size = st.st_size; + + close( fd ); + + return; // Success :) + +err_free: + free( buf ); +err_close: + close( fd ); +} + +void progress( size_t current, size_t maximum ) +{ + qDebug( "Current: %i of %i", current, maximum ); +} + +void MailWrapper::smtpSend( mailmime *mail ) +{ + mailsmtp *session; + clist *rcpts; + char *from, *data, *server, *user = NULL, *pass = NULL; + size_t size; + int err; + bool ssl; + uint16_t port; + + + from = getFrom( mail ); + SMTPaccount *smtp = getAccount( from ); + if ( smtp == NULL ) { + free(from); + return; + } + server = strdup( smtp->getServer().latin1() ); + ssl = smtp->getSSL(); + port = smtp->getPort().toUInt(); + rcpts = createRcptList( mail->fields ); + + QString file = getTmpFile(); + writeToFile( file, mail ); + readFromFile( file, &data, &size ); + QFile f( file ); + f.remove(); + + session = mailsmtp_new( 20, &progress ); + if ( session == NULL ) goto free_mem; + + qDebug( "Servername %s at port %i", server, port ); + if ( ssl ) { + qDebug( "SSL session" ); + err = mailsmtp_ssl_connect( session, server, port ); + } else { + qDebug( "No SSL session" ); + err = mailsmtp_socket_connect( session, server, port ); + } + if ( err != MAILSMTP_NO_ERROR ) goto free_mem_session; + + err = mailsmtp_init( session ); + if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; + + qDebug( "INIT OK" ); + + if ( smtp->getLogin() ) { + if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { + // get'em + LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); + login.show(); + if ( QDialog::Accepted == login.exec() ) { + // ok + user = strdup( login.getUser().latin1() ); + pass = strdup( login.getPassword().latin1() ); + } else { + goto free_con_session; + } + } else { + user = strdup( smtp->getUser().latin1() ); + pass = strdup( smtp->getPassword().latin1() ); + } + qDebug( "session->auth: %i", session->auth); + err = mailsmtp_auth( session, user, pass ); + if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); + qDebug( "Done auth!" ); + } + + err = mailsmtp_send( session, from, rcpts, data, size ); + if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; + + qDebug( "Mail sent." ); + +free_con_session: + mailsmtp_quit( session ); +free_mem_session: + mailsmtp_free( session ); +free_mem: + smtp_address_list_free( rcpts ); + free( data ); + free( server ); + if ( smtp->getLogin() ) { + free( user ); + free( pass ); + } + free( from ); +} + +void MailWrapper::sendMail( Mail mail ) +{ + mailmime *mimeMail; + + mimeMail = createMimeMail( &mail ); + if ( mimeMail == NULL ) { + qDebug( "sendMail: error creating mime mail" ); + } else { + smtpSend( mimeMail ); + mailmime_free( mimeMail ); + } +} + +Mail::Mail() + :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") +{ +} + +RecMail::RecMail() + :subject(""),date(""),msg_number(0),msg_flags(7) +{ +} + +#if 0 +void RecMail::setDate(const QString&aDate) +{ + mDate = QDateTime::fromString(aDate); +} +#endif diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h new file mode 100644 index 0000000..3de28a0 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h @@ -0,0 +1,183 @@ +#ifndef MAILWRAPPER_H +#define MAILWRAPPER_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "settings.h" + +class Attachment +{ +public: + Attachment( DocLnk lnk ); + virtual ~Attachment(){} + const QString getFileName()const{ return doc.file(); } + const QString getName()const{ return doc.name(); } + const QString getMimeType()const{ return doc.type(); } + const QPixmap getPixmap()const{ return doc.pixmap(); } + const int getSize()const { return size; } + DocLnk getDocLnk() { return doc; } + +protected: + DocLnk doc; + int size; + +}; + +#define FLAG_ANSWERED 0 +#define FLAG_FLAGGED 1 +#define FLAG_DELETED 2 +#define FLAG_SEEN 3 +#define FLAG_DRAFT 4 +#define FLAG_RECENT 5 + +/* a class to describe mails in a mailbox */ +class RecMail +{ +public: + RecMail(); + virtual ~RecMail(){} + + const int getNumber()const{return msg_number;} + void setNumber(int number){msg_number=number;} + const QString&getDate()const{ return date; } + void setDate( const QString&a ) { date = a; } + const QString&getFrom()const{ return from; } + void setFrom( const QString&a ) { from = a; } + const QString&getSubject()const { return subject; } + void setSubject( const QString&s ) { subject = s; } + void setFlags(const QBitArray&flags){msg_flags = flags;} + const QBitArray&getFlags()const{return msg_flags;} + +#if 0 + void setDate(const QString&dstring); + void setDate(const QDateTime&date){mDate = date;} + QString getDate()const{return mDate.toString();} +#endif +protected: + QString subject,date,from; + int msg_number; + QBitArray msg_flags; +#if 0 + QDateTime mDate; +#endif +}; + +typedef QList Maillist; + +class Mail +{ +public: + Mail(); + /* Possible that this destructor must not be declared virtual + * 'cause it seems that it will never have some child classes. + * in this case this object will not get a virtual table -> memory and + * speed will be a little bit better? + */ + virtual ~Mail(){} + void addAttachment( Attachment *att ) { attList.append( att ); } + const QList& getAttachments()const { return attList; } + void removeAttachment( Attachment *att ) { attList.remove( att ); } + const QString&getName()const { return name; } + void setName( QString s ) { name = s; } + const QString&getMail()const{ return mail; } + void setMail( const QString&s ) { mail = s; } + const QString&getTo()const{ return to; } + void setTo( const QString&s ) { to = s; } + const QString&getCC()const{ return cc; } + void setCC( const QString&s ) { cc = s; } + const QString&getBCC()const { return bcc; } + void setBCC( const QString&s ) { bcc = s; } + const QString&getMessage()const { return message; } + void setMessage( const QString&s ) { message = s; } + const QString&getSubject()const { return subject; } + void setSubject( const QString&s ) { subject = s; } + const QString&getReply()const{ return reply; } + void setReply( const QString&a ) { reply = a; } + +private: + QList attList; + QString name, mail, to, cc, bcc, reply, subject, message; +}; + +class Folder : public QObject +{ + Q_OBJECT + +public: + Folder( const QString&init_name ); + const QString&getDisplayName()const { return nameDisplay; } + const QString&getName()const { return name; } + virtual bool may_select()const{return true;}; + +private: + QString nameDisplay, name; + +}; + +class IMAPFolder : public Folder +{ + public: + IMAPFolder( QString name,bool select=true ) : Folder( name ),m_MaySelect(select) {} + virtual bool may_select()const{return m_MaySelect;} + private: + bool m_MaySelect; +}; + +class MailWrapper : public QObject +{ + Q_OBJECT + +public: + MailWrapper( Settings *s ); + void sendMail( Mail mail ); + +private: + mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); + mailimf_address_list *parseAddresses(const QString&addr ); + mailimf_fields *createImfFields( Mail *mail ); + mailmime *buildTxtPart( QString str ); + mailmime *buildFilePart( QString filename, QString mimetype ); + void addFileParts( mailmime *message, QList files ); + mailmime *createMimeMail( Mail *mail ); + void smtpSend( mailmime *mail ); + mailimf_field *getField( mailimf_fields *fields, int type ); + clist *createRcptList( mailimf_fields *fields ); + char *getFrom( mailmime *mail ); + SMTPaccount *getAccount( QString from ); + void writeToFile( QString file, mailmime *mail ); + void readFromFile( QString file, char **data, size_t *size ); + static QString mailsmtpError( int err ); + static QString getTmpFile(); + + Settings *settings; + +}; + +class IMAPwrapper : public QObject +{ + Q_OBJECT + +public: + IMAPwrapper( IMAPaccount *a ); + QList* listFolders(); + void listMessages(const QString & mailbox,Maillist&target ); + QString fetchBody(const QString & mailbox,const RecMail&mail); + +protected: + RecMail*parse_list_result(mailimap_msg_att*); + +private: + IMAPaccount *account; + +}; + +#endif diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp new file mode 100644 index 0000000..9632301 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/settings.cpp @@ -0,0 +1,432 @@ +#include +#include + +#include + +#include "settings.h" +#include "defines.h" + +Settings::Settings() + : QObject() +{ + updateAccounts(); +} + +void Settings::checkDirectory() +{ + if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { + system( "mkdir -p $HOME/Applications/opiemail" ); + qDebug( "$HOME/Applications/opiemail created" ); + } +} + +QList Settings::getAccounts() +{ + return accounts; +} + +void Settings::addAccount( Account *account ) +{ + accounts.append( account ); +} + +void Settings::delAccount( Account *account ) +{ + accounts.remove( account ); + account->remove(); +} + +void Settings::updateAccounts() +{ + accounts.clear(); + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "imap-*" ); + for ( it = imap.begin(); it != imap.end(); it++ ) { + qDebug( "Added IMAP account" ); + IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); + accounts.append( account ); + } + + QStringList pop3 = dir.entryList( "pop3-*" ); + for ( it = pop3.begin(); it != pop3.end(); it++ ) { + qDebug( "Added POP account" ); + POP3account *account = new POP3account( (*it).replace(0, 5, "") ); + accounts.append( account ); + } + + QStringList smtp = dir.entryList( "smtp-*" ); + for ( it = smtp.begin(); it != smtp.end(); it++ ) { + qDebug( "Added SMTP account" ); + SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); + accounts.append( account ); + } + + QStringList nntp = dir.entryList( "nntp-*" ); + for ( it = nntp.begin(); it != nntp.end(); it++ ) { + qDebug( "Added NNTP account" ); + NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); + accounts.append( account ); + } + + readAccounts(); +} + +void Settings::saveAccounts() +{ + checkDirectory(); + Account *it; + + for ( it = accounts.first(); it; it = accounts.next() ) { + it->save(); + } +} + +void Settings::readAccounts() +{ + checkDirectory(); + Account *it; + + for ( it = accounts.first(); it; it = accounts.next() ) { + it->read(); + } +} + +Account::Account() +{ + accountName = "changeMe"; + type = "changeMe"; + ssl = false; +} + +void Account::remove() +{ + QFile file( getFileName() ); + file.remove(); +} + +IMAPaccount::IMAPaccount() + : Account() +{ + file = IMAPaccount::getUniqueFileName(); + accountName = "New IMAP Account"; + ssl = false; + type = "IMAP"; + port = IMAP_PORT; +} + +IMAPaccount::IMAPaccount( QString filename ) + : Account() +{ + file = filename; + accountName = "New IMAP Account"; + ssl = false; + type = "IMAP"; + port = IMAP_PORT; +} + +QString IMAPaccount::getUniqueFileName() +{ + int num = 0; + QString unique; + + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "imap-*" ); + do { + unique.setNum( num++ ); + } while ( imap.contains( "imap-" + unique ) > 0 ); + + return unique; +} + +void IMAPaccount::read() +{ + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "IMAP Account" ); + accountName = conf->readEntry( "Account","" ); + if (accountName.isNull()) accountName = ""; + server = conf->readEntry( "Server","" ); + if (server.isNull()) server=""; + port = conf->readEntry( "Port","" ); + if (port.isNull()) port="143"; + ssl = conf->readBoolEntry( "SSL",false ); + user = conf->readEntry( "User","" ); + if (user.isNull()) user = ""; + password = conf->readEntryCrypt( "Password","" ); + if (password.isNull()) password = ""; + prefix = conf->readEntry("MailPrefix",""); + if (prefix.isNull()) prefix = ""; +} + +void IMAPaccount::save() +{ + qDebug( "saving " + getFileName() ); + Settings::checkDirectory(); + + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "IMAP Account" ); + conf->writeEntry( "Account", accountName ); + conf->writeEntry( "Server", server ); + conf->writeEntry( "Port", port ); + conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "User", user ); + conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "MailPrefix",prefix); + conf->write(); +} + + +QString IMAPaccount::getFileName() +{ + return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; +} + +POP3account::POP3account() + : Account() +{ + file = POP3account::getUniqueFileName(); + accountName = "New POP3 Account"; + ssl = false; + type = "POP3"; + port = POP3_PORT; +} + +POP3account::POP3account( QString filename ) + : Account() +{ + file = filename; + accountName = "New POP3 Account"; + ssl = false; + type = "POP3"; + port = POP3_PORT; +} + +QString POP3account::getUniqueFileName() +{ + int num = 0; + QString unique; + + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "pop3-*" ); + do { + unique.setNum( num++ ); + } while ( imap.contains( "pop3-" + unique ) > 0 ); + + return unique; +} + +void POP3account::read() +{ + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "POP3 Account" ); + accountName = conf->readEntry( "Account" ); + server = conf->readEntry( "Server" ); + port = conf->readEntry( "Port" ); + ssl = conf->readBoolEntry( "SSL" ); + user = conf->readEntry( "User" ); + password = conf->readEntryCrypt( "Password" ); +} + +void POP3account::save() +{ + qDebug( "saving " + getFileName() ); + Settings::checkDirectory(); + + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "POP3 Account" ); + conf->writeEntry( "Account", accountName ); + conf->writeEntry( "Server", server ); + conf->writeEntry( "Port", port ); + conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "User", user ); + conf->writeEntryCrypt( "Password", password ); + conf->write(); +} + + +QString POP3account::getFileName() +{ + return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; +} + +SMTPaccount::SMTPaccount() + : Account() +{ + file = SMTPaccount::getUniqueFileName(); + accountName = "New SMTP Account"; + ssl = false; + login = false; + useCC = false; + useBCC = false; + useReply = false; + type = "SMTP"; + port = SMTP_PORT; +} + +SMTPaccount::SMTPaccount( QString filename ) + : Account() +{ + file = filename; + accountName = "New SMTP Account"; + ssl = false; + login = false; + useCC = false; + useBCC = false; + useReply = false; + type = "SMTP"; + port = SMTP_PORT; +} + +QString SMTPaccount::getUniqueFileName() +{ + int num = 0; + QString unique; + + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "smtp-*" ); + do { + unique.setNum( num++ ); + } while ( imap.contains( "smtp-" + unique ) > 0 ); + + return unique; +} + +void SMTPaccount::read() +{ + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "SMTP Account" ); + accountName = conf->readEntry( "Account" ); + server = conf->readEntry( "Server" ); + port = conf->readEntry( "Port" ); + ssl = conf->readBoolEntry( "SSL" ); + login = conf->readBoolEntry( "Login" ); + user = conf->readEntry( "User" ); + password = conf->readEntryCrypt( "Password" ); + useCC = conf->readBoolEntry( "useCC" ); + useBCC = conf->readBoolEntry( "useBCC" ); + useReply = conf->readBoolEntry( "useReply" ); + name = conf->readEntry( "Name" ); + mail = conf->readEntry( "Mail" ); + org = conf->readEntry( "Org" ); + cc = conf->readEntry( "CC" ); + bcc = conf->readEntry( "BCC" ); + reply = conf->readEntry( "Reply" ); + signature = conf->readEntry( "Signature" ); + signature = signature.replace( QRegExp( "
" ), "\n" ); +} + +void SMTPaccount::save() +{ + qDebug( "saving " + getFileName() ); + Settings::checkDirectory(); + + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "SMTP Account" ); + conf->writeEntry( "Account", accountName ); + conf->writeEntry( "Server", server ); + conf->writeEntry( "Port", port ); + conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "Login", login ); + conf->writeEntry( "User", user ); + conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "useCC", useCC ); + conf->writeEntry( "useBCC", useBCC ); + conf->writeEntry( "useReply", useReply ); + conf->writeEntry( "Name", name ); + conf->writeEntry( "Mail", mail ); + conf->writeEntry( "Org", org ); + conf->writeEntry( "CC", cc ); + conf->writeEntry( "BCC", bcc ); + conf->writeEntry( "Reply", reply ); + conf->writeEntry( "Signature", + signature.replace( QRegExp( "\\n" ), "
" ) ); + conf->write(); +} + + +QString SMTPaccount::getFileName() +{ + return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; +} + +NNTPaccount::NNTPaccount() + : Account() +{ + file = NNTPaccount::getUniqueFileName(); + accountName = "New NNTP Account"; + ssl = false; + login = false; + type = "NNTP"; + port = NNTP_PORT; +} + +NNTPaccount::NNTPaccount( QString filename ) + : Account() +{ + file = filename; + accountName = "New NNTP Account"; + ssl = false; + login = false; + type = "NNTP"; + port = NNTP_PORT; +} + +QString NNTPaccount::getUniqueFileName() +{ + int num = 0; + QString unique; + + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "nntp-*" ); + do { + unique.setNum( num++ ); + } while ( imap.contains( "nntp-" + unique ) > 0 ); + + return unique; +} + +void NNTPaccount::read() +{ + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "NNTP Account" ); + accountName = conf->readEntry( "Account" ); + server = conf->readEntry( "Server" ); + port = conf->readEntry( "Port" ); + ssl = conf->readBoolEntry( "SSL" ); + login = conf->readBoolEntry( "Login" ); + user = conf->readEntry( "User" ); + password = conf->readEntryCrypt( "Password" ); +} + +void NNTPaccount::save() +{ + qDebug( "saving " + getFileName() ); + Settings::checkDirectory(); + + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "NNTP Account" ); + conf->writeEntry( "Account", accountName ); + conf->writeEntry( "Server", server ); + conf->writeEntry( "Port", port ); + conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "Login", login ); + conf->writeEntry( "User", user ); + conf->writeEntryCrypt( "Password", password ); + conf->write(); +} + + +QString NNTPaccount::getFileName() +{ + return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; +} + diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h new file mode 100644 index 0000000..22184a5 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/settings.h @@ -0,0 +1,166 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include +#include + +class Account +{ + +public: + Account(); + virtual ~Account() {} + + void remove(); + void setAccountName( QString name ) { accountName = name; } + const QString&getAccountName()const{ return accountName; } + const QString&getType()const{ return type; } + + void setServer(const QString&str){ server = str; } + const QString&getServer()const{ return server; } + + void setPort(const QString&str) { port = str; } + const QString&getPort()const{ return port; } + + void setUser(const QString&str){ user = str; } + const QString&getUser()const{ return user; } + + void setPassword(const QString&str) { password = str; } + const QString&getPassword()const { return password; } + + void setSSL( bool b ) { ssl = b; } + bool getSSL() { return ssl; } + + virtual QString getFileName() { return accountName; } + virtual void read() { qDebug( "base reading..." ); } + virtual void save() { qDebug( "base saving..." ); } + +protected: + QString accountName, type, server, port, user, password; + bool ssl; + +}; + +class IMAPaccount : public Account +{ + +public: + IMAPaccount(); + IMAPaccount( QString filename ); + + static QString getUniqueFileName(); + + virtual void read(); + virtual void save(); + virtual QString getFileName(); + + void setPrefix(const QString&str) {prefix=str;} + const QString&getPrefix()const{return prefix;} + +private: + QString file,prefix; + +}; + +class POP3account : public Account +{ + +public: + POP3account(); + POP3account( QString filename ); + + static QString getUniqueFileName(); + + virtual void read(); + virtual void save(); + virtual QString getFileName(); + +private: + QString file; + +}; + +class SMTPaccount : public Account +{ + +public: + SMTPaccount(); + SMTPaccount( QString filename ); + + static QString getUniqueFileName(); + + virtual void read(); + virtual void save(); + virtual QString getFileName(); + + void setName( QString str ) { name = str; } + QString getName() { return name; } + void setMail( QString str ) { mail = str; } + QString getMail() { return mail; } + void setOrg( QString str ) { org = str; } + QString getOrg() { return org; } + void setUseCC( bool b ) { useCC = b; } + bool getUseCC() { return useCC; } + void setCC( QString str ) { cc = str; } + QString getCC() { return cc; } + void setUseBCC( bool b ) { useBCC = b; } + bool getUseBCC() { return useBCC; } + void setBCC( QString str ) { bcc = str; } + QString getBCC() { return bcc; } + void setUseReply( bool b ) { useReply = b; } + bool getUseReply() { return useReply; } + void setReply( QString str ) { reply = str; } + QString getReply() { return reply; } + void setSignature( QString str ) { signature = str; } + QString getSignature() { return signature; } + void setLogin( bool b ) { login = b; } + bool getLogin() { return login; } + +private: + QString file, name, mail, org, cc, bcc, reply, signature; + bool useCC, useBCC, useReply, login; + +}; + +class NNTPaccount : public Account +{ + +public: + NNTPaccount(); + NNTPaccount( QString filename ); + + static QString getUniqueFileName(); + + virtual void read(); + virtual void save(); + virtual QString getFileName(); + + void setLogin( bool b ) { login = b; } + bool getLogin() { return login; } + +private: + QString file; + bool login; + +}; + +class Settings : public QObject +{ + Q_OBJECT + +public: + Settings(); + QList getAccounts(); + void addAccount(Account *account); + void delAccount(Account *account); + void saveAccounts(); + void readAccounts(); + static void checkDirectory(); + +private: + void updateAccounts(); + QList accounts; + +}; + +#endif diff --git a/noncore/net/mail/logindialog.cpp b/noncore/net/mail/logindialog.cpp new file mode 100644 index 0000000..d2c6a07 --- a/dev/null +++ b/noncore/net/mail/logindialog.cpp @@ -0,0 +1,26 @@ +#include + +#include "logindialog.h" + +LoginDialog::LoginDialog( QString user, QString pass, QWidget *parent, const char *name, bool modal, WFlags flags ) + : LoginDialogUI( parent, name, modal, flags ) +{ + userLine->setText( user ); + passLine->setText( pass ); + _user = user; + _pass = pass; + + if ( user.isEmpty() ) { + userLine->setFocus(); + } else { + passLine->setFocus(); + } +} + +void LoginDialog::accept() +{ + _user.replace( 0, _user.length(), userLine->text() ); + _pass.replace( 0, _pass.length(), passLine->text() ); + + QDialog::accept(); +} diff --git a/noncore/net/mail/logindialog.h b/noncore/net/mail/logindialog.h new file mode 100644 index 0000000..7a0d1b0 --- a/dev/null +++ b/noncore/net/mail/logindialog.h @@ -0,0 +1,23 @@ +#ifndef LOGINDIALOG_H +#define LOGINDIALOG_H + +#include "logindialogui.h" + +class LoginDialog : public LoginDialogUI +{ + Q_OBJECT + +public: + LoginDialog( QString user, QString pass, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); + QString getUser() { return _user; } + QString getPassword() { return _pass; } + +protected slots: + void accept(); + +private: + QString _user, _pass; + +}; + +#endif diff --git a/noncore/net/mail/logindialogui.ui b/noncore/net/mail/logindialogui.ui new file mode 100644 index 0000000..565f777 --- a/dev/null +++ b/noncore/net/mail/logindialogui.ui @@ -0,0 +1,83 @@ + +LoginDialogUI + + QDialog + + name + LoginDialogUI + + + geometry + + 0 + 0 + 196 + 110 + + + + caption + Login + + + layoutMargin + + + layoutSpacing + + + + margin + 4 + + + spacing + 3 + + + QLabel + + name + userLabel + + + text + User + + + + QLineEdit + + name + userLine + + + + QLineEdit + + name + passLine + + + echoMode + Password + + + + QLabel + + name + passLabel + + + text + Password + + + + + + userLine + passLine + + diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro new file mode 100644 index 0000000..098817a --- a/dev/null +++ b/noncore/net/mail/mail.pro @@ -0,0 +1,42 @@ +CONFIG += qt warn_on debug quick-app + +HEADERS = defines.h \ + logindialog.h \ + settings.h \ + editaccounts.h \ + mailwrapper.h \ + composemail.h \ + accountview.h \ + mainwindow.h \ + readmailgui.h \ + opiemail.h + +SOURCES = main.cpp \ + opiemail.cpp \ + mainwindow.cpp \ + accountview.cpp \ + composemail.cpp \ + mailwrapper.cpp \ + imapwrapper.cpp \ + addresspicker.cpp \ + editaccounts.cpp \ + logindialog.cpp \ + readmailgui.cpp \ + settings.cpp + +INTERFACES = editaccountsui.ui \ + selectmailtypeui.ui \ + imapconfigui.ui \ + pop3configui.ui \ + nntpconfigui.ui \ + smtpconfigui.ui \ + addresspickerui.ui \ + logindialogui.ui \ + composemailui.ui + +INCLUDEPATH += $(OPIEDIR)/include +INCLUDEPATH += $(OPIEDIR)/include/libetpan +LIBS += -lqpe -lopie -letpan -lssl -lcrypto -ldb +TARGET = opiemail + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp new file mode 100644 index 0000000..17bed65 --- a/dev/null +++ b/noncore/net/mail/mailwrapper.cpp @@ -0,0 +1,643 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mailwrapper.h" +#include "logindialog.h" +#include "mail.h" +#include "defines.h" + +Attachment::Attachment( DocLnk lnk ) +{ + doc = lnk; + size = QFileInfo( doc.file() ).size(); +} + +Folder::Folder(const QString&tmp_name ) +{ + name = tmp_name; + nameDisplay = name; + + for ( int pos = nameDisplay.find( '&' ); pos != -1; + pos = nameDisplay.find( '&' ) ) { + int end = nameDisplay.find( '-' ); + if ( end == -1 || end <= pos ) break; + QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); + // TODO: do real base64 decoding here ! + if ( str64.compare( "APw" ) == 0 ) { + nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); + } else if ( str64.compare( "APY" ) == 0 ) { + nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); + } + } + + qDebug( "folder " + name + " - displayed as " + nameDisplay ); +} + +MailWrapper::MailWrapper( Settings *s ) + : QObject() +{ + settings = s; +} + +QString MailWrapper::mailsmtpError( int errnum ) +{ + switch ( errnum ) { + case MAILSMTP_NO_ERROR: + return tr( "No error" ); + case MAILSMTP_ERROR_UNEXPECTED_CODE: + return tr( "Unexpected error code" ); + case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: + return tr( "Service not available" ); + case MAILSMTP_ERROR_STREAM: + return tr( "Stream error" ); + case MAILSMTP_ERROR_HOSTNAME: + return tr( "gethostname() failed" ); + case MAILSMTP_ERROR_NOT_IMPLEMENTED: + return tr( "Not implemented" ); + case MAILSMTP_ERROR_ACTION_NOT_TAKEN: + return tr( "Error, action not taken" ); + case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: + return tr( "Data exceeds storage allocation" ); + case MAILSMTP_ERROR_IN_PROCESSING: + return tr( "Error in processing" ); + // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: + // return tr( "Insufficient system storage" ); + case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: + return tr( "Mailbox unavailable" ); + case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: + return tr( "Mailbox name not allowed" ); + case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: + return tr( "Bad command sequence" ); + case MAILSMTP_ERROR_USER_NOT_LOCAL: + return tr( "User not local" ); + case MAILSMTP_ERROR_TRANSACTION_FAILED: + return tr( "Transaction failed" ); + case MAILSMTP_ERROR_MEMORY: + return tr( "Memory error" ); + case MAILSMTP_ERROR_CONNECTION_REFUSED: + return tr( "Connection refused" ); + default: + return tr( "Unknown error code" ); + } +} + +mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail ) +{ + return mailimf_mailbox_new( strdup( name.latin1() ), + strdup( mail.latin1() ) ); +} + +mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) +{ + mailimf_address_list *addresses; + + if ( addr.isEmpty() ) return NULL; + + addresses = mailimf_address_list_new_empty(); + + QStringList list = QStringList::split( ',', addr ); + QStringList::Iterator it; + for ( it = list.begin(); it != list.end(); it++ ) { + char *str = strdup( (*it).latin1() ); + int err = mailimf_address_list_add_parse( addresses, str ); + if ( err != MAILIMF_NO_ERROR ) { + qDebug( "Error parsing" ); + qDebug( *it ); + free( str ); + } else { + qDebug( "Parse success! :)" ); + } + } + + return addresses; +} + +mailimf_fields *MailWrapper::createImfFields( Mail *mail ) +{ + mailimf_fields *fields; + mailimf_field *xmailer; + mailimf_mailbox *sender, *fromBox; + mailimf_mailbox_list *from; + mailimf_address_list *to, *cc, *bcc, *reply; + char *subject = strdup( mail->getSubject().latin1() ); + int err; + + sender = newMailbox( mail->getName(), mail->getMail() ); + if ( sender == NULL ) goto err_free; + + fromBox = newMailbox( mail->getName(), mail->getMail() ); + if ( fromBox == NULL ) goto err_free_sender; + + from = mailimf_mailbox_list_new_empty(); + if ( from == NULL ) goto err_free_fromBox; + + err = mailimf_mailbox_list_add( from, fromBox ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_from; + + to = parseAddresses( mail->getTo() ); + if ( to == NULL ) goto err_free_from; + + cc = parseAddresses( mail->getCC() ); + bcc = parseAddresses( mail->getBCC() ); + reply = parseAddresses( mail->getReply() ); + + fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, + NULL, NULL, subject ); + if ( fields == NULL ) goto err_free_reply; + + xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), + strdup( USER_AGENT ) ); + if ( xmailer == NULL ) goto err_free_fields; + + err = mailimf_fields_add( fields, xmailer ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; + + return fields; // Success :) + +err_free_xmailer: + mailimf_field_free( xmailer ); +err_free_fields: + mailimf_fields_free( fields ); +err_free_reply: + mailimf_address_list_free( reply ); + mailimf_address_list_free( bcc ); + mailimf_address_list_free( cc ); + mailimf_address_list_free( to ); +err_free_from: + mailimf_mailbox_list_free( from ); +err_free_fromBox: + mailimf_mailbox_free( fromBox ); +err_free_sender: + mailimf_mailbox_free( sender ); +err_free: + free( subject ); + qDebug( "createImfFields - error" ); + + return NULL; // Error :( +} + +mailmime *MailWrapper::buildTxtPart( QString str ) +{ + mailmime *txtPart; + mailmime_fields *fields; + mailmime_content *content; + mailmime_parameter *param; + char *txt = strdup( str.latin1() ); + int err; + + param = mailmime_parameter_new( strdup( "charset" ), + strdup( "iso-8859-1" ) ); + if ( param == NULL ) goto err_free; + + content = mailmime_content_new_with_str( "text/plain" ); + if ( content == NULL ) goto err_free_param; + + err = clist_append( content->parameters, param ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_content; + + fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); + if ( fields == NULL ) goto err_free_content; + + txtPart = mailmime_new_empty( content, fields ); + if ( txtPart == NULL ) goto err_free_fields; + + err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; + + return txtPart; // Success :) + +err_free_txtPart: + mailmime_free( txtPart ); +err_free_fields: + mailmime_fields_free( fields ); +err_free_content: + mailmime_content_free( content ); +err_free_param: + mailmime_parameter_free( param ); +err_free: + free( txt ); + qDebug( "buildTxtPart - error" ); + + return NULL; // Error :( +} + +mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) +{ + mailmime * filePart; + mailmime_fields * fields; + mailmime_content * content; + mailmime_parameter * param = NULL; + int err; + + int pos = filename.findRev( '/' ); + QString tmp = filename.right( filename.length() - ( pos + 1 ) ); + char *name = strdup( tmp.latin1() ); // just filename + char *file = strdup( filename.latin1() ); // full name with path + char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain + + fields = mailmime_fields_new_filename( + MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, + MAILMIME_MECHANISM_BASE64 ); + if ( fields == NULL ) goto err_free; + + content = mailmime_content_new_with_str( mime ); + if ( content == NULL ) goto err_free_fields; + + if ( mimetype.compare( "text/plain" ) == 0 ) { + param = mailmime_parameter_new( strdup( "charset" ), + strdup( "iso-8859-1" ) ); + if ( param == NULL ) goto err_free_content; + + err = clist_append( content->parameters, param ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_param; + } + + filePart = mailmime_new_empty( content, fields ); + if ( filePart == NULL ) goto err_free_param; + + err = mailmime_set_body_file( filePart, file ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; + + return filePart; // Success :) + +err_free_filePart: + mailmime_free( filePart ); +err_free_param: + if ( param != NULL ) mailmime_parameter_free( param ); +err_free_content: + mailmime_content_free( content ); +err_free_fields: + mailmime_fields_free( fields ); +err_free: + free( name ); + free( mime ); + free( file ); + qDebug( "buildFilePart - error" ); + + return NULL; // Error :( +} + +void MailWrapper::addFileParts( mailmime *message, QList files ) +{ + Attachment *it; + for ( it = files.first(); it; it = files.next() ) { + qDebug( "Adding file" ); + mailmime *filePart; + int err; + + filePart = buildFilePart( it->getFileName(), it->getMimeType() ); + if ( filePart == NULL ) goto err_free; + + err = mailmime_smart_add_part( message, filePart ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; + + continue; // Success :) + + err_free_filePart: + mailmime_free( filePart ); + err_free: + qDebug( "addFileParts: error adding file:" ); + qDebug( it->getFileName() ); + } +} + +mailmime *MailWrapper::createMimeMail( Mail *mail ) +{ + mailmime *message, *txtPart; + mailimf_fields *fields; + int err; + + fields = createImfFields( mail ); + if ( fields == NULL ) goto err_free; + + message = mailmime_new_message_data( NULL ); + if ( message == NULL ) goto err_free_fields; + + mailmime_set_imf_fields( message, fields ); + + txtPart = buildTxtPart( mail->getMessage() ); + if ( txtPart == NULL ) goto err_free_message; + + err = mailmime_smart_add_part( message, txtPart ); + if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; + + addFileParts( message, mail->getAttachments() ); + + return message; // Success :) + +err_free_txtPart: + mailmime_free( txtPart ); +err_free_message: + mailmime_free( message ); +err_free_fields: + mailimf_fields_free( fields ); +err_free: + qDebug( "createMimeMail: error" ); + + return NULL; // Error :( +} + +mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type ) +{ + mailimf_field *field; + clistiter *it; + + it = clist_begin( fields->list ); + while ( it ) { + field = (mailimf_field *) it->data; + if ( field->type == type ) { + return field; + } + it = it->next; + } + + return NULL; +} + +static void addRcpts( clist *list, mailimf_address_list *addr_list ) +{ + clistiter *it, *it2; + + for ( it = clist_begin( addr_list->list ); it; it = it->next ) { + mailimf_address *addr; + addr = (mailimf_address *) it->data; + + if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { + esmtp_address_list_add( list, addr->mailbox->addr_spec, 0, NULL ); + } else if ( addr->type == MAILIMF_ADDRESS_GROUP ) { + clist *l = addr->group->mb_list->list; + for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { + mailimf_mailbox *mbox; + mbox = (mailimf_mailbox *) it2->data; + esmtp_address_list_add( list, mbox->addr_spec, 0, NULL ); + } + } + } +} + +clist *MailWrapper::createRcptList( mailimf_fields *fields ) +{ + clist *rcptList; + mailimf_field *field; + + rcptList = esmtp_address_list_new(); + + field = getField( fields, MAILIMF_FIELD_TO ); + if ( field && (field->type == MAILIMF_FIELD_TO) + && field->field.to->addr_list ) { + addRcpts( rcptList, field->field.to->addr_list ); + } + + field = getField( fields, MAILIMF_FIELD_CC ); + if ( field && (field->type == MAILIMF_FIELD_CC) + && field->field.cc->addr_list ) { + addRcpts( rcptList, field->field.cc->addr_list ); + } + + field = getField( fields, MAILIMF_FIELD_BCC ); + if ( field && (field->type == MAILIMF_FIELD_BCC) + && field->field.bcc->addr_list ) { + addRcpts( rcptList, field->field.bcc->addr_list ); + } + + return rcptList; +} + +char *MailWrapper::getFrom( mailmime *mail ) +{ + char *from = NULL; + + mailimf_field *ffrom; + ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); + if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) + && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { + clist *cl = ffrom->field.from->mb_list->list; + clistiter *it; + for ( it = clist_begin( cl ); it; it = it->next ) { + mailimf_mailbox *mb = (mailimf_mailbox *) it->data; + from = strdup( mb->addr_spec ); + } + } + + return from; +} + +SMTPaccount *MailWrapper::getAccount( QString from ) +{ + SMTPaccount *smtp; + + QList list = settings->getAccounts(); + Account *it; + for ( it = list.first(); it; it = list.next() ) { + if ( it->getType().compare( "SMTP" ) == 0 ) { + smtp = static_cast(it); + if ( smtp->getMail().compare( from ) == 0 ) { + qDebug( "SMTPaccount found for" ); + qDebug( from ); + return smtp; + } + } + } + + return NULL; +} + +QString MailWrapper::getTmpFile() { + int num = 0; + QString unique; + + QDir dir( "/tmp" ); + QStringList::Iterator it; + + QStringList list = dir.entryList( "opiemail-tmp-*" ); + do { + unique.setNum( num++ ); + } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); + + return "/tmp/opiemail-tmp-" + unique; +} + +void MailWrapper::writeToFile( QString file, mailmime *mail ) +{ + FILE *f; + int err, col = 0; + + f = fopen( file.latin1(), "w" ); + if ( f == NULL ) { + qDebug( "writeToFile: error opening file" ); + return; + } + + err = mailmime_write( f, &col, mail ); + if ( err != MAILIMF_NO_ERROR ) { + fclose( f ); + qDebug( "writeToFile: error writing mailmime" ); + return; + } + + fclose( f ); +} + +void MailWrapper::readFromFile( QString file, char **data, size_t *size ) +{ + char *buf; + struct stat st; + int fd, count = 0, total = 0; + + fd = open( file.latin1(), O_RDONLY, 0 ); + if ( fd == -1 ) return; + + if ( fstat( fd, &st ) != 0 ) goto err_close; + if ( !st.st_size ) goto err_close; + + buf = (char *) malloc( st.st_size ); + if ( !buf ) goto err_close; + + while ( ( total < st.st_size ) && ( count >= 0 ) ) { + count = read( fd, buf + total, st.st_size - total ); + total += count; + } + if ( count < 0 ) goto err_free; + + *data = buf; + *size = st.st_size; + + close( fd ); + + return; // Success :) + +err_free: + free( buf ); +err_close: + close( fd ); +} + +void progress( size_t current, size_t maximum ) +{ + qDebug( "Current: %i of %i", current, maximum ); +} + +void MailWrapper::smtpSend( mailmime *mail ) +{ + mailsmtp *session; + clist *rcpts; + char *from, *data, *server, *user = NULL, *pass = NULL; + size_t size; + int err; + bool ssl; + uint16_t port; + + + from = getFrom( mail ); + SMTPaccount *smtp = getAccount( from ); + if ( smtp == NULL ) { + free(from); + return; + } + server = strdup( smtp->getServer().latin1() ); + ssl = smtp->getSSL(); + port = smtp->getPort().toUInt(); + rcpts = createRcptList( mail->fields ); + + QString file = getTmpFile(); + writeToFile( file, mail ); + readFromFile( file, &data, &size ); + QFile f( file ); + f.remove(); + + session = mailsmtp_new( 20, &progress ); + if ( session == NULL ) goto free_mem; + + qDebug( "Servername %s at port %i", server, port ); + if ( ssl ) { + qDebug( "SSL session" ); + err = mailsmtp_ssl_connect( session, server, port ); + } else { + qDebug( "No SSL session" ); + err = mailsmtp_socket_connect( session, server, port ); + } + if ( err != MAILSMTP_NO_ERROR ) goto free_mem_session; + + err = mailsmtp_init( session ); + if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; + + qDebug( "INIT OK" ); + + if ( smtp->getLogin() ) { + if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { + // get'em + LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); + login.show(); + if ( QDialog::Accepted == login.exec() ) { + // ok + user = strdup( login.getUser().latin1() ); + pass = strdup( login.getPassword().latin1() ); + } else { + goto free_con_session; + } + } else { + user = strdup( smtp->getUser().latin1() ); + pass = strdup( smtp->getPassword().latin1() ); + } + qDebug( "session->auth: %i", session->auth); + err = mailsmtp_auth( session, user, pass ); + if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); + qDebug( "Done auth!" ); + } + + err = mailsmtp_send( session, from, rcpts, data, size ); + if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; + + qDebug( "Mail sent." ); + +free_con_session: + mailsmtp_quit( session ); +free_mem_session: + mailsmtp_free( session ); +free_mem: + smtp_address_list_free( rcpts ); + free( data ); + free( server ); + if ( smtp->getLogin() ) { + free( user ); + free( pass ); + } + free( from ); +} + +void MailWrapper::sendMail( Mail mail ) +{ + mailmime *mimeMail; + + mimeMail = createMimeMail( &mail ); + if ( mimeMail == NULL ) { + qDebug( "sendMail: error creating mime mail" ); + } else { + smtpSend( mimeMail ); + mailmime_free( mimeMail ); + } +} + +Mail::Mail() + :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") +{ +} + +RecMail::RecMail() + :subject(""),date(""),msg_number(0),msg_flags(7) +{ +} + +#if 0 +void RecMail::setDate(const QString&aDate) +{ + mDate = QDateTime::fromString(aDate); +} +#endif diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h new file mode 100644 index 0000000..3de28a0 --- a/dev/null +++ b/noncore/net/mail/mailwrapper.h @@ -0,0 +1,183 @@ +#ifndef MAILWRAPPER_H +#define MAILWRAPPER_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "settings.h" + +class Attachment +{ +public: + Attachment( DocLnk lnk ); + virtual ~Attachment(){} + const QString getFileName()const{ return doc.file(); } + const QString getName()const{ return doc.name(); } + const QString getMimeType()const{ return doc.type(); } + const QPixmap getPixmap()const{ return doc.pixmap(); } + const int getSize()const { return size; } + DocLnk getDocLnk() { return doc; } + +protected: + DocLnk doc; + int size; + +}; + +#define FLAG_ANSWERED 0 +#define FLAG_FLAGGED 1 +#define FLAG_DELETED 2 +#define FLAG_SEEN 3 +#define FLAG_DRAFT 4 +#define FLAG_RECENT 5 + +/* a class to describe mails in a mailbox */ +class RecMail +{ +public: + RecMail(); + virtual ~RecMail(){} + + const int getNumber()const{return msg_number;} + void setNumber(int number){msg_number=number;} + const QString&getDate()const{ return date; } + void setDate( const QString&a ) { date = a; } + const QString&getFrom()const{ return from; } + void setFrom( const QString&a ) { from = a; } + const QString&getSubject()const { return subject; } + void setSubject( const QString&s ) { subject = s; } + void setFlags(const QBitArray&flags){msg_flags = flags;} + const QBitArray&getFlags()const{return msg_flags;} + +#if 0 + void setDate(const QString&dstring); + void setDate(const QDateTime&date){mDate = date;} + QString getDate()const{return mDate.toString();} +#endif +protected: + QString subject,date,from; + int msg_number; + QBitArray msg_flags; +#if 0 + QDateTime mDate; +#endif +}; + +typedef QList Maillist; + +class Mail +{ +public: + Mail(); + /* Possible that this destructor must not be declared virtual + * 'cause it seems that it will never have some child classes. + * in this case this object will not get a virtual table -> memory and + * speed will be a little bit better? + */ + virtual ~Mail(){} + void addAttachment( Attachment *att ) { attList.append( att ); } + const QList& getAttachments()const { return attList; } + void removeAttachment( Attachment *att ) { attList.remove( att ); } + const QString&getName()const { return name; } + void setName( QString s ) { name = s; } + const QString&getMail()const{ return mail; } + void setMail( const QString&s ) { mail = s; } + const QString&getTo()const{ return to; } + void setTo( const QString&s ) { to = s; } + const QString&getCC()const{ return cc; } + void setCC( const QString&s ) { cc = s; } + const QString&getBCC()const { return bcc; } + void setBCC( const QString&s ) { bcc = s; } + const QString&getMessage()const { return message; } + void setMessage( const QString&s ) { message = s; } + const QString&getSubject()const { return subject; } + void setSubject( const QString&s ) { subject = s; } + const QString&getReply()const{ return reply; } + void setReply( const QString&a ) { reply = a; } + +private: + QList attList; + QString name, mail, to, cc, bcc, reply, subject, message; +}; + +class Folder : public QObject +{ + Q_OBJECT + +public: + Folder( const QString&init_name ); + const QString&getDisplayName()const { return nameDisplay; } + const QString&getName()const { return name; } + virtual bool may_select()const{return true;}; + +private: + QString nameDisplay, name; + +}; + +class IMAPFolder : public Folder +{ + public: + IMAPFolder( QString name,bool select=true ) : Folder( name ),m_MaySelect(select) {} + virtual bool may_select()const{return m_MaySelect;} + private: + bool m_MaySelect; +}; + +class MailWrapper : public QObject +{ + Q_OBJECT + +public: + MailWrapper( Settings *s ); + void sendMail( Mail mail ); + +private: + mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); + mailimf_address_list *parseAddresses(const QString&addr ); + mailimf_fields *createImfFields( Mail *mail ); + mailmime *buildTxtPart( QString str ); + mailmime *buildFilePart( QString filename, QString mimetype ); + void addFileParts( mailmime *message, QList files ); + mailmime *createMimeMail( Mail *mail ); + void smtpSend( mailmime *mail ); + mailimf_field *getField( mailimf_fields *fields, int type ); + clist *createRcptList( mailimf_fields *fields ); + char *getFrom( mailmime *mail ); + SMTPaccount *getAccount( QString from ); + void writeToFile( QString file, mailmime *mail ); + void readFromFile( QString file, char **data, size_t *size ); + static QString mailsmtpError( int err ); + static QString getTmpFile(); + + Settings *settings; + +}; + +class IMAPwrapper : public QObject +{ + Q_OBJECT + +public: + IMAPwrapper( IMAPaccount *a ); + QList* listFolders(); + void listMessages(const QString & mailbox,Maillist&target ); + QString fetchBody(const QString & mailbox,const RecMail&mail); + +protected: + RecMail*parse_list_result(mailimap_msg_att*); + +private: + IMAPaccount *account; + +}; + +#endif diff --git a/noncore/net/mail/main.cpp b/noncore/net/mail/main.cpp new file mode 100644 index 0000000..f97bea1 --- a/dev/null +++ b/noncore/net/mail/main.cpp @@ -0,0 +1,6 @@ +#include +#include + +#include "opiemail.h" + +OPIE_EXPORT_APP( OApplicationFactory ) diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp new file mode 100644 index 0000000..0a433a0 --- a/dev/null +++ b/noncore/net/mail/mainwindow.cpp @@ -0,0 +1,151 @@ +#include +#include +#include +#include + +#include + +#include "defines.h" +#include "readmailgui.h" +#include "mainwindow.h" + +MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) + : QMainWindow( parent, name, flags ) +{ + setCaption( tr( "Opie-Mail" ) ); + setToolBarsMovable( false ); + + toolBar = new QToolBar( this ); + menuBar = new QMenuBar( toolBar ); + mailMenu = new QPopupMenu( menuBar ); + menuBar->insertItem( tr( "Mail" ), mailMenu ); + settingsMenu = new QPopupMenu( menuBar ); + menuBar->insertItem( tr( "Settings" ), settingsMenu ); + + addToolBar( toolBar ); + toolBar->setHorizontalStretchable( true ); + + QLabel *spacer = new QLabel( toolBar ); + spacer->setBackgroundMode( QWidget::PaletteButton ); + toolBar->setStretchableWidget( spacer ); + + composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, + 0, 0, this ); + composeMail->addTo( toolBar ); + composeMail->addTo( mailMenu ); + + sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, + 0, 0, this ); + sendQueued->addTo( toolBar ); + sendQueued->addTo( mailMenu ); + + syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, + 0, 0, this ); + syncFolders->addTo( toolBar ); + syncFolders->addTo( mailMenu ); + + showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, + 0, 0, this, 0, true ); + showFolders->addTo( toolBar ); + showFolders->addTo( mailMenu ); + connect(showFolders, SIGNAL( toggled( bool ) ), + SLOT( slotShowFolders( bool ) ) ); + + searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, + 0, 0, this ); + searchMails->addTo( toolBar ); + searchMails->addTo( mailMenu ); + + + editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, + 0, 0, this ); + editSettings->addTo( settingsMenu ); + + editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, + 0, 0, this ); + editAccounts->addTo( settingsMenu ); + + QVBox *view = new QVBox( this ); + setCentralWidget( view ); + + folderView = new AccountView( view ); + folderView->header()->hide(); + folderView->setMinimumHeight( 90 ); + folderView->setMaximumHeight( 90 ); + folderView->addColumn( tr( "Mailbox" ) ); + folderView->hide(); + + mailView = new QListView( view ); + mailView->setMinimumHeight( 50 ); + mailView->addColumn( tr( "Subject" ),QListView::Manual ); + mailView->addColumn( tr( "Sender" ),QListView::Manual ); + mailView->addColumn( tr( "Date" )); + mailView->setAllColumnsShowFocus(true); + mailView->setSorting(-1); + connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, + SLOT( displayMail( QListViewItem * ) ) ); + + connect(folderView,SIGNAL(refreshMailview(Maillist*)),this,SLOT(refreshMailView(Maillist*))); + + QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); +} + +void MainWindow::slotAdjustColumns() +{ + bool hidden = folderView->isHidden(); + if ( hidden ) folderView->show(); + folderView->setColumnWidth( 0, folderView->visibleWidth() ); + if ( hidden ) folderView->hide(); + + mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); + mailView->setColumnWidth( 1, 80 ); + mailView->setColumnWidth( 2, 50 ); +} + +void MainWindow::slotShowFolders( bool show ) +{ + qDebug( "Show Folders" ); + if ( show && folderView->isHidden() ) { + qDebug( "-> showing" ); + folderView->show(); + } else if ( !show && !folderView->isHidden() ) { + qDebug( "-> hiding" ); + folderView->hide(); + } +} + +void MainWindow::refreshMailView(Maillist*list) +{ + MailListViewItem*item = 0; + mailView->clear(); +#if 0 + QFont f = mailView->getFont(); + QFont bf = f; +#endif + for (unsigned int i = 0; i < list->count();++i) { + item = new MailListViewItem(mailView,item); + item->storeData(*(list->at(i))); + item->showEntry(); +#if 0 + if (!list->at(i)->getFlags().testBit(FLAG_SEEN)) { + item->setFont(bf); + } +#endif + } +} +void MainWindow::displayMail(QListViewItem*item) +{ + if (!item) return; + qDebug("View mail"); + RecMail mail = ((MailListViewItem*)item)->data(); + QString body = folderView->fetchBody(mail); + + qDebug(body); +} + +void MailListViewItem::showEntry() +{ + setText(0,mail_data.getSubject()); + setText(1,mail_data.getFrom()); + setText(2,mail_data.getDate()); +} diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h new file mode 100644 index 0000000..a5142ab --- a/dev/null +++ b/noncore/net/mail/mainwindow.h @@ -0,0 +1,54 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include + +#include +#include + +#include "accountview.h" + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); + +public slots: + void slotAdjustColumns(); + +protected slots: + virtual void slotShowFolders( bool show ); + virtual void refreshMailView(Maillist*); + virtual void displayMail(QListViewItem*); + +protected: + QToolBar *toolBar; + QMenuBar *menuBar; + QPopupMenu *mailMenu, *settingsMenu; + QAction *composeMail, *sendQueued, *showFolders, *searchMails, + *editSettings, *editAccounts, *syncFolders; + AccountView *folderView; + QListView *mailView; + +}; + +class MailListViewItem:public QListViewItem +{ +public: + MailListViewItem(QListView * parent, MailListViewItem * after ) + :QListViewItem(parent,after),mail_data(){} + virtual ~MailListViewItem(){} + + void storeData(const RecMail&data){mail_data = data;} + const RecMail&data()const{return mail_data;} + void showEntry(); + +protected: + RecMail mail_data; +}; + +#endif diff --git a/noncore/net/mail/nntpconfigui.ui b/noncore/net/mail/nntpconfigui.ui new file mode 100644 index 0000000..cc439f4 --- a/dev/null +++ b/noncore/net/mail/nntpconfigui.ui @@ -0,0 +1,257 @@ + +NNTPconfigUI + + QDialog + + name + NNTPconfigUI + + + geometry + + 0 + 0 + 228 + 320 + + + + caption + Configure NNTP + + + layoutMargin + + + layoutSpacing + + + + margin + 4 + + + spacing + 3 + + + QLineEdit + + name + serverLine + + + + QLabel + + name + portLabel + + + text + Port + + + + QLineEdit + + name + portLine + + + + QLineEdit + + name + accountLine + + + toolTip + Name of the Account + + + + QLabel + + name + accountLabel + + + text + Account + + + + QLabel + + name + serverLabel + + + enabled + true + + + caption + + + + text + Server + + + layoutMargin + + + layoutSpacing + + + + Line + + name + line1 + + + caption + + + + orientation + Horizontal + + + layoutMargin + + + layoutSpacing + + + + QCheckBox + + name + sslBox + + + text + Use SSL + + + + Line + + name + line2 + + + enabled + true + + + caption + + + + orientation + Horizontal + + + layoutMargin + + + layoutSpacing + + + + QLabel + + name + userLabel + + + text + User + + + + QLabel + + name + passLabel + + + text + Password + + + + + name + spacer + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QCheckBox + + name + loginBox + + + text + Use Login + + + + QLineEdit + + name + userLine + + + enabled + false + + + + QLineEdit + + name + passLine + + + enabled + false + + + echoMode + Password + + + + + + accountLine + serverLine + portLine + sslBox + loginBox + userLine + passLine + + diff --git a/noncore/net/mail/opie-mail.control b/noncore/net/mail/opie-mail.control new file mode 100644 index 0000000..a93067f --- a/dev/null +++ b/noncore/net/mail/opie-mail.control @@ -0,0 +1,10 @@ +Package: opie-mail +Files: bin/opiemail apps/1Pim/opiemail.desktop pics/mail/*.png +Priority: optional +Section: opie/applications +Maintainer: Juergen Graf +Architecture: arm +Version: 0.0.1-$SUB_VERSION +Depends: task-opie-minimal, libopie1 +Description: Opie's mail and news client (POP3, IMAP and NNTP) +License: LGPL diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp new file mode 100644 index 0000000..93f3bb7 --- a/dev/null +++ b/noncore/net/mail/opiemail.cpp @@ -0,0 +1,50 @@ +#include "opiemail.h" +#include "editaccounts.h" +#include "composemail.h" + +OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) + : MainWindow( parent, name, flags ) +{ + settings = new Settings(); + + folderView->populate( settings->getAccounts() ); + + connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); + connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); + connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); + connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) ); + connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); +} + +void OpieMail::slotComposeMail() +{ + qDebug( "Compose Mail" ); + ComposeMail compose( settings, this, 0 , true ); + compose.showMaximized(); + compose.slotAdjustColumns(); + compose.exec(); +} + +void OpieMail::slotSendQueued() +{ + qDebug( "Send Queued" ); +} + +void OpieMail::slotSearchMails() +{ + qDebug( "Search Mails" ); +} + +void OpieMail::slotEditSettings() +{ + qDebug( "Edit Settings" ); +} + +void OpieMail::slotEditAccounts() +{ + qDebug( "Edit Accounts" ); + EditAccounts eaDialog( settings, this, 0, true ); + eaDialog.showMaximized(); + eaDialog.slotAdjustColumns(); + eaDialog.exec(); +} diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h new file mode 100644 index 0000000..dcab47c --- a/dev/null +++ b/noncore/net/mail/opiemail.h @@ -0,0 +1,28 @@ +#ifndef OPIEMAIL_H +#define OPIEMAIL_H + +#include "mainwindow.h" +#include "settings.h" + +class OpieMail : public MainWindow +{ + Q_OBJECT + +public: + OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); + + static QString appName() { return QString::fromLatin1("opiemail"); } + +protected slots: + void slotComposeMail(); + void slotSendQueued(); + void slotSearchMails(); + void slotEditSettings(); + void slotEditAccounts(); + +private: + Settings *settings; + +}; + +#endif diff --git a/noncore/net/mail/pop3configui.ui b/noncore/net/mail/pop3configui.ui new file mode 100644 index 0000000..8fdb4ba --- a/dev/null +++ b/noncore/net/mail/pop3configui.ui @@ -0,0 +1,199 @@ + +POP3configUI + + QDialog + + name + POP3configUI + + + geometry + + 0 + 0 + 236 + 320 + + + + caption + Configure POP3 + + + layoutMargin + + + layoutSpacing + + + + margin + 4 + + + spacing + 3 + + + QLineEdit + + name + userLine + + + + QLabel + + name + passLabel + + + text + Password + + + + QLineEdit + + name + passLine + + + echoMode + Password + + + + QLineEdit + + name + portLine + + + + QLineEdit + + name + serverLine + + + + QLabel + + name + serverLabel + + + text + Server + + + + QCheckBox + + name + sslBox + + + text + Use SSL + + + + QLabel + + name + portLabel + + + text + Port + + + + QLabel + + name + userLabel + + + text + User + + + + + name + spacer + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + Line + + name + line2 + + + orientation + Horizontal + + + + QLabel + + name + accountLabel + + + text + Account + + + + QLineEdit + + name + accountLine + + + toolTip + Name of the Account + + + + Line + + name + line1 + + + orientation + Horizontal + + + + + + accountLine + serverLine + portLine + sslBox + userLine + passLine + + diff --git a/noncore/net/mail/readmailgui.cpp b/noncore/net/mail/readmailgui.cpp new file mode 100644 index 0000000..0063070 --- a/dev/null +++ b/noncore/net/mail/readmailgui.cpp @@ -0,0 +1,29 @@ +#include "readmailgui.h" +#include "defines.h" +#include + +ReadMailGui::ReadMailGui( QWidget* parent, const char* name, bool modal, WFlags fl ) +: QDialog( parent, name, modal, fl ) { + + +QVBoxLayout * layout = new QVBoxLayout( this ); +QMainWindow * m_mainWindow = new QMainWindow( this ); +m_toolBar = new QToolBar( m_mainWindow ); +m_mainWindow->addToolBar( m_toolBar ); + +m_reply = new QAction( tr( "Compose new mail" ), ICON_SENDQUEUED, 0, 0, m_mainWindow ); +m_reply->addTo( m_toolBar ); + +m_textWindow = new QTextBrowser( this ); +m_textWindow->setResizePolicy( QScrollView::AutoOneFit ); + +layout->addWidget( m_mainWindow ); +layout->addWidget( m_textWindow ); +} + +ReadMailGui::~ReadMailGui() { +} + +void ReadMailGui::passMessage( const QString & message ) { + m_textWindow->setText( message ); +} diff --git a/noncore/net/mail/readmailgui.h b/noncore/net/mail/readmailgui.h new file mode 100644 index 0000000..dac1937 --- a/dev/null +++ b/noncore/net/mail/readmailgui.h @@ -0,0 +1,33 @@ +#ifndef READMAILGUI_H +#define READMAILGUI_H + +#include +#include +#include +#include +#include +#include +#include + + +class ReadMailGui : public QDialog +{ + Q_OBJECT + +public: + ReadMailGui( QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0 ); + ~ReadMailGui(); + + void passMessage( const QString & message ); + +private: + + QMainWindow * m_mainWindow; + QToolBar * m_toolBar; + QMenuBar * m_menuBar; + QTextBrowser * m_textWindow; + QAction * m_reply; + +}; + +#endif diff --git a/noncore/net/mail/selectmailtypeui.ui b/noncore/net/mail/selectmailtypeui.ui new file mode 100644 index 0000000..1fe0369 --- a/dev/null +++ b/noncore/net/mail/selectmailtypeui.ui @@ -0,0 +1,94 @@ + +SelectMailTypeUI + + QDialog + + name + SelectMailTypeUI + + + geometry + + 0 + 0 + 157 + 66 + + + + caption + Select Type + + + layoutMargin + + + layoutSpacing + + + + margin + 4 + + + spacing + 3 + + + QGroupBox + + name + groupBox + + + title + Select Account Type + + + layoutMargin + + + layoutSpacing + + + + margin + 4 + + + spacing + 3 + + + QComboBox + + + text + IMAP + + + + + text + POP3 + + + + + text + SMTP + + + + name + typeBox + + + + + + + + typeBox + + diff --git a/noncore/net/mail/settings.cpp b/noncore/net/mail/settings.cpp new file mode 100644 index 0000000..9632301 --- a/dev/null +++ b/noncore/net/mail/settings.cpp @@ -0,0 +1,432 @@ +#include +#include + +#include + +#include "settings.h" +#include "defines.h" + +Settings::Settings() + : QObject() +{ + updateAccounts(); +} + +void Settings::checkDirectory() +{ + if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { + system( "mkdir -p $HOME/Applications/opiemail" ); + qDebug( "$HOME/Applications/opiemail created" ); + } +} + +QList Settings::getAccounts() +{ + return accounts; +} + +void Settings::addAccount( Account *account ) +{ + accounts.append( account ); +} + +void Settings::delAccount( Account *account ) +{ + accounts.remove( account ); + account->remove(); +} + +void Settings::updateAccounts() +{ + accounts.clear(); + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "imap-*" ); + for ( it = imap.begin(); it != imap.end(); it++ ) { + qDebug( "Added IMAP account" ); + IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); + accounts.append( account ); + } + + QStringList pop3 = dir.entryList( "pop3-*" ); + for ( it = pop3.begin(); it != pop3.end(); it++ ) { + qDebug( "Added POP account" ); + POP3account *account = new POP3account( (*it).replace(0, 5, "") ); + accounts.append( account ); + } + + QStringList smtp = dir.entryList( "smtp-*" ); + for ( it = smtp.begin(); it != smtp.end(); it++ ) { + qDebug( "Added SMTP account" ); + SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); + accounts.append( account ); + } + + QStringList nntp = dir.entryList( "nntp-*" ); + for ( it = nntp.begin(); it != nntp.end(); it++ ) { + qDebug( "Added NNTP account" ); + NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); + accounts.append( account ); + } + + readAccounts(); +} + +void Settings::saveAccounts() +{ + checkDirectory(); + Account *it; + + for ( it = accounts.first(); it; it = accounts.next() ) { + it->save(); + } +} + +void Settings::readAccounts() +{ + checkDirectory(); + Account *it; + + for ( it = accounts.first(); it; it = accounts.next() ) { + it->read(); + } +} + +Account::Account() +{ + accountName = "changeMe"; + type = "changeMe"; + ssl = false; +} + +void Account::remove() +{ + QFile file( getFileName() ); + file.remove(); +} + +IMAPaccount::IMAPaccount() + : Account() +{ + file = IMAPaccount::getUniqueFileName(); + accountName = "New IMAP Account"; + ssl = false; + type = "IMAP"; + port = IMAP_PORT; +} + +IMAPaccount::IMAPaccount( QString filename ) + : Account() +{ + file = filename; + accountName = "New IMAP Account"; + ssl = false; + type = "IMAP"; + port = IMAP_PORT; +} + +QString IMAPaccount::getUniqueFileName() +{ + int num = 0; + QString unique; + + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "imap-*" ); + do { + unique.setNum( num++ ); + } while ( imap.contains( "imap-" + unique ) > 0 ); + + return unique; +} + +void IMAPaccount::read() +{ + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "IMAP Account" ); + accountName = conf->readEntry( "Account","" ); + if (accountName.isNull()) accountName = ""; + server = conf->readEntry( "Server","" ); + if (server.isNull()) server=""; + port = conf->readEntry( "Port","" ); + if (port.isNull()) port="143"; + ssl = conf->readBoolEntry( "SSL",false ); + user = conf->readEntry( "User","" ); + if (user.isNull()) user = ""; + password = conf->readEntryCrypt( "Password","" ); + if (password.isNull()) password = ""; + prefix = conf->readEntry("MailPrefix",""); + if (prefix.isNull()) prefix = ""; +} + +void IMAPaccount::save() +{ + qDebug( "saving " + getFileName() ); + Settings::checkDirectory(); + + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "IMAP Account" ); + conf->writeEntry( "Account", accountName ); + conf->writeEntry( "Server", server ); + conf->writeEntry( "Port", port ); + conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "User", user ); + conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "MailPrefix",prefix); + conf->write(); +} + + +QString IMAPaccount::getFileName() +{ + return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; +} + +POP3account::POP3account() + : Account() +{ + file = POP3account::getUniqueFileName(); + accountName = "New POP3 Account"; + ssl = false; + type = "POP3"; + port = POP3_PORT; +} + +POP3account::POP3account( QString filename ) + : Account() +{ + file = filename; + accountName = "New POP3 Account"; + ssl = false; + type = "POP3"; + port = POP3_PORT; +} + +QString POP3account::getUniqueFileName() +{ + int num = 0; + QString unique; + + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "pop3-*" ); + do { + unique.setNum( num++ ); + } while ( imap.contains( "pop3-" + unique ) > 0 ); + + return unique; +} + +void POP3account::read() +{ + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "POP3 Account" ); + accountName = conf->readEntry( "Account" ); + server = conf->readEntry( "Server" ); + port = conf->readEntry( "Port" ); + ssl = conf->readBoolEntry( "SSL" ); + user = conf->readEntry( "User" ); + password = conf->readEntryCrypt( "Password" ); +} + +void POP3account::save() +{ + qDebug( "saving " + getFileName() ); + Settings::checkDirectory(); + + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "POP3 Account" ); + conf->writeEntry( "Account", accountName ); + conf->writeEntry( "Server", server ); + conf->writeEntry( "Port", port ); + conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "User", user ); + conf->writeEntryCrypt( "Password", password ); + conf->write(); +} + + +QString POP3account::getFileName() +{ + return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; +} + +SMTPaccount::SMTPaccount() + : Account() +{ + file = SMTPaccount::getUniqueFileName(); + accountName = "New SMTP Account"; + ssl = false; + login = false; + useCC = false; + useBCC = false; + useReply = false; + type = "SMTP"; + port = SMTP_PORT; +} + +SMTPaccount::SMTPaccount( QString filename ) + : Account() +{ + file = filename; + accountName = "New SMTP Account"; + ssl = false; + login = false; + useCC = false; + useBCC = false; + useReply = false; + type = "SMTP"; + port = SMTP_PORT; +} + +QString SMTPaccount::getUniqueFileName() +{ + int num = 0; + QString unique; + + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "smtp-*" ); + do { + unique.setNum( num++ ); + } while ( imap.contains( "smtp-" + unique ) > 0 ); + + return unique; +} + +void SMTPaccount::read() +{ + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "SMTP Account" ); + accountName = conf->readEntry( "Account" ); + server = conf->readEntry( "Server" ); + port = conf->readEntry( "Port" ); + ssl = conf->readBoolEntry( "SSL" ); + login = conf->readBoolEntry( "Login" ); + user = conf->readEntry( "User" ); + password = conf->readEntryCrypt( "Password" ); + useCC = conf->readBoolEntry( "useCC" ); + useBCC = conf->readBoolEntry( "useBCC" ); + useReply = conf->readBoolEntry( "useReply" ); + name = conf->readEntry( "Name" ); + mail = conf->readEntry( "Mail" ); + org = conf->readEntry( "Org" ); + cc = conf->readEntry( "CC" ); + bcc = conf->readEntry( "BCC" ); + reply = conf->readEntry( "Reply" ); + signature = conf->readEntry( "Signature" ); + signature = signature.replace( QRegExp( "
" ), "\n" ); +} + +void SMTPaccount::save() +{ + qDebug( "saving " + getFileName() ); + Settings::checkDirectory(); + + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "SMTP Account" ); + conf->writeEntry( "Account", accountName ); + conf->writeEntry( "Server", server ); + conf->writeEntry( "Port", port ); + conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "Login", login ); + conf->writeEntry( "User", user ); + conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "useCC", useCC ); + conf->writeEntry( "useBCC", useBCC ); + conf->writeEntry( "useReply", useReply ); + conf->writeEntry( "Name", name ); + conf->writeEntry( "Mail", mail ); + conf->writeEntry( "Org", org ); + conf->writeEntry( "CC", cc ); + conf->writeEntry( "BCC", bcc ); + conf->writeEntry( "Reply", reply ); + conf->writeEntry( "Signature", + signature.replace( QRegExp( "\\n" ), "
" ) ); + conf->write(); +} + + +QString SMTPaccount::getFileName() +{ + return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; +} + +NNTPaccount::NNTPaccount() + : Account() +{ + file = NNTPaccount::getUniqueFileName(); + accountName = "New NNTP Account"; + ssl = false; + login = false; + type = "NNTP"; + port = NNTP_PORT; +} + +NNTPaccount::NNTPaccount( QString filename ) + : Account() +{ + file = filename; + accountName = "New NNTP Account"; + ssl = false; + login = false; + type = "NNTP"; + port = NNTP_PORT; +} + +QString NNTPaccount::getUniqueFileName() +{ + int num = 0; + QString unique; + + QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); + QStringList::Iterator it; + + QStringList imap = dir.entryList( "nntp-*" ); + do { + unique.setNum( num++ ); + } while ( imap.contains( "nntp-" + unique ) > 0 ); + + return unique; +} + +void NNTPaccount::read() +{ + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "NNTP Account" ); + accountName = conf->readEntry( "Account" ); + server = conf->readEntry( "Server" ); + port = conf->readEntry( "Port" ); + ssl = conf->readBoolEntry( "SSL" ); + login = conf->readBoolEntry( "Login" ); + user = conf->readEntry( "User" ); + password = conf->readEntryCrypt( "Password" ); +} + +void NNTPaccount::save() +{ + qDebug( "saving " + getFileName() ); + Settings::checkDirectory(); + + Config *conf = new Config( getFileName(), Config::File ); + conf->setGroup( "NNTP Account" ); + conf->writeEntry( "Account", accountName ); + conf->writeEntry( "Server", server ); + conf->writeEntry( "Port", port ); + conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "Login", login ); + conf->writeEntry( "User", user ); + conf->writeEntryCrypt( "Password", password ); + conf->write(); +} + + +QString NNTPaccount::getFileName() +{ + return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; +} + diff --git a/noncore/net/mail/settings.h b/noncore/net/mail/settings.h new file mode 100644 index 0000000..22184a5 --- a/dev/null +++ b/noncore/net/mail/settings.h @@ -0,0 +1,166 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include +#include + +class Account +{ + +public: + Account(); + virtual ~Account() {} + + void remove(); + void setAccountName( QString name ) { accountName = name; } + const QString&getAccountName()const{ return accountName; } + const QString&getType()const{ return type; } + + void setServer(const QString&str){ server = str; } + const QString&getServer()const{ return server; } + + void setPort(const QString&str) { port = str; } + const QString&getPort()const{ return port; } + + void setUser(const QString&str){ user = str; } + const QString&getUser()const{ return user; } + + void setPassword(const QString&str) { password = str; } + const QString&getPassword()const { return password; } + + void setSSL( bool b ) { ssl = b; } + bool getSSL() { return ssl; } + + virtual QString getFileName() { return accountName; } + virtual void read() { qDebug( "base reading..." ); } + virtual void save() { qDebug( "base saving..." ); } + +protected: + QString accountName, type, server, port, user, password; + bool ssl; + +}; + +class IMAPaccount : public Account +{ + +public: + IMAPaccount(); + IMAPaccount( QString filename ); + + static QString getUniqueFileName(); + + virtual void read(); + virtual void save(); + virtual QString getFileName(); + + void setPrefix(const QString&str) {prefix=str;} + const QString&getPrefix()const{return prefix;} + +private: + QString file,prefix; + +}; + +class POP3account : public Account +{ + +public: + POP3account(); + POP3account( QString filename ); + + static QString getUniqueFileName(); + + virtual void read(); + virtual void save(); + virtual QString getFileName(); + +private: + QString file; + +}; + +class SMTPaccount : public Account +{ + +public: + SMTPaccount(); + SMTPaccount( QString filename ); + + static QString getUniqueFileName(); + + virtual void read(); + virtual void save(); + virtual QString getFileName(); + + void setName( QString str ) { name = str; } + QString getName() { return name; } + void setMail( QString str ) { mail = str; } + QString getMail() { return mail; } + void setOrg( QString str ) { org = str; } + QString getOrg() { return org; } + void setUseCC( bool b ) { useCC = b; } + bool getUseCC() { return useCC; } + void setCC( QString str ) { cc = str; } + QString getCC() { return cc; } + void setUseBCC( bool b ) { useBCC = b; } + bool getUseBCC() { return useBCC; } + void setBCC( QString str ) { bcc = str; } + QString getBCC() { return bcc; } + void setUseReply( bool b ) { useReply = b; } + bool getUseReply() { return useReply; } + void setReply( QString str ) { reply = str; } + QString getReply() { return reply; } + void setSignature( QString str ) { signature = str; } + QString getSignature() { return signature; } + void setLogin( bool b ) { login = b; } + bool getLogin() { return login; } + +private: + QString file, name, mail, org, cc, bcc, reply, signature; + bool useCC, useBCC, useReply, login; + +}; + +class NNTPaccount : public Account +{ + +public: + NNTPaccount(); + NNTPaccount( QString filename ); + + static QString getUniqueFileName(); + + virtual void read(); + virtual void save(); + virtual QString getFileName(); + + void setLogin( bool b ) { login = b; } + bool getLogin() { return login; } + +private: + QString file; + bool login; + +}; + +class Settings : public QObject +{ + Q_OBJECT + +public: + Settings(); + QList getAccounts(); + void addAccount(Account *account); + void delAccount(Account *account); + void saveAccounts(); + void readAccounts(); + static void checkDirectory(); + +private: + void updateAccounts(); + QList accounts; + +}; + +#endif diff --git a/noncore/net/mail/smtpconfigui.ui b/noncore/net/mail/smtpconfigui.ui new file mode 100644 index 0000000..2cae8d6 --- a/dev/null +++ b/noncore/net/mail/smtpconfigui.ui @@ -0,0 +1,500 @@ + +SMTPconfigUI + + QDialog + + name + SMTPconfigUI + + + geometry + + 0 + 0 + 253 + 342 + + + + caption + Configure SMTP + + + layoutMargin + + + layoutSpacing + + + + margin + 0 + + + spacing + 0 + + + QTabWidget + + name + smtpTab + + + caption + + + + layoutMargin + + + layoutSpacing + + + QWidget + + name + serverTab + + + title + Server + + + + margin + 4 + + + spacing + 3 + + + QLabel + + name + portLabel + + + text + Port + + + + QLineEdit + + name + serverLine + + + toolTip + Name of the SMTP Server + + + + QLabel + + name + serverLabel + + + text + Server + + + + QLineEdit + + name + portLine + + + toolTip + Port of the SMTP Server + + + + QLabel + + name + accountLabel + + + text + Account + + + + QLineEdit + + name + accountLine + + + toolTip + Name of the Account + + + + Line + + name + line1 + + + orientation + Horizontal + + + + QCheckBox + + name + sslBox + + + text + Use SSL + + + + Line + + name + line2 + + + orientation + Horizontal + + + + QLineEdit + + name + passLine + + + enabled + false + + + echoMode + Password + + + + QCheckBox + + name + loginBox + + + text + Use Login + + + + QLabel + + name + passLabel + + + text + Password + + + + QLabel + + name + userLabel + + + text + User + + + + QLineEdit + + name + userLine + + + enabled + false + + + + + name + spacer + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QWidget + + name + identityTab + + + title + Identity + + + + margin + 4 + + + spacing + 3 + + + QMultiLineEdit + + name + sigMultiLine + + + + + name + Spacer3 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + toolTip + Name of the Account + + + + QLabel + + name + sigLabel + + + text + Signature + + + + QLineEdit + + name + replyLine + + + enabled + false + + + + QLineEdit + + name + bccLine + + + enabled + false + + + + QLineEdit + + name + ccLine + + + enabled + false + + + + QCheckBox + + name + bccBox + + + text + BCC + + + + QCheckBox + + name + replyBox + + + text + Reply-To + + + + QCheckBox + + name + ccBox + + + text + CC + + + + QLabel + + name + mailLabel + + + text + E-Mail + + + + QLineEdit + + name + nameLine + + + toolTip + Your Full Name + + + + QLabel + + name + nameLabel + + + text + Name + + + + QLabel + + name + orgLabel + + + text + Org. + + + layoutMargin + + + layoutSpacing + + + + QLineEdit + + name + orgLine + + + toolTip + Your Organisation + + + + QLineEdit + + name + mailLine + + + toolTip + Your E-Mail Adress + + + + Line + + name + line3 + + + orientation + Horizontal + + + + Line + + name + line4 + + + orientation + Horizontal + + + + + + + + + accountLine + serverLine + portLine + sslBox + loginBox + userLine + passLine + smtpTab + nameLine + mailLine + orgLine + ccBox + ccLine + bccBox + bccLine + replyBox + replyLine + sigMultiLine + + -- cgit v0.9.0.2