author | ar <ar> | 2004-05-31 13:04:55 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-31 13:04:55 (UTC) |
commit | 27b09fe4f930b96e82cea9fb0eb1a9b87f7ec062 (patch) (unidiff) | |
tree | 5b850ee6ad8b8a48b6c49f4a6ce10e75caf234e5 | |
parent | 5bd7c2eee656e8f30635921f15770bd4a43da9e6 (diff) | |
download | opie-27b09fe4f930b96e82cea9fb0eb1a9b87f7ec062.zip opie-27b09fe4f930b96e82cea9fb0eb1a9b87f7ec062.tar.gz opie-27b09fe4f930b96e82cea9fb0eb1a9b87f7ec062.tar.bz2 |
- convert qDebug to odebug
-rw-r--r-- | noncore/apps/opie-reader/CExpander.h | 21 | ||||
-rw-r--r-- | noncore/games/zlines/linesboard.h | 12 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 42 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/tabmanager/tablistview.h | 24 |
6 files changed, 53 insertions, 48 deletions
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index 9fae245..553069c 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h | |||
@@ -1,151 +1,158 @@ | |||
1 | #ifndef __CExpander_h | 1 | #ifndef __CExpander_h |
2 | #define __CExpander_h | 2 | #define __CExpander_h |
3 | 3 | ||
4 | #ifndef _WINDOWS | ||
5 | #include <unistd.h> | ||
6 | #endif | ||
7 | #include <stdio.h> | ||
8 | #include <time.h> | ||
9 | #include <qmessagebox.h> | ||
10 | #include "useqpe.h" | 4 | #include "useqpe.h" |
11 | #include "config.h" | 5 | #include "config.h" |
12 | #include "StyleConsts.h" | 6 | #include "StyleConsts.h" |
13 | #include "Markups.h" | 7 | #include "Markups.h" |
14 | #include "names.h" | 8 | #include "names.h" |
15 | #include "linktype.h" | 9 | #include "linktype.h" |
16 | 10 | ||
11 | /* OPIE */ | ||
12 | #include <opie2/odebug.h> | ||
13 | |||
14 | /* QT */ | ||
15 | #include <qmessagebox.h> | ||
16 | |||
17 | /* STD */ | ||
18 | #ifndef _WINDOWS | ||
19 | #include <unistd.h> | ||
20 | #endif | ||
21 | #include <stdio.h> | ||
22 | #include <time.h> | ||
23 | |||
17 | class QImage; | 24 | class QImage; |
18 | class Bkmk; | 25 | class Bkmk; |
19 | 26 | ||
20 | template<class T> | 27 | template<class T> |
21 | class CList; | 28 | class CList; |
22 | 29 | ||
23 | class CCharacterSource | 30 | class CCharacterSource |
24 | { | 31 | { |
25 | public: | 32 | public: |
26 | virtual void getch(tchar&, CStyle&) = 0; | 33 | virtual void getch(tchar&, CStyle&) = 0; |
27 | virtual linkType hyperlink(unsigned int n, QString&) = 0; | 34 | virtual linkType hyperlink(unsigned int n, QString&) = 0; |
28 | }; | 35 | }; |
29 | 36 | ||
30 | class CExpander | 37 | class CExpander |
31 | { | 38 | { |
32 | protected: | 39 | protected: |
33 | size_t m_homepos; | 40 | size_t m_homepos; |
34 | bool m_continuous; | 41 | bool m_continuous; |
35 | char* fname; | 42 | char* fname; |
36 | bool bSuspended; | 43 | bool bSuspended; |
37 | size_t suspos; | 44 | size_t suspos; |
38 | time_t sustime; | 45 | time_t sustime; |
39 | int m_scrWidth; | 46 | int m_scrWidth; |
40 | unsigned long m_currentstart, m_currentend; | 47 | unsigned long m_currentstart, m_currentend; |
41 | public: | 48 | public: |
42 | #ifdef USEQPE | 49 | #ifdef USEQPE |
43 | virtual void suspend() = 0; | 50 | virtual void suspend() = 0; |
44 | virtual void unsuspend() = 0; | 51 | virtual void unsuspend() = 0; |
45 | #endif | 52 | #endif |
46 | size_t getHome() { return m_homepos; } | 53 | size_t getHome() { return m_homepos; } |
47 | CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {}; | 54 | CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {}; |
48 | virtual ~CExpander() { if (fname != NULL) delete [] fname; }; | 55 | virtual ~CExpander() { if (fname != NULL) delete [] fname; }; |
49 | int openfile(const char *src) | 56 | int openfile(const char *src) |
50 | { | 57 | { |
51 | bSuspended = false; | 58 | bSuspended = false; |
52 | fname = strdup(src); | 59 | fname = strdup(src); |
53 | return OpenFile(src); | 60 | return OpenFile(src); |
54 | } | 61 | } |
55 | virtual int OpenFile(const char *src) = 0; | 62 | virtual int OpenFile(const char *src) = 0; |
56 | virtual unsigned int locate() = 0; | 63 | virtual unsigned int locate() = 0; |
57 | virtual void locate(unsigned int n) = 0; | 64 | virtual void locate(unsigned int n) = 0; |
58 | virtual bool hasrandomaccess() = 0; | 65 | virtual bool hasrandomaccess() = 0; |
59 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; | 66 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; |
60 | virtual CList<Bkmk>* getbkmklist() { return NULL; } | 67 | virtual CList<Bkmk>* getbkmklist() { return NULL; } |
61 | virtual void getch(tchar& ch, CStyle& sty) | 68 | virtual void getch(tchar& ch, CStyle& sty) |
62 | { | 69 | { |
63 | int ich = getch(); | 70 | int ich = getch(); |
64 | ch = (ich == EOF) ? UEOF : ich; | 71 | ch = (ich == EOF) ? UEOF : ich; |
65 | sty.unset(); | 72 | sty.unset(); |
66 | } | 73 | } |
67 | virtual int getch() = 0; | 74 | virtual int getch() = 0; |
68 | virtual linkType hyperlink(unsigned int n, QString& wrd) | 75 | virtual linkType hyperlink(unsigned int n, QString& wrd) |
69 | { | 76 | { |
70 | locate(n); | 77 | locate(n); |
71 | return eLink; | 78 | return eLink; |
72 | } | 79 | } |
73 | virtual MarkupType PreferredMarkup() = 0; | 80 | virtual MarkupType PreferredMarkup() = 0; |
74 | virtual void saveposn(size_t posn) {} | 81 | virtual void saveposn(size_t posn) {} |
75 | virtual void writeposn(size_t posn) {} | 82 | virtual void writeposn(size_t posn) {} |
76 | virtual bool forward(size_t& loc) { return false; } | 83 | virtual bool forward(size_t& loc) { return false; } |
77 | virtual bool back(size_t& loc) { return false; } | 84 | virtual bool back(size_t& loc) { return false; } |
78 | virtual bool hasnavigation() { return false; } | 85 | virtual bool hasnavigation() { return false; } |
79 | unsigned long startSection() | 86 | unsigned long startSection() |
80 | { | 87 | { |
81 | unsigned long current = locate(); | 88 | unsigned long current = locate(); |
82 | if (m_currentstart > current || current > m_currentend) | 89 | if (m_currentstart > current || current > m_currentend) |
83 | { | 90 | { |
84 | start2endSection(); | 91 | start2endSection(); |
85 | } | 92 | } |
86 | return m_currentstart; | 93 | return m_currentstart; |
87 | } | 94 | } |
88 | unsigned long endSection() | 95 | unsigned long endSection() |
89 | { | 96 | { |
90 | unsigned long current = locate(); | 97 | unsigned long current = locate(); |
91 | if (m_currentstart > current || current > m_currentend) | 98 | if (m_currentstart > current || current > m_currentend) |
92 | { | 99 | { |
93 | start2endSection(); | 100 | start2endSection(); |
94 | } | 101 | } |
95 | return m_currentend; | 102 | return m_currentend; |
96 | } | 103 | } |
97 | virtual void start2endSection() | 104 | virtual void start2endSection() |
98 | { | 105 | { |
99 | m_currentstart = 0; | 106 | m_currentstart = 0; |
100 | unsigned long file; | 107 | unsigned long file; |
101 | sizes(file, m_currentend); | 108 | sizes(file, m_currentend); |
102 | } | 109 | } |
103 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } | 110 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } |
104 | void setContinuous(bool _b) { m_continuous = _b; } | 111 | void setContinuous(bool _b) { m_continuous = _b; } |
105 | #ifdef USEQPE | 112 | #ifdef USEQPE |
106 | virtual void suspend(FILE*& fin) | 113 | virtual void suspend(FILE*& fin) |
107 | { | 114 | { |
108 | bSuspended = true; | 115 | bSuspended = true; |
109 | suspos = ftell(fin); | 116 | suspos = ftell(fin); |
110 | fclose(fin); | 117 | fclose(fin); |
111 | fin = NULL; | 118 | fin = NULL; |
112 | sustime = time(NULL); | 119 | sustime = time(NULL); |
113 | } | 120 | } |
114 | virtual void unsuspend(FILE*& fin) | 121 | virtual void unsuspend(FILE*& fin) |
115 | { | 122 | { |
116 | if (bSuspended) | 123 | if (bSuspended) |
117 | { | 124 | { |
118 | bSuspended = false; | 125 | bSuspended = false; |
119 | int delay = time(NULL) - sustime; | 126 | int delay = time(NULL) - sustime; |
120 | if (delay < 10) sleep(10-delay); | 127 | if (delay < 10) sleep(10-delay); |
121 | fin = fopen(fname, "rb"); | 128 | fin = fopen(fname, "rb"); |
122 | for (int i = 0; fin == NULL && i < 5; i++) | 129 | for (int i = 0; fin == NULL && i < 5; i++) |
123 | { | 130 | { |
124 | sleep(5); | 131 | sleep(5); |
125 | fin = fopen(fname, "rb"); | 132 | fin = fopen(fname, "rb"); |
126 | } | 133 | } |
127 | if (fin == NULL) | 134 | if (fin == NULL) |
128 | { | 135 | { |
129 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 136 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
130 | exit(0); | 137 | exit(0); |
131 | } | 138 | } |
132 | suspos = fseek(fin, suspos, SEEK_SET); | 139 | suspos = fseek(fin, suspos, SEEK_SET); |
133 | } | 140 | } |
134 | } | 141 | } |
135 | #endif | 142 | #endif |
136 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 143 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
137 | { | 144 | { |
138 | len = srclen; | 145 | len = srclen; |
139 | data = new unsigned char[len]; | 146 | data = new unsigned char[len]; |
140 | memcpy(data, src, len); | 147 | memcpy(data, src, len); |
141 | } | 148 | } |
142 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) | 149 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) |
143 | { | 150 | { |
144 | if (srclen != 0) | 151 | if (srclen != 0) |
145 | { | 152 | { |
146 | qDebug("Don't know what to do with non-zero save data"); | 153 | odebug << "Don't know what to do with non-zero save data" << oendl; |
147 | } | 154 | } |
148 | } | 155 | } |
149 | void setwidth(int w) { m_scrWidth = w; } | 156 | void setwidth(int w) { m_scrWidth = w; } |
150 | }; | 157 | }; |
151 | #endif | 158 | #endif |
diff --git a/noncore/games/zlines/linesboard.h b/noncore/games/zlines/linesboard.h index 97697cd..58478ee 100644 --- a/noncore/games/zlines/linesboard.h +++ b/noncore/games/zlines/linesboard.h | |||
@@ -1,103 +1,95 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | linesboard.h - description | 2 | linesboard.h - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Fri May 19 2000 | 4 | begin : Fri May 19 2000 |
5 | copyright : (C) 2000 by Roman Merzlyakov | 5 | copyright : (C) 2000 by Roman Merzlyakov |
6 | email : roman@sbrf.barrt.ru | 6 | email : roman@sbrf.barrt.ru |
7 | copyright : (C) 2000 by Roman Razilov | 7 | copyright : (C) 2000 by Roman Razilov |
8 | email : Roman.Razilov@gmx.de | 8 | email : Roman.Razilov@gmx.de |
9 | ***************************************************************************/ | 9 | ***************************************************************************/ |
10 | 10 | ||
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | #ifndef __linesboard_h | 19 | #ifndef __linesboard_h |
20 | #define __linesboard_h | 20 | #define __linesboard_h |
21 | 21 | ||
22 | #include <qwidget.h> | 22 | #include <qwidget.h> |
23 | #include <qpixmap.h> | 23 | #include <qpixmap.h> |
24 | #include <qtimer.h> | 24 | #include <qtimer.h> |
25 | 25 | ||
26 | #include "field.h" | 26 | #include "field.h" |
27 | //#include "shotcounter.h" | 27 | //#include "shotcounter.h" |
28 | #include "ballpainter.h" | 28 | #include "ballpainter.h" |
29 | 29 | ||
30 | #ifdef Q_WS_QWS | ||
31 | #define debug (void) | ||
32 | #else | ||
33 | #define debug qDebug | ||
34 | #endif | ||
35 | #define fatal qFatal | ||
36 | #define warning qWarning | ||
37 | |||
38 | class LinesBoard : public Field | 30 | class LinesBoard : public Field |
39 | { | 31 | { |
40 | Q_OBJECT | 32 | Q_OBJECT |
41 | public: | 33 | public: |
42 | LinesBoard( BallPainter * abPainter, QWidget* parent=0, const char* name=0 ); | 34 | LinesBoard( BallPainter * abPainter, QWidget* parent=0, const char* name=0 ); |
43 | ~LinesBoard(); | 35 | ~LinesBoard(); |
44 | 36 | ||
45 | int width(); | 37 | int width(); |
46 | int height(); | 38 | int height(); |
47 | int wHint(); | 39 | int wHint(); |
48 | int hHint(); | 40 | int hHint(); |
49 | // void doAfterBalls(); | 41 | // void doAfterBalls(); |
50 | void placeBalls(int nextBalls[BALLSDROP]); | 42 | void placeBalls(int nextBalls[BALLSDROP]); |
51 | void undo(); | 43 | void undo(); |
52 | 44 | ||
53 | signals: | 45 | signals: |
54 | void endTurn(); | 46 | void endTurn(); |
55 | void endGame(); | 47 | void endGame(); |
56 | void eraseLine(int nb); | 48 | void eraseLine(int nb); |
57 | 49 | ||
58 | private: | 50 | private: |
59 | int anim; | 51 | int anim; |
60 | 52 | ||
61 | struct Waypoints { | 53 | struct Waypoints { |
62 | int x,y; | 54 | int x,y; |
63 | } *way; | 55 | } *way; |
64 | int nextBalls[BALLSDROP]; | 56 | int nextBalls[BALLSDROP]; |
65 | 57 | ||
66 | int animmax; | 58 | int animmax; |
67 | 59 | ||
68 | //used for running and animation phase | 60 | //used for running and animation phase |
69 | int painting; | 61 | int painting; |
70 | int animstep; | 62 | int animstep; |
71 | int animdelaycount; | 63 | int animdelaycount; |
72 | int animdelaystart; | 64 | int animdelaystart; |
73 | int direction; | 65 | int direction; |
74 | 66 | ||
75 | 67 | ||
76 | int nextBallToPlace; | 68 | int nextBallToPlace; |
77 | int jumpingCol; | 69 | int jumpingCol; |
78 | int jumpingRow; | 70 | int jumpingRow; |
79 | 71 | ||
80 | 72 | ||
81 | QTimer* timer; | 73 | QTimer* timer; |
82 | // ShotCounter* shCounter; | 74 | // ShotCounter* shCounter; |
83 | BallPainter* bPainter; | 75 | BallPainter* bPainter; |
84 | 76 | ||
85 | void paintEvent( QPaintEvent* ); | 77 | void paintEvent( QPaintEvent* ); |
86 | void mousePressEvent( QMouseEvent* ); | 78 | void mousePressEvent( QMouseEvent* ); |
87 | 79 | ||
88 | void AnimStart(int panim); | 80 | void AnimStart(int panim); |
89 | void AnimNext(); | 81 | void AnimNext(); |
90 | int AnimEnd(); | 82 | int AnimEnd(); |
91 | int getAnim(int x, int y ); // returns if the specifyed cell is animated.. | 83 | int getAnim(int x, int y ); // returns if the specifyed cell is animated.. |
92 | void AnimJump( int col, int row ); | 84 | void AnimJump( int col, int row ); |
93 | 85 | ||
94 | int erase5Balls(); | 86 | int erase5Balls(); |
95 | bool existPath(int ax, int ay, int bx, int by); | 87 | bool existPath(int ax, int ay, int bx, int by); |
96 | void placeBall(); | 88 | void placeBall(); |
97 | 89 | ||
98 | protected slots: | 90 | protected slots: |
99 | void timerSlot(); | 91 | void timerSlot(); |
100 | 92 | ||
101 | }; | 93 | }; |
102 | 94 | ||
103 | #endif | 95 | #endif |
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 203ff91..ba4e11a 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -1,259 +1,258 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | // this file is based on work by trolltech | 34 | // this file is based on work by trolltech |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include "mediaplayerstate.h" | 37 | #include "mediaplayerstate.h" |
38 | 38 | ||
39 | #include <assert.h> | 39 | #include <assert.h> |
40 | 40 | ||
41 | //#define MediaPlayerDebug(x) qDebug x | ||
42 | #define MediaPlayerDebug(x) | 41 | #define MediaPlayerDebug(x) |
43 | 42 | ||
44 | 43 | ||
45 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 44 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
46 | : QObject( parent, name ) { | 45 | : QObject( parent, name ) { |
47 | Config cfg( "OpiePlayer" ); | 46 | Config cfg( "OpiePlayer" ); |
48 | readConfig( cfg ); | 47 | readConfig( cfg ); |
49 | streaming = false; | 48 | streaming = false; |
50 | seekable = true; | 49 | seekable = true; |
51 | } | 50 | } |
52 | 51 | ||
53 | 52 | ||
54 | MediaPlayerState::~MediaPlayerState() { | 53 | MediaPlayerState::~MediaPlayerState() { |
55 | } | 54 | } |
56 | 55 | ||
57 | 56 | ||
58 | void MediaPlayerState::readConfig( Config& cfg ) { | 57 | void MediaPlayerState::readConfig( Config& cfg ) { |
59 | cfg.setGroup("Options"); | 58 | cfg.setGroup("Options"); |
60 | fullscreen = cfg.readBoolEntry( "FullScreen" ); | 59 | fullscreen = cfg.readBoolEntry( "FullScreen" ); |
61 | scaled = cfg.readBoolEntry( "Scaling" ); | 60 | scaled = cfg.readBoolEntry( "Scaling" ); |
62 | looping = cfg.readBoolEntry( "Looping" ); | 61 | looping = cfg.readBoolEntry( "Looping" ); |
63 | shuffled = cfg.readBoolEntry( "Shuffle" ); | 62 | shuffled = cfg.readBoolEntry( "Shuffle" ); |
64 | videoGamma = cfg.readNumEntry( "VideoGamma" ); | 63 | videoGamma = cfg.readNumEntry( "VideoGamma" ); |
65 | playing = FALSE; | 64 | playing = FALSE; |
66 | streaming = FALSE; | 65 | streaming = FALSE; |
67 | paused = FALSE; | 66 | paused = FALSE; |
68 | curPosition = 0; | 67 | curPosition = 0; |
69 | curLength = 0; | 68 | curLength = 0; |
70 | m_displayType = MediaSelection; | 69 | m_displayType = MediaSelection; |
71 | } | 70 | } |
72 | 71 | ||
73 | 72 | ||
74 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 73 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
75 | cfg.setGroup( "Options" ); | 74 | cfg.setGroup( "Options" ); |
76 | cfg.writeEntry( "FullScreen", fullscreen ); | 75 | cfg.writeEntry( "FullScreen", fullscreen ); |
77 | cfg.writeEntry( "Scaling", scaled ); | 76 | cfg.writeEntry( "Scaling", scaled ); |
78 | cfg.writeEntry( "Looping", looping ); | 77 | cfg.writeEntry( "Looping", looping ); |
79 | cfg.writeEntry( "Shuffle", shuffled ); | 78 | cfg.writeEntry( "Shuffle", shuffled ); |
80 | cfg.writeEntry( "VideoGamma", videoGamma ); | 79 | cfg.writeEntry( "VideoGamma", videoGamma ); |
81 | } | 80 | } |
82 | 81 | ||
83 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const | 82 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const |
84 | { | 83 | { |
85 | return m_displayType; | 84 | return m_displayType; |
86 | } | 85 | } |
87 | 86 | ||
88 | // slots | 87 | // slots |
89 | void MediaPlayerState::setIsStreaming( bool b ) { | 88 | void MediaPlayerState::setIsStreaming( bool b ) { |
90 | streaming = b; | 89 | streaming = b; |
91 | } | 90 | } |
92 | 91 | ||
93 | void MediaPlayerState::setIsSeekable( bool b ) { | 92 | void MediaPlayerState::setIsSeekable( bool b ) { |
94 | seekable = b; | 93 | seekable = b; |
95 | emit isSeekableToggled(b); | 94 | emit isSeekableToggled(b); |
96 | } | 95 | } |
97 | 96 | ||
98 | 97 | ||
99 | void MediaPlayerState::setFullscreen( bool b ) { | 98 | void MediaPlayerState::setFullscreen( bool b ) { |
100 | if ( fullscreen == b ) { | 99 | if ( fullscreen == b ) { |
101 | return; | 100 | return; |
102 | } | 101 | } |
103 | fullscreen = b; | 102 | fullscreen = b; |
104 | emit fullscreenToggled(b); | 103 | emit fullscreenToggled(b); |
105 | } | 104 | } |
106 | 105 | ||
107 | 106 | ||
108 | void MediaPlayerState::setBlanked( bool b ) { | 107 | void MediaPlayerState::setBlanked( bool b ) { |
109 | if ( blanked == b ) { | 108 | if ( blanked == b ) { |
110 | return; | 109 | return; |
111 | } | 110 | } |
112 | blanked = b; | 111 | blanked = b; |
113 | emit blankToggled(b); | 112 | emit blankToggled(b); |
114 | } | 113 | } |
115 | 114 | ||
116 | 115 | ||
117 | void MediaPlayerState::setScaled( bool b ) { | 116 | void MediaPlayerState::setScaled( bool b ) { |
118 | if ( scaled == b ) { | 117 | if ( scaled == b ) { |
119 | return; | 118 | return; |
120 | } | 119 | } |
121 | scaled = b; | 120 | scaled = b; |
122 | emit scaledToggled(b); | 121 | emit scaledToggled(b); |
123 | } | 122 | } |
124 | 123 | ||
125 | void MediaPlayerState::setLooping( bool b ) { | 124 | void MediaPlayerState::setLooping( bool b ) { |
126 | if ( looping == b ) { | 125 | if ( looping == b ) { |
127 | return; | 126 | return; |
128 | } | 127 | } |
129 | looping = b; | 128 | looping = b; |
130 | emit loopingToggled(b); | 129 | emit loopingToggled(b); |
131 | } | 130 | } |
132 | 131 | ||
133 | void MediaPlayerState::setShuffled( bool b ) { | 132 | void MediaPlayerState::setShuffled( bool b ) { |
134 | if ( shuffled == b ) { | 133 | if ( shuffled == b ) { |
135 | return; | 134 | return; |
136 | } | 135 | } |
137 | shuffled = b; | 136 | shuffled = b; |
138 | emit shuffledToggled(b); | 137 | emit shuffledToggled(b); |
139 | } | 138 | } |
140 | 139 | ||
141 | void MediaPlayerState::setPaused( bool b ) { | 140 | void MediaPlayerState::setPaused( bool b ) { |
142 | if ( paused == b ) { | 141 | if ( paused == b ) { |
143 | paused = FALSE; | 142 | paused = FALSE; |
144 | emit pausedToggled(FALSE); | 143 | emit pausedToggled(FALSE); |
145 | return; | 144 | return; |
146 | } | 145 | } |
147 | paused = b; | 146 | paused = b; |
148 | emit pausedToggled(b); | 147 | emit pausedToggled(b); |
149 | } | 148 | } |
150 | 149 | ||
151 | void MediaPlayerState::setPlaying( bool b ) { | 150 | void MediaPlayerState::setPlaying( bool b ) { |
152 | if ( playing == b ) { | 151 | if ( playing == b ) { |
153 | return; | 152 | return; |
154 | } | 153 | } |
155 | playing = b; | 154 | playing = b; |
156 | stopped = !b; | 155 | stopped = !b; |
157 | emit playingToggled(b); | 156 | emit playingToggled(b); |
158 | } | 157 | } |
159 | 158 | ||
160 | void MediaPlayerState::setStopped( bool b ) { | 159 | void MediaPlayerState::setStopped( bool b ) { |
161 | if ( stopped == b ) { | 160 | if ( stopped == b ) { |
162 | return; | 161 | return; |
163 | } | 162 | } |
164 | stopped = b; | 163 | stopped = b; |
165 | emit stopToggled(b); | 164 | emit stopToggled(b); |
166 | } | 165 | } |
167 | 166 | ||
168 | void MediaPlayerState::setPosition( long p ) { | 167 | void MediaPlayerState::setPosition( long p ) { |
169 | if ( curPosition == p ) { | 168 | if ( curPosition == p ) { |
170 | return; | 169 | return; |
171 | } | 170 | } |
172 | curPosition = p; | 171 | curPosition = p; |
173 | emit positionChanged(p); | 172 | emit positionChanged(p); |
174 | } | 173 | } |
175 | 174 | ||
176 | void MediaPlayerState::updatePosition( long p ){ | 175 | void MediaPlayerState::updatePosition( long p ){ |
177 | if ( curPosition == p ) { | 176 | if ( curPosition == p ) { |
178 | return; | 177 | return; |
179 | } | 178 | } |
180 | curPosition = p; | 179 | curPosition = p; |
181 | emit positionUpdated(p); | 180 | emit positionUpdated(p); |
182 | } | 181 | } |
183 | 182 | ||
184 | void MediaPlayerState::setVideoGamma( int v ){ | 183 | void MediaPlayerState::setVideoGamma( int v ){ |
185 | if ( videoGamma == v ) { | 184 | if ( videoGamma == v ) { |
186 | return; | 185 | return; |
187 | } | 186 | } |
188 | videoGamma = v; | 187 | videoGamma = v; |
189 | emit videoGammaChanged( v ); | 188 | emit videoGammaChanged( v ); |
190 | } | 189 | } |
191 | 190 | ||
192 | void MediaPlayerState::setLength( long l ) { | 191 | void MediaPlayerState::setLength( long l ) { |
193 | if ( curLength == l ) { | 192 | if ( curLength == l ) { |
194 | return; | 193 | return; |
195 | } | 194 | } |
196 | curLength = l; | 195 | curLength = l; |
197 | emit lengthChanged(l); | 196 | emit lengthChanged(l); |
198 | } | 197 | } |
199 | 198 | ||
200 | void MediaPlayerState::setDisplayType( DisplayType displayType ) | 199 | void MediaPlayerState::setDisplayType( DisplayType displayType ) |
201 | { | 200 | { |
202 | if ( m_displayType == displayType ) | 201 | if ( m_displayType == displayType ) |
203 | return; | 202 | return; |
204 | 203 | ||
205 | m_displayType = displayType; | 204 | m_displayType = displayType; |
206 | emit displayTypeChanged( m_displayType ); | 205 | emit displayTypeChanged( m_displayType ); |
207 | } | 206 | } |
208 | 207 | ||
209 | void MediaPlayerState::setPrev(){ | 208 | void MediaPlayerState::setPrev(){ |
210 | emit prev(); | 209 | emit prev(); |
211 | } | 210 | } |
212 | 211 | ||
213 | void MediaPlayerState::setNext() { | 212 | void MediaPlayerState::setNext() { |
214 | emit next(); | 213 | emit next(); |
215 | } | 214 | } |
216 | 215 | ||
217 | void MediaPlayerState::setList() { | 216 | void MediaPlayerState::setList() { |
218 | setPlaying( FALSE ); | 217 | setPlaying( FALSE ); |
219 | setDisplayType( MediaSelection ); | 218 | setDisplayType( MediaSelection ); |
220 | } | 219 | } |
221 | 220 | ||
222 | void MediaPlayerState::setVideo() { | 221 | void MediaPlayerState::setVideo() { |
223 | setDisplayType( Video ); | 222 | setDisplayType( Video ); |
224 | } | 223 | } |
225 | 224 | ||
226 | void MediaPlayerState::setAudio() { | 225 | void MediaPlayerState::setAudio() { |
227 | setDisplayType( Audio ); | 226 | setDisplayType( Audio ); |
228 | } | 227 | } |
229 | 228 | ||
230 | void MediaPlayerState::toggleFullscreen() { | 229 | void MediaPlayerState::toggleFullscreen() { |
231 | setFullscreen( !fullscreen ); | 230 | setFullscreen( !fullscreen ); |
232 | } | 231 | } |
233 | 232 | ||
234 | void MediaPlayerState::toggleScaled() { | 233 | void MediaPlayerState::toggleScaled() { |
235 | setScaled( !scaled); | 234 | setScaled( !scaled); |
236 | } | 235 | } |
237 | 236 | ||
238 | void MediaPlayerState::toggleLooping() { | 237 | void MediaPlayerState::toggleLooping() { |
239 | setLooping( !looping); | 238 | setLooping( !looping); |
240 | } | 239 | } |
241 | 240 | ||
242 | void MediaPlayerState::toggleShuffled() { | 241 | void MediaPlayerState::toggleShuffled() { |
243 | setShuffled( !shuffled); | 242 | setShuffled( !shuffled); |
244 | } | 243 | } |
245 | 244 | ||
246 | void MediaPlayerState::togglePaused() { | 245 | void MediaPlayerState::togglePaused() { |
247 | setPaused( !paused); | 246 | setPaused( !paused); |
248 | } | 247 | } |
249 | 248 | ||
250 | void MediaPlayerState::togglePlaying() { | 249 | void MediaPlayerState::togglePlaying() { |
251 | setPlaying( !playing); | 250 | setPlaying( !playing); |
252 | } | 251 | } |
253 | 252 | ||
254 | void MediaPlayerState::toggleBlank() { | 253 | void MediaPlayerState::toggleBlank() { |
255 | setBlanked( !blanked); | 254 | setBlanked( !blanked); |
256 | } | 255 | } |
257 | 256 | ||
258 | 257 | ||
259 | 258 | ||
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index 27e2823..bf27b97 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h | |||
@@ -1,161 +1,165 @@ | |||
1 | #ifndef SETTINGS_H | 1 | #ifndef SETTINGS_H |
2 | #define SETTINGS_H | 2 | #define SETTINGS_H |
3 | 3 | ||
4 | #include "maildefines.h" | 4 | #include "maildefines.h" |
5 | 5 | ||
6 | /* OPIE */ | ||
7 | #include <opie2/odebug.h> | ||
8 | |||
9 | /* QT */ | ||
6 | #include <qobject.h> | 10 | #include <qobject.h> |
7 | #include <qlist.h> | 11 | #include <qlist.h> |
8 | 12 | ||
9 | class Account | 13 | class Account |
10 | { | 14 | { |
11 | 15 | ||
12 | public: | 16 | public: |
13 | Account(); | 17 | Account(); |
14 | virtual ~Account() {} | 18 | virtual ~Account() {} |
15 | 19 | ||
16 | void remove(); | 20 | void remove(); |
17 | void setAccountName( QString name ) { accountName = name; } | 21 | void setAccountName( QString name ) { accountName = name; } |
18 | const QString&getAccountName()const{ return accountName; } | 22 | const QString&getAccountName()const{ return accountName; } |
19 | MAILLIB::ATYPE getType()const{ return type; } | 23 | MAILLIB::ATYPE getType()const{ return type; } |
20 | 24 | ||
21 | void setServer(const QString&str){ server = str; } | 25 | void setServer(const QString&str){ server = str; } |
22 | const QString&getServer()const{ return server; } | 26 | const QString&getServer()const{ return server; } |
23 | 27 | ||
24 | void setPort(const QString&str) { port = str; } | 28 | void setPort(const QString&str) { port = str; } |
25 | const QString&getPort()const{ return port; } | 29 | const QString&getPort()const{ return port; } |
26 | 30 | ||
27 | void setUser(const QString&str){ user = str; } | 31 | void setUser(const QString&str){ user = str; } |
28 | const QString&getUser()const{ return user; } | 32 | const QString&getUser()const{ return user; } |
29 | 33 | ||
30 | void setPassword(const QString&str) { password = str; } | 34 | void setPassword(const QString&str) { password = str; } |
31 | const QString&getPassword()const { return password; } | 35 | const QString&getPassword()const { return password; } |
32 | 36 | ||
33 | void setSSL( bool b ) { ssl = b; } | 37 | void setSSL( bool b ) { ssl = b; } |
34 | bool getSSL() { return ssl; } | 38 | bool getSSL() { return ssl; } |
35 | 39 | ||
36 | void setConnectionType( int x ) { connectionType = x; } | 40 | void setConnectionType( int x ) { connectionType = x; } |
37 | int ConnectionType() { return connectionType; } | 41 | int ConnectionType() { return connectionType; } |
38 | 42 | ||
39 | 43 | ||
40 | void setOffline(bool b) {offline = b;} | 44 | void setOffline(bool b) {offline = b;} |
41 | bool getOffline()const{return offline;} | 45 | bool getOffline()const{return offline;} |
42 | 46 | ||
43 | virtual QString getFileName() { return accountName; } | 47 | virtual QString getFileName() { return accountName; } |
44 | virtual void read() { qDebug( "base reading..." ); } | 48 | virtual void read() { odebug << "base reading..." << oendl; } |
45 | virtual void save() { qDebug( "base saving..." ); } | 49 | virtual void save() { odebug << "base saving..." << oendl; } |
46 | 50 | ||
47 | protected: | 51 | protected: |
48 | QString accountName, server, port, user, password; | 52 | QString accountName, server, port, user, password; |
49 | bool ssl; | 53 | bool ssl; |
50 | int connectionType; | 54 | int connectionType; |
51 | bool offline; | 55 | bool offline; |
52 | MAILLIB::ATYPE type; | 56 | MAILLIB::ATYPE type; |
53 | }; | 57 | }; |
54 | 58 | ||
55 | class IMAPaccount : public Account | 59 | class IMAPaccount : public Account |
56 | { | 60 | { |
57 | 61 | ||
58 | public: | 62 | public: |
59 | IMAPaccount(); | 63 | IMAPaccount(); |
60 | IMAPaccount( QString filename ); | 64 | IMAPaccount( QString filename ); |
61 | 65 | ||
62 | static QString getUniqueFileName(); | 66 | static QString getUniqueFileName(); |
63 | 67 | ||
64 | virtual void read(); | 68 | virtual void read(); |
65 | virtual void save(); | 69 | virtual void save(); |
66 | virtual QString getFileName(); | 70 | virtual QString getFileName(); |
67 | 71 | ||
68 | void setPrefix(const QString&str) {prefix=str;} | 72 | void setPrefix(const QString&str) {prefix=str;} |
69 | const QString&getPrefix()const{return prefix;} | 73 | const QString&getPrefix()const{return prefix;} |
70 | 74 | ||
71 | private: | 75 | private: |
72 | QString file,prefix; | 76 | QString file,prefix; |
73 | 77 | ||
74 | }; | 78 | }; |
75 | 79 | ||
76 | class POP3account : public Account | 80 | class POP3account : public Account |
77 | { | 81 | { |
78 | 82 | ||
79 | public: | 83 | public: |
80 | POP3account(); | 84 | POP3account(); |
81 | POP3account( QString filename ); | 85 | POP3account( QString filename ); |
82 | 86 | ||
83 | static QString getUniqueFileName(); | 87 | static QString getUniqueFileName(); |
84 | 88 | ||
85 | virtual void read(); | 89 | virtual void read(); |
86 | virtual void save(); | 90 | virtual void save(); |
87 | virtual QString getFileName(); | 91 | virtual QString getFileName(); |
88 | 92 | ||
89 | private: | 93 | private: |
90 | QString file; | 94 | QString file; |
91 | 95 | ||
92 | }; | 96 | }; |
93 | 97 | ||
94 | class SMTPaccount : public Account | 98 | class SMTPaccount : public Account |
95 | { | 99 | { |
96 | 100 | ||
97 | public: | 101 | public: |
98 | SMTPaccount(); | 102 | SMTPaccount(); |
99 | SMTPaccount( QString filename ); | 103 | SMTPaccount( QString filename ); |
100 | 104 | ||
101 | static QString getUniqueFileName(); | 105 | static QString getUniqueFileName(); |
102 | 106 | ||
103 | virtual void read(); | 107 | virtual void read(); |
104 | virtual void save(); | 108 | virtual void save(); |
105 | virtual QString getFileName(); | 109 | virtual QString getFileName(); |
106 | 110 | ||
107 | void setLogin( bool b ) { login = b; } | 111 | void setLogin( bool b ) { login = b; } |
108 | bool getLogin() { return login; } | 112 | bool getLogin() { return login; } |
109 | 113 | ||
110 | private: | 114 | private: |
111 | QString file, name, mail, org, cc, bcc, reply, signature; | 115 | QString file, name, mail, org, cc, bcc, reply, signature; |
112 | bool useCC, useBCC, useReply, login; | 116 | bool useCC, useBCC, useReply, login; |
113 | 117 | ||
114 | }; | 118 | }; |
115 | 119 | ||
116 | class NNTPaccount : public Account | 120 | class NNTPaccount : public Account |
117 | { | 121 | { |
118 | 122 | ||
119 | public: | 123 | public: |
120 | NNTPaccount(); | 124 | NNTPaccount(); |
121 | NNTPaccount( QString filename ); | 125 | NNTPaccount( QString filename ); |
122 | 126 | ||
123 | static QString getUniqueFileName(); | 127 | static QString getUniqueFileName(); |
124 | 128 | ||
125 | virtual void read(); | 129 | virtual void read(); |
126 | virtual void save(); | 130 | virtual void save(); |
127 | virtual QString getFileName(); | 131 | virtual QString getFileName(); |
128 | 132 | ||
129 | void setLogin( bool b ) { login = b; } | 133 | void setLogin( bool b ) { login = b; } |
130 | bool getLogin() { return login; } | 134 | bool getLogin() { return login; } |
131 | 135 | ||
132 | void setGroups( QStringList list ) { subscribedGroups = list; } | 136 | void setGroups( QStringList list ) { subscribedGroups = list; } |
133 | QStringList getGroups() { return subscribedGroups; } | 137 | QStringList getGroups() { return subscribedGroups; } |
134 | 138 | ||
135 | private: | 139 | private: |
136 | QString file; | 140 | QString file; |
137 | bool login; | 141 | bool login; |
138 | QStringList subscribedGroups; | 142 | QStringList subscribedGroups; |
139 | 143 | ||
140 | }; | 144 | }; |
141 | 145 | ||
142 | class Settings : public QObject | 146 | class Settings : public QObject |
143 | { | 147 | { |
144 | Q_OBJECT | 148 | Q_OBJECT |
145 | 149 | ||
146 | public: | 150 | public: |
147 | Settings(); | 151 | Settings(); |
148 | QList<Account> getAccounts(); | 152 | QList<Account> getAccounts(); |
149 | void addAccount(Account *account); | 153 | void addAccount(Account *account); |
150 | void delAccount(Account *account); | 154 | void delAccount(Account *account); |
151 | void saveAccounts(); | 155 | void saveAccounts(); |
152 | void readAccounts(); | 156 | void readAccounts(); |
153 | static void checkDirectory(); | 157 | static void checkDirectory(); |
154 | 158 | ||
155 | private: | 159 | private: |
156 | void updateAccounts(); | 160 | void updateAccounts(); |
157 | QList<Account> accounts; | 161 | QList<Account> accounts; |
158 | 162 | ||
159 | }; | 163 | }; |
160 | 164 | ||
161 | #endif | 165 | #endif |
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index 3bc7d43..79f015b 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -1,1085 +1,1084 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd Front End for the KDE project | 2 | * kPPP: A pppd Front End for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * This file was added by Harri Porten <porten@tu-harburg.de> | 9 | * This file was added by Harri Porten <porten@tu-harburg.de> |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | /* OPIE */ | 27 | /* OPIE */ |
28 | #include <opie2/odebug.h> | 28 | #include <opie2/odebug.h> |
29 | using namespace Opie::Core; | 29 | using namespace Opie::Core; |
30 | 30 | ||
31 | /* STD */ | 31 | /* STD */ |
32 | #include <errno.h> | 32 | #include <errno.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | #include <fcntl.h> | 35 | #include <fcntl.h> |
36 | #include <signal.h> | 36 | #include <signal.h> |
37 | #include <sys/ioctl.h> | 37 | #include <sys/ioctl.h> |
38 | #include <sys/types.h> | 38 | #include <sys/types.h> |
39 | #include <sys/stat.h> | 39 | #include <sys/stat.h> |
40 | #include <setjmp.h> | 40 | #include <setjmp.h> |
41 | #include <regex.h> | 41 | #include <regex.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <assert.h> | 43 | #include <assert.h> |
44 | #include <string.h> | 44 | #include <string.h> |
45 | 45 | ||
46 | #ifdef HAVE_RESOLV_H | 46 | #ifdef HAVE_RESOLV_H |
47 | # include <arpa/nameser.h> | 47 | # include <arpa/nameser.h> |
48 | # include <resolv.h> | 48 | # include <resolv.h> |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #ifndef _PATH_RESCONF | 51 | #ifndef _PATH_RESCONF |
52 | #define _PATH_RESCONF "/etc/resolv.conf" | 52 | #define _PATH_RESCONF "/etc/resolv.conf" |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #define strlcpy strcpy | 55 | #define strlcpy strcpy |
56 | #include "auth.h" | 56 | #include "auth.h" |
57 | #include "modem.h" | 57 | #include "modem.h" |
58 | #include "pppdata.h" | 58 | #include "pppdata.h" |
59 | #define qError qDebug | ||
60 | 59 | ||
61 | 60 | ||
62 | #define MY_ASSERT(x) if (!(x)) { \ | 61 | #define MY_ASSERT(x) if (!(x)) { \ |
63 | ofatal << "ASSERT: \"" << #x << "\" in " << __FILE__ << " (" << __LINE__ << ")\n" << oendl; \ | 62 | ofatal << "ASSERT: \"" << #x << "\" in " << __FILE__ << " (" << __LINE__ << ")\n" << oendl; \ |
64 | exit(1); } | 63 | exit(1); } |
65 | 64 | ||
66 | 65 | ||
67 | static sigjmp_buf jmp_buffer; | 66 | static sigjmp_buf jmp_buffer; |
68 | 67 | ||
69 | //Modem *Modem::modem = 0; | 68 | //Modem *Modem::modem = 0; |
70 | 69 | ||
71 | 70 | ||
72 | const char* pppdPath() { | 71 | const char* pppdPath() { |
73 | // wasting a few bytes | 72 | // wasting a few bytes |
74 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; | 73 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; |
75 | static char *pppdPath = 0L; | 74 | static char *pppdPath = 0L; |
76 | char *p; | 75 | char *p; |
77 | 76 | ||
78 | if(pppdPath == 0L) { | 77 | if(pppdPath == 0L) { |
79 | const char *c = PPPDSEARCHPATH; | 78 | const char *c = PPPDSEARCHPATH; |
80 | while(*c != '\0') { | 79 | while(*c != '\0') { |
81 | while(*c == ':') | 80 | while(*c == ':') |
82 | c++; | 81 | c++; |
83 | p = buffer; | 82 | p = buffer; |
84 | while(*c != '\0' && *c != ':') | 83 | while(*c != '\0' && *c != ':') |
85 | *p++ = *c++; | 84 | *p++ = *c++; |
86 | *p = '\0'; | 85 | *p = '\0'; |
87 | strcat(p, "/"); | 86 | strcat(p, "/"); |
88 | strcat(p, PPPDNAME); | 87 | strcat(p, PPPDNAME); |
89 | if(access(buffer, F_OK) == 0) | 88 | if(access(buffer, F_OK) == 0) |
90 | return (pppdPath = buffer); | 89 | return (pppdPath = buffer); |
91 | } | 90 | } |
92 | } | 91 | } |
93 | 92 | ||
94 | return pppdPath; | 93 | return pppdPath; |
95 | } | 94 | } |
96 | 95 | ||
97 | 96 | ||
98 | Modem::Modem( PPPData* pd ) | 97 | Modem::Modem( PPPData* pd ) |
99 | { | 98 | { |
100 | _pppdata = pd; | 99 | _pppdata = pd; |
101 | modemfd = -1; | 100 | modemfd = -1; |
102 | _pppdExitStatus = -1; | 101 | _pppdExitStatus = -1; |
103 | pppdPid = -1; | 102 | pppdPid = -1; |
104 | sn = m_modemDebug = 0L; | 103 | sn = m_modemDebug = 0L; |
105 | data_mode = false; | 104 | data_mode = false; |
106 | modem_is_locked = false; | 105 | modem_is_locked = false; |
107 | lockfile[0] = '\0'; | 106 | lockfile[0] = '\0'; |
108 | device = "/dev/modem"; | 107 | device = "/dev/modem"; |
109 | } | 108 | } |
110 | 109 | ||
111 | 110 | ||
112 | Modem::~Modem() | 111 | Modem::~Modem() |
113 | { | 112 | { |
114 | } | 113 | } |
115 | 114 | ||
116 | 115 | ||
117 | speed_t Modem::modemspeed() { | 116 | speed_t Modem::modemspeed() { |
118 | // convert the string modem speed int the gpppdata object to a t_speed type | 117 | // convert the string modem speed int the gpppdata object to a t_speed type |
119 | // to set the modem. The constants here should all be ifdef'd because | 118 | // to set the modem. The constants here should all be ifdef'd because |
120 | // other systems may not have them | 119 | // other systems may not have them |
121 | int i = _pppdata->speed().toInt()/100; | 120 | int i = _pppdata->speed().toInt()/100; |
122 | 121 | ||
123 | switch(i) { | 122 | switch(i) { |
124 | case 24: | 123 | case 24: |
125 | return B2400; | 124 | return B2400; |
126 | break; | 125 | break; |
127 | case 96: | 126 | case 96: |
128 | return B9600; | 127 | return B9600; |
129 | break; | 128 | break; |
130 | case 192: | 129 | case 192: |
131 | return B19200; | 130 | return B19200; |
132 | break; | 131 | break; |
133 | case 384: | 132 | case 384: |
134 | return B38400; | 133 | return B38400; |
135 | break; | 134 | break; |
136 | #ifdef B57600 | 135 | #ifdef B57600 |
137 | case 576: | 136 | case 576: |
138 | return B57600; | 137 | return B57600; |
139 | break; | 138 | break; |
140 | #endif | 139 | #endif |
141 | 140 | ||
142 | #ifdef B115200 | 141 | #ifdef B115200 |
143 | case 1152: | 142 | case 1152: |
144 | return B115200; | 143 | return B115200; |
145 | break; | 144 | break; |
146 | #endif | 145 | #endif |
147 | 146 | ||
148 | #ifdef B230400 | 147 | #ifdef B230400 |
149 | case 2304: | 148 | case 2304: |
150 | return B230400; | 149 | return B230400; |
151 | break; | 150 | break; |
152 | #endif | 151 | #endif |
153 | 152 | ||
154 | #ifdef B460800 | 153 | #ifdef B460800 |
155 | case 4608: | 154 | case 4608: |
156 | return B460800; | 155 | return B460800; |
157 | break; | 156 | break; |
158 | #endif | 157 | #endif |
159 | 158 | ||
160 | default: | 159 | default: |
161 | return B38400; | 160 | return B38400; |
162 | break; | 161 | break; |
163 | } | 162 | } |
164 | } | 163 | } |
165 | 164 | ||
166 | bool Modem::opentty() { | 165 | bool Modem::opentty() { |
167 | // int flags; | 166 | // int flags; |
168 | 167 | ||
169 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 168 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
170 | close(modemfd); | 169 | close(modemfd); |
171 | device = _pppdata->modemDevice(); | 170 | device = _pppdata->modemDevice(); |
172 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 171 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
173 | odebug << "error opening modem device !" << oendl; | 172 | odebug << "error opening modem device !" << oendl; |
174 | errmsg = QObject::tr("Unable to open modem."); | 173 | errmsg = QObject::tr("Unable to open modem."); |
175 | return false; | 174 | return false; |
176 | } | 175 | } |
177 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 176 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
178 | //} | 177 | //} |
179 | 178 | ||
180 | #if 0 | 179 | #if 0 |
181 | if(_pppdata->UseCDLine()) { | 180 | if(_pppdata->UseCDLine()) { |
182 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 181 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
183 | errmsg = QObject::tr("Unable to detect state of CD line."); | 182 | errmsg = QObject::tr("Unable to detect state of CD line."); |
184 | ::close(modemfd); | 183 | ::close(modemfd); |
185 | modemfd = -1; | 184 | modemfd = -1; |
186 | return false; | 185 | return false; |
187 | } | 186 | } |
188 | if ((flags&TIOCM_CD) == 0) { | 187 | if ((flags&TIOCM_CD) == 0) { |
189 | errmsg = QObject::tr("The modem is not ready."); | 188 | errmsg = QObject::tr("The modem is not ready."); |
190 | ::close(modemfd); | 189 | ::close(modemfd); |
191 | modemfd = -1; | 190 | modemfd = -1; |
192 | return false; | 191 | return false; |
193 | } | 192 | } |
194 | } | 193 | } |
195 | #endif | 194 | #endif |
196 | 195 | ||
197 | tcdrain (modemfd); | 196 | tcdrain (modemfd); |
198 | tcflush (modemfd, TCIOFLUSH); | 197 | tcflush (modemfd, TCIOFLUSH); |
199 | 198 | ||
200 | if(tcgetattr(modemfd, &tty) < 0){ | 199 | if(tcgetattr(modemfd, &tty) < 0){ |
201 | // this helps in some cases | 200 | // this helps in some cases |
202 | tcsendbreak(modemfd, 0); | 201 | tcsendbreak(modemfd, 0); |
203 | sleep(1); | 202 | sleep(1); |
204 | if(tcgetattr(modemfd, &tty) < 0){ | 203 | if(tcgetattr(modemfd, &tty) < 0){ |
205 | errmsg = QObject::tr("The modem is busy."); | 204 | errmsg = QObject::tr("The modem is busy."); |
206 | ::close(modemfd); | 205 | ::close(modemfd); |
207 | modemfd = -1; | 206 | modemfd = -1; |
208 | return false; | 207 | return false; |
209 | } | 208 | } |
210 | } | 209 | } |
211 | 210 | ||
212 | memset(&initial_tty,'\0',sizeof(initial_tty)); | 211 | memset(&initial_tty,'\0',sizeof(initial_tty)); |
213 | 212 | ||
214 | initial_tty = tty; | 213 | initial_tty = tty; |
215 | 214 | ||
216 | tty.c_cc[VMIN] = 0; // nonblocking | 215 | tty.c_cc[VMIN] = 0; // nonblocking |
217 | tty.c_cc[VTIME] = 0; | 216 | tty.c_cc[VTIME] = 0; |
218 | tty.c_oflag = 0; | 217 | tty.c_oflag = 0; |
219 | tty.c_lflag = 0; | 218 | tty.c_lflag = 0; |
220 | 219 | ||
221 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); | 220 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); |
222 | tty.c_cflag |= CS8 | CREAD; | 221 | tty.c_cflag |= CS8 | CREAD; |
223 | tty.c_cflag |= CLOCAL; // ignore modem status lines | 222 | tty.c_cflag |= CLOCAL; // ignore modem status lines |
224 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; | 223 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; |
225 | tty.c_lflag &= ~ICANON; // non-canonical mode | 224 | tty.c_lflag &= ~ICANON; // non-canonical mode |
226 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); | 225 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); |
227 | 226 | ||
228 | 227 | ||
229 | if(_pppdata->flowcontrol() != "None") { | 228 | if(_pppdata->flowcontrol() != "None") { |
230 | if(_pppdata->flowcontrol() == "CRTSCTS") { | 229 | if(_pppdata->flowcontrol() == "CRTSCTS") { |
231 | tty.c_cflag |= CRTSCTS; | 230 | tty.c_cflag |= CRTSCTS; |
232 | } | 231 | } |
233 | else { | 232 | else { |
234 | tty.c_iflag |= IXON | IXOFF; | 233 | tty.c_iflag |= IXON | IXOFF; |
235 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ | 234 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ |
236 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ | 235 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ |
237 | } | 236 | } |
238 | } | 237 | } |
239 | else { | 238 | else { |
240 | tty.c_cflag &= ~CRTSCTS; | 239 | tty.c_cflag &= ~CRTSCTS; |
241 | tty.c_iflag &= ~(IXON | IXOFF); | 240 | tty.c_iflag &= ~(IXON | IXOFF); |
242 | } | 241 | } |
243 | 242 | ||
244 | cfsetospeed(&tty, modemspeed()); | 243 | cfsetospeed(&tty, modemspeed()); |
245 | cfsetispeed(&tty, modemspeed()); | 244 | cfsetispeed(&tty, modemspeed()); |
246 | 245 | ||
247 | tcdrain(modemfd); | 246 | tcdrain(modemfd); |
248 | 247 | ||
249 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ | 248 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ |
250 | errmsg = QObject::tr("The modem is busy."); | 249 | errmsg = QObject::tr("The modem is busy."); |
251 | ::close(modemfd); | 250 | ::close(modemfd); |
252 | modemfd=-1; | 251 | modemfd=-1; |
253 | return false; | 252 | return false; |
254 | } | 253 | } |
255 | 254 | ||
256 | errmsg = QObject::tr("Modem Ready."); | 255 | errmsg = QObject::tr("Modem Ready."); |
257 | return true; | 256 | return true; |
258 | } | 257 | } |
259 | 258 | ||
260 | 259 | ||
261 | bool Modem::closetty() { | 260 | bool Modem::closetty() { |
262 | if(modemfd >=0 ) { | 261 | if(modemfd >=0 ) { |
263 | stop(); | 262 | stop(); |
264 | /* discard data not read or transmitted */ | 263 | /* discard data not read or transmitted */ |
265 | tcflush(modemfd, TCIOFLUSH); | 264 | tcflush(modemfd, TCIOFLUSH); |
266 | 265 | ||
267 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ | 266 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ |
268 | errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n"); | 267 | errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n"); |
269 | ::close(modemfd); | 268 | ::close(modemfd); |
270 | modemfd = -1; | 269 | modemfd = -1; |
271 | return false; | 270 | return false; |
272 | } | 271 | } |
273 | ::close(modemfd); | 272 | ::close(modemfd); |
274 | modemfd = -1; | 273 | modemfd = -1; |
275 | } | 274 | } |
276 | 275 | ||
277 | return true; | 276 | return true; |
278 | } | 277 | } |
279 | 278 | ||
280 | 279 | ||
281 | void Modem::readtty(int) { | 280 | void Modem::readtty(int) { |
282 | char buffer[200]; | 281 | char buffer[200]; |
283 | unsigned char c; | 282 | unsigned char c; |
284 | int len; | 283 | int len; |
285 | 284 | ||
286 | // read data in chunks of up to 200 bytes | 285 | // read data in chunks of up to 200 bytes |
287 | if((len = ::read(modemfd, buffer, 200)) > 0) { | 286 | if((len = ::read(modemfd, buffer, 200)) > 0) { |
288 | // split buffer into single characters for further processing | 287 | // split buffer into single characters for further processing |
289 | for(int i = 0; i < len; i++) { | 288 | for(int i = 0; i < len; i++) { |
290 | c = buffer[i] & 0x7F; | 289 | c = buffer[i] & 0x7F; |
291 | emit charWaiting(c); | 290 | emit charWaiting(c); |
292 | } | 291 | } |
293 | } | 292 | } |
294 | } | 293 | } |
295 | 294 | ||
296 | 295 | ||
297 | void Modem::notify(const QObject *receiver, const char *member) { | 296 | void Modem::notify(const QObject *receiver, const char *member) { |
298 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); | 297 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); |
299 | startNotifier(); | 298 | startNotifier(); |
300 | } | 299 | } |
301 | 300 | ||
302 | 301 | ||
303 | void Modem::stop() { | 302 | void Modem::stop() { |
304 | disconnect(SIGNAL(charWaiting(unsigned char))); | 303 | disconnect(SIGNAL(charWaiting(unsigned char))); |
305 | stopNotifier(); | 304 | stopNotifier(); |
306 | } | 305 | } |
307 | 306 | ||
308 | 307 | ||
309 | void Modem::startNotifier() { | 308 | void Modem::startNotifier() { |
310 | if(modemfd >= 0) { | 309 | if(modemfd >= 0) { |
311 | if(sn == 0) { | 310 | if(sn == 0) { |
312 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); | 311 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); |
313 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); | 312 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); |
314 | odebug << "QSocketNotifier started!" << oendl; | 313 | odebug << "QSocketNotifier started!" << oendl; |
315 | } else { | 314 | } else { |
316 | odebug << "QSocketNotifier re-enabled!" << oendl; | 315 | odebug << "QSocketNotifier re-enabled!" << oendl; |
317 | sn->setEnabled(true); | 316 | sn->setEnabled(true); |
318 | } | 317 | } |
319 | } | 318 | } |
320 | } | 319 | } |
321 | 320 | ||
322 | 321 | ||
323 | void Modem::stopNotifier() { | 322 | void Modem::stopNotifier() { |
324 | if(sn != 0) { | 323 | if(sn != 0) { |
325 | sn->setEnabled(false); | 324 | sn->setEnabled(false); |
326 | disconnect(sn); | 325 | disconnect(sn); |
327 | delete sn; | 326 | delete sn; |
328 | sn = 0; | 327 | sn = 0; |
329 | odebug << "QSocketNotifier stopped!" << oendl; | 328 | odebug << "QSocketNotifier stopped!" << oendl; |
330 | } | 329 | } |
331 | } | 330 | } |
332 | 331 | ||
333 | 332 | ||
334 | void Modem::flush() { | 333 | void Modem::flush() { |
335 | char c; | 334 | char c; |
336 | while(read(modemfd, &c, 1) == 1); | 335 | while(read(modemfd, &c, 1) == 1); |
337 | } | 336 | } |
338 | 337 | ||
339 | 338 | ||
340 | bool Modem::writeChar(unsigned char c) { | 339 | bool Modem::writeChar(unsigned char c) { |
341 | int s; | 340 | int s; |
342 | do { | 341 | do { |
343 | s = write(modemfd, &c, 1); | 342 | s = write(modemfd, &c, 1); |
344 | if (s < 0) { | 343 | if (s < 0) { |
345 | oerr << "write() in Modem::writeChar failed" << oendl; | 344 | oerr << "write() in Modem::writeChar failed" << oendl; |
346 | return false; | 345 | return false; |
347 | } | 346 | } |
348 | } while(s == 0); | 347 | } while(s == 0); |
349 | 348 | ||
350 | return true; | 349 | return true; |
351 | } | 350 | } |
352 | 351 | ||
353 | 352 | ||
354 | bool Modem::writeLine(const char *buf) { | 353 | bool Modem::writeLine(const char *buf) { |
355 | int len = strlen(buf); | 354 | int len = strlen(buf); |
356 | char *b = new char[len+2]; | 355 | char *b = new char[len+2]; |
357 | memcpy(b, buf, len); | 356 | memcpy(b, buf, len); |
358 | // different modems seem to need different line terminations | 357 | // different modems seem to need different line terminations |
359 | QString term = _pppdata->enter(); | 358 | QString term = _pppdata->enter(); |
360 | if(term == "LF") | 359 | if(term == "LF") |
361 | b[len++]='\n'; | 360 | b[len++]='\n'; |
362 | else if(term == "CR") | 361 | else if(term == "CR") |
363 | b[len++]='\r'; | 362 | b[len++]='\r'; |
364 | else if(term == "CR/LF") { | 363 | else if(term == "CR/LF") { |
365 | b[len++]='\r'; | 364 | b[len++]='\r'; |
366 | b[len++]='\n'; | 365 | b[len++]='\n'; |
367 | } | 366 | } |
368 | int l = len; | 367 | int l = len; |
369 | while(l) { | 368 | while(l) { |
370 | int wr = write(modemfd, &b[len-l], l); | 369 | int wr = write(modemfd, &b[len-l], l); |
371 | if(wr < 0) { | 370 | if(wr < 0) { |
372 | // TODO do something meaningful with the error code (or ignore it | 371 | // TODO do something meaningful with the error code (or ignore it |
373 | oerr << "write() in Modem::writeLine failed" << oendl; | 372 | oerr << "write() in Modem::writeLine failed" << oendl; |
374 | delete[] b; | 373 | delete[] b; |
375 | return false; | 374 | return false; |
376 | } | 375 | } |
377 | l -= wr; | 376 | l -= wr; |
378 | } | 377 | } |
379 | delete[] b; | 378 | delete[] b; |
380 | return true; | 379 | return true; |
381 | } | 380 | } |
382 | 381 | ||
383 | 382 | ||
384 | bool Modem::hangup() { | 383 | bool Modem::hangup() { |
385 | // this should really get the modem to hang up and go into command mode | 384 | // this should really get the modem to hang up and go into command mode |
386 | // If anyone sees a fault in the following please let me know, since | 385 | // If anyone sees a fault in the following please let me know, since |
387 | // this is probably the most imporant snippet of code in the whole of | 386 | // this is probably the most imporant snippet of code in the whole of |
388 | // kppp. If people complain about kppp being stuck, this piece of code | 387 | // kppp. If people complain about kppp being stuck, this piece of code |
389 | // is most likely the reason. | 388 | // is most likely the reason. |
390 | struct termios temptty; | 389 | struct termios temptty; |
391 | 390 | ||
392 | if(modemfd >= 0) { | 391 | if(modemfd >= 0) { |
393 | 392 | ||
394 | // is this Escape & HangupStr stuff really necessary ? (Harri) | 393 | // is this Escape & HangupStr stuff really necessary ? (Harri) |
395 | 394 | ||
396 | if (data_mode) escape_to_command_mode(); | 395 | if (data_mode) escape_to_command_mode(); |
397 | 396 | ||
398 | // Then hangup command | 397 | // Then hangup command |
399 | writeLine(_pppdata->modemHangupStr().local8Bit()); | 398 | writeLine(_pppdata->modemHangupStr().local8Bit()); |
400 | 399 | ||
401 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 400 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
402 | 401 | ||
403 | #ifndef DEBUG_WO_DIALING | 402 | #ifndef DEBUG_WO_DIALING |
404 | if (sigsetjmp(jmp_buffer, 1) == 0) { | 403 | if (sigsetjmp(jmp_buffer, 1) == 0) { |
405 | // set alarm in case tcsendbreak() hangs | 404 | // set alarm in case tcsendbreak() hangs |
406 | signal(SIGALRM, alarm_handler); | 405 | signal(SIGALRM, alarm_handler); |
407 | alarm(2); | 406 | alarm(2); |
408 | 407 | ||
409 | tcsendbreak(modemfd, 0); | 408 | tcsendbreak(modemfd, 0); |
410 | 409 | ||
411 | alarm(0); | 410 | alarm(0); |
412 | signal(SIGALRM, SIG_IGN); | 411 | signal(SIGALRM, SIG_IGN); |
413 | } else { | 412 | } else { |
414 | // we reach this point if the alarm handler got called | 413 | // we reach this point if the alarm handler got called |
415 | closetty(); | 414 | closetty(); |
416 | close(modemfd); | 415 | close(modemfd); |
417 | modemfd = -1; | 416 | modemfd = -1; |
418 | errmsg = QObject::tr("The modem does not respond."); | 417 | errmsg = QObject::tr("The modem does not respond."); |
419 | return false; | 418 | return false; |
420 | } | 419 | } |
421 | 420 | ||
422 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. | 421 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. |
423 | tcgetattr(modemfd, &temptty); | 422 | tcgetattr(modemfd, &temptty); |
424 | cfsetospeed(&temptty, B0); | 423 | cfsetospeed(&temptty, B0); |
425 | cfsetispeed(&temptty, B0); | 424 | cfsetispeed(&temptty, B0); |
426 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 425 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
427 | #else | 426 | #else |
428 | int modemstat; | 427 | int modemstat; |
429 | ioctl(modemfd, TIOCMGET, &modemstat); | 428 | ioctl(modemfd, TIOCMGET, &modemstat); |
430 | modemstat &= ~TIOCM_DTR; | 429 | modemstat &= ~TIOCM_DTR; |
431 | ioctl(modemfd, TIOCMSET, &modemstat); | 430 | ioctl(modemfd, TIOCMSET, &modemstat); |
432 | ioctl(modemfd, TIOCMGET, &modemstat); | 431 | ioctl(modemfd, TIOCMGET, &modemstat); |
433 | modemstat |= TIOCM_DTR; | 432 | modemstat |= TIOCM_DTR; |
434 | ioctl(modemfd, TIOCMSET, &modemstat); | 433 | ioctl(modemfd, TIOCMSET, &modemstat); |
435 | #endif | 434 | #endif |
436 | 435 | ||
437 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs | 436 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs |
438 | 437 | ||
439 | cfsetospeed(&temptty, modemspeed()); | 438 | cfsetospeed(&temptty, modemspeed()); |
440 | cfsetispeed(&temptty, modemspeed()); | 439 | cfsetispeed(&temptty, modemspeed()); |
441 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 440 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
442 | #endif | 441 | #endif |
443 | return true; | 442 | return true; |
444 | } else | 443 | } else |
445 | return false; | 444 | return false; |
446 | } | 445 | } |
447 | 446 | ||
448 | 447 | ||
449 | void Modem::escape_to_command_mode() { | 448 | void Modem::escape_to_command_mode() { |
450 | // Send Properly bracketed escape code to put the modem back into command state. | 449 | // Send Properly bracketed escape code to put the modem back into command state. |
451 | // A modem will accept AT commands only when it is in command state. | 450 | // A modem will accept AT commands only when it is in command state. |
452 | // When a modem sends the host the CONNECT string, that signals | 451 | // When a modem sends the host the CONNECT string, that signals |
453 | // that the modem is now in the connect state (no long accepts AT commands.) | 452 | // that the modem is now in the connect state (no long accepts AT commands.) |
454 | // Need to send properly timed escape sequence to put modem in command state. | 453 | // Need to send properly timed escape sequence to put modem in command state. |
455 | // Escape codes and guard times are controlled by S2 and S12 values. | 454 | // Escape codes and guard times are controlled by S2 and S12 values. |
456 | // | 455 | // |
457 | tcflush(modemfd, TCIOFLUSH); | 456 | tcflush(modemfd, TCIOFLUSH); |
458 | 457 | ||
459 | // +3 because quiet time must be greater than guard time. | 458 | // +3 because quiet time must be greater than guard time. |
460 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); | 459 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); |
461 | QCString tmp = _pppdata->modemEscapeStr().local8Bit(); | 460 | QCString tmp = _pppdata->modemEscapeStr().local8Bit(); |
462 | write(modemfd, tmp.data(), tmp.length()); | 461 | write(modemfd, tmp.data(), tmp.length()); |
463 | tcflush(modemfd, TCIOFLUSH); | 462 | tcflush(modemfd, TCIOFLUSH); |
464 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); | 463 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); |
465 | 464 | ||
466 | data_mode = false; | 465 | data_mode = false; |
467 | } | 466 | } |
468 | 467 | ||
469 | 468 | ||
470 | const QString Modem::modemMessage() { | 469 | const QString Modem::modemMessage() { |
471 | return errmsg; | 470 | return errmsg; |
472 | } | 471 | } |
473 | 472 | ||
474 | 473 | ||
475 | QString Modem::parseModemSpeed(const QString &s) { | 474 | QString Modem::parseModemSpeed(const QString &s) { |
476 | // this is a small (and bad) parser for modem speeds | 475 | // this is a small (and bad) parser for modem speeds |
477 | int rx = -1; | 476 | int rx = -1; |
478 | int tx = -1; | 477 | int tx = -1; |
479 | int i; | 478 | int i; |
480 | QString result; | 479 | QString result; |
481 | 480 | ||
482 | odebug << "Modem reported result string: " << s.latin1() << "" << oendl; | 481 | odebug << "Modem reported result string: " << s.latin1() << "" << oendl; |
483 | 482 | ||
484 | const int RXMAX = 7; | 483 | const int RXMAX = 7; |
485 | const int TXMAX = 2; | 484 | const int TXMAX = 2; |
486 | QRegExp rrx[RXMAX] = { | 485 | QRegExp rrx[RXMAX] = { |
487 | QRegExp("[0-9]+[:/ ]RX", false), | 486 | QRegExp("[0-9]+[:/ ]RX", false), |
488 | QRegExp("[0-9]+RX", false), | 487 | QRegExp("[0-9]+RX", false), |
489 | QRegExp("[/: -][0-9]+[/: ]", false), | 488 | QRegExp("[/: -][0-9]+[/: ]", false), |
490 | QRegExp("[/: -][0-9]+$", false), | 489 | QRegExp("[/: -][0-9]+$", false), |
491 | QRegExp("CARRIER [^0-9]*[0-9]+", false), | 490 | QRegExp("CARRIER [^0-9]*[0-9]+", false), |
492 | QRegExp("CONNECT [^0-9]*[0-9]+", false), | 491 | QRegExp("CONNECT [^0-9]*[0-9]+", false), |
493 | QRegExp("[0-9]+") // panic mode | 492 | QRegExp("[0-9]+") // panic mode |
494 | }; | 493 | }; |
495 | 494 | ||
496 | QRegExp trx[TXMAX] = { | 495 | QRegExp trx[TXMAX] = { |
497 | QRegExp("[0-9]+[:/ ]TX", false), | 496 | QRegExp("[0-9]+[:/ ]TX", false), |
498 | QRegExp("[0-9]+TX", false) | 497 | QRegExp("[0-9]+TX", false) |
499 | }; | 498 | }; |
500 | 499 | ||
501 | for(i = 0; i < RXMAX; i++) { | 500 | for(i = 0; i < RXMAX; i++) { |
502 | int len, idx, result; | 501 | int len, idx, result; |
503 | if((idx = rrx[i].match(s,0,&len)) > -1) { | 502 | if((idx = rrx[i].match(s,0,&len)) > -1) { |
504 | // if((idx = rrx[i].search(s)) > -1) { | 503 | // if((idx = rrx[i].search(s)) > -1) { |
505 | // len = rrx[i].matchedLength(); | 504 | // len = rrx[i].matchedLength(); |
506 | 505 | ||
507 | // | 506 | // |
508 | // rrx[i] has been matched, idx contains the start of the match | 507 | // rrx[i] has been matched, idx contains the start of the match |
509 | // and len contains how long the match is. Extract the match. | 508 | // and len contains how long the match is. Extract the match. |
510 | // | 509 | // |
511 | QString sub = s.mid(idx, len); | 510 | QString sub = s.mid(idx, len); |
512 | 511 | ||
513 | // | 512 | // |
514 | // Now extract the digits only from the match, which will | 513 | // Now extract the digits only from the match, which will |
515 | // then be converted to an int. | 514 | // then be converted to an int. |
516 | // | 515 | // |
517 | if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { | 516 | if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { |
518 | // if ((idx = rrx[RXMAX-1].search( sub )) > -1) { | 517 | // if ((idx = rrx[RXMAX-1].search( sub )) > -1) { |
519 | // len = rrx[RXMAX-1].matchedLength(); | 518 | // len = rrx[RXMAX-1].matchedLength(); |
520 | sub = sub.mid(idx, len); | 519 | sub = sub.mid(idx, len); |
521 | result = sub.toInt(); | 520 | result = sub.toInt(); |
522 | if(result > 0) { | 521 | if(result > 0) { |
523 | rx = result; | 522 | rx = result; |
524 | break; | 523 | break; |
525 | } | 524 | } |
526 | } | 525 | } |
527 | } | 526 | } |
528 | } | 527 | } |
529 | 528 | ||
530 | for(i = 0; i < TXMAX; i++) { | 529 | for(i = 0; i < TXMAX; i++) { |
531 | int len, idx, result; | 530 | int len, idx, result; |
532 | if((idx = trx[i].match(s,0,&len)) > -1) { | 531 | if((idx = trx[i].match(s,0,&len)) > -1) { |
533 | // if((idx = trx[i].search(s)) > -1) { | 532 | // if((idx = trx[i].search(s)) > -1) { |
534 | // len = trx[i].matchedLength(); | 533 | // len = trx[i].matchedLength(); |
535 | 534 | ||
536 | // | 535 | // |
537 | // trx[i] has been matched, idx contains the start of the match | 536 | // trx[i] has been matched, idx contains the start of the match |
538 | // and len contains how long the match is. Extract the match. | 537 | // and len contains how long the match is. Extract the match. |
539 | // | 538 | // |
540 | QString sub = s.mid(idx, len); | 539 | QString sub = s.mid(idx, len); |
541 | 540 | ||
542 | // | 541 | // |
543 | // Now extract the digits only from the match, which will then | 542 | // Now extract the digits only from the match, which will then |
544 | // be converted to an int. | 543 | // be converted to an int. |
545 | // | 544 | // |
546 | if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { | 545 | if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { |
547 | // if((idx = rrx[RXMAX-1].search(sub)) > -1) { | 546 | // if((idx = rrx[RXMAX-1].search(sub)) > -1) { |
548 | // len = rrx[RXMAX-1].matchedLength(); | 547 | // len = rrx[RXMAX-1].matchedLength(); |
549 | sub = sub.mid(idx, len); | 548 | sub = sub.mid(idx, len); |
550 | result = sub.toInt(); | 549 | result = sub.toInt(); |
551 | if(result > 0) { | 550 | if(result > 0) { |
552 | tx = result; | 551 | tx = result; |
553 | break; | 552 | break; |
554 | } | 553 | } |
555 | } | 554 | } |
556 | } | 555 | } |
557 | } | 556 | } |
558 | 557 | ||
559 | if(rx == -1 && tx == -1) | 558 | if(rx == -1 && tx == -1) |
560 | result = QObject::tr("Unknown speed"); | 559 | result = QObject::tr("Unknown speed"); |
561 | else if(tx == -1) | 560 | else if(tx == -1) |
562 | result.setNum(rx); | 561 | result.setNum(rx); |
563 | else if(rx == -1) // should not happen | 562 | else if(rx == -1) // should not happen |
564 | result.setNum(tx); | 563 | result.setNum(tx); |
565 | else | 564 | else |
566 | result.sprintf("%d/%d", rx, tx); | 565 | result.sprintf("%d/%d", rx, tx); |
567 | 566 | ||
568 | odebug << "The parsed result is: " << result.latin1() << "" << oendl; | 567 | odebug << "The parsed result is: " << result.latin1() << "" << oendl; |
569 | 568 | ||
570 | return result; | 569 | return result; |
571 | } | 570 | } |
572 | 571 | ||
573 | 572 | ||
574 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if | 573 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if |
575 | // a lock file can't be created ( permission problem ) | 574 | // a lock file can't be created ( permission problem ) |
576 | int Modem::lockdevice() { | 575 | int Modem::lockdevice() { |
577 | int fd; | 576 | int fd; |
578 | char newlock[80]=""; // safe | 577 | char newlock[80]=""; // safe |
579 | 578 | ||
580 | if(!_pppdata->modemLockFile()) { | 579 | if(!_pppdata->modemLockFile()) { |
581 | odebug << "The user doesn't want a lockfile." << oendl; | 580 | odebug << "The user doesn't want a lockfile." << oendl; |
582 | return 0; | 581 | return 0; |
583 | } | 582 | } |
584 | 583 | ||
585 | if (modem_is_locked) | 584 | if (modem_is_locked) |
586 | return 1; | 585 | return 1; |
587 | 586 | ||
588 | QString lockfile = LOCK_DIR"/LCK.."; | 587 | QString lockfile = LOCK_DIR"/LCK.."; |
589 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ | 588 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ |
590 | 589 | ||
591 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { | 590 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { |
592 | // if ((fd = Requester::rq-> | 591 | // if ((fd = Requester::rq-> |
593 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | 592 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { |
594 | // Mario: it's not necessary to read more than lets say 32 bytes. If | 593 | // Mario: it's not necessary to read more than lets say 32 bytes. If |
595 | // file has more than 32 bytes, skip the rest | 594 | // file has more than 32 bytes, skip the rest |
596 | char oldlock[33]; // safe | 595 | char oldlock[33]; // safe |
597 | int sz = read(fd, &oldlock, 32); | 596 | int sz = read(fd, &oldlock, 32); |
598 | close (fd); | 597 | close (fd); |
599 | if (sz <= 0) | 598 | if (sz <= 0) |
600 | return 1; | 599 | return 1; |
601 | oldlock[sz] = '\0'; | 600 | oldlock[sz] = '\0'; |
602 | 601 | ||
603 | odebug << "Device is locked by: " << oldlock << "" << oendl; | 602 | odebug << "Device is locked by: " << oldlock << "" << oendl; |
604 | 603 | ||
605 | int oldpid; | 604 | int oldpid; |
606 | int match = sscanf(oldlock, "%d", &oldpid); | 605 | int match = sscanf(oldlock, "%d", &oldpid); |
607 | 606 | ||
608 | // found a pid in lockfile ? | 607 | // found a pid in lockfile ? |
609 | if (match < 1 || oldpid <= 0) | 608 | if (match < 1 || oldpid <= 0) |
610 | return 1; | 609 | return 1; |
611 | 610 | ||
612 | // check if process exists | 611 | // check if process exists |
613 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) | 612 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) |
614 | return 1; | 613 | return 1; |
615 | 614 | ||
616 | odebug << "lockfile is stale" << oendl; | 615 | odebug << "lockfile is stale" << oendl; |
617 | } | 616 | } |
618 | } | 617 | } |
619 | 618 | ||
620 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); | 619 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); |
621 | if(fd >= 0) { | 620 | if(fd >= 0) { |
622 | sprintf(newlock,"%010d\n", getpid()); | 621 | sprintf(newlock,"%010d\n", getpid()); |
623 | odebug << "Locking Device: " << newlock << "" << oendl; | 622 | odebug << "Locking Device: " << newlock << "" << oendl; |
624 | 623 | ||
625 | write(fd, newlock, strlen(newlock)); | 624 | write(fd, newlock, strlen(newlock)); |
626 | close(fd); | 625 | close(fd); |
627 | modem_is_locked=true; | 626 | modem_is_locked=true; |
628 | 627 | ||
629 | return 0; | 628 | return 0; |
630 | } | 629 | } |
631 | 630 | ||
632 | return -1; | 631 | return -1; |
633 | 632 | ||
634 | } | 633 | } |
635 | 634 | ||
636 | 635 | ||
637 | // UnLock modem device | 636 | // UnLock modem device |
638 | void Modem::unlockdevice() { | 637 | void Modem::unlockdevice() { |
639 | if (modem_is_locked) { | 638 | if (modem_is_locked) { |
640 | odebug << "UnLocking Modem Device" << oendl; | 639 | odebug << "UnLocking Modem Device" << oendl; |
641 | close(modemfd); | 640 | close(modemfd); |
642 | modemfd = -1; | 641 | modemfd = -1; |
643 | unlink(lockfile); | 642 | unlink(lockfile); |
644 | lockfile[0] = '\0'; | 643 | lockfile[0] = '\0'; |
645 | modem_is_locked=false; | 644 | modem_is_locked=false; |
646 | } | 645 | } |
647 | } | 646 | } |
648 | 647 | ||
649 | int Modem::openLockfile( QString lockfile, int flags) | 648 | int Modem::openLockfile( QString lockfile, int flags) |
650 | { | 649 | { |
651 | int fd; | 650 | int fd; |
652 | int mode; | 651 | int mode; |
653 | flags = O_RDONLY; | 652 | flags = O_RDONLY; |
654 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) | 653 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) |
655 | mode = 0644; | 654 | mode = 0644; |
656 | else | 655 | else |
657 | mode = 0; | 656 | mode = 0; |
658 | 657 | ||
659 | lockfile = LOCK_DIR; | 658 | lockfile = LOCK_DIR; |
660 | lockfile += "/LCK.."; | 659 | lockfile += "/LCK.."; |
661 | lockfile += device.right( device.length() - device.findRev("/") -1 ); | 660 | lockfile += device.right( device.length() - device.findRev("/") -1 ); |
662 | odebug << "lockfile >" << lockfile.latin1() << "<" << oendl; | 661 | odebug << "lockfile >" << lockfile.latin1() << "<" << oendl; |
663 | // TODO: | 662 | // TODO: |
664 | // struct stat st; | 663 | // struct stat st; |
665 | // if(stat(lockfile.data(), &st) == -1) { | 664 | // if(stat(lockfile.data(), &st) == -1) { |
666 | // if(errno == EBADF) | 665 | // if(errno == EBADF) |
667 | // return -1; | 666 | // return -1; |
668 | // } else { | 667 | // } else { |
669 | // // make sure that this is a regular file | 668 | // // make sure that this is a regular file |
670 | // if(!S_ISREG(st.st_mode)) | 669 | // if(!S_ISREG(st.st_mode)) |
671 | // return -1; | 670 | // return -1; |
672 | // } | 671 | // } |
673 | if ((fd = open(lockfile, flags, mode)) == -1) { | 672 | if ((fd = open(lockfile, flags, mode)) == -1) { |
674 | odebug << "error opening lockfile!" << oendl; | 673 | odebug << "error opening lockfile!" << oendl; |
675 | lockfile = QString::null; | 674 | lockfile = QString::null; |
676 | fd = open(DEVNULL, O_RDONLY); | 675 | fd = open(DEVNULL, O_RDONLY); |
677 | } else | 676 | } else |
678 | fchown(fd, 0, 0); | 677 | fchown(fd, 0, 0); |
679 | return fd; | 678 | return fd; |
680 | } | 679 | } |
681 | 680 | ||
682 | 681 | ||
683 | 682 | ||
684 | void alarm_handler(int) { | 683 | void alarm_handler(int) { |
685 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); | 684 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); |
686 | 685 | ||
687 | // jump | 686 | // jump |
688 | siglongjmp(jmp_buffer, 1); | 687 | siglongjmp(jmp_buffer, 1); |
689 | } | 688 | } |
690 | 689 | ||
691 | 690 | ||
692 | const char* Modem::authFile(Auth method, int version) { | 691 | const char* Modem::authFile(Auth method, int version) { |
693 | switch(method|version) { | 692 | switch(method|version) { |
694 | case PAP|Original: | 693 | case PAP|Original: |
695 | return PAP_AUTH_FILE; | 694 | return PAP_AUTH_FILE; |
696 | break; | 695 | break; |
697 | case PAP|New: | 696 | case PAP|New: |
698 | return PAP_AUTH_FILE".new"; | 697 | return PAP_AUTH_FILE".new"; |
699 | break; | 698 | break; |
700 | case PAP|Old: | 699 | case PAP|Old: |
701 | return PAP_AUTH_FILE".old"; | 700 | return PAP_AUTH_FILE".old"; |
702 | break; | 701 | break; |
703 | case CHAP|Original: | 702 | case CHAP|Original: |
704 | return CHAP_AUTH_FILE; | 703 | return CHAP_AUTH_FILE; |
705 | break; | 704 | break; |
706 | case CHAP|New: | 705 | case CHAP|New: |
707 | return CHAP_AUTH_FILE".new"; | 706 | return CHAP_AUTH_FILE".new"; |
708 | break; | 707 | break; |
709 | case CHAP|Old: | 708 | case CHAP|Old: |
710 | return CHAP_AUTH_FILE".old"; | 709 | return CHAP_AUTH_FILE".old"; |
711 | break; | 710 | break; |
712 | default: | 711 | default: |
713 | return 0L; | 712 | return 0L; |
714 | } | 713 | } |
715 | } | 714 | } |
716 | 715 | ||
717 | 716 | ||
718 | bool Modem::createAuthFile(Auth method, const char *username, const char *password) { | 717 | bool Modem::createAuthFile(Auth method, const char *username, const char *password) { |
719 | const char *authfile, *oldName, *newName; | 718 | const char *authfile, *oldName, *newName; |
720 | char line[100]; | 719 | char line[100]; |
721 | char regexp[2*MaxStrLen+30]; | 720 | char regexp[2*MaxStrLen+30]; |
722 | regex_t preg; | 721 | regex_t preg; |
723 | 722 | ||
724 | if(!(authfile = authFile(method))) | 723 | if(!(authfile = authFile(method))) |
725 | return false; | 724 | return false; |
726 | 725 | ||
727 | if(!(newName = authFile(method, New))) | 726 | if(!(newName = authFile(method, New))) |
728 | return false; | 727 | return false; |
729 | 728 | ||
730 | // look for username, "username" or 'username' | 729 | // look for username, "username" or 'username' |
731 | // if you modify this RE you have to adapt regexp's size above | 730 | // if you modify this RE you have to adapt regexp's size above |
732 | snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']", | 731 | snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']", |
733 | username,username); | 732 | username,username); |
734 | MY_ASSERT(regcomp(&preg, regexp, 0) == 0); | 733 | MY_ASSERT(regcomp(&preg, regexp, 0) == 0); |
735 | 734 | ||
736 | // copy to new file pap- or chap-secrets | 735 | // copy to new file pap- or chap-secrets |
737 | int old_umask = umask(0077); | 736 | int old_umask = umask(0077); |
738 | FILE *fout = fopen(newName, "w"); | 737 | FILE *fout = fopen(newName, "w"); |
739 | if(fout) { | 738 | if(fout) { |
740 | // copy old file | 739 | // copy old file |
741 | FILE *fin = fopen(authfile, "r"); | 740 | FILE *fin = fopen(authfile, "r"); |
742 | if(fin) { | 741 | if(fin) { |
743 | while(fgets(line, sizeof(line), fin)) { | 742 | while(fgets(line, sizeof(line), fin)) { |
744 | if(regexec(&preg, line, 0, 0L, 0) == 0) | 743 | if(regexec(&preg, line, 0, 0L, 0) == 0) |
745 | continue; | 744 | continue; |
746 | fputs(line, fout); | 745 | fputs(line, fout); |
747 | } | 746 | } |
748 | fclose(fin); | 747 | fclose(fin); |
749 | } | 748 | } |
750 | 749 | ||
751 | // append user/pass pair | 750 | // append user/pass pair |
752 | fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password); | 751 | fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password); |
753 | fclose(fout); | 752 | fclose(fout); |
754 | } | 753 | } |
755 | 754 | ||
756 | // restore umask | 755 | // restore umask |
757 | umask(old_umask); | 756 | umask(old_umask); |
758 | 757 | ||
759 | // free memory allocated by regcomp | 758 | // free memory allocated by regcomp |
760 | regfree(&preg); | 759 | regfree(&preg); |
761 | 760 | ||
762 | if(!(oldName = authFile(method, Old))) | 761 | if(!(oldName = authFile(method, Old))) |
763 | return false; | 762 | return false; |
764 | 763 | ||
765 | // delete old file if any | 764 | // delete old file if any |
766 | unlink(oldName); | 765 | unlink(oldName); |
767 | 766 | ||
768 | rename(authfile, oldName); | 767 | rename(authfile, oldName); |
769 | rename(newName, authfile); | 768 | rename(newName, authfile); |
770 | 769 | ||
771 | return true; | 770 | return true; |
772 | } | 771 | } |
773 | 772 | ||
774 | 773 | ||
775 | bool Modem::removeAuthFile(Auth method) { | 774 | bool Modem::removeAuthFile(Auth method) { |
776 | const char *authfile, *oldName; | 775 | const char *authfile, *oldName; |
777 | 776 | ||
778 | if(!(authfile = authFile(method))) | 777 | if(!(authfile = authFile(method))) |
779 | return false; | 778 | return false; |
780 | if(!(oldName = authFile(method, Old))) | 779 | if(!(oldName = authFile(method, Old))) |
781 | return false; | 780 | return false; |
782 | 781 | ||
783 | if(access(oldName, F_OK) == 0) { | 782 | if(access(oldName, F_OK) == 0) { |
784 | unlink(authfile); | 783 | unlink(authfile); |
785 | return (rename(oldName, authfile) == 0); | 784 | return (rename(oldName, authfile) == 0); |
786 | } else | 785 | } else |
787 | return false; | 786 | return false; |
788 | } | 787 | } |
789 | 788 | ||
790 | 789 | ||
791 | bool Modem::setSecret(int method, const char* name, const char* password) | 790 | bool Modem::setSecret(int method, const char* name, const char* password) |
792 | { | 791 | { |
793 | 792 | ||
794 | Auth auth; | 793 | Auth auth; |
795 | if(method == AUTH_PAPCHAP) | 794 | if(method == AUTH_PAPCHAP) |
796 | return setSecret(AUTH_PAP, name, password) && | 795 | return setSecret(AUTH_PAP, name, password) && |
797 | setSecret(AUTH_CHAP, name, password); | 796 | setSecret(AUTH_CHAP, name, password); |
798 | 797 | ||
799 | switch(method) { | 798 | switch(method) { |
800 | case AUTH_PAP: | 799 | case AUTH_PAP: |
801 | auth = Modem::PAP; | 800 | auth = Modem::PAP; |
802 | break; | 801 | break; |
803 | case AUTH_CHAP: | 802 | case AUTH_CHAP: |
804 | auth = Modem::CHAP; | 803 | auth = Modem::CHAP; |
805 | break; | 804 | break; |
806 | default: | 805 | default: |
807 | return false; | 806 | return false; |
808 | } | 807 | } |
809 | 808 | ||
810 | return createAuthFile(auth, name, password); | 809 | return createAuthFile(auth, name, password); |
811 | 810 | ||
812 | } | 811 | } |
813 | 812 | ||
814 | bool Modem::removeSecret(int method) | 813 | bool Modem::removeSecret(int method) |
815 | { | 814 | { |
816 | Auth auth; | 815 | Auth auth; |
817 | 816 | ||
818 | switch(method) { | 817 | switch(method) { |
819 | case AUTH_PAP: | 818 | case AUTH_PAP: |
820 | auth = Modem::PAP; | 819 | auth = Modem::PAP; |
821 | break; | 820 | break; |
822 | case AUTH_CHAP: | 821 | case AUTH_CHAP: |
823 | auth = Modem::CHAP; | 822 | auth = Modem::CHAP; |
824 | break; | 823 | break; |
825 | default: | 824 | default: |
826 | return false; | 825 | return false; |
827 | } | 826 | } |
828 | return removeAuthFile( auth ); | 827 | return removeAuthFile( auth ); |
829 | } | 828 | } |
830 | 829 | ||
831 | int checkForInterface() | 830 | int checkForInterface() |
832 | { | 831 | { |
833 | // I don't know if Linux needs more initialization to get the ioctl to | 832 | // I don't know if Linux needs more initialization to get the ioctl to |
834 | // work, pppd seems to hint it does. But BSD doesn't, and the following | 833 | // work, pppd seems to hint it does. But BSD doesn't, and the following |
835 | // code should compile. | 834 | // code should compile. |
836 | #if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) | 835 | #if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) |
837 | int s, ok; | 836 | int s, ok; |
838 | struct ifreq ifr; | 837 | struct ifreq ifr; |
839 | // extern char *no_ppp_msg; | 838 | // extern char *no_ppp_msg; |
840 | 839 | ||
841 | if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) | 840 | if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) |
842 | return 1; /* can't tell */ | 841 | return 1; /* can't tell */ |
843 | 842 | ||
844 | strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); | 843 | strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); |
845 | ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; | 844 | ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; |
846 | close(s); | 845 | close(s); |
847 | 846 | ||
848 | if (ok == -1) { | 847 | if (ok == -1) { |
849 | // This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports | 848 | // This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports |
850 | // KLDs, the old LKM interface couldn't handle loading devices | 849 | // KLDs, the old LKM interface couldn't handle loading devices |
851 | // dynamically, and thus can't load ppp support on the fly | 850 | // dynamically, and thus can't load ppp support on the fly |
852 | #ifdef __FreeBSD__ | 851 | #ifdef __FreeBSD__ |
853 | // If we failed to load ppp support and don't have it already. | 852 | // If we failed to load ppp support and don't have it already. |
854 | if (kldload("if_ppp") == -1) { | 853 | if (kldload("if_ppp") == -1) { |
855 | return -1; | 854 | return -1; |
856 | } | 855 | } |
857 | return 0; | 856 | return 0; |
858 | #else | 857 | #else |
859 | return -1; | 858 | return -1; |
860 | #endif | 859 | #endif |
861 | } | 860 | } |
862 | return 0; | 861 | return 0; |
863 | #else | 862 | #else |
864 | // We attempt to use the SunOS/SysVr4 method and stat /dev/ppp | 863 | // We attempt to use the SunOS/SysVr4 method and stat /dev/ppp |
865 | struct stat buf; | 864 | struct stat buf; |
866 | 865 | ||
867 | memset(&buf, 0, sizeof(buf)); | 866 | memset(&buf, 0, sizeof(buf)); |
868 | return stat("/dev/ppp", &buf); | 867 | return stat("/dev/ppp", &buf); |
869 | #endif | 868 | #endif |
870 | } | 869 | } |
871 | 870 | ||
872 | bool Modem::execpppd(const char *arguments) { | 871 | bool Modem::execpppd(const char *arguments) { |
873 | char buf[MAX_CMDLEN]; | 872 | char buf[MAX_CMDLEN]; |
874 | char *args[MaxArgs]; | 873 | char *args[MaxArgs]; |
875 | pid_t pgrpid; | 874 | pid_t pgrpid; |
876 | 875 | ||
877 | if(modemfd<0) | 876 | if(modemfd<0) |
878 | return false; | 877 | return false; |
879 | 878 | ||
880 | _pppdExitStatus = -1; | 879 | _pppdExitStatus = -1; |
881 | 880 | ||
882 | (void)::pipe( m_pppdLOG ); | 881 | (void)::pipe( m_pppdLOG ); |
883 | 882 | ||
884 | switch(pppdPid = fork()) | 883 | switch(pppdPid = fork()) |
885 | { | 884 | { |
886 | case -1: | 885 | case -1: |
887 | fprintf(stderr,"In parent: fork() failed\n"); | 886 | fprintf(stderr,"In parent: fork() failed\n"); |
888 | ::close( m_pppdLOG[0] ); | 887 | ::close( m_pppdLOG[0] ); |
889 | ::close( m_pppdLOG[1] ); | 888 | ::close( m_pppdLOG[1] ); |
890 | return false; | 889 | return false; |
891 | break; | 890 | break; |
892 | 891 | ||
893 | case 0: | 892 | case 0: |
894 | // let's parse the arguments the user supplied into UNIX suitable form | 893 | // let's parse the arguments the user supplied into UNIX suitable form |
895 | // that is a list of pointers each pointing to exactly one word | 894 | // that is a list of pointers each pointing to exactly one word |
896 | strlcpy(buf, arguments); | 895 | strlcpy(buf, arguments); |
897 | parseargs(buf, args); | 896 | parseargs(buf, args); |
898 | // become a session leader and let /dev/ttySx | 897 | // become a session leader and let /dev/ttySx |
899 | // be the controlling terminal. | 898 | // be the controlling terminal. |
900 | pgrpid = setsid(); | 899 | pgrpid = setsid(); |
901 | #ifdef TIOCSCTTY | 900 | #ifdef TIOCSCTTY |
902 | if(ioctl(modemfd, TIOCSCTTY, 0)<0) | 901 | if(ioctl(modemfd, TIOCSCTTY, 0)<0) |
903 | fprintf(stderr, "ioctl() failed.\n"); | 902 | fprintf(stderr, "ioctl() failed.\n"); |
904 | #elif defined (TIOCSPGRP) | 903 | #elif defined (TIOCSPGRP) |
905 | if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) | 904 | if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) |
906 | fprintf(stderr, "ioctl() failed.\n"); | 905 | fprintf(stderr, "ioctl() failed.\n"); |
907 | #endif | 906 | #endif |
908 | if(tcsetpgrp(modemfd, pgrpid)<0) | 907 | if(tcsetpgrp(modemfd, pgrpid)<0) |
909 | fprintf(stderr, "tcsetpgrp() failed.\n"); | 908 | fprintf(stderr, "tcsetpgrp() failed.\n"); |
910 | 909 | ||
911 | ::close( m_pppdLOG[0] ); | 910 | ::close( m_pppdLOG[0] ); |
912 | ::setenv( "LANG", "C", 1 ); // overwrite | 911 | ::setenv( "LANG", "C", 1 ); // overwrite |
913 | dup2(m_pppdLOG[1], 11 ); // for logfd 11 | 912 | dup2(m_pppdLOG[1], 11 ); // for logfd 11 |
914 | dup2(modemfd, 0); | 913 | dup2(modemfd, 0); |
915 | dup2(modemfd, 1); | 914 | dup2(modemfd, 1); |
916 | 915 | ||
917 | 916 | ||
918 | switch (checkForInterface()) { | 917 | switch (checkForInterface()) { |
919 | case 1: | 918 | case 1: |
920 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); | 919 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); |
921 | break; | 920 | break; |
922 | case -1: | 921 | case -1: |
923 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); | 922 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); |
924 | break; | 923 | break; |
925 | case 0: | 924 | case 0: |
926 | fprintf(stderr, "Kernel supports ppp alright.\n"); | 925 | fprintf(stderr, "Kernel supports ppp alright.\n"); |
927 | break; | 926 | break; |
928 | } | 927 | } |
929 | 928 | ||
930 | execve(pppdPath(), args, 0L); | 929 | execve(pppdPath(), args, 0L); |
931 | _exit(0); | 930 | _exit(0); |
932 | break; | 931 | break; |
933 | 932 | ||
934 | default: | 933 | default: |
935 | odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl; | 934 | odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl; |
936 | close(modemfd); | 935 | close(modemfd); |
937 | 936 | ||
938 | ::close( m_pppdLOG[1] ); | 937 | ::close( m_pppdLOG[1] ); |
939 | // set it to nonblocking io | 938 | // set it to nonblocking io |
940 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); | 939 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); |
941 | 940 | ||
942 | if ( !(flag & O_NONBLOCK) ) { | 941 | if ( !(flag & O_NONBLOCK) ) { |
943 | odebug << "Setting nonblocking io" << oendl; | 942 | odebug << "Setting nonblocking io" << oendl; |
944 | flag |= O_NONBLOCK; | 943 | flag |= O_NONBLOCK; |
945 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); | 944 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); |
946 | } | 945 | } |
947 | 946 | ||
948 | delete m_modemDebug; | 947 | delete m_modemDebug; |
949 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); | 948 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); |
950 | connect(m_modemDebug, SIGNAL(activated(int) ), | 949 | connect(m_modemDebug, SIGNAL(activated(int) ), |
951 | this, SLOT(slotModemDebug(int) ) ); | 950 | this, SLOT(slotModemDebug(int) ) ); |
952 | 951 | ||
953 | modemfd = -1; | 952 | modemfd = -1; |
954 | m_pppdDev = QString::fromLatin1("ppp0"); | 953 | m_pppdDev = QString::fromLatin1("ppp0"); |
955 | return true; | 954 | return true; |
956 | break; | 955 | break; |
957 | } | 956 | } |
958 | } | 957 | } |
959 | 958 | ||
960 | 959 | ||
961 | bool Modem::killpppd() { | 960 | bool Modem::killpppd() { |
962 | odebug << "In killpppd and pid is " << pppdPid << "" << oendl; | 961 | odebug << "In killpppd and pid is " << pppdPid << "" << oendl; |
963 | if(pppdPid > 0) { | 962 | if(pppdPid > 0) { |
964 | delete m_modemDebug; | 963 | delete m_modemDebug; |
965 | m_modemDebug = 0; | 964 | m_modemDebug = 0; |
966 | odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl; | 965 | odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl; |
967 | if(kill(pppdPid, SIGTERM) < 0) { | 966 | if(kill(pppdPid, SIGTERM) < 0) { |
968 | odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl; | 967 | odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl; |
969 | if(kill(pppdPid, SIGKILL) < 0) { | 968 | if(kill(pppdPid, SIGKILL) < 0) { |
970 | odebug << "Error killing " << pppdPid << "\n" << oendl; | 969 | odebug << "Error killing " << pppdPid << "\n" << oendl; |
971 | return false; | 970 | return false; |
972 | } | 971 | } |
973 | } | 972 | } |
974 | } | 973 | } |
975 | return true; | 974 | return true; |
976 | } | 975 | } |
977 | 976 | ||
978 | 977 | ||
979 | void Modem::parseargs(char* buf, char** args) { | 978 | void Modem::parseargs(char* buf, char** args) { |
980 | int nargs = 0; | 979 | int nargs = 0; |
981 | int quotes; | 980 | int quotes; |
982 | 981 | ||
983 | while(nargs < MaxArgs-1 && *buf != '\0') { | 982 | while(nargs < MaxArgs-1 && *buf != '\0') { |
984 | 983 | ||
985 | quotes = 0; | 984 | quotes = 0; |
986 | 985 | ||
987 | // Strip whitespace. Use nulls, so that the previous argument is | 986 | // Strip whitespace. Use nulls, so that the previous argument is |
988 | // terminated automatically. | 987 | // terminated automatically. |
989 | 988 | ||
990 | while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) | 989 | while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) |
991 | *buf++ = '\0'; | 990 | *buf++ = '\0'; |
992 | 991 | ||
993 | // detect begin of quoted argument | 992 | // detect begin of quoted argument |
994 | if (*buf == '"' || *buf == '\'') { | 993 | if (*buf == '"' || *buf == '\'') { |
995 | quotes = *buf; | 994 | quotes = *buf; |
996 | *buf++ = '\0'; | 995 | *buf++ = '\0'; |
997 | } | 996 | } |
998 | 997 | ||
999 | // save the argument | 998 | // save the argument |
1000 | if(*buf != '\0') { | 999 | if(*buf != '\0') { |
1001 | *args++ = buf; | 1000 | *args++ = buf; |
1002 | nargs++; | 1001 | nargs++; |
1003 | } | 1002 | } |
1004 | 1003 | ||
1005 | if (!quotes) | 1004 | if (!quotes) |
1006 | while ((*buf != '\0') && (*buf != '\n') && | 1005 | while ((*buf != '\0') && (*buf != '\n') && |
1007 | (*buf != '\t') && (*buf != ' ')) | 1006 | (*buf != '\t') && (*buf != ' ')) |
1008 | buf++; | 1007 | buf++; |
1009 | else { | 1008 | else { |
1010 | while ((*buf != '\0') && (*buf != quotes)) | 1009 | while ((*buf != '\0') && (*buf != quotes)) |
1011 | buf++; | 1010 | buf++; |
1012 | *buf++ = '\0'; | 1011 | *buf++ = '\0'; |
1013 | } | 1012 | } |
1014 | } | 1013 | } |
1015 | 1014 | ||
1016 | *args = 0L; | 1015 | *args = 0L; |
1017 | } | 1016 | } |
1018 | 1017 | ||
1019 | bool Modem::execPPPDaemon(const QString & arguments) | 1018 | bool Modem::execPPPDaemon(const QString & arguments) |
1020 | { | 1019 | { |
1021 | if(execpppd(arguments)) { | 1020 | if(execpppd(arguments)) { |
1022 | _pppdata->setpppdRunning(true); | 1021 | _pppdata->setpppdRunning(true); |
1023 | return true; | 1022 | return true; |
1024 | } else | 1023 | } else |
1025 | return false; | 1024 | return false; |
1026 | } | 1025 | } |
1027 | 1026 | ||
1028 | void Modem::killPPPDaemon() | 1027 | void Modem::killPPPDaemon() |
1029 | { | 1028 | { |
1030 | _pppdata->setpppdRunning(false); | 1029 | _pppdata->setpppdRunning(false); |
1031 | killpppd(); | 1030 | killpppd(); |
1032 | } | 1031 | } |
1033 | 1032 | ||
1034 | int Modem::pppdExitStatus() | 1033 | int Modem::pppdExitStatus() |
1035 | { | 1034 | { |
1036 | return _pppdExitStatus; | 1035 | return _pppdExitStatus; |
1037 | } | 1036 | } |
1038 | 1037 | ||
1039 | int Modem::openResolv(int flags) | 1038 | int Modem::openResolv(int flags) |
1040 | { | 1039 | { |
1041 | int fd; | 1040 | int fd; |
1042 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { | 1041 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { |
1043 | odebug << "error opening resolv.conf!" << oendl; | 1042 | odebug << "error opening resolv.conf!" << oendl; |
1044 | fd = open(DEVNULL, O_RDONLY); | 1043 | fd = open(DEVNULL, O_RDONLY); |
1045 | } | 1044 | } |
1046 | return fd; | 1045 | return fd; |
1047 | } | 1046 | } |
1048 | 1047 | ||
1049 | bool Modem::setHostname(const QString & name) | 1048 | bool Modem::setHostname(const QString & name) |
1050 | { | 1049 | { |
1051 | return sethostname(name, name.length()) == 0; | 1050 | return sethostname(name, name.length()) == 0; |
1052 | } | 1051 | } |
1053 | 1052 | ||
1054 | QString Modem::pppDevice()const { | 1053 | QString Modem::pppDevice()const { |
1055 | return m_pppdDev; | 1054 | return m_pppdDev; |
1056 | } | 1055 | } |
1057 | void Modem::setPPPDevice( const QString& dev ) { | 1056 | void Modem::setPPPDevice( const QString& dev ) { |
1058 | m_pppdDev = dev; | 1057 | m_pppdDev = dev; |
1059 | } | 1058 | } |
1060 | pid_t Modem::pppPID()const { | 1059 | pid_t Modem::pppPID()const { |
1061 | return pppdPid; | 1060 | return pppdPid; |
1062 | } | 1061 | } |
1063 | void Modem::setPPPDPid( pid_t pid ) { | 1062 | void Modem::setPPPDPid( pid_t pid ) { |
1064 | odebug << "Modem setting pid" << oendl; | 1063 | odebug << "Modem setting pid" << oendl; |
1065 | _pppdExitStatus = -1; | 1064 | _pppdExitStatus = -1; |
1066 | pppdPid = pid; | 1065 | pppdPid = pid; |
1067 | modemfd = -1; | 1066 | modemfd = -1; |
1068 | } | 1067 | } |
1069 | void Modem::slotModemDebug(int fd) { | 1068 | void Modem::slotModemDebug(int fd) { |
1070 | char buf[2049]; | 1069 | char buf[2049]; |
1071 | int len; | 1070 | int len; |
1072 | 1071 | ||
1073 | // read in pppd data look for Using interface | 1072 | // read in pppd data look for Using interface |
1074 | // then read the interface | 1073 | // then read the interface |
1075 | // we limit to 10 device now 0-9 | 1074 | // we limit to 10 device now 0-9 |
1076 | if((len = ::read(fd, buf, 2048)) > 0) { | 1075 | if((len = ::read(fd, buf, 2048)) > 0) { |
1077 | buf[len+1] = '\0'; | 1076 | buf[len+1] = '\0'; |
1078 | char *found; | 1077 | char *found; |
1079 | if ( (found = ::strstr(buf, "Using interface ") ) ) { | 1078 | if ( (found = ::strstr(buf, "Using interface ") ) ) { |
1080 | found += 16; | 1079 | found += 16; |
1081 | m_pppdDev = QString::fromLatin1(found, 5 ); | 1080 | m_pppdDev = QString::fromLatin1(found, 5 ); |
1082 | m_pppdDev = m_pppdDev.simplifyWhiteSpace(); | 1081 | m_pppdDev = m_pppdDev.simplifyWhiteSpace(); |
1083 | } | 1082 | } |
1084 | } | 1083 | } |
1085 | } | 1084 | } |
diff --git a/noncore/settings/tabmanager/tablistview.h b/noncore/settings/tabmanager/tablistview.h index dfd88f7..54b87b6 100644 --- a/noncore/settings/tabmanager/tablistview.h +++ b/noncore/settings/tabmanager/tablistview.h | |||
@@ -1,65 +1,69 @@ | |||
1 | #ifndef TABLISTVIEW_H | 1 | #ifndef TABLISTVIEW_H |
2 | #define TABLISTVIEW_H | 2 | #define TABLISTVIEW_H |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | |||
7 | /* QT */ | ||
4 | #include <qlistview.h> | 8 | #include <qlistview.h> |
5 | #include <qcursor.h> | 9 | #include <qcursor.h> |
6 | #include <qapplication.h> | 10 | #include <qapplication.h> |
7 | 11 | ||
8 | class TabListView : public QListView { | 12 | class TabListView : public QListView { |
9 | Q_OBJECT | 13 | Q_OBJECT |
10 | 14 | ||
11 | signals: | 15 | signals: |
12 | void moveItem(QListViewItem *item, QListViewItem *newFolder); | 16 | void moveItem(QListViewItem *item, QListViewItem *newFolder); |
13 | 17 | ||
14 | public: | 18 | public: |
15 | TabListView( QWidget* parent = 0, const char* name = 0) : QListView(parent, name){ currentSelectedItem = NULL; | 19 | TabListView( QWidget* parent = 0, const char* name = 0) : QListView(parent, name){ currentSelectedItem = NULL; |
16 | connect(this, SIGNAL(pressed ( QListViewItem *)), this, SLOT(itemPressed(QListViewItem *))); | 20 | connect(this, SIGNAL(pressed ( QListViewItem *)), this, SLOT(itemPressed(QListViewItem *))); |
17 | internalCursor.setShape(0); | 21 | internalCursor.setShape(0); |
18 | }; | 22 | }; |
19 | 23 | ||
20 | protected: | 24 | protected: |
21 | void contentsMouseReleaseEvent(QMouseEvent* ){ | 25 | void contentsMouseReleaseEvent(QMouseEvent* ){ |
22 | QListViewItem *newGroup = this->currentItem(); | 26 | QListViewItem *newGroup = this->currentItem(); |
23 | // Make sure they are both real. | 27 | // Make sure they are both real. |
24 | if (currentSelectedItem == NULL || newGroup == NULL) | 28 | if (currentSelectedItem == NULL || newGroup == NULL) |
25 | return; | 29 | return; |
26 | // Make sure they are not the same | 30 | // Make sure they are not the same |
27 | if(this->isSelected(currentSelectedItem) == true) | 31 | if(this->isSelected(currentSelectedItem) == true) |
28 | return; | 32 | return; |
29 | 33 | ||
30 | // Ok we have two valid items. | 34 | // Ok we have two valid items. |
31 | if(newGroup->parent()) | 35 | if(newGroup->parent()) |
32 | newGroup = newGroup->parent(); | 36 | newGroup = newGroup->parent(); |
33 | 37 | ||
34 | // Just in case the parent was null | 38 | // Just in case the parent was null |
35 | if(newGroup == NULL) | 39 | if(newGroup == NULL) |
36 | return; | 40 | return; |
37 | 41 | ||
38 | // If the new folder and buddies current parent are the same don't do anything. | 42 | // If the new folder and buddies current parent are the same don't do anything. |
39 | if (newGroup != currentSelectedItem->parent()) | 43 | if (newGroup != currentSelectedItem->parent()) |
40 | moveItem(currentSelectedItem, newGroup); | 44 | moveItem(currentSelectedItem, newGroup); |
41 | currentSelectedItem = NULL; | 45 | currentSelectedItem = NULL; |
42 | qApp->restoreOverrideCursor(); | 46 | qApp->restoreOverrideCursor(); |
43 | }; | 47 | }; |
44 | 48 | ||
45 | private slots: | 49 | private slots: |
46 | void itemPressed(QListViewItem *item){ | 50 | void itemPressed(QListViewItem *item){ |
47 | if(item == NULL || !item->parent()){ | 51 | if(item == NULL || !item->parent()){ |
48 | if(item == NULL) | 52 | if(item == NULL) |
49 | qDebug("Item is NULL"); | 53 | odebug << "Item is NULL" << oendl; |
50 | return; | 54 | return; |
51 | } | 55 | } |
52 | 56 | ||
53 | currentSelectedItem = item; | 57 | currentSelectedItem = item; |
54 | internalCursor.setShape(13); | 58 | internalCursor.setShape(13); |
55 | qApp->setOverrideCursor(internalCursor); | 59 | qApp->setOverrideCursor(internalCursor); |
56 | }; | 60 | }; |
57 | 61 | ||
58 | 62 | ||
59 | private: | 63 | private: |
60 | QListViewItem *currentSelectedItem; | 64 | QListViewItem *currentSelectedItem; |
61 | QCursor internalCursor; | 65 | QCursor internalCursor; |
62 | }; | 66 | }; |
63 | 67 | ||
64 | #endif | 68 | #endif |
65 | 69 | ||