3 Copyright (C) 2005-2006 Oswald Buddenhagen <ossi@kde.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "kdm_greet.h"
28 QString
qString( char *str
)
32 QString qs
= QString::fromUtf8( str
);
37 QStringList
qStringList( char **strList
)
40 for (int i
= 0; strList
[i
]; i
++) {
41 qsl
.append( QString::fromUtf8( strList
[i
] ) );
49 fetchSessions( int flags
)
51 QList
<DpySpec
> sessions
;
58 while (!(tsess
.display
= qString( gRecvStr() )).isEmpty()) {
59 tsess
.from
= qString( gRecvStr() );
61 tsess
.vt
= gRecvInt();
63 tsess
.user
= qString( gRecvStr() );
64 tsess
.session
= qString( gRecvStr() );
65 tsess
.flags
= gRecvInt();
66 if ((tsess
.flags
& isTTY
) && !tsess
.from
.isEmpty())
67 for (int i
= 0; i
< sessions
.size(); i
++)
68 if (!sessions
[i
].user
.isEmpty() &&
69 sessions
[i
].user
== tsess
.user
&&
70 sessions
[i
].from
== tsess
.from
)
76 sessions
.append( tsess
);
83 decodeSession( const DpySpec
&sess
, QString
&user
, QString
&loc
)
85 if (sess
.flags
& isTTY
) {
87 i18ncp( "user: ...", "%2: TTY login", "%2: %1 TTY logins",
88 sess
.count
, sess
.user
);
92 QString("vt%1").arg( sess
.vt
) :
94 !sess
.from
.isEmpty() ?
95 sess
.from
: sess
.display
;
98 sess
.session
.isEmpty() ?
99 i18nc("... session", "Unused") :
100 !sess
.user
.isEmpty() ?
101 i18nc( "user: session type", "%1: %2",
102 sess
.user
, sess
.session
) :
103 i18nc( "... host", "X login on %1", sess
.session
);
107 QString("%1, vt%2").arg( sess
.display
).arg( sess
.vt
) :