]> git.sesse.net Git - vlc/blobdiff - bin/winvlc.c
skins2: slider fix notifyLayout wrongly removed
[vlc] / bin / winvlc.c
index de7674928d7e6efa3e9bd60926f2ed45d6f9e986..db97bae35cf4465b2bf546fd612dbdef9724e3e8 100644 (file)
 #include <windows.h>
 #include <shellapi.h>
 
-#if !defined(UNDER_CE)
-# ifndef _WIN32_IE
-#   define  _WIN32_IE 0x501
-# endif
-# include <fcntl.h>
-# include <io.h>
-# include <shlobj.h>
-# include <wininet.h>
-# define PSAPI_VERSION 1
-# include <psapi.h>
-# define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
+#ifndef _WIN32_IE
+#  define  _WIN32_IE 0x501
+#endif
+#include <fcntl.h>
+#include <io.h>
+#include <shlobj.h>
+#include <wininet.h>
+#define PSAPI_VERSION 1
+#include <psapi.h>
+#define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
 static void check_crashdump(void);
 LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo);
 static const wchar_t *crashdump_path;
-#endif
 
-#ifndef UNDER_CE
 static char *FromWide (const wchar_t *wide)
 {
     size_t len;
@@ -60,67 +57,20 @@ static char *FromWide (const wchar_t *wide)
         WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL);
     return out;
 }
-#else
-static int parse_cmdline (char *line, char ***argvp)
-{
-    char **argv = malloc (sizeof (char *));
-    int argc = 0;
-
-    while (*line != '\0')
-    {
-        char quote = 0;
-
-        /* Skips white spaces */
-        while (strchr ("\t ", *line))
-            line++;
-        if (!*line)
-            break;
-
-        /* Starts a new parameter */
-        argv = realloc (argv, (argc + 2) * sizeof (char *));
-        if (*line == '"')
-        {
-            quote = '"';
-            line++;
-        }
-        argv[argc++] = line;
-
-    more:
-            while (*line && !strchr ("\t ", *line))
-            line++;
-
-    if (line > argv[argc - 1] && line[-1] == quote)
-        /* End of quoted parameter */
-        line[-1] = 0;
-    else
-        if (*line && quote)
-    {
-        /* Space within a quote */
-        line++;
-        goto more;
-    }
-    else
-        /* End of unquoted parameter */
-        if (*line)
-            *line++ = 0;
-    }
-    argv[argc] = NULL;
-    *argvp = argv;
-    return argc;
-}
-#endif
 
 int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
-#ifndef UNDER_CE
                     LPSTR lpCmdLine,
-#else
-                    LPWSTR lpCmdLine,
-#endif
                     int nCmdShow )
 {
     int argc;
 
-#ifndef UNDER_CE
+    /* VLC does not change the thread locale, so gettext/libintil will use the
+     * user default locale as reference. */
+    /* gettext versions 0.18-0.18.1 will use the Windows Vista locale name
+     * if the GETTEXT_MUI environment variable is set. If not set or if running
+     * on Windows 2000/XP/2003 an hard-coded language ID list is used. This
+     * putenv() call may become redundant with later versions of gettext. */
+    putenv("GETTEXT_MUI=1");
 #ifdef TOP_BUILDDIR
     putenv("VLC_PLUGIN_PATH=Z:"TOP_BUILDDIR"/modules");
     putenv("VLC_DATA_PATH=Z:"TOP_SRCDIR"/share");
@@ -182,23 +132,14 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
         if( S_OK != SHGetFolderPathW( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
                     NULL, SHGFP_TYPE_CURRENT, path ) )
             fprintf( stderr, "Can't open the vlc conf PATH\n" );
-        swprintf( path+wcslen( path ), L"%s", L"\\vlc\\crashdump" );
+        _snwprintf( path+wcslen( path ), MAX_PATH,  L"%s", L"\\vlc\\crashdump" );
         crashdump_path = &path[0];
 
         check_crashdump();
         SetUnhandledExceptionFilter(vlc_exception_filter);
     }
 
-    _setmode( _fileno( stdin ), _O_BINARY ); /* Needed for pipes */
-
-#else /* UNDER_CE */
-    char **argv, psz_cmdline[wcslen(lpCmdLine) * 4];
-
-    WideCharToMultiByte( CP_UTF8, 0, lpCmdLine, -1,
-                         psz_cmdline, sizeof (psz_cmdline), NULL, NULL );
-
-    argc = parse_cmdline (psz_cmdline, &argv);
-#endif
+    _setmode( STDIN_FILENO, _O_BINARY ); /* Needed for pipes */
 
     /* Initialize libvlc */
     libvlc_instance_t *vlc;
@@ -206,12 +147,19 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
     if (vlc != NULL)
     {
         libvlc_set_user_agent (vlc, "VLC media player", "VLC/"PACKAGE_VERSION);
+        libvlc_add_intf (vlc, "hotkeys,none");
         libvlc_add_intf (vlc, "globalhotkeys,none");
         libvlc_add_intf (vlc, NULL);
         libvlc_playlist_play (vlc, -1, 0, NULL);
         libvlc_wait (vlc);
         libvlc_release (vlc);
     }
