~ubuntu-branches/ubuntu/breezy/koffice/breezy-security

« back to all changes in this revision

Viewing changes to kexi/main/projectWizard/kexicreateprojectpageengine.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-10-11 14:49:50 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051011144950-lwpngbifzp8nk0ds
Tags: 1:1.4.1-0ubuntu7
* SECURITY UPDATE: fix heap based buffer overflow in the RTF importer of KWord
* Opening specially crafted RTF files in KWord can cause
  execution of abitrary code.
* Add kubuntu_01_rtfimport_heap_overflow.diff
* References:
  CAN-2005-2971
  CESA-2005-005
  http://www.koffice.org/security/advisory-20051011-1.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
Copyright (C) 2002   Lucijan Busch <lucijan@gmx.at>
 
3
 
 
4
This program is free software; you can redistribute it and/or
 
5
modify it under the terms of the GNU Library General Public
 
6
License as published by the Free Software Foundation; either
 
7
version 2 of the License, or (at your option) any later version.
 
8
 
 
9
This program is distributed in the hope that it will be useful,
 
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
Library General Public License for more details.
 
13
 
 
14
You should have received a copy of the GNU Library General Public License
 
15
along with this program; see the file COPYING.  If not, write to
 
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
Boston, MA 02111-1307, USA.
 
18
*/
 
19
 
 
20
#include <qlayout.h>
 
21
#include <qlabel.h>
 
22
#include <qframe.h>
 
23
#include <qwizard.h>
 
24
#include <qpushbutton.h>
 
25
#include <qlistbox.h>
 
26
#include <qpen.h>
 
27
#include <qpainter.h>
 
28
 
 
29
#include <klocale.h>
 
30
#include <kdebug.h>
 
31
#include <kcombobox.h>
 
32
#include <ktextbrowser.h>
 
33
#include <kdialog.h>
 
34
#include <kiconloader.h>
 
35
#include <kapplication.h>
 
36
 
 
37
#include <kexidb/drivermanager.h>
 
38
#include "kexicreateprojectpageengine.h"
 
39
#include "kexiproject.h"
 
40
 
 
41
#include "kexi_version.h"
 
42
 
 
43
//! Small extension: list item that can be shown as disabled, but still selectable
 
44
class KexiListBoxItem : public QListBoxPixmap {
 
45
        public:
 
46
        KexiListBoxItem( QListBox * listbox, const QPixmap & pix, const QString & text, bool enabled=true )
 
47
                : QListBoxPixmap(listbox, pix, text ), m_enabled(enabled)
 
48
        {}
 
49
        protected:
 
50
                virtual void paint( QPainter * painter ) {
 
51
                        QPen p = painter->pen();
 
52
                        if (!m_enabled && !isSelected())
 
53
                                        p.setColor( qApp->palette().disabled().text() );
 
54
//                              if (listBox()->currentItem()==this)
 
55
//                                      ;//p.setColor( isSelected() && listBox()->hasFocus() ? qApp->palette().disabled().highlightedText() : qApp->palette().disabled().text() );
 
56
//                              else
 
57
//kdDebug() << isSelected() << " " <<  listBox()->hasFocus() << endl;
 
58
//                                      p.setColor( isSelected() && listBox()->hasFocus() ? qApp->palette().disabled().highlightedText() : qApp->palette().disabled().text() );
 
59
//                      }
 
60
                        painter->setPen(p);
 
61
                        QListBoxPixmap::paint(painter);
 
62
                }
 
63
                bool m_enabled : 1;
 
64
};
 
65
 
 
66
KexiCreateProjectPageEngine::KexiCreateProjectPageEngine(KexiCreateProject *parent, QPixmap *wpic, const char *name)
 
67
 : KexiCreateProjectPage(parent, wpic, name)
 
68
{
 
69
        QLabel *lEngine = new QLabel(i18n("Driver: "), m_contents);
 
70
 
 
71
        m_engine = new KComboBox(m_contents);
 
72
        m_engine->setMaxCount(8);
 
73
        connect(m_engine, SIGNAL(activated(int)), this, SLOT(slotActivated(int)));
 
74
 
 
75
        m_summary = new KTextBrowser(m_contents);
 
76
 
 
77
        QGridLayout *g = new QGridLayout(m_contents);
 
78
        g->addWidget(lEngine,           0,      0);
 
79
        g->addWidget(m_engine,          0,      1);
 
80
        g->addMultiCellWidget(m_summary,1,      1,      0,      1);
 
81
        g->setSpacing(KDialog::spacingHint());
 
82
 
 
83
        fill();
 
84
 
 
85
        setProperty("section", QVariant("Both"));
 
86
        setProperty("caption", QVariant(i18n("Engine")));
 
87
 
 
88
        m_engine->setFocus();
 
89
}
 
