libtdepim

maillistdrag.h
1 /*
2  This file is part of libtdepim.
3 
4  Copyright (c) 2003 Don Sanders <sanders@kde.org>
5  Copyright (c) 2005 George Staikos <staikos@kde.org.
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 #ifndef maillistdrag_h
23 #define maillistdrag_h
24 
25 #include "tqdragobject.h"
26 #include "tqvaluelist.h"
27 #include "tqglobal.h"
28 #include "time.h"
29 
30 #include <tdemacros.h>
31 
45 namespace KPIM {
46 
47 class TDE_EXPORT MailSummary
48 {
49 public:
50  MailSummary( TQ_UINT32 serialNumber, TQString messageId, TQString subject,
51  TQString from, TQString to, time_t date );
52  MailSummary() {}
53  ~MailSummary() {}
54 
55  /*** Set fields for this mail summary ***/
56  void set( TQ_UINT32, TQString, TQString, TQString, TQString, time_t );
57 
58  /*** KMail unique identification number ***/
59  TQ_UINT32 serialNumber() const;
60 
61  /*** MD5 checksum of message identification string ***/
62  TQString messageId();
63 
64  /*** Subject of the message including prefixes ***/
65  TQString subject();
66 
67  /*** Simplified from address ***/
68  TQString from();
69 
71  TQString to();
72 
73  /*** Date the message was sent ***/
74  time_t date();
75 
76 private:
77  TQ_UINT32 mSerialNumber;
78  TQString mMessageId, mSubject, mFrom, mTo;
79  time_t mDate;
80 };
81 
82 // List of mail summaries
83 typedef TQValueList<MailSummary> MailList;
84 
85 // Object for the drag object to call-back for message fulltext
86 class TDE_EXPORT MailTextSource {
87 public:
88  MailTextSource() {}
89  virtual ~MailTextSource() {}
90 
91  virtual TQCString text(TQ_UINT32 serialNumber) const = 0;
92 };
93 
94 // Drag and drop object for mails
95 class TDE_EXPORT MailListDrag : public TQStoredDrag
96 {
97 public:
98  // Takes ownership of "src" and deletes it when done
99  MailListDrag( MailList, TQWidget * parent = 0, MailTextSource *src = 0 );
100  ~MailListDrag();
101 
102  const char *format(int i) const;
103 
104  bool provides(const char *mimeType) const;
105 
106  TQByteArray encodedData(const char *) const;
107 
108  /* Reset the list of mail summaries */
109  void setMailList( MailList );
110 
111  /* The format for this drag - "x-kmail-drag/message-list" */
112  static const char* format();
113 
114  /* Returns TRUE if the information in e can be decoded into a TQString;
115  otherwsie returns FALSE */
116  static bool canDecode( TQMimeSource* e );
117 
118  /* Attempts to decode the dropped information;
119  Returns TRUE if successful; otherwise return false */
120  static bool decode( TQDropEvent* e, MailList& s );
121 
122  /* Attempts to decode the serialNumbers of the dropped information;
123  Returns TRUE if successful; otherwise return false */
124  static bool decode( TQDropEvent* e, TQByteArray& a );
125 
126  /* Attempts to decode the encoded MailList;
127  Returns TRUE if successful; otherwise return false */
128  static bool decode( TQByteArray& a, MailList& s );
129 
130 private:
131  MailTextSource *_src;
132 };
133 
134 }
135 #endif /*maillistdrag_h*/
TDEPIM classes for drag and drop of mails.