1
// -*- c-basic-offset: 2 -*-
3
This file is part of libkabc.
4
Copyright (c) 2008-2009 Kevin Krammer <kevin.krammer@gmx.at>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with this library; see the file COPYING.LIB. If not, write to
18
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
Boston, MA 02110-1301, USA.
21
#include "resourceakonadi.h"
23
#include "resourceakonadi_p.h"
24
#include "resourceakonadiconfig.h"
28
ResourceAkonadi::ResourceAkonadi()
29
: ResourceABC(), d( new Private( this ) )
31
KGlobal::locale()->insertCatalog("kresources_shared_akonadi");
34
ResourceAkonadi::ResourceAkonadi( const KConfigGroup &group )
35
: ResourceABC( group ), d( new Private( group, this ) )
39
ResourceAkonadi::~ResourceAkonadi()
44
void ResourceAkonadi::clear()
52
void ResourceAkonadi::writeConfig( KConfigGroup &group )
55
ResourceABC::writeConfig( group );
57
d->writeConfig( group );
60
bool ResourceAkonadi::doOpen()
65
void ResourceAkonadi::doClose()
71
Ticket *ResourceAkonadi::requestSaveTicket()
74
if ( !addressBook() ) {
75
kDebug(5700) << "no addressbook";
79
return createTicket( this );
82
void ResourceAkonadi::releaseSaveTicket( Ticket *ticket )
87
bool ResourceAkonadi::load()
95
bool ResourceAkonadi::asyncLoad()
100
return d->doAsyncLoad();
103
bool ResourceAkonadi::save( Ticket *ticket )
111
bool ResourceAkonadi::asyncSave( Ticket *ticket )
116
return d->doAsyncSave();
119
void ResourceAkonadi::insertAddressee( const Addressee &addr )
122
if ( d->insertAddressee( addr ) ) {
123
ResourceABC::insertAddressee( addr );
127
void ResourceAkonadi::removeAddressee( const Addressee &addr )
130
d->removeAddressee( addr );
132
ResourceABC::removeAddressee( addr );
135
void ResourceAkonadi::insertDistributionList( DistributionList *list )
137
kDebug(5700) << "identifier=" << list->identifier()
138
<< ", name=" << list->name();
140
if ( d->insertDistributionList( list ) ) {
141
ResourceABC::insertDistributionList( list );
145
void ResourceAkonadi::removeDistributionList( DistributionList *list )
147
kDebug(5700) << "identifier=" << list->identifier()
148
<< ", name=" << list->name();
150
d->removeDistributionList( list );
152
ResourceABC::removeDistributionList( list );
155
bool ResourceAkonadi::subresourceActive( const QString &subResource ) const
157
kDebug(5700) << "subResource" << subResource;
160
SubResource *resource = d->subResource( subResource );
161
if ( resource != 0 ) {
162
active = resource->isActive();
168
bool ResourceAkonadi::subresourceWritable( const QString &subResource ) const
170
kDebug(5700) << "subResource" << subResource;
172
bool writable = false;
173
SubResource *resource = d->subResource( subResource );
174
if ( resource != 0 ) {
175
writable = resource->isWritable();
181
QString ResourceAkonadi::subresourceLabel( const QString &subResource ) const
183
kDebug(5700) << "subResource" << subResource;
186
SubResource *resource = d->subResource( subResource );
187
if ( resource != 0 ) {
188
label = resource->label();
194
int ResourceAkonadi::subresourceCompletionWeight( const QString &subResource ) const
196
kDebug(5700) << "subResource" << subResource;
199
SubResource *resource = d->subResource( subResource );
200
if ( resource != 0 ) {
201
weight = resource->completionWeight();
207
QStringList ResourceAkonadi::subresources() const
209
kDebug(5700) << d->subResourceIdentifiers();
210
return d->subResourceIdentifiers();
213
QMap<QString, QString> ResourceAkonadi::uidToResourceMap() const
215
return d->uidToResourceMap();
218
StoreConfigIface &ResourceAkonadi::storeConfig()
223
void ResourceAkonadi::setSubresourceActive( const QString &subResource, bool active )
225
kDebug(5700) << "subResource" << subResource << ", active" << active;
227
// TODO check if this check for change isn't already handled in the private
228
bool changed = false;
230
SubResource *resource = d->subResource( subResource );
231
if ( resource != 0 ) {
232
if ( active != resource->isActive() ) {
233
resource->setActive( active );
239
addressBook()->emitAddressBookChanged();
242
void ResourceAkonadi::setSubresourceCompletionWeight( const QString &subResource, int weight )
244
kDebug(5700) << "subResource" << subResource << ", weight" << weight;
246
SubResource *resource = d->subResource( subResource );
247
if ( resource != 0 ) {
248
resource->setCompletionWeight( weight );
252
#include "resourceakonadi.moc"
253
// kate: space-indent on; indent-width 2; replace-tabs on;