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
cda52677
Commit
cda52677
authored
Aug 04, 2016
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made IconManager thread safe
parent
2e3865b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
33 deletions
+20
-33
contacts.py
blink/contacts.py
+5
-3
presence.py
blink/presence.py
+6
-6
resources.py
blink/resources.py
+9
-24
No files found.
blink/contacts.py
View file @
cda52677
...
@@ -2817,9 +2817,11 @@ class ContactModel(QAbstractListModel):
...
@@ -2817,9 +2817,11 @@ class ContactModel(QAbstractListModel):
elif
item
.
group
.
settings
is
all_contacts_group
:
elif
item
.
group
.
settings
is
all_contacts_group
:
removed_items
.
append
(
item
.
settings
)
removed_items
.
append
(
item
.
settings
)
group_ids
=
[
contact
.
group
.
settings
.
id
for
contact
in
self
.
iter_contacts
()
if
contact
.
settings
is
item
.
settings
and
not
contact
.
group
.
virtual
]
group_ids
=
[
contact
.
group
.
settings
.
id
for
contact
in
self
.
iter_contacts
()
if
contact
.
settings
is
item
.
settings
and
not
contact
.
group
.
virtual
]
icon
=
icon_manager
.
get_image
(
item
.
settings
.
id
)
icon
=
icon_manager
.
get
(
item
.
settings
.
id
)
alternate_icon
=
icon_manager
.
get_image
(
item
.
settings
.
id
+
'_alt'
)
icon_data
=
icon
and
icon
.
content
undo_operations
.
append
(
AddContactOperation
(
contact
=
RecallState
(
item
.
settings
),
group_ids
=
group_ids
,
icon
=
icon
,
alternate_icon
=
alternate_icon
))
alternate_icon
=
icon_manager
.
get
(
item
.
settings
.
id
+
'_alt'
)
alternate_icon_data
=
alternate_icon
and
alternate_icon
.
content
undo_operations
.
append
(
AddContactOperation
(
contact
=
RecallState
(
item
.
settings
),
group_ids
=
group_ids
,
icon
=
icon_data
,
alternate_icon
=
alternate_icon_data
))
elif
item
.
group
.
settings
not
in
removed_items
:
elif
item
.
group
.
settings
not
in
removed_items
:
item
.
group
.
settings
.
contacts
.
remove
(
item
.
settings
)
item
.
group
.
settings
.
contacts
.
remove
(
item
.
settings
)
removed_members
.
append
(
item
.
group
.
settings
)
removed_members
.
append
(
item
.
group
.
settings
)
...
...
blink/presence.py
View file @
cda52677
...
@@ -182,10 +182,10 @@ class PresencePublicationHandler(object):
...
@@ -182,10 +182,10 @@ class PresencePublicationHandler(object):
state
=
BlinkPresenceState
(
account
)
.
offline_state
state
=
BlinkPresenceState
(
account
)
.
offline_state
account
.
xcap_manager
.
set_offline_status
(
OfflineStatus
(
state
)
if
state
is
not
None
else
None
)
account
.
xcap_manager
.
set_offline_status
(
OfflineStatus
(
state
)
if
state
is
not
None
else
None
)
if
'presence.icon'
in
notification
.
data
.
modified
:
if
'presence.icon'
in
notification
.
data
.
modified
:
icon
_data
=
IconManager
()
.
get_image
(
'avatar'
)
icon
=
IconManager
()
.
get
(
'avatar'
)
icon
=
Icon
(
icon_data
,
'image/png'
)
if
icon_data
is
not
None
else
None
status_icon
=
Icon
(
icon
.
content
,
icon
.
content_type
)
if
icon
is
not
None
else
None
for
account
in
(
account
for
account
in
account_manager
.
get_accounts
()
if
account
.
xcap_available
):
for
account
in
(
account
for
account
in
account_manager
.
get_accounts
()
if
account
.
xcap_available
):
account
.
xcap_manager
.
set_status_icon
(
icon
)
account
.
xcap_manager
.
set_status_icon
(
status_
icon
)
if
'presence.current_state'
in
notification
.
data
.
modified
:
if
'presence.current_state'
in
notification
.
data
.
modified
:
for
account
in
(
account
for
account
in
account_manager
.
get_accounts
()
if
account
.
enabled
and
account
.
presence
.
enabled
):
for
account
in
(
account
for
account
in
account_manager
.
get_accounts
()
if
account
.
enabled
and
account
.
presence
.
enabled
):
account
.
presence_state
=
BlinkPresenceState
(
account
)
.
online_state
account
.
presence_state
=
BlinkPresenceState
(
account
)
.
online_state
...
@@ -242,9 +242,9 @@ class PresencePublicationHandler(object):
...
@@ -242,9 +242,9 @@ class PresencePublicationHandler(object):
def
_NH_SIPAccountDidDiscoverXCAPSupport
(
self
,
notification
):
def
_NH_SIPAccountDidDiscoverXCAPSupport
(
self
,
notification
):
account
=
notification
.
sender
account
=
notification
.
sender
icon
_data
=
IconManager
()
.
get_image
(
'avatar'
)
icon
=
IconManager
()
.
get
(
'avatar'
)
if
icon
_data
is
not
None
:
if
icon
is
not
None
:
account
.
xcap_manager
.
set_status_icon
(
Icon
(
icon
_data
,
'image/png'
))
account
.
xcap_manager
.
set_status_icon
(
Icon
(
icon
.
content
,
icon
.
content_type
))
@
run_in_gui_thread
@
run_in_gui_thread
def
_NH_XCAPManagerDidReloadData
(
self
,
notification
):
def
_NH_XCAPManagerDidReloadData
(
self
,
notification
):
...
...
blink/resources.py
View file @
cda52677
...
@@ -7,13 +7,12 @@ import os
...
@@ -7,13 +7,12 @@ import os
import
platform
import
platform
import
sys
import
sys
from
PyQt4.QtCore
import
Qt
,
QBuffer
,
QThread
from
PyQt4.QtCore
import
Qt
,
QBuffer
from
PyQt4.QtGui
import
Q
Application
,
Q
Icon
,
QPixmap
from
PyQt4.QtGui
import
QIcon
,
QPixmap
from
application.python.descriptor
import
classproperty
from
application.python.descriptor
import
classproperty
from
application.python.types
import
Singleton
from
application.python.types
import
Singleton
from
application.system
import
makedirs
,
unlink
from
application.system
import
makedirs
,
unlink
from
threading
import
Event
from
sipsimple.configuration.datatypes
import
Path
from
sipsimple.configuration.datatypes
import
Path
from
blink.util
import
run_in_gui_thread
from
blink.util
import
run_in_gui_thread
...
@@ -92,6 +91,7 @@ class IconManager(object):
...
@@ -92,6 +91,7 @@ class IconManager(object):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
iconmap
=
{}
self
.
iconmap
=
{}
@
run_in_gui_thread
(
wait
=
True
)
def
get
(
self
,
id
):
def
get
(
self
,
id
):
try
:
try
:
return
self
.
iconmap
[
id
]
return
self
.
iconmap
[
id
]
...
@@ -107,31 +107,12 @@ class IconManager(object):
...
@@ -107,31 +107,12 @@ class IconManager(object):
icon
=
QIcon
(
pixmap
)
icon
=
QIcon
(
pixmap
)
icon
.
filename
=
filename
icon
.
filename
=
filename
icon
.
content
=
data
icon
.
content
=
data
icon
.
content_type
=
'image/png'
else
:
else
:
icon
=
None
icon
=
None
return
self
.
iconmap
.
setdefault
(
id
,
icon
)
return
self
.
iconmap
.
setdefault
(
id
,
icon
)
def
get_image
(
self
,
id
):
@
run_in_gui_thread
(
wait
=
True
)
application
=
QApplication
.
instance
()
if
QThread
.
currentThread
()
is
application
.
thread
():
icon
=
self
.
get
(
id
)
else
:
@
run_in_gui_thread
def
get_icon
(
id
,
event
):
try
:
event
.
icon
=
self
.
get
(
id
)
except
:
event
.
icon
=
None
finally
:
event
.
set
()
event
=
Event
()
get_icon
(
id
,
event
)
event
.
wait
()
icon
=
event
.
icon
if
icon
is
None
:
return
None
return
icon
.
content
def
store_data
(
self
,
id
,
data
):
def
store_data
(
self
,
id
,
data
):
directory
=
ApplicationData
.
get
(
'images'
)
directory
=
ApplicationData
.
get
(
'images'
)
filename
=
os
.
path
.
join
(
directory
,
id
+
'.png'
)
filename
=
os
.
path
.
join
(
directory
,
id
+
'.png'
)
...
@@ -150,12 +131,14 @@ class IconManager(object):
...
@@ -150,12 +131,14 @@ class IconManager(object):
icon
=
QIcon
(
pixmap
)
icon
=
QIcon
(
pixmap
)
icon
.
filename
=
filename
icon
.
filename
=
filename
icon
.
content
=
data
icon
.
content
=
data
icon
.
content_type
=
'image/png'
else
:
else
:
unlink
(
filename
)
unlink
(
filename
)
icon
=
None
icon
=
None
self
.
iconmap
[
id
]
=
icon
self
.
iconmap
[
id
]
=
icon
return
icon
return
icon
@
run_in_gui_thread
(
wait
=
True
)
def
store_file
(
self
,
id
,
file
):
def
store_file
(
self
,
id
,
file
):
directory
=
ApplicationData
.
get
(
'images'
)
directory
=
ApplicationData
.
get
(
'images'
)
filename
=
os
.
path
.
join
(
directory
,
id
+
'.png'
)
filename
=
os
.
path
.
join
(
directory
,
id
+
'.png'
)
...
@@ -174,12 +157,14 @@ class IconManager(object):
...
@@ -174,12 +157,14 @@ class IconManager(object):
icon
=
QIcon
(
pixmap
)
icon
=
QIcon
(
pixmap
)
icon
.
filename
=
filename
icon
.
filename
=
filename
icon
.
content
=
data
icon
.
content
=
data
icon
.
content_type
=
'image/png'
else
:
else
:
unlink
(
filename
)
unlink
(
filename
)
icon
=
None
icon
=
None
self
.
iconmap
[
id
]
=
icon
self
.
iconmap
[
id
]
=
icon
return
icon
return
icon
@
run_in_gui_thread
(
wait
=
True
)
def
remove
(
self
,
id
):
def
remove
(
self
,
id
):
self
.
iconmap
.
pop
(
id
,
None
)
self
.
iconmap
.
pop
(
id
,
None
)
unlink
(
ApplicationData
.
get
(
os
.
path
.
join
(
'images'
,
id
+
'.png'
)))
unlink
(
ApplicationData
.
get
(
os
.
path
.
join
(
'images'
,
id
+
'.png'
)))
...
...
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