~marceloshima/tacix/0.1

« back to all changes in this revision

Viewing changes to tacix/server/nx/provider.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:
50
50
        dbus.service.Object.__init__(self, bus_name, PROVIDER_PATH)
51
51
        #self.loop = gobject.MainLoop()
52
52
 
 
53
        self.ck_manager = dbus.Interface (
 
54
                self.bus.get_object ('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Manager'),
 
55
                'org.freedesktop.ConsoleKit.Manager')
 
56
 
53
57
        #self.dbus_info = dbus.Interface(self.bus.get_object('org.freedesktop.DBus',
54
58
        #                                '/org/freedesktop/DBus/Bus', False), 'org.freedesktop.DBus')
55
59
 
57
61
        logger.debug("NXProvider Started")
58
62
 
59
63
    def __get_resumable_sessions(self, user, options):
60
 
        for session in self.tacix_manager._get_sessions_by_type('nx'):
 
64
        sessions = {}
 
65
        for session in self.tacix_manager._get_sessions_for_type('nx'):
61
66
            properties = session.get_properties()
62
 
            if properties['persistent'] == '0':
 
67
            if 'persistent' in properties and properties['persistent'] == '0':
63
68
                continue
64
69
            if properties['user'] != user:
65
70
                continue
66
 
            if 'status' in options:
67
 
                if options['status'].find(properties['state']) == -1:
68
 
                    continue
 
71
            if 'status' in options and options['status'].find(properties['state']) == -1:
 
72
                continue
69
73
            logger.debug("Adding session %s" % properties)
70
74
            sessions[session.get_property('display')] = properties
71
75
        return sessions
120
124
          /org/tacix/nx/provider \
121
125
          org.tacix.nx.provider.GetResumableSessions
122
126
        '''
123
 
        self._check_polkit_privilege(sender, conn, 'org.tacix.sessionmanager.resume')
 
127
        #return {}
 
128
        #self._check_polkit_privilege(sender, conn, 'org.tacix.sessionmanager.resume')
124
129
        return self.__get_resumable_sessions(options['user'], options)
125
130
 
126
131
    @dbus.service.method( dbus_interface=PROVIDER_INTERFACE,
134
139
          org.tacix.nx.provider.GetShadowableSessions
135
140
        '''
136
141
 
137
 
        self._check_polkit_privilege(sender, conn, 'org.tacix.sessionmanager.resume')
 
142
        #self._check_polkit_privilege(sender, conn, 'org.tacix.sessionmanager.resume')
138
143
        sessions = {}
139
144
        ck_sessions = self.ck_manager.GetSessions()
140
145
        for ck_op_session in ck_sessions:
141
 
            ck_session_obj = self.bus.get_object ('org.freedesktop.ConsoleKit', ck_op_session)
142
 
            ck_session = dbus.Interface (ck_session_obj, 'org.freedesktop.ConsoleKit.Session')
 
146
            ck_session = dbus.Interface (self.bus.get_object ('org.freedesktop.ConsoleKit', ck_op_session), 'org.freedesktop.ConsoleKit.Session')
143
147
            display = ck_session.GetX11Display().replace(':', '')
144
148
            if display != '' and int(display) < 100:
145
149
                session_opts = {'display': display,
153
157
                    'session': 'X%s (Local)' % display}
154
158
                sessions[session_opts['display']] = session_opts
155
159
 
156
 
        for session_key in self.manager_sessions.keys():
157
 
            session = self.manager_sessions[session_key]
 
160
        for session in self.tacix_manager.manager_sessions.values():
158
161
            props = session.get_properties()
159
162
            props['available'] = 'Yes'
160
163
            props['session'] = props['uniqueid']