20 #include <tqhbuttongroup.h>
21 #include <tqpushbutton.h>
24 #include <tqmultilineedit.h>
25 #include <tqradiobutton.h>
26 #include <tqwhatsthis.h>
29 #include <tdeaboutdata.h>
30 #include <tdeapplication.h>
31 #include <tdeconfig.h>
33 #include <klineedit.h>
35 #include <tdemessagebox.h>
36 #include <tdeprocess.h>
37 #include <kstandarddirs.h>
38 #include <kstdguiitem.h>
40 #include <kurllabel.h>
42 #include "kbugreport.h"
48 #include <sys/utsname.h>
50 #include "kdepackages.h"
51 #include <kcombobox.h>
53 #include <tdetempfile.h>
54 #include <tqtextstream.h>
57 class KBugReportPrivate {
64 TQPushButton *submitBugButton;
70 i18n(
"Submit Bug Report"),
79 d =
new KBugReportPrivate;
83 m_aboutData = aboutData
85 : ( TDEGlobal::_activeInstance ? TDEGlobal::_activeInstance->aboutData()
89 d->submitBugButton = 0;
95 d->submitBugButton =
new TQPushButton( parent );
100 TQVBoxLayout * lay =
new TQVBoxLayout( parent, 0,
spacingHint() );
102 TQGridLayout *glay =
new TQGridLayout( lay, 4, 3 );
103 glay->setColStretch( 1, 10 );
104 glay->setColStretch( 2, 10 );
108 if ( !d->submitBugButton )
111 TQString qwtstr = i18n(
"Your email address. If incorrect, use the Configure Email button to change it" );
112 tmpLabel =
new TQLabel( i18n(
"From:"), parent );
113 glay->addWidget( tmpLabel, row,0 );
114 TQWhatsThis::add( tmpLabel, qwtstr );
115 m_from =
new TQLabel( parent );
116 glay->addWidget( m_from, row, 1 );
117 TQWhatsThis::add( m_from, qwtstr );
121 m_configureEmail =
new TQPushButton( i18n(
"Configure Email..."),
123 connect( m_configureEmail, TQ_SIGNAL( clicked() ),
this,
125 glay->addMultiCellWidget( m_configureEmail, 0, 2, 2, 2, TQt::AlignTop|TQt::AlignRight );
128 qwtstr = i18n(
"The email address this bug report is sent to." );
129 tmpLabel =
new TQLabel( i18n(
"To:"), parent );
130 glay->addWidget( tmpLabel, ++row,0 );
131 TQWhatsThis::add( tmpLabel, qwtstr );
132 tmpLabel =
new TQLabel( m_aboutData->
bugAddress(), parent );
133 glay->addWidget( tmpLabel, row, 1 );
134 TQWhatsThis::add( tmpLabel, qwtstr );
137 i18n(
"Send this bug report to %1." ).arg( m_aboutData->
bugAddress() ) ) );
142 m_configureEmail = 0;
148 TQString qwtstr = i18n(
"The application for which you wish to submit a bug report - if incorrect, please use the Report Bug menu item of the correct application" );
149 tmpLabel =
new TQLabel( i18n(
"Application: "), parent );
150 glay->addWidget( tmpLabel, ++row, 0 );
151 TQWhatsThis::add( tmpLabel, qwtstr );
152 d->appcombo =
new KComboBox(
false, parent,
"app");
153 TQWhatsThis::add( d->appcombo, qwtstr );
154 d->appcombo->insertStrList((
const char**)packages);
155 connect(d->appcombo, TQ_SIGNAL(activated(
int)), TQ_SLOT(
appChanged(
int)));
156 d->appname = TQString::fromLatin1( m_aboutData
159 glay->addWidget( d->appcombo, row, 1 );
161 for (; index < d->appcombo->count(); index++) {
162 if (d->appcombo->text(index) == d->appname) {
166 if (index == d->appcombo->count()) {
167 d->appcombo->insertItem(d->appname);
169 d->appcombo->setCurrentItem(index);
171 TQWhatsThis::add( tmpLabel, qwtstr );
174 qwtstr = i18n(
"The version of this application - please make sure that no newer version is available before sending a bug report" );
175 tmpLabel =
new TQLabel( i18n(
"Version:"), parent );
176 glay->addWidget( tmpLabel, ++row, 0 );
177 TQWhatsThis::add( tmpLabel, qwtstr );
179 m_strVersion = m_aboutData->
version();
181 m_strVersion = i18n(
"no version set (programmer error!)");
182 d->tde_version = TQString::fromLatin1( TDE_VERSION_STRING );
183 if (TQString::fromLatin1( KDE_DISTRIBUTION_TEXT ) !=
"")
184 d->tde_version +=
", " + TQString::fromLatin1( KDE_DISTRIBUTION_TEXT );
185 if ( !d->submitBugButton )
186 m_strVersion +=
" " + d->tde_version;
187 m_version =
new TQLabel( m_strVersion, parent );
189 glay->addMultiCellWidget( m_version, row, row, 1, 2 );
190 TQWhatsThis::add( m_version, qwtstr );
192 tmpLabel =
new TQLabel(i18n(
"OS:"), parent);
193 glay->addWidget( tmpLabel, ++row, 0 );
195 struct utsname unameBuf;
197 d->os = TQString::fromLatin1( unameBuf.sysname ) +
198 " (" + TQString::fromLatin1( unameBuf.machine ) +
") "
199 "release " + TQString::fromLatin1( unameBuf.release );
201 tmpLabel =
new TQLabel(d->os, parent);
202 glay->addMultiCellWidget( tmpLabel, row, row, 1, 2 );
204 tmpLabel =
new TQLabel(i18n(
"Compiler:"), parent);
205 glay->addWidget( tmpLabel, ++row, 0 );
206 tmpLabel =
new TQLabel(TQString::fromLatin1(KDE_COMPILER_VERSION), parent);
207 glay->addMultiCellWidget( tmpLabel, row, row, 1, 2 );
209 if ( !d->submitBugButton )
212 m_bgSeverity =
new TQHButtonGroup( i18n(
"Se&verity"), parent );
213 static const char *
const sevNames[5] = {
"critical",
"grave",
"normal",
"wishlist",
"i18n" };
214 const TQString sevTexts[5] = { i18n(
"Critical"), i18n(
"Grave"), i18n(
"normal severity",
"Normal"), i18n(
"Wishlist"), i18n(
"Translation") };
216 for (
int i = 0 ; i < 5 ; i++ )
219 TQRadioButton *rb =
new TQRadioButton( sevTexts[i], m_bgSeverity, sevNames[i] );
220 if (i==2) rb->setChecked(
true);
223 lay->addWidget( m_bgSeverity );
226 TQHBoxLayout * hlay =
new TQHBoxLayout( lay );
227 tmpLabel =
new TQLabel( i18n(
"S&ubject: "), parent );
228 hlay->addWidget( tmpLabel );
230 m_subject->setFocus();
231 tmpLabel->setBuddy(m_subject);
232 hlay->addWidget( m_subject );
234 TQString
text = i18n(
"Enter the text (in English if possible) that you wish to submit for the "
236 "If you press \"Send\", a mail message will be sent to the maintainer of "
238 TQLabel * label =
new TQLabel( parent,
"label" );
240 label->setText(
text );
241 lay->addWidget( label );
244 m_lineedit =
new TQMultiLineEdit( parent,
"TQMultiLineEdit" );
245 m_lineedit->setMinimumHeight( 180 );
246 m_lineedit->setWordWrap(TQMultiLineEdit::WidgetWidth);
247 lay->addWidget( m_lineedit, 10 );
254 TQString
text = i18n(
"Reporting bugs and requesting enhancements are maintained using the Bugzilla reporting system.\n"
255 "You'll need a login account and password to use the reporting system.\n"
256 "To control spam and rogue elements the login requires a valid email address.\n"
257 "Consider using any large email service if you want to avoid using your private email address.\n"
259 "Selecting the button below opens your web browser to http://bugs.trinitydesktop.org,\n"
260 "where you will find the report form.\n"
261 "The information displayed above will be transferred to the reporting system.\n"
262 "Session cookies must be enabled to use the reporting system.\n"
264 "Thank you for helping!");
265 TQLabel * label =
new TQLabel(
text, parent,
"label");
266 lay->addWidget( label );
270 d->submitBugButton->setText( i18n(
"&Launch Bug Report Wizard") );
271 d->submitBugButton->setSizePolicy(TQSizePolicy::Fixed,TQSizePolicy::Fixed);
272 lay->addWidget( d->submitBugButton );
275 connect( d->submitBugButton, TQ_SIGNAL(clicked()),
287 KURL url (
"http://bugs.trinitydesktop.org/enter_bug.cgi" );
290 url.
addQueryItem(
"cf_kde_compiler", KDE_COMPILER_VERSION );
293 url.
addQueryItem(
"cf_kde_package", d->appcombo->currentText() );
300 TQString appName = d->appcombo->text(i);
301 int index = appName.find(
'/' );
303 appName = appName.left( index );
306 if (d->appname == appName && m_aboutData)
307 m_strVersion = m_aboutData->
version();
309 m_strVersion = i18n(
"unknown program name",
"unknown");
311 if ( !d->submitBugButton )
312 m_strVersion += d->tde_version;
314 m_version->setText(m_strVersion);
315 if ( d->submitBugButton )
321 if (m_process)
return;
323 *m_process << TQString::fromLatin1(
"tdecmshell") << TQString::fromLatin1(
"kcm_useraccount");
325 if (!m_process->
start())
327 kdDebug() <<
"Couldn't start tdecmshell.." <<
endl;
332 m_configureEmail->setEnabled(
false);
339 m_configureEmail->setEnabled(
true);
342 TDEConfig emailConf( TQString::fromLatin1(
"emaildefaults") );
345 emailConf.
setGroup( TQString::fromLatin1(
"Defaults") );
346 TQString profile = TQString::fromLatin1(
"PROFILE_");
347 profile += emailConf.
readEntry( TQString::fromLatin1(
"Profile"),
348 TQString::fromLatin1(
"Default") );
351 TQString fromaddr = emailConf.
readEntry( TQString::fromLatin1(
"EmailAddress") );
352 if (fromaddr.isEmpty()) {
354 p = getpwuid(getuid());
355 fromaddr = TQString::fromLatin1(p->pw_name);
357 TQString name = emailConf.
readEntry( TQString::fromLatin1(
"FullName"));
359 fromaddr = name + TQString::fromLatin1(
" <") + fromaddr + TQString::fromLatin1(
">");
361 m_from->setText( fromaddr );
367 kapp->invokeBrowser( urlText );
371 if ( d->submitBugButton )
378 if ( d->submitBugButton ) {
380 kapp->invokeBrowser( d->url.url() );
384 if( m_lineedit->text().isEmpty() ||
385 m_subject->text().isEmpty() )
387 TQString msg = i18n(
"You must specify both a subject and a description "
388 "before the report can be sent.");
393 switch ( m_bgSeverity->id( m_bgSeverity->selected() ) )
397 "<p>You chose the severity <b>Critical</b>. "
398 "Please note that this severity is intended only for bugs that</p>"
399 "<ul><li>break unrelated software on the system (or the whole system)</li>"
400 "<li>cause serious data loss</li>"
401 "<li>introduce a security hole on the system where the affected package is installed</li></ul>\n"
402 "<p>Does the bug you are reporting cause any of the above damage? "
403 "If it does not, please select a lower severity. Thank you!</p>" ),TQString::null,
KStdGuiItem::cont(),KStdGuiItem::cancel() ) == KMessageBox::No )
408 "<p>You chose the severity <b>Grave</b>. "
409 "Please note that this severity is intended only for bugs that</p>"
410 "<ul><li>make the package in question unusable or mostly so</li>"
411 "<li>cause data loss</li>"
412 "<li>introduce a security hole allowing access to the accounts of users who use the affected package</li></ul>\n"
413 "<p>Does the bug you are reporting cause any of the above damage? "
414 "If it does not, please select a lower severity. Thank you!</p>" ),TQString::null,
KStdGuiItem::cont(),KStdGuiItem::cancel() ) == KMessageBox::No )
420 TQString msg = i18n(
"Unable to send the bug report.\n"
421 "Please submit a bug report manually...\n"
422 "See http://bugs.trinitydesktop.org/ for instructions.");
428 i18n(
"Bug report sent, thank you for your input."));
434 if( !d->submitBugButton && ( m_lineedit->edited() || m_subject->edited() ) )
437 i18n(
"Close and discard\nedited message?" ),
439 if( rc == KMessageBox::No )
448 kdDebug() << m_bgSeverity->selected()->name() <<
endl;
450 TQString severity = TQString::fromLatin1(m_bgSeverity->selected()->name());
451 TQString appname = d->appcombo->currentText();
452 TQString os = TQString::fromLatin1(
"OS: %1 (%2)\n").
453 arg(KDE_COMPILING_OS).
454 arg(KDE_DISTRIBUTION_TEXT);
456 for(
int i = 0; i < m_lineedit->numLines(); i++)
458 TQString line = m_lineedit->textLine(i);
459 if (!line.endsWith(
"\n"))
466 TQString
package = TQString::fromLatin1("i18n_%1").arg(TDEGlobal::locale()->language());
467 package = package.replace(TQString::fromLatin1("_"), TQString::fromLatin1("-"));
468 return TQString::fromLatin1(
"Package: %1").arg(package) +
469 TQString::fromLatin1(
"\n"
472 "Version: %2\n").arg(appname).arg(m_strVersion)+
473 os+TQString::fromLatin1(
"\n")+bodyText;
475 appname = appname.replace(TQString::fromLatin1(
"_"), TQString::fromLatin1(
"-"));
477 return TQString::fromLatin1(
"Package: %1\n"
480 .arg(appname).arg(m_strVersion).arg(severity)+
481 TQString::fromLatin1(
"Compiler: %1\n").arg(KDE_COMPILER_VERSION)+
482 os+TQString::fromLatin1(
"\n")+bodyText;
488 TQString recipient ( m_aboutData ?
490 TQString::fromLatin1(
"submit@bugs.trinitydesktop.org") );
493 command =
locate(
"exe",
"tdesendbugmail");
494 if (command.isEmpty())
500 TQString subject = m_subject->text();
501 command +=
" --subject ";
503 command +=
" --recipient ";
511 FILE * fd = popen(TQFile::encodeName(command),
"w");
514 kdError() <<
"Unable to open a pipe to " << command <<
endl;
518 TQString btext =
text();
519 fwrite(btext.ascii(),btext.length(),1,fd);
522 int error = pclose(fd);
523 kdDebug() <<
"exit status1 " << error <<
" " << (WIFEXITED(error)) <<
" " << WEXITSTATUS(error) <<
endl;
525 if ((WIFEXITED(error)) && WEXITSTATUS(error) == 1) {
526 TQFile of(outputfile.
name());
527 if (of.open(IO_ReadOnly )) {
528 TQTextStream is(&of);
529 is.setEncoding(TQTextStream::UnicodeUTF8);
532 line = is.readLine();
535 d->lastError = TQString::null;
544 TQString KBugReport::compilerVersion() {
545 return KDE_COMPILER_VERSION;
548 TQString KBugReport::operatingSystem() {
552 TQString KBugReport::tdeVersion() {
553 return d->tde_version;
556 void KBugReport::virtual_hook(
int id,
void* data )
557 { KDialogBase::virtual_hook(
id, data ); }
559 #include "kbugreport.moc"
virtual void slotConfigureEmail()
"Configure email" has been clicked - this calls tdecmshell System/email
virtual void slotCancel()
Cancel has been clicked.
virtual void slotOk(void)
OK has been clicked.
void appChanged(int)
Application combo selection changed (and was activated)
virtual ~KBugReport()
Destructor.
TQString text() const
A complete copy of the bug report.
virtual void slotSetFrom()
Sets the "From" field from the e-mail configuration Called at creation time, but also after "Configur...
virtual void slotUrlClicked(const TQString &)
The URL-Label "http://bugs.trinitydesktop.org/" was clicked.
void updateURL()
Update the url to match the current os, compiler, selected app, etc.
KBugReport(TQWidget *parent=0L, bool modal=true, const TDEAboutData *aboutData=0L)
Creates a bug-report dialog.
bool sendBugReport()
Attempt to e-mail the bug report.
A dialog base class with standard buttons and predefined layouts.
virtual void slotCancel()
Activated when the Cancel button has been clicked.
void setButtonOK(const KGuiItem &item=KStdGuiItem::ok())
Sets the appearance of the OK button.
void setButtonCancel(const KGuiItem &item=KStdGuiItem::cancel())
Sets the appearance of the Cancel button.
TQFrame * plainPage()
Retrieve the empty page when the predefined layout is used in Plain mode.
void showButtonOK(bool state)
Hide or display the OK button.
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
An abstract class for GUI data such as ToolTip and Icon.
An enhanced TQLineEdit widget for inputting text.
static void information(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const TQString &dontShowAgainName=TQString::null, int options=Notify)
Display an "Information" dialog.
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
Display an "Error" dialog.
static int questionYesNo(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
Display a simple "question" dialog.
static int warningYesNo(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontAskAgainName=TQString::null, int options=Notify|Dangerous)
Display a "warning" dialog.
static KGuiItem cont()
Returns a "continue" item.
void addQueryItem(const TQString &_item, const TQString &_value, int encoding_hint=0)
TQString bugAddress() const
const char * productName() const
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
void setGroup(const TQString &group)
static TDEInstance * instance()
static TDELocale * locale()
const TDEAboutData * aboutData() const
static TQString defaultLanguage()
virtual bool start(RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
static TQString quote(const TQString &arg)
static TQString findExe(const TQString &appname, const TQString &pathstr=TQString::null, bool ignoreExecBit=false)
kndbgstream & endl(kndbgstream &s)
kdbgstream kdError(int area=0)
kdbgstream kdDebug(int area=0)
TQString locate(const char *type, const TQString &filename, const TDEInstance *instance=TDEGlobal::instance())