1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-16 21:35:24 +00:00

Merge branch 'master' into xep0308-last-message-correction

Conflicts:
	src/ui/mucwin.c
	src/ui/win_types.h
	src/ui/window.c
	src/ui/window.h
This commit is contained in:
James Booth 2017-01-22 22:26:07 +00:00
commit 4c8c3ca267
25 changed files with 1353 additions and 48 deletions

View File

@ -23,16 +23,16 @@ typedef void(*WINDOW_CB)(PROF_WIN_TAG win, char *line);
/** Highlights the console window in the status bar. */
void prof_cons_alert(void);
/**
/**
Show a message in the console window.
@param message the message to print
@return 1 on success, 0 on failure
*/
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
@ -341,7 +341,7 @@ End any encrypted session with the specified user.
void prof_encryption_reset(char *barejid);
/**
Set the text to display in the titlebar encryption indicator.
Set the text to display in the titlebar encryption indicator for recipient.
@param barejid Jabber ID of the recipient
@param enctext The text to display
@return 1 on success, 0 on failure
@ -349,9 +349,110 @@ Set the text to display in the titlebar encryption indicator.
int prof_chat_set_titlebar_enctext(char *barejid, char *enctext);
/**
Let profanity decide what to show in the titlebar encryption indicator
Let profanity decide what to show in the titlebar encryption indicator for recipient.
@param barejid Jabber ID of the recipient
@return 1 on success, 0 on failure
*/
int prof_chat_unset_titlebar_enctext(char *barejid);
/**
Set the incoming message prefix character for specified contact.
@param barejid Jabber ID of the recipient
@param ch The character to display
@return 1 on success, 0 on failure
*/
int prof_chat_set_incoming_char(char *barejid, char *ch);
/**
Reset the incoming message prefix character for specified contact.
@param barejid Jabber ID of the recipient
@return 1 on success, 0 on failure
*/
int prof_chat_unset_incoming_char(char *barejid);
/**
Set the outgoing message prefix character for specified contact.
@param barejid Jabber ID of the recipient
@param ch The character to display
@return 1 on success, 0 on failure
*/
int prof_chat_set_outgoing_char(char *barejid, char *ch);
/**
Reset the outgoing message prefix character for specified contact.
@param barejid Jabber ID of the recipient
@return 1 on success, 0 on failure
*/
int prof_chat_unset_outgoing_char(char *barejid);
/**
Set the text to display in the titlebar encryption indicator for room.
@param roomjid Jabber ID of the room
@param enctext The text to display
@return 1 on success, 0 on failure
*/
int prof_room_set_titlebar_enctext(char *roomjid, char *enctext);
/**
Let profanity decide what to show in the titlebar encryption indicator for room.
@param roomjid Jabber ID of the room
@return 1 on success, 0 on failure
*/
int prof_room_unset_titlebar_enctext(char *roomjid);
/**
Set the message prefix character for specified room.
@param roomjid Jabber ID of the room
@param ch The character to display
@return 1 on success, 0 on failure
*/
int prof_room_set_message_char(char *roomjid, char *ch);
/**
Reset the message prefix character for specified room.
@param roomjid Jabber ID of the 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);

View File

@ -61,7 +61,7 @@ void prof_post_chat_message_display(const char * const barejid, const char *cons
Called before a chat message is sent
@param barejid Jabber ID of the message recipient
@param message the message to be sent
@return the new message to send, or NULL to preserve the original message
@return the modified or original message to send, or NULL to cancel sending of the message
*/
char* prof_pre_chat_message_send(const char * const barejid, const char *message);
@ -93,7 +93,7 @@ void prof_post_room_message_display(const char * const barejid, const char * con
Called before a chat room message is sent
@param barejid Jabber ID of the room
@param message the message to be sent
@return the new message to send, or NULL to preserve the original message
@return the modified or original message to send, or NULL to cancel sending of the message
*/
char* prof_pre_room_message_send(const char * const barejid, const char *message);
@ -135,7 +135,7 @@ Called before a private chat room message is sent
@param barejid Jabber ID of the room
@param nick nickname of message recipient
@param message the message to be sent
@return the new message to send, or NULL to preserve the original message
@return the modified or original message to send, or NULL to cancel sending of the message
*/
char* prof_pre_priv_message_send(const char * const barejid, const char * const nick, const char *message);

View File

@ -106,7 +106,7 @@ def prof_pre_chat_message_send(barejid, message):
:param message: the message to be sent
:type barejid: str or unicode
:type message: str or unicode
:return: the new message to send, or ``None`` to preserve the original message
:return: the modified or original message to send, or ``None`` to cancel sending of the message
:rtype: str or unicode
"""
pass
@ -158,7 +158,7 @@ def prof_pre_room_message_send(barejid, message):
:param message: the message to be sent
:type barejid: str or unicode
:type message: str or unicode
:return: the new message to send, or ``None`` to preserve the original message
:return: the modified or original message to send, or ``None`` to cancel sending of the message
:rtype: str or unicode
"""
pass
@ -227,7 +227,7 @@ def prof_pre_priv_message_send(barejid, nick, message):
:type barejid: str or unicode
:type nick: str or unicode
:type message: str or unicode
:return: the new message to send, or ``None`` to preserve the original message
:return: the modified or original message to send, or ``None`` to cancel sending of the message
:rtype: str or unicode
"""
pass

View File

@ -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
@ -268,6 +268,7 @@ def get_room_nick(barejid):
:return: Room nickname.
:rtype: str
"""
pass
def current_win_is_console():
@ -375,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
@ -498,6 +499,7 @@ def settings_string_list_get(group, key):
::
prof.settings_get_string_list("someplugin", "somelist")
"""
pass
def settings_string_list_add(group, key, value):
@ -516,6 +518,7 @@ def settings_string_list_add(group, key, value):
::
prof.settings_string_list_add("someplugin", "somelist", "anelement")
"""
pass
def settings_string_list_remove(group, key, value):
@ -535,6 +538,7 @@ def settings_string_list_remove(group, key, value):
::
prof.settings_string_list_remove("someplugin", "somelist", "anelement")
"""
pass
def settings_string_list_clear(group, key):
@ -552,6 +556,7 @@ def settings_string_list_clear(group, key):
::
prof.settings_string_list_remove_all("someplugin", "somelist")
"""
pass
def settings_int_get(group, key, default):
@ -604,6 +609,7 @@ def incoming_message(barejid, resource, message):
::
prof.incoming_message("bob@server.org", "laptop", "Hello there")
"""
pass
def disco_add_feature(feature):
@ -630,10 +636,11 @@ def encryption_reset(barejid):
::
prof.encryption_reset("alice@server.org")
"""
pass
def chat_set_titlebar_enctext(barejid, enctext):
"""Set the text to display in the titlebar encryption indicator.
"""Set the text to display in the titlebar encryption indicator for recipient.
:param barejid: Jabber ID of the recipient
:param enctext: The text to display
@ -642,15 +649,15 @@ def chat_set_titlebar_enctext(barejid, enctext):
:return: ``True`` if the text was set successfully, ``False`` otherwise
:rtype: boolean
Example:
::
prof.chat_set_titlebar_enctext("bob@chat.org", "safe")
"""
pass
def chat_unset_titlebar_enctext(barejid):
"""Let profanity decide what to show in the titlebar encryption indicator.
"""Let profanity decide what to show in the titlebar encryption indicator for recipient.
:param barejid: Jabber ID of the recipient
:type barejid: str or unicode
@ -661,4 +668,218 @@ def chat_unset_titlebar_enctext(barejid):
::
prof.chat_unset_titlebar_enctext("bob@chat.org")
"""
pass
def chat_set_incoming_char(barejid, ch):
"""Set the incoming message prefix character for specified contact.
:param barejid: Jabber ID of the recipient
:param enctext: The character to display
:type barejid: str or unicode
:type enctext: str or unicode
:return: ``True`` if the character was set successfully, ``False`` otherwise
:rtype: boolean
Example:
::
prof.chat_set_incoming_char("kristine@chat.org", "*")
"""
pass
def chat_unset_incoming_char(barejid):
"""Reset the incoming message prefix character for specified contact.
:param barejid: Jabber ID of the recipient
:type barejid: str or unicode
:return: ``True`` if the char was unset successfully, ``False`` otherwise
:rtype: boolean
Example:
::
prof.chat_unset_incoming_char("kristine@chat.org")
"""
pass
def chat_set_outgoing_char(barejid, ch):
"""Set the outgoing message prefix character for specified contact.
:param barejid: Jabber ID of the recipient
:param enctext: The character to display
:type barejid: str or unicode
:type enctext: str or unicode
:return: ``True`` if the character was set successfully, ``False`` otherwise
:rtype: boolean
Example:
::
prof.chat_set_outgoing_char("david@chat.org", "+")
"""
pass
def chat_unset_outgoing_char(barejid):
"""Reset the outgoing message prefix character for specified contact.
:param barejid: Jabber ID of the recipient
:type barejid: str or unicode
:return: ``True`` if the char was unset successfully, ``False`` otherwise
:rtype: boolean
Example:
::
prof.chat_unset_outgoing_char("david@chat.org")
"""
pass
def room_set_titlebar_enctext(roomjid, enctext):
"""Set the text to display in the titlebar encryption indicator for room.
:param roomjid: Jabber ID of the room
:param enctext: The text to display
:type roomjid: str or unicode
:type enctext: str or unicode
:return: ``True`` if the text was set successfully, ``False`` otherwise
:rtype: boolean
Example:
::
prof.room_set_titlebar_enctext("generalchat@conference.service.com", "secret")
"""
pass
def room_unset_titlebar_enctext(roomjid):
"""Let profanity decide what to show in the titlebar encryption indicator for room.
:param roomjid: Jabber ID of the room
:type roomjid: str or unicode
:return: ``True`` if the text was unset successfully, ``False`` otherwise
:rtype: boolean
Example:
::
prof.room_unset_titlebar_enctext("generalchat@conference.service.com")
"""
pass
def room_set_message_char(roomjid, ch):
"""Set the message prefix character for specified room.
:param roomjid: Jabber ID of the room
:param enctext: The character to display
:type roomjid: str or unicode
:type enctext: str or unicode
:return: ``True`` if the character was set successfully, ``False`` otherwise
:rtype: boolean
Example:
::
prof.room_set_message_char("ohnoes@conference.chat.org", "^")
"""
pass
def room_unset_message_char(roomjid):
"""Reset the message prefix character for specified room.
:param roomjid: Jabber ID of the room
:type roomjid: str or unicode
:return: ``True`` if the char was unset successfully, ``False`` otherwise
:rtype: boolean
Example:
::
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

View File

@ -141,6 +141,9 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, gboolean upload, gbo
}
char *plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg);
if (plugin_msg == NULL) {
return;
}
// OTR suported, PGP supported
#ifdef HAVE_LIBOTR
@ -223,6 +226,9 @@ void
cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg, gboolean upload)
{
char *plugin_msg = plugins_pre_room_message_send(mucwin->roomjid, msg);
if (plugin_msg == NULL) {
return;
}
message_send_groupchat(mucwin->roomjid, plugin_msg, upload);

View File

@ -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;
}
@ -561,3 +569,320 @@ api_chat_unset_titlebar_enctext(const char *const barejid)
return 1;
}
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;
}
chatwin_set_incoming_char(chatwin, ch);
return 1;
}
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;
}
chatwin_unset_incoming_char(chatwin);
return 1;
}
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;
}
chatwin_set_outgoing_char(chatwin, ch);
return 1;
}
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;
}
chatwin_unset_outgoing_char(chatwin);
return 1;
}
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;
}
mucwin_set_enctext(mucwin, enctext);
return 1;
}
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;
}
mucwin_unset_enctext(mucwin);
return 1;
}
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;
}
mucwin_set_message_char(mucwin, ch);
return 1;
}
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;
}
mucwin_unset_message_char(mucwin);
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;
}

View File

@ -100,5 +100,21 @@ void api_encryption_reset(const char *const barejid);
int api_chat_set_titlebar_enctext(const char *const barejid, const char *const enctext);
int api_chat_unset_titlebar_enctext(const char *const barejid);
int api_chat_set_incoming_char(const char *const barejid, const char *const ch);
int api_chat_unset_incoming_char(const char *const barejid);
int api_chat_set_outgoing_char(const char *const barejid, const char *const ch);
int api_chat_unset_outgoing_char(const char *const barejid);
int api_room_set_titlebar_enctext(const char *const roomjid, const char *const enctext);
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

View File

@ -359,6 +359,80 @@ c_api_chat_unset_titlebar_enctext(const char *barejid)
return api_chat_unset_titlebar_enctext(barejid);
}
static int
c_api_chat_set_incoming_char(const char *barejid, const char *ch)
{
return api_chat_set_incoming_char(barejid, ch);
}
static int
c_api_chat_unset_incoming_char(const char *barejid)
{
return api_chat_unset_incoming_char(barejid);
}
static int
c_api_chat_set_outgoing_char(const char *barejid, const char *ch)
{
return api_chat_set_outgoing_char(barejid, ch);
}
static int
c_api_chat_unset_outgoing_char(const char *barejid)
{
return api_chat_unset_outgoing_char(barejid);
}
static int
c_api_room_set_titlebar_enctext(const char *roomjid, const char *enctext)
{
return api_room_set_titlebar_enctext(roomjid, enctext);
}
static int
c_api_room_unset_titlebar_enctext(const char *roomjid)
{
return api_room_unset_titlebar_enctext(roomjid);
}
static int
c_api_room_set_message_char(const char *roomjid, const char *ch)
{
return api_room_set_message_char(roomjid, ch);
}
static int
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)
{
@ -429,6 +503,18 @@ c_api_init(void)
prof_encryption_reset = c_api_encryption_reset;
prof_chat_set_titlebar_enctext = c_api_chat_set_titlebar_enctext;
prof_chat_unset_titlebar_enctext = c_api_chat_unset_titlebar_enctext;
prof_chat_set_incoming_char = c_api_chat_set_incoming_char;
prof_chat_unset_incoming_char = c_api_chat_unset_incoming_char;
prof_chat_set_outgoing_char = c_api_chat_set_outgoing_char;
prof_chat_unset_outgoing_char = c_api_chat_unset_outgoing_char;
prof_room_set_titlebar_enctext = c_api_room_set_titlebar_enctext;
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 *

View File

@ -81,6 +81,7 @@ c_plugin_create(const char *const filename)
plugin->lang = LANG_C;
plugin->module = handle;
plugin->init_func = c_init_hook;
plugin->contains_hook = c_contains_hook;
plugin->on_start_func = c_on_start_hook;
plugin->on_shutdown_func = c_on_shutdown_hook;
plugin->on_unload_func = c_on_unload_hook;
@ -136,6 +137,16 @@ c_init_hook(ProfPlugin *plugin, const char *const version, const char *const sta
func(version, status, account_name, fulljid);
}
gboolean
c_contains_hook(ProfPlugin *plugin, const char *const hook)
{
if (dlsym(plugin->module, hook)) {
return TRUE;
} else {
return FALSE;
}
}
void
c_on_start_hook(ProfPlugin *plugin)
{

View File

@ -45,6 +45,9 @@ void c_shutdown(void);
void c_init_hook(ProfPlugin *plugin, const char *const version, const char *const status, const char *const account_name,
const char *const fulljid);
gboolean c_contains_hook(ProfPlugin *plugin, const char *const hook);
void c_on_start_hook(ProfPlugin *plugin);
void c_on_shutdown_hook(ProfPlugin *plugin);
void c_on_unload_hook(ProfPlugin *plugin);

View File

@ -413,11 +413,18 @@ plugins_pre_chat_message_send(const char * const barejid, const char *message)
GList *curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
new_message = plugin->pre_chat_message_send(plugin, barejid, curr_message);
if (new_message) {
free(curr_message);
curr_message = strdup(new_message);
free(new_message);
if (plugin->contains_hook(plugin, "prof_pre_chat_message_send")) {
new_message = plugin->pre_chat_message_send(plugin, barejid, curr_message);
if (new_message) {
free(curr_message);
curr_message = strdup(new_message);
free(new_message);
} else {
free(curr_message);
g_list_free(values);
return NULL;
}
}
curr = g_list_next(curr);
}
@ -485,11 +492,18 @@ plugins_pre_room_message_send(const char * const barejid, const char *message)
GList *curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
new_message = plugin->pre_room_message_send(plugin, barejid, curr_message);
if (new_message) {
free(curr_message);
curr_message = strdup(new_message);
free(new_message);
if (plugin->contains_hook(plugin, "prof_pre_room_message_send")) {
new_message = plugin->pre_room_message_send(plugin, barejid, curr_message);
if (new_message) {
free(curr_message);
curr_message = strdup(new_message);
free(new_message);
} else {
free(curr_message);
g_list_free(values);
return NULL;
}
}
curr = g_list_next(curr);
}
@ -587,11 +601,19 @@ plugins_pre_priv_message_send(const char * const fulljid, const char * const mes
GList *curr = values;
while (curr) {
ProfPlugin *plugin = curr->data;
new_message = plugin->pre_priv_message_send(plugin, jidp->barejid, jidp->resourcepart, curr_message);
if (new_message) {
free(curr_message);
curr_message = strdup(new_message);
free(new_message);
if (plugin->contains_hook(plugin, "prof_pre_priv_message_send")) {
new_message = plugin->pre_priv_message_send(plugin, jidp->barejid, jidp->resourcepart, curr_message);
if (new_message) {
free(curr_message);
curr_message = strdup(new_message);
free(new_message);
} else {
free(curr_message);
g_list_free(values);
jid_destroy(jidp);
return NULL;
}
}
curr = g_list_next(curr);
}

View File

@ -49,6 +49,8 @@ typedef struct prof_plugin_t {
void (*init_func)(struct prof_plugin_t* plugin, const char * const version,
const char * const status, const char *const account_name, const char *const fulljid);
gboolean (*contains_hook)(struct prof_plugin_t* plugin, const char *const hook);
void (*on_start_func)(struct prof_plugin_t* plugin);
void (*on_shutdown_func)(struct prof_plugin_t* plugin);
void (*on_unload_func)(struct prof_plugin_t* plugin);

View File

@ -97,4 +97,19 @@ void (*prof_encryption_reset)(const char *barejid) = NULL;
int (*prof_chat_set_titlebar_enctext)(const char *barejid, const char *enctext) = NULL;
int (*prof_chat_unset_titlebar_enctext)(const char *barejid) = NULL;
int (*prof_chat_set_incoming_char)(const char *barejid, const char *ch) = NULL;
int (*prof_chat_unset_incoming_char)(const char *barejid) = NULL;
int (*prof_chat_set_outgoing_char)(const char *barejid, const char *ch) = NULL;
int (*prof_chat_unset_outgoing_char)(const char *barejid) = NULL;
int (*prof_room_set_titlebar_enctext)(const char *roomjid, const char *enctext) = NULL;
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;

View File

@ -109,5 +109,21 @@ void (*prof_encryption_reset)(const char *barejid);
int (*prof_chat_set_titlebar_enctext)(const char *barejid, const char *enctext);
int (*prof_chat_unset_titlebar_enctext)(const char *barejid);
int (*prof_chat_set_incoming_char)(const char *barejid, const char *ch);
int (*prof_chat_unset_incoming_char)(const char *barejid);
int (*prof_chat_set_outgoing_char)(const char *barejid, const char *ch);
int (*prof_chat_unset_outgoing_char)(const char *barejid);
int (*prof_room_set_titlebar_enctext)(const char *roomjid, const char *enctext);
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

View File

@ -1096,6 +1096,318 @@ python_api_chat_unset_titlebar_enctext(PyObject *self, PyObject *args)
}
}
static PyObject*
python_api_chat_set_incoming_char(PyObject *self, PyObject *args)
{
PyObject *barejid = NULL;
PyObject *ch = NULL;
if (!PyArg_ParseTuple(args, "OO", &barejid, &ch)) {
Py_RETURN_NONE;
}
char *barejid_str = python_str_or_unicode_to_string(barejid);
char *ch_str = python_str_or_unicode_to_string(ch);
allow_python_threads();
int res = api_chat_set_incoming_char(barejid_str, ch_str);
free(barejid_str);
free(ch_str);
disable_python_threads();
if (res) {
return Py_BuildValue("O", Py_True);
} else {
return Py_BuildValue("O", Py_False);
}
}
static PyObject*
python_api_chat_unset_incoming_char(PyObject *self, PyObject *args)
{
PyObject *barejid = NULL;
if (!PyArg_ParseTuple(args, "O", &barejid)) {
Py_RETURN_NONE;
}
char *barejid_str = python_str_or_unicode_to_string(barejid);
allow_python_threads();
int res = api_chat_unset_incoming_char(barejid_str);
free(barejid_str);
disable_python_threads();
if (res) {
return Py_BuildValue("O", Py_True);
} else {
return Py_BuildValue("O", Py_False);
}
}
static PyObject*
python_api_chat_set_outgoing_char(PyObject *self, PyObject *args)
{
PyObject *barejid = NULL;
PyObject *ch = NULL;
if (!PyArg_ParseTuple(args, "OO", &barejid, &ch)) {
Py_RETURN_NONE;
}
char *barejid_str = python_str_or_unicode_to_string(barejid);
char *ch_str = python_str_or_unicode_to_string(ch);
allow_python_threads();
int res = api_chat_set_outgoing_char(barejid_str, ch_str);
free(barejid_str);
free(ch_str);
disable_python_threads();
if (res) {
return Py_BuildValue("O", Py_True);
} else {
return Py_BuildValue("O", Py_False);
}
}
static PyObject*
python_api_chat_unset_outgoing_char(PyObject *self, PyObject *args)
{
PyObject *barejid = NULL;
if (!PyArg_ParseTuple(args, "O", &barejid)) {
Py_RETURN_NONE;
}
char *barejid_str = python_str_or_unicode_to_string(barejid);
allow_python_threads();
int res = api_chat_unset_outgoing_char(barejid_str);
free(barejid_str);
disable_python_threads();
if (res) {
return Py_BuildValue("O", Py_True);
} else {
return Py_BuildValue("O", Py_False);
}
}
static PyObject*
python_api_room_set_titlebar_enctext(PyObject *self, PyObject *args)
{
PyObject *roomjid = NULL;
PyObject *enctext = NULL;
if (!PyArg_ParseTuple(args, "OO", &roomjid, &enctext)) {
Py_RETURN_NONE;
}
char *roomjid_str = python_str_or_unicode_to_string(roomjid);
char *enctext_str = python_str_or_unicode_to_string(enctext);
allow_python_threads();
int res = api_room_set_titlebar_enctext(roomjid_str, enctext_str);
free(roomjid_str);
free(enctext_str);
disable_python_threads();
if (res) {
return Py_BuildValue("O", Py_True);
} else {
return Py_BuildValue("O", Py_False);
}
}
static PyObject*
python_api_room_unset_titlebar_enctext(PyObject *self, PyObject *args)
{
PyObject *roomjid = NULL;
if (!PyArg_ParseTuple(args, "O", &roomjid)) {
Py_RETURN_NONE;
}
char *roomjid_str = python_str_or_unicode_to_string(roomjid);
allow_python_threads();
int res = api_room_unset_titlebar_enctext(roomjid_str);
free(roomjid_str);
disable_python_threads();
if (res) {
return Py_BuildValue("O", Py_True);
} else {
return Py_BuildValue("O", Py_False);
}
}
static PyObject*
python_api_room_set_message_char(PyObject *self, PyObject *args)
{
PyObject *roomjid = NULL;
PyObject *ch = NULL;
if (!PyArg_ParseTuple(args, "OO", &roomjid, &ch)) {
Py_RETURN_NONE;
}
char *roomjid_str = python_str_or_unicode_to_string(roomjid);
char *ch_str = python_str_or_unicode_to_string(ch);
allow_python_threads();
int res = api_room_set_message_char(roomjid_str, ch_str);
free(roomjid_str);
free(ch_str);
disable_python_threads();
if (res) {
return Py_BuildValue("O", Py_True);
} else {
return Py_BuildValue("O", Py_False);
}
}
static PyObject*
python_api_room_unset_message_char(PyObject *self, PyObject *args)
{
PyObject *roomjid = NULL;
if (!PyArg_ParseTuple(args, "O", &roomjid)) {
Py_RETURN_NONE;
}
char *roomjid_str = python_str_or_unicode_to_string(roomjid);
allow_python_threads();
int res = api_room_unset_message_char(roomjid_str);
free(roomjid_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(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)
{
@ -1207,6 +1519,18 @@ static PyMethodDef apiMethods[] = {
{ "encryption_reset", python_api_encryption_reset, METH_VARARGS, "End encrypted chat session with barejid, if one exists" },
{ "chat_set_titlebar_enctext", python_api_chat_set_titlebar_enctext, METH_VARARGS, "Set the encryption status in the title bar for the specified contact" },
{ "chat_unset_titlebar_enctext", python_api_chat_unset_titlebar_enctext, METH_VARARGS, "Reset the encryption status in the title bar for the specified recipient" },
{ "chat_set_incoming_char", python_api_chat_set_incoming_char, METH_VARARGS, "Set the incoming message prefix character for specified contact" },
{ "chat_unset_incoming_char", python_api_chat_unset_incoming_char, METH_VARARGS, "Reset the incoming message prefix character for specified contact" },
{ "chat_set_outgoing_char", python_api_chat_set_outgoing_char, METH_VARARGS, "Set the outgoing message prefix character for specified contact" },
{ "chat_unset_outgoing_char", python_api_chat_unset_outgoing_char, METH_VARARGS, "Reset the outgoing message prefix character for specified contact" },
{ "room_set_titlebar_enctext", python_api_room_set_titlebar_enctext, METH_VARARGS, "Set the encryption status in the title bar for the specified room" },
{ "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 }
};

View File

@ -125,6 +125,7 @@ python_plugin_create(const char *const filename)
plugin->lang = LANG_PYTHON;
plugin->module = p_module;
plugin->init_func = python_init_hook;
plugin->contains_hook = python_contains_hook;
plugin->on_start_func = python_on_start_hook;
plugin->on_shutdown_func = python_on_shutdown_hook;
plugin->on_unload_func = python_on_unload_hook;
@ -184,6 +185,22 @@ python_init_hook(ProfPlugin *plugin, const char *const version, const char *cons
allow_python_threads();
}
gboolean
python_contains_hook(ProfPlugin *plugin, const char *const hook)
{
disable_python_threads();
gboolean res = FALSE;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, hook)) {
res = TRUE;
}
allow_python_threads();
return res;
}
void
python_on_start_hook(ProfPlugin *plugin)
{

View File

@ -47,6 +47,9 @@ const char* python_get_version(void);
void python_init_hook(ProfPlugin *plugin, const char *const version, const char *const status,
const char *const account_name, const char *const fulljid);
gboolean python_contains_hook(ProfPlugin *plugin, const char *const hook);
void python_on_start_hook(ProfPlugin *plugin);
void python_on_shutdown_hook(ProfPlugin *plugin);
void python_on_unload_hook(ProfPlugin *plugin);

View File

@ -331,7 +331,9 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
_chatwin_set_last_message(chatwin, id, message);
char enc_char = '-';
if (enc_mode == PROF_MSG_OTR) {
if (chatwin->outgoing_char) {
enc_char = chatwin->outgoing_char[0];
} else if (enc_mode == PROF_MSG_OTR) {
enc_char = prefs_get_otr_char();
} else if (enc_mode == PROF_MSG_PGP) {
enc_char = prefs_get_pgp_char();
@ -431,6 +433,42 @@ chatwin_unset_enctext(ProfChatWin *chatwin)
}
}
void
chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch)
{
if (chatwin->incoming_char) {
free(chatwin->incoming_char);
}
chatwin->incoming_char = strdup(ch);
}
void
chatwin_unset_incoming_char(ProfChatWin *chatwin)
{
if (chatwin->incoming_char) {
free(chatwin->incoming_char);
chatwin->incoming_char = NULL;
}
}
void
chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch)
{
if (chatwin->outgoing_char) {
free(chatwin->outgoing_char);
}
chatwin->outgoing_char = strdup(ch);
}
void
chatwin_unset_outgoing_char(ProfChatWin *chatwin)
{
if (chatwin->outgoing_char) {
free(chatwin->outgoing_char);
chatwin->outgoing_char = NULL;
}
}
static void
_chatwin_history(ProfChatWin *chatwin, const char *const contact)
{

View File

@ -479,15 +479,20 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const id,
ProfWin *window = (ProfWin*)mucwin;
char *mynick = muc_nick(mucwin->roomjid);
char ch = '-';
if (mucwin->message_char) {
ch = mucwin->message_char[0];
}
if (g_strcmp0(nick, mynick) != 0) {
if (g_slist_length(mentions) > 0) {
win_print_muc_occupant(window, THEME_ROOMMENTION, nick);
win_print_muc_occupant(window, THEME_ROOMMENTION, ch, nick);
_mucwin_print_mention(window, message, mynick, mentions);
} else if (triggers) {
win_print_muc_occupant(window, THEME_ROOMTRIGGER, nick);
win_print_muc_occupant(window, THEME_ROOMTRIGGER, ch, nick);
_mucwin_print_triggers(window, message, triggers);
} else {
win_print_muc_occupant_message(window, nick, message);
win_print_muc_occupant_message(window, ch, nick, message);
}
} else {
if (mucwin->last_message) {
@ -498,7 +503,7 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const id,
free(mucwin->last_id);
}
mucwin->last_id = strdup(id);
win_print_muc_self_message(window, mynick, message);
win_print_muc_self_message(window, ch, mynick, message);
}
}
@ -869,3 +874,39 @@ mucwin_get_string(ProfMucWin *mucwin)
return resstr;
}
void
mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext)
{
if (mucwin->enctext) {
free(mucwin->enctext);
}
mucwin->enctext = strdup(enctext);
}
void
mucwin_unset_enctext(ProfMucWin *mucwin)
{
if (mucwin->enctext) {
free(mucwin->enctext);
mucwin->enctext = NULL;
}
}
void
mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch)
{
if (mucwin->message_char) {
free(mucwin->message_char);
}
mucwin->message_char = strdup(ch);
}
void
mucwin_unset_message_char(ProfMucWin *mucwin)
{
if (mucwin->message_char) {
free(mucwin->message_char);
mucwin->message_char = NULL;
}
}

View File

@ -62,6 +62,7 @@ static void _title_bar_draw(void);
static void _show_self_presence(void);
static void _show_contact_presence(ProfChatWin *chatwin);
static void _show_privacy(ProfChatWin *chatwin);
static void _show_muc_privacy(ProfMucWin *mucwin);
void
create_title_bar(void)
@ -202,6 +203,10 @@ _title_bar_draw(void)
if (typing) {
wprintw(win, " (typing...)");
}
} else if (current && current->type == WIN_MUC) {
ProfMucWin *mucwin = (ProfMucWin*) current;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
_show_muc_privacy(mucwin);
}
_show_self_presence();
@ -310,6 +315,27 @@ _show_self_presence(void)
}
}
static void
_show_muc_privacy(ProfMucWin *mucwin)
{
int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED);
if (mucwin->enctext) {
wprintw(win, " ");
wattron(win, bracket_attrs);
wprintw(win, "[");
wattroff(win, bracket_attrs);
wattron(win, encrypted_attrs);
wprintw(win, mucwin->enctext);
wattroff(win, encrypted_attrs);
wattron(win, bracket_attrs);
wprintw(win, "]");
return;
}
}
static void
_show_privacy(ProfChatWin *chatwin)
{

View File

@ -137,6 +137,10 @@ void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, voi
#endif
void chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext);
void chatwin_unset_enctext(ProfChatWin *chatwin);
void chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch);
void chatwin_unset_incoming_char(ProfChatWin *chatwin);
void chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch);
void chatwin_unset_outgoing_char(ProfChatWin *chatwin);
// MUC window
void mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason);
@ -185,6 +189,10 @@ void mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const ch
void mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks);
void mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error);
char* mucwin_get_string(ProfMucWin *mucwin);
void mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext);
void mucwin_unset_enctext(ProfMucWin *mucwin);
void mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch);
void mucwin_unset_message_char(ProfMucWin *mucwin);
// MUC private chat window
void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp);

View File

@ -158,6 +158,8 @@ typedef struct prof_chat_win_t {
char *last_id;
char *last_message;
char *enctext;
char *incoming_char;
char *outgoing_char;
} ProfChatWin;
typedef struct prof_muc_win_t {
@ -170,6 +172,8 @@ typedef struct prof_muc_win_t {
unsigned long memcheck;
char *last_id;
char *last_message;
char *enctext;
char *message_char;
} ProfMucWin;
typedef struct prof_mucconf_win_t {
@ -243,3 +247,4 @@ typedef struct prof_buff_entry_t {
} ProfBuffEntry;
#endif

View File

@ -150,6 +150,8 @@ win_create_chat(const char *const barejid)
new_win->last_message = NULL;
new_win->last_id = NULL;
new_win->enctext = NULL;
new_win->incoming_char = NULL;
new_win->outgoing_char = NULL;
new_win->memcheck = PROFCHATWIN_MEMCHECK;
@ -197,6 +199,8 @@ win_create_muc(const char *const roomjid)
}
new_win->last_id = NULL;
new_win->last_message = NULL;
new_win->enctext = NULL;
new_win->message_char = NULL;
new_win->memcheck = PROFMUCWIN_MEMCHECK;
@ -438,6 +442,8 @@ win_free(ProfWin* window)
free(chatwin->barejid);
free(chatwin->resource_override);
free(chatwin->enctext);
free(chatwin->incoming_char);
free(chatwin->outgoing_char);
chat_state_free(chatwin->state);
break;
}
@ -445,6 +451,8 @@ win_free(ProfWin* window)
{
ProfMucWin *mucwin = (ProfMucWin*)window;
free(mucwin->roomjid);
free(mucwin->enctext);
free(mucwin->message_char);
break;
}
case WIN_MUC_CONFIG:
@ -1106,31 +1114,31 @@ win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *con
}
void
win_print_muc_occupant(ProfWin *window, theme_item_t theme_item, const char *const them)
win_print_muc_occupant(ProfWin *window, theme_item_t theme_item, char ch, const char *const them)
{
ProfBuffDate *date = buffer_date_new_now();
ProfBuffFrom *from = them ? buffer_from_new(FROM_THEM, them) : NULL;
ProfBuffEntry *entry = buffer_entry_create(theme_item, date, '-', from, "", 0, FALSE, NULL);
ProfBuffEntry *entry = buffer_entry_create(theme_item, date, ch, from, "", 0, FALSE, NULL);
buffer_append(window, entry);
}
void
win_print_muc_occupant_message(ProfWin *window, const char *const them, const char *const message)
win_print_muc_occupant_message(ProfWin *window, char ch, const char *const them, const char *const message)
{
ProfBuffDate *date = buffer_date_new_now();
ProfBuffFrom *from = them ? buffer_from_new(FROM_THEM, them) : NULL;
ProfBuffEntry *entry = buffer_entry_create(THEME_TEXT_THEM, date, '-', from, message, 0, TRUE, NULL);
ProfBuffEntry *entry = buffer_entry_create(THEME_TEXT_THEM, date, ch, from, message, 0, TRUE, NULL);
buffer_append(window, entry);
}
void
win_print_muc_self_message(ProfWin *window, const char *const me, const char *const message)
win_print_muc_self_message(ProfWin *window, char ch, const char *const me, const char *const message)
{
ProfBuffDate *date = buffer_date_new_now();
ProfBuffFrom *from = me ? buffer_from_new(FROM_ME, me) : NULL;
ProfBuffEntry *entry = buffer_entry_create(THEME_TEXT_ME, date, '-', from, message, 0, TRUE, NULL);
ProfBuffEntry *entry = buffer_entry_create(THEME_TEXT_ME, date, ch, from, message, 0, TRUE, NULL);
buffer_append(window, entry);
}
@ -1145,7 +1153,10 @@ win_print_incoming(ProfWin *window, GDateTime *timestamp, const char *const them
char ch = '-';
if (window->type == WIN_CHAT) {
if (enc_mode == PROF_MSG_OTR) {
ProfChatWin *chatwin = (ProfChatWin*)window;
if (chatwin->incoming_char) {
ch = chatwin->incoming_char[0];
} else if (enc_mode == PROF_MSG_OTR) {
ch = prefs_get_otr_char();
} else if (enc_mode == PROF_MSG_PGP) {
ch = prefs_get_pgp_char();

View File

@ -59,10 +59,9 @@ void win_show_status_string(ProfWin *window, const char *const from,
GDateTime *last_activity, const char *const pre,
const char *const default_show);
void win_print_muc_occupant(ProfWin *window, theme_item_t theme_item, const char *const them);
void win_print_muc_occupant_message(ProfWin *window, const char *const them, const char *const message);
void win_print_muc_self_message(ProfWin *window, const char *const me, const char *const message);
void win_print_muc_occupant(ProfWin *window, theme_item_t theme_item, char ch, const char *const them);
void win_print_muc_occupant_message(ProfWin *window, char ch, const char *const them, const char *const message);
void win_print_muc_self_message(ProfWin *window, char ch, const char *const me, const char *const message);
void win_print_outgoing(ProfWin *window, const char ch, const char *const message, const char *const id, gboolean request_receipt);
void win_print_incoming(ProfWin *window, GDateTime *timestamp, const char *const them, const char *const id,

View File

@ -69,6 +69,10 @@ void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, voi
void chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext) {}
void chatwin_unset_enctext(ProfChatWin *chatwin) {}
void chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch) {}
void chatwin_unset_incoming_char(ProfChatWin *chatwin) {}
void chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch) {}
void chatwin_unset_outgoing_char(ProfChatWin *chatwin) {}
void ui_sigwinch_handler(int sig) {}
@ -217,6 +221,11 @@ void mucwin_occupant_presence(ProfMucWin *mucwin, const char * const nick, const
void mucwin_update_occupants(ProfMucWin *mucwin) {}
void mucwin_show_occupants(ProfMucWin *mucwin) {}
void mucwin_hide_occupants(ProfMucWin *mucwin) {}
void mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext) {}
void mucwin_unset_enctext(ProfMucWin *mucwin) {}
void mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch) {}
void mucwin_unset_message_char(ProfMucWin *mucwin) {}
void ui_show_roster(void) {}
void ui_hide_roster(void) {}
void ui_roster_add(const char * const barejid, const char * const name) {}