- GUI: Bind a transport (for example SMTP server) to an indentity

Patch by Jason Stephenson <panda@mis.net>
- Remove information about not existing folder from the config file.
  Especially useful for IMAP folders. That just made my kmailrc 90% smaller.
- Mention a few more features on the about page.

svn path=/trunk/kdenetwork/kmail/; revision=86724
wilder-work
Michael Haeckel 25 years ago
parent f597ef56d5
commit 0f4aea501b
  1. 206
      configuredialog.cpp
  2. 34
      configuredialog.h
  3. 23
      kmcomposewin.cpp
  4. 47
      kmfoldertree.cpp
  5. 3
      kmfoldertree.h
  6. 7
      kmidentity.cpp
  7. 7
      kmidentity.h
  8. 2
      kmmainwin.cpp
  9. 12
      kmreaderwin.cpp

@ -504,7 +504,7 @@ void ConfigureDialog::makeIdentityPage( void )
QGridLayout *glay = new QGridLayout( topLevel, 12, 3 );
glay->addColSpacing( 1, fontMetrics().maxWidth()*15 );
glay->addRowSpacing( 6, spacingHint() );
//glay->addRowSpacing( 6, spacingHint() );
glay->setRowStretch( 11, 10 );
glay->setColStretch( 1, 10 );
@ -589,7 +589,22 @@ void ConfigureDialog::makeIdentityPage( void )
mIdentity.signatureFileRadio =
new QRadioButton( i18n("Use a signature from file"), page );
buttonGroup->insert( mIdentity.signatureFileRadio );
glay->addMultiCellWidget( mIdentity.signatureFileRadio, 7, 7, 0, 2 );
glay->addMultiCellWidget( mIdentity.signatureFileRadio, 7, 7, 0, 1 );
mIdentity.transportButton = new QPushButton(i18n("Add Transport..."),
page);
connect(mIdentity.transportButton, SIGNAL(clicked()), this,
SLOT(slotIdentityTransport()));
glay->addWidget(mIdentity.transportButton, 7, 2);
mIdentity.transportButton->setAutoDefault( false );
if (mIdentity.identityCombo->currentItem() == 0) {
mIdentity.transportButton->setEnabled(false);
mIdentity.transportButton->hide();
}
else {
mIdentity.transportButton->setEnabled(true);
mIdentity.transportButton->show();
}
mIdentity.signatureFileLabel = new QLabel( i18n("Signature File:"), page );
glay->addWidget( mIdentity.signatureFileLabel, 8, 0 );
@ -2276,6 +2291,10 @@ void ConfigureDialog::setIdentityInformation( const QString &identity )
mIdentity.signatureExecCheck->setChecked(entry->signatureFileIsAProgram());
mIdentity.signatureTextEdit->setText( entry->signatureInlineText() );
useSignatureFile = entry->useSignatureFile();
if (entry->transport().isNull() || entry->transport().isEmpty())
mIdentity.transportButton->setText(i18n("Add Transport..."));
else
mIdentity.transportButton->setText(i18n("Edit Transport..."));
}
if( useSignatureFile == true )
@ -2416,6 +2435,14 @@ void ConfigureDialog::slotIdentitySelectorChanged( void )
mIdentity.removeIdentityButton->setEnabled( currentItem != 0 );
mIdentity.renameIdentityButton->setEnabled( currentItem != 0 );
setIdentityInformation( mIdentity.identityCombo->currentText() );
if (currentItem == 0) {
mIdentity.transportButton->setEnabled(false);
mIdentity.transportButton->hide();
}
else {
mIdentity.transportButton->setEnabled(true);
mIdentity.transportButton->show();
}
}
@ -3286,6 +3313,11 @@ bool IdentityEntry::useSignatureFile() const
return( mUseSignatureFile );
}
QString IdentityEntry::transport() const
{
return ( mTransport );
}
void IdentityEntry::setIdentity( const QString &identity )
{
@ -3354,7 +3386,10 @@ void IdentityEntry::setUseSignatureFile( bool useSignatureFile )
mUseSignatureFile = useSignatureFile;
}
void IdentityEntry::setTransport( const QString &transport )
{
mTransport = transport;
}
@ -3424,6 +3459,7 @@ void IdentityList::importData()
entry.setSignatureFileName( ident.signatureFile(), true );
entry.setSignatureInlineText( ident.signatureInlineText() );
entry.setUseSignatureFile( ident.useSignatureFile() );
entry.setTransport(ident.transport());
add( entry );
}
}
@ -3443,6 +3479,7 @@ void IdentityList::exportData()
ident.setUseSignatureFile( e->useSignatureFile() );
ident.setSignatureFile( e->signatureFileName(true) );
ident.setSignatureInlineText( e->signatureInlineText() );
ident.setTransport( e->transport() );
ident.writeConfig(false);
ids.append( e->identity() );
}
@ -3536,3 +3573,166 @@ void IdentityList::update( const IdentityEntry &entry )
}
}
}
// ConfigureTransportDialog stuff below here.
ConfigureTransportDialog::ConfigureTransportDialog(QWidget *parent, const char *name, bool modal, const QString &transport) : KDialogBase( parent, name, modal, i18n("Configure Transport"), Ok|Cancel, Ok, true )
{
QFrame *frame = makeMainWidget();
QButtonGroup *buttonGroup = new QButtonGroup( frame );
buttonGroup->hide();
connect( buttonGroup, SIGNAL(clicked(int)),
this, SLOT(slotSendmailType(int)) );
QGridLayout *glay = new QGridLayout( frame, 6, 4, spacingHint() );
glay->addColSpacing( 2, fontMetrics().maxWidth()*15 );
this->sendmailRadio = new QRadioButton( i18n("Sendmail"), frame );
buttonGroup->insert(this->sendmailRadio);
glay->addMultiCellWidget(this->sendmailRadio, 0, 0, 0, 3);
QLabel *label = new QLabel( i18n("Location:"), frame );
glay->addWidget( label, 1, 1 );
this->sendmailLocationEdit = new QLineEdit( frame );
glay->addWidget( this->sendmailLocationEdit, 1, 2 );
this->sendmailChooseButton =
new QPushButton( i18n("Choose..."), frame );
connect( this->sendmailChooseButton, SIGNAL(clicked()),
this, SLOT(slotSendmailChooser()) );
this->sendmailChooseButton->setAutoDefault( false );
glay->addWidget( this->sendmailChooseButton, 1, 3 );
this->smtpRadio = new QRadioButton( i18n("SMTP"), frame );
buttonGroup->insert(this->smtpRadio);
glay->addMultiCellWidget(this->smtpRadio, 2, 2, 0, 3);
label = new QLabel( i18n("Server:"), frame );
glay->addWidget( label, 3, 1 );
this->smtpServerEdit = new QLineEdit( frame );
glay->addWidget( this->smtpServerEdit, 3, 2 );
label = new QLabel( i18n("Port:"), frame );
glay->addWidget( label, 4, 1 );
this->smtpPortEdit = new QLineEdit( frame );
this->smtpPortEdit->setValidator( new QIntValidator(frame) );
glay->addWidget( this->smtpPortEdit, 4, 2 );
this->deleteRadio = new QRadioButton(i18n("Remove this transport."), frame);
buttonGroup->insert(this->deleteRadio);
glay->addMultiCellWidget(this->deleteRadio, 5, 5, 0, 3);
// Set widgets to default values:
sendmailLocationEdit->setText(kernel->msgSender()->mailer());
// Reset the widgets based on passed in values.
mTransport = transport;
if (mTransport && !mTransport.isEmpty()) {
if (mTransport.left(5) == "smtp:") {
int lastColon = mTransport.find(":", 7);
smtpRadio->setChecked(true);
smtpServerEdit->setText(mTransport.mid(7,lastColon - 7));
smtpPortEdit->setText(mTransport.mid(lastColon + 1, mTransport.length()
- (lastColon + 1)));
this->slotSendmailType(1);
}
else {
sendmailRadio->setChecked(true);
sendmailLocationEdit->setText(mTransport);
this->slotSendmailType(0);
}
}
}
QString ConfigureTransportDialog::getTransport(void)
{
return mTransport;
}
void ConfigureTransportDialog::slotOk( void )
{
if (smtpRadio->isChecked()) {
if (!smtpServerEdit->text().isEmpty()) {
mTransport = "smtp://" + smtpServerEdit->text() + ":";
if (smtpPortEdit->text().isNull()) mTransport += "25";
else mTransport += smtpPortEdit->text();
}
}
else if (sendmailRadio->isChecked()) {
if (!sendmailLocationEdit->text().isEmpty())
mTransport = sendmailLocationEdit->text();
}
else if (deleteRadio->isChecked()) {
mTransport = "";
}
accept();
}
void ConfigureTransportDialog::slotCancel( void )
{
reject();
}
void ConfigureTransportDialog::slotSendmailType( int id )
{
bool useSendmail;
if( id == 0 )
{
useSendmail = true;
}
else if( id == 1 )
{
useSendmail = false;
}
else
{
this->sendmailLocationEdit->setEnabled(false);
this->sendmailChooseButton->setEnabled(false);
this->smtpServerEdit->setEnabled(false);
this->smtpPortEdit->setEnabled(false);
return;
}
this->sendmailLocationEdit->setEnabled( useSendmail );
this->sendmailChooseButton->setEnabled( useSendmail );
this->smtpServerEdit->setEnabled( !useSendmail );
this->smtpPortEdit->setEnabled( !useSendmail );
}
void ConfigureTransportDialog::slotSendmailChooser( void )
{
KFileDialog dialog("/", "*", this, 0, true );
dialog.setCaption(i18n("Choose Sendmail Location") );
if( dialog.exec() == QDialog::Accepted )
{
KURL url = dialog.selectedURL();
if( url.isEmpty() == true )
{
return;
}
if( url.isLocalFile() == false )
{
KMessageBox::sorry( 0L, i18n( "Only local files allowed." ) );
return;
}
this->sendmailLocationEdit->setText( url.path() );
}
}
// This is the ConfigureDialog slot for the button that opens the
// ConfigureTransportDialog. I put it down here, so I can easily
// find it while working on it.
void ConfigureDialog::slotIdentityTransport(void)
{
IdentityEntry *id;
id = mIdentityList.get(mIdentity.mActiveIdentity);
// Create the dialog.
ConfigureTransportDialog ctd(this, 0, true, id->transport());
ctd.setCaption(i18n("Configure Transport"));
if (ctd.exec() == QDialog::Accepted) {
id->setTransport(ctd.getTransport());
if (ctd.getTransport().isEmpty())
mIdentity.transportButton->setText("Add Transport...");
else
mIdentity.transportButton->setText("Edit Transport...");
}
}

@ -117,6 +117,7 @@ class IdentityEntry
QString signatureInlineText() const;
bool signatureFileIsAProgram() const;
bool useSignatureFile() const;
QString transport() const;
void setIdentity( const QString &identity );
void setFullName( const QString &fullName );
@ -129,6 +130,7 @@ class IdentityEntry
void setSignatureInlineText( const QString &signatureInlineText );
void setSignatureFileIsAProgram( bool signatureFileIsAProgram );
void setUseSignatureFile( bool useSignatureFile );
void setTransport(const QString &transport);
private:
QString mIdentity;
@ -141,6 +143,7 @@ class IdentityEntry
QString mSignatureInlineText;
bool mSignatureFileIsAProgram;
bool mUseSignatureFile;
QString mTransport;
};
@ -168,6 +171,34 @@ class IdentityList
};
class ConfigureTransportDialog : public KDialogBase
{
Q_OBJECT
public:
ConfigureTransportDialog(QWidget *parent=0, const char *name=0,
bool modal=true, const QString &transport=0);
QString getTransport(void);
protected slots:
virtual void slotOk( void );
virtual void slotCancel( void );
private slots:
void slotSendmailType( int id );
void slotSendmailChooser( void );
private:
QRadioButton *sendmailRadio;
QRadioButton *smtpRadio;
QRadioButton *deleteRadio;
QPushButton *sendmailChooseButton;
QLineEdit *sendmailLocationEdit;
QLineEdit *smtpServerEdit;
QLineEdit *smtpPortEdit;
QString mTransport;
};
class LanguageItem
{
public:
@ -255,6 +286,7 @@ class ConfigureDialog : public KDialogBase
QCheckBox *signatureExecCheck;
QPushButton *signatureBrowseButton;
QPushButton *signatureEditButton;
QPushButton *transportButton;
QRadioButton *signatureFileRadio;
QRadioButton *signatureTextRadio;
QMultiLineEdit *signatureTextEdit;
@ -451,6 +483,7 @@ class ConfigureDialog : public KDialogBase
void slotSignatureEdit( void );
void slotSignatureFile( const QString &filename );
void slotSignatureExecMode( bool state );
void slotIdentityTransport( void );
void slotSendmailType( int id );
void slotSendmailChooser( void );
void slotAccountSelected( void );
@ -510,5 +543,4 @@ class ConfigureDialog : public KDialogBase
bool secondIdentity;
};
#endif

