misc.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
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
00039 if (!pw)
00040 return;
00041
00042 char hostname[512];
00043
00044
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
This file is part of the documentation for KDevelop Version 3.1.2.