aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-09-15 21:44:24 -0300
committerdequis <dx@dxzone.com.ar>2015-09-20 18:20:58 -0300
commit55182f5e3dde8d57e5af4c6aa653e1564633614d (patch)
tree118ce369ba3e2d5e5ea56dbbd86e59c148c40e18
parentb7b80ed2cbd8241ba7baeeb0f1e019c37f09d833 (diff)
downloadbitlbee-facebook-55182f5e3dde8d57e5af4c6aa653e1564633614d.tar.gz
bitlbee-facebook-55182f5e3dde8d57e5af4c6aa653e1564633614d.tar.bz2
bitlbee-facebook-55182f5e3dde8d57e5af4c6aa653e1564633614d.tar.xz
Show self-messages when there's a compatible bitlbee
This feature is not yet in any stable bitlbee release, but it's designed to be backwards compatible: - Run time: Detects if the "self_messages" global setting exists. - Build time: sets OPT_SELFMESSAGE to 0 if it doesn't exist. In other words, if this is built against a bitlbee version that supports this feature, it will still run in anything 3.4+, and only display these messages in the newer ones.
-rw-r--r--facebook/facebook.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/facebook/facebook.c b/facebook/facebook.c
index b77af1b..79fdc94 100644
--- a/facebook/facebook.c
+++ b/facebook/facebook.c
@@ -22,6 +22,10 @@
#include "facebook-mqtt.h"
#include "facebook-util.h"
+#ifndef OPT_SELFMESSAGE
+#define OPT_SELFMESSAGE 0
+#endif
+
static void
fb_cb_api_messages(FbApi *api, GSList *msgs, gpointer data);
@@ -296,9 +300,11 @@ fb_cb_api_messages(FbApi *api, GSList *msgs, gpointer data)
FbData *fata = data;
gboolean mark;
gboolean open;
+ gboolean selfmess;
gchar tid[FB_ID_STRMAX];
gchar uid[FB_ID_STRMAX];
GSList *l;
+ guint32 flags;
struct groupchat *gc;
struct im_connection *ic;
@@ -306,13 +312,20 @@ fb_cb_api_messages(FbApi *api, GSList *msgs, gpointer data)
acct = ic->acc;
mark = set_getbool(&acct->set, "mark_read");
open = set_getbool(&acct->set, "group_chat_open");
+ selfmess = (set_find(&ic->bee->set, "self_messages") != NULL);
for (l = msgs; l != NULL; l = l->next) {
msg = l->data;
FB_ID_TO_STR(msg->uid, uid);
+ flags = 0;
+
if (msg->flags & FB_API_MESSAGE_FLAG_SELF) {
- continue;
+ if (!selfmess) {
+ continue;
+ }
+
+ flags = OPT_SELFMESSAGE;
}
if (bee_user_by_handle(ic->bee, ic, uid) == NULL) {
@@ -327,7 +340,7 @@ fb_cb_api_messages(FbApi *api, GSList *msgs, gpointer data)
fb_api_read(api, msg->uid, FALSE);
}
- imcb_buddy_msg(ic, uid, (gchar*) msg->text, 0, 0);
+ imcb_buddy_msg(ic, uid, (gchar*) msg->text, flags, 0);
continue;
}
@@ -344,7 +357,7 @@ fb_cb_api_messages(FbApi *api, GSList *msgs, gpointer data)
fb_api_read(api, msg->tid, TRUE);
}
- imcb_chat_msg(gc, uid, (gchar*) msg->text, 0, 0);
+ imcb_chat_msg(gc, uid, (gchar*) msg->text, flags, 0);
}
}
}