summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-12-08 22:52:28 (UTC)
committer harlekin <harlekin>2003-12-08 22:52:28 (UTC)
commit92d67d6f0e34cdee111c94d2b0304768dfdea2f9 (patch) (side-by-side diff)
treeee5f7f94cf6a898402285cc29fa31ce6e75d6d38
parent115bb2c722dc03c0491e2f1c49495a1ceb760000 (diff)
downloadopie-92d67d6f0e34cdee111c94d2b0304768dfdea2f9.zip
opie-92d67d6f0e34cdee111c94d2b0304768dfdea2f9.tar.gz
opie-92d67d6f0e34cdee111c94d2b0304768dfdea2f9.tar.bz2
less includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/composemail.cpp7
-rw-r--r--noncore/net/mail/editaccounts.cpp1
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp2
-rw-r--r--noncore/net/mail/mailwrapper.cpp2
-rw-r--r--noncore/net/mail/main.cpp1
-rw-r--r--noncore/net/mail/mainwindow.cpp1
6 files changed, 0 insertions, 14 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index a17ccb3..88dd780 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -1,180 +1,173 @@
#include <qt.h>
-#include <qcombobox.h>
-#include <qmessagebox.h>
-#include <qlistview.h>
-#include <qtabwidget.h>
-#include <qmultilineedit.h>
-#include <qregexp.h>
#include <opie/ofiledialog.h>
#include <qpe/resource.h>
#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<Account> accounts = settings->getAccounts();
Account *it;
for ( it = accounts.first(); it; it = accounts.next() ) {
if ( it->getType().compare( "SMTP" ) == 0 ) {
SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
fromBox->insertItem( smtp->getMail() );
smtpAccounts.append( smtp );
}
}
if ( smtpAccounts.count() > 0 ) {
fillValues( fromBox->currentItem() );
} else {
QMessageBox::information( this, tr( "Problem" ),
tr( "<p>Please create an SMTP account first.</p>" ),
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( "<p>Please select a File.</p>" ),
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/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index 7e2dd24..1c80adb 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -1,194 +1,193 @@
#include <qt.h>
-#include <qtabwidget.h>
#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<Account> 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<IMAPaccount *>(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<POP3account *>(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<SMTPaccount *>(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<NNTPaccount *>(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( "<p>Do you really want to delete the selected Account?</p>" ),
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( "<p>Please select an account.</p>" ),
tr( "Ok" ) );
return;
}
Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
slotEditAccount( a );
}
void EditAccounts::slotDeleteMail()
{
if ( !mailList->currentItem() ) {
QMessageBox::information( this, tr( "Error" ),
tr( "<p>Please select an account.</p>" ),
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" );
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index 13a3fd9..ea9e7b2 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -1,201 +1,199 @@
-#include <qfileinfo.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <qdir.h>
-#include <qtextstream.h>
#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;
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp
index 13a3fd9..ea9e7b2 100644
--- a/noncore/net/mail/mailwrapper.cpp
+++ b/noncore/net/mail/mailwrapper.cpp
@@ -1,201 +1,199 @@
-#include <qfileinfo.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <qdir.h>
-#include <qtextstream.h>
#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;
diff --git a/noncore/net/mail/main.cpp b/noncore/net/mail/main.cpp
index f97bea1..3bfcb4a 100644
--- a/noncore/net/mail/main.cpp
+++ b/noncore/net/mail/main.cpp
@@ -1,6 +1,5 @@
-#include <qpe/qpeapplication.h>
#include <opie/oapplicationfactory.h>
#include "opiemail.h"
OPIE_EXPORT_APP( OApplicationFactory<OpieMail> )
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 28111d0..6f054cc 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,150 +1,149 @@
#include <qlabel.h>
#include <qvbox.h>
#include <qheader.h>
#include <qtimer.h>
-#include <qpe/resource.h>
#include "defines.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());
}