| 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); |
| 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, |
| 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 |