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

« back to all changes in this revision

Viewing changes to services/plugins/desktopEvents/sessionMgr.c

  • 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
 * @file sessionMgr.c
 
21
 *
 
22
 * Support for X session management using the, well, X Session Management
 
23
 * Library (libSM) with a little help from the Inter-Client Exchange Library
 
24
 * (libICE).  This allows vmusr to receive X session lifecycle events and clean
 
25
 * up appropriately upon session termination.  For now, cleanup upon shutdown
 
26
 * is the only activity we're interested in.
 
27
 *
 
28
 * A custom event source is used to bind libICE connections with GLib's main
 
29
 * loop and dispatch messages.  As this is the first (and hopefully only)
 
30
 * libICE client, all ICE interaction is handled here (as opposed to in a
 
31
 * provider application).
 
32
 *
 
33
 * This should work with any session manager implementing XSMP, covering all
 
34
 * of our supported desktop environments.
 
35
 *
 
36
 * This plugin also maps the XSM callbacks to GLib signals.  See desktopevents.h
 
37
 * for details.
 
38
 *
 
39
 * @todo Scrutinize libICE error handling.  I/O errors should be handled here,
 
40
 *       but errors handled by libICE's default may exit().
 
41
 */
 
42
 
 
43
 
 
44
/* Include first.  Sets G_LOG_DOMAIN. */
 
45
#include "desktopEventsInt.h"
 
46
 
 
47
#include "vmware.h"
 
48
#include "vmware/tools/desktopevents.h"
 
49
#include "sessionMgrSignals.h"
 
50
 
 
51
#include <errno.h>
 
52
#include <glib.h>
 
53
#include <pwd.h>
 
54
#include <stdlib.h>
 
55
#include <string.h>
 
56
#include <unistd.h>
 
57
#include <X11/SM/SMlib.h>
 
58
#include <X11/ICE/ICElib.h>
 
59
 
 
60
 
 
61
/*
 
62
 * Identifier used for SessionMgr private data in DesktopEvents private hash
 
63
 * table.
 
64
 */
 
65
#define DE_FEATURE_KEY  "sessionMgr"
 
66
 
 
67
 
 
68
static void InitSignals(ToolsAppCtx* ctx);
 
69
static void InitSMProperties(SmcConn smcCnx);
 
70
 
 
71
 
 
72
/*
 
73
 * libICE integration declarations.
 
74
 */
 
75
 
 
76
 
 
77
typedef struct {
 
78
   GSource *iceSource;
 
79
   IceConn  iceCnx;
 
80
} ICEWatchCtx;
 
81
 
 
82
static gboolean ICEDispatch(GIOChannel *chn, GIOCondition cond, gpointer cbData);
 
83
static void ICEIOErrorHandler(IceConn iceCnx);
 
84
static void ICEWatch(IceConn iceCnx, IcePointer clientData, Bool opening,
 
85
                     IcePointer *watchData);
 
86
 
 
87
 
 
88
/*
 
89
 * libSM callbacks.
 
90
 */
 
91
 
 
92
 
 
93
static void SMDieCb(SmcConn smcCnx, SmPointer cbData);
 
94
static void SMSaveYourselfCb(SmcConn smcCnx, SmPointer cbData, int saveType,
 
95
                             Bool shutdown, int interactStyle, Bool fast);
 
96
static void SMSaveCompleteCb(SmcConn smcCnx, SmPointer cbData);
 
97
static void SMShutdownCancelledCb(SmcConn smcCnx, SmPointer cbData);
 
98
 
 
99
 
 
100
/*
 
101
 ******************************************************************************
 
102
 * SessionMgr_Init --                                                    */ /**
 
103
 *
 
104
 * Register custom ICE connection source and sign up with the session manager.
 
105
 *
 
106
 * @param[in] ctx   Application context.
 
107
 * @param[in] pdata Plugin data.
 
108
 *
 
109
 * @retval TRUE Always "succeeds".  Session management is optional.
 
110
 *
 
111
 ******************************************************************************
 
112
 */
 
113
 
 
114
gboolean
 
115
SessionMgr_Init(ToolsAppCtx *ctx,
 
116
                ToolsPluginData *pdata)
 
