summaryrefslogtreecommitdiffstats
path: root/kcontrol/tdeio/kcookiesmain.cpp
blob: 9869c6c9226d4d6cdf5ab32d6abb2fea00bb5204 (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
// kcookiesmain.cpp - Cookies configuration
//
// First version of cookies configuration by Waldo Bastian <bastian@kde.org>
// This dialog box created by David Faure <faure@kde.org>

#include <tqlayout.h>
#include <tqtabwidget.h>

#include <tdelocale.h>
#include <tdeapplication.h>
#include <tdemessagebox.h>
#include <kdebug.h>
#include <dcopref.h>

#include "kcookiesmain.h"
#include "kcookiespolicies.h"
#include "kcookiesmanagement.h"

KCookiesMain::KCookiesMain(TQWidget *parent)
  : TDECModule(parent, "kcmtdeio")
{
    int currentTabNumber = 0;
    policiesTabNumber = -1;
    managementTabNumber = -1;

    management = 0;
    bool managerOK = true;

    DCOPReply reply = DCOPRef( "kded", "kded" ).call( "loadModule", 
        TQCString( "kcookiejar" ) );

    if( !reply.isValid() )
    {
       managerOK = false;
       kdDebug(7103) << "kcm_tdeio: KDED could not load KCookiejar!" << endl;
       KMessageBox::sorry(0, i18n("Unable to start the cookie handler service.\n"
                             "You will not be able to manage the cookies that "
                             "are stored on your computer."));
    }

    TQVBoxLayout *layout = new TQVBoxLayout(this);
    tab = new TQTabWidget(this);
    layout->addWidget(tab);

    policies = new KCookiesPolicies(this);
    tab->addTab(policies, i18n("&Policy"));
    policiesTabNumber = currentTabNumber;
    currentTabNumber++;
    connect(policies, TQT_SIGNAL(changed(bool)), TQT_SIGNAL(changed(bool)));

    if( managerOK )
    {
        management = new KCookiesManagement(this);
        tab->addTab(management, i18n("&Management"));
        managementTabNumber = currentTabNumber;
        currentTabNumber++;
        connect(management, TQT_SIGNAL(changed(bool)), TQT_SIGNAL(changed(bool)));
    }
}

KCookiesMain::~KCookiesMain()
{
}

void KCookiesMain::load()
{
  policies->load();
  if( management )
      management->load();
}

void KCookiesMain::save()
{
  policies->save();
  if ( management )
      management->save();
}

void KCookiesMain::defaults()
{
  TDECModule* module = static_cast<TDECModule*>(tab->currentPage());
  
  if ( module == policies )
    policies->defaults();
  else if( management )
    management->defaults();
}

TQString KCookiesMain::quickHelp() const
{
  return i18n("<h1>Cookies</h1> Cookies contain information that Konqueror"
    " (or other TDE applications using the HTTP protocol) stores on your"
    " computer, initiated by a remote Internet server. This means that"
    " a web server can store information about you and your browsing activities"
    " on your machine for later use. You might consider this an invasion of"
    " privacy. <p> However, cookies are useful in certain situations. For example, they"
    " are often used by Internet shops, so you can 'put things into a shopping basket'."
    " Some sites require you have a browser that supports cookies. <p>"
    " Because most people want a compromise between privacy and the benefits cookies offer,"
    " TDE offers you the ability to customize the way it handles cookies. So you might want"
    " to set TDE's default policy to ask you whenever a server wants to set a cookie,"
    " allowing you to decide. For your favorite shopping web sites that you trust, you might"
    " want to set the policy to accept, then you can access the web sites without being prompted"
    " every time TDE receives a cookie." );
}

TQString KCookiesMain::handbookSection() const
{
	int index = tab->currentPageIndex();
	if (index == policiesTabNumber) {
		//return "cookie-policy";
		return TQString::null;
	}
	else if (index == managementTabNumber) {
		return "cookie-management";
	}
	else {
		return TQString::null;
	}
}

#include "kcookiesmain.moc"