28 #include <KMime/HeaderParsing>
30 #include <KPIMIdentities/Identity>
31 #include <KPIMIdentities/IdentityManager>
33 #include <KPIMUtils/Email>
35 #include <KEMailSettings>
36 #include <KSystemTimeZone>
38 using namespace CalendarSupport;
45 Private(
KCalPrefs *qq ) : mDefaultCalendarId( -1 ), q( qq )
47 mDefaultCategoryColor =
QColor( 151, 235, 121 );
53 delete mCategoryConfig;
56 KDateTime::Spec mTimeSpec;
57 Akonadi::Entity::Id mDefaultCalendarId;
61 QColor mDefaultCategoryColor;
79 static bool firstCall =
true;
83 globalPrefs->readConfig();
94 KEMailSettings settings;
95 QString tmp = settings.getSetting( KEMailSettings::RealName );
99 tmp = settings.getSetting( KEMailSettings::EmailAddress );
107 KConfigSkeleton::usrSetDefaults();
112 return KSystemTimeZones::local();
122 return d->mDefaultCalendarId;
127 d->mDefaultCalendarId = id;
132 KTimeZone zone = KSystemTimeZones::local();
133 if ( !zone.isValid() ) {
134 kError() <<
"KSystemTimeZones::local() return 0";
138 kDebug () <<
"----- time zone:" << zone.name();
145 userEmailItem()->swapDefault();
146 QString defEmail = userEmailItem()->value();
147 userEmailItem()->swapDefault();
149 if ( userEmail() == defEmail ) {
151 KEMailSettings settings;
152 if ( !settings.getSetting( KEMailSettings::EmailAddress ).isEmpty() ) {
153 mEmailControlCenter =
true;
160 KConfigGroup generalConfig( config(),
"General" );
162 if ( !d->mTimeSpec.isValid() ) {
166 KConfigGroup defaultCalendarConfig( config(),
"Calendar" );
167 d->mDefaultCalendarId = defaultCalendarConfig.readEntry(
"Default Calendar", -1 );
170 d->mCategoryColors = d->mCategoryConfig->readColors();
172 config()->setGroup(
"FreeBusy" );
173 if ( mRememberRetrievePw ) {
174 d->mRetrievePassword =
175 KStringHandler::obscure( config()->readEntry(
"Retrieve Server Password" ) );
179 KConfigSkeleton::usrReadConfig();
185 KConfigGroup generalConfig( config(),
"General" );
186 d->mCategoryConfig->setColors( d->mCategoryColors );
189 if ( mRememberRetrievePw ) {
190 config()->writeEntry(
"Retrieve Server Password",
191 KStringHandler::obscure( d->mRetrievePassword ) );
193 config()->deleteEntry(
"Retrieve Server Password" );
197 KConfigGroup defaultCalendarConfig( config(),
"Calendar" );
200 KConfigSkeleton::usrWriteConfig();
206 if ( mEmailControlCenter ) {
207 KEMailSettings settings;
208 tusername = settings.getSetting( KEMailSettings::RealName );
210 tusername = userName();
214 tusername = KPIMUtils::quoteNameIfNecessary( tusername );
219 KPIMUtils::extractEmailAddressAndName( tusername, temail, tname );
225 if ( mEmailControlCenter ) {
226 KEMailSettings settings;
227 return settings.getSetting( KEMailSettings::EmailAddress );
238 lst += mAdditionalMails;
256 KPIMIdentities::IdentityManager::ConstIterator it1;
257 for ( it1 = idmanager->begin(); it1 != idmanager->end(); ++it1 ) {
258 fullEmails << (*it1).fullEmailAddr();
261 lst = mAdditionalMails;
262 for ( it = lst.
begin(); it != lst.
end(); ++it ) {
290 KMime::Types::Mailbox mbox;
291 KMime::HeaderParsing::parseMailbox( cursor, end, mbox );
294 if ( this->
email() == email ) {
298 CalendarSupport::IdentityManager::ConstIterator it;
301 if ( (*it).matchesEmailAddress( email ) ) {
306 if ( mAdditionalMails.contains( email ) ) {
315 d->mCategoryColors.insert( cat, color );
323 color = d->mCategoryColors.value( cat );
326 return color.
isValid() ? color : d->mDefaultCategoryColor;
331 return d->mCategoryColors[ cat ].isValid();
336 d->mDayBegins = dateTime;
341 return d->mDayBegins;
void setTimeSpec(const KDateTime::Spec &spec)
QStringList fullEmails()
Returns all email addresses together with the full username for the user.
void usrWriteConfig()
Write preferences to config file.
QColor categoryColor(const QString &cat) const
void usrSetDefaults()
Set preferences to default values.
QStringList allEmails()
Returns all email addresses for the user.
KPIMIdentities::IdentityManager * identityManager()
bool thatIsMe(const QString &email)
Return true if the given email belongs to the user.
QString fromUtf8(const char *str, int size)
Akonadi::Entity::Id defaultCalendarId() const
void setCategoryColor(const QString &cat, const QColor &color)
void setDefaultCalendarId(const Akonadi::Entity::Id)
const char * constData() const
KCalPrefs()
Constructor disabled for public.
static KCalPrefs * instance()
Get instance of KCalPrefs.
bool hasCategoryColor(const QString &cat) const
QDateTime dayBegins() const
void setDayBegins(const QDateTime &dateTime)
void setTimeZoneDefault()
void usrReadConfig()
Read preferences from config file.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
KDateTime::Spec timeSpec()
void fillMailDefaults()
Fill empty mail fields with default values.
QByteArray toUtf8() const