1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2016-03-23 22:59:39 +00:00
commit d613a36bfe
10 changed files with 61 additions and 6 deletions

View File

@ -325,3 +325,10 @@ api_win_show_themed(const char *tag, const char *const group, const char *const
return 1;
}
int
api_send_stanza(const char *const stanza)
{
return jabber_send_stanza(stanza);
}

View File

@ -70,5 +70,6 @@ int api_win_focus(const char *tag);
int api_win_show(const char *tag, const char *line);
int api_win_show_themed(const char *tag, const char *const group, const char *const key, const char *const def, const char *line);
int api_send_stanza(const char *const stanza);
#endif

View File

@ -188,6 +188,12 @@ c_api_win_show_themed(char *tag, char *group, char *key, char *def, char *line)
return api_win_show_themed(tag, group, key, def, line);
}
static int
c_api_send_stanza(char *stanza)
{
return api_send_stanza(stanza);
}
void
c_command_callback(PluginCommand *command, gchar **args)
{
@ -236,4 +242,5 @@ c_api_init(void)
prof_win_focus = c_api_win_focus;
prof_win_show = c_api_win_show;
prof_win_show_themed = c_api_win_show_themed;
prof_send_stanza = c_api_send_stanza;
}

View File

@ -69,3 +69,4 @@ int (*prof_win_focus)(PROF_WIN_TAG win) = NULL;
int (*prof_win_show)(PROF_WIN_TAG win, char *line) = NULL;
int (*prof_win_show_themed)(PROF_WIN_TAG tag, char *group, char *key, char *def, char *line) = NULL;
int (*prof_send_stanza)(char *stanza) = NULL;

View File

@ -69,5 +69,7 @@ int (*prof_win_focus)(PROF_WIN_TAG win);
int (*prof_win_show)(PROF_WIN_TAG win, char *line);
int (*prof_win_show_themed)(PROF_WIN_TAG tag, char *group, char *key, char *def, char *line);
int (*prof_send_stanza)(char *stanza);
#endif

View File

@ -433,6 +433,24 @@ python_api_win_show_themed(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
static PyObject*
python_api_send_stanza(PyObject *self, PyObject *args)
{
const char *stanza = NULL;
if (!PyArg_ParseTuple(args, "s", &stanza)) {
return Py_BuildValue("i", 0);
}
allow_python_threads();
int res = api_send_stanza(stanza);
disable_python_threads();
if (res) {
return Py_BuildValue("i", 1);
} else {
return Py_BuildValue("i", 0);
}
}
void
python_command_callback(PluginCommand *command, gchar **args)
{
@ -522,6 +540,7 @@ static PyMethodDef apiMethods[] = {
{ "win_focus", python_api_win_focus, METH_VARARGS, "Focus a window." },
{ "win_show", python_api_win_show, METH_VARARGS, "Show text in the window." },
{ "win_show_themed", python_api_win_show_themed, METH_VARARGS, "Show themed text in the window." },
{ "send_stanza", python_api_send_stanza, METH_VARARGS, "Send an XMPP stanza." },
{ NULL, NULL, 0, NULL }
};

View File

@ -480,6 +480,17 @@ jabber_conn_is_secured(void)
}
}
gboolean
jabber_send_stanza(const char *const stanza)
{
if (jabber_conn.conn_status != JABBER_CONNECTED) {
return FALSE;
} else {
xmpp_send_raw(jabber_conn.conn, stanza, strlen(stanza));
return TRUE;
}
}
static jabber_conn_status_t
_jabber_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
const char *const tls_policy)

View File

@ -637,13 +637,13 @@ _caps_response_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
}
if (query == NULL) {
log_warning("No query element found.");
log_info("No query element found.");
return 0;
}
char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
if (node == NULL) {
log_warning("No node attribute found");
log_info("No node attribute found");
return 0;
}
@ -715,14 +715,14 @@ _caps_response_handler_for_jid(xmpp_conn_t *const conn, xmpp_stanza_t *const sta
}
if (query == NULL) {
log_warning("No query element found.");
log_info("No query element found.");
free(jid);
return 0;
}
char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
if (node == NULL) {
log_warning("No node attribute found");
log_info("No node attribute found");
free(jid);
return 0;
}
@ -774,14 +774,14 @@ _caps_response_handler_legacy(xmpp_conn_t *const conn, xmpp_stanza_t *const stan
}
if (query == NULL) {
log_warning("No query element found.");
log_info("No query element found.");
free(expected_node);
return 0;
}
char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
if (node == NULL) {
log_warning("No node attribute found");
log_info("No node attribute found");
free(expected_node);
return 0;
}

View File

@ -159,6 +159,7 @@ void jabber_free_uuid(char *uuid);
TLSCertificate* jabber_get_tls_peer_cert(void);
#endif
gboolean jabber_conn_is_secured(void);
gboolean jabber_send_stanza(const char *const stanza);
// message functions
char* message_send_chat(const char *const barejid, const char *const msg);

View File

@ -64,6 +64,12 @@ GList * jabber_get_available_resources(void)
return NULL;
}
gboolean
jabber_send_stanza(const char *const stanza)
{
return TRUE;
}
// message functions
char* message_send_chat(const char * const barejid, const char * const msg)
{