~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to services/plugins/unity/unityPluginPosix.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************
 
2
 * Copyright (C) 2011 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
 * unityPluginPosix.cpp --
 
21
 *
 
22
 *    POSIX subclass of UnityPlugin interface.
 
23
 */
 
24
 
 
25
 
 
26
#include "unityPluginPosix.h"
 
27
 
 
28
 
 
29
extern "C" {
 
30
#include <glib-object.h>
 
31
 
 
32
#include "vmware/tools/desktopevents.h"
 
33
#if defined(OPEN_VM_TOOLS)
 
34
   #include "unitylib/unity.h"
 
35
#else
 
36
   #include "unity.h"
 
37
#endif // OPEN_VM_TOOLS
 
38
}
 
39
 
 
40
 
 
41
namespace vmware {
 
42
namespace tools {
 
43
 
 
44
 
 
45
/*
 
46
 *-----------------------------------------------------------------------------
 
47
 *
 
48
 * UnityPluginPosix::UnityPluginPosix --
 
49
 *
 
50
 *      Constructor.
 
51
 *
 
52
 * Results:
 
53
 *      None.
 
54
 *
 
55
 * Side effects:
 
56
 *      None.
 
57
 *
 
58
 *-----------------------------------------------------------------------------
 
59
 */
 
60
 
 
61
UnityPluginPosix::UnityPluginPosix()
 
62
   : UnityPlugin(),
 
63
     mCtx(NULL)
 
64
{
 
65
}
 
66
 
 
67
 
 
68
/*
 
69
 *-----------------------------------------------------------------------------
 
70
 *
 
71
 * UnityPluginPosix::~UnityPluginPosix --
 
72
 *
 
73
 *      Destructor.
 
74
 *
 
75
 * Results:
 
76
 *      None.
 
77
 *
 
78
 * Side effects:
 
79
 *      None.
 
80
 *
 
81
 *-----------------------------------------------------------------------------
 
82
 */
 
83
 
 
84
UnityPluginPosix::~UnityPluginPosix()
 
85
{
 
86
   if (mCtx) {
 
87
      for (std::map<const char*, gulong>::iterator i = mSignalIDs.begin();
 
88
           i != mSignalIDs.end();
 
89
           ++i) {
 
90
         g_signal_handler_disconnect(mCtx->serviceObj, i->second);
 
91
      }
 
92
   }
 
93
}
 
94
 
 
95
 
 
96
/*
 
97
 *-----------------------------------------------------------------------------
 
98
 *
 
99
 * UnityPluginPosix::Initialize --
 
100
 *
 
101
 *      Initialize UnityPlugin base class and connect to X Session Manager
 
102
 *      GLib signals.
 
103
 *
 
104
 * Results:
 
105
 *      TRUE on success, FALSE otherwise.
 
106
 *
 
107
 * Side effects:
 
108
 *      None.
 
109
 *
 
110
 *-----------------------------------------------------------------------------
 
111
 */
 
112
 
 
113
gboolean
 
114
UnityPluginPosix::Initialize(ToolsAppCtx* ctx)  // IN
 
115
{
 
116
   if (UnityPlugin::Initialize(ctx)) {
 
117
      mCtx = ctx;
 
118
      mSignalIDs[TOOLS_CORE_SIG_XSM_DIE] =
 
119
         g_signal_connect(ctx->serviceObj, TOOLS_CORE_SIG_XSM_DIE,
 
120
                          G_CALLBACK(XSMDieCb), static_cast<gpointer>(this));
 
121
      return TRUE;
 
122
   }
 
123
 
 
124
   return FALSE;
 
125
}
 
126
 
 
127
 
 
128
/*
 
129
 *-----------------------------------------------------------------------------
 
130
 *
 
131
 * UnityPluginPosix::OnXSMEvent --
 
132
 *
 
133
 *      X Session Management event handler.  Exits Unity upon notice of session
 
134
 *      termination.
 
135
 *
 
136
 * Results:
 
137
 *      None.
 
138
 *
 
139
 * Side effects:
 
140
 *      May trigger Unity exit.
 
141
 *
 
142
 *-----------------------------------------------------------------------------
 
143
 */
 
144
 
 
145
void
 
146
UnityPluginPosix::OnXSMDie()
 
147
{
 
148
   if (Unity_IsActive()) {
 
149
      Unity_Exit();
 
150
   }
 
151
}
 
152
 
 
153
 
 
154
/*
 
155
 ******************************************************************************
 
156
 * BEGIN Static member functions
 
157
 */
 
158
 
 
159
 
 
160
/*
 
161
 *-----------------------------------------------------------------------------
 
162
 *
 
163
 * UnityPluginPosix::XSMDieCb --
 
164
 *
 
165
 *      Thunk between XSM "die" OnXSMDie.
 
166
 *
 
167
 * Results:
 
168
 *      None.
 
169
 *
 
170
 * Side effects:
 
171
 *      See OnXSMDie.
 
172
 *
 
173
 *-----------------------------------------------------------------------------
 
174
 */
 
175
 
 
176
void
 
177
UnityPluginPosix::XSMDieCb(GObject* obj,        // UNUSED
 
178
                           ToolsAppCtx* ctx,    // UNUSED
 
179
                           gpointer cbData)     // IN: UnityPluginPosix*
 
180
{
 
181
   UnityPluginPosix* unityPlugin = static_cast<UnityPluginPosix*>(cbData);
 
182
   unityPlugin->OnXSMDie();
 
183
}
 
184
 
 
185
 
 
186
/*
 
187
 * END Static member functions
 
188
 ******************************************************************************
 
189
 */
 
190
 
 
191
 
 
192
} // namespace tools
 
193
} // namespace vmware