~ubuntu-branches/ubuntu/quantal/akonadi/quantal

« back to all changes in this revision

Viewing changes to server/src/storagejanitor.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-01-24 23:43:13 UTC
  • mto: (3.1.12 sid)
  • mto: This revision was merged to the branch mainline in revision 69.
  • Revision ID: package-import@ubuntu.com-20120124234313-ooald4uh9w8jilyw
Tags: upstream-1.7.0
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2011 Volker Krause <vkrause@kde.org>
 
3
 
 
4
    This library is free software; you can redistribute it and/or modify it
 
5
    under the terms of the GNU Library General Public License as published by
 
6
    the Free Software Foundation; either version 2 of the License, or (at your
 
7
    option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful, but WITHOUT
 
10
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 
12
    License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to the
 
16
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
17
    02110-1301, USA.
 
18
*/
 
19
 
 
20
#ifndef STORAGEJANITOR_H
 
21
#define STORAGEJANITOR_H
 
22
 
 
23
#include <QThread>
 
24
#include <qdbusmacros.h>
 
25
#include <QtDBus/QDBusConnection>
 
26
 
 
27
namespace Akonadi {
 
28
class Collection;
 
29
}
 
30
 
 
31
class StorageJanitorThread : public QThread
 
32
{
 
33
  Q_OBJECT
 
34
  public:
 
35
    explicit StorageJanitorThread( QObject * parent = 0 );
 
36
  protected:
 
37
    virtual void run();
 
38
};
 
39
 
 
40
/**
 
41
 * Various database checking/maintenance features.
 
42
 */
 
43
class StorageJanitor : public QObject
 
44
{
 
45
  Q_OBJECT
 
46
  Q_CLASSINFO( "D-Bus Interface", "org.freedesktop.Akonadi.Janitor" )
 
47
  public:
 
48
    explicit StorageJanitor(QObject* parent = 0);
 
49
    ~StorageJanitor();
 
50
 
 
51
  public slots:
 
52
    /** Triggers a consistency check of the internal storage. */
 
53
    Q_SCRIPTABLE Q_NOREPLY void check();
 
54
    /** Triggers a vacuuming of the database, that is compacting of unused space. */
 
55
    Q_SCRIPTABLE Q_NOREPLY void vacuum();
 
56
 
 
57
  signals:
 
58
    /** Sends informational messages to a possible UI for this. */
 
59
    Q_SCRIPTABLE void information( const QString &msg );
 
60
 
 
61
  private:
 
62
    void inform( const char *msg );
 
63
    void inform( const QString &msg );
 
64
 
 
65
    /**
 
66
     * Look for collections belonging to non-existent resources.
 
67
     */
 
68
    void findOrphanedCollections();
 
69
 
 
70
    /**
 
71
     * Verifies there is a path from @p col to the root of the collection tree
 
72
     * and that that everything along that path belongs to the same resource.
 
73
     */
 
74
    void checkPathToRoot( const Akonadi::Collection &col );
 
75
 
 
76
    /**
 
77
     * Look for items belonging to non-existing collections.
 
78
     */
 
79
    void findOrphanedItems();
 
80
 
 
81
    /**
 
82
     * Look for parts belonging to non-existing items.
 
83
     */
 
84
    void findOrphanedParts();
 
85
 
 
86
    /**
 
87
     * Look for parts referring to the same external file.
 
88
     */
 
89
    void findOverlappingParts();
 
90
 
 
91
    /**
 
92
     * Verify fs and db part state.
 
93
     */
 
94
    void verifyExternalParts();
 
95
 
 
96
    /**
 
97
     * Look for dirty objects.
 
98
     */
 
99
    void findDirtyObjects();
 
100
 
 
101
  private:
 
102
    QDBusConnection m_connection;
 
103
};
 
104
 
 
105
#endif // STORAGEJANITOR_H