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
0fd86e52
Commit
0fd86e52
authored
Jun 20, 2013
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store presence state using RuntimeSettings (fixes GUI presence state)
parent
8356bdbe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
30 deletions
+38
-30
addressbook.py
blink/configuration/addressbook.py
+8
-2
contacts.py
blink/contacts.py
+19
-24
presence.py
blink/presence.py
+11
-4
No files found.
blink/configuration/addressbook.py
View file @
0fd86e52
...
...
@@ -5,8 +5,8 @@
__all__
=
[
'ContactExtension'
,
'GroupExtension'
]
from
sipsimple.addressbook
import
ContactExtension
,
GroupExtension
,
SharedSetting
from
sipsimple.configuration
import
Setting
from
sipsimple.addressbook
import
ContactExtension
,
GroupExtension
,
PresenceSettings
,
SharedSetting
from
sipsimple.configuration
import
Setting
,
RuntimeSetting
from
blink.configuration.datatypes
import
IconDescriptor
...
...
@@ -14,7 +14,13 @@ from blink.configuration.datatypes import IconDescriptor
SharedSetting
.
set_namespace
(
'ag-projects:blink'
)
class
PresenceSettingsExtension
(
PresenceSettings
):
state
=
RuntimeSetting
(
type
=
unicode
,
nillable
=
True
,
default
=
None
)
note
=
RuntimeSetting
(
type
=
unicode
,
nillable
=
True
,
default
=
None
)
class
ContactExtension
(
ContactExtension
):
presence
=
PresenceSettingsExtension
icon
=
Setting
(
type
=
IconDescriptor
,
nillable
=
True
,
default
=
None
)
alternate_icon
=
Setting
(
type
=
IconDescriptor
,
nillable
=
True
,
default
=
None
)
preferred_media
=
SharedSetting
(
type
=
str
,
default
=
'audio'
)
...
...
blink/contacts.py
View file @
0fd86e52
...
...
@@ -793,8 +793,6 @@ class Contact(object):
def
__init__
(
self
,
contact
,
group
):
self
.
settings
=
contact
self
.
group
=
group
self
.
state
=
None
self
.
note
=
None
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
ObserverWeakrefProxy
(
self
),
sender
=
contact
)
...
...
@@ -822,7 +820,7 @@ class Contact(object):
return
'
%
s(
%
r,
%
r)'
%
(
self
.
__class__
.
__name__
,
self
.
settings
,
self
.
group
)
def
__getstate__
(
self
):
return
(
self
.
settings
.
id
,
dict
(
group
=
self
.
group
,
state
=
self
.
state
,
note
=
self
.
note
))
return
(
self
.
settings
.
id
,
dict
(
group
=
self
.
group
))
def
__setstate__
(
self
,
state
):
contact_id
,
state
=
state
...
...
@@ -866,6 +864,14 @@ class Contact(object):
except
StopIteration
:
return
u''
@
property
def
state
(
self
):
return
self
.
settings
.
presence
.
state
@
property
def
note
(
self
):
return
self
.
settings
.
presence
.
note
@
property
def
icon
(
self
):
try
:
...
...
@@ -916,16 +922,6 @@ class Contact(object):
self
.
__dict__
.
pop
(
'pixmap'
,
None
)
notification
.
center
.
post_notification
(
'BlinkContactDidChange'
,
sender
=
self
)
def
_NH_AddressbookContactGotPresenceUpdate
(
self
,
notification
):
self
.
state
=
notification
.
data
.
state
self
.
note
=
notification
.
data
.
note
if
notification
.
data
.
icon_data
:
icon
=
IconManager
()
.
store_data
(
self
.
settings
.
id
,
notification
.
data
.
icon_data
)
if
icon
:
self
.
settings
.
icon
=
notification
.
data
.
icon_descriptor
self
.
settings
.
save
()
notification
.
center
.
post_notification
(
'BlinkContactDidChange'
,
sender
=
self
)
class
ContactDetail
(
object
):
implements
(
IObserver
)
...
...
@@ -943,8 +939,6 @@ class ContactDetail(object):
def
__init__
(
self
,
contact
):
self
.
settings
=
contact
self
.
state
=
None
self
.
note
=
None
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
ObserverWeakrefProxy
(
self
),
sender
=
contact
)
...
...
@@ -952,7 +946,7 @@ class ContactDetail(object):
return
'
%
s(
%
r)'
%
(
self
.
__class__
.
__name__
,
self
.
settings
)
def
__getstate__
(
self
):
return
(
self
.
settings
.
id
,
dict
(
state
=
self
.
state
,
note
=
self
.
note
)
)
return
(
self
.
settings
.
id
,
{}
)
def
__setstate__
(
self
,
state
):
contact_id
,
state
=
state
...
...
@@ -996,6 +990,14 @@ class ContactDetail(object):
except
StopIteration
:
return
u''
@
property
def
state
(
self
):
return
self
.
settings
.
presence
.
state
@
property
def
note
(
self
):
return
self
.
settings
.
presence
.
note
@
property
def
icon
(
self
):
try
:
...
...
@@ -1046,11 +1048,6 @@ class ContactDetail(object):
self
.
__dict__
.
pop
(
'pixmap'
,
None
)
notification
.
center
.
post_notification
(
'BlinkContactDetailDidChange'
,
sender
=
self
)
def
_NH_AddressbookContactGotPresenceUpdate
(
self
,
notification
):
self
.
state
=
notification
.
data
.
state
self
.
note
=
notification
.
data
.
note
notification
.
center
.
post_notification
(
'BlinkContactDetailDidChange'
,
sender
=
self
)
class
ContactURI
(
object
):
implements
(
IObserver
)
...
...
@@ -1066,8 +1063,6 @@ class ContactURI(object):
self
.
contact
=
contact
self
.
uri
=
uri
self
.
default
=
default
self
.
state
=
None
self
.
note
=
None
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
ObserverWeakrefProxy
(
self
),
sender
=
contact
)
...
...
@@ -1075,7 +1070,7 @@ class ContactURI(object):
return
'
%
s(
%
r,
%
r)'
%
(
self
.
__class__
.
__name__
,
self
.
contact
,
self
.
uri
)
def
__getstate__
(
self
):
state_dict
=
dict
(
default
=
self
.
default
,
state
=
self
.
state
,
note
=
self
.
note
)
state_dict
=
dict
(
default
=
self
.
default
)
if
isinstance
(
self
.
contact
,
addressbook
.
Contact
):
uri_id
=
self
.
uri
.
id
else
:
...
...
blink/presence.py
View file @
0fd86e52
...
...
@@ -364,7 +364,6 @@ class PresenceSubscriptionHandler(object):
@
run_in_green_thread
def
_process_presence_data
(
self
,
uris
=
None
):
addressbook_manager
=
addressbook
.
AddressbookManager
()
notification_center
=
NotificationCenter
()
current_pidf_map
=
{}
contact_pidf_map
=
{}
...
...
@@ -395,8 +394,9 @@ class PresenceSubscriptionHandler(object):
note
=
unicode
(
next
(
iter
(
service
.
notes
)))
if
service
.
notes
else
None
icon
=
unicode
(
service
.
icon
)
if
service
.
icon
else
None
# review this logic (add NotChanged, NoIcon, ... markers to better represent the icon data and icon descriptor) -Dan
icon_data
=
icon_descriptor
=
None
if
icon
and
icon
!=
unknown_icon
and
(
not
contact
.
icon
or
(
contact
.
icon
and
not
contact
.
icon
.
is_local
))
:
if
icon
and
icon
!=
unknown_icon
:
if
'blink-icon'
in
icon
and
contact
.
icon
and
icon
==
contact
.
icon
.
url
:
# Fast path, icon hasn't changed
pass
...
...
@@ -404,9 +404,16 @@ class PresenceSubscriptionHandler(object):
icon_data
,
etag
=
self
.
_download_icon
(
icon
,
contact
.
icon
.
etag
if
contact
.
icon
else
None
)
if
icon_data
:
icon_descriptor
=
IconDescriptor
(
icon
,
etag
)
self
.
_update_contact_presence_state
(
contact
,
state
,
note
,
icon_descriptor
,
icon_data
)
data
=
NotificationData
(
state
=
state
,
note
=
note
,
icon_descriptor
=
icon_descriptor
,
icon_data
=
icon_data
)
notification_center
.
post_notification
(
'AddressbookContactGotPresenceUpdate'
,
sender
=
contact
,
data
=
data
)
@
run_in_gui_thread
def
_update_contact_presence_state
(
self
,
contact
,
state
,
note
,
icon_descriptor
,
icon_data
):
contact
.
presence
.
state
=
state
contact
.
presence
.
note
=
note
if
icon_data
:
IconManager
()
.
store_data
(
contact
.
id
,
icon_data
)
contact
.
icon
=
icon_descriptor
contact
.
save
()
def
handle_notification
(
self
,
notification
):
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
...
...
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