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.
177 lines
3.9 KiB
177 lines
3.9 KiB
15 years ago
|
/*=========================================================================
|
||
|
| KCardDAV
|
||
|
|--------------------------------------------------------------------------
|
||
|
| (c) 2010 Timothy Pearson
|
||
|
|
|
||
|
| This project is released under the GNU General Public License.
|
||
|
| Please see the file COPYING for more details.
|
||
|
|--------------------------------------------------------------------------
|
||
|
| Job class for accessing remote address books.
|
||
|
========================================================================*/
|
||
|
|
||
|
/*=========================================================================
|
||
|
| INCLUDES
|
||
|
========================================================================*/
|
||
|
|
||
|
#ifndef KABCDAV_JOB_H
|
||
|
#define KABCDAV_JOB_H
|
||
|
|
||
15 years ago
|
#include <tqthread.h>
|
||
|
#include <tqstring.h>
|
||
|
#include <tqdatetime.h>
|
||
|
#include <tqapplication.h>
|
||
15 years ago
|
|
||
|
extern "C" {
|
||
14 years ago
|
#include <carddav.h>
|
||
15 years ago
|
}
|
||
|
|
||
|
namespace KABC {
|
||
|
|
||
|
/*=========================================================================
|
||
|
| CLASS
|
||
|
========================================================================*/
|
||
|
|
||
|
/**
|
||
|
* Calendar job.
|
||
|
*/
|
||
15 years ago
|
class CardDavJob : public TQThread {
|
||
15 years ago
|
|
||
|
public:
|
||
|
|
||
|
/**
|
||
|
* @param url URL to load.
|
||
|
*/
|
||
15 years ago
|
CardDavJob(const TQString& url = TQString());
|
||
15 years ago
|
|
||
|
virtual ~CardDavJob();
|
||
|
|
||
|
/**
|
||
|
* Sets a new URL to load.
|
||
|
*/
|
||
15 years ago
|
virtual void setUrl(const TQString& s) {
|
||
15 years ago
|
mUrl = s;
|
||
|
}
|
||
|
|
||
15 years ago
|
/**
|
||
|
* Sets whether to use UID (false) or URI (true) as an object's unique identifier
|
||
|
*/
|
||
|
virtual void setUseURI(bool b) {
|
||
|
mUseURI = b;
|
||
|
}
|
||
|
|
||
15 years ago
|
/**
|
||
13 years ago
|
* Sets the parent qobject.
|
||
15 years ago
|
*/
|
||
15 years ago
|
virtual void setParent(TQObject *s) {
|
||
15 years ago
|
mParent = s;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Sets the type (0==read, 1==write)
|
||
|
*/
|
||
|
virtual void setType(int s) {
|
||
|
mType = s;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return URL to load.
|
||
|
*/
|
||
15 years ago
|
virtual TQString url() const {
|
||
15 years ago
|
return mUrl;
|
||
|
}
|
||
|
|
||
15 years ago
|
/**
|
||
|
* @return whether to use UID (false) or URI (true) as an object's unique identifier
|
||
|
*/
|
||
|
virtual bool getUseURI() {
|
||
|
return mUseURI;
|
||
|
}
|
||
|
|
||
15 years ago
|
/**
|
||
13 years ago
|
* @return parent object
|
||
15 years ago
|
*/
|
||
13 years ago
|
virtual TQObject *parent() {
|
||
15 years ago
|
return mParent;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return type
|
||
|
*/
|
||
|
virtual int type() {
|
||
|
return mType;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return true if downloading process failed.
|
||
|
*/
|
||
|
virtual bool error() const {
|
||
|
return mError;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return an error string.
|
||
|
*/
|
||
15 years ago
|
virtual TQString errorString() const {
|
||
15 years ago
|
return mErrorString;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return an error number.
|
||
|
*/
|
||
|
virtual long errorNumber() const {
|
||
|
return mErrorNumber;
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
|
||
|
virtual void run();
|
||
|
|
||
|
/**
|
||
|
* Main run method for jobs. Jobs should not override run() method.
|
||
|
* Instead of this they should override this one.
|
||
|
* @param carddavRuntime specific libcarddav runtime information. This pointer should not be saved for the usage
|
||
|
* outside of runJob.
|
||
|
* @return libcarddav response code (see CARDDAV_RESPONSE)
|
||
|
*/
|
||
|
virtual int runJob(runtime_info* carddavRuntime) = 0;
|
||
|
|
||
|
/**
|
||
|
* Some cleaning. Jobs may (and usually should) override this method.
|
||
|
*/
|
||
|
virtual void cleanJob() {
|
||
|
mError = false;
|
||
|
mErrorString = "";
|
||
|
mErrorNumber = 0;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Sets an error string to @p err. Also sets an error flag.
|
||
|
*/
|
||
15 years ago
|
void setErrorString(const TQString& str, const long number);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Process an error.
|
||
|
* Subclasses can overwrite this method, if some special error message handling
|
||
|
* should be done. Call setErrorString() to set the error after processing is done.
|
||
|
* @param err error structure.
|
||
|
*/
|
||
|
virtual void processError(const carddav_error* err);
|
||
|
|
||
|
private:
|
||
|
|
||
15 years ago
|
TQString mUrl;
|
||
15 years ago
|
bool mError;
|
||
15 years ago
|
TQString mErrorString;
|
||
15 years ago
|
long mErrorNumber;
|
||
15 years ago
|
TQObject *mParent;
|
||
15 years ago
|
int mType;
|
||
15 years ago
|
bool mUseURI;
|
||
15 years ago
|
|
||
|
void enableCarddavDebug(runtime_info*);
|
||
|
};
|
||
|
|
||
|
} // namespace KABC
|
||
|
|
||
|
#endif // KABCDAV_JOB_H
|
||
|
|