Here it comes again.
I hope this mail goes through and is ok, I used different client here.
Stupid Hotmail. Maybe it was aware that I tried to send a patch for a
Linux program and therefore messed with the attachment...

Regards,
Tuomas Jaakola
diff -ru licq.orig/plugins/qt-gui/src/ewidgets.cpp licq/plugins/qt-gui/src/ewidgets.cpp
--- licq.orig/plugins/qt-gui/src/ewidgets.cpp   2002-09-20 03:25:28.000000000 +0300
+++ licq/plugins/qt-gui/src/ewidgets.cpp        2002-09-20 03:24:50.000000000 +0300
@@ -506,17 +506,23 @@
 :CHistoryWidget(parent,name)
 {
   m_nUin= _nUin;
+  parentWidget = parent;
+
   // add all unread messages.
-//   ICQUser *u = gUserManager.FetchUser(_nUin, LOCK_W);
-//   if (u != NULL && u->NewMessages() > 0)
-//   {
-//     addMsg(u->EventPeek(0));
-//     for (unsigned short i = 1; i < u->NewMessages(); i++)
-//     {
-//       addMsg(u->EventPeek(i));
-//     }
-//   }
-//   gUserManager.DropUser(u);
+  vector<CUserEvent*> newEventList;
+  ICQUser *u = gUserManager.FetchUser(_nUin, LOCK_W);
+  if (u != NULL && u->NewMessages() > 0)
+  {
+    for (unsigned short i = 0; i < u->NewMessages(); i++)
+    {
+      CUserEvent *e = u->EventPeek(i);
+      if (e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG)
+       newEventList.push_back(e);
+    }
+  }
+  gUserManager.DropUser(u);
+  for (unsigned short i = 0; i < newEventList.size(); i++)
+    addMsg(newEventList[i]);
 }
 
 void CMessageViewWidget::addMsg(ICQEvent * _e)
@@ -608,7 +614,11 @@
 #endif 
   GotoEnd();
 
-  if (e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG) {
+  if (
+#if QT_VERSION >= 300
+      parentWidget && parentWidget->isActiveWindow() &&
+#endif
+      e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG) {
     ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_R );
     if (u != NULL) {
        u->EventClearId(e->Id());
diff -ru licq.orig/plugins/qt-gui/src/ewidgets.h licq/plugins/qt-gui/src/ewidgets.h
--- licq.orig/plugins/qt-gui/src/ewidgets.h     2002-09-20 03:25:28.000000000 +0300
+++ licq/plugins/qt-gui/src/ewidgets.h  2002-09-20 03:24:50.000000000 +0300
@@ -129,6 +129,7 @@
   Q_OBJECT
 private:
   unsigned long m_nUin;
+  QWidget *parentWidget;
 public:
   CMessageViewWidget(unsigned long _nUin, QWidget* parent=0, const char * name =0);
   virtual ~CMessageViewWidget(){};
diff -ru licq.orig/plugins/qt-gui/src/mainwin.cpp licq/plugins/qt-gui/src/mainwin.cpp
--- licq.orig/plugins/qt-gui/src/mainwin.cpp    2002-09-20 03:25:28.000000000 +0300
+++ licq/plugins/qt-gui/src/mainwin.cpp 2002-09-20 03:24:50.000000000 +0300
@@ -1633,6 +1633,17 @@
   // set default function to read or send depending on whether or not
   // there are new messages
   int fcn = (u->NewMessages() == 0 ? mnuUserSendMsg : mnuUserView);
+  if (fcn == mnuUserView && m_bMsgChatView)
+  {
+    // if one of the new events is a msg in chatview mode,
+    // change def function to send
+    for (unsigned short i = 0; i < u->NewMessages(); i++)
+      if (u->EventPeek(i)->SubCommand() == ICQ_CMDxSUB_MSG)
+      {
+        fcn = mnuUserSendMsg;
+       break;
+      }
+  }
   gUserManager.DropUser(u);
 
   // See if the clipboard contains a url
@@ -1943,8 +1954,6 @@
         QPtrListIterator<UserSendCommon> it(licqUserSend);
 #endif
 
-        if ( !m_bMsgChatView ) break;
-
         for (; it.current(); ++it)
           if ((*it)->Uin() == nUin)
           {
@@ -1968,38 +1977,7 @@
   {
     case mnuUserView:
     {
-#if QT_VERSION < 300
-      QListIterator<UserViewEvent> it(licqUserView);
-#else
-      QPtrListIterator<UserViewEvent> it(licqUserView);
-#endif
-
-      for (; it.current(); ++it)
-      {
-        if ((*it)->Uin() == nUin)
-        {
-          e = *it;
-          break;
-        }
-      }
-
-      if (e == NULL)
-      {
-        e = new UserViewEvent(licqDaemon, licqSigMan, this, nUin);
-        connect (e, SIGNAL(finished(unsigned long)), SLOT(slot_userfinished(unsigned 
long)));
-        licqUserView.append(static_cast<UserViewEvent*>(e));
-      }
-      else
-      {
-        if(!qApp->activeWindow() || 
!qApp->activeWindow()->inherits("UserEventCommon"))
-        {
-          e->raise();
-#ifdef USE_KDE
-          KWin::setActiveWindow(e->winId());
-#endif
-        }
-        return e;
-      }
+      e = new UserViewEvent(licqDaemon, licqSigMan, this, nUin);
       break;
     }
     case mnuUserSendMsg:
@@ -2039,9 +2017,18 @@
     e->show();
     // there might be more than one send window open
     // make sure we only remember one, or it will get compliated
-    slot_sendfinished( nUin );
-    connect( e, SIGNAL( finished( unsigned long ) ), this, SLOT( slot_sendfinished( 
unsigned long ) ) );
-    licqUserSend.append(static_cast<UserSendCommon*>(e));
+    if (fcn == mnuUserView)
+    {
+      slot_userfinished(nUin);
+      connect(e, SIGNAL(finished(unsigned long)), SLOT(slot_userfinished(unsigned 
+long)));
+      licqUserView.append(static_cast<UserViewEvent*>(e));
+    }
+    else
+    {
+      slot_sendfinished(nUin);
+      connect(e, SIGNAL(finished(unsigned long)), SLOT(slot_sendfinished(unsigned 
+long)));
+      licqUserSend.append(static_cast<UserSendCommon*>(e));
+    }
   }
 
   return e;
@@ -2088,8 +2075,8 @@
       return;
     }
   }
-  gLog.Warn("%sUser finished signal for user with no window (%ld)!\n",
-            L_WARNxSTR, nUin);
+  //gLog.Warn("%sUser finished signal for user with no window (%ld)!\n",
+  //          L_WARNxSTR, nUin);
 }
 
 void CMainWindow::slot_sendfinished(unsigned long nUin)

Reply via email to