medit/moo/mooapp/mooappabout.h

155 lines
4.0 KiB
C
Raw Normal View History

2006-03-15 15:21:48 -06:00
/*
* mooapp/mooappabout.h
*
2010-12-21 20:15:45 -08:00
* Copyright (C) 2004-2010 by Yevgen Muntyan <emuntyan@users.sourceforge.net>
2006-03-15 15:21:48 -06:00
*
* This file is part of medit. medit is free software; you can
* redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version.
2006-03-15 15:21:48 -06:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
2006-03-15 15:21:48 -06:00
*/
#ifndef MOO_APP_ABOUT_H
#define MOO_APP_ABOUT_H
2006-03-15 15:21:48 -06:00
#ifdef HAVE_CONFIG_H
2006-03-15 15:21:48 -06:00
#include "config.h"
#endif
2006-03-15 15:21:48 -06:00
#ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
#endif
#ifdef __WIN32__
#include <windows.h>
#endif
2016-01-31 00:03:05 -08:00
#include <moocpp/moocpp.h>
2015-12-25 21:30:53 -08:00
#include <mooglib/moo-glib.h>
2006-03-15 15:21:48 -06:00
#include <errno.h>
#include <gtk/gtk.h>
using namespace moo;
2009-11-01 12:44:46 -08:00
#ifdef __WIN32__
2006-03-15 15:21:48 -06:00
static gstr
2009-11-01 12:44:46 -08:00
get_system_name (void)
2006-03-15 15:21:48 -06:00
{
2008-01-16 17:39:29 -06:00
OSVERSIONINFOEXW ver;
2006-03-15 15:21:48 -06:00
memset (&ver, 0, sizeof (ver));
2008-01-16 17:39:29 -06:00
ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFOW);
2006-03-15 15:21:48 -06:00
2008-01-16 17:39:29 -06:00
if (!GetVersionExW ((OSVERSIONINFOW*) &ver))
return gstr::wrap_const ("Windows");
2006-03-15 15:21:48 -06:00
switch (ver.dwMajorVersion)
{
case 4: /* Windows NT 4.0, Windows Me, Windows 98, or Windows 95 */
switch (ver.dwMinorVersion)
{
case 0: /* Windows NT 4.0 or Windows95 */
if (ver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
return gstr::wrap_const ("Windows 95");
2006-03-15 15:21:48 -06:00
else
return gstr::wrap_const ("Windows NT 4.0");
2006-03-15 15:21:48 -06:00
case 10:
return gstr::wrap_const ("Windows 98");
2006-03-15 15:21:48 -06:00
case 90:
return gstr::wrap_const ("Windows 98");
2006-03-15 15:21:48 -06:00
}
break;
case 5: /* Windows Server 2003 R2, Windows Server 2003, Windows XP, or Windows 2000 */
switch (ver.dwMinorVersion)
{
case 0:
return gstr::wrap_const ("Windows 2000");
2006-03-15 15:21:48 -06:00
case 1:
return gstr::wrap_const ("Windows XP");
2006-03-15 15:21:48 -06:00
case 2:
return gstr::wrap_const ("Windows Server 2003");
2006-03-15 15:21:48 -06:00
}
break;
case 6:
memset (&ver, 0, sizeof (ver));
2008-01-16 17:39:29 -06:00
ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW);
2006-03-15 15:21:48 -06:00
2009-11-01 12:44:46 -08:00
if (!GetVersionExW ((OSVERSIONINFOW*) &ver) || ver.wProductType == VER_NT_WORKSTATION)
{
switch (ver.dwMinorVersion)
{
case 0:
return gstr::wrap_const ("Windows Vista");
case 1:
return gstr::wrap_const ("Windows 7");
case 2:
return gstr::wrap_const ("Windows 8");
}
}
2006-03-15 15:21:48 -06:00
else
{
switch (ver.dwMinorVersion)
{
case 0:
return gstr::wrap_const ("Windows Server 2008");
case 1:
return gstr::wrap_const ("Windows Server 2008 R2");
case 2:
return gstr::wrap_const ("Windows Server 2012");
}
}
2009-11-01 12:44:46 -08:00
break;
2006-03-15 15:21:48 -06:00
}
return gstr::wrap_const ("Windows");
2006-03-15 15:21:48 -06:00
}
2009-11-01 12:44:46 -08:00
2010-08-30 22:19:58 -07:00
#elif defined(HAVE_SYS_UTSNAME_H)
2009-11-01 12:44:46 -08:00
2006-03-15 15:21:48 -06:00
static char *
2009-11-01 12:44:46 -08:00
get_system_name (void)
2006-03-15 15:21:48 -06:00
{
2010-08-30 22:19:58 -07:00
struct utsname name;
if (uname (&name) != 0)
{
2015-12-25 21:30:53 -08:00
MGW_ERROR_IF_NOT_SHARED_LIBC
mgw_errno_t err = { errno };
g_critical ("%s", mgw_strerror (err));
2010-08-30 22:19:58 -07:00
return g_strdup ("unknown");
}
return g_strdup_printf ("%s %s (%s), %s", name.sysname,
name.release, name.version, name.machine);
2006-03-15 15:21:48 -06:00
}
2009-11-01 12:44:46 -08:00
2010-08-30 22:19:58 -07:00
#else
2006-03-15 15:21:48 -06:00
2010-08-30 22:19:58 -07:00
static char *
get_system_name (void)
{
char *string;
2010-10-06 23:48:20 -07:00
if (g_spawn_command_line_sync ("uname -s -r -v -m", &string, NULL, NULL, NULL))
2010-08-30 22:19:58 -07:00
return string;
else
return g_strdup ("unknown");
}
#endif
2006-03-15 15:21:48 -06:00
#endif /* MOO_APP_ABOUT_H */
2010-08-30 22:19:58 -07:00