Index: /trunk/libffado/config.h.in =================================================================== --- /trunk/libffado/config.h.in (revision 1046) +++ /trunk/libffado/config.h.in (revision 1060) @@ -27,5 +27,5 @@ #define FFADO_API_VERSION $FFADO_API_VERSION -#define CACHEDIR "~/.ffado" +#define CACHEDIR "$CONFIGDIR" #define BINDIR "$BINDIR" Index: /trunk/libffado/SConstruct =================================================================== --- /trunk/libffado/SConstruct (revision 1052) +++ /trunk/libffado/SConstruct (revision 1060) @@ -411,4 +411,8 @@ env['LIBVERSION'] = "1.0.0" +env['CONFIGDIR'] = "~/.ffado" + +env['REGISTRATION_URL'] = "http://ffado.org/deviceregistration/register.php?action=register" + # # To have the top_srcdir as the doxygen-script is used from auto* Index: /trunk/libffado/support/mixer/ffado_regdialog.py =================================================================== --- /trunk/libffado/support/mixer/ffado_regdialog.py (revision 1060) +++ /trunk/libffado/support/mixer/ffado_regdialog.py (revision 1060) @@ -0,0 +1,60 @@ +# +# Copyright (C) 2005-2008 by Pieter Palmers +# +# This file is part of FFADO +# FFADO = Free Firewire (pro-)audio drivers for linux +# +# FFADO is based upon FreeBoB. +# +# This program 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) version 3 of the License. +# +# This program 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 this program. If not, see . +# + +from qt import * +from ffado_regdialogui import * + +class ffadoRegDialog(ffadoRegDialogUI): + def __init__(self, devtext, vendormodel, + guid, version, email="(optional)", + parent = None,name = None,modal = 1,fl = 0): + ffadoRegDialogUI.__init__(self,parent,name,modal,fl) + + self.txtDevice.setText(devtext) + self.txtVendorModel.setText(vendormodel) + self.txtGUID.setText("%016X" % guid) + self.txtVersion.setText(version) + self.txtEmail.setText(email) + self.choice = "nosend" + + def buttonPressed(self): + sender = self.sender() + if sender == self.btnSend: + print "user chose to send" + self.choice = "send" + elif sender == self.btnNoSend: + print "user chose not to send" + self.choice = "nosend" + elif sender == self.btnNeverSend: + print "user chose to never send" + self.choice = "neversend" + self.close() + + def getEmail(self): + return self.txtEmail.text() + + def init(self): + print "Init ffado reg window" + self.choice = "nosend" + QObject.connect(self.btnSend,SIGNAL('clicked()'),self.buttonPressed) + QObject.connect(self.btnNoSend,SIGNAL('clicked()'),self.buttonPressed) + QObject.connect(self.btnNeverSend,SIGNAL('clicked()'),self.buttonPressed) Index: /trunk/libffado/support/mixer/mixer_dummy.py =================================================================== --- /trunk/libffado/support/mixer/mixer_dummy.py (revision 1060) +++ /trunk/libffado/support/mixer/mixer_dummy.py (revision 1060) @@ -0,0 +1,34 @@ +# +# Copyright (C) 2005-2008 by Pieter Palmers +# +# This file is part of FFADO +# FFADO = Free Firewire (pro-)audio drivers for linux +# +# FFADO is based upon FreeBoB. +# +# This program 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) version 3 of the License. +# +# This program 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 this program. If not, see . +# + +from qt import * +from mixer_dummyui import * + +class DummyMixer(DummyMixerUI): + def __init__(self,parent = None,name = None,modal = 0,fl = 0): + DummyMixerUI.__init__(self,parent,name,modal,fl) + + def init(self): + print "Init Dummy mixer window" + + def initValues(self): + pass Index: /trunk/libffado/support/mixer/SConscript =================================================================== --- /trunk/libffado/support/mixer/SConscript (revision 994) +++ /trunk/libffado/support/mixer/SConscript (revision 1060) @@ -32,5 +32,9 @@ e['MIXERAPPS'] = [ 'phase24', 'phase88', 'saffirepro', 'saffire', 'saffirele', 'af2', 'bcoaudio5', 'edirolfa66', - 'mackie_generic', 'quatafire', 'motu', 'generic' ] + 'mackie_generic', 'quatafire', 'motu', + 'generic', 'dummy' + ] + e['OTHERAPPS'] = ['ffado_regdialog'] + # # For the ffadomixer.in @@ -46,5 +50,16 @@ e.Install( "$pythondir", app+".py" ) + for app in e['OTHERAPPS']: + if os.path.exists( app+".ui" ): + e.PyUIC( source=app+".ui", target=app+"ui.py" ) + e.Install( "$pythondir", app+"ui.py" ) + e.Install( "$pythondir", app+".py" ) + + e.ScanReplace( "ffadomixer_config.py.in" ) + e.Depends( "ffadomixer_config.py", "#/SConstruct" ) + e.Install( "$pythondir", "ffadomixer_config.py" ) + e.ScanReplace( "ffadomixer.in" ) + e.Depends( "ffadomixer", "#/SConstruct" ) e.Depends( "ffadomixer", "SConscript" ) e.Install( "$bindir", "ffadomixer" ) Index: /trunk/libffado/support/mixer/ffadomixer.in =================================================================== --- /trunk/libffado/support/mixer/ffadomixer.in (revision 994) +++ /trunk/libffado/support/mixer/ffadomixer.in (revision 1060) @@ -24,6 +24,9 @@ import sys + # Add the path of the installed ffado-mixer-modules sys.path.append( "$PYTHONDIR" ) + +from ffadomixer_config import FFADO_VERSION import os @@ -31,4 +34,6 @@ import dbus from qt import * + +from ffado_registration import * from mixer_phase88 import * @@ -43,4 +48,5 @@ from mixer_quatafire import * from mixer_motu import * +from mixer_dummy import * from mixer_generic import * @@ -238,5 +244,5 @@ except dbus.DBusException, ex: time.sleep( 1 ) - + nbDevices=devmgr.getNbDevices() @@ -251,6 +257,14 @@ unitVersion = cfgrom.getUnitVersion() GUID = cfgrom.getGUID() - print " Found (%s, %X, %X) %s %s" % (str(GUID), vendorId, modelId, cfgrom.getVendorName(), cfgrom.getModelName()) - + vendorName = cfgrom.getVendorName() + modelName = cfgrom.getModelName() + print " Found (%s, %X, %X) %s %s" % (str(GUID), vendorId, modelId, vendorName, modelName) + + # check whether this has already been registered at ffado.org + reg = ffado_registration(FFADO_VERSION, int(GUID, 16), + vendorId, modelId, + vendorName, modelName) + reg.check_for_registration() + thisdev=(vendorId, modelId); # The MOTU devices use unitVersion to differentiate models. For the @@ -260,4 +274,5 @@ thisdev=(vendorId, 0x00000000) + found_panel = False for dev in SupportedDevices: if dev[0] == thisdev: @@ -275,14 +290,27 @@ exec('forms.append('+mixerapp+'())') forms[idx].hw = ControlInterface(server, basepath+'/DeviceManager/'+path) + forms[idx].configrom = cfgrom forms[idx].clockselect = ClockSelectInterface(server, basepath+'/DeviceManager/'+path) forms[idx].initValues() forms[idx].show() - - if not forms and nbDevices > 0: + found_panel = True + + if not found_panel: + forms.append( DummyMixer( ) ) + forms[idx].hw = ControlInterface(server, basepath+'/DeviceManager/'+path) + forms[idx].configrom = cfgrom + forms[idx].clockselect = ClockSelectInterface(server, basepath+'/DeviceManager/'+path) + forms[idx].initValues() + forms[idx].show() + + # note: the generic mixer is disabled for now... + use_generic = False # !!! HACK !!! + if nbDevices > 0 and use_generic: forms.append( GenericMixer( devmgr.bus, server ) ) - forms[0].show() + forms[-1].show() if forms: - app.setMainWidget(forms[0]) + # not setting this makes that the app doesn't quit when the first window is closed + #app.setMainWidget(forms[0]) QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()")) Index: /trunk/libffado/support/mixer/ffado_registration.py =================================================================== --- /trunk/libffado/support/mixer/ffado_registration.py (revision 1060) +++ /trunk/libffado/support/mixer/ffado_registration.py (revision 1060) @@ -0,0 +1,149 @@ +import urllib +import ConfigParser, os + +from ffadomixer_config import REGISTER_URL, INI_FILE_PATH + +from qt import * +from ffado_regdialog import * + +class ffado_registration(): + def __init__(self, ffado_version, + guid, + vendor_id, + model_id, + vendor_string, + model_string): + self.ffado_version = ffado_version + #import pdb;pdb.set_trace() + self.guid = guid + self.vendor_id = vendor_id + self.model_id = model_id + self.vendor_string = vendor_string + self.model_string = model_string + + self.config_filename = os.path.expanduser(INI_FILE_PATH) + self.parser = ConfigParser.SafeConfigParser() + self.parser.read(self.config_filename) + self.section_name = "%s:%X" % (ffado_version, guid) + self.email = "(optional)" + if self.parser.has_section("history") \ + and self.parser.has_option("history", "email"): + self.email = self.parser.get("history", "email") + + def register_ffado_usage(self): + post_vals = {} + post_vals['guid'] = self.guid + post_vals['vendor_id'] = self.vendor_id + post_vals['model_id'] = self.model_id + post_vals['vendor_string'] = self.vendor_string + post_vals['model_string'] = self.model_string + post_vals['ffado_version'] = self.ffado_version + post_vals['email'] = self.email + + try: + response = urllib.urlopen(REGISTER_URL, + urllib.urlencode(post_vals)) + except: + print "failed, network error" + return (-1, "Network Error") + + lines = response.readlines() + + ok = False + errline = "Bad response from server" + for i in range(len(lines)): + if lines[i][0:10] == "RESULT: OK": + ok = True + elif lines[i][0:12] == "RESULT: FAIL": + ok = False + if len(lines)>i+1: + errline = lines[i+1] + if not ok: + print "registration failed" + print " " + errline + return (-2, errline) + else: + return (0, "") + + def check_for(self, what): + if not self.parser.has_section(self.section_name): + return False + if not self.parser.has_option(self.section_name, what): + return False + return self.parser.getboolean(self.section_name, what) + + def check_if_already_registered(self): + return self.check_for("registered") + + def check_for_ignore(self): + return self.check_for("ignore") + + def mark(self, what, value): + if not self.parser.has_section(self.section_name): + self.parser.add_section(self.section_name) + self.parser.set(self.section_name, what, str(value)) + + def mark_version_registered(self): + self.mark("registered", True) + + def mark_ignore_version(self): + self.mark("ignore", True) + + def remember_email(self, email): + if not self.parser.has_section("history"): + self.parser.add_section("history") + self.parser.set("history", "email", str(email)) + + def check_for_registration(self): + + if self.check_for_ignore(): + print "user requested to ignore registration" + else: + if self.check_if_already_registered(): + print "version/GUID combo already registered" + else: + print "show dialog..." + devtext = "%s %s" % (self.vendor_string, + self.model_string) + vendormodel = "0x%X / 0x%X" % (self.vendor_id, + self.model_id) + dlg = ffadoRegDialog(devtext, vendormodel, + self.guid, self.ffado_version, + self.email) + dlg.exec_loop() + + #import pdb;pdb.set_trace() + if dlg.choice == "neversend": + self.mark_ignore_version() + elif dlg.choice == "send": + self.email = dlg.getEmail().latin1() + self.remember_email(self.email) + + retval = self.register_ffado_usage() + msg = QMessageBox() + if retval[0] == 0: + print "registration successful" + devinfomsg = "

