mirror of
https://github.com/profanity-im/profanity.git
synced 2024-09-29 19:56:07 -04:00
Added xmpp_message.c
This commit is contained in:
parent
0b7a0531d0
commit
b269ac9702
@ -7,7 +7,7 @@ profanity_SOURCES = src/command.c src/contact.c src/command_history.c src/xmpp.h
|
|||||||
src/history.c src/ui.h src/common.h src/ contact_list.h src/xmpp_conn.c \
|
src/history.c src/ui.h src/common.h src/ contact_list.h src/xmpp_conn.c \
|
||||||
src/main.c src/profanity.h src/history.h src/xmpp_presence.c \
|
src/main.c src/profanity.h src/history.h src/xmpp_presence.c \
|
||||||
src/tinyurl.c src/tinyurl.h src/chat_session.c \
|
src/tinyurl.c src/tinyurl.h src/chat_session.c \
|
||||||
src/chat_session.h src/muc.c \
|
src/chat_session.h src/muc.c src/xmpp_message.c \
|
||||||
src/muc.h src/xmpp_stanza.c src/command_parser.c \
|
src/muc.h src/xmpp_stanza.c src/command_parser.c \
|
||||||
src/theme.c src/theme.h src/window.c src/window.h \
|
src/theme.c src/theme.h src/window.c src/window.h \
|
||||||
src/files.c src/files.h src/accounts.c src/accounts.h \
|
src/files.c src/files.h src/accounts.c src/accounts.h \
|
||||||
|
@ -909,7 +909,7 @@ cmd_execute_default(const char * const inp)
|
|||||||
win_current_show("You are not currently connected.");
|
win_current_show("You are not currently connected.");
|
||||||
} else {
|
} else {
|
||||||
char *recipient = win_current_get_recipient();
|
char *recipient = win_current_get_recipient();
|
||||||
jabber_send(inp, recipient);
|
message_send(inp, recipient);
|
||||||
|
|
||||||
if (win_current_is_chat() && prefs_get_chlog()) {
|
if (win_current_is_chat() && prefs_get_chlog()) {
|
||||||
const char *jid = jabber_get_jid();
|
const char *jid = jabber_get_jid();
|
||||||
@ -1669,7 +1669,7 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
|
|||||||
g_string_append(full_jid, usr);
|
g_string_append(full_jid, usr);
|
||||||
|
|
||||||
if (msg != NULL) {
|
if (msg != NULL) {
|
||||||
jabber_send(msg, full_jid->str);
|
message_send(msg, full_jid->str);
|
||||||
win_show_outgoing_msg("me", full_jid->str, msg);
|
win_show_outgoing_msg("me", full_jid->str, msg);
|
||||||
} else {
|
} else {
|
||||||
win_new_chat_win(full_jid->str);
|
win_new_chat_win(full_jid->str);
|
||||||
@ -1685,7 +1685,7 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (msg != NULL) {
|
if (msg != NULL) {
|
||||||
jabber_send(msg, usr);
|
message_send(msg, usr);
|
||||||
win_show_outgoing_msg("me", usr, msg);
|
win_show_outgoing_msg("me", usr, msg);
|
||||||
|
|
||||||
if (win_current_is_chat() && prefs_get_chlog()) {
|
if (win_current_is_chat() && prefs_get_chlog()) {
|
||||||
@ -1882,7 +1882,7 @@ _cmd_tiny(gchar **args, struct cmd_help_t help)
|
|||||||
if (tiny != NULL) {
|
if (tiny != NULL) {
|
||||||
if (win_current_is_chat()) {
|
if (win_current_is_chat()) {
|
||||||
char *recipient = win_current_get_recipient();
|
char *recipient = win_current_get_recipient();
|
||||||
jabber_send(tiny, recipient);
|
message_send(tiny, recipient);
|
||||||
|
|
||||||
if (prefs_get_chlog()) {
|
if (prefs_get_chlog()) {
|
||||||
const char *jid = jabber_get_jid();
|
const char *jid = jabber_get_jid();
|
||||||
@ -1893,7 +1893,7 @@ _cmd_tiny(gchar **args, struct cmd_help_t help)
|
|||||||
free(recipient);
|
free(recipient);
|
||||||
} else if (win_current_is_private()) {
|
} else if (win_current_is_private()) {
|
||||||
char *recipient = win_current_get_recipient();
|
char *recipient = win_current_get_recipient();
|
||||||
jabber_send(tiny, recipient);
|
message_send(tiny, recipient);
|
||||||
win_show_outgoing_msg("me", recipient, tiny);
|
win_show_outgoing_msg("me", recipient, tiny);
|
||||||
free(recipient);
|
free(recipient);
|
||||||
} else { // groupchat
|
} else { // groupchat
|
||||||
|
@ -146,7 +146,6 @@ jabber_conn_status_t jabber_connect_with_account(ProfAccount *account,
|
|||||||
const char * const passwd);
|
const char * const passwd);
|
||||||
void jabber_disconnect(void);
|
void jabber_disconnect(void);
|
||||||
void jabber_process_events(void);
|
void jabber_process_events(void);
|
||||||
void jabber_send(const char * const msg, const char * const recipient);
|
|
||||||
void jabber_send_groupchat(const char * const msg, const char * const recipient);
|
void jabber_send_groupchat(const char * const msg, const char * const recipient);
|
||||||
void jabber_send_inactive(const char * const recipient);
|
void jabber_send_inactive(const char * const recipient);
|
||||||
void jabber_send_composing(const char * const recipient);
|
void jabber_send_composing(const char * const recipient);
|
||||||
@ -168,6 +167,9 @@ void jabber_conn_set_priority(int priority);
|
|||||||
void jabber_conn_set_status(const char * const message);
|
void jabber_conn_set_status(const char * const message);
|
||||||
char* jabber_get_account_name(void);
|
char* jabber_get_account_name(void);
|
||||||
|
|
||||||
|
// message functions
|
||||||
|
void message_send(const char * const msg, const char * const recipient);
|
||||||
|
|
||||||
// iq functions
|
// iq functions
|
||||||
void iq_add_handlers(void);
|
void iq_add_handlers(void);
|
||||||
|
|
||||||
|
@ -241,29 +241,6 @@ jabber_process_events(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
jabber_send(const char * const msg, const char * const recipient)
|
|
||||||
{
|
|
||||||
if (prefs_get_states()) {
|
|
||||||
if (!chat_session_exists(recipient)) {
|
|
||||||
chat_session_start(recipient, TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xmpp_stanza_t *message;
|
|
||||||
if (prefs_get_states() && chat_session_get_recipient_supports(recipient)) {
|
|
||||||
chat_session_set_active(recipient);
|
|
||||||
message = stanza_create_message(jabber_conn.ctx, recipient, STANZA_TYPE_CHAT,
|
|
||||||
msg, STANZA_NAME_ACTIVE);
|
|
||||||
} else {
|
|
||||||
message = stanza_create_message(jabber_conn.ctx, recipient, STANZA_TYPE_CHAT,
|
|
||||||
msg, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
xmpp_send(jabber_conn.conn, message);
|
|
||||||
xmpp_stanza_release(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
jabber_send_groupchat(const char * const msg, const char * const recipient)
|
jabber_send_groupchat(const char * const msg, const char * const recipient)
|
||||||
{
|
{
|
||||||
|
52
src/xmpp_message.c
Normal file
52
src/xmpp_message.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* xmpp_message.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
|
||||||
|
*
|
||||||
|
* This file is part of Profanity.
|
||||||
|
*
|
||||||
|
* Profanity is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Profanity is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Profanity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <strophe.h>
|
||||||
|
|
||||||
|
#include "chat_session.h"
|
||||||
|
#include "preferences.h"
|
||||||
|
#include "xmpp.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
message_send(const char * const msg, const char * const recipient)
|
||||||
|
{
|
||||||
|
xmpp_conn_t * const conn = jabber_get_conn();
|
||||||
|
xmpp_ctx_t * const ctx = jabber_get_ctx();
|
||||||
|
if (prefs_get_states()) {
|
||||||
|
if (!chat_session_exists(recipient)) {
|
||||||
|
chat_session_start(recipient, TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xmpp_stanza_t *message;
|
||||||
|
if (prefs_get_states() && chat_session_get_recipient_supports(recipient)) {
|
||||||
|
chat_session_set_active(recipient);
|
||||||
|
message = stanza_create_message(ctx, recipient, STANZA_TYPE_CHAT,
|
||||||
|
msg, STANZA_NAME_ACTIVE);
|
||||||
|
} else {
|
||||||
|
message = stanza_create_message(ctx, recipient, STANZA_TYPE_CHAT,
|
||||||
|
msg, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
xmpp_send(conn, message);
|
||||||
|
xmpp_stanza_release(message);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user