summaryrefslogtreecommitdiffstats
path: root/krfb/krfb/configuration.h
blob: 1f9c8ab5e7c6d029121b07b8420f3e8f5e49dcad (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
/***************************************************************************
                               configuration.h
                             -------------------
    begin                : Tue Dec 11 2001
    copyright            : (C) 2001-2003 by Tim Jansen
    email                : tim@tjansen.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 CONFIGURATION_H
#define CONFIGURATION_H

#include "invitation.h"

#include "manageinvitations.h"
#include "personalinvitedialog.h"
#include "invitedialog.h"

#include <dcopref.h>
#include <kconfig.h>
#include <tqtimer.h>
#include <tqobject.h>
#include <tqvalidator.h>
#include <tqstring.h>

#include <dcopobject.h>

enum krfb_mode {
	KRFB_UNKNOWN_MODE = 0,
	KRFB_KINETD_MODE,
	KRFB_INVITATION_MODE,
	KRFB_CONFIGURATION_MODE
};


/**
 * This class stores the app's configuration, manages the
 * standalone-config-dialog and all the invitation dialogs
 * @author Tim Jansen
 */
class Configuration : public TQObject, public DCOPObject {
		K_DCOP
   	Q_OBJECT
//	
public:
	Configuration(krfb_mode mode);
	virtual ~Configuration();

	krfb_mode mode() const;
	bool askOnConnect() const;
	bool allowDesktopControl() const;
	bool allowUninvitedConnections() const;
	bool enableSLP() const;
	TQString password() const;
	TQString hostname() const;
	int port() const;
	int preferredPort() const;
	bool disableBackground() const;
	bool disableXShm() const;

        void setAllowUninvited(bool allowUninvited);
	void setEnableSLP(bool e);
        void setAskOnConnect(bool askOnConnect);
	void setPassword(TQString password);
	void setPreferredPort(int p);
	void setDisableBackground(bool disable);
	void setDisableXShm(bool disable);
	void save();
	void update();

	TQValueList<Invitation> &invitations();
	void removeInvitation(TQValueList<Invitation>::iterator it);
signals:
	void invitationFinished();
	void invitationNumChanged(int num);

public slots:
        void setAllowDesktopControl(bool allowDesktopControl);
	void showManageInvitationsDialog();
	void showInvitationDialog();
	void showPersonalInvitationDialog();
	void showConfigurationModule();
	void inviteEmail();

private:
        void loadFromKConfig();
        void loadFromDialogs();
        void saveToKConfig();
        void saveToDialogs();
	Invitation createInvitation();
	void closeInvDlg();
	void invalidateOldInvitations();
	void setKInetdEnabled(const TQDateTime &date);
	void setKInetdEnabled(bool enabled);
	void setKInetdServiceRegistrationEnabled(bool enabled);
	void getPortFromKInetd();
	void setKInetdPort(int port);
	void doKinetdConf();

	krfb_mode m_mode;

	ManageInvitationsDialog invMngDlg;
	InviteDialog invDlg;
	PersonalInviteDialog persInvDlg;
	TQTimer refreshTimer;

	bool askOnConnectFlag;
	bool allowDesktopControlFlag;
	bool allowUninvitedFlag;
	bool enableSLPFlag;

	int portNum, preferredPortNum;

	DCOPRef kinetdRef;

	TQString passwordString;
	TQValueList<Invitation> invitationList;

	bool disableBackgroundFlag;
	bool disableXShmFlag;

k_dcop:
    // Connected to the DCOP signal
    void updateKConfig();	
private slots:
        void refreshTimeout();

	void invMngDlgDeleteOnePressed();
	void invMngDlgDeleteAllPressed();
};

#endif