--- a/CMakeLists.txt Wed Jan 20 19:50:41 2010 +0200
+++ b/CMakeLists.txt Wed Jan 20 19:59:55 2010 +0200
@@ -24,7 +24,16 @@
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
-pkg_check_modules(LM REQUIRED loudmouth-1.0)
+pkg_check_modules(LM REQUIRED loudmouth-1.0)
+find_program(GREP_EXECUTABLE grep DOC "Grep binary to detect functions in headers")
+if(GREP_EXECUTABLE)
+ execute_process(COMMAND ${GREP_EXECUTABLE} xmpp_is_online ${MCABBER_INCLUDE_DIR}/mcabber/xmpp.h OUTPUT_VARIABLE HAVE_XMPP_IS_ONLINE ERROR_QUIET)
+endif()
+include(CheckSymbolExists)
+set(CMAKE_REQUIRED_INCLUDES ${LM_INCLUDE_DIRS})
+set(CMAKE_REQUIRED_LIBRARIES ${LM_LIBRARIES})
+set(CMAKE_REQUIRED_FLAGS ${LM_LDFLAGS} ${LM_CFLAGS})
+check_symbol_exists(lm_connection_unregister_reply_handler loudmouth/loudmouth.h HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER)
link_directories(${GLIB_LIBRARY_DIRS}
${GMODULE_LIBRARY_DIRS}
${LM_LIBRARY_DIRS})
@@ -33,6 +42,7 @@
add_library(disco MODULE disco.c)
## Compiler setup
+configure_file(config.h.in config.h)
include_directories(SYSTEM ${GLIB_INCLUDE_DIRS}
${GMODULE_INCLUDE_DIRS}
${LM_INCLUDE_DIRS}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/config.h.in Wed Jan 20 19:59:55 2010 +0200
@@ -0,0 +1,20 @@
+
+#ifndef LOCAL_CONFIG_H
+#define LOCAL_CONFIG_H
+
+#cmakedefine HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER
+
+#cmakedefine HAVE_XMPP_IS_ONLINE
+
+#ifndef HAVE_XMPP_IS_ONLINE
+inline gboolean xmpp_is_online (void)
+{
+ if (lconnection && lm_connection_is_authenticated (lconnection))
+ return TRUE;
+ else
+ return FALSE;
+}
+#endif
+
+#endif
+
--- a/disco.c Wed Jan 20 19:50:41 2010 +0200
+++ b/disco.c Wed Jan 20 19:59:55 2010 +0200
@@ -275,7 +275,7 @@
void disco_info_request (const gchar *jid, const gchar *dnode, disco_info_handler_t handler, gpointer userdata, GDestroyNotify notify)
{
- if (!handler) {
+ if (!handler || !xmpp_is_online ()) {
if (notify)
notify (userdata);
return;
@@ -342,7 +342,7 @@
void disco_items_request (const gchar *jid, const gchar *dnode, disco_items_handler_t handler, gpointer userdata, GDestroyNotify notify)
{
- if (!handler) {
+ if (!handler || !xmpp_is_online ()) {
if (notify)
notify (userdata);
return;
@@ -552,6 +552,10 @@
for (hel = reply_handlers; hel; hel = hel -> next) {
LmMessageHandler *handler = hel -> data;
lm_message_handler_invalidate (handler);
+#ifdef HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER
+ if (lconnection)
+ lm_connection_unregister_reply_handler (handler);
+#endif
}
g_slist_free (reply_handlers);