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
Weblate
gajim
Commits
2af509d0
Commit
2af509d0
authored
17 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
reverting [8388] for the moment
parent
59aa2cf8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/contacts.py
+38
-38
38 additions, 38 deletions
src/common/contacts.py
with
38 additions
and
38 deletions
src/common/contacts.py
+
38
−
38
View file @
2af509d0
...
...
@@ -395,48 +395,48 @@ class Contacts:
answers
.
append
(
data
)
return
answers
def
compare_metacontacts
(
self
,
data1
,
data2
):
'''
compare 2 metacontacts.
Data is {
'
jid
'
: jid,
'
account
'
: account,
'
order
'
: order}
order is optional
'''
if
'
order
'
in
data1
and
'
order
'
in
data2
:
if
data1
[
'
order
'
]
>
data2
[
'
order
'
]:
return
1
if
data1
[
'
order
'
]
<
data2
[
'
order
'
]:
return
-
1
jid1
=
data1
[
'
jid
'
]
jid2
=
data2
[
'
jid
'
]
transport1
=
common
.
gajim
.
get_transport_name_from_jid
(
jid1
)
transport2
=
common
.
gajim
.
get_transport_name_from_jid
(
jid2
)
if
transport2
and
not
transport1
:
return
1
if
transport1
and
not
transport2
:
return
-
1
contact1
=
self
.
get_contact_with_highest_priority
(
data1
[
'
account
'
],
jid1
)
contact2
=
self
.
get_contact_with_highest_priority
(
data2
[
'
account
'
],
jid2
)
if
contact1
.
priority
>
contact2
.
priority
:
return
1
if
contact2
.
priority
>
contact1
.
priority
:
return
-
1
show_list
=
[
'
not in roster
'
,
'
error
'
,
'
offline
'
,
'
invisible
'
,
'
dnd
'
,
'
xa
'
,
'
away
'
,
'
chat
'
,
'
online
'
,
'
requested
'
,
'
message
'
]
show1
=
show_list
.
index
(
contact1
.
show
)
show2
=
show_list
.
index
(
contact2
.
show
)
if
show1
>
show2
:
return
1
if
show2
>
show1
:
return
-
1
if
jid1
>
jid2
:
return
1
if
jid2
>
jid1
:
return
-
1
return
0
def
_get_data_score
(
self
,
data
):
'''
compute thescore of a gived data
data is {
'
jid
'
: jid,
'
account
'
: account,
'
order
'
: order}
order is optional
score = (max_order - order)*10000 + is_jabber*priority*10 + status
'''
jid
=
data
[
'
jid
'
]
account
=
data
[
'
account
'
]
max_order
=
0
order
=
0
if
data
.
has_key
(
'
order
'
):
order
=
data
[
'
order
'
]
if
order
:
family
=
self
.
get_metacontacts_family
(
account
,
jid
)
for
data_
in
family
:
if
data_
.
has_key
(
'
order
'
)
and
data_
[
'
order
'
]
>
max_order
:
max_order
=
data_
[
'
order
'
]
contact
=
self
.
get_contact_with_highest_priority
(
account
,
jid
)
score
=
(
max_order
-
order
)
*
10000
if
common
.
gajim
.
get_transport_name_from_jid
(
jid
)
is
None
and
\
contact
.
show
not
in
(
'
error
'
,
'
offline
'
):
score
+=
10
if
contact
.
priority
>
0
:
score
+=
contact
.
priority
*
10
score
+=
[
'
not in roster
'
,
'
error
'
,
'
offline
'
,
'
invisible
'
,
'
dnd
'
,
'
xa
'
,
'
away
'
,
'
chat
'
,
'
online
'
,
'
requested
'
,
'
message
'
].
index
(
contact
.
show
)
if
contact
.
show
==
'
offline
'
and
contact
.
status
:
# Offline contacts with a status message have highest score
score
+=
1
return
score
def
get_metacontacts_big_brother
(
self
,
family
):
'''
which of the family will be the big brother under wich all
others will be ?
'''
family
.
sort
(
cmp
=
self
.
compare_metacontacts
)
return
family
[
-
1
]
max_score
=
0
max_data
=
family
[
0
]
for
data
in
family
:
score
=
self
.
_get_data_score
(
data
)
if
score
>
max_score
:
max_score
=
score
max_data
=
data
return
max_data
def
is_pm_from_jid
(
self
,
account
,
jid
):
'''
Returns True if the given jid is a private message jid
'''
...
...
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