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
f57fb537
Commit
f57fb537
authored
May 11, 2010
by
Luci Stanescu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for the bonjour neighbours group
parent
79d2f4dd
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
161 additions
and
38 deletions
+161
-38
contacts.py
blink/contacts.py
+125
-37
mainwindow.py
blink/mainwindow.py
+36
-1
No files found.
blink/contacts.py
View file @
f57fb537
This diff is collapsed.
Click to expand it.
blink/mainwindow.py
View file @
f57fb537
...
...
@@ -15,7 +15,7 @@ from zope.interface import implements
from
sipsimple.account
import
AccountManager
,
BonjourAccount
from
blink.contacts
import
Contact
,
ContactModel
,
ContactSearchModel
from
blink.contacts
import
BonjourNeighbour
,
Contact
,
ContactModel
,
ContactSearchModel
from
blink.resources
import
Resources
from
blink.util
import
run_in_gui_thread
...
...
@@ -68,6 +68,8 @@ class MainWindow(base_class, ui_class):
#self.connect(self.contact_list, QtCore.SIGNAL("doubleClicked(const QModelIndex &)"), self.double_click_action)
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
self
,
name
=
'BonjourAccountDidAddNeighbour'
)
notification_center
.
add_observer
(
self
,
name
=
'BonjourAccountDidRemoveNeighbour'
)
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountManagerDidChangeDefaultAccount"
)
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountManagerDidStart"
)
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountDidActivate"
)
...
...
@@ -139,11 +141,22 @@ class MainWindow(base_class, ui_class):
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
handler
(
notification
)
def
_NH_BonjourAccountDidAddNeighbour
(
self
,
notification
):
display_name
=
'
%
s (
%
s)'
%
(
notification
.
data
.
display_name
,
notification
.
data
.
host
)
contact
=
BonjourNeighbour
(
self
.
contact_model
.
bonjour_group
,
display_name
,
unicode
(
notification
.
data
.
uri
))
self
.
contact_model
.
addContact
(
contact
)
def
_NH_BonjourAccountDidRemoveNeighbour
(
self
,
notification
):
for
contact
in
(
c
for
c
in
self
.
contact_model
.
items
[:]
if
type
(
c
)
is
BonjourNeighbour
):
if
contact
.
uri
==
unicode
(
notification
.
data
.
uri
):
self
.
contact_model
.
removeContact
(
contact
)
def
_NH_SIPAccountDidActivate
(
self
,
notification
):
account
=
notification
.
sender
name
=
u'Bonjour'
if
account
is
BonjourAccount
()
else
account
.
id
icon
=
None
if
account
is
BonjourAccount
():
self
.
contact_model
.
addGroup
(
self
.
contact_model
.
bonjour_group
)
pixmap
=
QPixmap
()
if
pixmap
.
load
(
Resources
.
get
(
'icons/bonjour.png'
)):
pixmap
=
pixmap
.
scaled
(
16
,
16
,
Qt
.
KeepAspectRatio
,
Qt
.
SmoothTransformation
)
...
...
@@ -157,16 +170,38 @@ class MainWindow(base_class, ui_class):
account
=
notification
.
sender
name
=
u'Bonjour'
if
account
is
BonjourAccount
()
else
account
.
id
self
.
identity
.
removeItem
(
self
.
identity
.
findText
(
name
))
if
account
is
BonjourAccount
():
self
.
contact_model
.
removeGroup
(
self
.
contact_model
.
bonjour_group
)
def
_NH_SIPAccountManagerDidStart
(
self
,
notification
):
account
=
AccountManager
()
.
default_account
name
=
u'Bonjour'
if
account
is
BonjourAccount
()
else
account
.
id
self
.
identity
.
setCurrentIndex
(
self
.
identity
.
findText
(
name
))
if
not
BonjourAccount
()
.
enabled
and
self
.
contact_model
.
bonjour_group
in
self
.
contact_model
.
contact_groups
:
self
.
contact_model
.
removeGroup
(
self
.
contact_model
.
bonjour_group
)
if
notification
.
sender
.
default_account
is
BonjourAccount
():
group
=
self
.
contact_model
.
bonjour_group
group
.
previous_position
=
self
.
contact_model
.
contact_groups
.
index
(
group
)
self
.
contact_model
.
moveGroup
(
group
,
0
)
group
.
expand
()
def
_NH_SIPAccountManagerDidChangeDefaultAccount
(
self
,
notification
):
account
=
notification
.
data
.
account
old_account
=
notification
.
data
.
old_account
name
=
u'Bonjour'
if
account
is
BonjourAccount
()
else
account
.
id
self
.
identity
.
setCurrentIndex
(
self
.
identity
.
findText
(
name
))
if
account
is
BonjourAccount
():
group
=
self
.
contact_model
.
bonjour_group
group
.
previous_position
=
self
.
contact_model
.
contact_groups
.
index
(
group
)
self
.
contact_model
.
moveGroup
(
group
,
0
)
group
.
expand
()
elif
old_account
is
BonjourAccount
():
group
=
self
.
contact_model
.
bonjour_group
self
.
contact_model
.
moveGroup
(
group
,
group
.
previous_position
)
if
group
.
collapsed
and
not
group
.
user_collapsed
:
group
.
expand
()
elif
not
group
.
collapsed
and
group
.
user_collapsed
:
group
.
collapse
()
del
ui_class
,
base_class
...
...
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