summaryrefslogtreecommitdiffstats
path: root/kmail/kmailicalIface.h
blob: d57611035b891be71cdc16784e2f09ce25c2b31f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
    This file is part of KMail.
    Copyright (c) 2003 Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
    Copyright (c) 2003 - 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
    the Qt library by Trolltech AS, Norway (or with modified versions
    of Qt that use the same license as Qt), and distribute linked
    combinations including the two.  You must obey the GNU General
    Public License in all respects for all of the code used other than
    Qt.  If you modify this file, you may extend this exception to
    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 KMAILICALIFACE_H
#define KMAILICALIFACE_H

#include <dcopobject.h>
#include <tqstringlist.h>
#include <kurl.h>

// yes, this is this very header - but it tells dcopidl to include it
// in _stub.cpp and _skel.cpp files, to get the definition of the structs.
// ### dcopidlng bug: "" is copied verbatim...
// The kmail/ is so that it can be found by the resources easily
#include <kmail/kmailicalIface.h>

class KMailICalIface : virtual public DCOPObject
{
  K_DCOP

public:
k_dcop:
  struct SubResource {
    //dcopidl barfs on those constructors, but dcopidlng works
    SubResource() {} // for QValueList
    SubResource( const TQString& loc, const TQString& lab, bool rw, bool ar )
      : location( loc ), label( lab ), writable( rw ), alarmRelevant( ar ) {}
    TQString location; // unique
    TQString label;    // shown to the user
    bool writable;
    bool alarmRelevant;
  };

  /// The format of the mails containing other contents than actual mail
  /// (like contacts, calendar etc.)
  /// This is currently either ical/vcard, or XML.
  /// For actual mail folders this simply to know which resource handles it
  /// This enum matches the one defined in kmail.kcfg
  enum StorageFormat { StorageIcalVcard, StorageXML };

  /// This bitfield indicates which changes have been made in a folder, at syncing time.
  enum FolderChanges { NoChange = 0, Contents = 1, ACL = 2 };

  virtual bool isWritableFolder( const TQString& type,
                                 const TQString& resource ) = 0;

  virtual KMailICalIface::StorageFormat storageFormat( const TQString& resource ) = 0;

  virtual KURL getAttachment( const TQString& resource,
                              Q_UINT32 sernum,
                              const TQString& filename ) = 0;
  virtual TQString attachmentMimetype( const TQString &resource,
                                      Q_UINT32 sernum,
                                      const TQString &filename ) = 0;

  virtual TQStringList listAttachments( const TQString &resource, Q_UINT32 sernum ) = 0;

  /// Update a kolab storage entry. Returns the new mail serial number,
  /// or 0 if something went wrong. Can be used for adding as well.
  virtual Q_UINT32 update( const TQString& resource,
                           Q_UINT32 sernum,
                           const TQString& subject,
                           const TQString& plainTextBody,
                           const TQMap<TQCString, TQString>& customHeaders,
                           const TQStringList& attachmentURLs,
                           const TQStringList& attachmentMimetypes,
                           const TQStringList& attachmentNames,
                           const TQStringList& deletedAttachments ) = 0;

  virtual bool deleteIncidenceKolab( const TQString& resource,
                                     Q_UINT32 sernum ) = 0;

  /// Return the number of mails that need to be looked at by incidencesKolab.
  /// This allows to call incidencesKolab in chunks.
  virtual int incidencesKolabCount( const TQString& mimetype /*ignored*/,
                                    const TQString& resource ) = 0;

  virtual TQMap<Q_UINT32, TQString> incidencesKolab( const TQString& mimetype,
                                                   const TQString& resource,
                                                   int startIndex,
                                                   int nbMessages ) = 0;
  /**
   * Return list of subresources. @p contentsType is
   * Mail, Calendar, Contact, Note, Task or Journal
   */
  virtual TQValueList<KMailICalIface::SubResource> subresourcesKolab( const TQString& contentsType ) = 0;

   /**
   * Trigger the creation of a new resource folder with name @param resource
   * under parent @param.
   * @return success or failure
   */
  virtual bool addSubresource( const TQString& resource,
                               const TQString& parent,
                               const TQString& contentsType ) = 0;
  /**
   * Trigger the deletion of a new resource folder with id @param resource.
   * @return success or failure
   */
  virtual bool removeSubresource( const TQString& resource ) = 0;

  /**
   * Causes all resource folders of the given type to be synced with the server.
   */
  virtual bool triggerSync( const TQString & ) = 0;

k_dcop_signals:
  void incidenceAdded( const TQString& type, const TQString& folder,
                       Q_UINT32 sernum, int format, const TQString& entry );
  void asyncLoadResult( const TQMap<Q_UINT32, TQString>, const TQString& type,
                        const TQString& folder );
  void incidenceDeleted( const TQString& type, const TQString& folder,
                         const TQString& uid );
  void signalRefresh( const TQString& type, const TQString& folder );
  void subresourceAdded( const TQString& type, const TQString& resource,
                         const TQString& label, bool writable, bool alarmRelevant );
  void subresourceDeleted( const TQString& type, const TQString& resource );
};

inline TQDataStream& operator<<( TQDataStream& str, const KMailICalIface::SubResource& subResource )
{
  str << subResource.location << subResource.label << subResource.writable << subResource.alarmRelevant;
  return str;
}
inline TQDataStream& operator>>( TQDataStream& str, KMailICalIface::SubResource& subResource )
{
  str >> subResource.location >> subResource.label >> subResource.writable >> subResource.alarmRelevant;
  return str;
}

inline TQDataStream& operator<<( TQDataStream& str, const KMailICalIface::StorageFormat& format  )
{
  Q_UINT32 foo = format;
  str << foo;
  return str;
}

inline TQDataStream& operator>>( TQDataStream& str, KMailICalIface::StorageFormat& format  )
{
  Q_UINT32 foo;
  str >> foo;
  format = ( KMailICalIface::StorageFormat )foo;
  return str;
}


#endif