command/connection.c -> cpp

master
Tony Olagbaiye 2 years ago
parent f2e711a54a
commit 665457ad56
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -17,7 +17,7 @@
#include "input.h" #include "input.h"
#include "omemo.hh" #include "omemo.hh"
#include "account.hh" #include "account.hh"
#include "connection.h" #include "connection.hh"
#include "user.hh" #include "user.hh"
#include "channel.hh" #include "channel.hh"
#include "buffer.h" #include "buffer.h"

@ -16,7 +16,7 @@
#include "channel.hh" #include "channel.hh"
#include "buffer.h" #include "buffer.h"
#include "message.h" #include "message.h"
#include "command.h" #include "command.hh"
#define MAM_DEFAULT_DAYS 2 #define MAM_DEFAULT_DAYS 2
#define STR(X) #X #define STR(X) #X

@ -2,12 +2,9 @@
// License, version 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef _WEECHAT_XMPP_COMMAND_H_ #pragma once
#define _WEECHAT_XMPP_COMMAND_H_
int command__enter(const void *pointer, void *data, int command__enter(const void *pointer, void *data,
struct t_gui_buffer *buffer, int argc, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol); char **argv, char **argv_eol);
void command__init(); void command__init();
#endif /*WEECHAT_XMPP_COMMAND_H*/

@ -17,7 +17,7 @@
#include "account.hh" #include "account.hh"
#include "user.hh" #include "user.hh"
#include "channel.hh" #include "channel.hh"
#include "connection.h" #include "connection.hh"
#include "omemo.hh" #include "omemo.hh"
#include "pgp.hh" #include "pgp.hh"
#include "util.hh" #include "util.hh"
@ -118,12 +118,12 @@ int connection__presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void
if (node && ver) if (node && ver)
{ {
int len = strlen(node)+1+strlen(ver) + 1; 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); snprintf(clientid, len, "%s#%s", node, ver);
xmpp_stanza_t *children[2] = {NULL}; xmpp_stanza_t *children[2] = {NULL};
children[0] = stanza__iq_pubsub_items(account->context, NULL, children[0] = stanza__iq_pubsub_items(account->context, NULL,
"eu.siacs.conversations.axolotl.devicelist"); const_cast<char*>("eu.siacs.conversations.axolotl.devicelist"));
children[0] = stanza__iq_pubsub(account->context, NULL, children[0] = stanza__iq_pubsub(account->context, NULL,
children, with_noop("http://jabber.org/protocol/pubsub")); children, with_noop("http://jabber.org/protocol/pubsub"));
children[0] = stanza__iq(account->context, NULL, children, NULL, 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); 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); for (device = xmpp_stanza_get_children(list);
device; device = xmpp_stanza_get_next(device)) 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)) 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->id = strdup(id);
unread->thread = thread ? strdup(thread) : NULL; 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); char **orig_message = weechat_string_dyn_alloc(256);
for (int i = 0; i < weechat_arraylist_size(orig_lines); i++) for (int i = 0; i < weechat_arraylist_size(orig_lines); i++)
weechat_string_dyn_concat(orig_message, weechat_string_dyn_concat(orig_message,
weechat_arraylist_get(orig_lines, i), (const char*)weechat_arraylist_get(orig_lines, i),
-1); -1);
orig = *orig_message; orig = *orig_message;
weechat_string_dyn_free(orig_message, 0); 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); 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; dev->id = account->omemo->device_id;
snprintf(id, sizeof(id), "%d", dev->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); 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->id = atoi(device_id);
dev->name = strdup(device_id); dev->name = strdup(device_id);
dev->label = NULL; dev->label = NULL;
@ -1217,7 +1217,7 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
NULL, NULL, NULL)); NULL, NULL, NULL));
/* Send initial <presence/> so that we appear online to contacts */ /* Send initial <presence/> 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); pres__c = xmpp_stanza_new(account->context);
xmpp_stanza_set_name(pres__c, "c"); 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* connection__rand_string(int length)
{ {
char *string = malloc(length); char *string = (char*)malloc(length);
for(int i = 0; i < length; ++i){ for(int i = 0; i < length; ++i){
string[i] = '0' + rand()%72; // starting on '0', ending on '}' string[i] = '0' + rand()%72; // starting on '0', ending on '}'
if (!((string[i] >= '0' && string[i] <= '9') || if (!((string[i] >= '0' && string[i] <= '9') ||

@ -2,8 +2,11 @@
// License, version 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef _WEECHAT_XMPP_CONNECTION_H_ #pragma once
#define _WEECHAT_XMPP_CONNECTION_H_
#ifdef __cplusplus
#include <strophe.h>
#endif
void connection__init(); 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, void connection__process(xmpp_ctx_t *context, xmpp_conn_t *connection,
const unsigned long timeout); const unsigned long timeout);
#endif /*WEECHAT_XMPP_CONNECTION_H*/

@ -43,10 +43,10 @@ HDRS=plugin.hh \
account.hh \ account.hh \
buffer.h \ buffer.h \
channel.hh \ channel.hh \
command.h \ command.hh \
completion.h \ completion.h \
config.hh \ config.hh \
connection.h \ connection.hh \
input.h \ input.h \
message.h \ message.h \
omemo.hh \ omemo.hh \
@ -59,10 +59,10 @@ SRCS=plugin.cpp \
account.cpp \ account.cpp \
buffer.c \ buffer.c \
channel.cpp \ channel.cpp \
command.c \ command.cpp \
completion.c \ completion.c \
config.cpp \ config.cpp \
connection.c \ connection.cpp \
input.c \ input.c \
message.c \ message.c \
omemo.cpp \ omemo.cpp \

@ -13,8 +13,8 @@
#include "config.hh" #include "config.hh"
extern "C" { extern "C" {
#include "account.hh" #include "account.hh"
#include "connection.h" #include "connection.hh"
#include "command.h" #include "command.hh"
#include "input.h" #include "input.h"
#include "buffer.h" #include "buffer.h"
#include "completion.h" #include "completion.h"

Binary file not shown.
Loading…
Cancel
Save