~ubuntu-branches/ubuntu/saucy/kde-runtime/saucy-proposed

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
/*
   Copyright (C) 2010 by Jacopo De Simoi <wilderkde@gmail.com>


   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, 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 KSOLIDNOTIFY_H
#define KSOLIDNOTIFY_H

#include "knotify.h"

#include <solid/solidnamespace.h>

namespace Solid
{
	class Device;
}

/**
 * @brief Class which triggers solid notifications
 *
 * This is an internal class which listens to solid errors and route them via dbus to an
 * appropriate visualization (e.g. the plasma device notifier applet); if such visualization is not available
 * errors are shown via regular notifications
 *
 * @author Jacopo De Simoi <wilderkde at gmail.com>
*/

class KSolidNotify : public QObject
{ Q_OBJECT

	public:
		KSolidNotify(KNotify *parent);

	protected Q_SLOTS:
		void onDeviceAdded(const QString &udi);
		void onDeviceRemoved(const QString &udi);

	private slots:

		void storageEjectDone(Solid::ErrorType error, QVariant errorData, const QString & udi);
		void storageTeardownDone(Solid::ErrorType error, QVariant errorData, const QString & udi);
		void storageSetupDone(Solid::ErrorType error, QVariant errorData, const QString & udi);

		void slotServiceOwnerChanged(const QString &, const QString &, const QString &);

	private:
		void connectSignals(Solid::Device* device);
		bool isSafelyRemovable(const QString &udi);
		void notifySolidEvent(QString event, Solid::ErrorType error, QVariant errorData, const QString & udi, const QString & errorMessage);

		KNotify* m_kNotify;
		QHash<QString, Solid::Device> m_devices;
		bool m_dbusServiceExists;
};
#endif