+    else
+        MessageBox (NULL, TEXT("VLC media player could not start.\n"
+                    "Either the command line options were invalid or no plugins were found.\n"),
+                    TEXT("VLC media player"),
+                    MB_OK|MB_ICONERROR);
+
 
     for (int i = 0; i < argc; i++)
         free (argv[i]);
@@ -220,7 +168,6 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
     return 0;
 }
 
-#if !defined( UNDER_CE )
 /* Crashdumps handling */
 static void check_crashdump(void)
 {
@@ -229,8 +176,8 @@ static void check_crashdump(void)
         return;
     fclose( fd );
 
-    int answer = MessageBox( NULL, L"VLC media player just crashed." \
-    " Do you want to send a bug report to the developers team?",
+    int answer = MessageBox( NULL, L"Ooops: VLC media player just crashed.\n" \
+    "Would you like to send a bug report to the developers team?",
     L"VLC crash reporting", MB_YESNO);
 
     if(answer == IDYES)
@@ -247,27 +194,27 @@ static void check_crashdump(void)
                 SYSTEMTIME now;
                 GetSystemTime(&now);
                 wchar_t remote_file[MAX_PATH];
-                swprintf(remote_file,
+                _snwprintf(remote_file, MAX_PATH,
                         L"/crashes-win32/%04d%02d%02d%02d%02d%02d",
                         now.wYear, now.wMonth, now.wDay, now.wHour,
                         now.wMinute, now.wSecond );
 
                 if( FtpPutFile( ftp, crashdump_path, remote_file,
                             FTP_TRANSFER_TYPE_BINARY, 0) )
-                    MessageBox( NULL, L"Report sent correctly. Thanks a lot \
-                            for the help.", L"Report sent", MB_OK);
+                    MessageBox( NULL, L"Report sent correctly. Thanks a lot \
+                                "for the help.", L"Report sent", MB_OK);
                 else
-                    MessageBox( NULL, L"There was an error while \
-                            transferring to the FTP server. "\
-                                "Thanks a lot for the help anyway.",
+                    MessageBox( NULL, L"There was an error while "\
+                                "transferring the data to the FTP server.\n"\
+                                "Thanks a lot for the help.",
                                 L"Report sending failed", MB_OK);
                 InternetCloseHandle(ftp);
             }
             else
             {
-                MessageBox( NULL, L"There was an error while connecting to \
-                        the FTP server. "\
-                                "Thanks a lot for the help anyway.",
+                MessageBox( NULL, L"There was an error while connecting to \
+                                "the FTP server. "\
+                                "Thanks a lot for the help.",
                                 L"Report sending failed", MB_OK);
                 fprintf(stderr,"Can't connect to FTP server 0x%08lu\n",
                         (unsigned long)GetLastError());
@@ -276,8 +223,7 @@ static void check_crashdump(void)
         }
         else
         {
-              MessageBox( NULL, L"There was an error while connecting to the \
-                      Internet. "\
+              MessageBox( NULL, L"There was an error while connecting to the Internet.\n"\
                                 "Thanks a lot for the help anyway.",
                                 L"Report sending failed", MB_OK);
         }
@@ -350,23 +296,6 @@ LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo)
                         pContext->Ebp,pContext->Eip,pContext->Esp );
 #endif
 
-        HANDLE hpid = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
-                                        FALSE, GetCurrentProcessId());
-        if (hpid) {
-            HMODULE mods[1024];
-            DWORD size;
-            if (EnumProcessModules(hpid, mods, sizeof(mods), &size)) {
-                fwprintf( fd, L"\n\n[modules]\n" );
-                for (unsigned int i = 0; i < size / sizeof(HMODULE); i++) {
-                    wchar_t module[ 256 ];
-                    GetModuleFileName(mods[i], module, 256);
-                    fwprintf( fd, L"%p|%s\n", mods[i], module);
-                }
-            }
-            CloseHandle(hpid);
-        }
-
-
         fwprintf( fd, L"\n[stacktrace]\n#EIP|base|module\n" );
 
 #ifdef WIN64
@@ -391,9 +320,24 @@ LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo)
             pBase = *pBase;
         }
 
+        HANDLE hpid = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
+                                        FALSE, GetCurrentProcessId());
+        if (hpid) {
+            HMODULE mods[1024];
+            DWORD size;
+            if (EnumProcessModules(hpid, mods, sizeof(mods), &size)) {
+                fwprintf( fd, L"\n\n[modules]\n" );
+                for (unsigned int i = 0; i < size / sizeof(HMODULE); i++) {
+                    wchar_t module[ 256 ];
+                    GetModuleFileName(mods[i], module, 256);
+                    fwprintf( fd, L"%p|%s\n", mods[i], module);
+                }
+            }
+            CloseHandle(hpid);
+        }
+
         fclose( fd );
         fflush( stderr );
         exit( 1 );
     }
 }
-#endif