~ubuntu-branches/ubuntu/karmic/tangerine/karmic

« back to all changes in this revision

Viewing changes to plugins/Session/src/session-glue.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-08-18 21:38:02 UTC
  • mfrom: (2.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090818213802-oqfj7o0bxxu3ti4e
Tags: 0.3.2.2-1
* New upstream release
* debian/watch, debian/control:
  + Update to new homepage
* debian/control:
  + No-change bump to Standards 3.8.3
  + Add myself to Uploaders, and drop some inactive contributors' names
  + Update Vcs-* fields to reflect migration to git
  + Update build depends:
    - Update order to reflect configure.ac order
    - Drop libavahi1.0-cil, libmono-sqlite2.0-cil, cdbs
    - Add banshee, libmono-zeroconf1.0-cil, libndesk-dbus-glib1.0-cil
    - Use DH7
  + Add a debug package, tangerine-dbg
* debian/rules:
  + Rewrite to use DH7
  + Clean up get-orig-source rule
  + Add some custom configure flags
  + Add dh_{,cli}strip overrides to strip into tangerine-dbg
  + Remove /usr/share/doc/tangerine/sample.conf since it's handled by
    dh_installexamples
* debian/compat:
  + Bump to 7
* debian/copyright:
  + Update and use DEP-5
* debian/tangerine*.1, debian/tangerine.manpages:
  + Added manpages for tangerine and tangerine-properties.
* debian/tangerine.examples:
  + Install sample.conf as a sample conf file for ~/.tangerine
* debian/patches:
  + Drop all patches, since they are either applied upstream or no
    longer relevant.
* debian/*.dll.config:
  + Dropped, no longer needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include <stdio.h>
 
3
#include <stdlib.h>
 
4
#include <strings.h>
 
5
#include <X11/SM/SMlib.h>
 
6
#include <signal.h>
 
7
 
 
8
static IceConn iceconn = NULL;
 
9
static int pipes[2];
 
10
static int closed = 0;
 
11
 
 
12
static void
 
13
session_died (SmcConn conn, SmPointer client_data)
 
14
{
 
15
        SmcCloseConnection (conn, 0, NULL);
 
16
        kill (getpid (), SIGTERM);
 
17
}
 
18
 
 
19
static void
 
20
save_yourself (SmcConn conn, SmPointer client_data, int save_type, Bool shutdown, int interact_style, Bool fast)
 
21
{
 
22
        SmcSaveYourselfDone (conn, True);
 
23
}
 
24
 
 
25
static void
 
26
save_complete (SmcConn conn, SmPointer client_data)
 
27
{
 
28
}
 
29
 
 
30
static void
 
31
shutdown_cancelled (SmcConn conn, SmPointer client_data)
 
32
{
 
33
}
 
34
 
 
35
static void
 
36
ice_watch (IceConn ice_conn, IcePointer client_data, Bool opening, IcePointer *watch_data)
 
37
{
 
38
        if (opening) {
 
39
                iceconn = ice_conn;
 
40
        }
 
41
}
 
42
 
 
43
void
 
44
close_session (void)
 
45
{
 
46
        if (iceconn != NULL) {
 
47
                closed = 1;
 
48
                write (pipes[1], "closed", 7);
 
49
        }
 
50
}
 
51
 
 
52
void
 
53
run_session (void)
 
54
{
 
55
        SmcConn conn;
 
56
        SmcCallbacks callbacks;
 
57
        char *id;
 
58
        fd_set rfds;
 
59
 
 
60
        IceInitThreads ();
 
61
        IceAddConnectionWatch (ice_watch, NULL);
 
62
 
 
63
        bzero (&callbacks, sizeof (SmcCallbacks));
 
64
        callbacks.die.callback = session_died;
 
65
        callbacks.save_yourself.callback = save_yourself;
 
66
        callbacks.save_complete.callback = save_complete;
 
67
        callbacks.shutdown_cancelled.callback = shutdown_cancelled;
 
68
        
 
69
        conn = SmcOpenConnection (NULL, NULL, 1, 0, SmcDieProcMask | SmcSaveYourselfProcMask |
 
70
                                  SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask, &callbacks,
 
71
                                  NULL, &id, 0, NULL);
 
72
        IceRemoveConnectionWatch (ice_watch, NULL);
 
73
 
 
74
        if (conn == NULL)
 
75
                return;
 
76
        
 
77
        FD_ZERO (&rfds);
 
78
        FD_SET (IceConnectionNumber (iceconn), &rfds);
 
79
 
 
80
        pipe (pipes);
 
81
        FD_SET (pipes[0], &rfds);
 
82
        
 
83
        
 
84
        while (select (pipes[0] + 1, &rfds, NULL, NULL, NULL) > 0) {
 
85
                if (closed) {
 
86
                        SmcConn smcconn = (SmcConn) iceconn;
 
87
                        if (smcconn == NULL)
 
88
                                continue;
 
89
                        SmcCloseConnection (smcconn, 0, NULL);
 
90
                        break;
 
91
                } else if (IceProcessMessages (iceconn, NULL, NULL) == IceProcessMessagesConnectionClosed) {
 
92
                        break;
 
93
                }
 
94
        }
 
95
}