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.
110 lines
3.0 KiB
110 lines
3.0 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.
|
||
|
|--------------------------------------------------------------------------
|
||
|
| Remote address book writing class.
|
||
|
========================================================================*/
|
||
|
|
||
|
/*=========================================================================
|
||
|
| INCLUDES
|
||
|
========================================================================*/
|
||
|
|
||
|
#ifndef KCARDDAV_WRITER_H
|
||
|
#define KCARDDAV_WRITER_H
|
||
|
|
||
|
#include "job.h"
|
||
|
|
||
|
#include <string>
|
||
15 years ago
|
#include <tqstring.h>
|
||
|
#include <tqdatetime.h>
|
||
15 years ago
|
|
||
|
namespace KABC {
|
||
|
|
||
|
/*=========================================================================
|
||
|
| CLASS
|
||
|
========================================================================*/
|
||
|
|
||
|
/**
|
||
|
* Calendar writer.
|
||
|
*/
|
||
|
class CardDavWriter : public CardDavJob {
|
||
|
|
||
|
public:
|
||
|
|
||
|
/**
|
||
|
* @param url URL to load.
|
||
|
*/
|
||
15 years ago
|
CardDavWriter(const TQString& url = TQString()) :
|
||
15 years ago
|
CardDavJob(url)
|
||
|
{
|
||
|
clearObjects();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Sets the information about added incidences writer should send to server.
|
||
|
* @param s icalendar-formatted string consists of all added incidences plus necessary calendar info.
|
||
|
* May be an empty string, which means there is no added incidences to send.
|
||
|
*/
|
||
15 years ago
|
void setAddedObjects(const TQString& s) {
|
||
15 years ago
|
mAdded = s;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Sets the information about changed incidences writer should send to server.
|
||
|
* @param s icalendar-formatted string consists of all changed incidences plus necessary calendar info.
|
||
|
* May be an empty string, which means there is no changed incidences to send.
|
||
|
*/
|
||
15 years ago
|
void setChangedObjects(const TQString& s) {
|
||
15 years ago
|
mChanged = s;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Sets the information about deleted incidences writer should send to server.
|
||
|
* @param s icalendar-formatted string consists of all deleted incidences plus necessary calendar info.
|
||
|
* May be an empty string, which means there is no deleted incidences to send.
|
||
|
*/
|
||
15 years ago
|
void setDeletedObjects(const TQString& s) {
|
||
15 years ago
|
mDeleted = s;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Clear all the information previously set.
|
||
|
*/
|
||
|
void clearObjects() {
|
||
|
setAddedObjects("");
|
||
|
setChangedObjects("");
|
||
|
setDeletedObjects("");
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
|
||
|
virtual int runJob(runtime_info* caldavRuntime);
|
||
|
|
||
|
virtual void cleanJob();
|
||
|
|
||
|
/// Just a wrapper above libcaldav functions.
|
||
|
template<typename Operation>
|
||
15 years ago
|
int pushObjects(const TQString& data, Operation op, int okCode, runtime_info* RT) {
|
||
15 years ago
|
int r = okCode;
|
||
|
if (!data.isNull() && !data.isEmpty()) {
|
||
|
r = op(std::string(data.ascii()).c_str(), std::string(url().ascii()).c_str(), RT);
|
||
|
}
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
|
||
15 years ago
|
TQString mAdded;
|
||
|
TQString mChanged;
|
||
|
TQString mDeleted;
|
||
15 years ago
|
};
|
||
|
|
||
|
} // namespace KABC
|
||
|
|
||
|
#endif // KCARDDAV_WRITER_H
|
||
|
|