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
f9e8ace7
Commit
f9e8ace7
authored
Jul 03, 2013
by
Saul Ibarra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed handling file URLs on different platforms
parent
50351870
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
10 deletions
+18
-10
datatypes.py
blink/configuration/datatypes.py
+10
-2
contacts.py
blink/contacts.py
+4
-4
mainwindow.py
blink/mainwindow.py
+2
-2
presence.py
blink/presence.py
+2
-2
No files found.
blink/configuration/datatypes.py
View file @
f9e8ace7
...
...
@@ -3,10 +3,11 @@
"""Definitions of datatypes for use in settings extensions."""
__all__
=
[
'ApplicationDataPath'
,
'DefaultPath'
,
'SoundFile'
,
'CustomSoundFile'
,
'HTTPURL'
,
'AuthorizationToken'
,
'InvalidToken'
,
'IconDescriptor'
,
'PresenceState'
,
'PresenceStateList'
]
__all__
=
[
'ApplicationDataPath'
,
'DefaultPath'
,
'SoundFile'
,
'CustomSoundFile'
,
'HTTPURL'
,
'
FileURL'
,
'
AuthorizationToken'
,
'InvalidToken'
,
'IconDescriptor'
,
'PresenceState'
,
'PresenceStateList'
]
import
os
import
re
from
urllib
import
pathname2url
,
url2pathname
from
urlparse
import
urlparse
from
sipsimple.configuration.datatypes
import
Hostname
,
List
...
...
@@ -136,11 +137,18 @@ class AuthorizationToken(str):
InvalidToken
=
AuthorizationToken
()
# a valid token is never empty
class
FileURL
(
unicode
):
def
__new__
(
cls
,
value
):
if
not
value
.
startswith
(
'file:'
):
value
=
'file:'
+
pathname2url
(
os
.
path
.
abspath
(
value
))
return
unicode
.
__new__
(
cls
,
value
)
class
ParsedURL
(
unicode
):
fragment
=
property
(
lambda
self
:
self
.
__parsed__
.
fragment
)
netloc
=
property
(
lambda
self
:
self
.
__parsed__
.
netloc
)
params
=
property
(
lambda
self
:
self
.
__parsed__
.
params
)
path
=
property
(
lambda
self
:
self
.
__parsed__
.
path
)
path
=
property
(
lambda
self
:
self
.
__parsed__
.
path
if
self
.
scheme
!=
'file'
else
url2pathname
(
self
.
__parsed__
.
path
)
)
query
=
property
(
lambda
self
:
self
.
__parsed__
.
query
)
scheme
=
property
(
lambda
self
:
self
.
__parsed__
.
scheme
)
...
...
blink/contacts.py
View file @
f9e8ace7
...
...
@@ -39,7 +39,7 @@ from sipsimple.configuration.settings import SIPSimpleSettings
from
sipsimple.threading
import
run_in_thread
,
run_in_twisted_thread
from
sipsimple.threading.green
import
Command
,
call_in_green_thread
,
run_in_green_thread
from
blink.configuration.datatypes
import
AuthorizationToken
,
InvalidToken
,
IconDescriptor
from
blink.configuration.datatypes
import
AuthorizationToken
,
InvalidToken
,
IconDescriptor
,
FileURL
from
blink.resources
import
ApplicationData
,
Resources
,
IconManager
from
blink.sessions
import
SessionManager
from
blink.util
import
QSingleton
,
call_in_gui_thread
,
call_later
,
run_in_gui_thread
...
...
@@ -2173,7 +2173,7 @@ class ContactModel(QAbstractListModel):
contact
.
name
=
name
contact
.
preferred_media
=
preferred_media
contact
.
uris
=
[
addressbook
.
ContactURI
(
uri
=
uri
,
type
=
'SIP'
)]
contact
.
icon
=
IconDescriptor
(
'file://'
+
icon
,
unicode
(
int
(
os
.
stat
(
icon
)
.
st_mtime
)))
contact
.
icon
=
IconDescriptor
(
FileURL
(
icon
)
,
unicode
(
int
(
os
.
stat
(
icon
)
.
st_mtime
)))
return
contact
test_group
=
addressbook
.
Group
(
id
=
'test'
)
test_group
.
name
=
'Test'
...
...
@@ -2188,7 +2188,7 @@ class ContactModel(QAbstractListModel):
except
KeyError
:
continue
icon
=
entry
[
'icon'
]
icon_descriptor
=
IconDescriptor
(
'file://'
+
icon
,
unicode
(
int
(
os
.
stat
(
icon
)
.
st_mtime
)))
icon_descriptor
=
IconDescriptor
(
FileURL
(
icon
)
,
unicode
(
int
(
os
.
stat
(
icon
)
.
st_mtime
)))
if
contact
.
icon
!=
icon_descriptor
:
icon_manager
.
store_file
(
contact
.
id
,
icon
)
contact
.
icon
=
icon_descriptor
...
...
@@ -4035,7 +4035,7 @@ class ContactEditorDialog(base_class, ui_class):
icon_manager
.
remove
(
contact
.
id
+
'_alt'
)
contact
.
alternate_icon
=
None
else
:
icon_descriptor
=
IconDescriptor
(
'file://'
+
self
.
icon_selector
.
filename
,
unicode
(
int
(
os
.
stat
(
self
.
icon_selector
.
filename
)
.
st_mtime
)))
icon_descriptor
=
IconDescriptor
(
FileURL
(
self
.
icon_selector
.
filename
)
,
unicode
(
int
(
os
.
stat
(
self
.
icon_selector
.
filename
)
.
st_mtime
)))
if
contact
.
alternate_icon
!=
icon_descriptor
:
icon_manager
.
store_file
(
contact
.
id
+
'_alt'
,
icon_descriptor
.
url
.
path
)
contact
.
alternate_icon
=
icon_descriptor
...
...
blink/mainwindow.py
View file @
f9e8ace7
...
...
@@ -27,7 +27,7 @@ from blink.contacts import BonjourNeighbour, Contact, ContactEditorDialog, Conta
from
blink.history
import
HistoryManager
from
blink.preferences
import
PreferencesWindow
from
blink.sessions
import
ConferenceDialog
,
SessionManager
,
SessionModel
from
blink.configuration.datatypes
import
IconDescriptor
,
InvalidToken
,
PresenceState
from
blink.configuration.datatypes
import
IconDescriptor
,
FileURL
,
InvalidToken
,
PresenceState
from
blink.configuration.settings
import
BlinkSettings
from
blink.presence
import
PendingWatcherDialog
from
blink.resources
import
IconManager
,
Resources
...
...
@@ -388,7 +388,7 @@ class MainWindow(base_class, ui_class):
icon_contents
=
icon_manager
.
get_image
(
'avatar'
)
if
icon_contents
is
not
None
:
hash
=
hashlib
.
sha512
(
icon_contents
)
.
hexdigest
()
blink_settings
.
presence
.
icon
=
IconDescriptor
(
'file://'
+
icon
.
filename
,
hash
)
blink_settings
.
presence
.
icon
=
IconDescriptor
(
FileURL
(
icon
.
filename
)
,
hash
)
else
:
icon_manager
.
remove
(
'avatar'
)
blink_settings
.
presence
.
icon
=
None
...
...
blink/presence.py
View file @
f9e8ace7
...
...
@@ -32,7 +32,7 @@ from sipsimple.payloads import cipid; cipid # needs to be imported to register i
from
sipsimple.threading.green
import
run_in_green_thread
from
sipsimple.util
import
ISOTimestamp
from
blink.configuration.datatypes
import
IconDescriptor
,
PresenceState
from
blink.configuration.datatypes
import
IconDescriptor
,
FileURL
,
PresenceState
from
blink.configuration.settings
import
BlinkSettings
from
blink.resources
import
IconManager
,
Resources
from
blink.util
import
run_in_gui_thread
...
...
@@ -262,7 +262,7 @@ class PresencePublicationHandler(object):
icon_hash
=
hashlib
.
sha512
(
status_icon
.
data
)
.
hexdigest
()
if
not
blink_settings
.
presence
.
icon
or
blink_settings
.
presence
.
icon
.
etag
!=
icon_hash
:
icon
=
icon_manager
.
store_data
(
'avatar'
,
status_icon
.
data
)
blink_settings
.
presence
.
icon
=
IconDescriptor
(
'file://'
+
icon
.
filename
,
icon_hash
)
if
icon
is
not
None
else
None
blink_settings
.
presence
.
icon
=
IconDescriptor
(
FileURL
(
icon
.
filename
)
,
icon_hash
)
if
icon
is
not
None
else
None
blink_settings
.
save
()
else
:
icon_desc
=
None
...
...
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