1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
/*
* This file is part of Magellan <http://www.kAlliance.org/Magellan>
*
* Copyright (c) 1998-2000 Teodor Mihai <teddy@ireland.com>
* Copyright (c) 1998-2000 Laur Ivan <laur.ivan@ul.ie>
* Copyright (c) 1999-2000 Virgil Palanciuc <vv@ulise.cs.pub.ro>
*
* Requires the Qt widget libraries, available at no cost at
* http://www.troll.no/
*
* Also requires the KDE libraries, available at no cost at
* http://www.kde.org/
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <names.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/utsname.h>
QString Names::systemUserName()
{
QString name;
struct passwd *pw=getpwuid(getuid());
if(pw)
name=pw->pw_gecos;
else
name="user";
return name;
}
QString Names::systemLoginName()
{
QString user;
struct passwd *pw=getpwuid(getuid());
if(pw)
user=pw->pw_name;
else
user="User Name";
return user;
}
QString Names::systemHostName()
{
char buf[50];
struct utsname ubuf;
QString host;
if(uname(&ubuf)==-1)
{
if(gethostname(buf, 50)==0)
host=buf;
}
else
{
host=ubuf.nodename;
}
if(host.isEmpty())
host=getenv("HOSTNAME");
return host;
}
QString Names::systemDomainName()
{
char buf[51];
struct utsname ubuf;
QString domain;
#ifdef OS_FREEBSD
if(getdomainname(buf, 50)==0)
domain=buf;
#else
if(uname(&ubuf)==-1)
{
if(getdomainname(buf, 50)==0)
domain=buf;
}
else
{
#ifdef __USE_GNU
domain=ubuf.domainname;
#else
domain=ubuf.__domainname;
#endif
}
#endif
return domain;
}
QString Names::systemHostDomainName()
{
QString hostdomain;
QString domain=Names::systemDomainName();
if(domain.isEmpty())
hostdomain=Names::systemHostName();
else
hostdomain=Names::systemHostName()+"."+Names::systemDomainName();
return hostdomain;
}
QString Names::systemPOP3ServerName()
{
// here we should query the KDE default POP3 server, when they'll publish the API
return systemHostName();
}
QString Names::systemIMAP4ServerName()
{
// ..KDE
return systemHostName();
}
QString Names::systemSMTPServerName()
{
// ..KDE
return systemHostName();
}
QString Names::systemMailbox()
{
QString mailbox="/var/spool/mail/"+systemLoginName();
return mailbox;
}
QString Names::systemServerLoginName()
{
// ..KDE
return systemLoginName();
}
QString Names::systemFullFromAddress()
{
// .. KDE
// we prefer user@domain instead of user@host.domain
QString from=systemUserName()+" <"+systemLoginName()+"@"+systemHostDomainName()+">";
return from;
}
QString Names::systemFromAddress()
{
// .. KDE
QString from=systemLoginName()+"@"+systemHostDomainName();
return from;
}
QString Names::systemReplyAddress()
{
// ..KDE
return systemFromAddress();
}
QString Names::systemBugReportAddress()
{
// this is temporary
QString bugs="aethera@thekompany.com";
return bugs;
}
|