~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to mailcommon/expirejob.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C++ -*-
 
2
 * Copyright (c) 2004 David Faure <faure@kde.org>
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; version 2 of the License
 
7
 *
 
8
 *  This program is distributed in the hope that it will be useful,
 
9
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 *  GNU General Public License for more details.
 
12
 *
 
13
 *  You should have received a copy of the GNU General Public License
 
14
 *  along with this program; if not, write to the Free Software
 
15
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
16
 *
 
17
 *  In addition, as a special exception, the copyright holders give
 
18
 *  permission to link the code of this program with any edition of
 
19
 *  the Qt library by Trolltech AS, Norway (or with modified versions
 
20
 *  of Qt that use the same license as Qt), and distribute linked
 
21
 *  combinations including the two.  You must obey the GNU General
 
22
 *  Public License in all respects for all of the code used other than
 
23
 *  Qt.  If you modify this file, you may extend this exception to
 
24
 *  your version of the file, but you are not obligated to do so.  If
 
25
 *  you do not wish to do so, delete this exception statement from
 
26
 *  your version.
 
27
 */
 
28
#ifndef MAILCOMMON_EXPIREJOB_H
 
29
#define MAILCOMMON_EXPIREJOB_H
 
30
 
 
31
#include "jobscheduler.h"
 
32
 
 
33
#include <akonadi/collection.h>
 
34
#include <akonadi/item.h>
 
35
 
 
36
#include <QList>
 
37
 
 
38
class KJob;
 
39
 
 
40
namespace MailCommon {
 
41
 
 
42
class Kernel;
 
43
 
 
44
class ExpireJob : public ScheduledJob
 
45
{
 
46
  Q_OBJECT
 
47
public:
 
48
  ExpireJob( const Akonadi::Collection& folder, bool immediate );
 
49
  virtual ~ExpireJob();
 
50
 
 
51
  virtual void execute();
 
52
  virtual void kill();
 
53
 
 
54
private slots:
 
55
  void slotDoWork();
 
56
  void slotMessagesMoved( KJob *job );
 
57
  void itemFetchResult( KJob* job );
 
58
 
 
59
private:
 
60
  void done();
 
61
 
 
62
private:
 
63
  QList<Akonadi::Item> mRemovedMsgs;
 
64
  int mCurrentIndex;
 
65
  int mMaxUnreadTime;
 
66
  int mMaxReadTime;
 
67
  bool mFolderOpen;
 
68
  Akonadi::Collection mMoveToFolder;
 
69
};
 
70
 
 
71
/// A scheduled "expire mails in this folder" task.
 
72
class ScheduledExpireTask : public ScheduledTask
 
73
{
 
74
public:
 
75
  /// If immediate is set, the job will execute synchronously. This is used when
 
76
  /// the user requests explicitly that the operation should happen immediately.
 
77
  ScheduledExpireTask( const Akonadi::Collection& folder, bool immediate )
 
78
    : ScheduledTask( folder, immediate ) {}
 
79
  virtual ~ScheduledExpireTask() {}
 
80
  virtual ScheduledJob* run() {
 
81
    return folder().isValid() ? new ExpireJob( folder(), isImmediate() ) : 0;
 
82
  }
 
83
  virtual int taskTypeId() const { return 1; }
 
84
};
 
85
 
 
86
} // namespace
 
87
 
 
88
#endif
 
89