Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
80f658e8
Commit
80f658e8
authored
7 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
ServerInfo: Add server uptime info
parent
3c823d30
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gajim/server_info.py
+39
-2
39 additions, 2 deletions
gajim/server_info.py
with
39 additions
and
2 deletions
gajim/server_info.py
+
39
−
2
View file @
80f658e8
...
...
@@ -18,14 +18,19 @@
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
from
collections
import
namedtuple
from
datetime
import
timedelta
import
nbxmpp
import
logging
from
gi.repository
import
Gtk
from
gajim.common
import
app
from
gajim.common
import
ged
from
gajim.gtkgui_helpers
import
get_icon_pixmap
,
Color
log
=
logging
.
getLogger
(
'
gajim.serverinfo
'
)
class
ServerInfoDialog
(
Gtk
.
Dialog
):
def
__init__
(
self
,
account
):
flags
=
Gtk
.
DialogFlags
.
DESTROY_WITH_PARENT
...
...
@@ -67,8 +72,10 @@ class ServerInfoDialog(Gtk.Dialog):
self
.
_nec_agent_info_received
)
self
.
version
=
''
self
.
uptime
=
''
self
.
hostname
=
app
.
get_hostname_from_account
(
account
)
app
.
connections
[
account
].
request_os_info
(
self
.
hostname
,
None
)
self
.
request_last_activity
()
for
feature
in
self
.
get_features
():
self
.
add_feature
(
feature
)
...
...
@@ -94,6 +101,35 @@ class ServerInfoDialog(Gtk.Dialog):
row
.
get_child
().
update
(
item
)
row
.
set_tooltip_text
(
item
.
tooltip
)
def
request_last_activity
(
self
):
if
not
app
.
account_is_connected
(
self
.
account
):
return
con
=
app
.
connections
[
self
.
account
]
iq
=
nbxmpp
.
Iq
(
to
=
self
.
hostname
,
typ
=
'
get
'
,
queryNS
=
nbxmpp
.
NS_LAST
)
con
.
connection
.
SendAndCallForResponse
(
iq
,
self
.
_on_last_activity
)
def
_on_last_activity
(
self
,
stanza
):
if
'
server_info
'
not
in
app
.
interface
.
instances
[
self
.
account
]:
# Window got closed in the meantime
return
if
not
nbxmpp
.
isResultNode
(
stanza
):
log
.
warning
(
'
Received malformed result: %s
'
,
stanza
)
return
if
stanza
.
getQueryNS
()
!=
nbxmpp
.
NS_LAST
:
log
.
warning
(
'
Wrong namespace on result: %s
'
,
stanza
)
return
try
:
seconds
=
int
(
stanza
.
getQuery
().
getAttr
(
'
seconds
'
))
except
(
ValueError
,
TypeError
,
AttributeError
):
log
.
exception
(
'
Received malformed last activity result
'
)
else
:
delta
=
timedelta
(
seconds
=
seconds
)
hours
=
0
if
seconds
>=
3600
:
hours
=
delta
.
seconds
//
3600
self
.
uptime
=
_
(
'
%s days, %s hours
'
)
%
(
delta
.
days
,
hours
)
self
.
update
(
self
.
get_infos
,
self
.
info_listbox
)
def
_nec_version_result_received
(
self
,
obj
):
if
obj
.
jid
!=
self
.
hostname
:
return
...
...
@@ -133,7 +169,8 @@ class ServerInfoDialog(Gtk.Dialog):
Info
=
namedtuple
(
'
Info
'
,
[
'
name
'
,
'
value
'
,
'
tooltip
'
])
return
[
Info
(
_
(
'
Hostname
'
),
self
.
hostname
,
None
),
Info
(
_
(
'
Server Software
'
),
self
.
version
,
None
)]
Info
(
_
(
'
Server Software
'
),
self
.
version
,
None
),
Info
(
_
(
'
Server Uptime
'
),
self
.
uptime
,
None
)]
def
on_response
(
self
,
dialog
,
response
):
if
response
==
Gtk
.
ResponseType
.
OK
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment