File indexing completed on 2025-01-19 03:52:45

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-11-07
0007  * Description : mail settings container.
0008  *
0009  * SPDX-FileCopyrightText: 2007-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2010      by Andi Clemens <andi dot clemens at googlemail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "mailsettings.h"
0017 
0018 // KDE includes
0019 
0020 #include <klocalizedstring.h>
0021 #include <kconfiggroup.h>
0022 
0023 namespace DigikamGenericSendByMailPlugin
0024 {
0025 
0026 MailSettings::MailSettings()
0027     : selMode(IMAGES),
0028       addFileProperties(false),
0029       imagesChangeProp(false),
0030       removeMetadata(false),
0031       imageCompression(75),
0032       attLimitInMbytes(17),
0033       mailProgram(THUNDERBIRD),
0034       imageSize(1024),
0035       imageFormat(JPEG)
0036 {
0037 }
0038 
0039 MailSettings::~MailSettings()
0040 {
0041 }
0042 
0043 void MailSettings::readSettings(KConfigGroup& group)
0044 {
0045     selMode           = (Selection)group.readEntry("SelMode",
0046                         (int)IMAGES);
0047     addFileProperties = group.readEntry("AddCommentsAndTags",
0048                         false);
0049     imagesChangeProp  = group.readEntry("ImagesChangeProp",
0050                         false);
0051     removeMetadata    = group.readEntry("RemoveMetadata",
0052                         false);
0053     attLimitInMbytes  = group.readEntry("AttLimitInMbytes",
0054                         17);
0055     imageCompression  = group.readEntry("ImageCompression",
0056                         75);
0057     mailProgram       = (MailClient)group.readEntry("MailProgram",
0058                         (int)THUNDERBIRD);
0059     imageSize         = group.readEntry("ImageSize",
0060                         1024);
0061     imageFormat       = (ImageFormat)group.readEntry("ImageFormat",
0062                         (int)JPEG);
0063 }
0064 
0065 void MailSettings::writeSettings(KConfigGroup& group)
0066 {
0067     group.writeEntry("SelMode",            (int)selMode);
0068     group.writeEntry("AddCommentsAndTags", addFileProperties);
0069     group.writeEntry("ImagesChangeProp",   imagesChangeProp);
0070     group.writeEntry("RemoveMetadata",     removeMetadata);
0071     group.writeEntry("AttLimitInMbytes",   attLimitInMbytes);
0072     group.writeEntry("ImageCompression",   imageCompression);
0073     group.writeEntry("MailProgram",        (int)mailProgram);
0074     group.writeEntry("ImageSize",          imageSize);
0075     group.writeEntry("ImageFormat",        (int)imageFormat);
0076 }
0077 
0078 QString MailSettings::format() const
0079 {
0080     if (imageFormat == JPEG)
0081     {
0082         return QLatin1String("JPEG");
0083     }
0084 
0085     return QLatin1String("PNG");
0086 }
0087 
0088 void MailSettings::setMailUrl(const QUrl& orgUrl, const QUrl& emailUrl)
0089 {
0090     itemsList.insert(orgUrl, emailUrl);
0091 }
0092 
0093 QUrl MailSettings::mailUrl(const QUrl& orgUrl) const
0094 {
0095     if (itemsList.contains(orgUrl))
0096     {
0097         return itemsList.find(orgUrl).value();
0098     }
0099 
0100     return QUrl();
0101 }
0102 
0103 qint64 MailSettings::attachementLimit() const
0104 {
0105     qint64 val = attLimitInMbytes * 1024 * 1024;
0106 
0107     return val;
0108 }
0109 
0110 QMap<MailSettings::MailClient, QString> MailSettings::mailClientNames()
0111 {
0112     QMap<MailClient, QString> clients;
0113 
0114     clients[BALSA]         = i18nc("Mail client: BALSA",         "Balsa");
0115     clients[CLAWSMAIL]     = i18nc("Mail client: CLAWSMAIL",     "Clawsmail");
0116     clients[EVOLUTION]     = i18nc("Mail client: EVOLUTION",     "Evolution");
0117     clients[KMAIL]         = i18nc("Mail client: KMAIL",         "Kmail");
0118     clients[NETSCAPE]      = i18nc("Mail client: NETSCAPE",      "Netscape Messenger");
0119     clients[OUTLOOK]       = i18nc("Mail client: OUTLOOK",       "Outlook");
0120     clients[SYLPHEED]      = i18nc("Mail client: SYLPHEED",      "Sylpheed");
0121     clients[THUNDERBIRD]   = i18nc("Mail client: THUNDERBIRD",   "Thunderbird");
0122 
0123     return clients;
0124 }
0125 
0126 QMap<MailSettings::ImageFormat, QString> MailSettings::imageFormatNames()
0127 {
0128     QMap<ImageFormat, QString> frms;
0129 
0130     frms[JPEG] = i18nc("Image format: JPEG", "Jpeg");
0131     frms[PNG]  = i18nc("Image format: PNG",  "Png");
0132 
0133     return frms;
0134 }
0135 
0136 } // namespace DigikamGenericSendByMailPlugin