Diffstat (limited to 'noncore/apps/opie-console/dialer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 90e2b6c..89a0e8d 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp | |||
@@ -80,121 +80,122 @@ void Dialer::slotCancel() | |||
80 | if(state != state_online) | 80 | if(state != state_online) |
81 | { | 81 | { |
82 | usercancel = 1; | 82 | usercancel = 1; |
83 | reset(); | 83 | reset(); |
84 | } | 84 | } |
85 | else accept(); | 85 | else accept(); |
86 | } | 86 | } |
87 | 87 | ||
88 | void Dialer::reset() | 88 | void Dialer::reset() |
89 | { | 89 | { |
90 | switchState(state_cancel); | 90 | switchState(state_cancel); |
91 | } | 91 | } |
92 | 92 | ||
93 | void Dialer::slotAutostart() | 93 | void Dialer::slotAutostart() |
94 | { | 94 | { |
95 | state = state_preinit; | 95 | state = state_preinit; |
96 | dial(m_profile.readEntry("Number")); | 96 | dial(m_profile.readEntry("Number")); |
97 | } | 97 | } |
98 | 98 | ||
99 | void Dialer::dial(const QString& number) | 99 | void Dialer::dial(const QString& number) |
100 | { | 100 | { |
101 | while(state != state_online) | 101 | while(state != state_online) |
102 | { | 102 | { |
103 | if(!usercancel) | 103 | if(!usercancel) |
104 | { | 104 | { |
105 | trydial(number); | 105 | trydial(number); |
106 | } | 106 | } |
107 | else break; | 107 | else break; |
108 | } | 108 | } |
109 | 109 | ||
110 | if(usercancel) | 110 | if(usercancel) |
111 | { | 111 | { |
112 | reject(); | 112 | reject(); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | void Dialer::trydial(const QString& number) | 116 | void Dialer::trydial(const QString& number) |
117 | { | 117 | { |
118 | if(state != state_cancel) | 118 | if(state != state_cancel) |
119 | { | 119 | { |
120 | switchState(state_preinit); | 120 | switchState(state_preinit); |
121 | // ... | 121 | // ... |
122 | QString response = receive(); | 122 | QString response = receive(); |
123 | } | 123 | } |
124 | 124 | ||
125 | if(state != state_cancel) | 125 | if(state != state_cancel) |
126 | { | 126 | { |
127 | switchState(state_init); | 127 | switchState(state_init); |
128 | send("ATZ"); | 128 | //send("ATZ"); |
129 | send(m_profile.readEntry("InitString")); | ||
129 | QString response2 = receive(); | 130 | QString response2 = receive(); |
130 | } | 131 | } |
131 | 132 | ||
132 | if(state != state_cancel) | 133 | if(state != state_cancel) |
133 | { | 134 | { |
134 | switchState(state_options); | 135 | switchState(state_options); |
135 | 136 | ||
136 | send("ATM0L0"); | 137 | send("ATM0L0"); |
137 | QString response3 = receive(); | 138 | QString response3 = receive(); |
138 | } | 139 | } |
139 | 140 | ||
140 | if(state != state_cancel) | 141 | if(state != state_cancel) |
141 | { | 142 | { |
142 | switchState(state_dialtone); | 143 | switchState(state_dialtone); |
143 | 144 | ||
144 | send("ATX1"); | 145 | send("ATX1"); |
145 | QString response4 = receive(); | 146 | QString response4 = receive(); |
146 | } | 147 | } |
147 | 148 | ||
148 | if(state != state_cancel) | 149 | if(state != state_cancel) |
149 | { | 150 | { |
150 | switchState(state_dialing); | 151 | switchState(state_dialing); |
151 | 152 | ||
152 | send(QString("ATDT %1").arg(number)); | 153 | send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); |
153 | QString response5 = receive(); | 154 | QString response5 = receive(); |
154 | } | 155 | } |
155 | 156 | ||
156 | if(state != state_cancel) | 157 | if(state != state_cancel) |
157 | { | 158 | { |
158 | switchState(state_online); | 159 | switchState(state_online); |
159 | } | 160 | } |
160 | } | 161 | } |
161 | 162 | ||
162 | void Dialer::send(const QString& msg) | 163 | void Dialer::send(const QString& msg) |
163 | { | 164 | { |
164 | QString m = msg; | 165 | QString m = msg; |
165 | int bytes; | 166 | int bytes; |
166 | QString termination; | 167 | QString termination; |
167 | 168 | ||
168 | termination = m_profile.readEntry("Termination"); | 169 | termination = m_profile.readEntry("Termination"); |
169 | if(termination == "\n") m = m + "\n"; | 170 | if(termination == "\n") m = m + "\n"; |
170 | else if(termination == "\r") m = m + "\r"; | 171 | else if(termination == "\r") m = m + "\r"; |
171 | else m = m + "\r\n"; | 172 | else m = m + "\r\n"; |
172 | 173 | ||
173 | bytes = write(0, m.local8Bit(), strlen(m.local8Bit())); | 174 | bytes = write(0, m.local8Bit(), strlen(m.local8Bit())); |
174 | if(bytes < 0) | 175 | if(bytes < 0) |
175 | { | 176 | { |
176 | reset(); | 177 | reset(); |
177 | } | 178 | } |
178 | } | 179 | } |
179 | 180 | ||
180 | QString Dialer::receive() | 181 | QString Dialer::receive() |
181 | { | 182 | { |
182 | for(int i = 0; i < 200000;i++) | 183 | for(int i = 0; i < 200000;i++) |
183 | qApp->processEvents(); | 184 | qApp->processEvents(); |
184 | return QString::null; | 185 | return QString::null; |
185 | } | 186 | } |
186 | 187 | ||
187 | void Dialer::switchState(int newstate) | 188 | void Dialer::switchState(int newstate) |
188 | { | 189 | { |
189 | int oldstate = state; | 190 | int oldstate = state; |
190 | state = newstate; | 191 | state = newstate; |
191 | 192 | ||
192 | switch(state) | 193 | switch(state) |
193 | { | 194 | { |
194 | case state_cancel: | 195 | case state_cancel: |
195 | status->setText(QObject::tr("Cancelling...")); | 196 | status->setText(QObject::tr("Cancelling...")); |
196 | progress->setProgress(0); | 197 | progress->setProgress(0); |
197 | break; | 198 | break; |
198 | case state_preinit: | 199 | case state_preinit: |
199 | status->setText(QObject::tr("Searching modem")); | 200 | status->setText(QObject::tr("Searching modem")); |
200 | progress->setProgress(10); | 201 | progress->setProgress(10); |