changeset 197:e0ec2280a778

Implement browser launching on Windows via ShellExecute().
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 17 Nov 2010 09:57:32 +0200
parents edd5ce3e5399
children 21a37995c3fb
files Makefile.w32 nnchat.c
diffstat 2 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.w32	Wed Nov 17 05:13:12 2010 +0200
+++ b/Makefile.w32	Wed Nov 17 09:57:32 2010 +0200
@@ -11,7 +11,7 @@
 CFLAGS=-DHAVE_STRING_H -Ipdcurses
 
 # Library path must be defined correctly here
-LDFLAGS=-L/usr/local/i386-mingw32/lib/ -lmingw32 -liberty -lws2_32 -s
+LDFLAGS=-L/usr/local/i386-mingw32/lib/ -liberty -lws2_32 -lole32 -s
 
 # Link PDCurses static library here .. you will want to change this
 ifeq ($(SDL),y)
--- a/nnchat.c	Wed Nov 17 05:13:12 2010 +0200
+++ b/nnchat.c	Wed Nov 17 09:57:32 2010 +0200
@@ -666,15 +666,22 @@
         printMsg("Opening profile for: '%s'\n", name);
 
         tmpStr = nn_encode_str1(name);
-        snprintf(tmpBuf, sizeof(tmpBuf), "openurl(http://www.newbienudes.com/profile/%s/,new-tab)", tmpStr);
+#ifdef __WIN32
+        {
+        int status;
+        snprintf(tmpBuf, sizeof(tmpBuf), "http://www.newbienudes.com/profile/%s/", tmpStr);
         th_free(tmpStr);
-
-#ifdef __WIN32
-        
+        status = ShellExecute(NULL, "open", tmpBuf, NULL, NULL, SW_SHOWNA);
+        if (status <= 32)
+            printMsg("Could not launch default web browser: %d\n", status);
+        }
 #else
         {
         int status;
         pid_t pid;
+        snprintf(tmpBuf, sizeof(tmpBuf), "openurl(http://www.newbienudes.com/profile/%s/,new-tab)", tmpStr);
+        th_free(tmpStr);
+
         if ((pid = fork()) < 0) {
             printMsg("Could not create sub-process!\n");
         } else if (pid == 0) {
@@ -876,7 +883,7 @@
 
     fputs(info, stdout);
     fgets(tmpBuf, sizeof(tmpBuf), stdin);
-        
+    
     for (bufLen = strlen(tmpBuf) - 1; bufLen > 0 && (tmpBuf[bufLen] == '\n' || tmpBuf[bufLen] == '\r' || th_isspace(tmpBuf[bufLen])); bufLen--)
         tmpBuf[bufLen] = 0;
 
@@ -941,6 +948,8 @@
     char tmpPath[MAX_PATH];
     if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK)
         homeDir = th_strdup(tmpPath);
+
+    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
     }
 #else
     homeDir = th_strdup(getenv("HOME"));