And another patch... -CICQDaemon::ViewUrl now returns false if exec fails
-UrlViewer editbox is replaced by a editable combobox, filled with some default values -Default KDE browser (=Konqi) is only started when no other viewer is specified (config item UrlViewer == "none" or empty). Now I can use viewurl-mozilla.sh together with --with-kde, which I couldn't before.
? autom4te.cache ? plugins/auto-reply/autom4te.cache ? plugins/console/autom4te.cache ? plugins/jons-gtk-gui/autom4te.cache ? plugins/jons-gtk-gui/config.h.in ? plugins/qt-gui/autom4te.cache ? plugins/rms/autom4te.cache Index: plugins/qt-gui/src/mlview3.cpp =================================================================== RCS file: /cvsroot/licq/qt-gui/src/mlview3.cpp,v retrieving revision 1.8 diff -u -3 -p -r1.8 mlview3.cpp --- plugins/qt-gui/src/mlview3.cpp 16 Sep 2002 23:25:44 -0000 1.8 +++ plugins/qt-gui/src/mlview3.cpp 19 Feb 2003 01:28:30 -0000 @@ -158,11 +158,13 @@ void MLView::setSource(const QString& na { #ifdef USE_KDE KApplication* app = static_cast<KApplication*>(qApp); - if (name.find(QRegExp("^\\w+://")) > -1) + // If no URL viewer is set, use KDE default + if (m_licqDaemon && (!m_licqDaemon->getUrlViewer()) && (name.find(QRegExp("^\\w+://")) > -1)) app->invokeBrowser( name ); else if (name.startsWith("mailto:")) app->invokeMailer( KURL(name) ); -#else + else +#endif if (name.find(QRegExp("^\\w+:")) > -1) { if (m_licqDaemon == NULL) @@ -170,7 +172,6 @@ void MLView::setSource(const QString& na else if (!m_licqDaemon->ViewUrl(name.local8Bit().data())) WarnUser(this, tr("Licq is unable to start your browser and open the URL.\nYou will need to start the browser and open the URL manually.")); } -#endif } } Index: plugins/qt-gui/src/optionsdlg.cpp =================================================================== RCS file: /cvsroot/licq/qt-gui/src/optionsdlg.cpp,v retrieving revision 1.129 diff -u -3 -p -r1.129 optionsdlg.cpp --- plugins/qt-gui/src/optionsdlg.cpp 7 Jan 2003 05:20:37 -0000 1.129 +++ plugins/qt-gui/src/optionsdlg.cpp 19 Feb 2003 01:28:31 -0000 @@ -39,9 +39,11 @@ #include <kapp.h> #include <kfontdialog.h> #include <kurlrequester.h> +#define DEFAULT_URL_VIEWER tr("KDE default") #else #include <qapplication.h> #include <qfontdialog.h> +#define DEFAULT_URL_VIEWER tr("none") #endif #include "optionsdlg.h" @@ -322,8 +324,8 @@ void OptionsDlg::SetupOptions() chkIgnoreEmailPager->setChecked(mainwin->licqDaemon->Ignore(IGNORE_EMAILPAGER)); // plugins tab - edtUrlViewer->setText(mainwin->licqDaemon->getUrlViewer() == NULL ? - tr("none") : QString(mainwin->licqDaemon->getUrlViewer())); + cmbUrlViewer->setCurrentText(mainwin->licqDaemon->getUrlViewer() == NULL ? + DEFAULT_URL_VIEWER : QString(mainwin->licqDaemon->getUrlViewer())); edtTerminal->setText(mainwin->licqDaemon->Terminal() == NULL ? tr("none") : QString(mainwin->licqDaemon->Terminal())); @@ -531,7 +533,11 @@ void OptionsDlg::ApplyOptions() mainwin->licqDaemon->SetIgnore(IGNORE_EMAILPAGER, chkIgnoreEmailPager->isChecked()); // Plugin tab - mainwin->licqDaemon->setUrlViewer(edtUrlViewer->text().local8Bit()); + if (cmbUrlViewer->currentText() == DEFAULT_URL_VIEWER) + mainwin->licqDaemon->setUrlViewer("none"); // untranslated! + else + mainwin->licqDaemon->setUrlViewer(cmbUrlViewer->currentText().local8Bit()); + mainwin->licqDaemon->SetTerminal(edtTerminal->text().local8Bit()); if (cmbDefaultEncoding->currentItem() > 0) mainwin->m_DefaultEncoding = UserCodec::encodingForName(cmbDefaultEncoding->currentText()); @@ -1271,7 +1277,15 @@ QWidget* OptionsDlg::new_misc_options() lblUrlViewer = new QLabel(tr("Url Viewer:"), boxExtensions); QWhatsThis::add(lblUrlViewer, tr("The command to run to view a URL. Will be passed the URL " "as a parameter.")); - edtUrlViewer = new QLineEdit(boxExtensions); + cmbUrlViewer = new QComboBox(true, boxExtensions); + cmbUrlViewer->insertItem(DEFAULT_URL_VIEWER); + cmbUrlViewer->insertItem("viewurl-lynx.sh"); + cmbUrlViewer->insertItem("viewurl-mozilla.sh"); + cmbUrlViewer->insertItem("viewurl-ncftp.sh"); + cmbUrlViewer->insertItem("viewurl-netscape.sh"); + cmbUrlViewer->insertItem("viewurl-opera.sh"); + cmbUrlViewer->insertItem("viewurl-w3m.sh"); + lblTerminal = new QLabel(tr("Terminal:"), boxExtensions); edtTerminal = new QLineEdit(tr("Terminal:"), boxExtensions); QWhatsThis::add(edtTerminal, tr("The command to run to start your terminal program.")); Index: plugins/qt-gui/src/optionsdlg.h =================================================================== RCS file: /cvsroot/licq/qt-gui/src/optionsdlg.h,v retrieving revision 1.60 diff -u -3 -p -r1.60 optionsdlg.h --- plugins/qt-gui/src/optionsdlg.h 7 Jan 2003 08:00:53 -0000 1.60 +++ plugins/qt-gui/src/optionsdlg.h 19 Feb 2003 01:28:31 -0000 @@ -101,7 +101,7 @@ protected: QWidget* new_misc_options(); QGroupBox *boxParanoia, *boxExtensions; QLabel *lblUrlViewer, *lblDefaultEncoding; - QLineEdit *edtUrlViewer; + QComboBox *cmbUrlViewer; QComboBox *cmbDefaultEncoding; QLabel *lblTerminal; QLineEdit *edtTerminal; Index: src/icqd.cpp =================================================================== RCS file: /cvsroot/licq/licq/src/icqd.cpp,v retrieving revision 1.64 diff -u -3 -p -r1.64 icqd.cpp --- src/icqd.cpp 1 Feb 2003 05:21:29 -0000 1.64 +++ src/icqd.cpp 19 Feb 2003 01:28:33 -0000 @@ -622,7 +622,7 @@ void CICQDaemon::SetAlwaysOnlineNotify(b const char *CICQDaemon::getUrlViewer() { - if (strcmp(m_szUrlViewer, "none") == 0) + if ((strcmp(m_szUrlViewer, "none") == 0) || (strlen(m_szUrlViewer) == 0)) return (NULL); else return (m_szUrlViewer); @@ -636,20 +636,41 @@ void CICQDaemon::setUrlViewer(const char bool CICQDaemon::ViewUrl(const char *u) { - if (strcmp(m_szUrlViewer, "none") == 0) return false; + if (getUrlViewer() == NULL) return false; char **arglist = (char**)malloc( 3*sizeof(char*)); arglist[0] = m_szUrlViewer; arglist[1] = (char*)u; arglist[2] = NULL; - if(!fork()) { + int pp[2]; + if (pipe(pp) < 0) return false; + + switch (fork()) { + case -1: + close(pp[0]); + close(pp[1]); + return false; + case 0: + close(pp[0]); + + // set close-on-exec flag + fcntl(pp[1], F_SETFD, 1); + execvp(arglist[0], arglist); + + // send a message indicating the failure + write(pp[1], (char *) &errno, sizeof errno); _exit(-1); } free(arglist); - return true; + close(pp[1]); + int err; + int n = read(pp[0], (char *) &err, sizeof err); + close(pp[0]); + + return (n == 0); }
ciao Jörg