1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sal.hxx" 30 #ifdef _MSC_VER 31 #pragma warning( disable: 4668 ) 32 #endif 33 34 #include <sal/types.h> 35 36 #define WIN32_LEAN_AND_MEAN 37 #include <windows.h> 38 #include <wininet.h> 39 40 #ifdef UNICODE 41 #define _UNICODE 42 #endif 43 #include <tchar.h> 44 #ifdef __MINGW32__ 45 #include <excpt.h> 46 #endif 47 48 #define elementsof(a) (sizeof(a)/sizeof((a)[0])) 49 50 // #i71984 51 extern "C" sal_Bool SAL_CALL hasInternetConnection() 52 { 53 DWORD dwFlags; 54 TCHAR szConnectionName[1024]; 55 56 #ifdef __MINGW32__ 57 jmp_buf jmpbuf; 58 __SEHandler han; 59 if (__builtin_setjmp(jmpbuf) == 0) 60 { 61 han.Set(jmpbuf, NULL, (__SEHandler::PF)EXCEPTION_EXECUTE_HANDLER); 62 #else 63 __try { 64 #endif 65 BOOL fIsConnected = InternetGetConnectedStateEx( 66 &dwFlags, 67 szConnectionName, 68 elementsof(szConnectionName), 69 0 ); 70 71 return fIsConnected ? sal_True : sal_False; 72 73 #ifdef __MINGW32__ 74 } 75 else return sal_False; 76 han.Reset(); 77 #else 78 } __except( EXCEPTION_EXECUTE_HANDLER ) { 79 return sal_False; 80 } 81 #endif 82 } 83