Mercurial > hg > nnchat
comparison nnchat.c @ 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 |
comparison
equal
deleted
inserted
replaced
196:edd5ce3e5399 | 197:e0ec2280a778 |
---|---|
664 char *name = trimLeft(buf + 3); | 664 char *name = trimLeft(buf + 3); |
665 | 665 |
666 printMsg("Opening profile for: '%s'\n", name); | 666 printMsg("Opening profile for: '%s'\n", name); |
667 | 667 |
668 tmpStr = nn_encode_str1(name); | 668 tmpStr = nn_encode_str1(name); |
669 snprintf(tmpBuf, sizeof(tmpBuf), "openurl(http://www.newbienudes.com/profile/%s/,new-tab)", tmpStr); | 669 #ifdef __WIN32 |
670 { | |
671 int status; | |
672 snprintf(tmpBuf, sizeof(tmpBuf), "http://www.newbienudes.com/profile/%s/", tmpStr); | |
670 th_free(tmpStr); | 673 th_free(tmpStr); |
671 | 674 status = ShellExecute(NULL, "open", tmpBuf, NULL, NULL, SW_SHOWNA); |
672 #ifdef __WIN32 | 675 if (status <= 32) |
673 | 676 printMsg("Could not launch default web browser: %d\n", status); |
677 } | |
674 #else | 678 #else |
675 { | 679 { |
676 int status; | 680 int status; |
677 pid_t pid; | 681 pid_t pid; |
682 snprintf(tmpBuf, sizeof(tmpBuf), "openurl(http://www.newbienudes.com/profile/%s/,new-tab)", tmpStr); | |
683 th_free(tmpStr); | |
684 | |
678 if ((pid = fork()) < 0) { | 685 if ((pid = fork()) < 0) { |
679 printMsg("Could not create sub-process!\n"); | 686 printMsg("Could not create sub-process!\n"); |
680 } else if (pid == 0) { | 687 } else if (pid == 0) { |
681 execlp(setBrowser, setBrowser, "-remote", tmpBuf, NULL); | 688 execlp(setBrowser, setBrowser, "-remote", tmpBuf, NULL); |
682 _exit(errno); | 689 _exit(errno); |
874 char tmpBuf[512]; | 881 char tmpBuf[512]; |
875 ssize_t bufLen; | 882 ssize_t bufLen; |
876 | 883 |
877 fputs(info, stdout); | 884 fputs(info, stdout); |
878 fgets(tmpBuf, sizeof(tmpBuf), stdin); | 885 fgets(tmpBuf, sizeof(tmpBuf), stdin); |
879 | 886 |
880 for (bufLen = strlen(tmpBuf) - 1; bufLen > 0 && (tmpBuf[bufLen] == '\n' || tmpBuf[bufLen] == '\r' || th_isspace(tmpBuf[bufLen])); bufLen--) | 887 for (bufLen = strlen(tmpBuf) - 1; bufLen > 0 && (tmpBuf[bufLen] == '\n' || tmpBuf[bufLen] == '\r' || th_isspace(tmpBuf[bufLen])); bufLen--) |
881 tmpBuf[bufLen] = 0; | 888 tmpBuf[bufLen] = 0; |
882 | 889 |
883 if (bufLen > 0) | 890 if (bufLen > 0) |
884 return th_strdup(tmpBuf); | 891 return th_strdup(tmpBuf); |
939 #ifdef __WIN32 | 946 #ifdef __WIN32 |
940 { | 947 { |
941 char tmpPath[MAX_PATH]; | 948 char tmpPath[MAX_PATH]; |
942 if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK) | 949 if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK) |
943 homeDir = th_strdup(tmpPath); | 950 homeDir = th_strdup(tmpPath); |
951 | |
952 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); | |
944 } | 953 } |
945 #else | 954 #else |
946 homeDir = th_strdup(getenv("HOME")); | 955 homeDir = th_strdup(getenv("HOME")); |
947 #endif | 956 #endif |
948 | 957 |