KDevelop API Documentation

parts/appwizard/misc.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2002 by Bernd Gehrmann and Harald Fernengel * 00003 * bernd@kdevelop.org, harry@kdevelop.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 ***************************************************************************/ 00011 00012 #include "misc.h" 00013 00014 #include <qstring.h> 00015 #include <kemailsettings.h> 00016 00017 #include <pwd.h> 00018 #include <sys/types.h> 00019 #include <unistd.h> 00020 #include <kglobal.h> 00021 #include <kstandarddirs.h> 00022 #include <kconfig.h> 00023 00024 void AppWizardUtil::guessAuthorAndEmail(QString *author, QString *email) 00025 { 00026 KEMailSettings emailConfig; 00027 emailConfig.setProfile( emailConfig.defaultProfileName() ); 00028 QString fromAddr = emailConfig.getSetting( KEMailSettings::EmailAddress ); 00029 QString name = emailConfig.getSetting( KEMailSettings::RealName ); 00030 00031 if ( !fromAddr.isEmpty() && !name.isEmpty() ) { 00032 *author = name; 00033 *email = fromAddr; 00034 return; 00035 } 00036 00037 struct passwd *pw = ::getpwuid(getuid()); 00038 // pw==0 => the system must be really fucked up 00039 if (!pw) 00040 return; 00041 00042 char hostname[512]; 00043 00044 // I guess we don't have to support users with longer host names ;-) 00045 (void) ::gethostname(hostname, sizeof hostname); 00046 00047 if ( name.isEmpty() ) 00048 *author = QString::fromLocal8Bit( pw->pw_gecos ); 00049 else 00050 *author = name; 00051 if ( fromAddr.isEmpty() ) 00052 *email = QString(pw->pw_name) + "@" + hostname; 00053 else 00054 *email = fromAddr; 00055 } 00056
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:09 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003