[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    knode patch
From:       Christian Gebauer <gebauer () bigfoot ! com>
Date:       2000-09-16 3:20:22
[Download RAW message or body]

Hi,

big patch, sorry.

* keep the search dialog open when switching to another group
  the code was buggy because the original filter wasn't correctly
  restored, and we get a new feature for free.

* switched from KApplication to KUniqueApplication.
  we should have done this earlier, because two knode instances
  running in parallel will corrupt your data.

* added a "Save Options" entry to the settings menu to be compilant
  with the style guide. The code is now in sync with the latest
  API changes in KMainWindow.

* fixed two buglets concerning signature handling:
  use a directly entered sig as default again, and don't insert
  sigdashes for empty sigs

* filter out key events with SHIFT in KNListview to prevent
  multiselection with SHIFT+cursor keys (we "abuse" the
  multiselection mode to improve the keyboard navigation, but
  KNode can not yet handle multiselection)

* fix for #9747 (grave crash, easy to reproduce with large groups
  on a remote server) by adding a mutex.

Christian
-- 
>><< Christian Gebauer >><< gebauer@bigfoot.com >><< ICQ 14916141 >><<
["knode.diff" (text/plain)]

? knapplication.h
? knapplication.cpp
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdenetwork/knode/Makefile.am,v
retrieving revision 1.17
diff -u -3 -p -r1.17 Makefile.am
--- Makefile.am	2000/08/10 12:13:20	1.17
+++ Makefile.am	2000/09/16 02:43:38
@@ -23,13 +23,13 @@ knode_SOURCES = kngroupbrowser.cpp knpur
 	knscoredialog.cpp knthread.cpp knfiltermanager.cpp \
 	knstatusfilter.cpp knstringfilter.cpp knrangefilter.cpp \
 	knfilterdialog.cpp kngroupdialog.cpp  knstringsplitter.cpp \
-        knhdrviewitem.cpp knlistview.cpp knlistbox.cpp 	utilities.cpp \
-        knodeview.cpp knode.cpp main.cpp
+	knhdrviewitem.cpp knlistview.cpp knlistbox.cpp 	utilities.cpp \
+	knodeview.cpp knode.cpp knapplication.cpp main.cpp
 
 noinst_HEADERS = knaccmailsettings.h      knglobals.h              knrangefilter.h \
 	knaccnewssettings.h      kngroup.h                knappsettings.h \
 	knaccountmanager.h       kngroupdialog.h          knreadgensettings.h \
-	knarticle.h              knreadhdrsettings.h \
+	knarticle.h              knreadhdrsettings.h      knapplication.h \
 	knarticlebase.h          kngroupmanager.h         knsavedarticle.h \
 	knarticlecollection.h    kngrouppropdlg.h         knsavedarticlemanager.h \
 	knarticlefilter.h        kngroupselectdialog.h    knscoredialog.h \
Index: knarticlewindow.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knode/knarticlewindow.cpp,v
retrieving revision 1.19
diff -u -3 -p -r1.19 knarticlewindow.cpp
--- knarticlewindow.cpp	2000/08/15 00:34:53	1.19
+++ knarticlewindow.cpp	2000/09/16 02:43:38
@@ -19,6 +19,7 @@
 #include <klocale.h>
 #include <kedittoolbar.h>
 #include <kkeydialog.h>
+#include <kconfig.h>
 
 #include "kngroup.h"
 #include "knsavedarticle.h"
@@ -31,8 +32,8 @@
 #include "knarticlewindow.h"
 
 
-KNArticleWindow::KNArticleWindow(KNArticle *art, KNArticleCollection *col, const \
                char *name )
