summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2017-09-09 12:26:49 -0700
committerSean Whitton <spwhitton@spwhitton.name>2017-09-09 12:26:49 -0700
commit873b152886f42085647a56253e48defa37f368dc (patch)
tree6213584f2fadb53589f3bcedb856cc3770fc48c9
parent79fdb3b49e90421763734c6fe2ded4603cedd8bf (diff)
parentbc523728d7ae97a617746a47b451e7adf4a58927 (diff)
downloadbitlbee-facebook-873b152886f42085647a56253e48defa37f368dc.tar.gz
Merge tag 'v1.1.2'
-rwxr-xr-x.travis/obs.sh1
-rw-r--r--ChangeLog4
-rw-r--r--README15
-rw-r--r--configure.ac6
-rw-r--r--facebook/facebook-api.c58
-rw-r--r--facebook/facebook-api.h3
-rw-r--r--facebook/facebook-data.c9
-rw-r--r--facebook/facebook-http.c14
-rw-r--r--facebook/facebook-http.h8
-rw-r--r--facebook/facebook.c3
10 files changed, 106 insertions, 15 deletions
diff --git a/.travis/obs.sh b/.travis/obs.sh
index 34b08b9..7292750 100755
--- a/.travis/obs.sh
+++ b/.travis/obs.sh
@@ -18,6 +18,7 @@ sed -ri \
configure.ac
sed -ri \
-e "s/bitlbee-dev \([^\(\)]+\),?\s*//" \
+ -e "s/(bitlbee[^ ]*) \(>= 3.4\)/\1 (>= 3.5)/g" \
debian/control
cat <<EOF > debian/changelog
diff --git a/ChangeLog b/ChangeLog
index 155c907..f197571 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+bitlbee-facebook-1.1.2 (2017-08-30):
+ - Fix "Failed to read thrift" with unknown fields in /t_p payload
+ - Fix rare login hang/timeout when the last page of contacts is empty
+
bitlbee-facebook-1.1.1 (2017-04-02):
- Send orca-formatted user agent for all HTTP requests too. Fixes "Failed to
parse thread information" errors when joining channels.
diff --git a/README b/README
index 5e249eb..007b77d 100644
--- a/README
+++ b/README
@@ -1,5 +1,7 @@
The Facebook protocol plugin for bitlbee. This plugin uses the Facebook
-Mobile API.
+Messenger MQTT-based protocol.
+
+This project is not affiliated with Facebook, Inc.
## Usage
@@ -27,7 +29,7 @@ Do *not* use the source tree headers unless you know what you are
doing. This can lead to mismatched header versions, which often times
will lead to bad things.
- $ git clone https://github.com/jgeboski/bitlbee-facebook.git
+ $ git clone https://github.com/bitlbee/bitlbee-facebook.git
$ cd bitlbee-facebook
With a "global" (or system) bitlbee installation:
@@ -36,13 +38,10 @@ With a "global" (or system) bitlbee installation:
$ make
$ make install
-Or with a "local" bitlbee installation (location: $HOME/bitlbee):
+Otherwise, before running those commands, set PKG_CONFIG_PATH to the path to
+the `bitlbee.pc` file. For example:
- $ export BITLBEE_CFLAGS="-I$HOME/bitlbee/include/bitlbee"
- $ export BITLBEE_LIBS=""
- $ ./autogen.sh --with-plugindir=$HOME/bitlbee/lib
- $ make
- $ make install
+ $ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
## Debugging
diff --git a/configure.ac b/configure.ac
index 80ab259..fc31a95 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@
AC_INIT(
[bitlbee-facebook],
- [1.1.1],
+ [1.1.2],
[https://github.com/bitlbee/bitlbee-facebook/issues],
[bitlbee-facebook],
[https://github.com/bitlbee/bitlbee-facebook],
@@ -49,7 +49,7 @@ AC_ARG_ENABLE(
[--enable-warnings],
[Enable additional compile-time (GCC) warnings]
)],
- [WARNINGS="yes"],
+ [WARNINGS="$enableval"],
[WARNINGS="no"]
)
@@ -73,7 +73,7 @@ AC_ARG_WITH(
[--with-plugindir],
[BitlBee plugin directory]
)],
- [plugindir="$with_plugindir"]
+ [plugindir="$withval"]
)
PKG_CHECK_MODULES([BITLBEE], [bitlbee >= 3.4])
diff --git a/facebook/facebook-api.c b/facebook/facebook-api.c
index b318c62..fb0581d 100644
--- a/facebook/facebook-api.c
+++ b/facebook/facebook-api.c
@@ -38,6 +38,7 @@ enum
PROP_STOKEN,
PROP_TOKEN,
PROP_UID,
+ PROP_TWEAK,
PROP_N
};
@@ -62,6 +63,7 @@ struct _FbApiPrivate
guint unread;
FbId lastmid;
gchar *contacts_delta;
+ int tweak;
};
struct _FbApiData
@@ -87,6 +89,27 @@ fb_api_contacts_delta(FbApi *api, const gchar *delta_cursor);
G_DEFINE_TYPE(FbApi, fb_api, G_TYPE_OBJECT);
+static const gchar *agents[] = {
+ FB_API_AGENT,
+ FB_API_AGENT_BASE " " "[FBAN/Orca-Android;FBAV/64.0.0.5.83;FBPN/com.facebook.orca;FBLC/en_US;FBBV/26040814]",
+ FB_API_AGENT_BASE " " "[FBAN/Orca-Android;FBAV/109.0.0.17.70;FBBV/52182662]",
+ FB_API_AGENT_BASE " " "[FBAN/Orca-Android;FBAV/109.0.0.17.70;FBPN/com.facebook.orca;FBLC/en_US;FBBV/52182662]",
+ NULL,
+};
+
+static const gchar *
+fb_api_get_agent_string(int tweak, gboolean mqtt)
+{
+ gboolean http_only = tweak & 4;
+ gboolean mqtt_only = tweak & 8;
+
+ if (tweak <= 0 || tweak > 15 || (http_only && mqtt) || (mqtt_only && !mqtt)) {
+ return agents[0];
+ }
+
+ return agents[tweak & 3];
+}
+
static void
fb_api_set_property(GObject *obj, guint prop, const GValue *val,
GParamSpec *pspec)
@@ -116,6 +139,10 @@ fb_api_set_property(GObject *obj, guint prop, const GValue *val,
case PROP_UID:
priv->uid = g_value_get_int64(val);
break;
+ case PROP_TWEAK:
+ priv->tweak = g_value_get_int(val);
+ fb_http_set_agent(priv->http, fb_api_get_agent_string(priv->tweak, 0));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop, pspec);
@@ -147,6 +174,9 @@ fb_api_get_property(GObject *obj, guint prop, GValue *val, GParamSpec *pspec)
case PROP_UID:
g_value_set_int64(val, priv->uid);
break;
+ case PROP_TWEAK:
+ g_value_set_int(val, priv->tweak);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop, pspec);
@@ -268,6 +298,16 @@ fb_api_class_init(FbApiClass *klass)
"User identifier",
0, G_MAXINT64, 0,
G_PARAM_READWRITE);
+
+ /**
+ * FbApi:tweak:
+ */
+ props[PROP_TWEAK] = g_param_spec_int(
+ "tweak",
+ "Tweak",
+ "",
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE);
g_object_class_install_properties(gklass, PROP_N, props);
/**
@@ -878,7 +918,9 @@ fb_api_cb_mqtt_open(FbMqtt *mqtt, gpointer data)
/* Write the information string */
fb_thrift_write_field(thft, FB_THRIFT_TYPE_STRING, 2, 1);
- fb_thrift_write_str(thft, FB_API_MQTT_AGENT);
+ fb_thrift_write_str(thft, (priv->tweak != 0)
+ ? fb_api_get_agent_string(priv->tweak, 1)
+ : FB_API_MQTT_AGENT);
/* Write the UNKNOWN ("cp"?) */
fb_thrift_write_field(thft, FB_THRIFT_TYPE_I64, 3, 2);
@@ -1811,8 +1853,18 @@ fb_api_cb_publish_pt(FbThrift *thft, GSList **press, GError **error)
FB_API_TCHK(fb_thrift_read_i64(thft, NULL));
break;
+ case 6:
+ /* Unknown new field */
+ FB_API_TCHK(type == FB_THRIFT_TYPE_I64);
+ FB_API_TCHK(fb_thrift_read_i64(thft, NULL));
+ break;
+
default:
- FB_API_TCHK(FALSE);
+ /* Try to read unknown fields as varint */
+ FB_API_TCHK(type == FB_THRIFT_TYPE_I16 ||
+ type == FB_THRIFT_TYPE_I32 ||
+ type == FB_THRIFT_TYPE_I64);
+ FB_API_TCHK(fb_thrift_read_i64(thft, NULL));
break;
}
}
@@ -2347,7 +2399,7 @@ fb_api_cb_contacts(FbHttpRequest *req, gpointer data)
priv->contacts_delta = g_strdup(is_delta ? cursor : delta_cursor);
}
- if (users) {
+ if (users || (complete && !is_delta)) {
g_signal_emit_by_name(api, "contacts", users, complete);
}
diff --git a/facebook/facebook-api.h b/facebook/facebook-api.h
index 7236b48..3ed0e41 100644
--- a/facebook/facebook-api.h
+++ b/facebook/facebook-api.h
@@ -110,7 +110,8 @@
*
* The HTTP User-Agent header.
*/
-#define FB_API_AGENT "Facebook plugin / BitlBee / " PACKAGE_VERSION " " FB_ORCA_AGENT
+#define FB_API_AGENT_BASE "Facebook plugin / BitlBee / " PACKAGE_VERSION
+#define FB_API_AGENT FB_API_AGENT_BASE " " FB_ORCA_AGENT
/**
* FB_API_MQTT_AGENT
diff --git a/facebook/facebook-data.c b/facebook/facebook-data.c
index f7f7000..99cd5e5 100644
--- a/facebook/facebook-data.c
+++ b/facebook/facebook-data.c
@@ -117,6 +117,7 @@ fb_data_load(FbData *fata)
guint i;
guint64 uint;
GValue val = G_VALUE_INIT;
+ int num;
g_return_val_if_fail(FB_IS_DATA(fata), FALSE);
priv = fata->priv;
@@ -160,6 +161,14 @@ fb_data_load(FbData *fata)
ret = FALSE;
}
+ num = set_getint(&acct->set, "tweak");
+ if (num != 0) {
+ g_value_init(&val, G_TYPE_INT);
+ g_value_set_int(&val, num);
+ g_object_set_property(G_OBJECT(priv->api), "tweak", &val);
+ g_value_unset(&val);
+ }
+
fb_api_rehash(priv->api);
return ret;
}
diff --git a/facebook/facebook-http.c b/facebook/facebook-http.c
index 6234d55..7335848 100644
--- a/facebook/facebook-http.c
+++ b/facebook/facebook-http.c
@@ -242,6 +242,20 @@ fb_http_cookies_parse_request(FbHttp *http, FbHttpRequest *req)
g_strfreev(hdrs);
}
+void
+fb_http_set_agent(FbHttp *http, const gchar *agent)
+{
+ FbHttpPrivate *priv;
+
+ g_return_if_fail(FB_IS_HTTP(http));
+ priv = http->priv;
+
+ if (agent != priv->agent && g_strcmp0(agent, priv->agent)) {
+ g_free(priv->agent);
+ priv->agent = g_strdup(agent);
+ }
+}
+
FbHttpRequest *
fb_http_request_new(FbHttp *http, const gchar *url, gboolean post,
FbHttpFunc func, gpointer data)
diff --git a/facebook/facebook-http.h b/facebook/facebook-http.h
index b3ff001..f7d02d9 100644
--- a/facebook/facebook-http.h
+++ b/facebook/facebook-http.h
@@ -206,6 +206,14 @@ void
fb_http_cookies_parse_request(FbHttp *http, FbHttpRequest *req);
/**
+ * fb_http_set_agent:
+ * @http: The #FbHttp.
+ * @agent: The new user agent string.
+ */
+void
+fb_http_set_agent(FbHttp *http, const gchar *agent);
+
+/**
* fb_http_request_new:
* @http: The #FbHttp.
* @url: The url.
diff --git a/facebook/facebook.c b/facebook/facebook.c
index 995ad59..526ccfe 100644
--- a/facebook/facebook.c
+++ b/facebook/facebook.c
@@ -735,6 +735,9 @@ fb_init(account_t *acct)
s = set_add(&acct->set, "uid", NULL, NULL, acct);
s->flags = SET_NULL_OK | SET_HIDDEN;
+ s = set_add(&acct->set, "tweak", NULL, NULL, acct);
+ s->flags = SET_NULL_OK | SET_HIDDEN;
+
set_add(&acct->set, "group_chat_open", "false", fb_eval_open, acct);
set_add(&acct->set, "mark_read", "false", fb_eval_mark_read, acct);
set_add(&acct->set, "mark_read_reply", "false", set_eval_bool, acct);