summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/filePermissions.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/filePermissions.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/filePermissions.cpp48
1 files changed, 22 insertions, 26 deletions
diff --git a/noncore/apps/advancedfm/filePermissions.cpp b/noncore/apps/advancedfm/filePermissions.cpp
index c06f14f..4de6d12 100644
--- a/noncore/apps/advancedfm/filePermissions.cpp
+++ b/noncore/apps/advancedfm/filePermissions.cpp
@@ -13,20 +13,16 @@
13****************************************************************************/ 13****************************************************************************/
14#include "filePermissions.h" 14#include "filePermissions.h"
15 15
16#include <qfile.h>
17#include <qfileinfo.h> 16#include <qfileinfo.h>
18 17
19#include <qcheckbox.h> 18#include <qcheckbox.h>
20#include <qlabel.h> 19#include <qlabel.h>
21#include <qlineedit.h> 20#include <qlineedit.h>
22#include <qlayout.h>
23#include <qvariant.h>
24#include <qtooltip.h>
25#include <qmessagebox.h> 21#include <qmessagebox.h>
26 22
27#include <unistd.h> 23#include <unistd.h>
28#include <sys/stat.h> 24#include <sys/stat.h>
29#include <stdlib.h> 25#include <stdlib.h>
30#include <sys/types.h> 26#include <sys/types.h>
31#include <pwd.h> 27#include <pwd.h>
32#include <grp.h> 28#include <grp.h>
@@ -70,23 +66,23 @@ filePermissions::filePermissions( QWidget* parent, const char* name, bool modal
70 connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); 66 connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck()));
71 67
72 CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); 68 CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" );
73 CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); 69 CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) );
74 connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); 70 connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck()));
75 71
76 CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); 72 CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" );
77 CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); 73 CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) );
78 connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); 74 connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck()));
79 75
80 CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); 76 CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" );
81 CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); 77 CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) );
82 connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); 78 connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck()));
83 79
84 CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); 80 CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" );
85 CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); 81 CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) );
86 connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); 82 connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck()));
87 83
88 CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); 84 CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" );
89 CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); 85 CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) );
90 connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); 86 connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck()));
91 87
92 CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); 88 CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" );
@@ -94,38 +90,38 @@ filePermissions::filePermissions( QWidget* parent, const char* name, bool modal
94 connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); 90 connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck()));
95 91
96 CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); 92 CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" );
97 CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); 93 CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) );
98 connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); 94 connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck()));
99 95
100 GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); 96 GroupLineEdit = new QLineEdit( this, "GroupLineEdit" );
101 GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); 97 GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) );
102 98
103 OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); 99 OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" );
104 OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); 100 OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) );
105 101
106 TextLabel5 = new QLabel( this, "TextLabel5" ); 102 TextLabel5 = new QLabel( this, "TextLabel5" );
107 TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); 103 TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) );
108 TextLabel5->setText( tr( "Owner" ) ); 104 TextLabel5->setText( tr( "Owner" ) );
109 105
110 TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); 106 TextLabel5_2 = new QLabel( this, "TextLabel5_2" );
111 TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); 107 TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) );
112 TextLabel5_2->setText( tr( "Group" ) ); 108 TextLabel5_2->setText( tr( "Group" ) );
113 109
114 ModeLine = new QLineEdit( this, "TextLabelMode" ); 110 ModeLine = new QLineEdit( this, "TextLabelMode" );
115 ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); 111 ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) );
116 112
117 TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); 113 TextLabel3_2 = new QLabel( this, "TextLabel3_2" );
118 TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); 114 TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) );
119 TextLabel3_2->setText( tr( "read" ) ); 115 TextLabel3_2->setText( tr( "read" ) );
120 TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); 116 TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
121 117
122 TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); 118 TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" );
123 TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); 119 TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) );
124 TextLabel3_2_2->setText( tr( "write" ) ); 120 TextLabel3_2_2->setText( tr( "write" ) );
125 TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); 121 TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
126 122
127 TextLabel3 = new QLabel( this, "TextLabel3" ); 123 TextLabel3 = new QLabel( this, "TextLabel3" );
128 TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); 124 TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) );
129 TextLabel3->setText( tr( "execute" ) ); 125 TextLabel3->setText( tr( "execute" ) );
130 TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); 126 TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
131 127
@@ -149,17 +145,17 @@ filePermissions::filePermissions( QWidget* parent, const char* name, bool modal
149 if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } 145 if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); }
150 if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } 146 if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); }
151 if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } 147 if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); }
152 148
153 stat(file.latin1(), &buf); 149 stat(file.latin1(), &buf);
154 mode = buf.st_mode; 150 mode = buf.st_mode;
155 modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); 151 modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) );
156 ModeLine->setText(modeStr); 152 ModeLine->setText(modeStr);
157 bool ok; 153 bool ok;
158 i_mode = modeStr.toInt(&ok,10); 154 i_mode = modeStr.toInt(&ok,10);
159 155
160} 156}
161 157
162/* 158/*
163 * Destroys the object and frees any allocated resources 159 * Destroys the object and frees any allocated resources
164 */ 160 */
165filePermissions::~filePermissions() 161filePermissions::~filePermissions()
@@ -248,25 +244,25 @@ void filePermissions::accept() {
248 pwd = getpwnam(OwnerLineEdit->text().latin1() ); 244 pwd = getpwnam(OwnerLineEdit->text().latin1() );
249 if(pwd == NULL) { 245 if(pwd == NULL) {
250 perror("getpwnam"); 246 perror("getpwnam");
251 QMessageBox::warning(this,"Warning","Error- no user"); 247 QMessageBox::warning(this,tr("Warning"),tr("Error- no user") );
252 return; 248 return;
253 } else { 249 } else {
254 grp = getgrnam(GroupLineEdit->text().latin1()); 250 grp = getgrnam(GroupLineEdit->text().latin1());
255 if(grp==NULL) { 251 if(grp==NULL) {
256 perror("getgrnam"); 252 perror("getgrnam");
257 QMessageBox::warning(this,"Warning","Error- no group"); 253 QMessageBox::warning(this,tr("Warning"),tr("Error- no group"));
258 return; 254 return;
259 } 255 }
260 if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { 256 if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) {
261 perror("chown"); 257 perror("chown");
262 QMessageBox::warning(this,"Warning","Error setting ownership or group"); 258 QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group") );
263 return; 259 return;
264 } 260 }
265 bool ok; 261 bool ok;
266 uint moder = modeStr.toUInt(&ok,8); 262 uint moder = modeStr.toUInt(&ok,8);
267 if( chmod( file.latin1(), moder) < 0) { 263 if( chmod( file.latin1(), moder) < 0) {
268 perror("chmod"); 264 perror("chmod");
269 QMessageBox::warning(this,"Warning","Error setting mode"); 265 QMessageBox::warning(this,tr("Warning"),tr("Error setting mode") );
270 return; 266 return;
271 } 267 }
272 } 268 }