-  : KMainWindow(0, name)
+KNArticleWindow::KNArticleWindow(KNArticle *art, KNArticleCollection *col)
+  : KMainWindow(0, "articleWindow")
 {
   if(art)
     setCaption(art->subject());
@@ -66,25 +67,35 @@ KNArticleWindow::KNArticleWindow(KNArtic
   actSupersede->setEnabled(false);
 
   // settings menu
-  KStdAction::showToolbar(this, SLOT(slotToggleToolBar()), actionCollection());
+  actShowToolbar = KStdAction::showToolbar(this, SLOT(slotToggleToolBar()), \
actionCollection()); +  KStdAction::saveOptions(this, SLOT(slotSaveOptions()), \
actionCollection());  KStdAction::keyBindings(this, SLOT(slotConfKeys()), \
actionCollection());  KStdAction::configureToolbars(this, SLOT(slotConfToolbar()), \
actionCollection());  KStdAction::preferences(knGlobals.top, SLOT(slotSettings()), \
actionCollection());  
   createGUI("knreaderui.rc");
 
-  restoreWindowSize("reader", this, QSize(500,400));
+  KConfig *conf = KGlobal::config();
+  conf->setGroup("articleWindow_options");
+  applyMainWindowSettings(conf);
+  actShowToolbar->setChecked(!toolBar()->isHidden());
 }
 
 
 
 KNArticleWindow::~KNArticleWindow()
 {
-  saveWindowSize("reader", size()); 
 }
 
 
 
+QSize KNArticleWindow::sizeHint() const
+{
+  return QSize(500,400);    // default optimized for 800x600
+}
+
+
+
 void KNArticleWindow::slotArticleLoaded()
 {
   actPostReply->setEnabled(true);
@@ -140,10 +151,19 @@ void KNArticleWindow::slotArtSupersede()
 
 void KNArticleWindow::slotToggleToolBar()
 {
-  if(toolBar("mainToolBar")->isVisible())
-    toolBar("mainToolBar")->hide();
+  if(toolBar()->isVisible())
+    toolBar()->hide();
   else
-    toolBar("mainToolBar")->show();
+    toolBar()->show();
+}
+
+
+
+void KNArticleWindow::slotSaveOptions()
+{
+  KConfig *conf = KGlobal::config();
+  conf->setGroup("articleWindow_options");
+  saveMainWindowSettings(conf);
 }
 
 
Index: knarticlewindow.h
===================================================================
RCS file: /home/kde/kdenetwork/knode/knarticlewindow.h,v
retrieving revision 1.8
diff -u -3 -p -r1.8 knarticlewindow.h
--- knarticlewindow.h	2000/08/13 16:13:23	1.8
+++ knarticlewindow.h	2000/09/16 02:43:38
@@ -32,13 +32,16 @@ class KNArticleWindow : public KMainWind
   Q_OBJECT
   
   public:
-    KNArticleWindow(KNArticle *art=0, KNArticleCollection *col=0, const char \
*name=0); +    KNArticleWindow(KNArticle *art=0, KNArticleCollection *col=0);
     ~KNArticleWindow();
     KNArticleWidget* artWidget()        { return artW; }
+
+    virtual QSize sizeHint() const;   // useful default value
       
   protected:
     KNArticleWidget *artW;
     KAction *actPostReply, *actMailReply, *actForward, *actCancel, *actSupersede;
+    KToggleAction *actShowToolbar;
     
   protected slots:
     void slotArticleLoaded();
@@ -49,6 +52,7 @@ class KNArticleWindow : public KMainWind
     void slotArtCancel();
     void slotArtSupersede();
     void slotToggleToolBar();
+    void slotSaveOptions();
     void slotConfKeys();
     void slotConfToolbar();
 };
Index: kncomposer.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knode/kncomposer.cpp,v
retrieving revision 1.39
diff -u -3 -p -r1.39 kncomposer.cpp
--- kncomposer.cpp	2000/09/06 22:43:07	1.39
+++ kncomposer.cpp	2000/09/16 02:43:38
@@ -52,7 +52,7 @@
 // firstEdit==true: place the cursor at the end of the article
 // n==0: eMail
 KNComposer::KNComposer(KNSavedArticle *a, const QCString &sig, bool firstEdit, \
                KNNntpAccount *n)//, int textEnc)
-    : KMainWindow(0), spellChecker(0), r_esult(CRsave), a_rticle(a), nntp(n),
+    : KMainWindow(0,"composerWindow"), spellChecker(0), r_esult(CRsave), \
                a_rticle(a), nntp(n),
       externalEdited(false), attChanged(false), externalEditor(0), \
editorTempfile(0)//, textCTE(textEnc)  {
   if(!sig.isEmpty()) s_ignature=sig.copy();
@@ -121,7 +121,8 @@ KNComposer::KNComposer(KNSavedArticle *a
                                         actionCollection(), \
"attachment_properties");  
   // settings menu
-  KStdAction::showToolbar(this, SLOT(slotToggleToolBar()), actionCollection());
+  actShowToolbar = KStdAction::showToolbar(this, SLOT(slotToggleToolBar()), \
actionCollection()); +  KStdAction::saveOptions(this, SLOT(slotSaveOptions()), \
actionCollection());  KStdAction::keyBindings(this, SLOT(slotConfKeys()), \
actionCollection());  KStdAction::configureToolbars(this, SLOT(slotConfToolbar()), \
actionCollection());  KStdAction::preferences(knGlobals.top, SLOT(slotSettings()), \
actionCollection()); @@ -146,13 +147,13 @@ KNComposer::KNComposer(KNSavedArticle *a
 
   if (firstEdit && appSig) slotAppendSig();
 
-  if (view->viewOpen)
-    restoreWindowSize("composerAtt", this, QSize(535,450));  // optimized default \
                for 800x600
-  else
-    restoreWindowSize("composer", this, QSize(535,450));     // optimized default \
                for 800x600
-
   view->edit->setModified(false);
-    
+
+  KConfig *conf = KGlobal::config();
+  conf->setGroup("composerWindow_options");
+  applyMainWindowSettings(conf);
+  actShowToolbar->setChecked(!toolBar()->isHidden());
+
   if (useExternalEditor) slotExternalEditor();
 }
 
@@ -166,10 +167,12 @@ KNComposer::~KNComposer()
     editorTempfile->unlink();
     delete editorTempfile;
   }
