add more spacing
[personal-kdebase.git] / apps / konqueror / src / konqsessionmanager.h
blobb4ef2c0ff0599e0488bdd641dd23e94b57b84ad2
1 /*
2 This file is part of the KDE project
3 Copyright (C) 2008 Eduardo Robles Elvira <edulix@gmail.com>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef KONQSESSIONMANAGER_H
22 #define KONQSESSIONMANAGER_H
24 #include <QObject>
25 #include <QTimer>
26 #include <QStringList>
27 #include <QString>
29 #include <kconfig.h>
31 class QDBusMessage;
32 class KonqMainWindow;
34 /**
35 * This class is a singleton. It does some session related tasks:
36 * - Autosave current session every X seconds
37 * - Restore a saved session if konqueror crashed
38 * - Restore a given session manually
40 class KonqSessionManager : public QObject {
41 Q_OBJECT
42 public:
43 friend class KonqSessionManagerPrivate;
45 static KonqSessionManager *self();
47 /**
48 * Restore saved session(s).
50 * @param sessionFilePathsList list of session files to restore.
51 * @param openTabsInsideCurrentWindow indicates if you want to open the tabs
52 * in current window or not. False by default.
53 * @param parent indicates in which window the tabs will be opened if
54 * openTabsInsideCurrentWindow is set to true. Otherwise it won't be used.
56 void restoreSessions(const QStringList &sessionFilePathsList, bool
57 openTabsInsideCurrentWindow = false, KonqMainWindow *parent = 0L);
59 /**
60 * Restore saved session(s).
62 * @param sessionsDir directory containing the session files to
63 * restore.
64 * @param openTabsInsideCurrentWindow indicates if you want to open the tabs
65 * in current window or not. False by default.
66 * @param parent indicates in which window the tabs will be opened if
67 * openTabsInsideCurrentWindow is set to true. Otherwise it won't be used.
69 void restoreSessions(const QString &sessionsDir, bool
70 openTabsInsideCurrentWindow = false, KonqMainWindow *parent = 0L);
72 /**
73 * Restore saved session.
74 * @param sessionFilePath session file to restore.
75 * @param openTabsInsideCurrentWindow indicates if you want to open the tabs
76 * in current window or not. False by default.
77 * @param parent indicates in which window the tabs will be opened if
78 * openTabsInsideCurrentWindow is set to true. Otherwise it won't be used.
80 void restoreSession(const QString &sessionFilePath, bool
81 openTabsInsideCurrentWindow = false, KonqMainWindow *parent = 0L);
83 /**
84 * Disable the autosave feature. It's called when a konqueror instance is
85 * being preloaded
87 void disableAutosave();
89 /**
90 * Enable the autosave feature. It's called when a konqueror instance stops
91 * being preloaded and starts having a window showed to the user.
93 void enableAutosave();
95 /**
96 * Removes the owned_by directory and all its files inside (which were
97 * referencing the owned sessions).
99 void deleteOwnedSessions();
101 public Q_SLOTS:
103 * Ask the user with a KPassivePopup ballon if session should be restored
105 bool askUserToRestoreAutosavedAbandonedSessions();
108 * Saves current session.
109 * This is function is called by the autosave timer, but you can call it too
110 * if you want. It won't do anything if m_autosaveEnabled is false.
112 void autoSaveSession();
115 * Restore owned sessions
117 void restoreSessions();
120 * Save current session in a custom KConfig
122 void saveCurrentSession(KConfig* sessionConfig);
125 * Save current sessions of all konqueror instances (propagated via a
126 * dbus signal).
128 void saveCurrentSessions(const QString & path);
129 private:
130 KonqSessionManager();
132 ~KonqSessionManager();
135 * Creates the owned_by directory with files inside referencing the owned
136 * sessions and returns if there was any file to own/restore.
138 bool takeSessionsOwnership();
140 QString dirForMyOwnedSessionFiles() const {
141 return m_autosaveDir + "/owned_by" + m_baseService;
143 private:
144 QTimer m_autoSaveTimer;
145 QString m_autosaveDir;
146 QString m_baseService;
147 KConfig *m_autoSavedSessionConfig;
148 bool m_autosaveEnabled;
149 Q_SIGNALS: // DBUS signals
151 * Save current session of all konqueror running instances in a given
152 * directory
154 void saveCurrentSession( const QString& path );
155 private Q_SLOTS:// connected to DBUS signals
156 void slotSaveCurrentSession( const QString& path );
159 #endif /* KONQSESSIONMANAGER_H */