Changeset View
Changeset View
Standalone View
Standalone View
src/kcms/kio/smbrodlg.cpp
Show All 12 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
13 | Library General Public License for more details. | 13 | Library General Public License for more details. | ||
14 | 14 | | |||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | // TODO: remove me | | |||
22 | #undef QT_NO_CAST_FROM_ASCII | | |||
23 | | ||||
24 | // Own | 21 | // Own | ||
25 | #include "smbrodlg.h" | 22 | #include "smbrodlg.h" | ||
26 | 23 | | |||
27 | // Qt | 24 | // Qt | ||
28 | #include <QTextCodec> | 25 | #include <QTextCodec> | ||
29 | #include <QLabel> | 26 | #include <QLabel> | ||
30 | #include <QGridLayout> | 27 | #include <QGridLayout> | ||
31 | 28 | | |||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 103 | // m_showHiddenShares->setChecked(group.readEntry("ShowHiddenShares", QVariant(false)).toBool()); | |||
117 | for (int i=0; i<passwordLength; ++i) { | 114 | for (int i=0; i<passwordLength; ++i) { | ||
118 | QChar qc1 = scrambled[i*3]; | 115 | QChar qc1 = scrambled[i*3]; | ||
119 | QChar qc2 = scrambled[i*3+1]; | 116 | QChar qc2 = scrambled[i*3+1]; | ||
120 | QChar qc3 = scrambled[i*3+2]; | 117 | QChar qc3 = scrambled[i*3+2]; | ||
121 | unsigned int a1 = qc1.toLatin1() - '0'; | 118 | unsigned int a1 = qc1.toLatin1() - '0'; | ||
122 | unsigned int a2 = qc2.toLatin1() - 'A'; | 119 | unsigned int a2 = qc2.toLatin1() - 'A'; | ||
123 | unsigned int a3 = qc3.toLatin1() - '0'; | 120 | unsigned int a3 = qc3.toLatin1() - '0'; | ||
124 | unsigned int num = ((a1 & 0x3F) << 10) | ((a2& 0x1F) << 5) | (a3 & 0x1F); | 121 | unsigned int num = ((a1 & 0x3F) << 10) | ((a2& 0x1F) << 5) | (a3 & 0x1F); | ||
125 | password[i] = QChar((uchar)((num - 17) ^ 173)); // restore | 122 | password[i] = QLatin1Char((num - 17) ^ 173); // restore | ||
dfaure: You could remove the QChar() around I guess. | |||||
ahmadsamir: You're just being polite. | |||||
126 | } | 123 | } | ||
127 | m_passwordLe->setText(password); | 124 | m_passwordLe->setText(password); | ||
128 | 125 | | |||
129 | delete cfg; | 126 | delete cfg; | ||
130 | } | 127 | } | ||
131 | 128 | | |||
132 | void SMBRoOptions::save() | 129 | void SMBRoOptions::save() | ||
133 | { | 130 | { | ||
Show All 10 Lines | 137 | // group.writeEntry( "Encoding", m_encodingList->currentText() ); | |||
144 | //least better than storing the plain password | 141 | //least better than storing the plain password | ||
145 | QString password(m_passwordLe->text()); | 142 | QString password(m_passwordLe->text()); | ||
146 | QString scrambled; | 143 | QString scrambled; | ||
147 | for (const QChar c : qAsConst(password)) { | 144 | for (const QChar c : qAsConst(password)) { | ||
148 | unsigned int num = (c.unicode() ^ 173) + 17; | 145 | unsigned int num = (c.unicode() ^ 173) + 17; | ||
149 | unsigned int a1 = (num & 0xFC00) >> 10; | 146 | unsigned int a1 = (num & 0xFC00) >> 10; | ||
150 | unsigned int a2 = (num & 0x3E0) >> 5; | 147 | unsigned int a2 = (num & 0x3E0) >> 5; | ||
151 | unsigned int a3 = (num & 0x1F); | 148 | unsigned int a3 = (num & 0x1F); | ||
152 | scrambled += (char)(a1+'0'); | 149 | scrambled += QLatin1Char((char)(a1+'0')); | ||
153 | scrambled += (char)(a2+'A'); | 150 | scrambled += QLatin1Char((char)(a2+'A')); | ||
154 | scrambled += (char)(a3+'0'); | 151 | scrambled += QLatin1Char((char)(a3+'0')); | ||
155 | } | 152 | } | ||
156 | group.writeEntry( "Password", scrambled); | 153 | group.writeEntry( "Password", scrambled); | ||
157 | 154 | | |||
158 | delete cfg; | 155 | delete cfg; | ||
159 | } | 156 | } | ||
160 | 157 | | |||
161 | void SMBRoOptions::defaults() | 158 | void SMBRoOptions::defaults() | ||
162 | { | 159 | { | ||
Show All 23 Lines |
You could remove the QChar() around I guess.