[Digikam-devel] extragear/libs/kipi-plugins/sendimages
Gilles Caulier
caulier.gilles at gmail.com
Mon Nov 12 14:26:23 GMT 2007
SVN commit 735733 by cgilles:
Kipi-plugins from trunk (KDE4) : SendImages plugin port:
Huge improvement with mozilla/thunderbird emailer support about attachement files given on command line.
No need to check if an instance of mailer already exist in memory to use -remote option. If we use -compose
with the right options form. This way simplify the source code considerably... Thanks to Mozilla.org wiki page
to describe all catch command line options syntax.
I have tested with recent Thunderbird, Mozilla, and Netscape mailers. Please give me feedback if you occurs special
errors with old versions. Thanks in advance...
Note B.K.O files 148186 is closed because RAW attachement files is fixed now.
CCMAIL: digikam-devel at kde.org
CCMAIL: kde-imaging at kde.org
BUG: 148186
BUG: 150453
M +8 -55 emailpage.cpp
M +0 -6 emailpage.h
M +0 -2 emailsettingscontainer.h
M +39 -80 sendimages.cpp
M +0 -2 sendimagesdialog.cpp
--- trunk/extragear/libs/kipi-plugins/sendimages/emailpage.cpp #735732:735733
@@ -24,6 +24,7 @@
#include <QLayout>
#include <QLabel>
+#include <QGroupBox>
#include <QComboBox>
#include <QCheckBox>
#include <QPushButton>
@@ -34,7 +35,6 @@
#include <kdialog.h>
#include <knuminput.h>
#include <kiconloader.h>
-#include <kurlrequester.h>
// LibKDcraw includes.
@@ -57,8 +57,6 @@
{
labelMailAgent = 0;
mailAgentName = 0;
- labelThunderbirdBinPath = 0;
- thunderbirdBinPath = 0;
imagesResize = 0;
addComments = 0;
changeImagesProp = 0;
@@ -70,7 +68,6 @@
}
QLabel *labelMailAgent;
- QLabel *labelThunderbirdBinPath;
QLabel *labelImagesResize;
QLabel *labelImagesFormat;
@@ -83,8 +80,6 @@
KIntNumInput *imageCompression;
KIntNumInput *attachmentlimit;
-
- KUrlRequester *thunderbirdBinPath;
};
EmailPage::EmailPage(QWidget* parent)
@@ -117,15 +112,6 @@
//---------------------------------------------
- d->labelThunderbirdBinPath = new QLabel(i18n("&Thunderbird path:"), this);
-
- d->thunderbirdBinPath = new KUrlRequester(this);
- d->thunderbirdBinPath->setUrl(KUrl("/usr/bin/thunderbird"));
- d->labelThunderbirdBinPath->setBuddy( d->thunderbirdBinPath );
- d->thunderbirdBinPath->setWhatsThis(i18n("<p>The path name to the Thunderbird program."));
-
- //---------------------------------------------
-
d->addComments = new QCheckBox(i18n("Attach a file with caption and tags"), this);
d->addComments->setWhatsThis(i18n("<p>If you enable this option, all image captions and tags "
"will be added as an attached file."));
@@ -145,8 +131,8 @@
d->changeImagesProp->setWhatsThis(i18n("<p>If you enable this option, "
"all images to send can be resized and recompressed."));
- QGroupBox * groupBox = new QGroupBox(i18n("Image Properties"), this);
- QGridLayout* grid2 = new QGridLayout(groupBox);
+ QGroupBox *groupBox = new QGroupBox(i18n("Image Properties"), this);
+ QGridLayout *grid2 = new QGridLayout(groupBox);
d->imagesResize = new QComboBox(groupBox);
d->imagesResize->insertItem(EmailSettingsContainer::VERYSMALL, i18n("Very Small (320 pixels)"));
@@ -230,13 +216,11 @@
grid->addWidget(d->labelMailAgent, 0, 0, 1, 1);
grid->addWidget(d->mailAgentName, 0, 1, 1, 2);
- grid->addWidget(d->labelThunderbirdBinPath, 1, 0, 1, 1);
- grid->addWidget(d->thunderbirdBinPath, 1, 1, 1, 3);
- grid->addWidget(d->attachmentlimit, 2, 0, 1, 4);
- grid->addWidget(d->addComments, 3, 0, 1, 4);
- grid->addWidget(d->changeImagesProp, 4, 0, 1, 4);
- grid->addWidget(groupBox, 5, 0, 1, 4);
- grid->setRowStretch(6, 10);
+ grid->addWidget(d->attachmentlimit, 1, 0, 1, 4);
+ grid->addWidget(d->addComments, 2, 0, 1, 4);
+ grid->addWidget(d->changeImagesProp, 3, 0, 1, 4);
+ grid->addWidget(groupBox, 4, 0, 1, 4);
+ grid->setRowStretch(5, 10);
grid->setColumnStretch(3, 10);
grid->setMargin(0);
grid->setSpacing(KDialog::spacingHint());
@@ -246,12 +230,6 @@
connect(d->imagesFormat, SIGNAL(activated(int)),
this, SLOT(slotImagesFormatChanged(int)));
- connect(d->mailAgentName, SIGNAL(activated(int)),
- this, SLOT(slotMailAgentChanged(int)));
-
- connect(d->thunderbirdBinPath, SIGNAL(textChanged(const QString&)),
- this, SLOT(slotThunderbirdBinPathChanged(const QString&)));
-
connect(d->changeImagesProp, SIGNAL(toggled(bool)),
groupBox, SLOT(setEnabled(bool)));
}
@@ -269,26 +247,6 @@
d->imageCompression->setEnabled(false);
}
-void EmailPage::slotMailAgentChanged(int i)
-{
- if ( i == EmailSettingsContainer::THUNDERBIRD )
- {
- d->labelThunderbirdBinPath->setEnabled(true);
- d->thunderbirdBinPath->setEnabled(true);
- }
- else
- {
- d->labelThunderbirdBinPath->setEnabled(false);
- d->thunderbirdBinPath->setEnabled(false);
- }
-}
-
-void EmailPage::slotThunderbirdBinPathChanged(const QString& url)
-{
- if ( d->mailAgentName->currentIndex() == EmailSettingsContainer::THUNDERBIRD )
- emit signalEnableButtonOK( !url.isEmpty());
-}
-
void EmailPage::setEmailSettings(const EmailSettingsContainer& settings)
{
d->mailAgentName->setCurrentIndex((int)settings.emailProgram);
@@ -301,10 +259,7 @@
d->imageCompression->setValue(settings.imageCompression);
d->attachmentlimit->setValue(settings.attachmentLimitInMbytes);
- d->thunderbirdBinPath->setUrl(settings.thunderbirdPath);
-
slotImagesFormatChanged(d->imagesFormat->currentIndex());
- slotMailAgentChanged(d->mailAgentName->currentIndex());
}
EmailSettingsContainer EmailPage::emailSettings()
@@ -320,8 +275,6 @@
settings.imageCompression = d->imageCompression->value();
settings.attachmentLimitInMbytes = d->attachmentlimit->value();
- settings.thunderbirdPath = d->thunderbirdBinPath->url();
-
return settings;
}
--- trunk/extragear/libs/kipi-plugins/sendimages/emailpage.h #735732:735733
@@ -48,15 +48,9 @@
void setEmailSettings(const EmailSettingsContainer& settings);
EmailSettingsContainer emailSettings();
-signals:
-
- void signalEnableButtonOK(bool);
-
private slots:
void slotImagesFormatChanged(int);
- void slotMailAgentChanged(int);
- void slotThunderbirdBinPathChanged(const QString&);
private:
--- trunk/extragear/libs/kipi-plugins/sendimages/emailsettingscontainer.h #735732:735733
@@ -168,8 +168,6 @@
QString tempPath;
- KUrl thunderbirdPath;
-
EmailClient emailProgram;
ImageSize imageSize;
--- trunk/extragear/libs/kipi-plugins/sendimages/sendimages.cpp #735732:735733
@@ -61,10 +61,13 @@
SendImagesPriv()
{
+ invokedBefore = false;
threadImgResize = 0;
progressDlg = 0;
}
+ bool invokedBefore;
+
KUrl::List attachementFiles;
KUrl::List failedResizedImages;
@@ -440,97 +443,53 @@
break;
}
- case EmailSettingsContainer::GMAILAGENT:
- {
- break;
- }
+ // More info about command lines options with Mozilla & co:
+ // http://www.mozilla.org/docs/command-line-args.html#Syntax_Rules
case EmailSettingsContainer::MOZILLA:
- {
- break;
- }
-
case EmailSettingsContainer::NETSCAPE:
- {
- break;
- }
-
case EmailSettingsContainer::THUNDERBIRD:
+ case EmailSettingsContainer::GMAILAGENT:
{
+ QString prog;
+ if (d->settings.emailProgram == EmailSettingsContainer::MOZILLA)
+ prog = QString("mozila");
+ else if (d->settings.emailProgram == EmailSettingsContainer::NETSCAPE)
+ prog = QString("netscape");
+ else if (d->settings.emailProgram == EmailSettingsContainer::THUNDERBIRD)
+ prog = QString("thunderbird");
+ else
+ prog = QString("gmailagent");
+
+ QStringList args;
+ args.append("-compose");
+ QString tmp = "attachment='";
+ for (KUrl::List::Iterator it = fileList.begin() ; it != fileList.end() ; ++it )
+ {
+ tmp.append( "file://" );
+ QString toencode=(*it).encodedPathAndQuery();
+ tmp.append(toencode);
+ tmp.append( "," );
+ }
+ tmp.remove(tmp.length()-1, 1);
+ tmp.append("'");
+
+ args.append(tmp);
+
+ if (!QProcess::startDetached(prog, args))
+ invokeMailAgentError(prog, args);
+ else
+ {
+ invokeMailAgentDone(prog, args);
+ agentInvoked = true;
+ }
+
break;
}
}
}
}
while(!fileList.isEmpty());
-
-/*
-
- // Mozilla | Netscape | Thunderbird mail agent call.
-
- if ( m_sendImagesDialog->m_mailAgentName->currentText() == "Mozilla" ||
- m_sendImagesDialog->m_mailAgentName->currentText() == "Netscape" ||
- m_sendImagesDialog->m_mailAgentName->currentText() == "Thunderbird" ||
- m_sendImagesDialog->m_mailAgentName->currentText() == "GmailAgent")
- {
- m_mailAgentProc = new KProcess;
-
- m_thunderbirdUrl = m_sendImagesDialog->m_ThunderbirdBinPath->url();
-
- if ( m_sendImagesDialog->m_mailAgentName->currentText() == "Mozilla" )
- {
- *m_mailAgentProc << "mozilla" << "-remote";
- }
- else if ( m_sendImagesDialog->m_mailAgentName->currentText() == "Thunderbird" )
- {
- *m_mailAgentProc << m_thunderbirdUrl << "-remote";
- qDebug("URL: %s", m_thunderbirdUrl.ascii());
- }
- else if ( m_sendImagesDialog->m_mailAgentName->currentText() == "GmailAgent" )
- {
- *m_mailAgentProc << "gmailagent" << "-remote";
- }
- else
- {
- *m_mailAgentProc << "netscape" << "-remote";
- }
-
- QString Temp = " xfeDoCommand(composeMessage,attachment='";
-
- for ( KURL::List::Iterator it = filelist.begin() ; it != filelist.end() ; ++it )
- {
- Temp.append( "file://" );
- QString toencode=(*it).encodedPathAndQuery();
- Temp.append(toencode);
- Temp.append( "," );
- }
-
- Temp.remove(Temp.length()-1,1);
- Temp.append("')");
-
- *m_mailAgentProc << Temp;
-
- if (!m_invokedBefore)
- {
- connect(m_mailAgentProc, SIGNAL(processExited(KProcess *)),
- this, SLOT(slotMozillaExited(KProcess*)));
-
- connect(m_mailAgentProc, SIGNAL(receivedStderr(KProcess *, char*, int)),
- this, SLOT(slotMozillaReadStderr(KProcess*, char*, int)));
- }
- qDebug ("%s", Temp.ascii());
-
- if ( m_mailAgentProc->start(KProcess::NotifyOnExit , KProcess::All) == false )
- KMessageBox::error(kapp->activeWindow(),
- i18n("Cannot start '%1' program;\nplease "
- "check your installation.")
- .arg(m_sendImagesDialog->m_mailAgentName->currentText()));
- else
- { agentInvoked = true;
- m_invokedBefore=true;
- }
- }
-*/
return agentInvoked;
}
--- trunk/extragear/libs/kipi-plugins/sendimages/sendimagesdialog.cpp #735732:735733
@@ -215,7 +215,6 @@
settings.addCommentsAndTags = group.readEntry("AddCommentsAndTags", false);
settings.imageCompression = group.readEntry("ImageCompression", 75);
settings.attachmentLimitInMbytes = group.readEntry("AttachmentLimit", 17);
- settings.thunderbirdPath = group.readEntry("ThunderbirdPath", KUrl());
d->emailPage->setEmailSettings(settings);
KConfigGroup group2 = config.group(QString("SendImages Dialog"));
@@ -236,7 +235,6 @@
group.writeEntry("AddCommentsAndTags", settings.addCommentsAndTags);
group.writeEntry("ImageCompression", settings.imageCompression);
group.writeEntry("AttachmentLimit", settings.attachmentLimitInMbytes);
- group.writeEntry("ThunderbirdPath", settings.thunderbirdPath);
KConfigGroup group2 = config.group(QString("SendImages Dialog"));
saveDialogSize(group2);
More information about the Digikam-devel
mailing list