~marceloshima/tacix/0.1

« back to all changes in this revision

Viewing changes to tacix/server/nx/node.py

  • Committer: Marcelo Boveto Shima
  • Date: 2009-08-06 04:39:10 UTC
  • Revision ID: mshima@sempron-20090806043910-elbliq3p80b9tgg5
Lots of fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        self.bus = dbus.SystemBus()
47
47
        self.manager_obj = self.bus.get_object (BUS_NAME, MANAGER_PATH)
48
48
        self.manager = dbus.Interface (self.manager_obj, MANAGER_INTERFACE)
49
 
        self.manager_obj = 
50
49
        self.provider = dbus.Interface (self.bus.get_object (PROVIDER_BUS_NAME, PROVIDER_PATH), PROVIDER_INTERFACE)
51
50
        self.user = user
52
51
        if user is None:
69
68
        pass
70
69
 
71
70
    def __watch_agent_state(self, state):
72
 
        if state == 'ready':
73
 
            self.txsession.Run()
74
 
            self.__state_signal.remove()
 
71
        if state == 'ready' and self.txsession.GetProperty ('seat-type') == 'nx':
 
72
            self.txsession.Run ()
 
73
            self.__state_signal.remove ()
 
74
        elif state == 'ready':
 
75
            self.logger.debug ('Starting shadow')
 
76
            self.session_worker = dbus.Interface (self.bus.get_object (self.txsession.GetSessionWorker(), '/Session'), SESSION_WORKER_INTERFACE)
 
77
 
 
78
            # Getting the ConsoleKit object
 
79
            ck_manager = dbus.Interface (
 
80
                    self.bus.get_object ('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Manager'),
 
81
                    'org.freedesktop.ConsoleKit.Manager')
 
82
 
 
83
            ck_session_id = None
 
84
            ck_sessions = ck_manager.GetSessions()
 
85
            for ck_op_session in ck_sessions:
 
86
                ck_session = dbus.Interface (self.bus.get_object ('org.freedesktop.ConsoleKit', ck_op_session), 'org.freedesktop.ConsoleKit.Session')
 
87
                if ck_session.GetX11Display() == ':' + self.txsession.GetProperty ('shadowdisplay'):
 
88
                    ck_session_id = ck_session.GetId ()
 
89
            self.logger.debug ('Starting shadow for ck ' + ck_session_id)
 
90
 
 
91
            if ck_session_id is None:
 
92
                self.quit ()
 
93
            self.session_worker.RunShadowForCKSession (ck_session_id)
 
94
            self.logger.debug ('Running shadow')
 
95
            self.txsession.Run ()
 
96
            self.__state_signal.remove ()
 
97
            self.logger.debug ('shadow running')
75
98
        return
76
99
 
77
100
    def watch_agent_state_resume(self, state):
133
156
        if 'display' in options:
134
157
            options['shadowdisplay'] = options['display']
135
158
            del options['display']
136
 
        self.start_session(options)
 
159
        self.start_session(options, 'nx-shadow')
137
160
 
138
161
    def suspend_session(self, options):
139
162
        self.get_session(options['id'])
148
171
        session_obj = self.bus.get_object (BUS_NAME, session_path)
149
172
        self.txsession = dbus.Interface (session_obj, SESSION_INTERFACE)
150
173
 
151
 
    def start_session(self, options):
 
174
    def start_session(self, options, session_type):
152
175
        '''Init the NX Node'''
153
176
        # Create TXManager session
154
 
        session_path = self.manager.CreateSession (self.user, 'nx')
 
177
        session_path = self.manager.CreateSession (self.user, session_type)
155
178
        session_obj = self.bus.get_object (BUS_NAME, session_path)
156
179
        self.txsession = dbus.Interface (session_obj, SESSION_INTERFACE)
157
180
        self.add_signals()