From 665457ad56b77cd26323c84d62ba81ffefe4d369 Mon Sep 17 00:00:00 2001 From: Tony Olagbaiye Date: Tue, 11 Jan 2022 23:23:54 +0000 Subject: [PATCH] command/connection.c -> cpp --- account.cpp | 2 +- command.c => command.cpp | 2 +- command.h => command.hh | 5 +---- connection.c => connection.cpp | 20 ++++++++++---------- connection.h => connection.hh | 9 +++++---- makefile | 8 ++++---- plugin.cpp | 4 ++-- tests/run | Bin 1322912 -> 1323152 bytes 8 files changed, 24 insertions(+), 26 deletions(-) rename command.c => command.cpp (99%) rename command.h => command.hh (79%) rename connection.c => connection.cpp (98%) rename connection.h => connection.hh (82%) diff --git a/account.cpp b/account.cpp index fe2aec4..e435a0b 100644 --- a/account.cpp +++ b/account.cpp @@ -17,7 +17,7 @@ #include "input.h" #include "omemo.hh" #include "account.hh" -#include "connection.h" +#include "connection.hh" #include "user.hh" #include "channel.hh" #include "buffer.h" diff --git a/command.c b/command.cpp similarity index 99% rename from command.c rename to command.cpp index 6a3ef96..5cfff16 100644 --- a/command.c +++ b/command.cpp @@ -16,7 +16,7 @@ #include "channel.hh" #include "buffer.h" #include "message.h" -#include "command.h" +#include "command.hh" #define MAM_DEFAULT_DAYS 2 #define STR(X) #X diff --git a/command.h b/command.hh similarity index 79% rename from command.h rename to command.hh index fb87318..9fa820c 100644 --- a/command.h +++ b/command.hh @@ -2,12 +2,9 @@ // 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_COMMAND_H_ -#define _WEECHAT_XMPP_COMMAND_H_ +#pragma once int command__enter(const void *pointer, void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol); void command__init(); - -#endif /*WEECHAT_XMPP_COMMAND_H*/ diff --git a/connection.c b/connection.cpp similarity index 98% rename from connection.c rename to connection.cpp index 0b1c0fa..bb8657c 100644 --- a/connection.c +++ b/connection.cpp @@ -17,7 +17,7 @@ #include "account.hh" #include "user.hh" #include "channel.hh" -#include "connection.h" +#include "connection.hh" #include "omemo.hh" #include "pgp.hh" #include "util.hh" @@ -118,12 +118,12 @@ int connection__presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void if (node && ver) { int len = strlen(node)+1+strlen(ver) + 1; - clientid = malloc(sizeof(char)*len); + clientid = (char*)malloc(sizeof(char)*len); snprintf(clientid, len, "%s#%s", node, ver); xmpp_stanza_t *children[2] = {NULL}; children[0] = stanza__iq_pubsub_items(account->context, NULL, - "eu.siacs.conversations.axolotl.devicelist"); + const_cast("eu.siacs.conversations.axolotl.devicelist")); children[0] = stanza__iq_pubsub(account->context, NULL, children, with_noop("http://jabber.org/protocol/pubsub")); children[0] = stanza__iq(account->context, NULL, children, NULL, @@ -397,7 +397,7 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void * from ? from : account_jid(account), items); } - children = malloc(sizeof(*children) * (3 + 1)); + children = (xmpp_stanza_t**)malloc(sizeof(*children) * (3 + 1)); for (device = xmpp_stanza_get_children(list); device; device = xmpp_stanza_get_next(device)) @@ -476,7 +476,7 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void * if (id && (markable || request)) { - struct t_channel_unread *unread = malloc(sizeof(struct t_channel_unread)); + struct t_channel_unread *unread = (struct t_channel_unread *)malloc(sizeof(struct t_channel_unread)); unread->id = strdup(id); unread->thread = thread ? strdup(thread) : NULL; @@ -612,7 +612,7 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void * char **orig_message = weechat_string_dyn_alloc(256); for (int i = 0; i < weechat_arraylist_size(orig_lines); i++) weechat_string_dyn_concat(orig_message, - weechat_arraylist_get(orig_lines, i), + (const char*)weechat_arraylist_get(orig_lines, i), -1); orig = *orig_message; weechat_string_dyn_free(orig_message, 0); @@ -1020,7 +1020,7 @@ int connection__iq_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userd account__free_device_all(account); - dev = malloc(sizeof(struct t_account_device)); + dev = (t_account_device*)malloc(sizeof(struct t_account_device)); dev->id = account->omemo->device_id; snprintf(id, sizeof(id), "%d", dev->id); @@ -1041,7 +1041,7 @@ int connection__iq_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userd device_id = xmpp_stanza_get_id(device); - dev = malloc(sizeof(struct t_account_device)); + dev = (t_account_device*)malloc(sizeof(struct t_account_device)); dev->id = atoi(device_id); dev->name = strdup(device_id); dev->label = NULL; @@ -1217,7 +1217,7 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status, NULL, NULL, NULL)); /* Send initial so that we appear online to contacts */ - children = malloc(sizeof(*children) * (3 + 1)); + children = (xmpp_stanza_t**)malloc(sizeof(*children) * (3 + 1)); pres__c = xmpp_stanza_new(account->context); xmpp_stanza_set_name(pres__c, "c"); @@ -1335,7 +1335,7 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status, char* connection__rand_string(int length) { - char *string = malloc(length); + char *string = (char*)malloc(length); for(int i = 0; i < length; ++i){ string[i] = '0' + rand()%72; // starting on '0', ending on '}' if (!((string[i] >= '0' && string[i] <= '9') || diff --git a/connection.h b/connection.hh similarity index 82% rename from connection.h rename to connection.hh index 54eb1dc..1fc8c9a 100644 --- a/connection.h +++ b/connection.hh @@ -2,8 +2,11 @@ // 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_CONNECTION_H_ -#define _WEECHAT_XMPP_CONNECTION_H_ +#pragma once + +#ifdef __cplusplus +#include +#endif void connection__init(); @@ -12,5 +15,3 @@ int connection__connect(struct t_account *account, xmpp_conn_t **connection, void connection__process(xmpp_ctx_t *context, xmpp_conn_t *connection, const unsigned long timeout); - -#endif /*WEECHAT_XMPP_CONNECTION_H*/ diff --git a/makefile b/makefile index 05d6fe0..6fc07e7 100644 --- a/makefile +++ b/makefile @@ -43,10 +43,10 @@ HDRS=plugin.hh \ account.hh \ buffer.h \ channel.hh \ - command.h \ + command.hh \ completion.h \ config.hh \ - connection.h \ + connection.hh \ input.h \ message.h \ omemo.hh \ @@ -59,10 +59,10 @@ SRCS=plugin.cpp \ account.cpp \ buffer.c \ channel.cpp \ - command.c \ + command.cpp \ completion.c \ config.cpp \ - connection.c \ + connection.cpp \ input.c \ message.c \ omemo.cpp \ diff --git a/plugin.cpp b/plugin.cpp index 7f3be51..bc95522 100644 --- a/plugin.cpp +++ b/plugin.cpp @@ -13,8 +13,8 @@ #include "config.hh" extern "C" { #include "account.hh" -#include "connection.h" -#include "command.h" +#include "connection.hh" +#include "command.hh" #include "input.h" #include "buffer.h" #include "completion.h" diff --git a/tests/run b/tests/run index 1a14eb402d529e464c372571abcba92fc2d39962..8a35afbf8aa08a8271d248747c0329f68fc09d93 100755 GIT binary patch delta 1029 zcmZ2*KVZVcfC(B*7t|(dE#pk^VE}`KjW-WiYNh9u>KB*f7p3ZFOXWE{9omtkL(R_L*A4|O81t$lvqu9YD1B1i#pL{I(j1Q)3 z^0UY@7EC|LCn!9*!DmUE085(yYnuRDn*e*80LL}~PG&2PW+g@jW`=sM>D*qNa`l8P z*DWZ@Ps_|n)z8dJ&M8ev)lbP!E=eseVbCW&EHKPS*4BpVS0ySir%(6dtf{BWLjBYV z${amC#+$Q@gcLCSp*N>EiRwkC%lL3|P~cNaqeZ`^r)A~< zg))<@^waZ7^@~gLi&FK=jSN##DvA?}v(1XkiZiNmbBzqLb1Jga($dV6b1c(Q^i98b zQP6HOpLNOP`PSzrD_F~J&bP^BoLpebviXTEi%?TQTL9y>04DEt1wzKQXJ2R9o_(EJ z)|@e9dM6)Cyxp@1t(dxWd^x50 z(R8&J`f>s>7Z7s;F%J;)0x=&D^KUQo6@Hmz!WnBComEp z@(YSHzG(l+F9^g!KrFodC%;I!1TfkQHAM6|du$*&d#10{5HaV38T4cNOAt509wHkt zT~iatg{6@f+cPyqj