summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp21
-rw-r--r--noncore/applets/pcmcia/configdialog.h2
-rw-r--r--noncore/applets/pcmcia/configdialogbase.ui76
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp12
4 files changed, 91 insertions, 20 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp
index c08926e..e7c97c1 100644
--- a/noncore/applets/pcmcia/configdialog.cpp
+++ b/noncore/applets/pcmcia/configdialog.cpp
@@ -1,73 +1,86 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "configdialog.h" 30#include "configdialog.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/oconfig.h> 33#include <opie2/oconfig.h>
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35using namespace Opie::Core; 35using namespace Opie::Core;
36 36
37/* QT */ 37/* QT */
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qdir.h>
40#include <qlabel.h>
39 41
40ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) 42ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent )
41 :ConfigDialogBase( parent, "pcmcia config dialog", true ) 43 :ConfigDialogBase( parent, "pcmcia config dialog", true )
42{ 44{
43 setCaption( tr( "Configure %1" ).arg( cardname ) ); 45 //setCaption( tr( "Configure %1" ).arg( cardname ) );
44 46 textCardName->setText( cardname );
47
45 OConfig cfg( "PCMCIA" ); 48 OConfig cfg( "PCMCIA" );
46 cfg.setGroup( "Global" ); 49 cfg.setGroup( "Global" );
47 int nCards = cfg.readNumEntry( "nCards", 0 ); 50 int nCards = cfg.readNumEntry( "nCards", 0 );
48 QString insert; 51 QString insert;
49 52
50 for ( int i = 0; i < nCards; ++i ) 53 for ( int i = 0; i < nCards; ++i )
51 { 54 {
52 QString cardSection = QString( "Card_%1" ).arg( i ); 55 QString cardSection = QString( "Card_%1" ).arg( i );
53 cfg.setGroup( cardSection ); 56 cfg.setGroup( cardSection );
54 QString name = cfg.readEntry( "name" ); 57 QString name = cfg.readEntry( "name" );
55 odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl; 58 odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl;
56 if ( cardname == name ) 59 if ( cardname == name )
57 { 60 {
58 insert = cfg.readEntry( "insert" ); 61 insert = cfg.readEntry( "insert" );
59 break; 62 break;
60 } 63 }
61 } 64 }
62 odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl; 65 odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl;
63 66
64 if ( !insert.isEmpty() ) 67 if ( !insert.isEmpty() )
65 { 68 {
66 for ( int i; i < cbAction->count(); ++i ) 69 for ( int i; i < cbAction->count(); ++i )
67 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); 70 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i );
68 } 71 }
72
73 // parse possible device and class names out of /etc/pcmcia/*.conf
74 QStringList deviceNames;
75 QStringList classNames;
76
77 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" );
78
79 for ( int i = 0; i < pcmciaconfdir.count(); ++i )
80 odebug << "found conf file '" << pcmciaconfdir[i] << "'" << oendl;
81
69} 82}
70 83
71ConfigDialog::~ConfigDialog() 84ConfigDialog::~ConfigDialog()
72{ 85{
73} 86}
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h
index 12500c4..f79d7a6 100644
--- a/noncore/applets/pcmcia/configdialog.h
+++ b/noncore/applets/pcmcia/configdialog.h
@@ -1,44 +1,44 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#ifndef CONFIGDIALOG_H 30#ifndef CONFIGDIALOG_H
31#define CONFIGDIALOG_H 31#define CONFIGDIALOG_H
32 32
33#include "configdialogbase.h" 33#include "configdialogbase.h"
34 34
35class ConfigDialog : public ConfigDialogBase 35class ConfigDialog : public ConfigDialogBase
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 39
40 ConfigDialog( const QString& cardname, QWidget* parent ); 40 ConfigDialog( const QString& cardname, QWidget* parent );
41 ~ConfigDialog(); 41 ~ConfigDialog();
42}; 42};
43 43
44#endif 44#endif
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui
index d8dd983..a9682c5 100644
--- a/noncore/applets/pcmcia/configdialogbase.ui
+++ b/noncore/applets/pcmcia/configdialogbase.ui
@@ -1,92 +1,150 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>ConfigDialogBase</class> 2<class>ConfigDialogBase</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>ConfigDialogBase</cstring> 7 <cstring>ConfigDialogBase</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>214</width> 14 <width>234</width>
15 <height>44</height> 15 <height>130</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Configure PCMCIA/CF Card</string> 20 <string>Configure PCMCIA/CF Card</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <grid> 28 <grid>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>11</number> 31 <number>7</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>6</number> 35 <number>4</number>
36 </property> 36 </property>
37 <widget row="0" column="2" > 37 <widget row="2" column="2" >
38 <class>QLabel</class> 38 <class>QLabel</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
41 <cstring>TextLabel3</cstring> 41 <cstring>TextLabel3</cstring>
42 </property> 42 </property>
43 <property stdset="1"> 43 <property stdset="1">
44 <name>text</name> 44 <name>text</name>
45 <string>card</string> 45 <string>card</string>
46 </property> 46 </property>
47 </widget> 47 </widget>
48 <widget row="0" column="1" > 48 <widget row="2" column="0" >
49 <class>QLabel</class>
50 <property stdset="1">
51 <name>name</name>
52 <cstring>TextLabel2</cstring>
53 </property>
54 <property stdset="1">
55 <name>text</name>
56 <string>Upon insertion,</string>
57 </property>
58 </widget>
59 <widget row="2" column="1" >
49 <class>QComboBox</class> 60 <class>QComboBox</class>
50 <item> 61 <item>
51 <property> 62 <property>
52 <name>text</name> 63 <name>text</name>
53 <string>suspend</string> 64 <string>suspend</string>
54 </property> 65 </property>
55 </item> 66 </item>
56 <item> 67 <item>
57 <property> 68 <property>
58 <name>text</name> 69 <name>text</name>
59 <string>activate</string> 70 <string>activate</string>
60 </property> 71 </property>
61 </item> 72 </item>
62 <item> 73 <item>
63 <property> 74 <property>
64 <name>text</name> 75 <name>text</name>
65 <string>eject</string> 76 <string>eject</string>
66 </property> 77 </property>
67 </item> 78 </item>
68 <item> 79 <item>
69 <property> 80 <property>
70 <name>text</name> 81 <name>text</name>
71 <string>prompt for</string> 82 <string>prompt for</string>
72 </property> 83 </property>
73 </item> 84 </item>
74 <property stdset="1"> 85 <property stdset="1">
75 <name>name</name> 86 <name>name</name>
76 <cstring>cbAction</cstring> 87 <cstring>cbAction</cstring>
77 </property> 88 </property>
78 </widget> 89 </widget>
79 <widget row="0" column="0" > 90 <widget row="3" column="1" rowspan="1" colspan="2" >
91 <class>QComboBox</class>
92 <property stdset="1">
93 <name>name</name>
94 <cstring>cbBindTo</cstring>
95 </property>
96 </widget>
97 <widget row="1" column="0" rowspan="1" colspan="3" >
98 <class>Line</class>
99 <property stdset="1">
100 <name>name</name>
101 <cstring>Line1</cstring>
102 </property>
103 <property stdset="1">
104 <name>orientation</name>
105 <enum>Horizontal</enum>
106 </property>
107 </widget>
108 <widget row="3" column="0" >
80 <class>QLabel</class> 109 <class>QLabel</class>
81 <property stdset="1"> 110 <property stdset="1">
82 <name>name</name> 111 <name>name</name>
83 <cstring>TextLabel2</cstring> 112 <cstring>textBindTo</cstring>
84 </property> 113 </property>
85 <property stdset="1"> 114 <property stdset="1">
86 <name>text</name> 115 <name>text</name>
87 <string>Upon insertion,</string> 116 <string>Bind to:</string>
117 </property>
118 </widget>
119 <widget row="4" column="0" >
120 <class>QLabel</class>
121 <property stdset="1">
122 <name>name</name>
123 <cstring>textClassName</cstring>
124 </property>
125 <property stdset="1">
126 <name>text</name>
127 <string>Classname:</string>
128 </property>
129 </widget>
130 <widget row="4" column="1" rowspan="1" colspan="2" >
131 <class>QComboBox</class>
132 <property stdset="1">
133 <name>name</name>
134 <cstring>cbClassName</cstring>
135 </property>
136 </widget>
137 <widget row="0" column="0" rowspan="1" colspan="3" >
138 <class>QLabel</class>
139 <property stdset="1">
140 <name>name</name>
141 <cstring>textCardName</cstring>
142 </property>
143 <property stdset="1">
144 <name>text</name>
145 <string>CardName</string>
88 </property> 146 </property>
89 </widget> 147 </widget>
90 </grid> 148 </grid>
91</widget> 149</widget>
92</UI> 150</UI>
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 4fcc189..6c18e86 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -1,281 +1,281 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "pcmcia.h" 30#include "pcmcia.h"
31#include "configdialog.h" 31#include "configdialog.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/odevice.h> 35#include <opie2/odevice.h>
36#include <opie2/oconfig.h> 36#include <opie2/oconfig.h>
37#include <opie2/oprocess.h> 37#include <opie2/oprocess.h>
38#include <opie2/opcmciasystem.h> 38#include <opie2/opcmciasystem.h>
39#include <opie2/oresource.h> 39#include <opie2/oresource.h>
40#include <opie2/otaskbarapplet.h> 40#include <opie2/otaskbarapplet.h>
41#include <qpe/applnk.h> 41#include <qpe/applnk.h>
42#include <qpe/resource.h> 42#include <qpe/resource.h>
43using namespace Opie::Core; 43using namespace Opie::Core;
44using namespace Opie::Ui; 44using namespace Opie::Ui;
45 45
46/* QT */ 46/* QT */
47#include <qcopchannel_qws.h> 47#include <qcopchannel_qws.h>
48#include <qpainter.h> 48#include <qpainter.h>
49#include <qfile.h> 49#include <qfile.h>
50#include <qtextstream.h> 50#include <qtextstream.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qsound.h> 52#include <qsound.h>
53#include <qtimer.h> 53#include <qtimer.h>
54 54
55/* STD */ 55/* STD */
56#include <stdio.h> 56#include <stdio.h>
57#include <unistd.h> 57#include <unistd.h>
58#include <stdlib.h> 58#include <stdlib.h>
59#include <string.h> 59#include <string.h>
60#include <fcntl.h> 60#include <fcntl.h>
61#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 61#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
62#include <sys/vfs.h> 62#include <sys/vfs.h>
63#include <mntent.h> 63#include <mntent.h>
64#endif 64#endif
65 65
66PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) 66PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent )
67{ 67{
68 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); 68 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this );
69 connect( pcmciaChannel, 69 connect( pcmciaChannel,
70 SIGNAL( received(const QCString&,const QByteArray&) ), this, 70 SIGNAL( received(const QCString&,const QByteArray&) ), this,
71 SLOT( cardMessage(const QCString&,const QByteArray&) ) ); 71 SLOT( cardMessage(const QCString&,const QByteArray&) ) );
72 72
73 setFocusPolicy( NoFocus ); 73 setFocusPolicy( NoFocus );
74 setFixedWidth ( AppLnk::smallIconSize() ); 74 setFixedWidth ( AppLnk::smallIconSize() );
75 setFixedHeight ( AppLnk::smallIconSize() ); 75 setFixedHeight ( AppLnk::smallIconSize() );
76 pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); 76 pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon );
77} 77}
78 78
79 79
80PcmciaManager::~PcmciaManager() 80PcmciaManager::~PcmciaManager()
81{ 81{
82} 82}
83 83
84 84
85void PcmciaManager::popUp( QString message, QString icon ) 85void PcmciaManager::popUp( QString message, QString icon )
86{ 86{
87 if ( !popupMenu ) { 87 if ( !popupMenu ) {
88 popupMenu = new QPopupMenu( this ); 88 popupMenu = new QPopupMenu( this );
89 } 89 }
90 90
91 popupMenu->clear(); 91 popupMenu->clear();
92 if ( icon.isEmpty() ) { 92 if ( icon.isEmpty() ) {
93 popupMenu->insertItem( message, 0 ); 93 popupMenu->insertItem( message, 0 );
94 } else { 94 } else {
95 popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), 95 popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ),
96 message, 0 ); 96 message, 0 );
97 } 97 }
98 98
99 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 99 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
100 QSize s = popupMenu->sizeHint(); 100 QSize s = popupMenu->sizeHint();
101 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), 101 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
102 p.y() - s.height() ), 0 ); 102 p.y() - s.height() ), 0 );
103 103
104 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); 104 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
105} 105}
106 106
107 107
108void PcmciaManager::popupTimeout() 108void PcmciaManager::popupTimeout()
109{ 109{
110 popupMenu->hide(); 110 popupMenu->hide();
111} 111}
112 112
113enum { EJECT, INSERT, SUSPEND, RESUME, CONFIGURE }; 113enum { EJECT, INSERT, SUSPEND, RESUME, CONFIGURE };
114 114
115void PcmciaManager::mousePressEvent( QMouseEvent* ) 115void PcmciaManager::mousePressEvent( QMouseEvent* )
116{ 116{
117 QPopupMenu* menu = new QPopupMenu( this ); 117 QPopupMenu* menu = new QPopupMenu( this );
118 QStringList cmd; 118 QStringList cmd;
119 bool execute = true; 119 bool execute = true;
120 120
121 OPcmciaSystem* sys = OPcmciaSystem::instance(); 121 OPcmciaSystem* sys = OPcmciaSystem::instance();
122 OPcmciaSystem::CardIterator it = sys->iterator(); 122 OPcmciaSystem::CardIterator it = sys->iterator();
123 if ( !sys->count() ) return; 123 if ( !sys->count() ) return;
124 124
125 int i = 0; 125 int i = 0;
126 while ( it.current() ) 126 while ( it.current() )
127 { 127 {
128 QPopupMenu* submenu = new QPopupMenu( menu ); 128 QPopupMenu* submenu = new QPopupMenu( menu );
129 submenu->insertItem( "&Eject", EJECT+i*100 ); 129 submenu->insertItem( "&Eject", EJECT+i*100 );
130 submenu->insertItem( "&Insert", INSERT+i*100 ); 130 submenu->insertItem( "&Insert", INSERT+i*100 );
131 submenu->insertItem( "&Suspend", SUSPEND+i*100 ); 131 submenu->insertItem( "&Suspend", SUSPEND+i*100 );
132 submenu->insertItem( "&Resume", RESUME+i*100 ); 132 submenu->insertItem( "&Resume", RESUME+i*100 );
133 submenu->insertItem( "&Configure", CONFIGURE+i*100 ); 133 submenu->insertItem( "&Configure", CONFIGURE+i*100 );
134 134
135 submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); 135 submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() );
136 submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); 136 submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() );
137 submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); 137 submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() );
138 submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); 138 submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() );
139 submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() ); 139 submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() );
140 140
141 connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); 141 connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) );
142 menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); 142 menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 );
143 ++it; 143 ++it;
144 } 144 }
145 145
146 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 146 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
147 QSize s = menu->sizeHint(); 147 QSize s = menu->sizeHint();
148 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); 148 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 );
149 qDebug( "pcmcia: menu result = %d", opt ); 149 qDebug( "pcmcia: menu result = %d", opt );
150 delete menu; 150 delete menu;
151} 151}
152 152
153 153
154void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) 154void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
155{ 155{
156 odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; 156 odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl;
157 if ( msg != "stabChanged()" ) return; 157 if ( msg != "stabChanged()" ) return;
158 158
159 /* check if a previously unknown card has been inserted */ 159 /* check if a previously unknown card has been inserted */
160 OPcmciaSystem::instance()->synchronize(); 160 OPcmciaSystem::instance()->synchronize();
161 161
162 if ( !OPcmciaSystem::instance()->cardCount() ) return; 162 if ( !OPcmciaSystem::instance()->cardCount() ) return;
163 163
164 OConfig cfg( "PCMCIA" ); 164 OConfig cfg( "PCMCIA" );
165 cfg.setGroup( "Global" ); 165 cfg.setGroup( "Global" );
166 int nCards = cfg.readNumEntry( "nCards", 0 ); 166 int nCards = cfg.readNumEntry( "nCards", 0 );
167 167
168 OPcmciaSystem* sys = OPcmciaSystem::instance(); 168 OPcmciaSystem* sys = OPcmciaSystem::instance();
169 OPcmciaSystem::CardIterator it = sys->iterator(); 169 OPcmciaSystem::CardIterator it = sys->iterator();
170 170
171 bool newCard = true; 171 bool newCard = true;
172 OPcmciaSocket* theCard = 0; 172 OPcmciaSocket* theCard = 0;
173 173
174 while ( it.current() && newCard ) 174 while ( it.current() && newCard )
175 { 175 {
176 if ( it.current()->isEmpty() ) 176 if ( it.current()->isEmpty() )
177 { 177 {
178 odebug << "skipping empty card in socket " << it.current()->number() << oendl; 178 odebug << "skipping empty card in socket " << it.current()->number() << oendl;
179 ++it; 179 ++it;
180 continue; 180 continue;
181 } 181 }
182 else 182 else
183 { 183 {
184 OPcmciaSocket* theCard = it.current(); 184 OPcmciaSocket* theCard = it.current();
185 QString cardName = theCard->identity(); 185 QString cardName = theCard->identity();
186 for ( int i = 0; i < nCards; ++i ) 186 for ( int i = 0; i < nCards; ++i )
187 { 187 {
188 QString cardSection = QString( "Card_%1" ).arg( i ); 188 QString cardSection = QString( "Card_%1" ).arg( i );
189 cfg.setGroup( cardSection ); 189 cfg.setGroup( cardSection );
190 QString name = cfg.readEntry( "name" ); 190 QString name = cfg.readEntry( "name" );
191 odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; 191 odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
192 if ( cardName == name ) 192 if ( cardName == name )
193 { 193 {
194 newCard = false; 194 newCard = false;
195 break; 195 break;
196 } 196 }
197 } 197 }
198 if ( !newCard ) ++it; else break; 198 if ( !newCard ) ++it; else break;
199 } 199 }
200 } 200 }
201 if ( newCard ) 201 if ( newCard )
202 { 202 {
203 odebug << "pcmcia: new card detected" << oendl; 203 odebug << "pcmcia: new card detected" << oendl;
204 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); 204 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
205 cfg.writeEntry( "name", theCard->identity() ); 205 cfg.writeEntry( "name", theCard->identity() );
206 cfg.writeEntry( "insert", "suspend" ); 206 cfg.writeEntry( "insert", "suspend" );
207 cfg.setGroup( "Global" ); 207 cfg.setGroup( "Global" );
208 cfg.writeEntry( "nCards", nCards+1 ); 208 cfg.writeEntry( "nCards", nCards+1 );
209 cfg.write(); 209 cfg.write();
210 210
211 int result = QMessageBox::information( qApp->desktop(), 211 int result = QMessageBox::information( qApp->desktop(),
212 tr( "PCMCIA/CF Subsystem" ), 212 tr( "PCMCIA/CF Subsystem" ),
213 tr( "You have inserted a new card:\n%1\nDo you want to configure?" ).arg( theCard->identity() ), 213 tr( "You have inserted a new card:\n%1\nDo you want to configure?" ).arg( theCard->identity() ),
214 tr( "Yes" ), tr( "No" ), 0, 0, 1 ); 214 tr( "Yes" ), tr( "No" ), 0, 0, 1 );
215 odebug << "result = " << result << oendl; 215 odebug << "result = " << result << oendl;
216 if ( result == 0 ) 216 if ( result == 0 )
217 { 217 {
218 configure( theCard ); 218 configure( theCard );
219 } 219 }
220 else 220 else
221 { 221 {
222 odebug << "pcmcia: user doesn't want to configure " << theCard->identity() << " now." << oendl; 222 odebug << "pcmcia: user doesn't want to configure " << theCard->identity() << " now." << oendl;
223 } 223 }
224 } 224 }
225 else 225 else
226 { 226 {
227 odebug << "pcmcia: card has been previously inserted" << oendl; 227 odebug << "pcmcia: card has been previously inserted" << oendl;
228 } 228 }
229 repaint( true ); 229 repaint( true );
230} 230}
231 231
232 232
233void PcmciaManager::paintEvent( QPaintEvent * ) 233void PcmciaManager::paintEvent( QPaintEvent * )
234{ 234{
235 QPainter p( this ); 235 QPainter p( this );
236 odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; 236 odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl;
237 237
238 if ( OPcmciaSystem::instance()->cardCount() ) 238 if ( OPcmciaSystem::instance()->cardCount() )
239 { 239 {
240 p.drawPixmap( 0, 0, pm ); 240 p.drawPixmap( 0, 0, pm );
241 show(); 241 show();
242 } 242 }
243 else 243 else
244 { 244 {
245 hide(); 245 hide();
246 } 246 }
247} 247}
248 248
249int PcmciaManager::position() 249int PcmciaManager::position()
250{ 250{
251 return 7; 251 return 7;
252} 252}
253 253
254void PcmciaManager::execCommand( const QStringList &strList ) 254void PcmciaManager::execCommand( const QStringList &strList )
255{ 255{
256} 256}
257 257
258void PcmciaManager::userCardAction( int action ) 258void PcmciaManager::userCardAction( int action )
259{ 259{
260 odebug << "user action requested. action = " << action << oendl; 260 odebug << "user action requested. action = " << action << oendl;
261 261
262 int socket = action / 100; 262 int socket = action / 100;
263 int what = action % 100; 263 int what = action % 100;
264 264
265 switch ( what ) 265 switch ( what )
266 { 266 {
267 case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); break; 267 case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); break;
268 default: odebug << "not yet implemented"; 268 default: odebug << "not yet implemented";
269 } 269 }
270} 270}
271 271
272void PcmciaManager::configure( OPcmciaSocket* card ) 272void PcmciaManager::configure( OPcmciaSocket* card )
273{ 273{
274 ConfigDialog dialog( card->identity(), qApp->desktop() ); 274 ConfigDialog dialog( card->identity(), qApp->desktop() );
275 int configresult = dialog.exec(); 275 int configresult = dialog.exec();
276 odebug << "pcmcia: configresult = " << configresult << oendl; 276 odebug << "pcmcia: configresult = " << configresult << oendl;
277} 277}
278 278
279 279
280EXPORT_OPIE_APPLET_v1( PcmciaManager ) 280EXPORT_OPIE_APPLET_v1( PcmciaManager )
281 281