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
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor 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
mesonium
gajim
Commits
545d25ca
Commit
545d25ca
authored
5 years ago
by
Daniel Brötzmann
Committed by
Philipp Hörist
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ServerInfo: Add contact addresses
parent
23d5a6e1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gajim/data/gui/server_info.ui
+28
-5
28 additions, 5 deletions
gajim/data/gui/server_info.ui
gajim/gtk/server_info.py
+77
-0
77 additions, 0 deletions
gajim/gtk/server_info.py
with
105 additions
and
5 deletions
gajim/data/gui/server_info.ui
+
28
−
5
View file @
545d25ca
...
...
@@ -9,6 +9,7 @@
<object
class=
"GtkGrid"
id=
"server"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"halign"
>
center
</property>
<property
name=
"row_spacing"
>
6
</property>
<property
name=
"column_spacing"
>
12
</property>
<child>
...
...
@@ -101,22 +102,44 @@
</packing>
</child>
<child>
<object
class=
"GtkBox"
id=
"spacer1"
>
<property
name=
"width_request"
>
160
</property>
<object
class=
"GtkLabel"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<child>
<placeholder/>
</child>
<property
name=
"margin_top"
>
12
</property>
<property
name=
"label"
translatable=
"yes"
>
Contact Addresses
</property>
<style>
<class
name=
"bold16"
/>
</style>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
3
</property>
<property
name=
"width"
>
2
</property>
</packing>
</child>
<child>
<object
class=
"GtkLabel"
id=
"no_addresses_label"
>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"no_show_all"
>
True
</property>
<property
name=
"label"
translatable=
"yes"
>
No contact addresses published for this server.
</property>
<property
name=
"wrap"
>
True
</property>
<property
name=
"max_width_chars"
>
50
</property>
<style>
<class
name=
"dim-label"
/>
</style>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
4
</property>
<property
name=
"width"
>
2
</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<style>
<class
name=
"margin-18"
/>
</style>
...
...
This diff is collapsed.
Click to expand it.
gajim/gtk/server_info.py
+
77
−
0
View file @
545d25ca
...
...
@@ -20,9 +20,11 @@
from
nbxmpp.util
import
is_error_result
from
gi.repository
import
Gtk
from
gi.repository
import
Gdk
from
gi.repository
import
Pango
from
gajim.common
import
app
from
gajim.common
import
ged
from
gajim.common.helpers
import
open_uri
from
gajim.common.i18n
import
_
from
gajim.gtk.util
import
ensure_not_destroyed
...
...
@@ -66,6 +68,9 @@ def __init__(self, account):
self
.
hostname
,
callback
=
self
.
_software_version_received
)
self
.
request_last_activity
()
server_info
=
con
.
get_module
(
'
Discovery
'
).
server_info
self
.
_add_contact_addresses
(
server_info
.
dataforms
)
self
.
cert
=
con
.
connection
.
Connection
.
ssl_certificate
self
.
_add_connection_info
()
...
...
@@ -142,6 +147,78 @@ def request_last_activity(self):
iq
=
nbxmpp
.
Iq
(
to
=
self
.
hostname
,
typ
=
'
get
'
,
queryNS
=
nbxmpp
.
NS_LAST
)
con
.
connection
.
SendAndCallForResponse
(
iq
,
self
.
_on_last_activity
)
def
_add_contact_addresses
(
self
,
dataforms
):
fields
=
{
'
admin-addresses
'
:
_
(
'
Admin
'
),
'
support-addresses
'
:
_
(
'
Support
'
),
'
security-addresses
'
:
_
(
'
Security
'
),
'
feedback-addresses
'
:
_
(
'
Feedback
'
),
'
abuse-addresses
'
:
_
(
'
Abuse
'
),
'
sales-addresses
'
:
_
(
'
Sales
'
),
}
addresses
=
self
.
_get_addresses
(
fields
,
dataforms
)
if
addresses
is
None
:
self
.
_ui
.
no_addresses_label
.
set_visible
(
True
)
return
row_count
=
4
for
address_type
,
values
in
addresses
.
items
():
label
=
self
.
_get_address_type_label
(
fields
[
address_type
])
self
.
_ui
.
server
.
attach
(
label
,
0
,
row_count
,
1
,
1
)
for
index
,
value
in
enumerate
(
values
):
last
=
index
==
len
(
values
)
-
1
label
=
self
.
_get_address_label
(
value
,
last
=
last
)
self
.
_ui
.
server
.
attach
(
label
,
1
,
row_count
,
1
,
1
)
row_count
+=
1
@staticmethod
def
_get_addresses
(
fields
,
dataforms
):
addresses
=
{}
for
form
in
dataforms
:
type_
=
form
.
vars
.
get
(
'
FORM_TYPE
'
)
if
type_
==
'
http://jabber.org/network/serverinfo
'
:
continue
for
address_type
in
fields
:
field
=
form
.
vars
.
get
(
address_type
)
if
field
is
None
:
continue
if
field
.
type_
!=
'
list-multi
'
:
continue
if
not
field
.
values
:
continue
addresses
[
address_type
]
=
field
.
values
return
addresses
or
None
return
None
@staticmethod
def
_get_address_type_label
(
text
):
label
=
Gtk
.
Label
(
label
=
text
)
label
.
set_halign
(
Gtk
.
Align
.
END
)
label
.
set_valign
(
Gtk
.
Align
.
START
)
label
.
get_style_context
().
add_class
(
'
dim-label
'
)
return
label
def
_get_address_label
(
self
,
address
,
last
=
False
):
label
=
Gtk
.
Label
()
label
.
set_markup
(
'
<a href=
"
%s
"
>%s</a>
'
%
(
address
,
address
))
label
.
set_ellipsize
(
Pango
.
EllipsizeMode
.
END
)
label
.
set_xalign
(
0
)
label
.
set_halign
(
Gtk
.
Align
.
START
)
label
.
get_style_context
().
add_class
(
'
link-button
'
)
label
.
connect
(
'
activate-link
'
,
self
.
_on_activate_link
)
if
last
:
label
.
set_margin_bottom
(
6
)
return
label
def
_on_activate_link
(
self
,
label
,
*
args
):
open_uri
(
label
.
get_text
(),
account
=
self
.
account
)
return
Gdk
.
EVENT_STOP
def
_on_last_activity
(
self
,
stanza
):
if
self
.
_destroyed
:
# Window got closed in the meantime
...
...
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