90
 
 
91
void
 
92
KexiCreateProjectPageEngine::fill()
 
93
{
 
94
        if (m_engine->count()>0)
 
95
                return;
 
96
        QStringList drivers = project()->manager()->driverNames();
 
97
        for(QStringList::Iterator it = drivers.begin(); it != drivers.end(); ++it)
 
98
        {
 
99
                m_engine->insertItem( kapp->iconLoader()->loadIcon("exec", KIcon::Small), *it);
 
100
        }
 
101
#ifdef KEXI_ADD_EXAMPLE_ENGINES
 
102
        m_first_example_engine_nr = m_engine->count();
 
103
        m_example_engines 
 
104
                << i18n("Default Kexi embedded engine")
 
105
                << "PostgreSQL"
 
106
                << "Interbase/Firebird"
 
107
                << "CQL++"
 
108
                << "SAP DB"
 
109
                << "IBM DB2"
 
110
                << "Oracle"
 
111
                << "Sybase/Adaptive Server Enterprise"
 
112
                << "ADABAS D"
 
113
                << "Informix" 
 
114
                << "Progress"
 
115
                << "ODBC";
 
116
                //(uniwersalne polaczenie do baz) 
 
117
 
 
118
        QPixmap icon = kapp->iconLoader()->loadIcon("exec", KIcon::Small);
 
119
        for ( QStringList::Iterator it = m_example_engines.begin(); it != m_example_engines.end(); ++it ) {
 
120
        m_engine->listBox()->insertItem( new KexiListBoxItem( 0, icon, *it, false ) );
 
121
//              m_engine->insertItem( kapp->iconLoader()->loadIcon("exec", KIcon::Small), *it);
 
122
        }
 
123
 
 
124
#endif
 
125
        if(!m_engine->currentText().isEmpty())
 
126
        {
 
127
                setProperty("engine", QVariant(m_engine->currentText()));
 
128
                setProperty("continue", QVariant(true));
 
129
        }
 
130
 
 
131
        fillSummary();
 
132
}
 
133
 
 
134
void
 
135
KexiCreateProjectPageEngine::fillSummary()
 
136
{
 
137
        QString engineSummary;
 
138
        QVariant location;
 
139
#ifdef KEXI_ADD_EXAMPLE_ENGINES
 
140
        if (m_engine->currentItem()>=m_first_example_engine_nr) {
 
141
                engineSummary = i18n("Sorry, this driver is not available with current version of %1.").arg(KEXI_APP_NAME);
 
142
                if (m_engine->currentText()=="ODBC") {
 
143
                        engineSummary += i18n("<p>ODBC is an open specification for accessing data sources more easily; data sources include both SQL databases available with Kexi drivers and others, like Microsoft SQL Server and Microsoft Access.");
 
144
                }
 
145
        } 
 
146
        else
 
147
#endif
 
148
        {      
 
149
                KService *ptr=project()->manager()->serviceInfo(m_engine->currentText());
 
150
                if (ptr) {
 
151
                        engineSummary = ptr->comment();
 
152
                        location = project()->manager()->serviceInfo(m_engine->currentText())->property("X-Kexi-Location");
 
153
                        setProperty("location", location);
 
154
                } else engineSummary=i18n("Internal error while retrieving information. (No driver installed ?)");
 
155
//              userSummary = QString("<b>" + m_engine->currentText() + "</b><br><hr><br>" + engineSummary);
 
156
        }
 
157
 
 
158
 
 
159
        if(!m_engine->currentText().isEmpty())
 
160
        {
 
161
                m_summary->setText( QString("<b>") + m_engine->currentText() + "</b><br><hr><br>" + engineSummary );
 
162
        }
 
163
 
 
164
}
 
165
 
 
166
void
 
167
KexiCreateProjectPageEngine::slotActivated(int idx)
 
168
{
 
169
        bool continue_enabled;
 
170
#ifdef KEXI_ADD_EXAMPLE_ENGINES
 
171
        continue_enabled = idx<m_first_example_engine_nr;
 
172
#else
 
173
        continue_enabled=true;
 
174
#endif
 
175
 
 
176
        setProperty("continue", continue_enabled);
 
177
        setProperty("engine", QVariant(m_engine->text(idx)));
 
178
        fillSummary();
 
179
}
 
180
 
 
181
KexiCreateProjectPageEngine::~KexiCreateProjectPageEngine()
 
182
{
 
183
}
 
184
 
 
185
#include "kexicreateprojectpageengine.moc"