1 | /* $Id: VBoxHostVersion.cpp 44529 2013-02-04 15:54:15Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxHostVersion - Checks the host's VirtualBox version and notifies
|
---|
4 | * the user in case of an update.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2010-2011 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "VBoxHostVersion.h"
|
---|
20 | #include "VBoxTray.h"
|
---|
21 | #include "VBoxHelpers.h"
|
---|
22 |
|
---|
23 | #include <VBox/VBoxGuestLib.h>
|
---|
24 |
|
---|
25 |
|
---|
26 | /** @todo Move this part in VbglR3 and just provide a callback for the platform-specific
|
---|
27 | notification stuff, since this is very similar to the VBoxClient code. */
|
---|
28 | int VBoxCheckHostVersion()
|
---|
29 | {
|
---|
30 | int rc;
|
---|
31 | uint32_t uGuestPropSvcClientID;
|
---|
32 |
|
---|
33 | rc = VbglR3GuestPropConnect(&uGuestPropSvcClientID);
|
---|
34 | if (RT_SUCCESS(rc))
|
---|
35 | {
|
---|
36 | char *pszHostVersion;
|
---|
37 | char *pszGuestVersion;
|
---|
38 | bool bUpdate;
|
---|
39 | rc = VbglR3HostVersionCheckForUpdate(uGuestPropSvcClientID, &bUpdate, &pszHostVersion, &pszGuestVersion);
|
---|
40 | if (RT_SUCCESS(rc))
|
---|
41 | {
|
---|
42 | if (bUpdate)
|
---|
43 | {
|
---|
44 | char szMsg[256]; /* Sizes according to MSDN. */
|
---|
45 | char szTitle[64];
|
---|
46 |
|
---|
47 | /** @todo Add some translation macros here. */
|
---|
48 | _snprintf(szTitle, sizeof(szTitle), "VirtualBox Guest Additions update available!");
|
---|
49 | _snprintf(szMsg, sizeof(szMsg), "Your guest is currently running the Guest Additions version %s. "
|
---|
50 | "We recommend updating to the latest version (%s) by choosing the "
|
---|
51 | "install option from the Devices menu.", pszGuestVersion, pszHostVersion);
|
---|
52 |
|
---|
53 | rc = hlpShowBalloonTip(ghInstance, ghwndToolWindow, ID_TRAYICON,
|
---|
54 | szMsg, szTitle,
|
---|
55 | 5000 /* Time to display in msec */, NIIF_INFO);
|
---|
56 | if (RT_FAILURE(rc))
|
---|
57 | Log(("VBoxTray: Guest Additions update found; however: could not show version notifier balloon tooltip! rc = %d\n", rc));
|
---|
58 | }
|
---|
59 |
|
---|
60 | /* Store host version to not notify again. */
|
---|
61 | rc = VbglR3HostVersionLastCheckedStore(uGuestPropSvcClientID, pszHostVersion);
|
---|
62 |
|
---|
63 | VbglR3GuestPropReadValueFree(pszHostVersion);
|
---|
64 | VbglR3GuestPropReadValueFree(pszGuestVersion);
|
---|
65 | }
|
---|
66 | VbglR3GuestPropDisconnect(uGuestPropSvcClientID);
|
---|
67 | }
|
---|
68 | return rc;
|
---|
69 | }
|
---|
70 |
|
---|