Allow one status message per Jabber status
Messages can be defined with the following options:
message (overrides any of the others),
message_avail,
message_free,
message_dnd,
message_notavail,
message_away
--- a/mcabber/mcabberrc.example Sat Jul 09 09:50:01 2005 +0100
+++ b/mcabber/mcabberrc.example Sat Jul 09 12:44:57 2005 +0100
@@ -44,6 +44,16 @@
# You can enable debug in main.c before compiling mcabber, too.
#debug = /home/mikael/mcabber.log
+# Status messages
+# The "message" value will override all others, take care!
+#message = Unique message status
+#message_avail = I'm available
+#message_free = I'm free for chat
+#message_dnd = Please do not disturb
+#message_notavail = I'm not available
+#message_away = I'm away
+#message_autoaway = Auto-away (Not yet implemented)
+
# The colors
# Colors are: black, red, green, yellow, blue, magenta, cyan, white
#color_background = blue
--- a/mcabber/src/jabglue.c Sat Jul 09 09:50:01 2005 +0100
+++ b/mcabber/src/jabglue.c Sat Jul 09 12:44:57 2005 +0100
@@ -29,6 +29,7 @@
#include "hooks.h"
#include "utf8.h"
#include "utils.h"
+#include "settings.h"
#define JABBERPORT 5222
#define JABBERSSLPORT 5223
@@ -226,7 +227,7 @@
return mystatus;
}
-void jb_setstatus(enum imstatus st, char *msg)
+void jb_setstatus(enum imstatus st, const char *msg)
{
xmlnode x;
@@ -274,10 +275,8 @@
strprio, (unsigned) -1);
}
- if (!msg) {
- msg = ""; // FIXME
- //msg = imstatus2str(st);
- }
+ if (!msg)
+ msg = settings_get_status_msg(st);
xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), msg,
(unsigned) -1);
@@ -434,7 +433,7 @@
//setautostatus(jhook.manualstatus);
- jb_setstatus(available, "I'm here!"); // XXX not always "available"...
+ jb_setstatus(available, NULL);
buddylist_build();
/*
for (i = 0; i < clist.count; i++) {
--- a/mcabber/src/jabglue.h Sat Jul 09 09:50:01 2005 +0100
+++ b/mcabber/src/jabglue.h Sat Jul 09 12:44:57 2005 +0100
@@ -43,7 +43,7 @@
void jb_delbuddy(const char *jid);
void jb_updatebuddy(const char *jid, const char *name, const char *group);
inline enum imstatus jb_getstatus();
-void jb_setstatus(enum imstatus st, char *msg);
+void jb_setstatus(enum imstatus st, const char *msg);
void jb_send_msg(const char *, const char *);
void jb_keepalive();
inline void jb_reset_keepalive();
--- a/mcabber/src/settings.c Sat Jul 09 09:50:01 2005 +0100
+++ b/mcabber/src/settings.c Sat Jul 09 12:44:57 2005 +0100
@@ -189,3 +189,48 @@
return settings_get(SETTINGS_TYPE_BINDING, asciikey);
}
+// settings_get_status_msg(status)
+// Return a string with the current status message:
+// - if there is a user-defined message ("message" option),
+// return this message
+// - if there is a user-defined message for the given status (and no
+// generic user message), it is returned
+// - if no user-defined message is found, return the mcabber default msg
+// - if there is no default (offline, invisible), return an empty string
+const gchar *settings_get_status_msg(enum imstatus status)
+{
+ const gchar *rstatus = settings_opt_get("message");
+
+ if (rstatus) return rstatus;
+
+ switch(status) {
+ case available:
+ if ((rstatus = settings_opt_get("message_avail")) == NULL)
+ rstatus = MSG_AVAIL;
+ break;
+
+ case freeforchat:
+ if ((rstatus = settings_opt_get("message_free")) == NULL)
+ rstatus = MSG_FREE;
+ break;
+
+ case dontdisturb:
+ if ((rstatus = settings_opt_get("message_dnd")) == NULL)
+ rstatus = MSG_DND;
+ break;
+
+ case notavail:
+ if ((rstatus = settings_opt_get("message_notavail")) == NULL)
+ rstatus = MSG_NOTAVAIL;
+ break;
+
+ case away:
+ if ((rstatus = settings_opt_get("message_away")) == NULL)
+ rstatus = MSG_AWAY;
+ break;
+
+ default:
+ rstatus = "";
+ }
+ return rstatus;
+}
--- a/mcabber/src/settings.h Sat Jul 09 09:50:01 2005 +0100
+++ b/mcabber/src/settings.h Sat Jul 09 12:44:57 2005 +0100
@@ -3,10 +3,22 @@
#include <glib.h>
+#include "jabglue.h"
+
#ifndef __USE_ISOC99
# define isblank(c) ((c) == 0x20 || (c) == 0x09)
#endif
+
+/* Default status messages */
+#define MSG_AVAIL "I'm here!"
+#define MSG_FREE "Free for chat"
+#define MSG_DND "Busy"
+#define MSG_NOTAVAIL "Not available"
+#define MSG_AWAY "Away"
+#define MSG_AUTOAWAY "Auto away"
+
+
#define SETTINGS_TYPE_OPTION 1
#define SETTINGS_TYPE_ALIAS 2
#define SETTINGS_TYPE_BINDING 3
@@ -20,6 +32,7 @@
void settings_del(guint type, const gchar *key);
const gchar *settings_get(guint type, const gchar *key);
int settings_get_int(guint type, const gchar *key);
+const gchar *settings_get_status_msg(enum imstatus status);
const gchar *isbound(int key);