@ -2178,6 +2178,29 @@ void KMComposeWin::slotIdentityActivated(int)
QString edtText = mEditor->text();
int pos = edtText.findRev( "\n-- \n" + mOldSigText);
if (!mBtnTransport.isChecked()) {
if (ident.transport().isEmpty())
mMsg->removeHeaderField("X-KMail-Transport");
else
mMsg->setHeaderField("X-KMail-Transport", ident.transport());
QString transp = ident.transport();
if (transp.isEmpty()) transp = kernel->msgSender()->transportString();
bool found = false;
int i;
for (i = 0; i < mTransport.count(); i++) {
if (mTransport.text(i) == transp) {
found = true;
mTransport.setCurrentItem(i);
break;
}
}
if (found == false) {
if (i == mTransport.maxCount()) mTransport.setMaxCount(i + 1);
mTransport.insertItem(transp,i);
mTransport.setCurrentItem(i);
}
}
if (((pos >= 0) && (pos + mOldSigText.length() + 5 == edtText.length())) ||
(mOldSigText.isEmpty())) {
if (pos >= 0)

@ -6,6 +6,7 @@
#include <assert.h>
#include <kapp.h>
#include <kconfig.h>
#include <ksimpleconfig.h>
#include <qpixmap.h>
#include <kiconloader.h>
#include <qtimer.h>
@ -810,6 +811,52 @@ void KMFolderTree::writeIsListViewItemOpen(KMFolderTreeItem *fti)
}
//-----------------------------------------------------------------------------
void KMFolderTree::cleanupConfigFile()
{
KConfig* appConfig = kapp->config();
appConfig->sync();
KSimpleConfig config(locateLocal("config","kmailrc"));
QStringList existingFolders;
QListViewItemIterator fldIt(this);
QMap<QString,bool> folderMap;
KMFolderTreeItem *fti;
for (QListViewItemIterator fldIt(this); fldIt.current(); fldIt++)
{
fti = static_cast<KMFolderTreeItem*>(fldIt.current());
if (fti && fti->folder)
folderMap.insert(fti->folder->idString(), fti->isExpandable());
}
QStringList groupList = config.groupList();
QString name, wholeName;
int pos;
bool original;
for (QStringList::Iterator grpIt = groupList.begin();
grpIt != groupList.end(); grpIt++)
{
if ((*grpIt).left(7) != "Folder-") continue;
wholeName = name = (*grpIt).mid(7);
original = TRUE;
while ((folderMap.find(name) == folderMap.end()) ||
!(original || *(folderMap.find(name))))
{
if ((pos = name.findRev(".directory/")) != -1)
{
name = name.left(pos);
name.remove(((pos = name.findRev("/.")) == -1) ? 0 : (pos+1), 1);
original = FALSE;
} else {
config.deleteGroup(*grpIt, TRUE);
kdDebug() << "Deleting information about folder " << wholeName << endl;
break;
}
}
}
config.sync();
appConfig->reparseConfiguration();
}
//-----------------------------------------------------------------------------
// Drag and Drop handling -- based on the Troll Tech dirview example

@ -104,6 +104,9 @@ public:
/** Ensure that there is only one selected item */
virtual void setSelected( QListViewItem *, bool );
/** Remove information about not existing folders from the config file */
void cleanupConfigFile();
signals:
/* The selected folder has changed */
void folderSelected(KMFolder*);

@ -105,6 +105,7 @@ void KMIdentity::readConfig(void)
mSignatureFile = config->readEntry("Signature File");
mUseSignatureFile = config->readBoolEntry("UseSignatureFile", false);
mSignatureInlineText = config->readEntry("Inline Signature");
mTransport = config->readEntry("Transport");
}
@ -128,6 +129,7 @@ void KMIdentity::writeConfig(bool aWithSync)
config->writeEntry("Inline Signature", mSignatureInlineText );
config->writeEntry("UseSignatureFile", mUseSignatureFile );
config->writeEntry("VCardFile", mVCardFile);
config->writeEntry("Transport", mTransport);
if (aWithSync) config->sync();
}
@ -213,6 +215,11 @@ void KMIdentity::setUseSignatureFile( bool flag )
mUseSignatureFile = flag;
}
//-----------------------------------------------------------------------------
void KMIdentity::setTransport(const QString str)
{
mTransport = str.copy();
}
//-----------------------------------------------------------------------------
const QString KMIdentity::signature(void) const

