Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
poezio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
178
Issues
178
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poezio
poezio
Commits
d693479d
Unverified
Commit
d693479d
authored
Apr 07, 2019
by
Maxime Buquet
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
safeJID: Remove some safeJID calls
Signed-off-by:
Maxime “pep” Buquet
<
pep@bouah.net
>
parent
cdd4a99c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
25 deletions
+39
-25
poezio/core/commands.py
poezio/core/commands.py
+2
-1
poezio/core/core.py
poezio/core/core.py
+12
-2
poezio/tabs/basetabs.py
poezio/tabs/basetabs.py
+10
-2
poezio/tabs/muctab.py
poezio/tabs/muctab.py
+2
-3
poezio/tabs/privatetab.py
poezio/tabs/privatetab.py
+12
-16
poezio/text_buffer.py
poezio/text_buffer.py
+1
-1
No files found.
poezio/core/commands.py
View file @
d693479d
...
...
@@ -369,7 +369,8 @@ class CommandCore:
# New tab
if
tab
is
None
:
tab
=
self
.
core
.
open_new_room
(
room
,
nick
,
password
=
password
)
tab
.
join
()
if
tab
is
not
None
:
tab
.
join
()
else
:
self
.
core
.
focus_tab
(
tab
)
if
tab
.
own_nick
==
nick
and
tab
.
joined
:
...
...
poezio/core/core.py
View file @
d693479d
...
...
@@ -1179,7 +1179,12 @@ class Core:
"""
Open a Private conversation in a MUC and focus if needed.
"""
complete_jid
=
room_name
+
'/'
+
user_nick
try
:
complete_jid_str
=
room_name
+
'/'
+
user_nick
complete_jid
=
JID
(
complete_jid_str
)
except
InvalidJID
:
self
.
information
(
'Invalid XMPP address %r for chat tab.'
,
complete_jid_str
)
return
None
# if the room exists, focus it and return
for
tab
in
self
.
get_tabs
(
tabs
.
PrivateTab
):
if
tab
.
name
==
complete_jid
:
...
...
@@ -1205,10 +1210,15 @@ class Core:
nick
:
str
,
*
,
password
:
Optional
[
str
]
=
None
,
focus
=
True
)
->
tabs
.
MucTab
:
focus
=
True
)
->
Optional
[
tabs
.
MucTab
]
:
"""
Open a new tab.MucTab containing a muc Room, using the specified nick
"""
try
:
room
=
JID
(
room
)
except
InvalidJID
:
self
.
information
(
'Invalid XMPP address %r for chat tab.'
,
room
)
return
None
new_tab
=
tabs
.
MucTab
(
self
,
room
,
nick
,
password
=
password
)
self
.
add_tab
(
new_tab
,
focus
)
self
.
refresh_window
()
...
...
poezio/tabs/basetabs.py
View file @
d693479d
...
...
@@ -20,7 +20,7 @@ from datetime import datetime
from
xml.etree
import
cElementTree
as
ET
from
typing
import
Any
,
Callable
,
Dict
,
List
,
Optional
from
slixmpp
import
JID
,
Message
from
slixmpp
import
JID
,
InvalidJID
,
Message
from
poezio.core.structs
import
Command
,
Completion
,
Status
from
poezio
import
timed_events
...
...
@@ -462,8 +462,16 @@ class ChatTab(Tab):
plugin_keys
=
{}
# type: Dict[str, Callable]
message_type
=
'chat'
def
__init__
(
self
,
core
,
jid
=
''
):
def
__init__
(
self
,
core
,
jid
:
JID
=
None
):
Tab
.
__init__
(
self
,
core
)
if
jid
is
not
None
and
not
isinstance
(
jid
,
JID
):
# XXX: Remove logging once we're more or less sure we've switched
# all calls.
log
.
debug
(
'ChatTab.name: %r: Not a JID object.'
,
jid
,
exc_info
=
True
)
try
:
jid
=
JID
(
jid
)
except
InvalidJID
:
log
.
debug
(
'ChatTab.name: invalid JID.'
)
self
.
name
=
jid
self
.
text_win
=
None
self
.
directed_presence
=
None
...
...
poezio/tabs/muctab.py
View file @
d693479d
...
...
@@ -55,7 +55,7 @@ class MucTab(ChatTab):
additional_information
=
{}
# type: Dict[str, Callable[[str], str]]
lagged
=
False
def
__init__
(
self
,
core
,
jid
,
nick
,
password
=
None
):
def
__init__
(
self
,
core
,
jid
:
JID
,
nick
:
str
,
password
:
str
=
None
):
ChatTab
.
__init__
(
self
,
core
,
jid
)
self
.
joined
=
False
self
.
_state
=
'disconnected'
...
...
@@ -63,7 +63,6 @@ class MucTab(ChatTab):
self
.
own_nick
=
nick
# self User object
self
.
own_user
=
None
# type: Optional[User]
self
.
name
=
jid
self
.
password
=
password
# buffered presences
self
.
presence_buffer
=
[]
...
...
@@ -1482,7 +1481,7 @@ class MucTab(ChatTab):
r
=
None
for
user
in
self
.
users
:
if
user
.
nick
==
nick
:
r
=
self
.
core
.
open_private_window
(
s
elf
.
name
,
user
.
nick
)
r
=
self
.
core
.
open_private_window
(
s
tr
(
self
.
name
)
,
user
.
nick
)
if
r
and
len
(
args
)
==
2
:
msg
=
args
[
1
]
self
.
core
.
tabs
.
current_tab
.
command_say
(
...
...
poezio/tabs/privatetab.py
View file @
d693479d
...
...
@@ -20,7 +20,6 @@ from poezio.tabs import OneToOneTab, MucTab, Tab
from
poezio
import
windows
from
poezio
import
xhtml
from
poezio.common
import
safeJID
from
poezio.config
import
config
from
poezio.core.structs
import
Command
from
poezio.decorators
import
refresh_wrapper
...
...
@@ -40,10 +39,9 @@ class PrivateTab(OneToOneTab):
message_type
=
'chat'
additional_information
=
{}
# type: Dict[str, Callable[[str], str]]
def
__init__
(
self
,
core
,
name
,
nick
):
def
__init__
(
self
,
core
,
name
:
JID
,
nick
:
str
):
OneToOneTab
.
__init__
(
self
,
core
,
name
)
self
.
own_nick
=
nick
self
.
name
=
name
self
.
text_win
=
windows
.
TextWin
()
self
.
_text_buffer
.
add_window
(
self
.
text_win
)
self
.
info_header
=
windows
.
PrivateInfoWin
()
...
...
@@ -65,13 +63,13 @@ class PrivateTab(OneToOneTab):
shortdesc
=
'Get the software version of a jid.'
)
self
.
resize
()
self
.
parent_muc
=
self
.
core
.
tabs
.
by_name_and_class
(
s
afeJID
(
name
)
.
bare
,
MucTab
)
s
elf
.
name
.
bare
,
MucTab
)
self
.
on
=
True
self
.
update_commands
()
self
.
update_keys
()
def
remote_user_color
(
self
):
user
=
self
.
parent_muc
.
get_user_by_name
(
s
afeJID
(
self
.
name
)
.
resource
)
user
=
self
.
parent_muc
.
get_user_by_name
(
s
elf
.
name
.
resource
)
if
user
:
return
dump_tuple
(
user
.
color
)
return
super
().
remote_user_color
()
...
...
@@ -105,9 +103,7 @@ class PrivateTab(OneToOneTab):
del
PrivateTab
.
additional_information
[
plugin_name
]
def
load_logs
(
self
,
log_nb
):
logs
=
logger
.
get_logs
(
safeJID
(
self
.
name
).
full
.
replace
(
'/'
,
'
\\
'
),
log_nb
)
return
logs
return
logger
.
get_logs
(
self
.
name
.
full
.
replace
(
'/'
,
'
\\
'
),
log_nb
)
def
log_message
(
self
,
txt
,
nickname
,
time
=
None
,
typ
=
1
):
"""
...
...
@@ -221,7 +217,7 @@ class PrivateTab(OneToOneTab):
"""
if
args
:
return
self
.
core
.
command
.
version
(
args
[
0
])
jid
=
s
afeJID
(
self
.
name
)
jid
=
s
elf
.
name
self
.
core
.
xmpp
.
plugin
[
'xep_0092'
].
get_version
(
jid
,
callback
=
self
.
core
.
handler
.
on_version_result
)
...
...
@@ -233,7 +229,7 @@ class PrivateTab(OneToOneTab):
if
arg
and
arg
[
0
]:
self
.
parent_muc
.
command_info
(
arg
[
0
])
else
:
user
=
s
afeJID
(
self
.
name
)
.
resource
user
=
s
elf
.
name
.
resource
self
.
parent_muc
.
command_info
(
user
)
def
resize
(
self
):
...
...
@@ -276,7 +272,7 @@ class PrivateTab(OneToOneTab):
self
.
input
.
refresh
()
def
get_nick
(
self
):
return
s
afeJID
(
self
.
name
)
.
resource
return
s
elf
.
name
.
resource
def
on_input
(
self
,
key
,
raw
):
if
not
raw
and
key
in
self
.
key_func
:
...
...
@@ -288,7 +284,7 @@ class PrivateTab(OneToOneTab):
empty_after
=
self
.
input
.
get_text
()
==
''
or
(
self
.
input
.
get_text
().
startswith
(
'/'
)
and
not
self
.
input
.
get_text
().
startswith
(
'//'
))
tab
=
self
.
core
.
tabs
.
by_name_and_class
(
s
afeJID
(
self
.
name
)
.
bare
,
MucTab
)
tab
=
self
.
core
.
tabs
.
by_name_and_class
(
s
elf
.
name
.
bare
,
MucTab
)
if
tab
and
tab
.
joined
:
self
.
send_composing_chat_state
(
empty_after
)
return
False
...
...
@@ -301,7 +297,7 @@ class PrivateTab(OneToOneTab):
self
.
text_win
.
remove_line_separator
()
self
.
text_win
.
add_line_separator
(
self
.
_text_buffer
)
tab
=
self
.
core
.
tabs
.
by_name_and_class
(
s
afeJID
(
self
.
name
)
.
bare
,
MucTab
)
tab
=
self
.
core
.
tabs
.
by_name_and_class
(
s
elf
.
name
.
bare
,
MucTab
)
if
tab
and
tab
.
joined
and
config
.
get_by_tabname
(
'send_chat_states'
,
self
.
general_jid
)
and
self
.
on
:
self
.
send_chat_state
(
'inactive'
)
...
...
@@ -310,7 +306,7 @@ class PrivateTab(OneToOneTab):
def
on_gain_focus
(
self
):
self
.
state
=
'current'
curses
.
curs_set
(
1
)
tab
=
self
.
core
.
tabs
.
by_name_and_class
(
s
afeJID
(
self
.
name
)
.
bare
,
MucTab
)
tab
=
self
.
core
.
tabs
.
by_name_and_class
(
s
elf
.
name
.
bare
,
MucTab
)
if
tab
and
tab
.
joined
and
config
.
get_by_tabname
(
'send_chat_states'
,
self
.
general_jid
,
...
...
@@ -345,7 +341,7 @@ class PrivateTab(OneToOneTab):
'info_col'
:
dump_tuple
(
get_theme
().
COLOR_INFORMATION_TEXT
)
},
typ
=
2
)
new_jid
=
s
afeJID
(
self
.
name
)
.
bare
+
'/'
+
user
.
nick
new_jid
=
s
elf
.
name
.
bare
+
'/'
+
user
.
nick
self
.
name
=
new_jid
return
self
.
core
.
tabs
.
current_tab
is
self
...
...
@@ -426,7 +422,7 @@ class PrivateTab(OneToOneTab):
self
.
add_message
(
txt
=
reason
,
typ
=
2
)
def
matching_names
(
self
):
return
[(
3
,
s
afeJID
(
self
.
name
)
.
resource
),
(
4
,
self
.
name
)]
return
[(
3
,
s
elf
.
name
.
resource
),
(
4
,
self
.
name
)]
def
add_error
(
self
,
error_message
):
theme
=
get_theme
()
...
...
poezio/text_buffer.py
View file @
d693479d
...
...
@@ -204,7 +204,7 @@ class TextBuffer:
"""Mark a message as errored"""
return
self
.
_edit_ack
(
-
1
,
old_id
,
jid
,
append
=
error
)
def
_edit_ack
(
self
,
value
:
int
,
old_id
:
str
,
jid
:
str
,
def
_edit_ack
(
self
,
value
:
int
,
old_id
:
str
,
jid
:
JID
,
append
:
str
=
''
)
->
Union
[
None
,
bool
,
Message
]:
"""
Edit the ack status of a message, and optionally
...
...
Maxime Buquet
@ppjet
mentioned in commit
bf222546
·
Apr 08, 2019
mentioned in commit
bf222546
mentioned in commit bf2225468e8f496a45db477b596eb7d233cb813f
Toggle commit list
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