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.
206 lines
8.1 KiB
206 lines
8.1 KiB
15 years ago
|
/*
|
||
|
This file is part of the kolab resource - the implementation of the
|
||
|
Kolab storage format. See www.kolab.org for documentation on this.
|
||
|
|
||
|
Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library 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
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
|
||
|
In addition, as a special exception, the copyright holders give
|
||
|
permission to link the code of this program with any edition of
|
||
14 years ago
|
the TQt library by Trolltech AS, Norway (or with modified versions
|
||
|
of TQt that use the same license as TQt), and distribute linked
|
||
15 years ago
|
combinations including the two. You must obey the GNU General
|
||
|
Public License in all respects for all of the code used other than
|
||
14 years ago
|
TQt. If you modify this file, you may extend this exception to
|
||
15 years ago
|
your version of the file, but you are not obligated to do so. If
|
||
|
you do not wish to do so, delete this exception statement from
|
||
|
your version.
|
||
|
*/
|
||
|
|
||
|
#ifndef RESOURCEKOLABBASE_H
|
||
|
#define RESOURCEKOLABBASE_H
|
||
|
|
||
15 years ago
|
#include <tqstring.h>
|
||
|
#include <tqmap.h>
|
||
|
#include <tqstringlist.h>
|
||
15 years ago
|
|
||
|
#include "subresource.h"
|
||
|
#include <kmail/kmailicalIface.h>
|
||
|
|
||
15 years ago
|
class TQCString;
|
||
15 years ago
|
class KURL;
|
||
|
|
||
|
namespace Kolab {
|
||
|
|
||
14 years ago
|
enum ResourceType { Tasks, Events, Incidences, Contacts, Notes };
|
||
|
|
||
15 years ago
|
class KMailConnection;
|
||
|
|
||
|
/**
|
||
|
This class provides the kmail connectivity for IMAP resources.
|
||
|
|
||
|
The main methods are:
|
||
|
|
||
|
fromKMail...() : calls made _by_ KMail to add/delete data representation in the resource.
|
||
|
|
||
|
kmail...() : calls _into_ KMail made by the resource.
|
||
|
|
||
|
e.g. fromKMailAddIncidence() is called by KMail
|
||
|
when a new iCard is there after an IMAP sync.
|
||
|
|
||
|
By calling fromKMailAddIncidence() KMail notifies
|
||
|
the resource about the new incidence, so in the
|
||
|
addressbook a new address will appear like magic.
|
||
|
|
||
|
e.g. kmailAddIncidence() is called by the resource when
|
||
|
iCard must be stored by KMail because the user has added
|
||
|
an address in the addressbook.
|
||
|
|
||
|
By calling kmailAddIncidence() the resource causes
|
||
|
KMail to store the new address in the (IMAP) folder.
|
||
|
*/
|
||
|
class ResourceKolabBase {
|
||
|
public:
|
||
15 years ago
|
ResourceKolabBase( const TQCString& objId );
|
||
15 years ago
|
virtual ~ResourceKolabBase();
|
||
|
|
||
|
// These are the methods called by KMail when the resource changes
|
||
15 years ago
|
virtual bool fromKMailAddIncidence( const TQString& type,
|
||
|
const TQString& resource,
|
||
14 years ago
|
TQ_UINT32 sernum,
|
||
15 years ago
|
int format,
|
||
15 years ago
|
const TQString& data ) = 0;
|
||
|
virtual void fromKMailDelIncidence( const TQString& type,
|
||
|
const TQString& resource,
|
||
|
const TQString& xml ) = 0;
|
||
|
virtual void fromKMailRefresh( const TQString& type,
|
||
|
const TQString& resource ) = 0;
|
||
|
virtual void fromKMailAddSubresource( const TQString& type,
|
||
|
const TQString& resource,
|
||
|
const TQString& label,
|
||
15 years ago
|
bool writable,
|
||
|
bool alarmRelevant ) = 0;
|
||
15 years ago
|
virtual void fromKMailDelSubresource( const TQString& type,
|
||
|
const TQString& resource ) = 0;
|
||
15 years ago
|
|
||
14 years ago
|
virtual void fromKMailAsyncLoadResult( const TQMap<TQ_UINT32, TQString>& map,
|
||
15 years ago
|
const TQString& type,
|
||
|
const TQString& folder ) = 0;
|
||
15 years ago
|
protected:
|
||
|
/// Do the connection to KMail.
|
||
|
bool connectToKMail() const;
|
||
|
|
||
|
// These are the KMail dcop function connections. The docs here say
|
||
|
// "Get", which here means that the first argument is the return arg
|
||
|
|
||
15 years ago
|
/// List all folders with a certain contentsType. Returns a TQMap with
|
||
15 years ago
|
/// resourcename/writable pairs
|
||
15 years ago
|
bool kmailSubresources( TQValueList<KMailICalIface::SubResource>& lst,
|
||
|
const TQString& contentsType ) const;
|
||
15 years ago
|
|
||
|
/// Get the number of messages in this folder.
|
||
|
/// Used to iterate over kmailIncidences by chunks
|
||
15 years ago
|
bool kmailIncidencesCount( int& count, const TQString& mimetype,
|
||
|
const TQString& resource ) const;
|
||
15 years ago
|
|
||
|
/// Get the mimetype attachments from a chunk of messages from this folder.
|
||
15 years ago
|
/// Returns a TQMap with serialNumber/attachment pairs.
|
||
14 years ago
|
bool kmailIncidences( TQMap<TQ_UINT32, TQString>& lst, const TQString& mimetype,
|
||
15 years ago
|
const TQString& resource,
|
||
15 years ago
|
int startIndex,
|
||
|
int nbMessages ) const;
|
||
|
|
||
15 years ago
|
bool kmailTriggerSync( const TQString& contentType ) const;
|
||
15 years ago
|
|
||
|
public: // for Contact
|
||
|
/// Get an attachment from a mail. Returns a URL to it. This can
|
||
|
/// be called by the resource after obtaining the incidence.
|
||
|
/// The resource must delete the temp file.
|
||
15 years ago
|
bool kmailGetAttachment( KURL& url, const TQString& resource,
|
||
14 years ago
|
TQ_UINT32 sernum,
|
||
15 years ago
|
const TQString& filename ) const;
|
||
15 years ago
|
|
||
|
/** Get the mimetype of the specified attachment. */
|
||
15 years ago
|
bool kmailAttachmentMimetype( TQString &mimeType, TQString &resource,
|
||
14 years ago
|
TQ_UINT32 sernum, const TQString &filename ) const;
|
||
15 years ago
|
|
||
|
/// List all attachments of a mail.
|
||
15 years ago
|
bool kmailListAttachments( TQStringList &list, const TQString &resource,
|
||
14 years ago
|
TQ_UINT32 sernum ) const;
|
||
15 years ago
|
|
||
|
protected:
|
||
|
/// Delete an incidence.
|
||
14 years ago
|
bool kmailDeleteIncidence( const TQString& resource, TQ_UINT32 sernum );
|
||
15 years ago
|
|
||
15 years ago
|
KMailICalIface::StorageFormat kmailStorageFormat( const TQString& folder ) const;
|
||
15 years ago
|
|
||
15 years ago
|
typedef TQMap<TQCString, TQString> CustomHeaderMap;
|
||
15 years ago
|
|
||
|
/// Update an incidence. The list of attachments are URLs.
|
||
|
/// The parameter sernum is updated with the right KMail serial number
|
||
14 years ago
|
bool kmailUpdate( const TQString& resource, TQ_UINT32& sernum,
|
||
15 years ago
|
const TQString& xml,
|
||
|
const TQString& mimetype,
|
||
|
const TQString& subject,
|
||
15 years ago
|
const CustomHeaderMap& customHeaders = CustomHeaderMap(),
|
||
15 years ago
|
const TQStringList& attachmentURLs = TQStringList(),
|
||
|
const TQStringList& attachmentMimetypes = TQStringList(),
|
||
|
const TQStringList& attachmentNames = TQStringList(),
|
||
|
const TQStringList& deletedAttachments = TQStringList() );
|
||
15 years ago
|
|
||
13 years ago
|
bool kmailAddSubresource( const TQString& resource, const TQString& parent,
|
||
15 years ago
|
const TQString& contentsType );
|
||
|
bool kmailRemoveSubresource( const TQString& resource );
|
||
15 years ago
|
|
||
|
/// Get the full path of the config file.
|
||
15 years ago
|
TQString configFile( const TQString& type ) const;
|
||
15 years ago
|
|
||
|
/// If only one of these is writable, return that. Otherwise return null.
|
||
14 years ago
|
TQString findWritableResource( const ResourceType &type,
|
||
|
const ResourceMap& resources,
|
||
14 years ago
|
const TQString& text = TQString() );
|
||
15 years ago
|
|
||
14 years ago
|
enum ErrorCode {
|
||
|
NoError,
|
||
|
NoWritableFound, /**< No writable resource is available */
|
||
|
UserCancel /**< User canceled the operation */
|
||
|
};
|
||
|
ErrorCode mErrorCode;
|
||
|
|
||
15 years ago
|
bool mSilent;
|
||
|
|
||
|
/**
|
||
|
* This is used to store a mapping from the XML UID to the KMail
|
||
|
* serial number of the mail it's stored in. That provides a quick way
|
||
|
* to access the storage in KMail.
|
||
|
*/
|
||
|
UidMap mUidMap;
|
||
|
|
||
|
/// This is used to distinguish operations triggered by the user,
|
||
|
/// from operations triggered by KMail
|
||
15 years ago
|
TQStringList mUidsPendingAdding;
|
||
|
TQStringList mUidsPendingDeletion;
|
||
|
TQStringList mUidsPendingUpdate;
|
||
15 years ago
|
|
||
|
private:
|
||
|
mutable KMailConnection* mConnection;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif // RESOURCEKOLABBASE_H
|