summaryrefslogtreecommitdiffstats
path: root/korn/imap_proto.h
blob: 4030c5cc59acf43ad4705b7878baa7a4efb07c16 (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
/*
 * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef MK_IMAP_PROTO_H
#define MK_IMAP_PROTO_H

#include "tdeio_proto.h"
#include <kurl.h>

/*
 * With deleting and IMAP4 is a small problem: messages don't looks as deleted, as they
 * apear with their full body. By deletion, tdeio_imap marks the message with FLAGS.SILENT as \DELETED.
 * If there is a commit-function, it should be installed in this file.
 */

/**
 * This class define the way a imap-protocol works.
 * It implements function of KIO_Protocol to make the kio-modules work with it,
 * as well as function of Protocol, to configure it.
 */
class Imap_Protocol : public KIO_Protocol
{
public:
	/**
	 * Constructor
	 */
	Imap_Protocol()  {}
	/**
	 * Destructor
	 */
	virtual ~Imap_Protocol() {}

	/**
	 * This function should return true if the protocol is connection-based.
	 * imap is, so this return "true".
	 *
	 * @return true
	 */
	virtual bool connectionBased() const { return true; }
	
	/**
	 * This gives the two names for a tdeioslave: imaps if ssl is selected, imap if not.
	 *
	 * @param ssl true if ssl is selected.
	 * @return "imaps" if ssl is true, "imap" otherwise
	 */
	virtual TQString protocol( bool ssl ) const { return ssl ? "imaps" : "imap"; }
	/**
	 * This name of this protocol: it goed in the configuration under this name.
	 *
	 * @return The name of this protocol: "imap"
	 */
	virtual TQString configName() const { return "imap"; }
	/**
	 * true, because it is possible to read subjects with imap.
	 *
	 * @return true
	 */
	virtual bool canReadSubjects() const { return true; }
	/**
	 * false, because deleting imap-mails doesn't work that well. See the commen above this class:
	 * metadata expunge=auto doesn't work.
	 * 
	 * @return false
	 */
	virtual bool canDeleteMail() const { return false; } //See comment above class: metadata expunge=auto doesn't work.
	/**
	 * true, because it is possible to read the whole message.
	 *
	 * @return true
	 */
	virtual bool canReadMail() const { return true; }

	/**
	 * This function returns the default port. This depends whether ssl is used or not.
	 * If ssl is used, it return 993, elsewise 143.
	 *
	 * @param ssl Is ssl used?
	 * @return 993 if ssl is true, false otherwise.
	 */
	virtual unsigned short defaultPort( bool ssl ) const { return ssl ? 993 : 143; }

	virtual TQStringList authList() const { return TQStringList::split( '|', "*|LOGIN|ANONYMOUS|CRAM-MD5", false); }
	//Could not test did, my server don't support other authentication methods.

	/**
	 * These function change the kurl and the metadata.
	 * In this case, "unseen" is added to the query to only list unlees kurls.
	 * These function are called in tdeio_*.cpp
	 */
	virtual void recheckKURL    ( KURL &kurl, TDEIO::MetaData & ) const { kurl.setQuery( "unseen" ); }
	virtual void readSubjectKURL( KURL &kurl, TDEIO::MetaData & ) const { kurl.setPath( kurl.path() + ";section=ENVELOPE" ); }
	virtual void deleteMailConnectKURL( KURL &, TDEIO::MetaData & metadata ) const { metadata.insert( "expunge", "auto" ); }
	
	/**
	 * This functions gives a list of names of groupboxes which are to be set in the configuration.
	 * In this case, two elements are added: "Server" and "Identity".
	 *
	 * @param list A list to add the name of groupboxes in.
	 */
	virtual void configFillGroupBoxes( TQStringList* list ) const;
	/**
	 * This function adds elements to the groupbox.
	 *
	 * @param vector The vector containing the groupBoxes
	 * @param object The object to connect signals to
	 * @param ptrlist A list with object which is filled in this function. The list must already be created.
	 */
	virtual void configFields( TQPtrVector< TQWidget >* vector, const TQObject* object, TQPtrList< AccountInput >* ptrlist ) const;
	/**
	 * This function is used to change the configuration.
	 * In the case, the metadata-key is splitted out, and put in the @p metadata parameter.
	 *
	 * @param map The mapping containing the configuration. This object can change in this function.
	 * @param metadata An empty mapping at the begin, a mapping containing metadata at the end.
	 */
        virtual void readEntries( TQMap< TQString, TQString >* map, TQMap< TQString, TQString >* metadata ) const;
	/**
	 * This function edits writeEntry. It merge things back to a metadata-key and adds this
	 * key to the configuration.
	 *
	 * @param map The mapping which contains the information to be written to a configuarion file.
	 *	the contents of this mapping can change in this function.
	 */
        virtual void writeEntries( TQMap< TQString, TQString >* map ) const;
};

#endif