~n-muench/ubuntu/quantal/open-vm-tools/open-vm-tools.may2.sid-sync

« back to all changes in this revision

Viewing changes to toolbox/toolboxInt.c

  • Committer: Bazaar Package Importer
  • Author(s): Nate Muench
  • Date: 2011-07-22 16:41:03 UTC
  • mfrom: (1.4.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110722164103-xci04yu18mjvhr1j
Tags: 2011.07.19-450511-0ubuntu1
* Merge latest upstream git tag. Fixes Building on Oneiric
  (LP: #776103, LP: #807903)

* The Toolbox (GUI) has been removed.
* Changes in debian folder:
  - Contents of open-vm-toolbox.lintian-overrides have been moved to
    open-vm-tools.lintian-overrides.
  - The contents of open-vm-toolbox.manpages (excluding the first line,
    which relates to the Toolbox) have been moved to open-vm-tools.manpages.
* Changes in debian/control:
  - Convert open-vm-toolbox into a transitional package.
  - All dependencies for toolbox have been moved to open-vm-tools package.
  - Changed architecture for open-vm-toolbox package to all.
  - Added Replaces and Breaks fields to open-vm-tools.
* Changes in debian/rules:
  - Commented out references to the Toolbox (GUI), that no longer exist
    in the package itself.
  - Remaining references changed from open-vm-toolbox to open-vm-tools.
  - Added -Wno-unused-but-set-variable to CFLAGS to suppress remaining
    issues with GCC 4.6.0 or later.
* Files removed in debian/manpages:
  - vmmemctl.9 (Component no longer in package)
  - vmware-toolbox.1 (Component removed in this release)
  - vmxnet3.9 (vmxnet3 is now included in kernel itself)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*********************************************************
2
 
 * Copyright (C) 2008 VMware, Inc. All rights reserved.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify it
5
 
 * under the terms of the GNU Lesser General Public License as published
6
 
 * by the Free Software Foundation version 2.1 and no later version.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful, but
9
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
11
 
 * License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU Lesser General Public License
14
 
 * along with this program; if not, write to the Free Software Foundation, Inc.,
15
 
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
16
 
 *
17
 
 *********************************************************/
18
 
 
19
 
/*
20
 
 * toolboxInt.c --
21
 
 *
22
 
 *    Internal, shared functions for the GTK toolbox.
23
 
 */
24
 
 
25
 
#include <errno.h>
26
 
#include <glib.h>
27
 
#include <glib/gprintf.h>
28
 
#include <glib/gstdio.h>
29
 
#include "conf.h"
30
 
#include "debug.h"
31
 
#include "guestApp.h"
32
 
#include "util.h"
33
 
#include "vmware/tools/utils.h"
34
 
 
35
 
 
36
 
/*
37
 
 *-----------------------------------------------------------------------------
38
 
 *
39
 
 * Toolbox_GetScriptPath --
40
 
 *
41
 
 *    Returns the absolute path to the given script. Relative paths
42
 
 *    given as input to this function are considered to be relative
43
 
 *    to the Tools "install" path.
44
 
 *
45
 
 * Results:
46
 
 *    The absolute path of the script.
47
 
 *
48
 
 * Side effects:
49
 
 *    None.
50
 
 *
51
 
 *-----------------------------------------------------------------------------
52
 
 */
53
 
 
54
 
#if defined(_WIN32)
55
 
gchar *
56
 
Toolbox_GetScriptPath(const wchar_t *scriptUtf16)  // IN
57
 
#else
58
 
gchar *
59
 
Toolbox_GetScriptPath(const gchar *script)   // IN
60
 
#endif
61
 
{
62
 
   gchar *ret;
63
 
#if defined(_WIN32)
64
 
   gchar *script;
65
 
   GError *err = NULL;
66
 
 
67
 
   script = g_utf16_to_utf8(scriptUtf16, -1, NULL, NULL, &err);
68
 
   if (err != NULL) {
69
 
      g_error("Error converting to UTF8: %s\n", err->message);
70
 
   }
71
 
#endif
72
 
   if (!g_path_is_absolute(script)) {
73
 
      char *toolsPath = GuestApp_GetInstallPath();
74
 
      ASSERT_MEM_ALLOC(toolsPath);
75
 
      ret = g_strdup_printf("%s%c%s", toolsPath, DIRSEPC, script);
76
 
      free(toolsPath);
77
 
   } else {
78
 
      ret = g_strdup(script);
79
 
   }
80
 
#if defined(_WIN32)
81
 
   g_free(script);
82
 
#endif
83
 
   return ret;
84
 
}
85
 
 
86
 
 
87
 
/*
88
 
 *-----------------------------------------------------------------------------
89
 
 *
90
 
 * Toolbox_LoadToolsConf --
91
 
 *
92
 
 *    Load the Tools configuration file from the default location.
93
 
 *
94
 
 *    XXX: This function is temporary until the GTK toolbox is refactored
95
 
 *    to be able to use vmtoolslib.
96
 
 *
97
 
 * Results:
98
 
 *    The config object. If loading the data fails, returns an empty conf object.
99
 
 *
100
 
 * Side effects:
101
 
 *    None.
102
 
 *
103
 
 *-----------------------------------------------------------------------------
104
 
 */
105
 
 
106
 
GKeyFile *
107
 
Toolbox_LoadToolsConf(void)
108
 
{
109
 
   GKeyFile *config = NULL;
110
 
 
111
 
   VMTools_LoadConfig(NULL,
112
 
                      G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
113
 
                      &config,
114
 
                      NULL);
115
 
 
116
 
   if (config == NULL) {
117
 
      Debug("Unable to load config file.\n");
118
 
      config = g_key_file_new();
119
 
   }
120
 
 
121
 
   return config;
122
 
}
123
 
 
124
 
 
125
 
/*
126
 
 *-----------------------------------------------------------------------------
127
 
 *
128
 
 * Toolbox_SaveToolsConf --
129
 
 *
130
 
 *    Saves the given config data to the default tools config file location.
131
 
 *
132
 
 *    XXX: This function is temporary until the GTK toolbox is refactored
133
 
 *    to be able to use vmtoolslib.
134
 
 *
135
 
 * Results:
136
 
 *    Whether saving was successful.
137
 
 *
138
 
 * Side effects:
139
 
 *    None.
140
 
 *
141
 
 *-----------------------------------------------------------------------------
142
 
 */
143
 
 
144
 
gboolean
145
 
Toolbox_SaveToolsConf(GKeyFile *config)   // IN
146
 
{
147
 
   gboolean ret = FALSE;
148
 
   GError *err = NULL;
149
 
 
150
 
   ret = VMTools_WriteConfig(NULL, config, &err);
151
 
 
152
 
   if (!ret) {
153
 
      Warning("Error saving conf data: %s\n", err->message);
154
 
      g_clear_error(&err);
155
 
   }
156
 
 
157
 
   return ret;
158
 
}
159