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
9ac7e753
Commit
9ac7e753
authored
18 years ago
by
sb
Browse files
Options
Downloads
Patches
Plain Diff
make sending compatible with ichat and adium
parent
da06dfb6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/zeroconf/connection_zeroconf.py
+2
-3
2 additions, 3 deletions
src/common/zeroconf/connection_zeroconf.py
src/common/zeroconf/zeroconf.py
+24
-16
24 additions, 16 deletions
src/common/zeroconf/zeroconf.py
with
26 additions
and
19 deletions
src/common/zeroconf/connection_zeroconf.py
+
2
−
3
View file @
9ac7e753
...
...
@@ -232,7 +232,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
def
change_status
(
self
,
show
,
msg
,
sync
=
False
,
auto
=
False
):
if
not
show
in
STATUS_LIST
:
return
-
1
check
=
True
#to check for errors from zeroconf
# 'connect'
...
...
@@ -307,7 +307,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
msg_iq
=
common
.
xmpp
.
Message
(
to
=
fjid
,
body
=
msgtxt
,
typ
=
'
normal
'
)
if
msgenc
:
msg_iq
.
setTag
(
common
.
xmpp
.
NS_ENCRYPTED
+
'
x
'
).
setData
(
msgenc
)
...
...
@@ -342,7 +341,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
kind
=
'
single_msg_sent
'
gajim
.
logger
.
write
(
kind
,
jid
,
log_msg
)
self
.
zeroconf
.
send_message
(
jid
,
msgtxt
)
self
.
zeroconf
.
send_message
(
jid
,
msgtxt
,
type
)
self
.
dispatch
(
'
MSGSENT
'
,
(
jid
,
msg
,
keyID
))
...
...
This diff is collapsed.
Click to expand it.
src/common/zeroconf/zeroconf.py
+
24
−
16
View file @
9ac7e753
...
...
@@ -43,6 +43,7 @@ class Zeroconf:
self
.
contacts
=
{}
# all current local contacts with data
self
.
entrygroup
=
None
self
.
connected
=
False
self
.
announced
=
False
## handlers for dbus callbacks
...
...
@@ -158,12 +159,10 @@ class Zeroconf:
# make zeroconf-valid names
def
replace_show
(
self
,
show
):
if
show
==
'
chat
'
or
show
==
''
:
show
=
'
online
'
if
show
==
'
chat
'
or
show
==
'
online
'
or
show
==
''
:
show
=
'
avail
'
elif
show
==
'
xa
'
:
show
=
'
away
'
elif
show
==
'
online
'
:
show
=
'
avail
'
return
show
def
create_service
(
self
):
...
...
@@ -197,16 +196,20 @@ class Zeroconf:
if
state
==
avahi
.
SERVER_RUNNING
:
self
.
create_service
()
self
.
announced
=
True
return
True
else
:
return
False
def
remove_announce
(
self
):
if
self
.
announced
==
False
:
return
False
try
:
if
self
.
entrygroup
.
GetState
()
!=
avahi
.
ENTRY_GROUP_FAILURE
:
self
.
entrygroup
.
Reset
()
self
.
entrygroup
.
Free
()
self
.
entrygroup
=
None
self
.
announced
=
False
return
True
else
:
return
False
...
...
@@ -250,8 +253,9 @@ class Zeroconf:
return
True
def
disconnect
(
self
):
self
.
connected
=
False
self
.
remove_announce
()
if
self
.
connected
:
self
.
connected
=
False
self
.
remove_announce
()
# refresh txt data of all contacts manually (no callback available)
def
resolve_all
(
self
):
...
...
@@ -292,26 +296,30 @@ class Zeroconf:
raise
RuntimeError
,
"
socket connection broken
"
totalsent
=
totalsent
+
sent
def
send_message
(
self
,
jid
,
msg
):
def
send_message
(
self
,
jid
,
msg
,
type
=
'
chat
'
):
print
'
zeroconf.py: send_message:
'
+
msg
jid
=
self
.
recreate_bad_jid
(
jid
)
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
#sock.setblocking(False)
sock
.
connect
(
(
self
.
contacts
[
jid
][
4
],
self
.
contacts
[
jid
][
6
]
)
)
try
:
recvd
=
sock
.
recv
(
16384
)
except
:
recvd
=
''
print
'
receive:
'
+
recvd
self
.
send
(
"
<?xml version=
'
1.0
'
encoding=
'
UTF-8
'
?><stream:stream to=
"
+
self
.
contacts
[
jid
][
5
]
+
"
xmlns=
'
jabber:client
'
xmlns:stream=
'
http://etherx.jabber.org/streams
'
>
"
,
sock
)
self
.
send
(
"
<message to=
"
+
jid
+
"
type=
'
chat
'
><body>
"
+
msg
+
"
</body><html xmlns=
'
html://www.w3.org/1999/xhtml
'
><body ichatballoncolor=
'
#111111
'
ichattextcolor=
'
#000000
'
><font face=
'
Courier
'
ABSZ=
'
3
'
>
"
+
msg
+
"
</font></body></html><x xmlns=
'
jabber:x:event
'
><delivered /></x></message>
"
,
sock
)
# jep-0174 wants clients to use the port from the srv record
# but at least adium uses the txt record (port.p2pj)
#sock.connect ( ( self.contacts[jid][4], self.contacts[jid][6] ) )
sock
.
connect
(
(
self
.
contacts
[
jid
][
4
],
int
((
self
.
txt_array_to_dict
(
self
.
contacts
[
jid
][
7
]))[
'
port.p2pj
'
])
)
)
#TODO: better use an xml-class for this...
self
.
send
(
"
<?xml version=
'
1.0
'
encoding=
'
UTF-8
'
?><stream:stream xmlns=
'
jabber:client
'
xmlns:stream=
'
http://etherx.jabber.org/streams
'
>
"
,
sock
)
try
:
recvd
=
sock
.
recv
(
16384
)
except
:
recvd
=
''
print
'
receive:
'
+
recvd
#adium requires the html parts
self
.
send
(
"
<message to=
'"
+
jid
+
"'
from=
'"
+
self
.
name
+
"'
type=
'"
+
type
+
"'
><body>
"
+
msg
+
"
</body><html xmlns=
'
html://www.w3.org/1999/xhtml
'
><body ichatballoncolor=
'
#5598d7
'
ichattextcolor=
'
#000000
'
><font face=
'
Courier
'
ABSZ=
'
3
'
>
"
+
msg
+
"
</font></body></html><x xmlns=
'
jabber:x:event
'
><composing /></x></message>
"
,
sock
)
# self.send("<message to='" + jid + "' from='" + self.name +"' type='" + type + "'><body>" + msg + "</body></message>", sock)
self
.
send
(
'
</stream>
'
,
sock
)
sock
.
close
()
...
...
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