mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Add chat and room show calls to plugins api
This commit is contained in:
parent
9cfd17821c
commit
7090f85d85
@ -32,7 +32,7 @@ int prof_cons_show(const char * const message);
|
||||
|
||||
/**
|
||||
Show a message in the console, using the specified theme.
|
||||
Themes can be must be specified in ~/.local/share/profanity/plugin_themes
|
||||
Themes are specified in ~/.local/share/profanity/plugin_themes
|
||||
@param group the group name in the themes file
|
||||
@param item the item name within the group
|
||||
@param def default colour if the theme cannot be found
|
||||
@ -206,7 +206,7 @@ int prof_win_show(PROF_WIN_TAG win, char *message);
|
||||
|
||||
/**
|
||||
Show a message in the plugin window, using the specified theme.
|
||||
Themes must be specified in ~/.local/share/profanity/plugin_themes
|
||||
Themes are specified in ~/.local/share/profanity/plugin_themes
|
||||
@param tag The {@link PROF_WIN_TAG} of the window to display the message
|
||||
@param group the group name in the themes file
|
||||
@param key the item name within the group
|
||||
@ -414,3 +414,45 @@ Reset the message prefix character for specified room.
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_room_unset_message_char(char *roomjid);
|
||||
|
||||
/**
|
||||
Show a message in a chat window.
|
||||
@param barejid Jabber ID of the recipient
|
||||
@param message the message to print
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_chat_show(char *barejid, char *message);
|
||||
|
||||
/**
|
||||
Show a message in a chat window, using the specified theme, and prefix character
|
||||
Themes are specified in ~/.local/share/profanity/plugin_themes
|
||||
@param barejid Jabber ID of the recipient
|
||||
@param group the group name in the themes file or NULL
|
||||
@param item the item name within the group or NULL
|
||||
@param def default colour if the theme cannot be found
|
||||
@param ch The character to prefix the message, or NULL for default behaviour
|
||||
@param message the message to print
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_chat_show_themed(char *barejid, char *group, char *item, char *def, char *ch, char *message);
|
||||
|
||||
/**
|
||||
Show a message in a chat room window.
|
||||
@param barejid Jabber ID of the room
|
||||
@param message the message to print
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_room_show(char *roomjid, char *message);
|
||||
|
||||
/**
|
||||
Show a message in a chat room window, using the specified theme, and prefix character
|
||||
Themes are specified in ~/.local/share/profanity/plugin_themes
|
||||
@param barejid Jabber ID of the room
|
||||
@param group the group name in the themes file or NULL
|
||||
@param item the item name within the group or NULL
|
||||
@param def default colour if the theme cannot be found
|
||||
@param ch The character to prefix the message, or NULL for default behaviour
|
||||
@param message the message to print
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_room_show_themed(char *roomjid, char *group, char *item, char *def, char *ch, char *message);
|
||||
|
@ -31,7 +31,7 @@ def cons_show(message):
|
||||
|
||||
def cons_show_themed(group, key, default, message):
|
||||
"""Show a message in the console, using the specified theme.\n
|
||||
Themes can be must be specified in ``~/.local/share/profanity/plugin_themes``
|
||||
Themes are specified in ``~/.local/share/profanity/plugin_themes``
|
||||
|
||||
:param group: the group name in the themes file
|
||||
:param key: the item name within the group
|
||||
@ -376,7 +376,7 @@ def win_show(tag, message):
|
||||
|
||||
def win_show_themed(tag, group, key, default, message):
|
||||
"""Show a message in the plugin window, using the specified theme.\n
|
||||
Themes must be specified in ``~/.local/share/profanity/plugin_themes``
|
||||
Themes are specified in ``~/.local/share/profanity/plugin_themes``
|
||||
|
||||
:param tag: The tag of the window to display the message
|
||||
:type tag: str or unicode
|
||||
@ -797,3 +797,89 @@ def room_unset_message_char(roomjid):
|
||||
prof.room_unset_message_char("ohnoes@conference.chat.org")
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def chat_show(barejid, message):
|
||||
"""Show a message in a chat window.
|
||||
|
||||
:param barejid: Jabber ID of the recipient
|
||||
:param message: the message to print
|
||||
:type barejid: str or unicode
|
||||
:type message: str or unicode
|
||||
:return: ``True`` if the message was printed, ``False`` otherwise
|
||||
:rtype: boolean
|
||||
|
||||
Example:
|
||||
::
|
||||
prof.chat_show("bob@server.org", "From a plugin in the chat window for bob")
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def chat_show_themed(barejid, group, key, default, ch, message):
|
||||
"""Show a message a chat window, using the specified theme and prefix character.\n
|
||||
Themes are specified in ``~/.local/share/profanity/plugin_themes``
|
||||
|
||||
:param barejid: Jabber ID of the recipient
|
||||
:param group: the group name in the themes file or ``None``
|
||||
:param key: the item name within the group or ``None``
|
||||
:param default: default colour if the theme cannot be found or ``None``
|
||||
:param ch: The prefix character to show, or ``None`` for default behaviour
|
||||
:param message: the message to print
|
||||
:type barejid: str or unicode
|
||||
:type group: str, unicode or None
|
||||
:type key: str, unicode or None
|
||||
:type default: str, unicode or None
|
||||
:type ch: str or unicode
|
||||
:type message: str or unicode
|
||||
:return: ``True`` if the message was printed, ``False`` otherwise
|
||||
:rtype: boolean
|
||||
|
||||
Example:
|
||||
::
|
||||
prof.chat_show_themed("bob@server.org", "myplugin", "text", None, "!", "Plugin themed message")
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def room_show(roomjid, message):
|
||||
"""Show a message in a chat room window.
|
||||
|
||||
:param roomjid: Jabber ID of the room
|
||||
:param message: the message to print
|
||||
:type roomjid: str or unicode
|
||||
:type message: str or unicode
|
||||
:return: ``True`` if the message was printed, ``False`` otherwise
|
||||
:rtype: boolean
|
||||
|
||||
Example:
|
||||
::
|
||||
prof.room_show("chat@conference.chat.org", "From a plugin in the chat room window")
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def room_show_themed(roomjid, group, key, default, ch, message):
|
||||
"""Show a message a chat room window, using the specified theme and prefix character.\n
|
||||
Themes are specified in ``~/.local/share/profanity/plugin_themes``
|
||||
|
||||
:param roomjid: Jabber ID of the room
|
||||
:param group: the group name in the themes file or ``None``
|
||||
:param key: the item name within the group or ``None``
|
||||
:param default: default colour if the theme cannot be found or ``None``
|
||||
:param ch: The prefix character to show, or ``None`` for default behaviour
|
||||
:param message: the message to print
|
||||
:type roomjid: str or unicode
|
||||
:type group: str, unicode or None
|
||||
:type key: str, unicode or None
|
||||
:type default: str, unicode or None
|
||||
:type ch: str or unicode
|
||||
:type message: str or unicode
|
||||
:return: ``True`` if the message was printed, ``False`` otherwise
|
||||
:rtype: boolean
|
||||
|
||||
Example:
|
||||
::
|
||||
prof.room_show_themed("chat@conference.chat.org", "myplugin", "text", None, "!", "Plugin themed message")
|
||||
"""
|
||||
pass
|
||||
|
@ -483,6 +483,7 @@ void
|
||||
api_disco_add_feature(char *plugin_name, char *feature)
|
||||
{
|
||||
if (feature == NULL) {
|
||||
log_warning("%s", "api_disco_add_feature failed, feature is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -501,11 +502,13 @@ void
|
||||
api_encryption_reset(const char *const barejid)
|
||||
{
|
||||
if (barejid == NULL) {
|
||||
log_warning("%s", "api_encryption_reset failed, barejid is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
log_warning("%s", "api_encryption_reset failed, could not find chat window for %s", barejid);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -528,15 +531,18 @@ int
|
||||
api_chat_set_titlebar_enctext(const char *const barejid, const char *const enctext)
|
||||
{
|
||||
if (enctext == NULL) {
|
||||
log_warning("%s", "api_chat_set_titlebar_enctext failed, enctext is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (barejid == NULL) {
|
||||
log_warning("%s", "api_chat_set_titlebar_enctext failed, barejid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
log_warning("%s", "api_chat_set_titlebar_enctext failed, could not find chat window for %s", barejid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -549,11 +555,13 @@ int
|
||||
api_chat_unset_titlebar_enctext(const char *const barejid)
|
||||
{
|
||||
if (barejid == NULL) {
|
||||
log_warning("%s", "api_chat_unset_titlebar_enctext failed, barejid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
log_warning("%s", "api_chat_unset_titlebar_enctext failed, could not find chat window for %s", barejid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -566,19 +574,23 @@ int
|
||||
api_chat_set_incoming_char(const char *const barejid, const char *const ch)
|
||||
{
|
||||
if (ch == NULL) {
|
||||
log_warning("%s", "api_chat_set_incoming_char failed, ch is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strlen(ch) != 1) {
|
||||
log_warning("%s", "api_chat_set_incoming_char failed, ch must be a string of length 1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (barejid == NULL) {
|
||||
log_warning("%s", "api_chat_set_incoming_char failed, barejid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
log_warning("%s", "api_chat_set_incoming_char failed, could not find chat window for %s", barejid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -591,11 +603,13 @@ int
|
||||
api_chat_unset_incoming_char(const char *const barejid)
|
||||
{
|
||||
if (barejid == NULL) {
|
||||
log_warning("%s", "api_chat_unset_incoming_char failed, barejid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
log_warning("%s", "api_chat_unset_incoming_char failed, could not find chat window for %s", barejid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -608,19 +622,23 @@ int
|
||||
api_chat_set_outgoing_char(const char *const barejid, const char *const ch)
|
||||
{
|
||||
if (ch == NULL) {
|
||||
log_warning("%s", "api_chat_set_outgoing_char failed, ch is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strlen(ch) != 1) {
|
||||
log_warning("%s", "api_chat_set_outgoing_char failed, ch must be a string of length 1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (barejid == NULL) {
|
||||
log_warning("%s", "api_chat_set_outgoing_char failed, barejid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
log_warning("%s", "api_chat_set_outgoing_char failed, could not find chat window for %s", barejid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -633,11 +651,13 @@ int
|
||||
api_chat_unset_outgoing_char(const char *const barejid)
|
||||
{
|
||||
if (barejid == NULL) {
|
||||
log_warning("%s", "api_chat_unset_outgoing_char failed, barejid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
log_warning("%s", "api_chat_unset_outgoing_char failed, could not find chat window for %s", barejid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -650,15 +670,18 @@ int
|
||||
api_room_set_titlebar_enctext(const char *const roomjid, const char *const enctext)
|
||||
{
|
||||
if (enctext == NULL) {
|
||||
log_warning("%s", "api_room_set_titlebar_enctext failed, enctext is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (roomjid == NULL) {
|
||||
log_warning("%s", "api_room_set_titlebar_enctext failed, roomjid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||
if (mucwin == NULL) {
|
||||
log_warning("%s", "api_room_set_titlebar_enctext failed, coudl not find room window for %s", roomjid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -671,11 +694,13 @@ int
|
||||
api_room_unset_titlebar_enctext(const char *const roomjid)
|
||||
{
|
||||
if (roomjid == NULL) {
|
||||
log_warning("%s", "api_room_unset_titlebar_enctext failed, roomjid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||
if (mucwin == NULL) {
|
||||
log_warning("%s", "api_room_unset_titlebar_enctext failed, coudl not find room window for %s", roomjid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -688,19 +713,23 @@ int
|
||||
api_room_set_message_char(const char *const roomjid, const char *const ch)
|
||||
{
|
||||
if (ch == NULL) {
|
||||
log_warning("%s", "api_room_set_message_char failed, ch is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strlen(ch) != 1) {
|
||||
log_warning("%s", "api_room_set_message_char failed, ch must be a string of length 1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (roomjid == NULL) {
|
||||
log_warning("%s", "api_room_set_message_char failed, roomjid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||
if (mucwin == NULL) {
|
||||
log_warning("%s", "api_room_set_message_char failed, could not find room window for %s", roomjid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -713,11 +742,13 @@ int
|
||||
api_room_unset_message_char(const char *const roomjid)
|
||||
{
|
||||
if (roomjid == NULL) {
|
||||
log_warning("%s", "api_room_unset_message_char failed, roomjid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||
if (mucwin == NULL) {
|
||||
log_warning("%s", "api_room_unset_message_char failed, could not find room window for %s", roomjid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -725,3 +756,133 @@ api_room_unset_message_char(const char *const roomjid)
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
api_chat_show(const char *const barejid, const char *message)
|
||||
{
|
||||
if (message == NULL) {
|
||||
log_warning("%s", "api_chat_show failed, message is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (barejid == NULL) {
|
||||
log_warning("%s", "api_chat_show failed, barejid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
log_warning("%s", "api_chat_show failed, could not find chat window for %s", barejid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *parsed = str_replace(message, "\r\n", "\n");
|
||||
win_println((ProfWin*)chatwin, THEME_TEXT, '-', "%s", parsed);
|
||||
free(parsed);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
api_chat_show_themed(const char *const barejid, const char *const group, const char *const key, const char *const def,
|
||||
const char *const ch, const char *const message)
|
||||
{
|
||||
if (message == NULL) {
|
||||
log_warning("%s", "api_chat_show_themed failed, message is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (barejid == NULL) {
|
||||
log_warning("%s", "api_chat_show_themed failed, barejid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
char show_ch = '-';
|
||||
if (ch) {
|
||||
if (strlen(ch) != 1) {
|
||||
log_warning("%s", "api_chat_show_themed failed, ch must be a string of length 1");
|
||||
return 0;
|
||||
} else {
|
||||
show_ch = ch[0];
|
||||
}
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin == NULL) {
|
||||
log_warning("%s", "api_chat_show_themed failed, could not find chat window for %s", barejid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *parsed = str_replace(message, "\r\n", "\n");
|
||||
theme_item_t themeitem = plugin_themes_get(group, key, def);
|
||||
|
||||
win_println((ProfWin*)chatwin, themeitem, show_ch, "%s", parsed);
|
||||
free(parsed);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
api_room_show(const char *const roomjid, const char *message)
|
||||
{
|
||||
if (message == NULL) {
|
||||
log_warning("%s", "api_room_show failed, message is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (roomjid == NULL) {
|
||||
log_warning("%s", "api_room_show failed, roomjid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||
if (mucwin == NULL) {
|
||||
log_warning("%s", "api_room_show failed, could not find room window for %s", roomjid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *parsed = str_replace(message, "\r\n", "\n");
|
||||
win_println((ProfWin*)mucwin, THEME_TEXT, '-', "%s", parsed);
|
||||
free(parsed);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
api_room_show_themed(const char *const roomjid, const char *const group, const char *const key, const char *const def,
|
||||
const char *const ch, const char *const message)
|
||||
{
|
||||
if (message == NULL) {
|
||||
log_warning("%s", "api_room_show_themed failed, message is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (roomjid == NULL) {
|
||||
log_warning("%s", "api_room_show_themed failed, roomjid is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
char show_ch = '-';
|
||||
if (ch) {
|
||||
if (strlen(ch) != 1) {
|
||||
log_warning("%s", "api_room_show_themed failed, ch must be a string of length 1");
|
||||
return 0;
|
||||
} else {
|
||||
show_ch = ch[0];
|
||||
}
|
||||
}
|
||||
|
||||
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||
if (mucwin == NULL) {
|
||||
log_warning("%s", "api_room_show_themed failed, could not find room window for %s", roomjid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *parsed = str_replace(message, "\r\n", "\n");
|
||||
theme_item_t themeitem = plugin_themes_get(group, key, def);
|
||||
|
||||
win_println((ProfWin*)mucwin, themeitem, show_ch, "%s", parsed);
|
||||
free(parsed);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -109,4 +109,12 @@ int api_room_unset_titlebar_enctext(const char *const roomjid);
|
||||
int api_room_set_message_char(const char *const roomjid, const char *const ch);
|
||||
int api_room_unset_message_char(const char *const roomjid);
|
||||
|
||||
int api_chat_show(const char *const barejid, const char *const message);
|
||||
int api_chat_show_themed(const char *const barejid, const char *const group, const char *const key, const char *const def,
|
||||
const char *const ch, const char *const message);
|
||||
|
||||
int api_room_show(const char *const roomjid, const char *message);
|
||||
int api_room_show_themed(const char *const roomjid, const char *const group, const char *const key, const char *const def,
|
||||
const char *const ch, const char *const message);
|
||||
|
||||
#endif
|
||||
|
@ -407,6 +407,32 @@ c_api_room_unset_message_char(const char *roomjid)
|
||||
return api_room_unset_message_char(roomjid);
|
||||
}
|
||||
|
||||
static int
|
||||
c_api_chat_show(const char *const barejid, const char *const message)
|
||||
{
|
||||
return api_chat_show(barejid, message);
|
||||
}
|
||||
|
||||
static int
|
||||
c_api_chat_show_themed(const char *const barejid, const char *const group, const char *const item, const char *const def,
|
||||
const char *const ch, const char *const message)
|
||||
{
|
||||
return api_chat_show_themed(barejid, group, item, def, ch, message);
|
||||
}
|
||||
|
||||
static int
|
||||
c_api_room_show(const char *const roomjid, const char *const message)
|
||||
{
|
||||
return api_room_show(roomjid, message);
|
||||
}
|
||||
|
||||
static int
|
||||
c_api_room_show_themed(const char *const roomjid, const char *const group, const char *const item, const char *const def,
|
||||
const char *const ch, const char *const message)
|
||||
{
|
||||
return api_room_show_themed(roomjid, group, item, def, ch, message);
|
||||
}
|
||||
|
||||
void
|
||||
c_command_callback(PluginCommand *command, gchar **args)
|
||||
{
|
||||
@ -485,6 +511,10 @@ c_api_init(void)
|
||||
prof_room_unset_titlebar_enctext = c_api_room_unset_titlebar_enctext;
|
||||
prof_room_set_message_char = c_api_room_set_message_char;
|
||||
prof_room_unset_message_char = c_api_room_unset_message_char;
|
||||
prof_chat_show = c_api_chat_show;
|
||||
prof_chat_show_themed = c_api_chat_show_themed;
|
||||
prof_room_show = c_api_room_show;
|
||||
prof_room_show_themed = c_api_room_show_themed;
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -105,3 +105,11 @@ int (*prof_room_set_titlebar_enctext)(const char *roomjid, const char *enctext)
|
||||
int (*prof_room_unset_titlebar_enctext)(const char *roomjid) = NULL;
|
||||
int (*prof_room_set_message_char)(const char *roomjid, const char *ch) = NULL;
|
||||
int (*prof_room_unset_message_char)(const char *roomjid) = NULL;
|
||||
|
||||
int (*prof_chat_show)(const char *const barejid, const char *const message) = NULL;
|
||||
int (*prof_chat_show_themed)(const char *const barejid, const char *const group, const char *const item, const char *const def,
|
||||
const char *const ch, const char *const message) = NULL;
|
||||
|
||||
int (*prof_room_show)(const char *const roomjid, const char *const message) = NULL;
|
||||
int (*prof_room_show_themed)(const char *const roomjid, const char *const group, const char *const item, const char *const def,
|
||||
const char *const ch, const char *const message) = NULL;
|
||||
|
@ -118,4 +118,12 @@ int (*prof_room_unset_titlebar_enctext)(const char *roomjid);
|
||||
int (*prof_room_set_message_char)(const char *roomjid, const char *ch);
|
||||
int (*prof_room_unset_message_char)(const char *roomjid);
|
||||
|
||||
int (*prof_chat_show)(const char *const barejid, const char *const message);
|
||||
int (*prof_chat_show_themed)(const char *const barejid, const char *const group, const char *const item, const char *const def,
|
||||
const char *const ch, const char *const message);
|
||||
|
||||
int (*prof_room_show)(const char *const roomjid, const char *const message);
|
||||
int (*prof_room_show_themed)(const char *const roomjid, const char *const group, const char *const item, const char *const def,
|
||||
const char *const ch, const char *const message);
|
||||
|
||||
#endif
|
||||
|
@ -1284,6 +1284,130 @@ python_api_room_unset_message_char(PyObject *self, PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
python_api_chat_show(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *barejid = NULL;
|
||||
PyObject *message = NULL;
|
||||
if (!PyArg_ParseTuple(args, "OO", &barejid, &message)) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
char *barejid_str = python_str_or_unicode_to_string(barejid);
|
||||
char *message_str = python_str_or_unicode_to_string(message);
|
||||
|
||||
allow_python_threads();
|
||||
int res = api_chat_show(barejid_str, message_str);
|
||||
free(barejid_str);
|
||||
free(message_str);
|
||||
disable_python_threads();
|
||||
|
||||
if (res) {
|
||||
return Py_BuildValue("O", Py_True);
|
||||
} else {
|
||||
return Py_BuildValue("O", Py_False);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
python_api_chat_show_themed(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *barejid = NULL;
|
||||
PyObject *group = NULL;
|
||||
PyObject *key = NULL;
|
||||
PyObject *def = NULL;
|
||||
PyObject *ch = NULL;
|
||||
PyObject *message = NULL;
|
||||
if (!PyArg_ParseTuple(args, "OOOOOO", &barejid, &group, &key, &def, &ch, &message)) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
char *barejid_str = python_str_or_unicode_to_string(barejid);
|
||||
char *group_str = python_str_or_unicode_to_string(group);
|
||||
char *key_str = python_str_or_unicode_to_string(key);
|
||||
char *def_str = python_str_or_unicode_to_string(def);
|
||||
char *ch_str = python_str_or_unicode_to_string(ch);
|
||||
char *message_str = python_str_or_unicode_to_string(message);
|
||||
|
||||
allow_python_threads();
|
||||
int res = api_chat_show_themed(barejid_str, group_str, key_str, def_str, ch_str, message_str);
|
||||
free(barejid_str);
|
||||
free(group_str);
|
||||
free(key_str);
|
||||
free(def_str);
|
||||
free(ch_str);
|
||||
free(message_str);
|
||||
disable_python_threads();
|
||||
|
||||
if (res) {
|
||||
return Py_BuildValue("O", Py_True);
|
||||
} else {
|
||||
return Py_BuildValue("O", Py_False);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
python_api_room_show(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *roomjid = NULL;
|
||||
PyObject *message = NULL;
|
||||
if (!PyArg_ParseTuple(args, "OO", &roomjid, &message)) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
char *roomjid_str = python_str_or_unicode_to_string(roomjid);
|
||||
char *message_str = python_str_or_unicode_to_string(message);
|
||||
|
||||
allow_python_threads();
|
||||
int res = api_room_show(roomjid_str, message_str);
|
||||
free(roomjid_str);
|
||||
free(message_str);
|
||||
disable_python_threads();
|
||||
|
||||
if (res) {
|
||||
return Py_BuildValue("O", Py_True);
|
||||
} else {
|
||||
return Py_BuildValue("O", Py_False);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
python_api_room_show_themed(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *roomjid = NULL;
|
||||
PyObject *group = NULL;
|
||||
PyObject *key = NULL;
|
||||
PyObject *def = NULL;
|
||||
PyObject *ch = NULL;
|
||||
PyObject *message = NULL;
|
||||
if (!PyArg_ParseTuple(args, "OOOOOO", &roomjid, &group, &key, &def, &ch, &message)) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
char *roomjid_str = python_str_or_unicode_to_string(roomjid);
|
||||
char *group_str = python_str_or_unicode_to_string(group);
|
||||
char *key_str = python_str_or_unicode_to_string(key);
|
||||
char *def_str = python_str_or_unicode_to_string(def);
|
||||
char *ch_str = python_str_or_unicode_to_string(ch);
|
||||
char *message_str = python_str_or_unicode_to_string(message);
|
||||
|
||||
allow_python_threads();
|
||||
int res = api_room_show_themed(roomjid_str, group_str, key_str, def_str, ch_str, message_str);
|
||||
free(roomjid_str);
|
||||
free(group_str);
|
||||
free(key_str);
|
||||
free(def_str);
|
||||
free(ch_str);
|
||||
free(message_str);
|
||||
disable_python_threads();
|
||||
|
||||
if (res) {
|
||||
return Py_BuildValue("O", Py_True);
|
||||
} else {
|
||||
return Py_BuildValue("O", Py_False);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
python_command_callback(PluginCommand *command, gchar **args)
|
||||
{
|
||||
@ -1403,6 +1527,10 @@ static PyMethodDef apiMethods[] = {
|
||||
{ "room_unset_titlebar_enctext", python_api_room_unset_titlebar_enctext, METH_VARARGS, "Reset the encryption status in the title bar for the specified room" },
|
||||
{ "room_set_message_char", python_api_room_set_message_char, METH_VARARGS, "Set the message prefix character for specified room" },
|
||||
{ "room_unset_message_char", python_api_room_unset_message_char, METH_VARARGS, "Reset the message prefix character for specified room" },
|
||||
{ "chat_show", python_api_chat_show, METH_VARARGS, "Print a line in a chat window" },
|
||||
{ "chat_show_themed", python_api_chat_show_themed, METH_VARARGS, "Print a themed line in a chat window" },
|
||||
{ "room_show", python_api_room_show, METH_VARARGS, "Print a line in a chat room window" },
|
||||
{ "room_show_themed", python_api_room_show_themed, METH_VARARGS, "Print a themed line in a chat room window" },
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user