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
82d5b407
Commit
82d5b407
authored
Jun 24, 2013
by
Saul Ibarra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for Bonjour presence
parent
08e26d33
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
+21
-18
account.py
blink/configuration/account.py
+1
-0
presence.py
blink/presence.py
+20
-18
No files found.
blink/configuration/account.py
View file @
82d5b407
...
...
@@ -86,6 +86,7 @@ class AccountExtension(SettingsObjectExtension):
class
BonjourAccountExtension
(
SettingsObjectExtension
):
msrp
=
BonjourMSRPSettingsExtension
presence
=
PresenceSettingsExtension
rtp
=
RTPSettingsExtension
sip
=
BonjourSIPSettings
sounds
=
SoundSettings
...
...
blink/presence.py
View file @
82d5b407
...
...
@@ -24,6 +24,7 @@ from zope.interface import implements
from
sipsimple
import
addressbook
from
sipsimple.account
import
AccountManager
,
BonjourAccount
from
sipsimple.account.bonjour
import
BonjourPresenceState
from
sipsimple.account.xcap
import
Icon
,
OfflineStatus
from
sipsimple.configuration.settings
import
SIPSimpleSettings
from
sipsimple.payloads
import
caps
,
cipid
,
pidf
,
prescontent
,
rpid
...
...
@@ -67,15 +68,14 @@ class PresencePublicationHandler(object):
notification_center
.
remove_observer
(
self
,
name
=
'XCAPManagerDidReloadData'
)
notification_center
.
remove_observer
(
self
,
sender
=
BlinkSettings
(),
name
=
'CFGSettingsObjectDidChange'
)
def
publish
(
self
,
account
=
None
):
if
not
account
:
account_manager
=
AccountManager
()
def
publish
(
self
,
accounts
):
bonjour_account
=
BonjourAccount
()
accounts
=
[
account
for
account
in
account_manager
.
get_accounts
()
if
account
is
not
bonjour_account
and
account
.
enabled
and
account
.
presence
.
enabled
]
else
:
accounts
=
[
account
]
for
account
in
accounts
:
if
account
is
not
bonjour_account
:
account
.
presence_state
=
self
.
build_pidf
(
account
)
else
:
blink_settings
=
BlinkSettings
()
account
.
presence_state
=
BonjourPresenceState
(
blink_settings
.
presence
.
current_state
.
state
,
blink_settings
.
presence
.
current_state
.
note
)
def
build_pidf
(
self
,
account
):
blink_settings
=
BlinkSettings
()
...
...
@@ -190,33 +190,35 @@ class PresencePublicationHandler(object):
def
_NH_CFGSettingsObjectDidChange
(
self
,
notification
):
if
notification
.
sender
is
BlinkSettings
():
account_manager
=
AccountManager
()
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
]
accounts
=
[
account
for
account
in
account_manager
.
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
()
accounts
=
[
account
for
account
in
account_manager
.
get_accounts
()
if
account
.
enabled
and
account
.
presence
.
enabled
]
self
.
publish
(
accounts
)
else
:
account
=
notification
.
sender
if
set
([
'xcap.enabled'
,
'xcap.xcap_root'
])
.
intersection
(
notification
.
data
.
modified
):
account
.
icon
=
None
if
set
([
'presence.enabled'
,
'display_name'
,
'xcap.enabled'
,
'xcap.xcap_root'
])
.
intersection
(
notification
.
data
.
modified
)
and
account
.
presence
.
enabled
:
self
.
publish
(
account
)
self
.
publish
(
[
account
]
)
def
_NH_SIPAccountWillActivate
(
self
,
notification
):
if
notification
.
sender
is
not
BonjourAccount
():
account
=
notification
.
sender
notification
.
center
.
add_observer
(
self
,
sender
=
account
,
name
=
'CFGSettingsObjectDidChange'
)
if
account
is
not
BonjourAccount
():
notification
.
center
.
add_observer
(
self
,
sender
=
account
,
name
=
'SIPAccountGotSelfPresenceState'
)
account
.
icon
=
None
def
_NH_SIPAccountWillDeactivate
(
self
,
notification
):
if
notification
.
sender
is
not
BonjourAccount
():
account
=
notification
.
sender
notification
.
center
.
remove_observer
(
self
,
sender
=
account
,
name
=
'CFGSettingsObjectDidChange'
)
if
account
is
not
BonjourAccount
():
notification
.
center
.
remove_observer
(
self
,
sender
=
account
,
name
=
'SIPAccountGotSelfPresenceState'
)
account
.
icon
=
None
...
...
@@ -278,7 +280,7 @@ class PresencePublicationHandler(object):
self
.
_save_icon
(
status_icon
.
data
,
icon_hash
)
if
icon_desc
!=
account
.
icon
:
account
.
icon
=
icon_desc
self
.
publish
(
account
)
self
.
publish
(
[
account
]
)
else
:
# TODO: remove local icon?
pass
...
...
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