117
{
 
118
   SmcCallbacks smCallbacks;
 
119
   unsigned long cbMask =
 
120
        SmcSaveYourselfProcMask
 
121
      | SmcDieProcMask
 
122
      | SmcSaveCompleteProcMask
 
123
      | SmcShutdownCancelledProcMask;
 
124
   SmcConn smcCnx;
 
125
   char errorBuf[128];
 
126
   char *clientID = NULL;
 
127
 
 
128
   IceSetIOErrorHandler(ICEIOErrorHandler);
 
129
   IceAddConnectionWatch(ICEWatch, pdata);
 
130
 
 
131
   memset(&smCallbacks, 0, sizeof smCallbacks);
 
132
   smCallbacks.save_yourself.callback = &SMSaveYourselfCb;
 
133
   smCallbacks.save_yourself.client_data = pdata;
 
134
   smCallbacks.save_complete.callback = &SMSaveCompleteCb;
 
135
   smCallbacks.save_complete.client_data = pdata;
 
136
   smCallbacks.shutdown_cancelled.callback = &SMShutdownCancelledCb;
 
137
   smCallbacks.shutdown_cancelled.client_data = pdata;
 
138
   smCallbacks.die.callback = &SMDieCb;
 
139
   smCallbacks.die.client_data = pdata;
 
140
 
 
141
   smcCnx =
 
142
      SmcOpenConnection(NULL, NULL, SmProtoMajor, SmProtoMinor, cbMask,
 
143
                        &smCallbacks, NULL, &clientID, sizeof errorBuf, errorBuf);
 
144
   if (smcCnx != NULL) {
 
145
      InitSignals(ctx);
 
146
      InitSMProperties(smcCnx);
 
147
      g_hash_table_insert(pdata->_private, DE_FEATURE_KEY, smcCnx);
 
148
      g_debug("Registered with session manager as %s\n", clientID);
 
149
      free(clientID);
 
150
   } else {
 
151
      g_message("Failed to register with session manager.\n");
 
152
      g_message("SmcOpenConnection: %s\n", errorBuf);
 
153
      IceRemoveConnectionWatch(ICEWatch, pdata);
 
154
   }
 
155
 
 
156
   return TRUE;
 
157
}
 
158
 
 
159
 
 
160
/*
 
161
 ******************************************************************************
 
162
 * SessionMgr_Shutdown --                                                */ /**
 
163
 *
 
164
 * Shuts down XSM and ICE interfaces and frees other resources.
 
165
 *
 
166
 * @param[in] ctx   Application context.
 
167
 * @param[in] pdata Plugin data.
 
168
 *
 
169
 ******************************************************************************
 
170
 */
 
171
 
 
172
void
 
173
SessionMgr_Shutdown(ToolsAppCtx *ctx,
 
174
                    ToolsPluginData *pdata)
 
175
{
 
176
   GHashTable *desktopData = pdata->_private;
 
177
   SmcConn smcCnx = g_hash_table_lookup(desktopData, DE_FEATURE_KEY);
 
178
   if (smcCnx != NULL) {
 
179
      SmcCloseConnection(smcCnx, 0, NULL);
 
180
      IceRemoveConnectionWatch(ICEWatch, pdata);
 
181
      g_hash_table_remove(desktopData, DE_FEATURE_KEY);
 
182
   }
 
183
}
 
184
 
 
185
 
 
186
/*
 
187
 ******************************************************************************
 
188
 * InitSignals --                                                        */ /**
 
189
 *
 
190
 * Creates new signals for XSM events.
 
191
 *
 
192
 * @param[in]  ctx      ToolsAppCtx*: Application context.
 
193
 *
 
194
 ******************************************************************************
 
195
 */
 
196
 
 
197
static void
 
198
InitSignals(ToolsAppCtx *ctx)
 
