20 #include <tqhbuttongroup.h> 21 #include <tqpushbutton.h> 24 #include <tqmultilineedit.h> 25 #include <tqradiobutton.h> 26 #include <tqwhatsthis.h> 29 #include <kaboutdata.h> 30 #include <kapplication.h> 33 #include <klineedit.h> 35 #include <kmessagebox.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 <ktempfile.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 : ( KGlobal::_activeInstance ? KGlobal::_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, TQT_SIGNAL( clicked() ),
this,
125 glay->addMultiCellWidget( m_configureEmail, 0, 2, 2, 2, (TQ_Alignment)(AlignTop|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, TQT_SIGNAL(activated(
int)), TQT_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->kde_version = TQString::fromLatin1( KDE_VERSION_STRING );
183 d->kde_version +=
", " + TQString::fromLatin1( KDE_DISTRIBUTION_TEXT );
184 if ( !d->submitBugButton )
185 m_strVersion +=
" " + d->kde_version;
186 m_version =
new TQLabel( m_strVersion, parent );
188 glay->addMultiCellWidget( m_version, row, row, 1, 2 );
189 TQWhatsThis::add( m_version, qwtstr );
191 tmpLabel =
new TQLabel(i18n(
"OS:"), parent);
192 glay->addWidget( tmpLabel, ++row, 0 );
194 struct utsname unameBuf;
196 d->os = TQString::fromLatin1( unameBuf.sysname ) +
197 " (" + TQString::fromLatin1( unameBuf.machine ) +
") " 198 "release " + TQString::fromLatin1( unameBuf.release );
200 tmpLabel =
new TQLabel(d->os, parent);
201 glay->addMultiCellWidget( tmpLabel, row, row, 1, 2 );
203 tmpLabel =
new TQLabel(i18n(
"Compiler:"), parent);
204 glay->addWidget( tmpLabel, ++row, 0 );
205 tmpLabel =
new TQLabel(TQString::fromLatin1(KDE_COMPILER_VERSION), parent);
206 glay->addMultiCellWidget( tmpLabel, row, row, 1, 2 );
208 if ( !d->submitBugButton )
211 m_bgSeverity =
new TQHButtonGroup( i18n(
"Se&verity"), parent );
212 static const char *
const sevNames[5] = {
"critical",
"grave",
"normal",
"wishlist",
"i18n" };
213 const TQString sevTexts[5] = { i18n(
"Critical"), i18n(
"Grave"), i18n(
"normal severity",
"Normal"), i18n(
"Wishlist"), i18n(
"Translation") };
215 for (
int i = 0 ; i < 5 ; i++ )
218 TQRadioButton *rb =
new TQRadioButton( sevTexts[i], m_bgSeverity, sevNames[i] );
219 if (i==2) rb->setChecked(
true);
222 lay->addWidget( m_bgSeverity );
225 TQHBoxLayout * hlay =
new TQHBoxLayout( lay );
226 tmpLabel =
new TQLabel( i18n(
"S&ubject: "), parent );
227 hlay->addWidget( tmpLabel );
229 m_subject->setFocus();
230 tmpLabel->setBuddy(m_subject);
231 hlay->addWidget( m_subject );
233 TQString
text = i18n(
"Enter the text (in English if possible) that you wish to submit for the " 235 "If you press \"Send\", a mail message will be sent to the maintainer of " 237 TQLabel * label =
new TQLabel( parent,
"label" );
239 label->setText( text );
240 lay->addWidget( label );
243 m_lineedit =
new TQMultiLineEdit( parent, TQMULTILINEEDIT_OBJECT_NAME_STRING );
244 m_lineedit->setMinimumHeight( 180 );
245 m_lineedit->setWordWrap(TQMultiLineEdit::WidgetWidth);
246 lay->addWidget( m_lineedit, 10 );
253 TQString
text = i18n(
"Reporting bugs and requesting enhancements are maintained using the Bugzilla reporting system.\n" 254 "You'll need a login account and password to use the reporting system.\n" 255 "To control spam and rogue elements the login requires a valid email address.\n" 256 "Consider using any large email service if you want to avoid using your private email address.\n" 258 "Selecting the button below opens your web browser to http://bugs.trinitydesktop.org,\n" 259 "where you will find the report form.\n" 260 "The information displayed above will be transferred to the reporting system.\n" 261 "Session cookies must be enabled to use the reporting system.\n" 263 "Thank you for helping!");
264 TQLabel * label =
new TQLabel( text, parent,
"label");
265 lay->addWidget( label );
269 d->submitBugButton->setText( i18n(
"&Launch Bug Report Wizard") );
270 d->submitBugButton->setSizePolicy(TQSizePolicy::Fixed,TQSizePolicy::Fixed);
271 lay->addWidget( d->submitBugButton );
274 connect( d->submitBugButton, TQT_SIGNAL(clicked()),
275 this, TQT_SLOT(
slotOk()));
286 KURL url (
"http://bugs.trinitydesktop.org/enter_bug.cgi" );
289 url.
addQueryItem(
"cf_kde_compiler", KDE_COMPILER_VERSION );
292 url.
addQueryItem(
"cf_kde_package", d->appcombo->currentText() );
299 TQString appName = d->appcombo->text(i);
300 int index = appName.find(
'/' );
302 appName = appName.left( index );
305 if (d->appname == appName && m_aboutData)
306 m_strVersion = m_aboutData->
version();
308 m_strVersion = i18n(
"unknown program name",
"unknown");
310 if ( !d->submitBugButton )
311 m_strVersion += d->kde_version;
313 m_version->setText(m_strVersion);
314 if ( d->submitBugButton )
320 if (m_process)
return;
322 *m_process << TQString::fromLatin1(
"kcmshell") << TQString::fromLatin1(
"kcm_useraccount");
324 if (!m_process->
start())
331 m_configureEmail->setEnabled(
false);
338 m_configureEmail->setEnabled(
true);
341 KConfig emailConf( TQString::fromLatin1(
"emaildefaults") );
344 emailConf.
setGroup( TQString::fromLatin1(
"Defaults") );
345 TQString profile = TQString::fromLatin1(
"PROFILE_");
346 profile += emailConf.
readEntry( TQString::fromLatin1(
"Profile"),
347 TQString::fromLatin1(
"Default") );
350 TQString fromaddr = emailConf.
readEntry( TQString::fromLatin1(
"EmailAddress") );
351 if (fromaddr.isEmpty()) {
353 p = getpwuid(getuid());
354 fromaddr = TQString::fromLatin1(p->pw_name);
356 TQString name = emailConf.
readEntry( TQString::fromLatin1(
"FullName"));
358 fromaddr = name + TQString::fromLatin1(
" <") + fromaddr + TQString::fromLatin1(
">");
360 m_from->setText( fromaddr );
366 kapp->invokeBrowser( urlText );
370 if ( d->submitBugButton )
377 if ( d->submitBugButton ) {
379 kapp->invokeBrowser( d->url.url() );
383 if( m_lineedit->text().isEmpty() ||
384 m_subject->text().isEmpty() )
386 TQString msg = i18n(
"You must specify both a subject and a description " 387 "before the report can be sent.");
392 switch ( m_bgSeverity->id( m_bgSeverity->selected() ) )
396 "<p>You chose the severity <b>Critical</b>. " 397 "Please note that this severity is intended only for bugs that</p>" 398 "<ul><li>break unrelated software on the system (or the whole system)</li>" 399 "<li>cause serious data loss</li>" 400 "<li>introduce a security hole on the system where the affected package is installed</li></ul>\n" 401 "<p>Does the bug you are reporting cause any of the above damage? " 402 "If it does not, please select a lower severity. Thank you!</p>" ),TQString::null,
KStdGuiItem::cont(),KStdGuiItem::cancel() ) == KMessageBox::No )
407 "<p>You chose the severity <b>Grave</b>. " 408 "Please note that this severity is intended only for bugs that</p>" 409 "<ul><li>make the package in question unusable or mostly so</li>" 410 "<li>cause data loss</li>" 411 "<li>introduce a security hole allowing access to the accounts of users who use the affected package</li></ul>\n" 412 "<p>Does the bug you are reporting cause any of the above damage? " 413 "If it does not, please select a lower severity. Thank you!</p>" ),TQString::null,
KStdGuiItem::cont(),KStdGuiItem::cancel() ) == KMessageBox::No )
419 TQString msg = i18n(
"Unable to send the bug report.\n" 420 "Please submit a bug report manually...\n" 421 "See http://bugs.trinitydesktop.org/ for instructions.");
427 i18n(
"Bug report sent, thank you for your input."));
433 if( !d->submitBugButton && ( m_lineedit->edited() || m_subject->edited() ) )
436 i18n(
"Close and discard\nedited message?" ),
438 if( rc == KMessageBox::No )
447 kdDebug() << m_bgSeverity->selected()->name() <<
endl;
449 TQString severity = TQString::fromLatin1(m_bgSeverity->selected()->name());
450 TQString appname = d->appcombo->currentText();
451 TQString os = TQString::fromLatin1(
"OS: %1 (%2)\n").
452 arg(KDE_COMPILING_OS).
453 arg(KDE_DISTRIBUTION_TEXT);
455 for(
int i = 0; i < m_lineedit->numLines(); i++)
457 TQString line = m_lineedit->textLine(i);
458 if (!line.endsWith(
"\n"))
465 TQString
package = TQString::fromLatin1("i18n_%1").arg(KGlobal::locale()->language());
466 package = package.replace(TQString::fromLatin1("_"), TQString::fromLatin1("-"));
467 return TQString::fromLatin1(
"Package: %1").arg(package) +
468 TQString::fromLatin1(
"\n" 471 "Version: %2\n").arg(appname).arg(m_strVersion)+
472 os+TQString::fromLatin1(
"\n")+bodyText;
474 appname = appname.replace(TQString::fromLatin1(
"_"), TQString::fromLatin1(
"-"));
476 return TQString::fromLatin1(
"Package: %1\n" 479 .arg(appname).arg(m_strVersion).arg(severity)+
480 TQString::fromLatin1(
"Compiler: %1\n").arg(KDE_COMPILER_VERSION)+
481 os+TQString::fromLatin1(
"\n")+bodyText;
487 TQString recipient ( m_aboutData ?
488 m_aboutData->bugAddress() :
489 TQString::fromLatin1(
"submit@bugs.trinitydesktop.org") );
492 command =
locate(
"exe",
"ksendbugmail");
493 if (command.isEmpty())
499 TQString subject = m_subject->text();
500 command +=
" --subject ";
502 command +=
" --recipient ";
510 FILE * fd = popen(TQFile::encodeName(command),
"w");
513 kdError() <<
"Unable to open a pipe to " << command <<
endl;
517 TQString btext =
text();
518 fwrite(btext.ascii(),btext.length(),1,fd);
521 int error = pclose(fd);
522 kdDebug() <<
"exit status1 " << error <<
" " << (WIFEXITED(error)) <<
" " << WEXITSTATUS(error) <<
endl;
524 if ((WIFEXITED(error)) && WEXITSTATUS(error) == 1) {
525 TQFile of(outputfile.
name());
526 if (of.open(IO_ReadOnly )) {
527 TQTextStream is(&of);
528 is.setEncoding(TQTextStream::UnicodeUTF8);
531 line = is.readLine();
534 d->lastError = TQString::null;
543 void KBugReport::virtual_hook(
int id,
void* data )
544 { KDialogBase::virtual_hook(
id, data ); }
546 #include "kbugreport.moc" static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
Display an "Error" dialog.
TQString locate(const char *type, const TQString &filename, const KInstance *instance=KGlobal::instance())
static KLocale * locale()
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.
virtual void slotOk(void)
OK has been clicked.
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 addQueryItem(const TQString &_item, const TQString &_value, int encoding_hint=0)
void setButtonCancel(const KGuiItem &item=KStdGuiItem::cancel())
Sets the appearance of the Cancel button.
TQString language() const
void showButtonOK(bool state)
Hide or display the OK button.
kdbgstream kdError(int area=0)
const char * productName() const
const KAboutData * aboutData() const
static TQString findExe(const TQString &appname, const TQString &pathstr=TQString::null, bool ignoreExecBit=false)
void updateURL()
Update the url to match the current os, compiler, selected app, etc.
TQString text() const
A complete copy of the bug report.
virtual bool start(RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
kdbgstream kdDebug(int area=0)
static KGuiItem cont()
Returns a "continue" item.
virtual ~KBugReport()
Destructor.
void setGroup(const TQString &group)
A dialog base class with standard buttons and predefined layouts.
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
KBugReport(TQWidget *parent=0L, bool modal=true, const KAboutData *aboutData=0L)
Creates a bug-report dialog.
An abstract class for GUI data such as ToolTip and Icon.
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.
void appChanged(int)
Application combo selection changed (and was activated)
static KInstance * instance()
virtual void slotConfigureEmail()
"Configure email" has been clicked - this calls kcmshell System/email
TQFrame * plainPage()
Retrieve the empty page when the predefined layout is used in Plain mode.
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
virtual void slotCancel()
Activated when the Cancel button has been clicked.
static TQString quote(const TQString &arg)
An enhanced TQLineEdit widget for inputting text.
static TQString defaultLanguage()
void setButtonOK(const KGuiItem &item=KStdGuiItem::ok())
Sets the appearance of the OK button.
bool sendBugReport()
Attempt to e-mail the bug report.
TQString bugAddress() const
kndbgstream & endl(kndbgstream &s)
virtual void slotCancel()
Cancel has been clicked.
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.