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
e7345baf
Commit
e7345baf
authored
19 years ago
by
nkour
Browse files
Options
Downloads
Patches
Plain Diff
cleanup, coding style, and logic fixes in sleepy
parent
7a8ff6d6
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/sleepy.py
+16
-15
16 additions, 15 deletions
src/common/sleepy.py
src/gajim.py
+4
-3
4 additions, 3 deletions
src/gajim.py
with
20 additions
and
18 deletions
src/common/sleepy.py
+
16
−
15
View file @
e7345baf
##
common/sleepy.py
## common/sleepy.py
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <kourem@gmail.com>
##
## Copyright (C) 2003-2005 Gajim Team
##
...
...
@@ -20,11 +21,11 @@ from common import gajim
STATE_UNKNOWN
=
'
OS probably not supported
'
STATE_XA
WAY
=
'
extanted away
'
STATE_XA
=
'
extanted away
'
STATE_AWAY
=
'
away
'
STATE_AWAKE
=
'
awake
'
SUPPORTED
=
1
SUPPORTED
=
True
try
:
import
common.idle
as
idle
# when we launch gajim from sources
except
:
...
...
@@ -32,32 +33,32 @@ except:
import
idle
# when Gajim is installed
except
:
gajim
.
log
.
debug
(
'
Unable to load idle module
'
)
SUPPORTED
=
0
SUPPORTED
=
False
class
Sleepy
:
def
__init__
(
self
,
interval1
=
60
,
interval2
=
120
):
self
.
interval1
=
interval1
self
.
interval2
=
interval2
self
.
state
=
STATE_AWAKE
## assume were awake to stake with
def
__init__
(
self
,
away_interval
=
60
,
xa_interval
=
120
):
self
.
away_interval
=
away_interval
self
.
xa_interval
=
xa_interval
self
.
state
=
STATE_AWAKE
# assume we are awake
try
:
idle
.
init
()
except
:
SUPPORTED
=
0
SUPPORTED
=
False
self
.
state
=
STATE_UNKNOWN
def
poll
(
self
):
if
not
SUPPORTED
:
return
0
if
not
SUPPORTED
:
return
False
idleTime
=
idle
.
getIdleSec
()
if
idleTime
>
self
.
interval
2
:
self
.
state
=
STATE_XA
WAY
elif
idleTime
>
self
.
interval
1
:
if
idleTime
>
self
.
xa_
interval
:
self
.
state
=
STATE_XA
elif
idleTime
>
self
.
away_
interval
:
self
.
state
=
STATE_AWAY
else
:
self
.
state
=
STATE_AWAKE
return
1
return
True
def
getState
(
self
):
return
self
.
state
...
...
This diff is collapsed.
Click to expand it.
src/gajim.py
+
4
−
3
View file @
e7345baf
...
...
@@ -823,7 +823,8 @@ class Interface:
def
read_sleepy
(
self
):
'''
Check idle status and change that status if needed
'''
if
not
self
.
sleeper
.
poll
():
return
True
# renew timeout (loop for ever)
# idle detection is not supported in that OS
return
False
# stop looping in vain
state
=
self
.
sleeper
.
getState
()
for
account
in
gajim
.
connections
:
if
not
gajim
.
sleeper_state
.
has_key
(
account
)
or
\
...
...
@@ -845,7 +846,7 @@ class Interface:
self
.
roster
.
send_status
(
account
,
'
away
'
,
gajim
.
config
.
get
(
'
autoaway_message
'
),
True
)
gajim
.
sleeper_state
[
account
]
=
'
autoaway
'
elif
state
==
common
.
sleepy
.
STATE_XA
WAY
and
(
\
elif
state
==
common
.
sleepy
.
STATE_XA
and
(
\
gajim
.
sleeper_state
[
account
]
==
'
autoaway
'
or
\
gajim
.
sleeper_state
[
account
]
==
'
online
'
)
and
\
gajim
.
config
.
get
(
'
autoxa
'
):
...
...
@@ -1165,7 +1166,7 @@ class Interface:
gtk
.
window_set_default_icon
(
pix
)
# set the icon to all newly opened windows
self
.
roster
.
window
.
set_icon_from_file
(
path_to_file
)
# and to roster window
self
.
sleeper
=
common
.
sleepy
.
Sleepy
(
gajim
.
config
.
get
(
'
autoawaytime
'
)
*
60
,
gajim
.
config
.
get
(
'
autoawaytime
'
)
*
60
,
# make minutes to seconds
gajim
.
config
.
get
(
'
autoxatime
'
)
*
60
)
self
.
systray_enabled
=
False
...
...
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