You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
4.8 KiB
170 lines
4.8 KiB
15 years ago
|
/*
|
||
13 years ago
|
This file is part of tdepim.
|
||
15 years ago
|
|
||
|
Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
|
||
|
|
||
|
This program is free software; you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation; either version 2 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this program; if not, write to the Free Software
|
||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
#ifndef KABC_RESOURCEGROUPWISE_H
|
||
|
#define KABC_RESOURCEGROUPWISE_H
|
||
|
|
||
|
#include "soap/groupwiseserver.h"
|
||
|
|
||
|
#include <kabcresourcecached.h>
|
||
13 years ago
|
#include <tdepimmacros.h>
|
||
15 years ago
|
|
||
13 years ago
|
#include <libtdepim/progressmanager.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeio/job.h>
|
||
15 years ago
|
|
||
12 years ago
|
class TDEConfig;
|
||
15 years ago
|
|
||
|
class GroupwiseServer;
|
||
|
|
||
|
namespace KABC {
|
||
|
|
||
|
class GroupwisePrefs;
|
||
|
|
||
|
class KDE_EXPORT ResourceGroupwise : public ResourceCached
|
||
|
{
|
||
|
friend class ResourceGroupwiseConfig;
|
||
|
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
|
||
|
public:
|
||
12 years ago
|
ResourceGroupwise( const TDEConfig * );
|
||
15 years ago
|
ResourceGroupwise( const KURL &url,
|
||
15 years ago
|
const TQString &user, const TQString &password,
|
||
|
const TQStringList &readAddressBooks,
|
||
|
const TQString &writeAddressBook );
|
||
15 years ago
|
~ResourceGroupwise();
|
||
|
|
||
12 years ago
|
void readConfig( const TDEConfig * );
|
||
|
void writeConfig( TDEConfig * );
|
||
15 years ago
|
|
||
|
void readAddressBooks();
|
||
|
void writeAddressBooks();
|
||
|
|
||
|
void retrieveAddressBooks();
|
||
|
|
||
|
GroupwisePrefs *prefs() const { return mPrefs; }
|
||
|
|
||
|
GroupWise::AddressBook::List addressBooks() const { return mAddressBooks; }
|
||
|
|
||
|
bool doOpen();
|
||
|
void doClose();
|
||
|
|
||
|
Ticket *requestSaveTicket();
|
||
|
void releaseSaveTicket( Ticket* );
|
||
|
|
||
|
bool load();
|
||
|
bool asyncLoad();
|
||
|
bool save( Ticket * );
|
||
|
bool asyncSave( Ticket * );
|
||
|
enum SABState { Error, Stale, InSync, RefreshNeeded };
|
||
|
|
||
|
/**
|
||
|
* Clears the cached data, in memory and on disk
|
||
|
*/
|
||
|
void clearCache();
|
||
|
protected:
|
||
|
enum ResourceState { Start, FetchingSAB, SABUptodate, FetchingUAB, Uptodate };
|
||
|
enum BookType { System, User };
|
||
|
enum AccessMode { Fetch, Update };
|
||
|
void init();
|
||
|
void initGroupwise();
|
||
|
|
||
|
/* STATE CHANGING METHODS */
|
||
|
/**
|
||
|
* Begin asynchronously fetching the system address book , replacing the cached copy
|
||
|
*/
|
||
|
void fetchAddressBooks( const BookType booktype );
|
||
|
/**
|
||
|
* Asynchronously update the system address book
|
||
|
*/
|
||
|
void updateSystemAddressBook();
|
||
|
/**
|
||
|
* Wrap up the load sequence
|
||
|
*/
|
||
|
void loadCompleted();
|
||
|
|
||
|
/** HELPER METHODS **/
|
||
|
/**
|
||
|
* Check to see if a local download of the SAB already exists
|
||
|
*/
|
||
|
SABState systemAddressBookState();
|
||
|
/**
|
||
|
* Check if the resource is configured to download the SAB
|
||
|
*/
|
||
|
bool shouldFetchSystemAddressBook();
|
||
|
/**
|
||
|
* Check if the resource is configured to download personal address
|
||
|
* books
|
||
|
*/
|
||
|
bool shouldFetchUserAddressBooks();
|
||
|
|
||
|
/**
|
||
|
* Create a URL for a single addressbook access.
|
||
|
* To fetch an address book completely, use mode = Fetch
|
||
|
* To just update an addressbook, use mode = Update and give the ast sequence number already held
|
||
|
* If Update is given without a sequence number, the mode falls back to Fetch
|
||
|
*/
|
||
|
KURL createAccessUrl( BookType bookType, AccessMode mode, unsigned long lastSequenceNumber = 0, unsigned long lastPORebuildTime = 0 );
|
||
|
|
||
|
/**
|
||
|
* Persist the last known delta info. Call after the SAB is up to date.
|
||
|
*/
|
||
|
void storeDeltaInfo();
|
||
|
|
||
|
/**
|
||
|
* Check if the application which has loaded this resource is whitelisted
|
||
|
* to load the System Address Book (time-consuming)
|
||
|
*/
|
||
|
bool appIsWhiteListedForSAB();
|
||
|
|
||
|
private slots:
|
||
|
/** STATE CHANGING SLOTS **/
|
||
12 years ago
|
void fetchSABResult( TDEIO::Job * );
|
||
|
void fetchUABResult( TDEIO::Job * );
|
||
|
void updateSABResult( TDEIO::Job * );
|
||
15 years ago
|
/** DATA PROCESSING SLOTS **/
|
||
12 years ago
|
void slotReadJobData( TDEIO::Job *, const TQByteArray & );
|
||
|
void slotUpdateJobData( TDEIO::Job *, const TQByteArray & );
|
||
15 years ago
|
/** HELPER TQT_SLOT **/
|
||
12 years ago
|
void slotJobPercent( TDEIO::Job *job, unsigned long percent );
|
||
15 years ago
|
|
||
|
void cancelLoad();
|
||
|
private:
|
||
|
GroupwisePrefs *mPrefs;
|
||
|
GroupWise::AddressBook::List mAddressBooks;
|
||
|
|
||
|
GroupwiseServer *mServer;
|
||
|
|
||
12 years ago
|
TDEIO::TransferJob *mJob;
|
||
15 years ago
|
KPIM::ProgressItem *mProgress;
|
||
|
KPIM::ProgressItem *mSABProgress;
|
||
|
KPIM::ProgressItem *mUABProgress;
|
||
15 years ago
|
TQString mJobData;
|
||
15 years ago
|
ResourceState mState;
|
||
|
unsigned long mServerFirstSequence, mServerLastSequence, mServerLastPORebuildTime;
|
||
|
|
||
|
bool mLimitedMode;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|