Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Daniel Brötzmann
gajim
Commits
6b754525
Commit
6b754525
authored
21 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
keyboard interrupt
comments
parent
e8b6c78f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
common/debug.py
+2
-2
2 additions, 2 deletions
common/debug.py
core/core.py
+23
-6
23 additions, 6 deletions
core/core.py
plugins/gtkgui/gtkgui.py
+59
-3
59 additions, 3 deletions
plugins/gtkgui/gtkgui.py
runCore.py
+1
-0
1 addition, 0 deletions
runCore.py
with
85 additions
and
11 deletions
common/debug.py
+
2
−
2
View file @
6b754525
...
...
@@ -131,7 +131,7 @@ def __init__( self,
# with prefix = chr(27) + '[34m'
# sufix = chr(27) + '[37;1m\n'
#
prefix
=
'
DEBUG:
'
,
prefix
=
color_red
+
'
DEBUG:
'
+
color_white
,
sufix
=
'
\n
'
,
#
# If you want unix style timestamps,
...
...
@@ -139,7 +139,7 @@ def __init__( self,
# 1 before prefix, good when prefix is a string
# 2 after prefix, good when prefix is a color
#
time_stamp
=
0
,
time_stamp
=
2
,
#
# flag_show should normaly be of, but can be turned on to get a
# good view of what flags are actually used for calls,
...
...
This diff is collapsed.
Click to expand it.
core/core.py
+
23
−
6
View file @
6b754525
...
...
@@ -35,6 +35,7 @@
CONFPATH
=
"
~/.gajimrc
"
class
GajimCore
:
"""
Core
"""
def
__init__
(
self
):
self
.
connected
=
0
self
.
cfgParser
=
common
.
optparser
.
OptionsParser
(
CONFPATH
)
...
...
@@ -43,11 +44,13 @@ def __init__(self):
# END __init__
def
messageCB
(
self
,
con
,
msg
):
"""
Called when we recieve a message
"""
self
.
hub
.
sendPlugin
(
'
MSG
'
,
(
msg
.
getFrom
().
getBasic
(),
\
msg
.
getBody
()))
# END messageCB
def
presenceCB
(
self
,
con
,
prs
):
"""
Called when we recieve a presence
"""
who
=
str
(
prs
.
getFrom
())
type
=
prs
.
getType
()
if
type
==
None
:
type
=
'
available
'
...
...
@@ -98,6 +101,7 @@ def presenceCB(self, con, prs):
# END presenceCB
def
disconnectedCB
(
self
,
con
):
"""
Called when we are disconnected
"""
log
.
debug
(
"
disconnectedCB
"
)
if
self
.
connected
==
1
:
self
.
connected
=
0
...
...
@@ -106,13 +110,14 @@ def disconnectedCB(self, con):
# END disconenctedCB
def
connect
(
self
,
account
):
"""
Connect and authentificate to the Jabber server
"""
self
.
cfgParser
.
parseCfgFile
()
hostname
=
self
.
cfgParser
.
__getattr__
(
"
%s
"
%
account
+
"
_hostname
"
)
name
=
self
.
cfgParser
.
__getattr__
(
"
%s
"
%
account
+
"
_name
"
)
password
=
self
.
cfgParser
.
__getattr__
(
"
%s
"
%
account
+
"
_password
"
)
ressource
=
self
.
cfgParser
.
__getattr__
(
"
%s
"
%
account
+
"
_ressource
"
)
self
.
con
=
common
.
jabber
.
Client
(
host
=
\
hostname
,
debug
=
[
common
.
jabber
.
DBG_
ALWAYS
],
log
=
sys
.
stderr
,
connection
=
common
.
xmlstream
.
TCP
,
port
=
5222
)
hostname
,
debug
=
[
common
.
jabber
.
DBG_
INIT
],
log
=
sys
.
stderr
,
connection
=
common
.
xmlstream
.
TCP
,
port
=
5222
)
# hostname, debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, connection=common.xmlstream.TCP_SSL, port=5223)
try
:
self
.
con
.
connect
()
...
...
@@ -121,15 +126,17 @@ def connect(self, account):
self
.
hub
.
sendPlugin
(
'
STATUS
'
,
'
offline
'
)
self
.
hub
.
sendPlugin
(
'
WARNING
'
,
"
Couldn
'
t connect to %s
"
%
hostname
)
return
0
except
self
.
con
.
socket
.
gaierror
,
e
:
log
.
debug
(
"
Couldn
'
t connect to %s %s
"
%
(
hostname
,
e
))
self
.
hub
.
sendPlugin
(
'
STATUS
'
,
'
offline
'
)
self
.
hub
.
sendPlugin
(
'
WARNING
'
,
"
Couldn
'
t connect to %s
"
%
hostname
)
return
0
else
:
log
.
debug
(
"
Connected to server
"
)
self
.
con
.
registerHandler
(
'
message
'
,
self
.
messageCB
)
self
.
con
.
registerHandler
(
'
presence
'
,
self
.
presenceCB
)
self
.
con
.
setDisconnectHandler
(
self
.
disconnectedCB
)
# self.con.setMessageHandler(self.messageCB)
# self.con.setPresenceHandler(self.presenceCB)
# self.con.setDisconnectHandler(self.disconnectedCB)
#BUG in jabberpy library : if hostname is wrong : "boucle"
if
self
.
con
.
auth
(
name
,
password
,
ressource
):
self
.
con
.
requestRoster
()
...
...
@@ -148,6 +155,7 @@ def connect(self, account):
# END connect
def
mainLoop
(
self
):
"""
Main Loop : Read the incomming queue to execute commands comming from plugins and process Jabber
"""
while
1
:
if
not
self
.
hub
.
queueIn
.
empty
():
ev
=
self
.
hub
.
queueIn
.
get
()
...
...
@@ -238,8 +246,9 @@ def mainLoop(self):
# END GajimCore
def
loadPlugins
(
gc
):
"""
Load defaults plugins :
'
modules
'
option in section Core in ConfFile and register then to the hub
"""
modStr
=
gc
.
cfgParser
.
Core_modules
if
modStr
:
if
modStr
:
mods
=
string
.
split
(
modStr
,
'
'
)
for
mod
in
mods
:
...
...
@@ -260,7 +269,15 @@ def loadPlugins(gc):
# END loadPLugins
def
start
():
"""
Start the Core
"""
gc
=
GajimCore
()
loadPlugins
(
gc
)
gc
.
mainLoop
()
try
:
gc
.
mainLoop
()
except
KeyboardInterrupt
:
print
"
Keyboard Interrupt : Bye!
"
if
self
.
r
.
connected
:
self
.
r
.
con
.
disconnect
()
gc
.
hub
.
sendPlugin
(
'
QUIT
'
,
())
return
0
# END start
This diff is collapsed.
Click to expand it.
plugins/gtkgui/gtkgui.py
+
59
−
3
View file @
6b754525
...
...
@@ -30,6 +30,7 @@
Waccounts
=
0
class
user
:
"""
Informations concerning each users
"""
def
__init__
(
self
,
*
args
):
if
len
(
args
)
==
0
:
self
.
jid
=
''
...
...
@@ -57,13 +58,17 @@ def __init__(self, *args):
else
:
raise
TypeError
,
'
bad arguments
'
class
info_user
:
"""
Class for user
'
s information window
"""
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
window
.
destroy
()
def
add_grp_to_user
(
self
,
model
,
path
,
iter
):
"""
Insert user to the group in inter
"""
self
.
user
.
groups
.
append
(
model
.
get_value
(
iter
,
0
))
def
on_close
(
self
,
widget
):
"""
Save user
'
s informations and update the roster on the Jabber server
"""
for
i
in
self
.
r
.
l_contact
[
self
.
user
.
jid
][
'
iter
'
]:
self
.
r
.
treestore
.
remove
(
i
)
self
.
r
.
l_contact
[
self
.
user
.
jid
][
'
iter
'
]
=
[]
...
...
@@ -75,26 +80,34 @@ def on_close(self, widget):
self
.
delete_event
(
self
)
def
add_grp
(
self
,
model
,
path
,
iter
,
stors
):
"""
Transfert the iter from stors[0] to stors[1]
"""
i
=
stors
[
1
].
append
()
stors
[
1
].
set
(
i
,
0
,
stors
[
0
].
get_value
(
iter
,
0
))
stors
[
0
].
remove
(
iter
)
def
on_add
(
self
,
widget
):
"""
When Add button is clicked
"""
select
=
self
.
list1
.
get_selection
()
select
.
selected_foreach
(
self
.
add_grp
,
(
self
.
store1
,
self
.
store2
))
def
on_remove
(
self
,
widget
):
"""
When Remove button is clicked
"""
select
=
self
.
list2
.
get_selection
()
select
.
selected_foreach
(
self
.
add_grp
,
(
self
.
store2
,
self
.
store1
))
def
on_new_key_pressed
(
self
,
widget
,
event
):
"""
If enter is pressed in new group entry, add the group
"""
if
event
.
keyval
==
gtk
.
keysyms
.
Return
:
txt
=
self
.
entry_new
.
get_text
()
iter
=
self
.
store1
.
append
()
self
.
store1
.
set
(
iter
,
0
,
txt
)
self
.
entry_new
.
set_text
(
''
)
return
1
else
:
return
0
def
init_lists
(
self
):
"""
Initialize both available and current listStores
"""
#list available
self
.
store1
=
gtk
.
ListStore
(
gobject
.
TYPE_STRING
)
for
i
in
self
.
r
.
l_group
.
keys
():
...
...
@@ -127,21 +140,28 @@ def __init__(self, user, roster):
self
.
xml
.
get_widget
(
'
label_id
'
).
set_text
(
user
.
jid
)
self
.
xml
.
get_widget
(
'
label_resource
'
).
set_text
(
user
.
resource
)
self
.
xml
.
get_widget
(
'
entry_name
'
).
set_text
(
user
.
name
)
self
.
xml
.
get_widget
(
'
label_status
'
).
set_text
(
user
.
show
+
'
:
'
+
user
.
status
)
if
not
user
.
status
:
user
.
status
=
''
self
.
xml
.
get_widget
(
'
label_status
'
).
set_text
(
user
.
show
+
'
:
'
+
\
user
.
status
)
self
.
init_lists
()
self
.
xml
.
signal_connect
(
'
gtk_widget_destroy
'
,
self
.
delete_event
)
self
.
xml
.
signal_connect
(
'
on_close_clicked
'
,
self
.
on_close
)
self
.
xml
.
signal_connect
(
'
on_add_clicked
'
,
self
.
on_add
)
self
.
xml
.
signal_connect
(
'
on_remove_clicked
'
,
self
.
on_remove
)
self
.
xml
.
signal_connect
(
'
on_entry_new_key_press_event
'
,
self
.
on_new_key_pressed
)
self
.
xml
.
signal_connect
(
'
on_entry_new_key_press_event
'
,
\
self
.
on_new_key_pressed
)
class
prefs
:
"""
Class for Preferences window
"""
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
window
.
destroy
()
def
on_color_button_clicked
(
self
,
widget
):
"""
Open a ColorSelectionDialog and change button
'
s color
"""
if
widget
.
name
==
'
colorIn
'
:
color
=
self
.
colorIn
da
=
self
.
da_in
...
...
@@ -169,6 +189,7 @@ def on_color_button_clicked(self, widget):
colorseldlg
.
destroy
()
def
write_cfg
(
self
):
"""
Save preferences in config File and apply them
"""
#Color for incomming messages
colSt
=
'
#
'
+
(
hex
(
self
.
colorIn
.
red
)
+
'
0
'
)[
2
:
4
]
\
+
(
hex
(
self
.
colorIn
.
green
)
+
'
0
'
)[
2
:
4
]
\
...
...
@@ -235,10 +256,12 @@ def write_cfg(self):
self
.
r
.
redraw_roster
()
def
on_ok
(
self
,
widget
):
"""
When Ok button is clicked
"""
self
.
write_cfg
()
self
.
window
.
destroy
()
def
__init__
(
self
,
roster
):
"""
Initialize Preference window
"""
self
.
xml
=
gtk
.
glade
.
XML
(
'
plugins/gtkgui/gtkgui.glade
'
,
'
Prefs
'
)
self
.
window
=
self
.
xml
.
get_widget
(
"
Prefs
"
)
self
.
r
=
roster
...
...
@@ -320,19 +343,25 @@ def __init__(self, roster):
self
.
spin_autoxatime
.
set_value
(
ti
)
self
.
xml
.
signal_connect
(
'
gtk_widget_destroy
'
,
self
.
delete_event
)
self
.
xml
.
signal_connect
(
'
on_but_col_clicked
'
,
self
.
on_color_button_clicked
)
self
.
xml
.
signal_connect
(
'
on_but_col_clicked
'
,
\
self
.
on_color_button_clicked
)
self
.
xml
.
signal_connect
(
'
on_ok_clicked
'
,
self
.
on_ok
)
class
away_msg
:
"""
Class for Away Message Window
"""
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
window
.
destroy
()
self
.
window
.
destroy
()
def
on_ok
(
self
):
"""
When Ok button is clicked
"""
beg
,
end
=
self
.
txtBuffer
.
get_bounds
()
self
.
msg
=
self
.
txtBuffer
.
get_text
(
beg
,
end
,
0
)
self
.
window
.
destroy
()
def
run
(
self
):
"""
Wait for Ok button to be pressed and return away messsage
"""
rep
=
self
.
window
.
run
()
if
rep
==
gtk
.
RESPONSE_OK
:
self
.
on_ok
()
...
...
@@ -347,10 +376,13 @@ def __init__(self):
self
.
xml
.
signal_connect
(
'
gtk_widget_destroy
'
,
self
.
delete_event
)
class
add
:
"""
Class for Add user window
"""
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
Wadd
.
destroy
()
def
on_subscribe
(
self
,
widget
):
"""
When Subscribe button is clicked
"""
who
=
self
.
xml
.
get_widget
(
"
entry_who
"
).
get_text
()
buf
=
self
.
xml
.
get_widget
(
"
textview_sub
"
).
get_buffer
()
start_iter
=
buf
.
get_start_iter
()
...
...
@@ -369,7 +401,9 @@ def __init__(self, roster, jid=None):
self
.
xml
.
signal_connect
(
'
on_button_sub_clicked
'
,
self
.
on_subscribe
)
class
warning
:
"""
Class for warning window : print a warning message
"""
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
window
.
destroy
()
def
__init__
(
self
,
txt
):
...
...
@@ -379,7 +413,9 @@ def __init__(self, txt):
self
.
xml
.
signal_connect
(
'
gtk_widget_destroy
'
,
self
.
delete_event
)
class
about
:
"""
Class for about window
"""
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
Wabout
.
destroy
()
def
__init__
(
self
):
...
...
@@ -388,10 +424,13 @@ def __init__(self):
self
.
xml
.
signal_connect
(
'
gtk_widget_destroy
'
,
self
.
delete_event
)
class
account_pref
:
"""
Class for account informations
"""
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
window
.
destroy
()
def
init_account
(
self
,
infos
):
"""
Initialize window with defaults values
"""
if
infos
.
has_key
(
'
name
'
):
self
.
xml
.
get_widget
(
"
entry_name
"
).
set_text
(
infos
[
'
name
'
])
if
infos
.
has_key
(
'
jid
'
):
...
...
@@ -402,6 +441,7 @@ def init_account(self, infos):
self
.
xml
.
get_widget
(
"
entry_ressource
"
).
set_text
(
infos
[
'
ressource
'
])
def
on_save_clicked
(
self
,
widget
):
"""
When save button is clicked : Save informations in config file
"""
name
=
self
.
xml
.
get_widget
(
"
entry_name
"
).
get_text
()
jid
=
self
.
xml
.
get_widget
(
'
entry_jid
'
).
get_text
()
if
(
name
==
''
):
...
...
@@ -465,25 +505,32 @@ def __init__(self, accs, infos = {}):
self
.
xml
.
signal_connect
(
'
on_save_clicked
'
,
self
.
on_save_clicked
)
class
accounts
:
"""
Class for accounts window : lists of accounts
"""
def
delete_event
(
self
,
widget
):
"""
close window
"""
global
Waccounts
Waccounts
=
0
self
.
window
.
destroy
()
def
init_accounts
(
self
):
"""
initialize listStore with existing accounts
"""
self
.
model
.
clear
()
for
account
in
self
.
accounts
:
iter
=
self
.
model
.
append
()
self
.
model
.
set
(
iter
,
0
,
account
,
1
,
self
.
cfgParser
.
__getattr__
(
"
%s
"
%
account
+
"
_hostname
"
))
def
on_row_activated
(
self
,
widget
):
"""
Activate delete and modify buttons when a row is selected
"""
self
.
modButt
.
set_sensitive
(
TRUE
)
self
.
delButt
.
set_sensitive
(
TRUE
)
def
on_new_clicked
(
self
,
widget
):
"""
When new button is clicked : open an account information window
"""
account_pref
(
self
)
def
on_delete_clicked
(
self
,
widget
):
"""
When delete button is clicked :
Remove an account from the listStore and from the config file
"""
sel
=
self
.
treeview
.
get_selection
()
(
mod
,
iter
)
=
sel
.
get_selected
()
account
=
self
.
model
.
get_value
(
iter
,
0
)
...
...
@@ -496,6 +543,8 @@ def on_delete_clicked(self, widget):
self
.
init_accounts
()
def
on_modify_clicked
(
self
,
widget
):
"""
When modify button is clicked :
open the account information window for this account
"""
infos
=
{}
sel
=
self
.
treeview
.
get_selection
()
(
mod
,
iter
)
=
sel
.
get_selected
()
...
...
@@ -534,6 +583,7 @@ def __init__(self, roster):
class
confirm
:
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
window
.
destroy
()
def
req_usub
(
self
,
widget
):
...
...
@@ -554,6 +604,7 @@ def __init__(self, roster, iter):
class
authorize
:
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
window
.
destroy
()
def
auth
(
self
,
widget
):
...
...
@@ -578,6 +629,7 @@ def __init__(self, roster, jid):
class
agent_reg
:
def
delete_event
(
self
,
widget
):
"""
close window
"""
self
.
window
.
destroy
()
def
draw_table
(
self
):
...
...
@@ -620,6 +672,7 @@ def __init__(self, agent, infos, roster):
class
browser
:
def
delete_event
(
self
,
widget
):
"""
close window
"""
global
Wbrowser
Wbrowser
=
0
self
.
window
.
destroy
()
...
...
@@ -665,6 +718,7 @@ def __init__(self, roster):
class
message
:
def
delete_event
(
self
,
widget
):
"""
close window
"""
del
self
.
r
.
tab_messages
[
self
.
user
.
jid
]
self
.
window
.
destroy
()
...
...
@@ -1257,6 +1311,8 @@ def read_queue(self):
self
.
r
.
cfgParser
.
parseCfgFile
()
if
(
Waccounts
!=
0
):
Waccounts
.
init_accounts
()
elif
ev
[
0
]
==
'
QUIT
'
:
self
.
r
.
on_quit
(
self
)
return
1
def
read_sleepy
(
self
):
...
...
This diff is collapsed.
Click to expand it.
runCore.py
+
1
−
0
View file @
6b754525
...
...
@@ -28,3 +28,4 @@
import
core
core
.
core
.
start
()
print
"
Core Stopped
"
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