-  if (view->viewOpen)
-    saveWindowSize("composerAtt", size());
-  else
-    saveWindowSize("composer", size());
+}
+
+
+QSize KNComposer::sizeHint() const
+{
+  return QSize(535,450);    // default optimized for 800x600
 }
 
 
@@ -624,7 +627,6 @@ void KNComposer::slotAttachFile()
     if (!view->viewOpen) {
       saveWindowSize("composer", size());
       view->showAttachmentView();
-      restoreWindowSize("composerAtt", this, QSize(535,450));  // optimized default \
for 800x600  }
     (void) new AttachmentViewItem(view->attView, new KNAttachment(path));
     attChanged=true;
@@ -647,7 +649,6 @@ void KNComposer::slotRemoveAttachment()
     if(view->attView->childCount()==0) {
       saveWindowSize("composerAtt", size());
       view->hideAttachmentView();
-      restoreWindowSize("composer", this, QSize(535,450));     // optimized default \
for 800x600  }
 
     attChanged=true;
@@ -705,10 +706,19 @@ void KNComposer::slotAttachmentRemove(QL
     
 void KNComposer::slotToggleToolBar()
 {
-  if(toolBar("mainToolBar")->isVisible())
-    toolBar("mainToolBar")->hide();
+  if(toolBar()->isVisible())
+    toolBar()->hide();
   else
-    toolBar("mainToolBar")->show();
+    toolBar()->show();
+}
+
+
+void KNComposer::slotSaveOptions()
+{
+  KConfig *conf = KGlobal::config();
+  conf->setGroup("composerWindow_options");
+  saveMainWindowSettings(conf);
+  view->saveOptions();
 }
 
 
@@ -909,20 +919,6 @@ KNComposer::ComposerView::ComposerView(Q
 
 KNComposer::ComposerView::~ComposerView()
 {
-  if (viewOpen) {
-    KConfig *conf=KGlobal::config();
-    conf->setGroup("POSTNEWS");
-
-    conf->writeEntry("Att_Splitter",sizes());   // save splitter pos
-
-    QValueList<int> lst;                        // save header sizes
-    QHeader *h=attView->header();
-    for (int i=0; i<5; i++)
-      lst << h->sectionSize(i);
-    conf->writeEntry("Att_Headers",lst);
-
-    conf->sync();
-  }
 }
 
 
@@ -993,19 +989,6 @@ void KNComposer::ComposerView::showAttac
 void KNComposer::ComposerView::hideAttachmentView()
 {
   if (viewOpen) {
-    KConfig *conf=KGlobal::config();
-    conf->setGroup("POSTNEWS");
-
-    conf->writeEntry("Att_Splitter",sizes());   // save splitter pos
-
-    QValueList<int> lst;                        // save header sizes
-    QHeader *h=attView->header();
-    for (int i=0; i<5; i++)
-      lst << h->sectionSize(i);
-    conf->writeEntry("Att_Headers",lst);
-
-    conf->sync();
-
     attWidget->hide();
     viewOpen = false;
   }
@@ -1027,6 +1010,23 @@ void KNComposer::ComposerView::hideExter
   notification->hide();
 }
 
+
+
+void KNComposer::ComposerView::saveOptions()
+{
+  if (viewOpen) {
+    KConfig *conf=KGlobal::config();
+    conf->setGroup("POSTNEWS");
+
+    conf->writeEntry("Att_Splitter",sizes());   // save splitter pos
+
+    QValueList<int> lst;                        // save header sizes
+    QHeader *h=attView->header();
+    for (int i=0; i<5; i++)
+      lst << h->sectionSize(i);
+    conf->writeEntry("Att_Headers",lst);
+  }
+}
 
 
 //===============================================================
Index: kncomposer.h
===================================================================
RCS file: /home/kde/kdenetwork/knode/kncomposer.h,v
retrieving revision 1.14
diff -u -3 -p -r1.14 kncomposer.h
--- kncomposer.h	2000/08/11 20:34:48	1.14
+++ kncomposer.h	2000/09/16 02:43:38
@@ -64,7 +64,8 @@ class KNComposer : public KMainWindow  {
     void setDoneSuccess(bool b)           { doneSuccess = b; }
     void setConfig();
     void applyChanges();      
-  
+
+    virtual QSize sizeHint() const;   // useful default value
             
   protected:
     void closeEvent(QCloseEvent *e);
@@ -98,6 +99,8 @@ class KNComposer : public KMainWindow  {
         void hideAttachmentView();
         void showExternalNotification();
         void hideExternalNotification();
+
+        void saveOptions();
       
         Editor *edit;
         QGroupBox *notification;
@@ -122,6 +125,7 @@ class KNComposer : public KMainWindow  {
     bool doneSuccess, externalEdited, attChanged;
     KAction *actExternalEditor, *actSpellCheck,
             *actRemoveAttachment, *actAttachmentProperties;
+    KToggleAction *actShowToolbar;
     KProcess *externalEditor;
     KTempFile *editorTempfile;
     QList<KNAttachment> *delAttList;
@@ -152,6 +156,7 @@ class KNComposer : public KMainWindow  {
     void slotRemoveAttachment();
     void slotAttachmentProperties();    
     void slotToggleToolBar();
+    void slotSaveOptions();
     void slotConfKeys();
     void slotConfToolbar();
     
Index: knfetcharticlemanager.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knode/knfetcharticlemanager.cpp,v
retrieving revision 1.26
diff -u -3 -p -r1.26 knfetcharticlemanager.cpp
--- knfetcharticlemanager.cpp	2000/09/08 01:19:46	1.26
+++ knfetcharticlemanager.cpp	2000/09/16 02:43:38
@@ -15,6 +15,8 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <pthread.h>
+
 #include <qheader.h>
 
 #include <klocale.h>
@@ -152,10 +154,6 @@ void KNFetchArticleManager::setGroup(KNG
 {
   if(g!=0) {
     if(g_roup==0) view->header()->setLabel(1, i18n("From"));   // switch back from a \
                folder
-    if(sDlg) {                        // search dialog was open, hide it and restore \
                filter
-      sDlg->hide();
-      if(f_ilter==sDlg->filter()) slotFilterChanged(0);
-    }
     actShowThreads->setEnabled(true);
     actExpandAll->setEnabled(true);
     actCollapseAll->setEnabled(true);
@@ -194,6 +192,20 @@ void KNFetchArticleManager::showHdrs(boo
     view->clear();
     setCurrentArticle(0);
   }
+
+  bool unlock = false;
+  if (g_roup->locked()) {
+    if (0==pthread_mutex_lock(knGlobals.netAccess->nntpMutex())) {
+      unlock = true;
+    } else {
+      kdDebug(5003) << "failed to lock nntp mutex" << endl;
+      knGlobals.top->setStatusMsg("");
+      updateStatusString();
+      knGlobals.top->setCursorBusy(false);
+      return;
+    }
+  }
+
   if(f_ilter) f_ilter->doFilter(g_roup);
   else
     for (int i=0; i<g_roup->length(); i++)
@@ -219,6 +231,10 @@ void KNFetchArticleManager::showHdrs(boo
         art->updateListItem();
     }
   }
+
+  if (unlock && (0!=pthread_mutex_unlock(knGlobals.netAccess->nntpMutex())))
+    kdDebug(5003) << "failed to unlock nntp mutex" << endl;
+
   if(view->firstChild())
     view->setCurrentItem(view->firstChild());
 
Index: knlistview.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knode/knlistview.cpp,v
retrieving revision 1.11
diff -u -3 -p -r1.11 knlistview.cpp
--- knlistview.cpp	2000/09/06 22:43:07	1.11
+++ knlistview.cpp	2000/09/16 02:43:38
@@ -275,6 +275,11 @@ void KNListView::keyPressEvent(QKeyEvent
 {
   if ( !e )       return; // subclass bug
 
+  if (e->state() & ShiftButton) {  // lame workaround to avoid multiselection in \
multiselection mode ;-) +    e->ignore();
+    return;
+  }
+
   switch(e->key()) {
    case Key_Enter:
    case Key_Return:
Index: knnetaccess.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knode/knnetaccess.cpp,v
retrieving revision 1.10
diff -u -3 -p -r1.10 knnetaccess.cpp
--- knnetaccess.cpp	2000/08/29 23:16:37	1.10
+++ knnetaccess.cpp	2000/09/16 02:43:39
@@ -58,9 +58,13 @@ KNNetAccess::KNNetAccess(QObject *parent
   smtpNotifier=new QSocketNotifier(smtpInPipe[0], QSocketNotifier::Read);
   connect(smtpNotifier, SIGNAL(activated(int)), this, SLOT(slotThreadSignal(int)));
 
-  nntpClient=new KNNntpClient(nntpOutPipe[0],nntpInPipe[1],this);
+  nntpClient=new KNNntpClient(nntpOutPipe[0],nntpInPipe[1],&nntp_Mutex,this);
   smtpClient=new KNSmtpClient(smtpOutPipe[0],smtpInPipe[1],this);
   
+  if(pthread_mutex_init(&nntp_Mutex, NULL)!=0) {
+    KMessageBox::error(knGlobals.topWidget, "Internal error:\nCannot initialize the \
nntp mutex!");  // i18n missing +    kapp->exit(1);
+  }
   if(pthread_create(&nntpThread, 0,&(nntpClient->startThread), nntpClient)!=0) {
     KMessageBox::error(knGlobals.topWidget, i18n("Internal error:\nCannot create the \
nntp-network-thread!"));  kapp->exit(1);
@@ -86,13 +90,15 @@ KNNetAccess::~KNNetAccess()
   disconnect(smtpNotifier, SIGNAL(activated(int)), this, \
SLOT(slotThreadSignal(int)));  
   if(pthread_cancel(nntpThread)!=0)
-    kdWarning(5003) << "KNNetAccess::~KNNetAccess() : cannot cancel thread" << endl;
+    kdWarning(5003) << "KNNetAccess::~KNNetAccess() : cannot cancel nntp thread" << \
endl;  if (0!=pthread_join(nntpThread,NULL))                         // join is \
                important...
-    kdWarning(5003) << "KNNetAccess::~KNNetAccess() : cannot join thread" << endl;
+    kdWarning(5003) << "KNNetAccess::~KNNetAccess() : cannot join nntp thread" << \
endl; +  if (0!=pthread_mutex_destroy(&nntp_Mutex))
+    kdWarning(5003) << "KNNetAccess::~KNNetAccess() : cannot destroy nntp mutex" << \
endl;  if(pthread_cancel(smtpThread)!=0)
-    kdWarning(5003) << "KNNetAccess::~KNNetAccess() : cannot cancel thread" << endl;
+    kdWarning(5003) << "KNNetAccess::~KNNetAccess() : cannot cancel smtp thread" << \
endl;  if (0!=pthread_join(smtpThread,NULL))                         // join is \
                important...
-    kdWarning(5003) << "KNNetAccess::~KNNetAccess() : cannot join thread" << endl;
+    kdWarning(5003) << "KNNetAccess::~KNNetAccess() : cannot join smtp thread" << \
endl;  
   delete nntpClient;
   delete smtpClient;
Index: knnetaccess.h
===================================================================
RCS file: /home/kde/kdenetwork/knode/knnetaccess.h,v
retrieving revision 1.5
diff -u -3 -p -r1.5 knnetaccess.h
--- knnetaccess.h	2000/07/27 19:44:04	1.5
+++ knnetaccess.h	2000/09/16 02:43:39
@@ -46,8 +46,10 @@ class KNNetAccess : public QObject  {
     
     void addJob(KNJobData *job);
     void stopJobsNntp(int type);         // type==0 => all jobs
-    void stopJobsSmtp(int type);         // type==0 => all jobs   
+    void stopJobsSmtp(int type);         // type==0 => all jobs
 
+    pthread_mutex_t* nntpMutex() { return &nntp_Mutex; }
+
   protected:
     void triggerAsyncThread(int pipeFd);     // passes a signal through the ipc-pipe \
to the net-thread  void startJobNntp();
@@ -63,6 +65,7 @@ class KNNetAccess : public QObject  {
     QQueue<KNJobData> nntpJobQueue, smtpJobQueue;
     KNJobData *currentNntpJob, *currentSmtpJob;
     pthread_t nntpThread, smtpThread;
+    pthread_mutex_t nntp_Mutex;
     int nntpInPipe[2], nntpOutPipe[2], smtpInPipe[2], smtpOutPipe[2];
     QSocketNotifier *nntpNotifier,*smtpNotifier;
     KAction* actNetStop;
Index: knnntpclient.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knode/knnntpclient.cpp,v
retrieving revision 1.13
diff -u -3 -p -r1.13 knnntpclient.cpp
--- knnntpclient.cpp	2000/09/03 23:06:03	1.13
+++ knnntpclient.cpp	2000/09/16 02:43:39
@@ -27,9 +27,11 @@
 #include "knnntpclient.h"
 
 
-KNNntpClient::KNNntpClient(int NfdPipeIn, int NfdPipeOut, QObject *parent, const \
char *name) +KNNntpClient::KNNntpClient(int NfdPipeIn, int NfdPipeOut, \
pthread_mutex_t *nntpMutex, QObject *parent, const char *name)  : \
                KNProtocolClient(NfdPipeIn,NfdPipeOut,parent,name)
-{}
+{
+  mutex = nntpMutex;
+}
 
 
 KNNntpClient::~KNNntpClient()
@@ -348,8 +350,14 @@ void KNNntpClient::doFetchNewHeaders()
   sendSignal(TSprogressUpdate);
     
   sendSignal(TSsortNew);
-  target->insortNewHeaders(&headers);
-  target->setLastNr(last);
+
+  if (0==pthread_mutex_lock(mutex)) {
+    target->insortNewHeaders(&headers);
+    target->setLastNr(last);
+    if (0!=pthread_mutex_unlock(mutex))
+      qDebug("knode: failed to unlock nntp mutex");
+  } else
+    qDebug("knode: failed to lock nntp mutex");
 }
 
 
Index: knnntpclient.h
===================================================================
RCS file: /home/kde/kdenetwork/knode/knnntpclient.h,v
retrieving revision 1.6
diff -u -3 -p -r1.6 knnntpclient.h
--- knnntpclient.h	2000/08/21 13:18:39	1.6
+++ knnntpclient.h	2000/09/16 02:43:39
@@ -19,6 +19,8 @@
 #ifndef KNNNTPCLIENT_H
 #define KNNNTPCLIENT_H
 
+#include <pthread.h>
+
 #include <knprotocolclient.h>
 
 
@@ -28,7 +30,7 @@ class KNNntpClient : public KNProtocolCl
 
   public:
     
-    KNNntpClient(int NfdPipeIn, int NfdPipeOut, QObject *parent=0, const char \
*name=0); +    KNNntpClient(int NfdPipeIn, int NfdPipeOut, pthread_mutex_t \
*nntpMutex, QObject *parent=0, const char *name=0);  ~KNNntpClient();
     
   protected:
@@ -45,6 +47,8 @@ class KNNntpClient : public KNProtocolCl
     virtual bool openConnection();     // connect, handshake
     virtual bool sendCommand(const QCString &cmd, int &rep);  // authentication on \
demand  virtual void handleErrors();
+
+    pthread_mutex_t *mutex;
     
 };
 
Index: knode.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knode/knode.cpp,v
retrieving revision 1.43
diff -u -3 -p -r1.43 knode.cpp
--- knode.cpp	2000/09/08 01:19:46	1.43
+++ knode.cpp	2000/09/16 02:43:39
@@ -198,7 +198,11 @@ KNodeApp::KNodeApp()
   initActions();
   initPopups();
 
-  restoreWindowSize("main", this, QSize(759,478));    // default optimized for \
800x600 +  KConfig *conf = KGlobal::config();
+  conf->setGroup("mainWindow_options");
+  applyMainWindowSettings(conf);
+  actShowToolbar->setChecked(!statusBar()->isHidden());
+  actShowStatusbar->setChecked(!toolBar()->isHidden());
 
   // set the keyboard focus indicator on the first item in the collectionView
   if(view->collectionView->firstChild())
@@ -301,6 +305,12 @@ void KNodeApp::secureProcessEvents()
 
 
 
+QSize KNodeApp::sizeHint() const
+{
+  return QSize(759,478);    // default optimized for 800x600
+}
+
+
 //============================ INIT && UPDATE ============================
 
 
@@ -368,8 +378,9 @@ void KNodeApp::initActions()
   connect(FAManager, SIGNAL(currentArticleChanged()), \
SLOT(slotCurrentArticleChanged()));  connect(SAManager, \
SIGNAL(currentArticleChanged()), SLOT(slotCurrentArticleChanged()));  
-  KStdAction::showToolbar(this, SLOT(slotToggleToolBar()), actionCollection());
-  KStdAction::showStatusbar(this, SLOT(slotToggleStatusBar()), actionCollection());
+  actShowToolbar = KStdAction::showToolbar(this, SLOT(slotToggleToolBar()), \
actionCollection()); +  actShowStatusbar = KStdAction::showStatusbar(this, \
SLOT(slotToggleStatusBar()), actionCollection()); +  KStdAction::saveOptions(this, \
SLOT(slotSaveOptions()), actionCollection());  KStdAction::keyBindings(this, \
SLOT(slotConfKeys()), actionCollection());  KStdAction::configureToolbars(this, \
SLOT(slotConfToolbar()), actionCollection());  KStdAction::preferences(this, \
SLOT(slotSettings()), actionCollection()); @@ -405,10 +416,8 @@ void \
KNodeApp::initPopups()  
 
 
-void KNodeApp::saveOptions()
+void KNodeApp::saveSettings()
 {
-  saveWindowSize("main", size());
-  view->saveOptions();
   FiManager->saveOptions();
   FAManager->saveOptions();
   KNArticleWidget::saveOptions();
@@ -483,10 +492,10 @@ void KNodeApp::slotSupersede()
 
 void KNodeApp::slotToggleToolBar()
 {
-  if(toolBar("mainToolBar")->isVisible())
-    toolBar("mainToolBar")->hide();
+  if(toolBar()->isVisible())
+    toolBar()->hide();
   else
-    toolBar("mainToolBar")->show();
+    toolBar()->show();
 }
 
 
@@ -499,6 +508,15 @@ void KNodeApp::slotToggleStatusBar()
 }
 
 
+void KNodeApp::slotSaveOptions()
+{
+  KConfig *conf = KGlobal::config();
+  conf->setGroup("mainWindow_options");
+  saveMainWindowSettings(conf);
+  view->saveOptions();
+}
+
+
 void KNodeApp::slotConfKeys()
 {
   KKeyDialog::configureKeys(actionCollection(), xmlFile(), true, this);
@@ -689,7 +707,7 @@ void KNodeApp::cleanup()
 {
   KNPurgeProgressDialog *ppdlg=0;
 
-  saveOptions();
+  saveSettings();
 
   if(GManager->timeToExpire()) {
     ppdlg=new KNPurgeProgressDialog();
Index: knode.h
===================================================================
RCS file: /home/kde/kdenetwork/knode/knode.h,v
retrieving revision 1.21
diff -u -3 -p -r1.21 knode.h
--- knode.h	2000/09/08 01:19:46	1.21
+++ knode.h	2000/09/16 02:43:39
@@ -83,6 +83,8 @@ class KNodeApp : public KMainWindow
     void blockUI(bool b=true);
     void secureProcessEvents();  // processEvents with some blocking
 
+    virtual QSize sizeHint() const;   // useful default value
+
     //network
     void jobDone(KNJobData *j);
 
@@ -98,7 +100,7 @@ class KNodeApp : public KMainWindow
     void initActions();
     void initPopups();        
     
-    void saveOptions();
+    void saveSettings();
 
     // checks if run for the first time, sets some global defaults (email \
configuration)  bool firstStart();
@@ -111,7 +113,7 @@ class KNodeApp : public KMainWindow
 
     //actions
     KAction *actCancel, *actSupersede;
-    KToggleAction *actShowAllHdrs;
+    KToggleAction *actShowAllHdrs, *actShowToolbar, *actShowStatusbar;
 
     //popups
     QPopupMenu  *accPopup, *groupPopup, *folderPopup,
@@ -141,6 +143,7 @@ class KNodeApp : public KMainWindow
     void slotSupersede();
     void slotToggleToolBar();
     void slotToggleStatusBar();
+    void slotSaveOptions();
     void slotConfKeys();
     void slotConfToolbar();
     void slotSettingsFinished();
Index: knuserentry.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knode/knuserentry.cpp,v
retrieving revision 1.7
diff -u -3 -p -r1.7 knuserentry.cpp
--- knuserentry.cpp	2000/08/11 18:11:27	1.7
+++ knuserentry.cpp	2000/09/16 02:43:39
@@ -25,6 +25,7 @@
 
 
 KNUserEntry::KNUserEntry()
+ : u_seSigFile(false)
 {
 }
 
@@ -52,7 +53,7 @@ const QCString& KNUserEntry::getSignatur
   } else
     s_igContents = s_igText;
 
-  if (!s_igContents.contains("\n-- \n") && !(s_igContents.left(4) == "-- \n"))
+  if (!s_igContents.isEmpty() && !s_igContents.contains("\n-- \n") && \
!(s_igContents.left(4) == "-- \n"))  s_igContents.prepend("-- \n");
   
   return s_igContents;
Index: main.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knode/main.cpp,v
retrieving revision 1.13
diff -u -3 -p -r1.13 main.cpp
--- main.cpp	2000/08/07 23:28:53	1.13
+++ main.cpp	2000/09/16 02:43:39
@@ -17,13 +17,12 @@
 #include <kcmdlineargs.h>
 #include <klocale.h>
 
-#include "knode.h"
+#include "knapplication.h"
 #include "resource.h"
 
 
 int main(int argc, char* argv[])
 {
-
   KAboutData aboutData("knode",
                         I18N_NOOP("KNode"),
                         KNODE_VERSION,
@@ -36,25 +35,16 @@ int main(int argc, char* argv[])
   aboutData.addAuthor("Christian \
Thurner",I18N_NOOP("Maintainer"),"cthurner@freepage.de");  \
aboutData.addAuthor("Christian Gebauer",0,"gebauer@bigfoot.com");  \
                aboutData.addAuthor("Dirk Mueller",0,"mueller@kde.org");
-  aboutData.addAuthor("Matthias Kalle Dalheimer",0,"kalle@kde.org");
-  KCmdLineArgs::init( argc, argv, &aboutData );
-  KApplication::addCmdLineOptions();
+  aboutData.addCredit("Stephan Johach",0,"lucardus@onlinehome.de");
+  aboutData.addCredit("Matthias Kalle Dalheimer",0,"kalle@kde.org");
 
-  KApplication app;
+  KCmdLineArgs::init( argc, argv, &aboutData );
+  KUniqueApplication::addCmdLineOptions();
 
-  if (app.isRestored()) {
-    int n = 1;
-    while (KMainWindow::canBeRestored(n)){
-      if (KMainWindow::classNameOfToplevel(n)=="KNodeApp")
-        (new KNodeApp)->restore(n);
-      n++;
-    }
-  } else {
-    KNodeApp* knode = new KNodeApp;
-    knode->show();
-  }
+  if (!KNApplication::start())
+    exit(0);
 
-  int ret=app.exec();
+  KNApplication app;
 
-  return ret;
+  return app.exec();
 }


["knapplication.h" (text/plain)]

/***************************************************************************
                     knapplication.h - description
 copyright            : (C) 2000 by Christian Gebauer
 email                : gebauer@bigfoot.com
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KNAPPLICATION_H
#define KNAPPLICATION_H

#include <kuniqueapp.h>


class KNApplication : public KUniqueApplication
{
  Q_OBJECT

  public:
    KNApplication();
    ~KNApplication();

    /** Create new instance of KNode. Make the existing
        main window active if KNode is already running */
    int newInstance();

};

#endif
["knapplication.cpp" (text/plain)]

/***************************************************************************
                        knapplication.cpp  -  description
 copyright            : (C) 2000 by Christian Gebauer
 email                : gebauer@bigfoot.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kwin.h>
#include <kdebug.h>

#include "knode.h"
#include "knapplication.h"


KNApplication::KNApplication()
 : KUniqueApplication()
{
}


KNApplication::~KNApplication()
{
}


int KNApplication::newInstance()
{
  kdDebug(5003) << "KNApplication::newInstance()" << endl;

  if (mainWidget())
    KWin::setActiveWindow(mainWidget()->winId());
  else {
    if (isRestored()) {
      int n = 1;
      while (KNodeApp::canBeRestored(n)){
        if (KNodeApp::classNameOfToplevel(n)=="KNodeApp") {
          (new KNodeApp)->restore(n);
          break;
        }
        n++;
      }
    } else {
      KNodeApp* knode = new KNodeApp;
      knode->show();
    }
  }

  kdDebug(5003) << "KNApplication::newInstance() done" << endl;
  return 0;
}

//--------------------------------

#include "knapplication.moc"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic