-rw-r--r-- | core/apps/textedit/filePermissions.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/textedit/filePermissions.cpp b/core/apps/textedit/filePermissions.cpp index def957b..f1c78a1 100644 --- a/core/apps/textedit/filePermissions.cpp +++ b/core/apps/textedit/filePermissions.cpp | |||
@@ -1,274 +1,274 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2002 ljp ljp@llornkcor.com | 2 | ** copyright 2002 ljp ljp@llornkcor.com |
3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter | 3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qfileinfo.h> | 17 | #include <qfileinfo.h> |
18 | 18 | ||
19 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qvariant.h> | 23 | #include <qvariant.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | 26 | ||
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <sys/types.h> | 30 | #include <sys/types.h> |
31 | #include <pwd.h> | 31 | #include <pwd.h> |
32 | #include <grp.h> | 32 | #include <grp.h> |
33 | 33 | ||
34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | 34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) |
35 | : QDialog( parent, name, modal, fl ) | 35 | : QDialog( parent, name, modal, fl ) |
36 | { | 36 | { |
37 | if ( !name ) | 37 | if ( !name ) |
38 | setName( tr("filePermissions") ); | 38 | setName( tr("File Permissions") ); |
39 | // qDebug("FilePermissions "+fileName); | 39 | // qDebug("FilePermissions "+fileName); |
40 | resize( 236, 210 ); | 40 | resize( 236, 210 ); |
41 | setMaximumSize( QSize( 236, 210 ) ); | 41 | setMaximumSize( QSize( 236, 210 ) ); |
42 | setCaption( tr( "Set File Permissions" ) ); | 42 | setCaption( tr( "Set File Permissions" ) ); |
43 | 43 | ||
44 | TextLabel1 = new QLabel( this, "TextLabel1" ); | 44 | TextLabel1 = new QLabel( this, "TextLabel1" ); |
45 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); | 45 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); |
46 | TextLabel1->setText( tr( "Set file permissions for:" ) ); | 46 | TextLabel1->setText( tr( "Set file permissions for:" ) ); |
47 | 47 | ||
48 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 48 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
49 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); | 49 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); |
50 | LineEdit1->setReadOnly(true); | 50 | LineEdit1->setReadOnly(true); |
51 | 51 | ||
52 | TextLabel4 = new QLabel( this, "TextLabel4" ); | 52 | TextLabel4 = new QLabel( this, "TextLabel4" ); |
53 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); | 53 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); |
54 | TextLabel4->setText( tr( "owner" ) ); | 54 | TextLabel4->setText( tr( "owner" ) ); |
55 | 55 | ||
56 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); | 56 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); |
57 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); | 57 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); |
58 | TextLabel4_2->setText( tr( "group" ) ); | 58 | TextLabel4_2->setText( tr( "group" ) ); |
59 | 59 | ||
60 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); | 60 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); |
61 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); | 61 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); |
62 | TextLabel4_3->setText( tr( "others" ) ); | 62 | TextLabel4_3->setText( tr( "others" ) ); |
63 | 63 | ||
64 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); | 64 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); |
65 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); | 65 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); |
66 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); | 66 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); |
67 | 67 | ||
68 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); | 68 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); |
69 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); | 69 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); |
70 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); | 70 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); |
71 | 71 | ||
72 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); | 72 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); |
73 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); | 73 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); |
74 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); | 74 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); |
75 | 75 | ||
76 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); | 76 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); |
77 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); | 77 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); |
78 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); | 78 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); |
79 | 79 | ||
80 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); | 80 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); |
81 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); | 81 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); |
82 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); | 82 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); |
83 | 83 | ||
84 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); | 84 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); |
85 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); | 85 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); |
86 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); | 86 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); |
87 | 87 | ||
88 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); | 88 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); |
89 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); | 89 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); |
90 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); | 90 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); |
91 | 91 | ||
92 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); | 92 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); |
93 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); | 93 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); |
94 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); | 94 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); |
95 | 95 | ||
96 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); | 96 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); |
97 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); | 97 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); |
98 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); | 98 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); |
99 | 99 | ||
100 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); | 100 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); |
101 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); | 101 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); |
102 | 102 | ||
103 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); | 103 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); |
104 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); | 104 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); |
105 | 105 | ||
106 | TextLabel5 = new QLabel( this, "TextLabel5" ); | 106 | TextLabel5 = new QLabel( this, "TextLabel5" ); |
107 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); | 107 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); |
108 | TextLabel5->setText( tr( "Owner" ) ); | 108 | TextLabel5->setText( tr( "Owner" ) ); |
109 | 109 | ||
110 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); | 110 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); |
111 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); | 111 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); |
112 | TextLabel5_2->setText( tr( "Group" ) ); | 112 | TextLabel5_2->setText( tr( "Group" ) ); |
113 | 113 | ||
114 | ModeLine = new QLineEdit( this, "TextLabelMode" ); | 114 | ModeLine = new QLineEdit( this, "TextLabelMode" ); |
115 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); | 115 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); |
116 | 116 | ||
117 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); | 117 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); |
118 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); | 118 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); |
119 | TextLabel3_2->setText( tr( "read" ) ); | 119 | TextLabel3_2->setText( tr( "read" ) ); |
120 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 120 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
121 | 121 | ||
122 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); | 122 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); |
123 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); | 123 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); |
124 | TextLabel3_2_2->setText( tr( "write" ) ); | 124 | TextLabel3_2_2->setText( tr( "write" ) ); |
125 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 125 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
126 | 126 | ||
127 | TextLabel3 = new QLabel( this, "TextLabel3" ); | 127 | TextLabel3 = new QLabel( this, "TextLabel3" ); |
128 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); | 128 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); |
129 | TextLabel3->setText( tr( "execute" ) ); | 129 | TextLabel3->setText( tr( "execute" ) ); |
130 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 130 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
131 | 131 | ||
132 | struct stat buf; | 132 | struct stat buf; |
133 | mode_t mode; | 133 | mode_t mode; |
134 | file = fileName; | 134 | file = fileName; |
135 | QFileInfo fi(file); | 135 | QFileInfo fi(file); |
136 | 136 | ||
137 | LineEdit1->setText( file); | 137 | LineEdit1->setText( file); |
138 | OwnerLineEdit->setText( fi.owner()); | 138 | OwnerLineEdit->setText( fi.owner()); |
139 | GroupLineEdit->setText( fi.group()); | 139 | GroupLineEdit->setText( fi.group()); |
140 | 140 | ||
141 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } | 141 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } |
142 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } | 142 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } |
143 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } | 143 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } |
144 | 144 | ||
145 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } | 145 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } |
146 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } | 146 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } |
147 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } | 147 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } |
148 | 148 | ||
149 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } | 149 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } |
150 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } | 150 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } |
151 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } | 151 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } |
152 | 152 | ||
153 | stat(file.latin1(), &buf); | 153 | stat(file.latin1(), &buf); |
154 | mode = buf.st_mode; | 154 | mode = buf.st_mode; |
155 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); | 155 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); |
156 | ModeLine->setText(modeStr); | 156 | ModeLine->setText(modeStr); |
157 | bool ok; | 157 | bool ok; |
158 | i_mode = modeStr.toInt(&ok,10); | 158 | i_mode = modeStr.toInt(&ok,10); |
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | /* | 162 | /* |
163 | * Destroys the object and frees any allocated resources | 163 | * Destroys the object and frees any allocated resources |
164 | */ | 164 | */ |
165 | filePermissions::~filePermissions() | 165 | filePermissions::~filePermissions() |
166 | { | 166 | { |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | // might this be better as a callback routine??? | 170 | // might this be better as a callback routine??? |
171 | void filePermissions::ownReadCheck() { | 171 | void filePermissions::ownReadCheck() { |
172 | if(CheckBox1->isChecked()) { i_mode +=400; } | 172 | if(CheckBox1->isChecked()) { i_mode +=400; } |
173 | else i_mode -=400; | 173 | else i_mode -=400; |
174 | modeStr.sprintf("0%d",i_mode); | 174 | modeStr.sprintf("0%d",i_mode); |
175 | ModeLine->setText( modeStr); | 175 | ModeLine->setText( modeStr); |
176 | // 0400 | 176 | // 0400 |
177 | } | 177 | } |
178 | 178 | ||
179 | void filePermissions::ownWriteCheck() { | 179 | void filePermissions::ownWriteCheck() { |
180 | if(CheckBox1_2->isChecked()) { i_mode +=200; } | 180 | if(CheckBox1_2->isChecked()) { i_mode +=200; } |
181 | else i_mode -=200; | 181 | else i_mode -=200; |
182 | modeStr.sprintf("0%d",i_mode); | 182 | modeStr.sprintf("0%d",i_mode); |
183 | ModeLine->setText(modeStr); | 183 | ModeLine->setText(modeStr); |
184 | // 0200 | 184 | // 0200 |
185 | } | 185 | } |
186 | 186 | ||
187 | void filePermissions::ownExeCheck() { | 187 | void filePermissions::ownExeCheck() { |
188 | if(CheckBox1_3->isChecked()) { i_mode +=100; } | 188 | if(CheckBox1_3->isChecked()) { i_mode +=100; } |
189 | else i_mode -=100; | 189 | else i_mode -=100; |
190 | modeStr.sprintf("0%d",i_mode); | 190 | modeStr.sprintf("0%d",i_mode); |
191 | ModeLine->setText(modeStr); | 191 | ModeLine->setText(modeStr); |
192 | // 0100 | 192 | // 0100 |
193 | } | 193 | } |
194 | 194 | ||
195 | void filePermissions::grpReadCheck() { | 195 | void filePermissions::grpReadCheck() { |
196 | if(CheckBox1_4->isChecked()) { i_mode +=40; } | 196 | if(CheckBox1_4->isChecked()) { i_mode +=40; } |
197 | else i_mode -=40; | 197 | else i_mode -=40; |
198 | modeStr.sprintf("0%d",i_mode); | 198 | modeStr.sprintf("0%d",i_mode); |
199 | ModeLine->setText(modeStr); | 199 | ModeLine->setText(modeStr); |
200 | // 0040 | 200 | // 0040 |
201 | } | 201 | } |
202 | 202 | ||
203 | void filePermissions::grpWriteCheck() { | 203 | void filePermissions::grpWriteCheck() { |
204 | if(CheckBox1_5->isChecked()) { i_mode +=20; } | 204 | if(CheckBox1_5->isChecked()) { i_mode +=20; } |
205 | else i_mode -=20; | 205 | else i_mode -=20; |
206 | modeStr.sprintf("0%d",i_mode); | 206 | modeStr.sprintf("0%d",i_mode); |
207 | ModeLine->setText(modeStr); | 207 | ModeLine->setText(modeStr); |
208 | // 0020 | 208 | // 0020 |
209 | } | 209 | } |
210 | 210 | ||
211 | void filePermissions::grpExeCheck() { | 211 | void filePermissions::grpExeCheck() { |
212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } | 212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } |
213 | else i_mode -=10; | 213 | else i_mode -=10; |
214 | modeStr.sprintf("0%d",i_mode); | 214 | modeStr.sprintf("0%d",i_mode); |
215 | ModeLine->setText(modeStr); | 215 | ModeLine->setText(modeStr); |
216 | // 0010 | 216 | // 0010 |
217 | } | 217 | } |
218 | 218 | ||
219 | void filePermissions::wrldReadCheck() { | 219 | void filePermissions::wrldReadCheck() { |
220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } | 220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } |
221 | else i_mode -=4; | 221 | else i_mode -=4; |
222 | modeStr.sprintf("0%d",i_mode); | 222 | modeStr.sprintf("0%d",i_mode); |
223 | ModeLine->setText(modeStr); | 223 | ModeLine->setText(modeStr); |
224 | // 0004 | 224 | // 0004 |
225 | } | 225 | } |
226 | 226 | ||
227 | void filePermissions::wrldWriteCheck() { | 227 | void filePermissions::wrldWriteCheck() { |
228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } | 228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } |
229 | else i_mode -=2; | 229 | else i_mode -=2; |
230 | modeStr.sprintf("0%d",i_mode); | 230 | modeStr.sprintf("0%d",i_mode); |
231 | ModeLine->setText(modeStr); | 231 | ModeLine->setText(modeStr); |
232 | // 0002 | 232 | // 0002 |
233 | } | 233 | } |
234 | 234 | ||
235 | void filePermissions::wrldExeCheck() { | 235 | void filePermissions::wrldExeCheck() { |
236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } | 236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } |
237 | else i_mode -=1; | 237 | else i_mode -=1; |
238 | modeStr.sprintf("0%d",i_mode); | 238 | modeStr.sprintf("0%d",i_mode); |
239 | ModeLine->setText(modeStr); | 239 | ModeLine->setText(modeStr); |
240 | // 0001 | 240 | // 0001 |
241 | } | 241 | } |
242 | 242 | ||
243 | void filePermissions::accept() { | 243 | void filePermissions::accept() { |
244 | 244 | ||
245 | QFileInfo fi(file); | 245 | QFileInfo fi(file); |
246 | struct passwd *pwd=0; | 246 | struct passwd *pwd=0; |
247 | struct group *grp=0; | 247 | struct group *grp=0; |
248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); | 248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); |
249 | if(pwd == NULL) { | 249 | if(pwd == NULL) { |
250 | perror("getpwnam"); | 250 | perror("getpwnam"); |
251 | QMessageBox::warning(this,tr("Warning"),tr("Error- no user")); | 251 | QMessageBox::warning(this,tr("Warning"),tr("Error- no user")); |
252 | return; | 252 | return; |
253 | } else { | 253 | } else { |
254 | grp = getgrnam(GroupLineEdit->text().latin1()); | 254 | grp = getgrnam(GroupLineEdit->text().latin1()); |
255 | if(grp==NULL) { | 255 | if(grp==NULL) { |
256 | perror("getgrnam"); | 256 | perror("getgrnam"); |
257 | QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); | 257 | QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { | 260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { |
261 | perror("chown"); | 261 | perror("chown"); |
262 | QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group")); | 262 | QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group")); |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | bool ok; | 265 | bool ok; |
266 | uint moder = modeStr.toUInt(&ok,8); | 266 | uint moder = modeStr.toUInt(&ok,8); |
267 | if( chmod( file.latin1(), moder) < 0) { | 267 | if( chmod( file.latin1(), moder) < 0) { |
268 | perror("chmod"); | 268 | perror("chmod"); |
269 | QMessageBox::warning(this,tr("Warning"),tr("Error setting mode")); | 269 | QMessageBox::warning(this,tr("Warning"),tr("Error setting mode")); |
270 | return; | 270 | return; |
271 | } | 271 | } |
272 | } | 272 | } |
273 | close(); | 273 | close(); |
274 | } | 274 | } |