|
Lines 42-47
Link Here
|
| 42 |
#undef Unsorted // x headers suck - make qdir.h work with --enable-final |
42 |
#undef Unsorted // x headers suck - make qdir.h work with --enable-final |
| 43 |
#include <qdir.h> |
43 |
#include <qdir.h> |
| 44 |
#include <qfile.h> |
44 |
#include <qfile.h> |
|
|
45 |
#include <qbuffer.h> |
| 46 |
#include <qmemarray.h> |
| 45 |
#include <qimage.h> |
47 |
#include <qimage.h> |
| 46 |
#include <qmovie.h> |
48 |
#include <qmovie.h> |
| 47 |
#include <qpopupmenu.h> |
49 |
#include <qpopupmenu.h> |
|
Lines 59-64
Link Here
|
| 59 |
#include <grp.h> |
61 |
#include <grp.h> |
| 60 |
#include <stdlib.h> |
62 |
#include <stdlib.h> |
| 61 |
#include <unistd.h> |
63 |
#include <unistd.h> |
|
|
64 |
#include <fcntl.h> |
| 62 |
#include <sys/types.h> |
65 |
#include <sys/types.h> |
| 63 |
|
66 |
|
| 64 |
#include <X11/Xlib.h> |
67 |
#include <X11/Xlib.h> |
|
Lines 163-168
Link Here
|
| 163 |
QString login; |
166 |
QString login; |
| 164 |
}; |
167 |
}; |
| 165 |
|
168 |
|
|
|
169 |
#define FILE_LIMIT_ICON 20 |
| 170 |
#define FILE_LIMIT_IMAGE 200 |
| 171 |
|
| 166 |
void |
172 |
void |
| 167 |
KGreeter::insertUser( const QImage &default_pix, |
173 |
KGreeter::insertUser( const QImage &default_pix, |
| 168 |
const QString &username, struct passwd *ps ) |
174 |
const QString &username, struct passwd *ps ) |
|
Lines 181-196
Link Here
|
| 181 |
nd = 1; |
187 |
nd = 1; |
| 182 |
QImage p; |
188 |
QImage p; |
| 183 |
do { |
189 |
do { |
| 184 |
QString fn = dp ? |
190 |
dp ^= 1; |
| 185 |
QFile::decodeName( ps->pw_dir ) + "/.face" : |
191 |
QCString fn = !dp ? |
| 186 |
_faceDir + '/' + username + ".face"; |
192 |
QCString( ps->pw_dir ) + '/' : |
| 187 |
if (p.load( fn + ".icon" ) || p.load( fn )) { |
193 |
QFile::encodeName( _faceDir + '/' + username ); |
| 188 |
QSize ns( 48, 48 ); |
194 |
fn += ".face.icon"; |
| 189 |
if (p.size() != ns) |
195 |
int fd, ico; |
| 190 |
p = p.convertDepth( 32 ).smoothScale( ns, QImage::ScaleMin ); |
196 |
if ((fd = open( fn.data(), O_RDONLY | O_NONBLOCK )) < 0) { |
| 191 |
goto gotit; |
197 |
fn.truncate( fn.length() - 5 ); |
|
|
198 |
if ((fd = open( fn.data(), O_RDONLY | O_NONBLOCK )) < 0) |
| 199 |
continue; |
| 200 |
ico = 0; |
| 201 |
} else |
| 202 |
ico = 1; |
| 203 |
QFile f; |
| 204 |
f.open( IO_ReadOnly, fd ); |
| 205 |
int fs = f.size(); |
| 206 |
if (fs > (ico ? FILE_LIMIT_ICON : FILE_LIMIT_IMAGE) * 1000) { |
| 207 |
LogWarn( "%s exceeds file size limit (%dkB)\n", |
| 208 |
fn.data(), ico ? FILE_LIMIT_ICON : FILE_LIMIT_IMAGE ); |
| 209 |
continue; |
| 192 |
} |
210 |
} |
| 193 |
dp = 1 - dp; |
211 |
QByteArray fc( fs ); |
|
|
212 |
int rfs = f.readBlock( fc.data(), fs ); |
| 213 |
::close( fd ); |
| 214 |
fc.resize( rfs > 0 ? rfs : 0 ); |
| 215 |
QBuffer buf( fc ); |
| 216 |
buf.open( IO_ReadOnly ); |
| 217 |
QImageIO ir; |
| 218 |
ir.setIODevice( &buf ); |
| 219 |
if (!ir.read()) { |
| 220 |
LogInfo( "%s is no valid image\n", fn.data() ); |
| 221 |
continue; |
| 222 |
} |
| 223 |
p = ir.image(); |
| 224 |
QSize ns( 48, 48 ); |
| 225 |
if (p.size() != ns) |
| 226 |
p = p.convertDepth( 32 ).smoothScale( ns, QImage::ScaleMin ); |
| 227 |
goto gotit; |
| 194 |
} while (--nd >= 0); |
228 |
} while (--nd >= 0); |
| 195 |
p = default_pix; |
229 |
p = default_pix; |
| 196 |
gotit: |
230 |
gotit: |