@ -83,10 +83,15 @@ public:
the signature file. */
virtual const QString signature(void) const;
/** The transport that is set for this identity. Used to link a
transport with an identity. */
const QString transport(void) { return mTransport; }
virtual void setTransport(QString);
protected:
QString mIdentity, mFullName, mOrganization, mPgpIdentity, mEmailAddr;
QString mReplyToAddr, mSignatureFile;
QString mSignatureInlineText;
QString mSignatureInlineText, mTransport;
QString mVCardFile;
bool mUseSignatureFile;
};

@ -118,6 +118,8 @@ KMMainWin::KMMainWin(QWidget *, char *name) :
setCaption( i18n("KDE Mail Client") );
mFolderTree->cleanupConfigFile();
// must be the last line of the constructor:
mStartupDone = TRUE;
}

@ -435,15 +435,19 @@ void KMReaderWin::displayAboutPage()
"<ul><li>KMail has many powerful features which are described in the "
"<A HREF=\"%2\">documentation</A></li>\n"
"<li>You can find news and updates at the <A HREF=\"%3\">KMail homepage"
"</A></li></ul>\n"
"<p>Some of the new features in this release of KMail include "
"</A></li></ul>\n") +
i18n("<p>Some of the new features in this release of KMail include "
"(compared to KMail 1.2, which is part of KDE 2.1):</p>\n"
"<ul>\n"
"<li>IMAP support</li>\n"
"<li>Only the selected part of a mail will be quoted on reply</li>\n"
"<li>Delete old messages from the trash folder on exit</li>\n"
"</ul>\n"
"<p>Please take a moment to fill in the KMail configuration panel at "
"<li>Collapsable threads</li>\n"
"<li>Multiple PGP identities</li>\n"
"<li>Bind a SMTP server to an identity</li>\n"
"<li>Better procmail support via the local account</li>\n"
"</ul>\n") +
i18n("<p>Please take a moment to fill in the KMail configuration panel at "
"Settings-&gt;Configuration.\n"
"You need to at least create a primary identity and a mail "
"account.</p>\n"

Loading…
Cancel
Save