Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
08e26d33
Commit
08e26d33
authored
Jun 24, 2013
by
Saul Ibarra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid computing XCAP capable accounts list multiple times
parent
b5c0d80f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
19 deletions
+11
-19
presence.py
blink/presence.py
+11
-19
No files found.
blink/presence.py
View file @
08e26d33
...
...
@@ -157,24 +157,14 @@ class PresencePublicationHandler(object):
return
doc
def
set_xcap_offline_note
(
self
,
account
=
None
):
def
set_xcap_offline_note
(
self
,
account
s
):
blink_settings
=
BlinkSettings
()
if
not
account
:
account_manager
=
AccountManager
()
accounts
=
[
account
for
account
in
account_manager
.
get_accounts
()
if
hasattr
(
account
,
'xcap'
)
and
account
.
xcap
.
enabled
and
account
.
xcap
.
discovered
]
else
:
accounts
=
[
account
]
for
account
in
accounts
:
status
=
OfflineStatus
(
self
.
build_offline_pidf
(
account
,
blink_settings
.
presence
.
offline_note
))
if
blink_settings
.
presence
.
offline_note
else
None
account
.
xcap_manager
.
set_offline_status
(
status
)
def
set_xcap_icon
(
self
,
account
=
None
):
def
set_xcap_icon
(
self
,
account
s
):
blink_settings
=
BlinkSettings
()
if
not
account
:
account_manager
=
AccountManager
()
accounts
=
[
account
for
account
in
account_manager
.
get_accounts
()
if
hasattr
(
account
,
'xcap'
)
and
account
.
xcap
.
enabled
and
account
.
xcap
.
discovered
]
else
:
accounts
=
[
account
]
try
:
icon
=
Icon
(
file
(
blink_settings
.
presence
.
icon
.
url
.
path
)
.
read
(),
'image/png'
)
except
Exception
:
...
...
@@ -200,11 +190,13 @@ class PresencePublicationHandler(object):
def
_NH_CFGSettingsObjectDidChange
(
self
,
notification
):
if
notification
.
sender
is
BlinkSettings
():
# TODO: use a transaction here as well? -Dan
if
'presence.offline_note'
in
notification
.
data
.
modified
:
self
.
set_xcap_offline_note
()
if
'presence.icon'
in
notification
.
data
.
modified
:
self
.
set_xcap_icon
()
if
set
([
'presence.icon'
,
'presence.offline_note'
])
.
intersection
(
notification
.
data
.
modified
):
# TODO: use a transaction here as well? -Dan
accounts
=
[
account
for
account
in
AccountManager
()
.
get_accounts
()
if
hasattr
(
account
,
'xcap'
)
and
account
.
enabled
and
account
.
xcap
.
enabled
and
account
.
xcap
.
discovered
]
if
'presence.offline_note'
in
notification
.
data
.
modified
:
self
.
set_xcap_offline_note
(
accounts
)
if
'presence.icon'
in
notification
.
data
.
modified
:
self
.
set_xcap_icon
(
accounts
)
if
'presence.current_state'
in
notification
.
data
.
modified
:
self
.
publish
()
else
:
...
...
@@ -258,8 +250,8 @@ class PresencePublicationHandler(object):
def
_NH_SIPAccountDidDiscoverXCAPSupport
(
self
,
notification
):
account
=
notification
.
sender
with
account
.
xcap_manager
.
transaction
():
self
.
set_xcap_offline_note
(
account
)
self
.
set_xcap_icon
(
account
)
self
.
set_xcap_offline_note
(
[
account
]
)
self
.
set_xcap_icon
(
[
account
]
)
def
_NH_XCAPManagerDidReloadData
(
self
,
notification
):
account
=
notification
.
sender
.
account
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment