maillistdrag.h
00001 /* 00002 This file is part of libtdepim. 00003 00004 Copyright (c) 2003 Don Sanders <sanders@kde.org> 00005 Copyright (c) 2005 George Staikos <staikos@kde.org. 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 #ifndef maillistdrag_h 00023 #define maillistdrag_h 00024 00025 #include "tqdragobject.h" 00026 #include "tqvaluelist.h" 00027 #include "tqglobal.h" 00028 #include "time.h" 00029 00030 #include <tdepimmacros.h> 00031 00045 namespace KPIM { 00046 00047 class KDE_EXPORT MailSummary 00048 { 00049 public: 00050 MailSummary( TQ_UINT32 serialNumber, TQString messageId, TQString subject, 00051 TQString from, TQString to, time_t date ); 00052 MailSummary() {} 00053 ~MailSummary() {} 00054 00055 /*** Set fields for this mail summary ***/ 00056 void set( TQ_UINT32, TQString, TQString, TQString, TQString, time_t ); 00057 00058 /*** KMail unique identification number ***/ 00059 TQ_UINT32 serialNumber() const; 00060 00061 /*** MD5 checksum of message identification string ***/ 00062 TQString messageId(); 00063 00064 /*** Subject of the message including prefixes ***/ 00065 TQString subject(); 00066 00067 /*** Simplified from address ***/ 00068 TQString from(); 00069 00071 TQString to(); 00072 00073 /*** Date the message was sent ***/ 00074 time_t date(); 00075 00076 private: 00077 TQ_UINT32 mSerialNumber; 00078 TQString mMessageId, mSubject, mFrom, mTo; 00079 time_t mDate; 00080 }; 00081 00082 // List of mail summaries 00083 typedef TQValueList<MailSummary> MailList; 00084 00085 // Object for the drag object to call-back for message fulltext 00086 class KDE_EXPORT MailTextSource { 00087 public: 00088 MailTextSource() {} 00089 virtual ~MailTextSource() {} 00090 00091 virtual TQCString text(TQ_UINT32 serialNumber) const = 0; 00092 }; 00093 00094 // Drag and drop object for mails 00095 class KDE_EXPORT MailListDrag : public TQStoredDrag 00096 { 00097 public: 00098 // Takes ownership of "src" and deletes it when done 00099 MailListDrag( MailList, TQWidget * parent = 0, MailTextSource *src = 0 ); 00100 ~MailListDrag(); 00101 00102 const char *format(int i) const; 00103 00104 bool provides(const char *mimeType) const; 00105 00106 TQByteArray encodedData(const char *) const; 00107 00108 /* Reset the list of mail summaries */ 00109 void setMailList( MailList ); 00110 00111 /* The format for this drag - "x-kmail-drag/message-list" */ 00112 static const char* format(); 00113 00114 /* Returns TRUE if the information in e can be decoded into a TQString; 00115 otherwsie returns FALSE */ 00116 static bool canDecode( TQMimeSource* e ); 00117 00118 /* Attempts to decode the dropped information; 00119 Returns TRUE if successful; otherwise return false */ 00120 static bool decode( TQDropEvent* e, MailList& s ); 00121 00122 /* Attempts to decode the serialNumbers of the dropped information; 00123 Returns TRUE if successful; otherwise return false */ 00124 static bool decode( TQDropEvent* e, TQByteArray& a ); 00125 00126 /* Attempts to decode the encoded MailList; 00127 Returns TRUE if successful; otherwise return false */ 00128 static bool decode( TQByteArray& a, MailList& s ); 00129 00130 private: 00131 MailTextSource *_src; 00132 }; 00133 00134 } 00135 #endif /*maillistdrag_h*/