199
{
 
200
   /* SmcCallbacks::save_yourself */
 
201
   g_signal_new(TOOLS_CORE_SIG_XSM_SAVE_YOURSELF,
 
202
                G_OBJECT_TYPE(ctx->serviceObj),
 
203
                0,      // GSignalFlags
 
204
                0,      // class offset
 
205
                NULL,   // accumulator
 
206
                NULL,   // accu_data
 
207
                g_cclosure_user_marshal_VOID__POINTER_INT_BOOLEAN_INT_BOOLEAN,
 
208
                G_TYPE_NONE,
 
209
                5,
 
210
                G_TYPE_POINTER,
 
211
                G_TYPE_INT,
 
212
                G_TYPE_BOOLEAN,
 
213
                G_TYPE_INT,
 
214
                G_TYPE_BOOLEAN);
 
215
 
 
216
   /* SmcCallbacks::die */
 
217
   g_signal_new(TOOLS_CORE_SIG_XSM_DIE,
 
218
                G_OBJECT_TYPE(ctx->serviceObj),
 
219
                0,      // GSignalFlags
 
220
                0,      // class offset
 
221
                NULL,   // accumulator
 
222
                NULL,   // accu_data
 
223
                g_cclosure_marshal_VOID__POINTER,
 
224
                G_TYPE_NONE,
 
225
                1,
 
226
                G_TYPE_POINTER);
 
227
 
 
228
   /* SmcCallbacks::save_complete */
 
229
   g_signal_new(TOOLS_CORE_SIG_XSM_SAVE_COMPLETE,
 
230
                G_OBJECT_TYPE(ctx->serviceObj),
 
231
                0,      // GSignalFlags
 
232
                0,      // class offset
 
233
                NULL,   // accumulator
 
234
                NULL,   // accu_data
 
235
                g_cclosure_marshal_VOID__POINTER,
 
236
                G_TYPE_NONE,
 
237
                1,
 
238
                G_TYPE_POINTER);
 
239
 
 
240
   /* SmcCallbacks::shutdown_cancelled */
 
241
   g_signal_new(TOOLS_CORE_SIG_XSM_SHUTDOWN_CANCELLED,
 
242
                G_OBJECT_TYPE(ctx->serviceObj),
 
243
                0,      // GSignalFlags
 
244
                0,      // class offset
 
245
                NULL,   // accumulator
 
246
                NULL,   // accu_data
 
247
                g_cclosure_marshal_VOID__POINTER,
 
248
                G_TYPE_NONE,
 
249
                1,
 
250
                G_TYPE_POINTER);
 
251
}
 
252
 
 
253
 
 
254
/*
 
255
 ******************************************************************************
 
256
 * InitSMProperties --                                                   */ /**
 
257
 *
 
258
 * Tell the session manager a little bit about ourself.
 
259
 *
 
260
 * The most important property to us is SmRestartStyleHint, where we hint to
 
261
 * the session manager that it shouldn't attempt to restore the vmusr container
 
262
 * as part of a session.  (Instead, that job is handled by our XDG autostart
 
263
 * entry.)
 
264
 *
 
265
 * The other properties are set only because SMlib docs claim they're
 
266
 * mandatory.  Dummy values are used where possible.
 
267
 *
 
268
 * @param[in]  smcCnx   SM client connection.
 
269
 *
 
270
 ******************************************************************************
 
271
 */
 
272
 
 
273
static void
 
274
InitSMProperties(SmcConn smcCnx)
 
275
{
 
276
   enum {
 
277
      PROP_ID_CLONE_CMD,
 
278
      PROP_ID_PROGRAM,
 
279
      PROP_ID_RESTART_CMD,
 
280
      PROP_ID_RESTART_STYLE,
 
281
      PROP_ID_USER_ID,
 
282
   };
 
283
   static uint8 restartHint = SmRestartNever;
 
284
   static SmPropValue values[] = {
 
285
      { sizeof "/bin/false" - 1, "/bin/false" },
 
286
      { sizeof "vmware-user" - 1, "vmware-user" },
 
287
      { sizeof "/bin/false" - 1, "/bin/false" },
 
288
      { sizeof restartHint, &restartHint },
 
289
      { 0, NULL },
 
290
   };
 
291
   static SmProp properties[] = {
 
292
      { SmCloneCommand, SmLISTofARRAY8, 1, &values[PROP_ID_CLONE_CMD] },
 
293
      { SmProgram, SmARRAY8, 1, &values[PROP_ID_PROGRAM] },
 
294
      { SmRestartCommand, SmLISTofARRAY8, 1, &values[PROP_ID_RESTART_CMD] },
 
295
      { SmRestartStyleHint, SmCARD8, 1, &values[PROP_ID_RESTART_STYLE] },
 
296
      { SmUserID, SmARRAY8, 1, &values[PROP_ID_USER_ID] },
 
297
   };
 
298
   static SmProp *propp[] = {
 
299
      &properties[0], &properties[1], &properties[2], &properties[3],
 
300
      &properties[4]
 
301
   };
 
302
 
 
303
   struct passwd *pw = getpwuid(getuid());
 
304
   values[PROP_ID_USER_ID].length = strlen(pw->pw_name);
 
305
   values[PROP_ID_USER_ID].value = pw->pw_name;
 
306
 
 
307
   SmcSetProperties(smcCnx, ARRAYSIZE(propp), (SmProp**)propp);
 
308
}
 
309
 
 
310
 
 
311
/*
 
312
 ******************************************************************************
 
313
 * BEGIN libICE stuff.
 
314
 */
 
