diff --git a/account.c b/account.c index 5a0ba68..4357d82 100644 --- a/account.c +++ b/account.c @@ -12,7 +12,7 @@ #include #include "plugin.hh" -#include "xmpp/stanza.h" +#include "xmpp/stanza.hh" #include "config.h" #include "input.h" #include "omemo.h" @@ -749,6 +749,8 @@ int account__timer_cb(const void *pointer, void *data, int remaining_calls) struct t_account *ptr_account; + if (!accounts) return WEECHAT_RC_ERROR; + for (ptr_account = accounts; ptr_account; ptr_account = ptr_account ? ptr_account->next_account : NULL) { diff --git a/connection.c b/connection.c index 12bac6e..0b4d24e 100644 --- a/connection.c +++ b/connection.c @@ -13,7 +13,7 @@ #include "plugin.hh" #include "diff/diff.h" -#include "xmpp/stanza.h" +#include "xmpp/stanza.hh" #include "config.h" #include "account.h" #include "user.h" diff --git a/diff b/diff deleted file mode 160000 index aadb3d7..0000000 --- a/diff +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aadb3d7fe4dcb4b212c77e4fc6c2599826aeb50a diff --git a/makefile b/makefile index 68828d0..3aaf743 100644 --- a/makefile +++ b/makefile @@ -53,7 +53,7 @@ HDRS=plugin.hh \ pgp.h \ user.h \ util.h \ - xmpp/stanza.h \ + xmpp/stanza.hh \ SRCS=plugin.cpp \ account.c \ @@ -69,12 +69,12 @@ SRCS=plugin.cpp \ pgp.c \ user.c \ util.c \ - xmpp/presence.c \ - xmpp/iq.c \ + xmpp/presence.cpp \ + xmpp/iq.cpp \ DEPS=deps/diff/libdiff.a \ -OBJS=$(patsubst %.cpp,.%.o,$(patsubst %.c,.%.o,$(patsubst xmpp/%.c,xmpp/.%.o,$(SRCS)))) +OBJS=$(patsubst %.cpp,.%.o,$(patsubst %.c,.%.o,$(patsubst xmpp/%.cpp,xmpp/.%.o,$(patsubst xmpp/%.c,xmpp/.%.o,$(SRCS))))) all: make depend @@ -97,6 +97,9 @@ xmpp.so: $(OBJS) $(DEPS) $(HDRS) xmpp/.%.o: xmpp/%.c @$(CC) $(CFLAGS) -c $< -o $@ +xmpp/.%.o: xmpp/%.cpp + @$(CXX) $(CPPFLAGS) -c $< -o $@ + deps/diff/libdiff.a: git submodule update --init --recursive cd deps/diff && env -u MAKEFLAGS ./configure diff --git a/omemo.c b/omemo.c index 2fe1360..4709412 100644 --- a/omemo.c +++ b/omemo.c @@ -31,7 +31,7 @@ struct t_pre_key { }; #include "plugin.hh" -#include "xmpp/stanza.h" +#include "xmpp/stanza.hh" #include "account.h" #include "omemo.h" #include "util.h" diff --git a/plugin.cpp b/plugin.cpp index a6b9014..e1cbbba 100644 --- a/plugin.cpp +++ b/plugin.cpp @@ -9,8 +9,8 @@ #include #include -extern "C" { #include "plugin.hh" +extern "C" { #include "config.h" #include "account.h" #include "connection.h" @@ -25,6 +25,7 @@ WEECHAT_PLUGIN_AUTHOR("bqv "); WEECHAT_PLUGIN_VERSION(WEECHAT_XMPP_PLUGIN_VERSION); WEECHAT_PLUGIN_LICENSE("MPL2"); WEECHAT_PLUGIN_PRIORITY(5500); +} struct t_weechat_plugin *weechat_xmpp_plugin = NULL; @@ -32,6 +33,7 @@ struct t_hook *weechat_xmpp_process_timer = NULL; struct t_gui_bar_item *weechat_xmpp_typing_bar_item = NULL; +extern "C" int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]) { (void) argc; @@ -71,6 +73,7 @@ int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]) return WEECHAT_RC_OK; } +extern "C" int weechat_plugin_end(struct t_weechat_plugin *plugin) { // make C compiler happy @@ -92,4 +95,3 @@ int weechat_plugin_end(struct t_weechat_plugin *plugin) return WEECHAT_RC_OK; } -} diff --git a/plugin.hh b/plugin.hh index ed09dc2..f60f7b6 100644 --- a/plugin.hh +++ b/plugin.hh @@ -6,7 +6,7 @@ #define weechat_plugin weechat_xmpp_plugin #define WEECHAT_XMPP_PLUGIN_NAME "xmpp" -#define WEECHAT_XMPP_PLUGIN_VERSION "0.1.1" +#define WEECHAT_XMPP_PLUGIN_VERSION "0.2.0" #define TIMER_INTERVAL_SEC 0.01 extern struct t_weechat_plugin *weechat_xmpp_plugin; diff --git a/tests/run b/tests/run index f158e82..21b73ce 100755 Binary files a/tests/run and b/tests/run differ diff --git a/xmpp/iq.c b/xmpp/iq.cpp similarity index 99% rename from xmpp/iq.c rename to xmpp/iq.cpp index f5d14a6..1dddf9b 100644 --- a/xmpp/iq.c +++ b/xmpp/iq.cpp @@ -2,10 +2,10 @@ // License, version 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include +#include #include -#include "stanza.h" +#include "stanza.hh" xmpp_stanza_t *stanza__iq(xmpp_ctx_t *context, xmpp_stanza_t *base, xmpp_stanza_t **children, char *ns, char *id, diff --git a/xmpp/presence.c b/xmpp/presence.cpp similarity index 98% rename from xmpp/presence.c rename to xmpp/presence.cpp index 94a367d..c5a59cc 100644 --- a/xmpp/presence.c +++ b/xmpp/presence.cpp @@ -2,7 +2,7 @@ // License, version 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include +#include #include xmpp_stanza_t *stanza__presence(xmpp_ctx_t *context, xmpp_stanza_t *base, diff --git a/xmpp/stanza.h b/xmpp/stanza.hh similarity index 91% rename from xmpp/stanza.h rename to xmpp/stanza.hh index f893ab5..2abf065 100644 --- a/xmpp/stanza.h +++ b/xmpp/stanza.hh @@ -2,8 +2,12 @@ // License, version 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef _WEECHAT_XMPP_STANZA_H_ -#define _WEECHAT_XMPP_STANZA_H_ +#pragma once + +#ifdef __cplusplus +#include +#include +#endif struct t_string { @@ -20,11 +24,11 @@ static void t_string_free(struct t_string *string) { free(string->value); } static void t_string_xmpp_free(struct t_string *string) -{ xmpp_free(string->pointer, string->value); } +{ xmpp_free((const xmpp_ctx_t*)string->pointer, string->value); } static inline struct t_string *with_noop(const char *const value) { - struct t_string *string = malloc(sizeof(struct t_string)); + struct t_string *string = (struct t_string *)malloc(sizeof(struct t_string)); string->value = (char*)value; string->finalize = &t_string_noop; string->pointer = NULL; @@ -33,7 +37,7 @@ static inline struct t_string *with_noop(const char *const value) static inline struct t_string *with_free(char *value) { - struct t_string *string = malloc(sizeof(struct t_string)); + struct t_string *string = (struct t_string *)malloc(sizeof(struct t_string)); string->value = value; string->finalize = &t_string_free; string->pointer = NULL; @@ -42,7 +46,7 @@ static inline struct t_string *with_free(char *value) static inline struct t_string *with_xmpp_free(char *value, xmpp_ctx_t *pointer) { - struct t_string *string = malloc(sizeof(struct t_string)); + struct t_string *string = (struct t_string *)malloc(sizeof(struct t_string)); string->value = value; string->finalize = &t_string_xmpp_free; string->pointer = pointer; @@ -119,5 +123,3 @@ xmpp_stanza_t *stanza__iq_ping(xmpp_ctx_t *context, xmpp_stanza_t *base, xmpp_stanza_t *stanza__iq_query(xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *ns, struct t_string *node); - -#endif /*WEECHAT_XMPP_STANZA_H*/