~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.raring-precise.backport

« back to all changes in this revision

Viewing changes to services/plugins/unity/ghIntegration/pseudoAppMgr.cc

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-01-23 16:09:45 UTC
  • mfrom: (1.4.6) (2.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20120123160945-b6s0r1vkcovucpf3
Tags: 2011.12.20-562307-0ubuntu1
* Merge latest upstream git tag. Fixes building on Precise
  (LP: #898289, LP: #905612)

* Items merged from Debian unstable:
  - debian/control:
    + open-vm-tools recommends open-vm-dkms. (LP: #598933)
    + open-vm-tools now suggests open-vm-toolbox. (LP: #604998)
  (From 2011.08.21-471295-1 release)
  - Updating maintainer and uploaders fields.
  - Removing vcs fields.
  - Removing references to Daniel's old email address.
  - Updating years in copyright file.
  - Updating to standards version 3.9.2.
  - Updating to debhelper version 8.
  - Switching to source format 3.0 (quilt).
  - Removing manual chrpath setting.
  - Removing exclusion from plugins from debhelper shlibs.
  - Rediffing kvers.patch.
  (From 2011.09.23-491607-1 release)
  - Marking binary architecture-dependend packages as linux and kfreebsd
  only.
  - Removing liburiparser-dev from build-depends as upstream dropped
  unity support.
  - Building with libproc-dev on amd64 again.
  - Dropping disabling of dnet support.
  (From 2011.09.23-491607-2 release)
  - Adding doxygen to build-depends for api documentation.
  - Adding libcunit1-dev to build-depends for test suites.
  - Minimizing rules file.
  - Adding open-vm-tools-dev package, containing only the api
    documentation for now.
  (From 2011.09.23-491607-3 release)
  - Sorting overrides in rules alphabetically.
  - Compacting copyright file.
  - Adding udev rule to set timeout for vmware scsi devices
  (From 2011.12.20-562307-1 release)
  - Adding patch to correct typo in upstreams dkms configuration

* Remaining Changes:
  - Remove Stable part of version numbering.
  - debian folder:
    + Re-added open-vm-dkms.postinst & open-vm-dkms.prerm.
      * Allows dkms modules to compile upon installation.
  - debian/control:
    + Re-add open-vm-source and make into a transitional package
      for open-vm-toolbox.
    + Return dependancies that were moved to open-vm-tools back to
      open-vm-toolbox.
  - debian/rules and debian/open-vm-toolbox.lintian-overrides:
    + Make vmware-user-suid-wrapper suid-root
  - debian/rules:
    + Added CFLAGS field with -Wno-deprecated-declarations
      * Will suppress issues with glib 2.31 or later.
    + Add line to copy vmware-xdg-detect-de into place.
    + Install vmware-user.desktop through toolbox package.
  - debian/open-vm-tools.init:
    + Re-add 'modprobe [-r] vmblock'.
    + Add 'modprobe [-r] vmxnet'.
      * Incase it's not loaded during boot.
    + Remove and re-add pcnet32 module
      * Will be done before (remove) and after (readd) vmxnet module
        is added.
      * If vmxnet doesn't exist (aka modules fail to build), pcnet32 can be
        still used for network connectivity.
      * Workaround until a better fix can be done.
  - Re-add gnome-session to debian/local/xautostart.conf
  - Manpages removed (from debian/manpages):
    + vmmemctl.9
    + vmxnet3.9
    + Remove references to manpages that have been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*********************************************************
2
 
 * Copyright (C) 2010 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
 
 * pseudoAppMgr.cc --
21
 
 *
22
 
 *      Manages "pseudo-applications" for special menu items, such as
23
 
 *      directories for which we wish to display custom menu item icons or
24
 
 *      executables which do not have regular menu items.
25
 
 *
26
 
 *      Pseudo apps are assigned well-known IDs (AppId, compile-time), and
27
 
 *      are associated with URIs at runtime.  (Example:  A user's Desktop
28
 
 *      folder has a compile-time AppId of PSEUDO_APP_DESKTOP with a likely
29
 
 *      runtime URI of $HOME/Desktop.)
30
 
 *
31
 
 *      URIs may be influenced by environment variables or simply the existence
32
 
 *      of a program in the user's search path.
33
 
 */
34
 
 
35
 
 
36
 
#include <glibmm.h>
37
 
#include <glib/gi18n.h>
38
 
#include <stdexcept>
39
 
 
40
 
#include "vmware/tools/ghi/pseudoAppMgr.hh"
41
 
 
42
 
extern "C" {
43
 
#include "vmware.h"
44
 
};
45
 
 
46
 
namespace vmware {
47
 
namespace tools {
48
 
namespace ghi {
49
 
 
50
 
 
51
 
/*
52
 
 * PseudoApps indexed by URI (ex: file:///home/user/Desktop).
53
 
 */
54
 
std::tr1::unordered_map<Glib::ustring,PseudoApp,
55
 
                        std::tr1::hash<std::string> > PseudoAppMgr::sApps;
56
 
 
57
 
/*
58
 
 * PseudoApp URIs indexed by app ID.
59
 
 */
60
 
std::vector<Glib::ustring> PseudoAppMgr::sUris;
61
 
 
62
 
 
63
 
/*
64
 
 *-----------------------------------------------------------------------------
65
 
 *
66
 
 * PseudoAppMgr::PseudoAppMgr --
67
 
 *
68
 
 *      Populates sApps.
69
 
 *
70
 
 * Results:
71
 
 *      None.
72
 
 *
73
 
 * Side effects:
74
 
 *      None.
75
 
 *
76
 
 *-----------------------------------------------------------------------------
77
 
 */
78
 
 
79
 
PseudoAppMgr::PseudoAppMgr()
80
 
{
81
 
   static bool initialized = false;
82
 
 
83
 
   if (!initialized) {
84
 
      InitUriVector();
85
 
      InitAppMap();
86
 
      initialized = true;
87
 
   }
88
 
}
89
 
 
90
 
 
91
 
/*
92
 
 *-----------------------------------------------------------------------------
93
 
 *
94
 
 * PseudoAppMgr::GetAppByAppId --
95
 
 *
96
 
 *      Search for pseudo app by AppId.
97
 
 *
98
 
 * Results:
99
 
 *      Populates app.
100
 
 *
101
 
 * Side effects:
102
 
 *      None.
103
 
 *
104
 
 *-----------------------------------------------------------------------------
105
 
 */
106
 
 
107
 
void
108
 
PseudoAppMgr::GetAppByAppId(AppId id,       // IN
109
 
                            PseudoApp& app) // OUT
110
 
   const
111
 
{
112
 
   if (id < PSEUDO_APP_HOME || id >= PSEUDO_APP_NAPPS) {
113
 
      throw std::logic_error("Invalid PseudoApp identifier");
114
 
   }
115
 
 
116
 
   app = sApps[sUris[id]];
117
 
}
118
 
 
119
 
 
120
 
/*
121
 
 *-----------------------------------------------------------------------------
122
 
 *
123
 
 * PseudoAppMgr::LookupPath --
124
 
 *
125
 
 *      Search for pseudo app by URI.
126
 
 *
127
 
 * Results:
128
 
 *      Returns true and populates app on success.
129
 
 *      Returns false on failure.
130
 
 *
131
 
 * Side effects:
132
 
 *      None.
133
 
 *
134
 
 *-----------------------------------------------------------------------------
135
 
 */
136
 
 
137
 
bool
138
 
PseudoAppMgr::GetAppByUri(const Glib::ustring& uri, // IN
139
 
                          PseudoApp& app)           // OUT
140
 
   const
141
 
{
142
 
   if (sApps.find(uri) != sApps.end()) {
143
 
      app = sApps[uri];
144
 
      return true;
145
 
   }
146
 
 
147
 
   return false;
148
 
}
149
 
 
150
 
 
151
 
/*
152
 
 ******************************************************************************
153
 
 * BEGIN private methods.
154
 
 */
155
 
 
156
 
 
157
 
/*
158
 
 *-----------------------------------------------------------------------------
159
 
 *
160
 
 * PseudoAppMgr::InitAppMap --
161
 
 *
162
 
 *      Populate application map based on static data.
163
 
 *
164
 
 * Results:
165
 
 *      None.
166
 
 *
167
 
 * Side effects:
168
 
 *      Populates sApps.
169
 
 *
170
 
 *-----------------------------------------------------------------------------
171
 
 */
172
 
 
173
 
void
174
 
PseudoAppMgr::InitAppMap()
175
 
{
176
 
   static const struct {
177
 
      const char* symbolicName;
178
 
      const char* iconName;
179
 
   } initTable[] = {
180
 
      { "Home Folder", "user-home" },           // PSEUDO_APP_HOME
181
 
      { "Bookmarks", "user-bookmarks" },        // ..._BOOKMARKS
182
 
      { "Desktop", "user-desktop" },            // ..._DESKTOP
183
 
      { "Documents", "folder" },                // ..._DOCUMENTS
184
 
      { "Download", "folder" },                 // ..._DOWNLOAD
185
 
      { "Music", "folder" },                    // ..._MUSIC
186
 
      { "Pictures", "folder" },                 // ..._PICTURES
187
 
      { "Connect to Server...", "applications-internet" }, // ..._GNOME_CONNECT
188
 
   };
189
 
   size_t idx;
190
 
 
191
 
   ASSERT_ON_COMPILE(ARRAYSIZE(initTable) == PSEUDO_APP_NAPPS);
192
 
 
193
 
   for (idx = 0; idx < ARRAYSIZE(initTable); idx++) {
194
 
      Glib::ustring uri = sUris[idx];
195
 
      if (!uri.empty()) {
196
 
         sApps[uri].uri = uri;
197
 
         /*
198
 
          * gettext lookup against xdg-user-dirs is purely opportunistic.  Standalone
199
 
          * apps (likely) won't exist there, but to keep the loop logic simple, they
200
 
          * aren't excluded from said lookup.
201
 
          */
202
 
         sApps[uri].symbolicName = g_dgettext("xdg-user-dirs",
203
 
                                              initTable[idx].symbolicName);
204
 
         sApps[uri].iconName = initTable[idx].iconName;
205
 
      }
206
 
   }
207
 
}
208
 
 
209
 
 
210
 
/*
211
 
 *-----------------------------------------------------------------------------
212
 
 *
213
 
 * PseudoAppMgr::InitUriVector --
214
 
 *
215
 
 *      Populate sUris based on runtime environment.  See xdg-user-dirs for
216
 
 *      more details.
217
 
 *
218
 
 * Results:
219
 
 *      None.
220
 
 *
221
 
 * Side effects:
222
 
 *      Populates sUris.
223
 
 *
224
 
 *-----------------------------------------------------------------------------
225
 
 */
226
 
 
227
 
void
228
 
PseudoAppMgr::InitUriVector()
229
 
{
230
 
   sUris.resize(PSEUDO_APP_NAPPS);
231
 
 
232
 
   try {
233
 
      sUris[PSEUDO_APP_HOME] = Glib::filename_to_uri(Glib::get_home_dir());
234
 
 
235
 
      std::vector<Glib::ustring> components;
236
 
      components.push_back(Glib::get_home_dir());
237
 
      components.push_back(".gtk-bookmarks");
238
 
      sUris[PSEUDO_APP_BOOKMARKS] =
239
 
         Glib::filename_to_uri(Glib::build_filename(components));
240
 
 
241
 
#define MAP_GUSER_PSEUDO(gUserDir, pAppId)  {                           \
242
 
   Glib::ustring dir = Glib::get_user_special_dir((gUserDir));          \
243
 
   if (!dir.empty()) {                                                  \
244
 
      sUris[(pAppId)] = Glib::filename_to_uri(dir);                     \
245
 
   }                                                                    \
246
 
}
247
 
 
248
 
      MAP_GUSER_PSEUDO(G_USER_DIRECTORY_DESKTOP, PSEUDO_APP_DESKTOP);
249
 
      MAP_GUSER_PSEUDO(G_USER_DIRECTORY_DOCUMENTS, PSEUDO_APP_DOCUMENTS);
250
 
      MAP_GUSER_PSEUDO(G_USER_DIRECTORY_DOWNLOAD, PSEUDO_APP_DOWNLOAD);
251
 
      MAP_GUSER_PSEUDO(G_USER_DIRECTORY_MUSIC, PSEUDO_APP_MUSIC);
252
 
      MAP_GUSER_PSEUDO(G_USER_DIRECTORY_PICTURES, PSEUDO_APP_PICTURES);
253
 
 
254
 
      Glib::ustring connectPath = Glib::find_program_in_path("nautilus-connect-server");
255
 
      if (!connectPath.empty()) {
256
 
         sUris[PSEUDO_APP_GNOME_CONNECT] = Glib::filename_to_uri(connectPath);
257
 
      }
258
 
   } catch (std::exception& e) {
259
 
      g_warning("%s: Caught exception while learning XDG directories: %s\n",
260
 
                __func__, e.what());
261
 
   }
262
 
}
263
 
 
264
 
 
265
 
/*
266
 
 * END private methods.
267
 
 ******************************************************************************
268
 
 */
269
 
 
270
 
} /* namespace ghi */ } /* namespace tools */ } /* namespace vmware */