[Licq-devel] New Mac OS X experimental patches

Arne Schmitz <[email protected]> Sun, 1 Feb 2009 23:21:05 +0100
Newsgroups gmane.network.licq.devel
Message-ID <[email protected]>
Here are two more patches against current svn to make Licq run under  
Mac OS X.

The good news:
- It runs
- You can send and receive messages
- Even PGP works, if gpgme is installed (e.g. via MacPorts)

The bad news:
- Currently using flynd's QTimer hack to replace QSocketNotifier
- Runs with 100% CPU all the time
- Network log does not work
- Preferences dialog works ONCE and then is greyed out :)
- Clicking the menubar icon toggles mainwindow, which does not make  
sense in Mac OS X

There are probably more glitches, but those are the ones I have found  
out about myself. Feel free to test.

Cheers,

Arne

-- 
Dipl.-Inform. Arne Schmitz              Phone   +49 (0)241 80-21817
Computer Graphics Group                 Fax     +49 (0)241 80-22899
RWTH Aachen University                  http://www.rwth-graphics.de
Ahornstrasse 55, 52074 Aachen, Germany
qt4gui-2009-02-01.patch (application/octet-stream, 3 KB)
Index: src/core/licqgui.h
===================================================================
--- src/core/licqgui.h	(revision 6612)
+++ src/core/licqgui.h	(working copy)
@@ -92,7 +92,7 @@
   virtual void commitData(QSessionManager& sm);
   virtual void saveState(QSessionManager& sm);
 
-#if defined(Q_WS_X11)
+#if defined Q_WS_X11
   virtual bool x11EventFilter(XEvent* event);
 #endif /* defined(Q_WS_X11) */
 
@@ -224,9 +224,7 @@
   void eventSent(const ICQEvent* event);
 
 private slots:
-#ifdef Q_WS_X11
   void grabKey(QString key);
-#endif
 
   void userDlgFinished(UserDlg* dialog);
   void userEventTabDlgDone();
Index: src/core/signalmanager.cpp
===================================================================
--- src/core/signalmanager.cpp	(revision 6612)
+++ src/core/signalmanager.cpp	(working copy)
@@ -24,7 +24,10 @@
 
 #include <QApplication>
 #include <QSocketNotifier>
+#include <QTimer>
 
+#include <iostream>
+
 #include <licq_icqd.h>
 #include <licq_log.h>
 #include <licq_user.h>
@@ -36,14 +39,16 @@
 SignalManager::SignalManager(int pipe)
   : myPipe(pipe)
 {
-  sn = new QSocketNotifier(myPipe, QSocketNotifier::Read);
-  connect(sn, SIGNAL(activated(int)), SLOT(process()));
-  sn->setEnabled(true);
+  myTimer = new QTimer(this);
+  connect(myTimer, SIGNAL(timeout()), SLOT(process()));
+  myTimer->setInterval(1000);
+  myTimer->setSingleShot(false);
+  myTimer->start();
 }
 
 SignalManager::~SignalManager()
 {
-  delete sn;
+//   delete sn;
 }
 
 void SignalManager::ProcessSignal(LicqSignal* sig)
@@ -203,6 +208,15 @@
 {
   char buf[16];
 
+  int n;
+  struct timeval tv = {0, 1000};
+  fd_set fs;
+  FD_ZERO(&fs);
+  FD_SET(myPipe, &fs);
+  n = select(myPipe+1, &fs, 0, 0, &tv);
+  if (n == 0)
+    return;
+
   read(myPipe, buf, 1);
 
   switch (buf[0])
Index: src/core/signalmanager.h
===================================================================
--- src/core/signalmanager.h	(revision 6612)
+++ src/core/signalmanager.h	(working copy)
@@ -23,6 +23,7 @@
 #include <QObject>
 
 class QSocketNotifier;
+class QTimer;
 
 class LicqSignal;
 class ICQEvent;
@@ -83,6 +84,7 @@
 private:
   int myPipe;
   QSocketNotifier* sn;
+  QTimer *myTimer;
 
   void ProcessSignal(LicqSignal* sig);
   void ProcessEvent(ICQEvent* ev);
Index: src/core/licqgui.cpp
===================================================================
--- src/core/licqgui.cpp	(revision 6612)
+++ src/core/licqgui.cpp	(working copy)
@@ -570,9 +570,11 @@
   return QApplication::x11EventFilter(event);
 #endif
 }
+#endif /* defined(Q_WS_X11) */
 
 void LicqGui::grabKey(QString key)
 {
+#if defined(Q_WS_X11)
   Display* dsp = QX11Info::display();
   Qt::HANDLE rootWin = QX11Info::appRootWindow();
 
@@ -599,8 +601,8 @@
   XGrabKey(dsp, XKeysymToKeycode(dsp, Support::keyToXSym(grabKeysym)),
       Support::keyToXMod(grabKeysym), rootWin, true,
       GrabModeAsync, GrabModeSync);
+#endif /* defined(Q_WS_X11) */
 }
-#endif /* defined(Q_WS_X11) */
 
 void LicqGui::changeStatus(unsigned long status, bool invisible)
 {
daemon-.patch (application/octet-stream, 755 B)
Index: include/licq_byteorder.h
===================================================================
--- include/licq_byteorder.h	(revision 6612)
+++ include/licq_byteorder.h	(working copy)
@@ -43,6 +43,13 @@
 #  define BSWAP_64(x) bswap_64(x)
 # endif
 
+// Mac OS X
+#elif defined(__APPLE__) && defined(__MACH__)
+# ifdef __BIG_ENDIAN__
+#  define IS_BIG_ENDIAN
+# else
+#  define IS_LITTLE_ENDIAN
+# endif
 
 // Mac OS X has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the compiler (at least with GCC)
 #elif defined(__APPLE__) && defined(__MACH__)
@@ -80,7 +87,6 @@
 # define LE_32(x) letoh32(x)
 # define LE_64(x) letoh64(x)
 
-
 // Solaris header for endian and byte swap
 #elif defined HAVE_SYS_BYTEORDER_H
 # include <sys/byteorder.h>
PGP.sig (application/pgp-signature, 194 B) - not displayed