Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
e7288176
Commit
e7288176
authored
18 years ago
by
sb
Browse files
Options
Downloads
Patches
Plain Diff
remove standalone stuff
parent
99e8bf1d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/zeroconf.py
+10
-10
10 additions, 10 deletions
src/zeroconf.py
with
10 additions
and
10 deletions
src/zeroconf.py
+
10
−
10
View file @
e7288176
#!/usr/bin/python
import
os
,
sys
import
os
import
sys
try
:
import
avahi
,
gobject
,
dbus
...
...
@@ -12,8 +11,6 @@ try:
except
ImportError
,
e
:
pass
service_browsers
=
{}
class
Zeroconf
:
def
__init__
(
self
,
name
):
self
.
domain
=
None
# specific domain to browse
...
...
@@ -22,6 +19,7 @@ class Zeroconf:
self
.
name
=
name
# service name / username
self
.
txt
=
{}
self
.
service_browsers
=
{}
self
.
contacts
=
{}
# all current local contacts with data
self
.
entrygroup
=
''
...
...
@@ -42,10 +40,8 @@ class Zeroconf:
del
self
.
contacts
[(
interface
,
name
,
domain
)]
def
new_service_type
(
self
,
interface
,
protocol
,
stype
,
domain
,
flags
):
global
service_browsers
# Are we already browsing this domain for this type?
if
service_browsers
.
has_key
((
interface
,
protocol
,
stype
,
domain
)):
if
self
.
service_browsers
.
has_key
((
interface
,
protocol
,
stype
,
domain
)):
return
print
"
Browsing for services of type
'
%s
'
in domain
'
%s
'
on %i.%i ...
"
%
(
stype
,
domain
,
interface
,
protocol
)
...
...
@@ -56,7 +52,7 @@ class Zeroconf:
b
.
connect_to_signal
(
'
ItemNew
'
,
self
.
new_service_callback
)
b
.
connect_to_signal
(
'
ItemRemove
'
,
self
.
remove_service_callback
)
service_browsers
[(
interface
,
protocol
,
stype
,
domain
)]
=
b
self
.
service_browsers
[(
interface
,
protocol
,
stype
,
domain
)]
=
b
def
new_domain_callback
(
self
,
interface
,
protocol
,
domain
,
flags
):
if
domain
!=
"
local
"
:
...
...
@@ -164,13 +160,16 @@ class Zeroconf:
self
.
resolve_all
return
self
.
contacts
def
set_status
(
self
,
status
):
def
set_status
(
self
,
status
):
self
.
txt
[(
'
status
'
)]
=
status
txt
=
avahi
.
dict_to_txt_array
(
self
.
txt
)
self
.
entrygroup
.
UpdateServiceTxt
(
avahi
.
IF_UNSPEC
,
avahi
.
PROTO_UNSPEC
,
dbus
.
UInt32
(
0
),
self
.
name
,
self
.
stype
,
''
,
txt
,
reply_handler
=
self
.
service_updated_callback
,
error_handler
=
self
.
print_error_callback
)
# self.entrygroup.Commit() # TODO: necessary?
# END Zeroconf
'''
def main():
zeroconf = Zeroconf(
'
foo
'
)
...
...
@@ -186,3 +185,4 @@ def main():
if __name__ ==
"
__main__
"
:
main()
'''
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment