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
c146010d
Commit
c146010d
authored
Dec 13, 2010
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added IP address monitor
parent
d8cc47fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
2 deletions
+47
-2
__init__.py
blink/__init__.py
+47
-2
No files found.
blink/__init__.py
View file @
c146010d
...
...
@@ -17,7 +17,8 @@ from PyQt4.QtGui import QApplication
from
application
import
log
from
application.notification
import
IObserver
,
NotificationCenter
from
application.python.util
import
Null
from
application.system
import
unlink
from
application.system
import
host
,
unlink
from
eventlet
import
api
from
gnutls.crypto
import
X509Certificate
,
X509PrivateKey
from
gnutls.errors
import
GNUTLSError
from
zope.interface
import
implements
...
...
@@ -26,7 +27,9 @@ from sipsimple.account import Account, AccountManager, BonjourAccount
from
sipsimple.application
import
SIPApplication
from
sipsimple.configuration.backend.file
import
FileBackend
from
sipsimple.configuration.settings
import
SIPSimpleSettings
from
sipsimple.util
import
makedirs
from
sipsimple.threading
import
run_in_twisted_thread
from
sipsimple.threading.green
import
run_in_green_thread
from
sipsimple.util
import
TimestampedNotificationData
,
makedirs
from
blink.configuration.account
import
AccountExtension
,
BonjourAccountExtension
from
blink.configuration.datatypes
import
InvalidToken
...
...
@@ -39,6 +42,43 @@ from blink.update import UpdateManager
from
blink.util
import
QSingleton
,
run_in_gui_thread
class
IPAddressMonitor
(
object
):
"""
An object which monitors the IP address used for the default route of the
host and posts a SystemIPAddressDidChange notification when a change is
detected.
"""
def
__init__
(
self
):
self
.
greenlet
=
None
@
run_in_green_thread
def
start
(
self
):
notification_center
=
NotificationCenter
()
if
self
.
greenlet
is
not
None
:
return
self
.
greenlet
=
api
.
getcurrent
()
current_address
=
host
.
default_ip
while
True
:
new_address
=
host
.
default_ip
# make sure the address stabilized
api
.
sleep
(
5
)
if
new_address
!=
host
.
default_ip
:
continue
if
new_address
!=
current_address
:
notification_center
.
post_notification
(
name
=
'SystemIPAddressDidChange'
,
sender
=
self
,
data
=
TimestampedNotificationData
(
old_ip_address
=
current_address
,
new_ip_address
=
new_address
))
current_address
=
new_address
api
.
sleep
(
5
)
@
run_in_twisted_thread
def
stop
(
self
):
if
self
.
greenlet
is
not
None
:
api
.
kill
(
self
.
greenlet
,
api
.
GreenletExit
())
self
.
greenlet
=
None
class
Blink
(
QApplication
):
__metaclass__
=
QSingleton
...
...
@@ -49,6 +89,7 @@ class Blink(QApplication):
self
.
application
=
SIPApplication
()
self
.
first_run
=
False
self
.
main_window
=
MainWindow
()
self
.
ip_address_monitor
=
IPAddressMonitor
()
self
.
update_manager
=
UpdateManager
()
self
.
main_window
.
check_for_updates_action
.
triggered
.
connect
(
self
.
update_manager
.
check_for_updates
)
...
...
@@ -166,6 +207,7 @@ class Blink(QApplication):
@
run_in_gui_thread
def
_NH_SIPApplicationDidStart
(
self
,
notification
):
self
.
ip_address_monitor
.
start
()
self
.
fetch_account
()
self
.
main_window
.
show
()
settings
=
SIPSimpleSettings
()
...
...
@@ -176,6 +218,9 @@ class Blink(QApplication):
self
.
main_window
.
google_contacts_dialog
.
open_for_incorrect_password
()
self
.
update_manager
.
initialize
()
def
_NH_SIPApplicationWillEnd
(
self
,
notification
):
self
.
ip_address_monitor
.
stop
()
def
_initialize_sipsimple
(
self
):
if
not
os
.
path
.
exists
(
ApplicationData
.
get
(
'config'
)):
self
.
first_run
=
True
...
...
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