315
 
 
316
 
 
317
/*
 
318
 * A note on source reference counting:
 
319
 *
 
320
 * There are two entities that maintain references on ICEWatchCtx's GSource.
 
321
 *    - GLib's GMainContext, and
 
322
 *    - libICE's IceConn (via ICEWatch's watchData).
 
323
 *
 
324
 * A source's initial reference created in ICEWatch may be considered as
 
325
 * transferred to libICE until ICEWatch is again called upon connection close.
 
326
 * The second reference comes from attaching the source to the GLib main loop.
 
327
 */
 
328
 
 
329
 
 
330
/*
 
331
 ******************************************************************************
 
332
 * ICEIOErrorHandler --                                                  */ /**
 
333
 *
 
334
 * Handler for libICE I/O errors.
 
335
 *
 
336
 * Does nothing but replaces libICE's default handler which would've caused us
 
337
 * to exit.
 
338
 *
 
339
 * @param[in]  iceCnx    Opaque ICE connection descriptor.
 
340
 *
 
341
 ******************************************************************************
 
342
 */
 
343
 
 
344
static void
 
345
ICEIOErrorHandler(IceConn iceCnx)
 
346
{
 
347
   g_message("%s: %s\n", __func__, strerror(errno));
 
348
}
 
349
 
 
350
 
 
351
/*
 
352
 ******************************************************************************
 
353
 * ICEDispatch --                                                        */ /**
 
354
 *
 
355
 * GSource dispatch routine.  Calls IceProcessMessages on the ICE connection.
 
356
 *
 
357
 * @param[in]  chn      GIOChannel event source
 
358
 * @param[in]  cond     condition satisfied (ignored)
 
359
 * @param[in]  cbData   (ICEWatchCtx*) Channel context.
 
360
 *
 
361
 * @retval TRUE  Underlying iceCnx is still valid, so do not kill this source.
 
362
 * @retval FALSE Underlying iceCnx was destroyed, so remove this source.
 
363
 *
 
364
 ******************************************************************************
 
365
 */
 
366
 
 
367
static gboolean
 
368
ICEDispatch(GIOChannel *chn,
 
369
            GIOCondition cond,
 
370
            gpointer cbData)
 
371
{
 
372
   IceProcessMessagesStatus status;
 
373
   ICEWatchCtx *watchCtx = cbData;
 
374
   ASSERT(watchCtx);
 
375
 
 
376
   /*
 
377
    * We ignore the error conditions here and let IceProcessMessages return
 
378
    * an IceProcessMessagesIOError, resulting in a single, shared error code
 
379
    * path.
 
380
    */
 
381
 
 
382
   status = IceProcessMessages(watchCtx->iceCnx, NULL, NULL);
 
383
   switch (status) {
 
384
   case IceProcessMessagesSuccess:
 
385
      return TRUE;
 
386
   case IceProcessMessagesIOError:
 
387
      IceCloseConnection(watchCtx->iceCnx);    // Let ICEWatch kill the source.
 
388
      return TRUE;
 
389
   case IceProcessMessagesConnectionClosed:
 
390
      /*
 
391
       * iceCnx was invalidated, so we won't see another call to ICEWatch,
 
392
       * so we'll return FALSE and let GLib destroy the source for us.
 
393
       */
 
394
      watchCtx->iceCnx = NULL;
 
395
      g_source_unref(watchCtx->iceSource);
 
396
      return FALSE;
 
397
   }
 
398
 
 
399
   NOT_REACHED();
 
400
}
 
401
 
 
402
 
 
403
/*
 
404
 ******************************************************************************
 
405
 * ICEWatch --                                                           */ /**
 
406
 *
 
407
 * libICE connection watching callback.
 
408
 *
 
409
 * Creates or removes GLib event sources upon ICE connection creation/
 
410
 * destruction.
 
411
 *
 
412
 * From ICElib.xml:
 
413
 *    "If opening is True the client should set the *watch_data pointer to
 
414
 *    any data it may need to save until the connection is closed and the
 
415
 *    watch procedure is invoked again with opening set to False."
 
416
 *
 
417
 * @param[in]  iceCnx    Opaque ICE connection descriptor.
 
418
 * @parma[in]  cbData    (ToolsPluginData*) plugin data
 
419
 * @param[in]  opening   True if creating a connection, False if closing.
 
420
 * @param[in]  watchData See above.  New source will be stored here.
 
421
 *
 
422
 ******************************************************************************
 
423
 */
 
