channel/user.c -> cpp

master
Tony Olagbaiye 2 years ago
parent 5c4aaa629c
commit 7fd3f4ac58
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -16,10 +16,10 @@
#include "config.hh"
#include "input.h"
#include "omemo.h"
#include "account.h"
#include "account.hh"
#include "connection.h"
#include "user.h"
#include "channel.h"
#include "user.hh"
#include "channel.hh"
#include "buffer.h"
struct t_account *accounts = NULL;
@ -116,7 +116,7 @@ void account__add_device(struct t_account *account,
new_device = account__search_device(account, device->id);
if (!new_device)
{
new_device = malloc(sizeof(*new_device));
new_device = (struct t_account_device*)malloc(sizeof(*new_device));
new_device->id = device->id;
new_device->name = strdup(device->name);
new_device->label = device->label ? strdup(device->label) : NULL;
@ -177,14 +177,14 @@ xmpp_stanza_t *account__get_devicelist(struct t_account *account)
char id[64] = {0};
int i = 0;
device = malloc(sizeof(struct t_account_device));
device = (struct t_account_device*)malloc(sizeof(struct t_account_device));
device->id = account->omemo->device_id;
snprintf(id, sizeof(id), "%u", device->id);
device->name = strdup(id);
device->label = strdup("weechat");
children = malloc(sizeof(xmpp_stanza_t *) * 128);
children = (xmpp_stanza_t **)malloc(sizeof(xmpp_stanza_t *) * 128);
children[i++] = stanza__iq_pubsub_publish_item_list_device(
account->context, NULL, with_noop(device->name), NULL);
@ -231,7 +231,7 @@ struct t_account_mam_query *account__add_mam_query(struct t_account *account,
if (!(mam_query = account__mam_query_search(account, id)))
{
mam_query = malloc(sizeof(struct t_account_mam_query));
mam_query = (struct t_account_mam_query*)malloc(sizeof(struct t_account_mam_query));
mam_query->id = strdup(id);
mam_query->with = strdup(channel->id);
@ -321,7 +321,7 @@ void account__log_emit_weechat(void *const userdata, const xmpp_log_level_t leve
const char *tags = level > XMPP_LEVEL_DEBUG ? "no_log" : NULL;
char *xml;
if ((level == XMPP_LEVEL_DEBUG) && ((xml = strchr(msg, '<')) != NULL))
if ((level == XMPP_LEVEL_DEBUG) && ((xml = const_cast<char*>(strchr(msg, '<'))) != NULL))
{
FILE *nullfd = fopen("/dev/null", "w+");
xmlGenericErrorContext = nullfd;
@ -350,7 +350,7 @@ void account__log_emit_weechat(void *const userdata, const xmpp_log_level_t leve
{
colour = weechat_color("red");
}
xmlChar *buf = malloc(strlen(xml) * 2);
xmlChar *buf = (xmlChar*)malloc(strlen(xml) * 2);
if (buf == NULL) {
weechat_printf(
account ? account->buffer : NULL,
@ -407,7 +407,7 @@ struct t_account *account__alloc(const char *name)
return NULL;
/* alloc memory for new account */
new_account = malloc(sizeof(*new_account));
new_account = (struct t_account*)malloc(sizeof(*new_account));
if (!new_account)
{
weechat_printf(NULL,
@ -466,7 +466,7 @@ struct t_account *account__alloc(const char *name)
strlen(account_options[i][0]) +
512 + /* inherited option name(xmpp.account_default.xxx) */
1;
option_name = malloc(length);
option_name = (char*)malloc(length);
if (option_name)
{
snprintf(option_name, length, "%s.%s << xmpp.account_default.%s",
@ -702,7 +702,7 @@ struct t_gui_buffer *account__create_buffer(struct t_account *account)
weechat_buffer_set(account->buffer, "nicklist", "1");
weechat_buffer_set(account->buffer, "nicklist_display_groups", "0");
weechat_buffer_set_pointer(account->buffer, "nicklist_callback",
&buffer__nickcmp_cb);
(void*)&buffer__nickcmp_cb);
weechat_buffer_set_pointer(account->buffer, "nicklist_callback_pointer",
account);

@ -2,8 +2,13 @@
// 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 _ACCOUNT_H_
#define _ACCOUNT_H_
#pragma once
#ifdef __cplusplus
#include <ctime>
#include <cstdint>
#include <strophe.h>
#endif
extern struct t_account *accounts;
extern struct t_account *last_account;
@ -129,9 +134,12 @@ extern char *account_options[][2];
struct t_account *account__search(const char *account_name);
struct t_account *account__casesearch (const char *account_name);
int account__search_option(const char *option_name);
struct t_account_device *account__search_device(struct t_account *account, uint32_t id);
void account__add_device(struct t_account *account, struct t_account_device *device);
void account__free_device(struct t_account *account, struct t_account_device *device);
struct t_account_device *account__search_device(struct t_account *account,
uint32_t id);
void account__add_device(struct t_account *account,
struct t_account_device *device);
void account__free_device(struct t_account *account,
struct t_account_device *device);
void account__free_device_all(struct t_account *account);
xmpp_stanza_t *account__get_devicelist(struct t_account *account);
struct t_account_mam_query *account__add_mam_query(struct t_account *account,
@ -152,5 +160,3 @@ void account__disconnect_all();
void account__close_connection(struct t_account *account);
int account__connect(struct t_account *account);
int account__timer_cb(const void *pointer, void *data, int remaining_calls);
#endif /*ACCOUNT_H*/

@ -8,8 +8,8 @@
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
#include "account.h"
#include "channel.h"
#include "account.hh"
#include "channel.hh"
#include "buffer.h"
void buffer__get_account_and_channel(struct t_gui_buffer *buffer,

@ -11,10 +11,10 @@
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
#include "account.h"
#include "account.hh"
#include "omemo.h"
#include "user.h"
#include "channel.h"
#include "user.hh"
#include "channel.hh"
#include "input.h"
#include "buffer.h"
#include "pgp.h"
@ -116,7 +116,7 @@ struct t_gui_buffer *channel__search_buffer(struct t_account *account,
const char *ptr_type, *ptr_account_name, *ptr_remote_jid;
hdata_buffer = weechat_hdata_get("buffer");
ptr_buffer = weechat_hdata_get_list(hdata_buffer, "gui_buffers");
ptr_buffer = (struct t_gui_buffer*)weechat_hdata_get_list(hdata_buffer, "gui_buffers");
while (ptr_buffer)
{
@ -140,7 +140,7 @@ struct t_gui_buffer *channel__search_buffer(struct t_account *account,
return ptr_buffer;
}
}
ptr_buffer = weechat_hdata_move(hdata_buffer, ptr_buffer, 1);
ptr_buffer = (struct t_gui_buffer*)weechat_hdata_move(hdata_buffer, ptr_buffer, 1);
}
return NULL;
@ -178,7 +178,7 @@ struct t_gui_buffer *channel__create_buffer(struct t_account *account,
if (buffer_created)
{
char *res = strrchr(name, '/');
char *res = (char*)strrchr(name, '/');
if (!weechat_buffer_get_integer(ptr_buffer, "short_name_is_set"))
weechat_buffer_set(ptr_buffer, "short_name",
res ? res + 1 : name);
@ -221,7 +221,7 @@ struct t_gui_buffer *channel__create_buffer(struct t_account *account,
weechat_buffer_set(ptr_buffer, "nicklist", "1");
weechat_buffer_set(ptr_buffer, "nicklist_display_groups", "0");
weechat_buffer_set_pointer(ptr_buffer, "nicklist_callback",
&buffer__nickcmp_cb);
(void*)&buffer__nickcmp_cb);
weechat_buffer_set_pointer(ptr_buffer, "nicklist_callback_pointer",
account);
}
@ -293,7 +293,7 @@ struct t_channel *channel__new(struct t_account *account,
if (!ptr_buffer)
return NULL;
if ((new_channel = malloc(sizeof(*new_channel))) == NULL)
if ((new_channel = (struct t_channel*)malloc(sizeof(*new_channel))) == NULL)
return NULL;
typing_timer = weechat_hook_timer(1 * 1000, 0, 0,
@ -569,7 +569,7 @@ int channel__add_typing(struct t_channel *channel,
new_typing = channel__typing_search(channel, user->id);
if (!new_typing)
{
new_typing = malloc(sizeof(*new_typing));
new_typing = (struct t_channel_typing*)malloc(sizeof(*new_typing));
new_typing->id = strdup(user->id);
new_typing->name = strdup(user->profile.display_name);
@ -695,7 +695,7 @@ int channel__add_self_typing(struct t_channel *channel,
new_typing = channel__self_typing_search(channel, user);
if (!new_typing)
{
new_typing = malloc(sizeof(*new_typing));
new_typing = (struct t_channel_typing*)malloc(sizeof(*new_typing));
new_typing->user = user;
new_typing->name = user ? strdup(user->profile.display_name) : NULL;
@ -739,7 +739,7 @@ void channel__unread_free_all(struct t_channel *channel)
struct t_weelist_item *ptr_item = weechat_list_get(channel->unreads, i);
if (ptr_item)
{
struct t_channel_unread *unread = weechat_list_user_data(ptr_item);
struct t_channel_unread *unread = (struct t_channel_unread *)weechat_list_user_data(ptr_item);
channel__unread_free(unread);
@ -896,7 +896,7 @@ struct t_channel_member *channel__add_member(struct t_account *account,
if (!(member = channel__member_search(channel, id)))
{
member = malloc(sizeof(struct t_channel_member));
member = (struct t_channel_member*)malloc(sizeof(struct t_channel_member));
member->id = strdup(id);
member->role = NULL;
@ -1114,7 +1114,7 @@ int channel__send_message(struct t_account *account, struct t_channel *channel,
channel__set_transport(channel, CHANNEL_TRANSPORT_PLAIN, 0);
}
char *url = strstr(body, "http");
char *url = (char*)strstr(body, "http");
if (url && channel->transport == CHANNEL_TRANSPORT_PLAIN)
{
xmpp_stanza_t *message__x = xmpp_stanza_new(account->context);
@ -1184,7 +1184,7 @@ void channel__send_reads(struct t_account *account, struct t_channel *channel)
if (ptr_item)
{
const char *unread_id = weechat_list_string(ptr_item);
struct t_channel_unread *unread = weechat_list_user_data(ptr_item);
struct t_channel_unread *unread = (struct t_channel_unread*)weechat_list_user_data(ptr_item);
xmpp_stanza_t *message = xmpp_message_new(account->context, NULL,
channel->id, NULL);

@ -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_CHANNEL_H_
#define _WEECHAT_XMPP_CHANNEL_H_
#pragma once
#ifdef __cplusplus
#include <ctime>
#endif
#define CHANNEL_MEMBERS_SPEAKING_LIMIT 128
@ -208,5 +211,3 @@ void channel__send_paused(struct t_account *account, struct t_channel *channel,
void channel__fetch_mam(struct t_account *account, struct t_channel *channel,
const char *id, time_t *start, time_t *end, const char *after);
#endif /*WEECHAT_XMPP_CHANNEL_H*/

@ -11,9 +11,9 @@
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
#include "account.h"
#include "user.h"
#include "channel.h"
#include "account.hh"
#include "user.hh"
#include "channel.hh"
#include "buffer.h"
#include "message.h"
#include "command.h"

@ -11,9 +11,9 @@
#include "plugin.hh"
#include "config.hh"
#include "account.h"
#include "channel.h"
#include "user.h"
#include "account.hh"
#include "channel.hh"
#include "user.hh"
#include "buffer.h"
#include "completion.h"

@ -9,7 +9,7 @@
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
#include "account.h"
#include "account.hh"
#include "config.hh"
struct t_config_file *config_file;

@ -14,9 +14,9 @@
#include "plugin.hh"
#include "xmpp/stanza.hh"
#include "config.hh"
#include "account.h"
#include "user.h"
#include "channel.h"
#include "account.hh"
#include "user.hh"
#include "channel.hh"
#include "connection.h"
#include "omemo.h"
#include "pgp.h"

@ -8,8 +8,8 @@
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
#include "account.h"
#include "channel.h"
#include "account.hh"
#include "channel.hh"
#include "buffer.h"
#include "message.h"
#include "input.h"

@ -40,9 +40,9 @@ PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
HDRS=plugin.hh \
account.h \
account.hh \
buffer.h \
channel.h \
channel.hh \
command.h \
completion.h \
config.hh \
@ -51,14 +51,14 @@ HDRS=plugin.hh \
message.h \
omemo.h \
pgp.h \
user.h \
user.hh \
util.h \
xmpp/stanza.hh \
SRCS=plugin.cpp \
account.c \
account.cpp \
buffer.c \
channel.c \
channel.cpp \
command.c \
completion.c \
config.cpp \
@ -67,7 +67,7 @@ SRCS=plugin.cpp \
message.c \
omemo.c \
pgp.c \
user.c \
user.cpp \
util.c \
xmpp/presence.cpp \
xmpp/iq.cpp \

@ -11,9 +11,9 @@
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
#include "account.h"
#include "channel.h"
#include "user.h"
#include "account.hh"
#include "channel.hh"
#include "user.hh"
#include "message.h"
static const char format_regex[] = "<([^>]*?)>";

@ -32,7 +32,7 @@ struct t_pre_key {
#include "plugin.hh"
#include "xmpp/stanza.hh"
#include "account.h"
#include "account.hh"
#include "omemo.h"
#include "util.h"

@ -12,7 +12,7 @@
#include "plugin.hh"
#include "config.hh"
extern "C" {
#include "account.h"
#include "account.hh"
#include "connection.h"
#include "command.h"
#include "input.h"

Binary file not shown.

@ -10,9 +10,9 @@
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
#include "account.h"
#include "user.h"
#include "channel.h"
#include "account.hh"
#include "user.hh"
#include "channel.hh"
const char *user__get_colour(struct t_user *user)
{
@ -166,7 +166,7 @@ struct t_user *user__new(struct t_account *account,
return ptr_user;
}
if ((new_user = malloc(sizeof(*new_user))) == NULL)
if ((new_user = (struct t_user*)malloc(sizeof(*new_user))) == NULL)
{
return NULL;
}

@ -2,8 +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/.
#ifndef _WEECHAT_XMPP_USER_H_
#define _WEECHAT_XMPP_USER_H_
#pragma once
struct t_user_profile
{
@ -31,6 +30,7 @@ struct t_user
struct t_user *prev_user;
struct t_user *next_user;
};
struct t_channel;
const char *user__get_colour(struct t_user *user);
@ -57,5 +57,3 @@ void user__nicklist_add(struct t_account *account,
void user__nicklist_remove(struct t_account *account,
struct t_channel *channel,
struct t_user *user);
#endif /*WEECHAT_XMPP_USER_H*/
Loading…
Cancel
Save