9#include "calendarsupport_debug.h"
10#include "identitymanager.h"
12#include <Akonadi/TagAttribute>
13#include <Akonadi/TagCache>
14#include <Akonadi/TagModifyJob>
16#include <KMime/HeaderParsing>
18#include <KEmailAddress>
19#include <KIdentityManagementCore/Identity>
21#include <KEMailSettings>
23using namespace CalendarSupport;
25Q_GLOBAL_STATIC(KCalPrefs, globalPrefs)
27class CalendarSupport::KCalPrefsPrivate
31 : mDefaultCalendarId(-1)
32 , mDefaultCategoryColor(
QColor(151, 235, 121))
36 ~KCalPrefsPrivate() =
default;
40 const QColor mDefaultCategoryColor;
46 , d(new KCalPrefsPrivate())
51KCalPrefs::~KCalPrefs() =
default;
53KCalPrefs *KCalPrefs::instance()
55 static bool firstCall =
true;
65void KCalPrefs::usrSetDefaults()
75 tmp = settings.
getSetting(KEMailSettings::EmailAddress);
86 return d->mDefaultCalendarId;
91 d->mDefaultCalendarId = id;
94void KCalPrefs::fillMailDefaults()
96 userEmailItem()->swapDefault();
97 QString defEmail = userEmailItem()->value();
98 userEmailItem()->swapDefault();
100 if (userEmail() == defEmail) {
104 mEmailControlCenter =
true;
109void KCalPrefs::usrRead()
111 KConfigGroup generalConfig(config(), QStringLiteral(
"General"));
113 KConfigGroup defaultCalendarConfig(config(), QStringLiteral(
"Calendar"));
114 d->mDefaultCalendarId = defaultCalendarConfig.readEntry(
"Default Calendar", -1);
117 config()->setGroup(
"FreeBusy");
118 if (mRememberRetrievePw) {
128bool KCalPrefs::usrSave()
130 KConfigGroup generalConfig(config(), QStringLiteral(
"General"));
133 if (mRememberRetrievePw) {
134 config()->writeEntry(
"Retrieve Server Password",
137 config()->deleteEntry(
"Retrieve Server Password");
141 KConfigGroup defaultCalendarConfig(config(), QStringLiteral(
"Calendar"));
142 defaultCalendarConfig.writeEntry(
"Default Calendar", defaultCalendarId());
150 if (mEmailControlCenter) {
152 tusername = settings.
getSetting(KEMailSettings::RealName);
154 tusername = userName();
170 if (mEmailControlCenter) {
172 return settings.
getSetting(KEMailSettings::EmailAddress);
183 lst += mAdditionalMails;
199 fullEmails.
reserve(1 + mAdditionalMails.count() + lst.
count());
201 fullEmails << QStringLiteral(
"%1 <%2>").arg(fullName(), email());
204 KIdentityManagementCore::IdentityManager::ConstIterator it1;
205 KIdentityManagementCore::IdentityManager::ConstIterator end1(idmanager->end());
206 for (it1 = idmanager->begin(); it1 != end1; ++it1) {
207 fullEmails << (*it1).fullEmailAddr();
210 lst = mAdditionalMails;
211 for (it = lst.
begin(); it != lst.
end(); ++it) {
212 fullEmails << QStringLiteral(
"%1 <%2>").arg(fullName(), *it);
219bool KCalPrefs::thatIsMe(
const QString &_email)
240 KMime::HeaderParsing::parseMailbox(cursor, end, mbox);
241 const QString email = mbox.addrSpec().asString();
243 if (this->email() == email) {
247 CalendarSupport::IdentityManager::ConstIterator it;
248 CalendarSupport::IdentityManager::ConstIterator endId(CalendarSupport::identityManager()->
end());
249 for (it = CalendarSupport::identityManager()->
begin(); it != endId; ++it) {
250 if ((*it).matchesEmailAddress(email)) {
255 if (mAdditionalMails.contains(email)) {
262void KCalPrefs::setDayBegins(
const QDateTime &dateTime)
264 d->mDayBegins = dateTime;
269 return d->mDayBegins;
272#include "moc_kcalprefs.cpp"
static TagCache * instance()
virtual void usrSetDefaults()
QString getSetting(KEMailSettings::Setting s) const
QStringList allEmails() const
QStringList identities() const
const QList< QKeySequence > & begin()
const QList< QKeySequence > & end()
KCOREADDONS_EXPORT QString obscure(const QString &str)
const char * constData() const const
qsizetype length() const const
qsizetype count() const const
void reserve(qsizetype size)
bool isEmpty() const const
QByteArray toUtf8() const const