424
 
 
425
static void
 
426
ICEWatch(IceConn iceCnx,
 
427
         IcePointer cbData,
 
428
         Bool opening,
 
429
         IcePointer *watchData)
 
430
{
 
431
   ToolsPluginData *pdata = cbData;
 
432
   ToolsAppCtx *ctx;
 
433
 
 
434
   ctx = g_hash_table_lookup(pdata->_private, DE_PRIVATE_CTX);
 
435
   ASSERT(ctx);
 
436
 
 
437
   if (opening) {
 
438
      GIOChannel *iceChannel;
 
439
      GSource *iceSource;
 
440
      ICEWatchCtx *watchCtx;
 
441
      GError *error = NULL;
 
442
 
 
443
      iceChannel = g_io_channel_unix_new(IceConnectionNumber(iceCnx));
 
444
      if (g_io_channel_set_encoding(iceChannel, NULL, &error) != G_IO_STATUS_NORMAL) {
 
445
         g_warning("%s: g_io_channel_set_encoding: %s\n", __func__, error->message);
 
446
         g_clear_error(&error);
 
447
         g_io_channel_unref(iceChannel);
 
448
         return;
 
449
      }
 
450
      g_io_channel_set_buffered(iceChannel, FALSE);
 
451
 
 
452
      iceSource = g_io_create_watch(iceChannel, G_IO_IN|G_IO_HUP|G_IO_ERR);
 
453
      g_io_channel_unref(iceChannel);   // Ownership transferred to iceSource.
 
454
 
 
455
      watchCtx = g_new(ICEWatchCtx, 1);
 
456
      watchCtx->iceSource = iceSource;
 
457
      watchCtx->iceCnx = iceCnx;
 
458
      *watchData = watchCtx;
 
459
 
 
460
      VMTOOLSAPP_ATTACH_SOURCE(ctx, iceSource, &ICEDispatch, watchCtx, NULL);
 
461
   } else {
 
462
      ICEWatchCtx *watchCtx = *watchData;
 
463
      if (watchCtx) {
 
464
         watchCtx->iceCnx = NULL;
 
465
         if (watchCtx->iceSource) {
 
466
            g_source_destroy(watchCtx->iceSource);
 
467
            g_source_unref(watchCtx->iceSource);
 
468
         }
 
469
         g_free(watchCtx);
 
470
         *watchData = NULL;
 
471
      }
 
472
   }
 
473
}
 
474
 
 
475
 
 
476
/*
 
477
 * END libICE stuff.
 
478
 ******************************************************************************
 
479
 */
 
480
 
 
481
 
 
482
/*
 
483
 ******************************************************************************
 
484
 * BEGIN libSM stuff.
 
485
 */
 
486
 
 
487
 
 
488
/*
 
489
 ******************************************************************************
 
490
 * SMDieCb --                                                            */ /**
 
491
 *
 
492
 * Callback for a XSM "Die" event.
 
493
 *
 
494
 * Instructs the main loop to quit.  We "acknowledge" the callback by closing
 
495
 * the connection in our shutdown handler.
 
496
 *
 
497
 * @param[in]  smcCnx   Opaque XSM connection object.
 
498
 * @param[in]  cbData   (ToolsPluginData*) Plugin data.
 
499
 *
 
500
 ******************************************************************************
 
501
 */
 
502
 
 
503
static void
 
504
SMDieCb(SmcConn smcCnx,
 
505
        SmPointer cbData)
 
506
{
 
507
   ToolsPluginData *pdata = cbData;
 
508
   ToolsAppCtx *ctx;
 
509
 
 
510
   ASSERT(pdata);
 
511
 
 
512
   ctx = g_hash_table_lookup(pdata->_private, DE_PRIVATE_CTX);
 
513
   ASSERT(ctx);
 
514
 
 
515
   g_message("Session manager says our time is up.  Exiting.\n");
 
516
   g_signal_emit_by_name(ctx->serviceObj, TOOLS_CORE_SIG_XSM_DIE, ctx);
 
517
   g_main_loop_quit(ctx->mainLoop);
 
518
}
 
