This file is indexed.

/usr/lib/ubiquity/plugins/myth-remote.py is in mythbuntu-live-autostart 0.76.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Copyright (C) 2006, 2007, 2009 Canonical Ltd.
# Written by Colin Watson <cjwatson@ubuntu.com>.
# Copyright (C) 2007-2010 Mario Limonciello
#
# This file is part of Ubiquity.
#
# Ubiquity is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Ubiquity is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ubiquity.  If not, see <http://www.gnu.org/licenses/>.

from ubiquity.plugin import *
from ubiquity import osextras
from mythbuntu_common.installer import *
from mythbuntu_common.lirc import LircHandler
from ubiquity import install_misc
import os
import debconf


NAME = 'myth-remote'
AFTER = 'myth-services'
WEIGHT = 10

class PageGtk(MythPageGtk):
    plugin_title = 'ubiquity/text/remote_heading_label'

    def __init__(self, controller, *args, **kwargs):
        self.ui_file = 'tab_remote_control'
        MythPageGtk.__init__(self, controller, *args, **kwargs)
        self.populate_lirc()
        #we use the radio button only
        self.remotecontrol.hide()
        #don't support any transmitters during install
        self.transmitter_vbox.hide()
        #hide the title so we can use the newer ubiquity one
        self.remote_control_title.hide()

    def populate_lirc(self):
        """Fills the lirc pages with the appropriate data"""
        self.remote_count = 0
        self.transmitter_count = 0
        remote_model = self.remote_list.get_model()
        transmitter_model = self.transmitter_list.get_model()
        lirchandler=LircHandler()
        for item in lirchandler.get_possible_devices("remote"):
            if "Custom" not in item and "Blaster" not in item:
                remote_model.append([item])
                self.remote_count = self.remote_count + 1
        for item in lirchandler.get_possible_devices("transmitter"):
            if "Custom" not in item:
                transmitter_model.append([item])
                self.transmitter_count = self.transmitter_count + 1
        self.remote_list.set_active(0)
        self.transmitter_list.set_active(0)

    def toggle_ir(self,widget):
        """Called whenever a request to enable/disable remote is called"""
        if widget is not None:
            if type(widget) is Gtk.RadioButton:
                if widget.get_active():
                    name = widget.get_name()
                    if name == 'lirc_support':
                        self.smartphone_vbox.set_sensitive(False)
                        self.lirc_vbox.set_sensitive(True)
                        self.remote_hbox.set_sensitive(True)
                        self.generate_lircrc_checkbox.set_sensitive(True)
                        self.remote_list.set_active(1)
                    else:
                        self.lirc_vbox.set_sensitive(False)
                        self.remote_list.set_active(0)
                        self.remote_hbox.set_sensitive(False)
                        self.generate_lircrc_checkbox.set_sensitive(False)
                        if name == 'native_support':
                            self.smartphone_vbox.set_sensitive(False)
                        elif name == 'smartphone_support':
                            self.smartphone_vbox.set_sensitive(True)

            ##turn on/off IR transmitter
            #elif widget.get_name() == "transmittercontrol":
            #    self.transmitter_hbox.set_sensitive(widget.get_active())
            #    if widget.get_active():
            #        if self.transmitter_list.get_active() == 0:
            #            self.transmitter_list.set_active(1)
            #    else:
            #        self.transmitter_list.set_active(0)

            #if our selected remote itself changed
            elif widget.get_name() == 'remote_list':
                self.generate_lircrc_checkbox.set_active(True)
                if self.remote_list.get_active() == 0:
                    self.native_support.set_active(True)
                    self.generate_lircrc_checkbox.set_active(False)
            ##if our selected transmitter itself changed
            #elif widget.get_name() == 'transmitter_list':
            #    if self.transmitter_list.get_active() == 0:
            #        self.transmittercontrol.set_active(False)

    def set_lirc(self,question,answer):
        """Preseeds a lirc configuration item"""
        if question == "remote":
            for i in range(0,self.remote_count):
                self.remote_list.set_active(i)
                found=False
                model = self.remote_list.get_model()
                iterator = self.remote_list.get_active_iter()
                value = model.get_value(iterator, 0)
                if value == answer:
                    found = True
                    break
                if not found:
                    self.remote_list.set_active(0)
        if question == "transmitter":
            for i in range(0,self.transmitter_count):
                self.transmitter_list.set_active(i)
                found=False
                model = self.transmitter_list.get_model()
                iterator = self.transmitter_list.get_active_iter()
                value = model.get_value(iterator, 0)
                if value == answer:
                    found = True
                    break
                if not found:
                    self.transmitter_list.set_active(0)

    def get_lirc(self,type):
        item = {"modules":"","device":"","driver":"","lircd_conf":""}
        if type == "remote":
            model = self.remote_list.get_model()
            iterator = self.remote_list.get_active_iter()
            item["remote"] = model.get_value(iterator, 0)
        elif type == "transmitter":
            model = self.transmitter_list.get_model()
            iterator = self.transmitter_list.get_active_iter()
            item["transmitter"] = model.get_value(iterator, 0)

        #smartphones
        if type == "remote" and self.smartphone_support.get_active():
            item["remote"] = "smartphone"
        return item