Device: %s
Vendor/Model Id: %s
Device GUID: %016X
FFADO Version: %s
E-Mail: %s

" % \ + (devtext, vendormodel, self.guid, self.ffado_version, self.email) + tmp = msg.question( msg, "Registration Successful", + "Thank you." + + "

The registration of the following information was successful:

" + + devinfomsg + + "

For this device you won't be asked to register again until you upgrade to a new version of FFADO.

", + QMessageBox.Ok ) + self.mark_version_registered() + else: + print "error: " + retval[1] + tmp = msg.question( msg, "Registration Failed", + "The registration at ffado.org failed." + + "

Error message:

" + retval[1] + + "

Try again next time?

", + QMessageBox.Yes, QMessageBox.No ) + if tmp == 4: + self.mark_ignore_version() + elif dlg.choice == "nosend": + pass + # write the updated config + f = open(self.config_filename, "w+") + self.parser.write(f) + f.close() Index: /trunk/libffado/support/mixer/ffadomixer_config.py.in =================================================================== --- /trunk/libffado/support/mixer/ffadomixer_config.py.in (revision 1060) +++ /trunk/libffado/support/mixer/ffadomixer_config.py.in (revision 1060) @@ -0,0 +1,4 @@ +REGISTER_URL = '$REGISTRATION_URL' +INI_FILE_PATH = "$CONFIGDIR/registration.ini" + +FFADO_VERSION="$VERSION-$REVISION" Index: /trunk/libffado/support/mixer/ffado_regdialog.ui =================================================================== --- /trunk/libffado/support/mixer/ffado_regdialog.ui (revision 1060) +++ /trunk/libffado/support/mixer/ffado_regdialog.ui (revision 1060) @@ -0,0 +1,273 @@ + +ffadoRegDialogUI + + + ffadoRegDialogUI + + + + 0 + 0 + 468 + 565 + + + + FFADO Usage Statistics + + + + regText + + + + 10 + 10 + 450 + 290 + + + + You are running this version of FFADO for the first time with this device. + +In order to collect decent usage statistics we would like to send some information about your system to ffado.org. We need usage statistics to convince vendors that Linux does matter. + +This information is intended only for usage monitoring. The only personal information sent is an optional email address. The source code for the registration process can be found in "ffado_registration.py". + + + WordBreak|AlignTop + + + + + btnSend + + + + 10 + 520 + 121 + 31 + + + + Send + + + true + + + + + btnNoSend + + + + 140 + 520 + 160 + 31 + + + + Don't send now + + + + + btnNeverSend + + + + 310 + 520 + 150 + 31 + + + + Never send + + + + + grpDeviceInfo + + + + 10 + 301 + 451 + 200 + + + + Information being sent + + + + textLabel2 + + + + 10 + 159 + 121 + 30 + + + + Your E-Mail: + + + + + txtEmail + + + + 140 + 160 + 300 + 31 + + + + (optional) + + + + + txtVersion + + + + 160 + 119 + 280 + 30 + + + + 0x1234546 + + + + + textLabel2_2_3 + + + + 10 + 120 + 140 + 30 + + + + FFADO Version: + + + + + textLabel2_2_2 + + + + 30 + 90 + 90 + 30 + + + + GUID: + + + + + textLabel2_2_2_2 + + + + 30 + 60 + 140 + 30 + + + + Vendor/Model Id: + + + + + textLabel2_2 + + + + 10 + 30 + 100 + 30 + + + + Device Info: + + + + + txtDevice + + + + 120 + 30 + 320 + 30 + + + + FFADO TEST + + + + + txtGUID + + + + 190 + 89 + 250 + 30 + + + + 0x1234546 + + + + + txtVendorModel + + + + 190 + 59 + 250 + 30 + + + + 0x1234546 + + + + + + init() + + + Index: /trunk/libffado/support/mixer/mixer_dummy.ui =================================================================== --- /trunk/libffado/support/mixer/mixer_dummy.ui (revision 1060) +++ /trunk/libffado/support/mixer/mixer_dummy.ui (revision 1060) @@ -0,0 +1,85 @@ + +DummyMixerUI +Copyright (C) 2005-2008 by Pieter Palmers + + This file is part of FFADO + FFADO = Free Firewire (pro-)audio drivers for linux + + FFADO is based upon FreeBoB. + + This program 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) version 3 of the License. + + This program 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. + + + + DummyMixerUI + + + + 0 + 0 + 220 + 221 + + + + Dummy Panel + + + + textLabel1 + + + + 10 + 10 + 210 + 170 + + + + This panel is merely a placeholder for devices that don't have a mixer panel yet. + + + WordBreak|AlignVCenter + + + + + pushButton1 + + + + 90 + 180 + 121 + 31 + + + + Close + + + + + + pushButton1 + clicked() + DummyMixerUI + close() + + + + setFB2(int) + setFB1(int) + init() + + +