get username from getlogin(), $LOGNAME, $USER, $LNAME, $USERNAME.

This commit is contained in:
Huang Peng 2008-08-04 21:04:48 +08:00
Родитель b5bd6f1aad
Коммит 66d293363d
2 изменённых файлов: 26 добавлений и 3 удалений

Просмотреть файл

@ -204,7 +204,7 @@ _ibus_im_client_ibus_open (IBusIMClient *client)
}
#endif
if (ibus_addr == NULL) {
gchar *display, *host, *id;
gchar *display, *host, *id, *username;
display = g_strdup (g_getenv ("DISPLAY"));
if (display != NULL) {
id = host = display;
@ -219,7 +219,18 @@ _ibus_im_client_ibus_open (IBusIMClient *client)
else {
host = id = "";
}
ibus_addr = g_strdup_printf ("unix:path=/tmp/ibus-%s/ibus-%s-%s", getlogin (), host, id);
username = getlogin();
if (username == NULL)
username = getenv("LOGNAME");
if (username == NULL)
username = getenv("USER");
if (username == NULL)
username = getenv("LNAME");
if (username == NULL)
username = getenv("USERNAME");
ibus_addr = g_strdup_printf ("unix:path=/tmp/ibus-%s/ibus-%s-%s", username, host, id);
g_free (display);
}

Просмотреть файл

@ -332,6 +332,7 @@ IBusClient::connectToBus ()
{
QString address;
QString session;
QString username;
QDBusConnection *connection = NULL;
if (ibus != NULL)
@ -339,7 +340,18 @@ IBusClient::connectToBus ()
session = getenv ("DISPLAY");
session.replace (":", "-");
address = QString("unix:path=/tmp/ibus-%1/ibus-%2").arg (getlogin(), session);
username = getlogin ();
if (username.isNull ())
username = getenv ("LOGNAME");
if (username.isNull ())
username = getenv ("USER");
if (username.isNull ())
username = getenv ("LNAME");
if (username.isNull ())
username = getenv ("USERNAME");
address = QString("unix:path=/tmp/ibus-%1/ibus-%2").arg (username, session);
connection = new QDBusConnection (
QDBusConnection::connectToBus (
address,