changeset 76:d575a8f76a53

* Win32 build fixes
author Chris Cannam
date Sat, 20 Nov 2010 10:11:00 +0000
parents 295e3ee4a257
children b522aaa2c053
files common.cpp easyhg.pro easyhg.rc hgexplorer.rc hgrunner.cpp mainwindow.cpp
diffstat 6 files changed, 33 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/common.cpp	Fri Nov 19 18:39:40 2010 +0000
+++ b/common.cpp	Sat Nov 20 10:11:00 2010 +0000
@@ -23,7 +23,14 @@
 #include <QStringList>
 
 #include <sys/types.h>
+
+#ifdef Q_OS_WIN32
+#define _WIN32_WINNT 0x0500
+#include <windows.h>
+#include <security.h>
+#else
 #include <pwd.h>
+#endif
 
 QString findExecutable(QString name)
 {
@@ -90,15 +97,20 @@
 #ifdef Q_OS_WIN32
 QString getUserRealName()
 {
-    const int maxlen = 1023;
-    TCHAR buf[maxlen + 2];
+    TCHAR buf[1024];
+    long unsigned int maxlen = 1000;
     LPTSTR info = buf;
 
-    if (!GetUserNameEx(NameDisplay, info, maxlen)) {
+    if (!GetUserNameEx(NameDisplay, info, &maxlen)) {
+        DEBUG << "GetUserNameEx failed: " << GetLastError() << endl;
         return "";
     }
 
-    return QString::fromUcs2(info);
+#ifdef UNICODE
+    return QString::fromUtf16((const unsigned short *)info);
+#else
+    return QString::fromLocal8Bit(info);
+#endif
 }
 #else
 #ifdef Q_OS_MAC
--- a/easyhg.pro	Fri Nov 19 18:39:40 2010 +0000
+++ b/easyhg.pro	Sat Nov 20 10:11:00 2010 +0000
@@ -61,7 +61,13 @@
     LIBS += -framework Foundation
 }
 
-LIBS += -lutil
+linux* {
+    LIBS += -lutil
+}
+
+win* {
+    LIBS += -lSecur32
+}
 
 # ! [0]
 RESOURCES = easyhg.qrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/easyhg.rc	Sat Nov 20 10:11:00 2010 +0000
@@ -0,0 +1,1 @@
+IDI_ICON1 ICON DISCARDABLE "hgexplorer.ico"
--- a/hgexplorer.rc	Fri Nov 19 18:39:40 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-IDI_ICON1 ICON DISCARDABLE "hgexplorer.ico"
--- a/hgrunner.cpp	Fri Nov 19 18:39:40 2010 +0000
+++ b/hgrunner.cpp	Sat Nov 20 10:11:00 2010 +0000
@@ -29,10 +29,13 @@
 
 #include <iostream>
 #include <unistd.h>
-#include <pty.h>
 #include <errno.h>
 #include <stdio.h>
 
+#ifndef Q_OS_WIN32
+#include <pty.h>
+#endif
+
 HgRunner::HgRunner(QWidget * parent): QProgressBar(parent)
 {
     proc = new QProcess(this);
@@ -50,6 +53,7 @@
     stdErr.clear();
 
     procInput = 0;
+#ifndef Q_OS_WIN32
     char name[1024];
     if (openpty(&ptyMasterFd, &ptySlaveFd, name, NULL, NULL)) {
         perror("openpty failed");
@@ -62,7 +66,7 @@
         proc->setStandardInputFile(ptySlaveFilename);
         ::close(ptySlaveFd);
     }
-
+#endif
     connect(proc, SIGNAL(started()), this, SLOT(started()));
     connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)),
             this, SLOT(finished(int, QProcess::ExitStatus)));
--- a/mainwindow.cpp	Fri Nov 19 18:39:40 2010 +0000
+++ b/mainwindow.cpp	Sat Nov 20 10:11:00 2010 +0000
@@ -1021,9 +1021,9 @@
                 {
                     case ACT_PATHS:
                     {
-                        QString stdout = runner->getStdOut();
-                        DEBUG << "stdout is " << stdout << endl;
-                        LogParser lp(stdout, "=");
+                        QString sout = runner->getStdOut();
+                        DEBUG << "stdout is " << sout << endl;
+                        LogParser lp(sout, "=");
                         LogList ll = lp.parse();
                         DEBUG << ll.size() << " results" << endl;
                         if (!ll.empty()) {