libpurple/protocols/facebook/api.c

changeset 37414
252bb96afbe0
parent 37385
43ac0ab4b1d0
child 37416
77536a48b4be
equal deleted inserted replaced
37413:03b1fd2e362b 37414:252bb96afbe0
842 const GByteArray *bytes; 842 const GByteArray *bytes;
843 FbApi *api = data; 843 FbApi *api = data;
844 FbApiPrivate *priv = api->priv; 844 FbApiPrivate *priv = api->priv;
845 FbThrift *thft; 845 FbThrift *thft;
846 GByteArray *cytes; 846 GByteArray *cytes;
847 GError *err = NULL;
847 848
848 static guint8 flags = FB_MQTT_CONNECT_FLAG_USER | 849 static guint8 flags = FB_MQTT_CONNECT_FLAG_USER |
849 FB_MQTT_CONNECT_FLAG_PASS | 850 FB_MQTT_CONNECT_FLAG_PASS |
850 FB_MQTT_CONNECT_FLAG_CLR; 851 FB_MQTT_CONNECT_FLAG_CLR;
851 852
916 917
917 /* Write the STOP for the struct */ 918 /* Write the STOP for the struct */
918 fb_thrift_write_stop(thft); 919 fb_thrift_write_stop(thft);
919 920
920 bytes = fb_thrift_get_bytes(thft); 921 bytes = fb_thrift_get_bytes(thft);
921 cytes = fb_util_zcompress(bytes); 922 cytes = fb_util_zcompress(bytes, &err);
923
924 FB_API_ERROR_EMIT(api, err,
925 g_object_unref(thft);
926 return;
927 );
922 928
923 fb_util_debug_hexdump(FB_UTIL_DEBUG_INFO, bytes, "Writing connect"); 929 fb_util_debug_hexdump(FB_UTIL_DEBUG_INFO, bytes, "Writing connect");
924 fb_mqtt_connect(mqtt, flags, cytes); 930 fb_mqtt_connect(mqtt, flags, cytes);
925 931
926 g_byte_array_free(cytes, TRUE); 932 g_byte_array_free(cytes, TRUE);
1597 gpointer data) 1603 gpointer data)
1598 { 1604 {
1599 FbApi *api = data; 1605 FbApi *api = data;
1600 gboolean comp; 1606 gboolean comp;
1601 GByteArray *bytes; 1607 GByteArray *bytes;
1608 GError *err = NULL;
1602 guint i; 1609 guint i;
1603 1610
1604 static const struct { 1611 static const struct {
1605 const gchar *topic; 1612 const gchar *topic;
1606 void (*func) (FbApi *api, GByteArray *pload); 1613 void (*func) (FbApi *api, GByteArray *pload);
1613 }; 1620 };
1614 1621
1615 comp = fb_util_zcompressed(pload); 1622 comp = fb_util_zcompressed(pload);
1616 1623
1617 if (G_LIKELY(comp)) { 1624 if (G_LIKELY(comp)) {
1618 bytes = fb_util_zuncompress(pload); 1625 bytes = fb_util_zuncompress(pload, &err);
1619 1626 FB_API_ERROR_EMIT(api, err, return);
1620 if (G_UNLIKELY(bytes == NULL)) {
1621 fb_api_error(api, FB_API_ERROR,
1622 _("Failed to decompress"));
1623 return;
1624 }
1625 } else { 1627 } else {
1626 bytes = (GByteArray*) pload; 1628 bytes = (GByteArray*) pload;
1627 } 1629 }
1628 1630
1629 fb_util_debug_hexdump(FB_UTIL_DEBUG_INFO, bytes, 1631 fb_util_debug_hexdump(FB_UTIL_DEBUG_INFO, bytes,
2110 { 2112 {
2111 FbApiPrivate *priv; 2113 FbApiPrivate *priv;
2112 GByteArray *bytes; 2114 GByteArray *bytes;
2113 GByteArray *cytes; 2115 GByteArray *cytes;
2114 gchar *msg; 2116 gchar *msg;
2117 GError *err = NULL;
2115 va_list ap; 2118 va_list ap;
2116 2119
2117 g_return_if_fail(FB_IS_API(api)); 2120 g_return_if_fail(FB_IS_API(api));
2118 g_return_if_fail(topic != NULL); 2121 g_return_if_fail(topic != NULL);
2119 g_return_if_fail(format != NULL); 2122 g_return_if_fail(format != NULL);
2122 va_start(ap, format); 2125 va_start(ap, format);
2123 msg = g_strdup_vprintf(format, ap); 2126 msg = g_strdup_vprintf(format, ap);
2124 va_end(ap); 2127 va_end(ap);
2125 2128
2126 bytes = g_byte_array_new_take((guint8*) msg, strlen(msg)); 2129 bytes = g_byte_array_new_take((guint8*) msg, strlen(msg));
2127 cytes = fb_util_zcompress(bytes); 2130 cytes = fb_util_zcompress(bytes, &err);
2131
2132 FB_API_ERROR_EMIT(api, err,
2133 g_byte_array_free(bytes, TRUE);
2134 return;
2135 );
2128 2136
2129 fb_util_debug_hexdump(FB_UTIL_DEBUG_INFO, bytes, 2137 fb_util_debug_hexdump(FB_UTIL_DEBUG_INFO, bytes,
2130 "Writing message (topic: %s)", 2138 "Writing message (topic: %s)",
2131 topic); 2139 topic);
2132 2140

mercurial