519
 
 
520
 
 
521
/*
 
522
 ******************************************************************************
 
523
 * SMSaveYourselfCb --                                                   */ /**
 
524
 *
 
525
 * Callback for XSM "SaveYourself" event.
 
526
 *
 
527
 * This event is sent to all XSM clients either to checkpoint a session
 
528
 * or in advance of a (cancellable) session  shutdown event.  If we needed
 
529
 * time to persist state, now would be the time to do it.  Since we don't,
 
530
 * however, this is nearly a no-op -- we only acknowledge the manager.
 
531
 *
 
532
 * @param[in]  smcCnx   Opaque XSM connection object.
 
533
 * @param[in]  cbData   (ToolsPluginData*) Plugin data.
 
534
 * @param[in]  saveType Refer to SMlib.xml.
 
535
 * @param[in]  shutdown Checkpoint or shutdown?
 
536
 * @param[in]  interactStyle May interact with user?
 
537
 * @param[in]  fast     Shutdown as quickly as possible.
 
538
 *
 
539
 * @todo Consider whether it'd make sense to unregister capabilities and pause
 
540
 *       other plugins if shutdown == True until either we receive a 'die' or
 
541
 *       'shutdown cancelled' event.
 
542
 *
 
543
 ******************************************************************************
 
544
 */
 
545
 
 
546
static void
 
547
SMSaveYourselfCb(SmcConn smcCnx,
 
548
                 SmPointer cbData,
 
549
                 int saveType,
 
550
                 Bool shutdown,
 
551
                 int interactStyle,
 
552
                 Bool fast)
 
553
{
 
554
   ToolsPluginData *pdata = cbData;
 
555
   ToolsAppCtx *ctx;
 
556
 
 
557
   ASSERT(pdata);
 
558
 
 
559
   ctx = g_hash_table_lookup(pdata->_private, DE_PRIVATE_CTX);
 
560
   ASSERT(ctx);
 
561
 
 
562
   g_signal_emit_by_name(ctx->serviceObj, TOOLS_CORE_SIG_XSM_SAVE_YOURSELF,
 
563
                         ctx, saveType, shutdown, interactStyle, fast);
 
564
   SmcSaveYourselfDone(smcCnx, True);
 
565
}
 
566
 
 
567
 
 
568
/*
 
569
 ******************************************************************************
 
570
 * SMSaveCompleteCb --                                                   */ /**
 
571
 *
 
572
 * Callback for XSM "SaveComplete" event.
 
573
 *
 
574
 * State has been checkpointed.  Application may resume normal operations.
 
575
 * Total no-op.
 
576
 *
 
577
 * @param[in]  smcCnx   Opaque XSM connection object.
 
578
 * @param[in]  cbData   (ToolsPluginData*) Plugin data.
 
579
 *
 
580
 ******************************************************************************
 
581
 */
 
582
 
 
583
static void
 
584
SMSaveCompleteCb(SmcConn smcCnx,
 
585
                 SmPointer cbData)
 
586
{
 
587
   ToolsPluginData *pdata = cbData;
 
588
   ToolsAppCtx *ctx;
 
589
 
 
590
   ASSERT(pdata);
 
591
 
 
592
   ctx = g_hash_table_lookup(pdata->_private, DE_PRIVATE_CTX);
 
593
   ASSERT(ctx);
 
594
 
 
595
   g_signal_emit_by_name(ctx->serviceObj, TOOLS_CORE_SIG_XSM_SAVE_COMPLETE, ctx);
 
596
}
 
597
 
 
598
 
 
599
/*
 
600
 ******************************************************************************
 
601
 * SMShutdownCancelledCb --                                              */ /**
 
602
 *
 
603
 * Callback for XSM "ShutdownCancelled" event.
 
604
 *
 
605
 * User cancelled shutdown.  May resume normal operations.  Again, total no-op.
 
606
 *
 
607
 * @param[in]  smcCnx   Opaque XSM connection object.
 
608
 * @param[in]  cbData   (ToolsPluginData*) Plugin data.
 
609
 *
 
610
 ******************************************************************************
 
611
 */
 
612
 
 
613
static void
 
614
SMShutdownCancelledCb(SmcConn smcCnx,
 
615
                      SmPointer cbData)
 
616
{
 
617
   ToolsPluginData *pdata = cbData;
 
618
   ToolsAppCtx *ctx;
 
619
 
 
620
   ASSERT(pdata);
 
621
 
 
622
   ctx = g_hash_table_lookup(pdata->_private, DE_PRIVATE_CTX);
 
623
   ASSERT(ctx);
 
624
 
 
625
   g_signal_emit_by_name(ctx->serviceObj, TOOLS_CORE_SIG_XSM_SHUTDOWN_CANCELLED,
 
626
                         ctx);
 
627
}
 
628
 
 
629
 
 
630
/*
 
631
 * END libSM stuff.
 
632
 ******************************************************************************
 
633
 */