| 1 |
#!/usr/bin/python |
|---|
| 2 |
# |
|---|
| 3 |
# Copyright (C) 2005-2008 by Pieter Palmers |
|---|
| 4 |
# 2007-2009 by Arnold Krille |
|---|
| 5 |
# |
|---|
| 6 |
# This file is part of FFADO |
|---|
| 7 |
# FFADO = Free Firewire (pro-)audio drivers for linux |
|---|
| 8 |
# |
|---|
| 9 |
# FFADO is based upon FreeBoB. |
|---|
| 10 |
# |
|---|
| 11 |
# This program is free software: you can redistribute it and/or modify |
|---|
| 12 |
# it under the terms of the GNU General Public License as published by |
|---|
| 13 |
# the Free Software Foundation, either version 3 of the License, or |
|---|
| 14 |
# (at your option) any later version. |
|---|
| 15 |
# |
|---|
| 16 |
# This program is distributed in the hope that it will be useful, |
|---|
| 17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 19 |
# GNU General Public License for more details. |
|---|
| 20 |
# |
|---|
| 21 |
# You should have received a copy of the GNU General Public License |
|---|
| 22 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 23 |
# |
|---|
| 24 |
|
|---|
| 25 |
import os |
|---|
| 26 |
|
|---|
| 27 |
from ffado.config import * |
|---|
| 28 |
|
|---|
| 29 |
import subprocess |
|---|
| 30 |
|
|---|
| 31 |
from PyQt4.QtCore import SIGNAL, SLOT, QObject, QTimer, Qt |
|---|
| 32 |
from PyQt4.QtGui import * |
|---|
| 33 |
|
|---|
| 34 |
from ffado.dbus_util import * |
|---|
| 35 |
|
|---|
| 36 |
from ffado.panelmanager import PanelManager |
|---|
| 37 |
|
|---|
| 38 |
from ffado.logginghandler import * |
|---|
| 39 |
|
|---|
| 40 |
"""Just a small helper to ask the retry-question without a blocking messagebox""" |
|---|
| 41 |
class StartDialog(QWidget): |
|---|
| 42 |
def __init__(self, parent): |
|---|
| 43 |
QWidget.__init__(self, parent) |
|---|
| 44 |
self.setObjectName("Restart Dialog") |
|---|
| 45 |
self.label = QLabel("<qt>Somehow the connection to the dbus-service of FFADO couldn't be established.<p>\nShall we take another try?</qt>",self) |
|---|
| 46 |
self.button = QPushButton("Retry", self) |
|---|
| 47 |
self.layout = QGridLayout(self) |
|---|
| 48 |
self.layout.setContentsMargins( 50, 10, 50, 10 ) |
|---|
| 49 |
self.layout.addWidget(self.label, 0, 0, Qt.AlignHCenter|Qt.AlignBottom) |
|---|
| 50 |
self.layout.addWidget(self.button, 1, 0, Qt.AlignHCenter|Qt.AlignTop) |
|---|
| 51 |
|
|---|
| 52 |
class FFADOWindow(QMainWindow): |
|---|
| 53 |
def __init__(self, parent): |
|---|
| 54 |
QMainWindow.__init__(self, parent) |
|---|
| 55 |
|
|---|
| 56 |
self.textlogger = QTextLogger(self) |
|---|
| 57 |
dock = QDockWidget("Log Messages",self) |
|---|
| 58 |
dock.setWidget(self.textlogger.textedit) |
|---|
| 59 |
logging.getLogger('').addHandler(self.textlogger) |
|---|
| 60 |
self.addDockWidget(Qt.BottomDockWidgetArea, dock) |
|---|
| 61 |
|
|---|
| 62 |
self.statuslogger = QStatusLogger(self, self.statusBar(), 20) |
|---|
| 63 |
logging.getLogger('').addHandler(self.statuslogger) |
|---|
| 64 |
|
|---|
| 65 |
self.manager = PanelManager(self) |
|---|
| 66 |
self.connect(self.manager, SIGNAL("connectionLost"), self.connectToDBUS) |
|---|
| 67 |
|
|---|
| 68 |
filemenu = self.menuBar().addMenu("File") |
|---|
| 69 |
quitaction = QAction("Quit", self) |
|---|
| 70 |
quitaction.setShortcut(self.tr("Ctrl+q")) |
|---|
| 71 |
self.connect(quitaction, SIGNAL("triggered()"), self, SLOT("close()")) |
|---|
| 72 |
filemenu.addAction(quitaction) |
|---|
| 73 |
|
|---|
| 74 |
editmenu = self.menuBar().addMenu("Edit") |
|---|
| 75 |
self.updateaction = QAction("Update Mixer Panels", self) |
|---|
| 76 |
self.updateaction.setEnabled(False) |
|---|
| 77 |
self.connect(self.updateaction, SIGNAL("triggered()"), self.manager.updatePanels) |
|---|
| 78 |
editmenu.addAction(self.updateaction) |
|---|
| 79 |
|
|---|
| 80 |
helpmenu = self.menuBar().addMenu( "Help" ) |
|---|
| 81 |
aboutaction = QAction( "About FFADO", self ) |
|---|
| 82 |
self.connect( aboutaction, SIGNAL( "triggered()" ), self.aboutFFADO ) |
|---|
| 83 |
helpmenu.addAction( aboutaction ) |
|---|
| 84 |
aboutqtaction = QAction( "About Qt", self ) |
|---|
| 85 |
self.connect( aboutqtaction, SIGNAL( "triggered()" ), qApp, SLOT( "aboutQt()" ) ) |
|---|
| 86 |
helpmenu.addAction( aboutqtaction ) |
|---|
| 87 |
|
|---|
| 88 |
log.info( "Starting up" ) |
|---|
| 89 |
|
|---|
| 90 |
QTimer.singleShot( 1, self.tryStartDBUSServer ) |
|---|
| 91 |
|
|---|
| 92 |
def __del__(self): |
|---|
| 93 |
log.info("__del__") |
|---|
| 94 |
del self.manager |
|---|
| 95 |
log.info("__del__ finished") |
|---|
| 96 |
|
|---|
| 97 |
def closeEvent(self, event): |
|---|
| 98 |
log.info("closeEvent()") |
|---|
| 99 |
event.accept() |
|---|
| 100 |
|
|---|
| 101 |
def connectToDBUS(self): |
|---|
| 102 |
log.info("connectToDBUS") |
|---|
| 103 |
try: |
|---|
| 104 |
self.setupDeviceManager() |
|---|
| 105 |
except dbus.DBusException, ex: |
|---|
| 106 |
log.error("Could not communicate with the FFADO DBus service...") |
|---|
| 107 |
if not hasattr(self,"retry"): |
|---|
| 108 |
self.retry = StartDialog(self) |
|---|
| 109 |
self.connect(self.retry.button, SIGNAL("clicked()"), self.tryStartDBUSServer) |
|---|
| 110 |
if hasattr(self, "retry"): |
|---|
| 111 |
self.manager.setParent(None) |
|---|
| 112 |
self.setCentralWidget(self.retry) |
|---|
| 113 |
self.retry.setEnabled(True) |
|---|
| 114 |
|
|---|
| 115 |
def tryStartDBUSServer(self): |
|---|
| 116 |
try: |
|---|
| 117 |
self.setupDeviceManager() |
|---|
| 118 |
except dbus.DBusException, ex: |
|---|
| 119 |
if hasattr(self, "retry"): |
|---|
| 120 |
self.retry.setEnabled(False) |
|---|
| 121 |
subprocess.Popen(['ffado-dbus-server', '-v3']).pid |
|---|
| 122 |
QTimer.singleShot(5000, self.connectToDBUS) |
|---|
| 123 |
|
|---|
| 124 |
def setupDeviceManager(self): |
|---|
| 125 |
devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH) |
|---|
| 126 |
self.manager.setManager(devmgr) |
|---|
| 127 |
if hasattr(self, "retry"): |
|---|
| 128 |
self.retry.setParent(None) |
|---|
| 129 |
self.setCentralWidget(self.manager) |
|---|
| 130 |
self.updateaction.setEnabled(True) |
|---|
| 131 |
|
|---|
| 132 |
def aboutFFADO(self): |
|---|
| 133 |
QMessageBox.about( self, "About FFADO", """ |
|---|
| 134 |
<h1>ffado.org</h1> |
|---|
| 135 |
|
|---|
| 136 |
<p>FFADO is the new approach to have firewire audio on linux.</p> |
|---|
| 137 |
|
|---|
| 138 |
<p>© 2006-2008 by the FFADO developers<br />ffado is licensed under the GPLv3, for the full license text see <a href="http://www.gnu.org/licenses/">www.gnu.org/licenses</a> or the LICENSE.* files shipped with ffado.</p> |
|---|
| 139 |
|
|---|
| 140 |
<p>FFADO developers are:<ul> |
|---|
| 141 |
<li>Pieter Palmers |
|---|
| 142 |
<li>Daniel Wagner |
|---|
| 143 |
<li>Jonathan Woithe |
|---|
| 144 |
<li>Arnold Krille |
|---|
| 145 |
</ul> |
|---|
| 146 |
""" ) |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
def ffadomain(args): |
|---|
| 150 |
#set up logging |
|---|
| 151 |
import logging |
|---|
| 152 |
logging.basicConfig( datefmt="%H:%M:%S", format="%(asctime)s %(name)-16s %(levelname)-8s %(message)s" ) |
|---|
| 153 |
|
|---|
| 154 |
if DEBUG: |
|---|
| 155 |
debug_level = logging.DEBUG |
|---|
| 156 |
else: |
|---|
| 157 |
debug_level = logging.INFO |
|---|
| 158 |
|
|---|
| 159 |
# main loggers: |
|---|
| 160 |
logging.getLogger('main').setLevel(debug_level) |
|---|
| 161 |
logging.getLogger('dbus').setLevel(debug_level) |
|---|
| 162 |
logging.getLogger('registration').setLevel(debug_level) |
|---|
| 163 |
logging.getLogger('panelmanager').setLevel(debug_level) |
|---|
| 164 |
logging.getLogger('configparser').setLevel(logging.INFO) |
|---|
| 165 |
|
|---|
| 166 |
# widgets: |
|---|
| 167 |
logging.getLogger('matrixmixer').setLevel(debug_level) |
|---|
| 168 |
logging.getLogger('crossbarrouter').setLevel(debug_level) |
|---|
| 169 |
|
|---|
| 170 |
# mixers: |
|---|
| 171 |
logging.getLogger('audiofire').setLevel(debug_level) |
|---|
| 172 |
logging.getLogger('bridgeco').setLevel(debug_level) |
|---|
| 173 |
logging.getLogger('edirolfa101').setLevel(debug_level) |
|---|
| 174 |
logging.getLogger('edirolfa66').setLevel(debug_level) |
|---|
| 175 |
logging.getLogger('motu').setLevel(debug_level) |
|---|
| 176 |
logging.getLogger('rme').setLevel(debug_level) |
|---|
| 177 |
logging.getLogger('phase24').setLevel(debug_level) |
|---|
| 178 |
logging.getLogger('phase88').setLevel(debug_level) |
|---|
| 179 |
logging.getLogger('quatafire').setLevel(debug_level) |
|---|
| 180 |
logging.getLogger('saffirebase').setLevel(debug_level) |
|---|
| 181 |
logging.getLogger('saffire').setLevel(debug_level) |
|---|
| 182 |
logging.getLogger('saffirepro').setLevel(debug_level) |
|---|
| 183 |
|
|---|
| 184 |
logging.getLogger('global').setLevel(debug_level) |
|---|
| 185 |
|
|---|
| 186 |
log = logging.getLogger('main') |
|---|
| 187 |
|
|---|
| 188 |
app = QApplication(args) |
|---|
| 189 |
app.setWindowIcon( QIcon( SHAREDIR + "/icons/hi64-apps-ffado.png" ) ) |
|---|
| 190 |
|
|---|
| 191 |
app.setOrganizationName("FFADO") |
|---|
| 192 |
app.setOrganizationDomain("ffado.org") |
|---|
| 193 |
app.setApplicationName("ffado-mixer") |
|---|
| 194 |
|
|---|
| 195 |
mainwindow = FFADOWindow(None) |
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
# rock & roll |
|---|
| 199 |
mainwindow.show() |
|---|
| 200 |
return app.exec_() |
|---|
| 201 |
|
|---|
| 202 |
if __name__ == "__main__": |
|---|
| 203 |
import sys |
|---|
| 204 |
sys.exit(ffadomain(sys.argv)) |
|---|
| 205 |
|
|---|
| 206 |
# |
|---|
| 207 |
# vim: ts=4 sw=4 et |
|---|