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
a064ccd0
Commit
a064ccd0
authored
Aug 25, 2016
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed obsolete code
parent
d5c13f1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
88 deletions
+39
-88
__init__.py
blink/__init__.py
+1
-83
accounts.py
blink/accounts.py
+38
-5
No files found.
blink/__init__.py
View file @
a064ccd0
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
import
os
import
os
import
sys
import
sys
import
sip
import
sip
import
cjson
sip
.
setapi
(
'QString'
,
2
)
sip
.
setapi
(
'QString'
,
2
)
sip
.
setapi
(
'QVariant'
,
2
)
sip
.
setapi
(
'QVariant'
,
2
)
...
@@ -15,11 +14,8 @@ QApplication.setAttribute(Qt.AA_X11InitThreads, True)
...
@@ -15,11 +14,8 @@ QApplication.setAttribute(Qt.AA_X11InitThreads, True)
from
application
import
log
from
application
import
log
from
application.notification
import
IObserver
,
NotificationCenter
,
NotificationData
from
application.notification
import
IObserver
,
NotificationCenter
,
NotificationData
from
application.python
import
Null
from
application.python
import
Null
from
application.system
import
host
,
makedirs
,
unlink
from
application.system
import
host
,
makedirs
from
collections
import
defaultdict
from
eventlib
import
api
from
eventlib
import
api
from
gnutls.crypto
import
X509Certificate
,
X509PrivateKey
from
gnutls.errors
import
GNUTLSError
from
zope.interface
import
implements
from
zope.interface
import
implements
from
sipsimple.account
import
Account
,
AccountManager
,
BonjourAccount
from
sipsimple.account
import
Account
,
AccountManager
,
BonjourAccount
...
@@ -176,82 +172,6 @@ class Blink(QApplication):
...
@@ -176,82 +172,6 @@ class Blink(QApplication):
self
.
main_window
.
close
()
self
.
main_window
.
close
()
super
(
Blink
,
self
)
.
quit
()
super
(
Blink
,
self
)
.
quit
()
def
fetch_account
(
self
):
filename
=
os
.
path
.
expanduser
(
'~/.blink_account'
)
if
not
os
.
path
.
exists
(
filename
):
return
try
:
data
=
open
(
filename
)
.
read
()
data
=
cjson
.
decode
(
data
.
replace
(
r'\/'
,
'/'
))
except
(
OSError
,
IOError
),
e
:
print
"Failed to read json data from ~/.blink_account:
%
s"
%
e
return
except
cjson
.
DecodeError
,
e
:
print
"Failed to decode json data from ~/.blink_account:
%
s"
%
e
return
finally
:
unlink
(
filename
)
data
=
defaultdict
(
lambda
:
None
,
data
)
account_id
=
data
[
'sip_address'
]
if
account_id
is
None
:
return
account_manager
=
AccountManager
()
try
:
account
=
account_manager
.
get_account
(
account_id
)
except
KeyError
:
account
=
Account
(
account_id
)
account
.
display_name
=
data
[
'display_name'
]
or
None
default_account
=
account
else
:
default_account
=
account_manager
.
default_account
account
.
auth
.
username
=
data
[
'auth_username'
]
account
.
auth
.
password
=
data
[
'password'
]
or
''
account
.
sip
.
outbound_proxy
=
data
[
'outbound_proxy'
]
account
.
xcap
.
xcap_root
=
data
[
'xcap_root'
]
account
.
nat_traversal
.
msrp_relay
=
data
[
'msrp_relay'
]
account
.
server
.
conference_server
=
data
[
'conference_server'
]
account
.
server
.
settings_url
=
data
[
'settings_url'
]
if
data
[
'passport'
]
is
not
None
:
try
:
passport
=
data
[
'passport'
]
certificate_path
=
self
.
save_certificates
(
account_id
,
passport
[
'crt'
],
passport
[
'key'
],
passport
[
'ca'
])
account
.
tls
.
certificate
=
certificate_path
except
(
GNUTLSError
,
IOError
,
OSError
):
pass
account
.
enabled
=
True
account
.
save
()
account_manager
.
default_account
=
default_account
def
save_certificates
(
self
,
sip_address
,
crt
,
key
,
ca
):
crt
=
crt
.
strip
()
+
os
.
linesep
key
=
key
.
strip
()
+
os
.
linesep
ca
=
ca
.
strip
()
+
os
.
linesep
X509Certificate
(
crt
)
X509PrivateKey
(
key
)
X509Certificate
(
ca
)
makedirs
(
ApplicationData
.
get
(
'tls'
))
certificate_path
=
ApplicationData
.
get
(
os
.
path
.
join
(
'tls'
,
sip_address
+
'.crt'
))
file
=
open
(
certificate_path
,
'w'
)
os
.
chmod
(
certificate_path
,
0600
)
file
.
write
(
crt
+
key
)
file
.
close
()
ca_path
=
ApplicationData
.
get
(
os
.
path
.
join
(
'tls'
,
'ca.crt'
))
try
:
existing_cas
=
open
(
ca_path
)
.
read
()
.
strip
()
+
os
.
linesep
except
:
file
=
open
(
ca_path
,
'w'
)
file
.
write
(
ca
)
file
.
close
()
else
:
if
ca
not
in
existing_cas
:
file
=
open
(
ca_path
,
'w'
)
file
.
write
(
existing_cas
+
ca
)
file
.
close
()
settings
=
SIPSimpleSettings
()
settings
.
tls
.
ca_list
=
ca_path
settings
.
save
()
return
certificate_path
def
eventFilter
(
self
,
watched
,
event
):
def
eventFilter
(
self
,
watched
,
event
):
if
watched
in
(
self
.
main_window
,
self
.
chat_window
):
if
watched
in
(
self
.
main_window
,
self
.
chat_window
):
if
event
.
type
()
==
QEvent
.
Show
:
if
event
.
type
()
==
QEvent
.
Show
:
...
@@ -286,9 +206,7 @@ class Blink(QApplication):
...
@@ -286,9 +206,7 @@ class Blink(QApplication):
@
run_in_gui_thread
@
run_in_gui_thread
def
_NH_SIPApplicationDidStart
(
self
,
notification
):
def
_NH_SIPApplicationDidStart
(
self
,
notification
):
self
.
ip_address_monitor
.
start
()
self
.
ip_address_monitor
.
start
()
self
.
fetch_account
()
self
.
main_window
.
show
()
self
.
main_window
.
show
()
settings
=
SIPSimpleSettings
()
accounts
=
AccountManager
()
.
get_accounts
()
accounts
=
AccountManager
()
.
get_accounts
()
if
not
accounts
or
(
self
.
first_run
and
accounts
==
[
BonjourAccount
()]):
if
not
accounts
or
(
self
.
first_run
and
accounts
==
[
BonjourAccount
()]):
self
.
main_window
.
preferences_window
.
show_create_account_dialog
()
self
.
main_window
.
preferences_window
.
show_create_account_dialog
()
...
...
blink/accounts.py
View file @
a064ccd0
...
@@ -15,6 +15,8 @@ from PyQt4.QtWebKit import QWebView
...
@@ -15,6 +15,8 @@ from PyQt4.QtWebKit import QWebView
import
cjson
import
cjson
from
application.notification
import
IObserver
,
NotificationCenter
from
application.notification
import
IObserver
,
NotificationCenter
from
application.python
import
Null
from
application.python
import
Null
from
application.system
import
makedirs
from
gnutls.crypto
import
X509Certificate
,
X509PrivateKey
from
gnutls.errors
import
GNUTLSError
from
gnutls.errors
import
GNUTLSError
from
zope.interface
import
implements
from
zope.interface
import
implements
...
@@ -24,7 +26,7 @@ from sipsimple.configuration.settings import SIPSimpleSettings
...
@@ -24,7 +26,7 @@ from sipsimple.configuration.settings import SIPSimpleSettings
from
sipsimple.threading
import
run_in_thread
from
sipsimple.threading
import
run_in_thread
from
sipsimple.util
import
user_info
from
sipsimple.util
import
user_info
from
blink.resources
import
Resources
from
blink.resources
import
ApplicationData
,
Resources
from
blink.widgets.labels
import
Status
from
blink.widgets.labels
import
Status
from
blink.util
import
QSingleton
,
call_in_gui_thread
,
run_in_gui_thread
from
blink.util
import
QSingleton
,
call_in_gui_thread
,
run_in_gui_thread
...
@@ -421,14 +423,14 @@ class AddAccountDialog(base_class, ui_class):
...
@@ -421,14 +423,14 @@ class AddAccountDialog(base_class, ui_class):
response_data
=
cjson
.
decode
(
response
.
read
()
.
replace
(
r'\/'
,
'/'
))
response_data
=
cjson
.
decode
(
response
.
read
()
.
replace
(
r'\/'
,
'/'
))
response_data
=
defaultdict
(
lambda
:
None
,
response_data
)
response_data
=
defaultdict
(
lambda
:
None
,
response_data
)
if
response_data
[
'success'
]:
if
response_data
[
'success'
]:
from
blink
import
Blink
try
:
try
:
certificate_path
=
None
passport
=
response_data
[
'passport'
]
passport
=
response_data
[
'passport'
]
if
passport
is
not
None
:
if
passport
is
not
None
:
certificate_path
=
Blink
()
.
save_certificates
(
response_data
[
'sip_address'
],
passport
[
'crt'
],
passport
[
'key'
],
passport
[
'ca'
])
certificate_path
=
self
.
_save_certificates
(
response_data
[
'sip_address'
],
passport
[
'crt'
],
passport
[
'key'
],
passport
[
'ca'
])
else
:
certificate_path
=
None
except
(
GNUTLSError
,
IOError
,
OSError
):
except
(
GNUTLSError
,
IOError
,
OSError
):
pass
certificate_path
=
None
account_manager
=
AccountManager
()
account_manager
=
AccountManager
()
try
:
try
:
account
=
Account
(
response_data
[
'sip_address'
])
account
=
Account
(
response_data
[
'sip_address'
])
...
@@ -457,6 +459,37 @@ class AddAccountDialog(base_class, ui_class):
...
@@ -457,6 +459,37 @@ class AddAccountDialog(base_class, ui_class):
finally
:
finally
:
call_in_gui_thread
(
self
.
setEnabled
,
True
)
call_in_gui_thread
(
self
.
setEnabled
,
True
)
@
staticmethod
def
_save_certificates
(
sip_address
,
crt
,
key
,
ca
):
crt
=
crt
.
strip
()
+
os
.
linesep
key
=
key
.
strip
()
+
os
.
linesep
ca
=
ca
.
strip
()
+
os
.
linesep
X509Certificate
(
crt
)
X509PrivateKey
(
key
)
X509Certificate
(
ca
)
makedirs
(
ApplicationData
.
get
(
'tls'
))
certificate_path
=
ApplicationData
.
get
(
os
.
path
.
join
(
'tls'
,
sip_address
+
'.crt'
))
certificate_file
=
open
(
certificate_path
,
'w'
)
os
.
chmod
(
certificate_path
,
0600
)
certificate_file
.
write
(
crt
+
key
)
certificate_file
.
close
()
ca_path
=
ApplicationData
.
get
(
os
.
path
.
join
(
'tls'
,
'ca.crt'
))
try
:
existing_cas
=
open
(
ca_path
)
.
read
()
.
strip
()
+
os
.
linesep
except
:
certificate_file
=
open
(
ca_path
,
'w'
)
certificate_file
.
write
(
ca
)
certificate_file
.
close
()
else
:
if
ca
not
in
existing_cas
:
certificate_file
=
open
(
ca_path
,
'w'
)
certificate_file
.
write
(
existing_cas
+
ca
)
certificate_file
.
close
()
settings
=
SIPSimpleSettings
()
settings
.
tls
.
ca_list
=
ca_path
settings
.
save
()
return
certificate_path
@
run_in_gui_thread
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
def
handle_notification
(
self
,
notification
):
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
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