summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-01-02 19:07:36 +0100
committermathieui <mathieui@mathieui.net>2013-01-02 19:07:36 +0100
commitd0a8304e5584ac925c858510a4005c4d5e9168cf (patch)
tree5c992441e44afe0e53dba06752cfc98a12c29d08
parentc04fbadf2f6c9449719096cbad152f29eaa2f042 (diff)
downloadpoezio-d0a8304e5584ac925c858510a4005c4d5e9168cf.tar.gz
poezio-d0a8304e5584ac925c858510a4005c4d5e9168cf.tar.bz2
poezio-d0a8304e5584ac925c858510a4005c4d5e9168cf.tar.xz
poezio-d0a8304e5584ac925c858510a4005c4d5e9168cf.zip
Add the save_status, status, and status_message options
(the name show is not intuitive, so I used status and status_message) - The status is send when connecting, and is the same used when joining rooms - save_status is true by default, and will make poezio save the status whenever it changes - status and status_message are empty by default
-rw-r--r--data/default_config.cfg12
-rw-r--r--doc/en/configure.txt14
-rw-r--r--src/core.py18
3 files changed, 41 insertions, 3 deletions
diff --git a/data/default_config.cfg b/data/default_config.cfg
index 284f1311..abeab2ac 100644
--- a/data/default_config.cfg
+++ b/data/default_config.cfg
@@ -60,6 +60,18 @@ jid =
# If you leave this empty, the password will be asked at each startup
password =
+# The status (show) poezio will send when connecting.
+# can be: xa,dnd,away,available,chat.
+# An empty or invalid value will mean available.
+status =
+
+# The status message you will have upon connection
+status_message =
+
+# Save the last used status in this file (in the status and status_message
+# options)
+save_status = true
+
# A custom host that will be used instead of the DNS records for the server
# (anonymous or the jid’s) defined above.
# You should not need this in a "normal" use case.
diff --git a/doc/en/configure.txt b/doc/en/configure.txt
index 609775e3..fb8917e2 100644
--- a/doc/en/configure.txt
+++ b/doc/en/configure.txt
@@ -321,6 +321,10 @@ section of this documentation.
separated by colons (":"). If there are more than 3 or 4 chained
sorting methods, your sorting is most likely inefficient.
+*save_status*:: true
+
+ Save the status automatically in the status and status_message options.
+
*send_chat_states*:: true
if true, chat states will be sent to the people you are talking to.
@@ -391,6 +395,16 @@ section of this documentation.
Whether or not to display a timestamp before each message.
+*status*:: [empty]
+
+ The status (show) poezio will send when connecting. It can be available,
+ dnd,chat, xa or away.
+ Nothing or an invalid value will mean available.
+
+*status_message*:: [empty]
+
+ The status message poezio will send when connecting.
+
*use_bookmark_method*:: [empty]
the method that poezio will use to store your bookmarks online.
diff --git a/src/core.py b/src/core.py
index 1ac0fe7f..cfe92189 100644
--- a/src/core.py
+++ b/src/core.py
@@ -113,7 +113,10 @@ class Core(object):
# of being displayed on the screen and exiting the program.
sys.excepthook = self.on_exception
self.connection_time = time.time()
- self.status = Status(show=None, message='')
+ status = config.get('status', None)
+ status = possible_show.get(status, None)
+ self.status = Status(show=status,
+ message=config.get('status_message', ''))
self.running = True
self.xmpp = singleton.Singleton(connection.Connection)
self.xmpp.core = self
@@ -600,6 +603,9 @@ class Core(object):
or to use it when joining a new muc)
"""
self.status = Status(show=pres, message=msg)
+ if config.get('save_status', 'true').lower() != 'false':
+ config.set_and_save('status', pres if pres else '')
+ config.set_and_save('status_message', msg.replace('\n', '|') if msg else '')
def get_bookmark_nickname(self, room_name):
"""
@@ -2773,8 +2779,10 @@ class Core(object):
# request the roster
self.xmpp.get_roster()
# send initial presence
- if config.get('send_initial_presence', 'true').lower() == 'true':
+ if config.get('send_initial_presence', 'true').lower() != 'false':
pres = self.xmpp.make_presence()
+ pres['show'] = self.status.show
+ pres['status'] = self.status.message
self.events.trigger('send_normal_presence', pres)
pres.send()
bookmark.get_local()
@@ -2791,7 +2799,11 @@ class Core(object):
histo_length= None
if histo_length is not None:
histo_length= str(histo_length)
- muc.join_groupchat(self.xmpp, bm.jid, nick, bm.password, histo_length)
+ muc.join_groupchat(self.xmpp, bm.jid, nick,
+ passwd=bm.password,
+ maxhistory=histo_length,
+ status=self.status.message,
+ show=self.status.show)
### Other handlers ###