class Page(Plugin):
    def prepare(self):
        self.top = ['remote', 'transmitter']
        questions = []
        for question in self.top:
            answer = self.db.get('lirc/' + question)
            if answer != '':
                self.ui.set_lirc(question,answer)
            questions.append('^lirc/' + question)
        return (['/usr/share/ubiquity/ask-mythbuntu','ir'], questions)

    def ok_handler(self):
        for question in self.top:
            device = self.ui.get_lirc(question)
            self.preseed('lirc/' + question,device[question])
        Plugin.ok_handler(self)

class Install(InstallPlugin):
    def install(self, target, progress, *args, **kwargs):
        progress.info('ubiquity/install/ir')

        lirchandler = LircHandler()

        remote = progress.get('lirc/remote')
        transmitter = progress.get('lirc/transmitter')

        if remote == "None" and transmitter == "None":
            install_misc.record_removed(['lirc'], True)
            return InstallPlugin.install(self, target, progress, *args, **kwargs)

        elif remote == 'smartphone':
            #TODO, configure telnet so remote will work
            install_misc.record_removed(['lirc'], True)
            return InstallPlugin.install(self, target, progress, *args, **kwargs)

        #configure lircd for remote and transmitter
        ir_device = {"modules":"","driver":"","device":"","lircd_conf":"","remote":"","transmitter":""}
        install_misc.chroot_setup(target)
        install_misc.chrex(target,'dpkg-divert', '--package', 'ubiquity', '--rename',
                   '--quiet', '--add', '/sbin/udevd')
        try:
            os.symlink('/bin/true', '/target/sbin/udevd')
        except OSError:
            pass

        try:
            ir_device["remote"] = remote
            install_misc.set_debconf(target, 'lirc/remote', ir_device["remote"])
            ir_device["modules"] = ""
            ir_device["driver"] = ""
            ir_device["device"] = ""
            ir_device["lircd_conf"] = ""
            lirchandler.set_device(ir_device, "remote")
        except debconf.DebconfError:
            pass

        try:
            ir_device["transmitter"] = transmitter
            install_misc.set_debconf(target, 'lirc/transmitter', ir_device["transmitter"])
            ir_device["modules"] = ""
            ir_device["driver"] = ""
            ir_device["device"] = ""
            ir_device["lircd_conf"] = ""
            lirchandler.set_device(ir_device, "transmitter")
        except debconf.DebconfError:
            pass

        lirchandler.write_hardware_conf(target + '/etc/lirc/hardware.conf')

        try:
            install_misc.reconfigure(target, 'lirc')
        finally:
            osextras.unlink_force('/target/sbin/udevd')
            install_misc.chrex(target,'dpkg-divert', '--package', 'ubiquity', '--rename',
                       '--quiet', '--remove', '/sbin/udevd')
        install_misc.chroot_cleanup(target)

        #configure lircrc
        home = '/target/home/' + progress.get('passwd/username')
        os.putenv('HOME',home)
        if not os.path.isdir(home):
            os.makedirs(home)

        # Redirect stdin from /dev/null and stdout to stderr to avoid them
        # interfering with our debconf protocol stream.
        saved_stdin = os.dup(0)
        try:
            null = os.open('/dev/null', os.O_RDONLY)
            os.dup2(null, 0)
            os.close(null)
        except OSError:
            pass
        saved_stdout = os.dup(1)
        os.dup2(2, 1)

        lirchandler.create_lircrc(os.path.join(target,"etc/lirc/lircd.conf"),False)

        # Put back stdin and stdout.
        os.dup2(saved_stdin, 0)
        os.close(saved_stdin)
        os.dup2(saved_stdout, 1)
        os.close(saved_stdout)

        return InstallPlugin.install(self, target, progress, *args, **kwargs)