summaryrefslogtreecommitdiffstats
path: root/kmailcvt/filters.hxx
blob: b680ab5e047c8ea9e35e40536f097e275c5f128e (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
/***************************************************************************
                          filters.hxx  -  description
                             -------------------
    begin                : Fri Jun 30 2000
    copyright            : (C) 2000 by Hans Dijkema
    email                : kmailcvt@hum.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef FILTERS_HXX
#define FILTERS_HXX

#ifndef MAX_LINE
#define MAX_LINE 4096
#endif

#include <tqcombobox.h>
#include <tqprogressbar.h>
#include <tqptrlist.h>
#include <tqlistbox.h>
#include <tqlabel.h>

#include "kimportpagedlg.h"

class FilterInfo
{
  public:
    FilterInfo(KImportPageDlg *dlg, TQWidget *parent, bool _removeDupMsg);
   ~FilterInfo();

    void seStatusMsg( const TQString& status );
    void setFrom( const TQString& from );
    void setTo( const TQString& to );
    void setCurrent( const TQString& current );
    void setCurrent( int percent = 0 );
    void setOverall( int percent = 0 );
    void addLog( const TQString& log );
    void clear();
    void alert( const TQString& message );
    static void terminateASAP();
    bool shouldTerminate();

    TQWidget *parent() { return m_parent; }
    bool removeDupMsg;

  private:
    KImportPageDlg *m_dlg;
    TQWidget      *m_parent;
    static bool s_terminateASAP;
};

class Filter
{
  public:
    Filter( const TQString& name, const TQString& author,
            const TQString& info = TQString::null );
    virtual ~Filter() {}
    virtual void import( FilterInfo* ) = 0;
    TQString author() const { return m_author; }
    TQString name() const { return m_name; }
    TQString info() const { return m_info; }

    virtual bool needsSecondPage();

    int count_duplicates; //to count all duplicate messages

  protected:
    void showKMailImportArchiveDialog( FilterInfo* info );
    bool addMessage( FilterInfo* info,
                     const TQString& folder,
                     const TQString& msgFile,
                     const TQString& msgStatusFlags = TQString());
    bool addMessage_fastImport( FilterInfo* info,
                     		    const TQString& folder,
                     		    const TQString& msgFile,
                                const TQString& msgStatusFlags = TQString());
  private:
    TQString m_name;
    TQString m_author;
    TQString m_info;
};



/** 
* Glorified QString[N] for (a) understandability (b) older gcc compatibility. 
*/
template <unsigned int size> class FolderStructureBase
{
public:
	typedef TQString NString[size];
	/** Constructor. Need a default constructor for TQValueList. */
	FolderStructureBase() {} ;

	/** Constructor. Turn N QStrings into a folder structure 
	*   description. 
	*/
	FolderStructureBase(const NString &s)
	{
	    for(unsigned int i=0; i<size; i++) d[i]=s[i];
	} ;

	/** Copy Constructor. */
	FolderStructureBase(const FolderStructureBase &s)
	{
	    for(unsigned int i=0; i<size; i++) d[i]=s[i];
	} ;

	/** Assignment operator. Does the same thing as
	*   the copy constructor.
	*/
	FolderStructureBase &operator =(const FolderStructureBase &s)
	{
	    for(unsigned int i=0; i<size; i++) d[i]=s[i];
	    return *this;
	} ;

	/** Access the different fields. There doesn't seem to
	*   be a real semantics for the fields.
	*/
	const TQString operator [](unsigned int i) const
	{
	    if (i<size) return d[i]; else return TQString::null;
	} ;

	/** Access the different fields, for writing. */
	TQString &operator [](unsigned int i)
	{
	    Q_ASSERT(i<size);
	    if (i<size) return d[i]; else return d[0];
	} ;
private:
	TQString d[size];
} ;

#endif