~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmix/kmixctrl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * kmixctrl - kmix volume save/restore utility
 
3
 *
 
4
 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Library General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Library General Public
 
17
 * License along with this program; if not, write to the Free
 
18
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
 */
 
20
 
 
21
#include <kapp.h>
 
22
#include <kcmdlineargs.h>
 
23
#include <kaboutdata.h>
 
24
#include <klocale.h>
 
25
#include <kglobal.h>
 
26
#include <kstddirs.h>
 
27
#include <kconfig.h>
 
28
#include <kdebug.h>
 
29
#include <qlist.h>
 
30
 
 
31
#include "mixer.h"
 
32
#include "version.h"
 
33
 
 
34
static const char *description =
 
35
I18N_NOOP("kmixctrl - kmix volume save/restore utility");
 
36
 
 
37
static KCmdLineOptions options[] =
 
38
{
 
39
   { "s", 0, 0 },
 
40
   { "save", I18N_NOOP("Save current volumes as default"), 0 },
 
41
   { "r", 0, 0 },
 
42
   { "restore", I18N_NOOP("Restore default volumes"), 0 },
 
43
   { 0, 0, 0 }
 
44
   // INSERT YOUR COMMANDLINE OPTIONS HERE
 
45
};
 
46
 
 
47
int main(int argc, char *argv[])
 
48
{
 
49
   KLocale::setMainCatalogue("kmix");
 
50
   KAboutData aboutData( "kmixctrl", I18N_NOOP("KMixCtrl"),
 
51
                         APP_VERSION, description, KAboutData::License_GPL,
 
52
                         "(c) 2000 by Stefan Schimanski");
 
53
 
 
54
   aboutData.addAuthor("Stefan Schimanski", 0, "1Stein@gmx.de");
 
55
 
 
56
   KCmdLineArgs::init( argc, argv, &aboutData );
 
57
   KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
 
58
   KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
59
   KApplication app;
 
60
 
 
61
   // get maximum values
 
62
   KConfig *config= new KConfig("kcmkmixrc", false);
 
63
   config->setGroup("Misc");
 
64
   int maxCards = config->readNumEntry( "maxCards", 2 );
 
65
   int maxDevices = config->readNumEntry( "maxDevices", 2 );
 
66
   delete config;
 
67
 
 
68
   // create mixers
 
69
   QList<Mixer> mixers;
 
70
   int drvNum = Mixer::getDriverNum();
 
71
   for( int drv=0; drv<drvNum && mixers.count()==0; drv++ )
 
72
       for ( int dev=0; dev<maxDevices; dev++ )
 
73
           for ( int card=0; card<maxCards; card++ ) {
 
74
 
 
75
               Mixer *mixer = Mixer::getMixer( drv, dev, card );
 
76
               int mixerError = mixer->grab();
 
77
               if ( mixerError!=0 )
 
78
                   delete mixer;
 
79
               else
 
80
                   mixers.append( mixer );
 
81
           }
 
82
 
 
83
   // load volumes
 
84
   if ( args->isSet("restore") )
 
85
   {
 
86
      for (Mixer *mixer=mixers.first(); mixer!=0; mixer=mixers.next())
 
87
         mixer->volumeLoad( KGlobal::config() );
 
88
   }
 
89
 
 
90
   // save volumes
 
91
   if ( args->isSet("save") )
 
92
   {
 
93
      for (Mixer *mixer=mixers.first(); mixer!=0; mixer=mixers.next())
 
94
         mixer->volumeSave( KGlobal::config() );
 
95
   }
 
96
}