View | Details | Raw Unified
Collapse All | Expand All

(-) kfrontend/kgreeter.cpp (-9 / +43 lines)
 Lines 42-47    Link Here 
#undef Unsorted // x headers suck - make qdir.h work with --enable-final
#undef Unsorted // x headers suck - make qdir.h work with --enable-final
#include <qdir.h>
#include <qdir.h>
#include <qfile.h>
#include <qfile.h>
#include <qbuffer.h>
#include <qmemarray.h>
#include <qimage.h>
#include <qimage.h>
#include <qmovie.h>
#include <qmovie.h>
#include <qpopupmenu.h>
#include <qpopupmenu.h>
 Lines 59-64    Link Here 
#include <grp.h>
#include <grp.h>
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/types.h>
#include <X11/Xlib.h>
#include <X11/Xlib.h>
 Lines 163-168    Link Here 
	QString login;
	QString login;
};
};
#define FILE_LIMIT_ICON 20
#define FILE_LIMIT_IMAGE 200
void
void
KGreeter::insertUser( const QImage &default_pix,
KGreeter::insertUser( const QImage &default_pix,
                      const QString &username, struct passwd *ps )
                      const QString &username, struct passwd *ps )
 Lines 181-196    Link Here 
		nd = 1;
		nd = 1;
	QImage p;
	QImage p;
	do {
	do {
		QString fn = dp ?
		dp ^= 1;
		             QFile::decodeName( ps->pw_dir ) + "/.face" :
		QCString fn = !dp ?
		             _faceDir + '/' + username + ".face";
		              QCString( ps->pw_dir ) + '/' :
		if (p.load( fn + ".icon" ) || p.load( fn )) {
		              QFile::encodeName( _faceDir + '/' + username );
			QSize ns( 48, 48 );
		fn += ".face.icon";
			if (p.size() != ns)
		int fd, ico;
				p = p.convertDepth( 32 ).smoothScale( ns, QImage::ScaleMin );
		if ((fd = open( fn.data(), O_RDONLY | O_NONBLOCK )) < 0) {
			goto gotit;
			fn.truncate( fn.length() - 5 );
			if ((fd = open( fn.data(), O_RDONLY | O_NONBLOCK )) < 0)
				continue;
			ico = 0;
		} else
			ico = 1;
		QFile f;
		f.open( IO_ReadOnly, fd );
		int fs = f.size();
		if (fs > (ico ? FILE_LIMIT_ICON : FILE_LIMIT_IMAGE) * 1000) {
			LogWarn( "%s exceeds file size limit (%dkB)\n",
			         fn.data(), ico ? FILE_LIMIT_ICON : FILE_LIMIT_IMAGE );
			continue;
		}
		}
		dp = 1 - dp;
		QByteArray fc( fs );
		int rfs = f.readBlock( fc.data(), fs );
		::close( fd );
		fc.resize( rfs > 0 ? rfs : 0 );
		QBuffer buf( fc );
		buf.open( IO_ReadOnly );
		QImageIO ir;
		ir.setIODevice( &buf );
		if (!ir.read()) {
			LogInfo( "%s is no valid image\n", fn.data() );
			continue;
		}
		p = ir.image();
		QSize ns( 48, 48 );
		if (p.size() != ns)
			p = p.convertDepth( 32 ).smoothScale( ns, QImage::ScaleMin );
		goto gotit;
	} while (--nd >= 0);
	} while (--nd >= 0);
	p = default_pix;
	p = default_pix;
  gotit:
  gotit: