mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Allow room display properies to be set by plugins
Conflicts: src/ui/mucwin.c src/ui/window.c src/ui/window.h
This commit is contained in:
parent
f474118093
commit
a3dc7ac5bd
@ -341,7 +341,7 @@ End any encrypted session with the specified user.
|
|||||||
void prof_encryption_reset(char *barejid);
|
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 barejid Jabber ID of the recipient
|
||||||
@param enctext The text to display
|
@param enctext The text to display
|
||||||
@return 1 on success, 0 on failure
|
@return 1 on success, 0 on failure
|
||||||
@ -349,7 +349,7 @@ Set the text to display in the titlebar encryption indicator.
|
|||||||
int prof_chat_set_titlebar_enctext(char *barejid, char *enctext);
|
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
|
@param barejid Jabber ID of the recipient
|
||||||
@return 1 on success, 0 on failure
|
@return 1 on success, 0 on failure
|
||||||
*/
|
*/
|
||||||
@ -384,3 +384,33 @@ Reset the outgoing message prefix character for specified contact.
|
|||||||
@return 1 on success, 0 on failure
|
@return 1 on success, 0 on failure
|
||||||
*/
|
*/
|
||||||
int prof_chat_unset_outgoing_char(char *barejid);
|
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);
|
||||||
|
@ -268,6 +268,7 @@ def get_room_nick(barejid):
|
|||||||
:return: Room nickname.
|
:return: Room nickname.
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def current_win_is_console():
|
def current_win_is_console():
|
||||||
@ -498,6 +499,7 @@ def settings_string_list_get(group, key):
|
|||||||
::
|
::
|
||||||
prof.settings_get_string_list("someplugin", "somelist")
|
prof.settings_get_string_list("someplugin", "somelist")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def settings_string_list_add(group, key, value):
|
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")
|
prof.settings_string_list_add("someplugin", "somelist", "anelement")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def settings_string_list_remove(group, key, value):
|
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")
|
prof.settings_string_list_remove("someplugin", "somelist", "anelement")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def settings_string_list_clear(group, key):
|
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")
|
prof.settings_string_list_remove_all("someplugin", "somelist")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def settings_int_get(group, key, default):
|
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")
|
prof.incoming_message("bob@server.org", "laptop", "Hello there")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def disco_add_feature(feature):
|
def disco_add_feature(feature):
|
||||||
@ -630,10 +636,11 @@ def encryption_reset(barejid):
|
|||||||
::
|
::
|
||||||
prof.encryption_reset("alice@server.org")
|
prof.encryption_reset("alice@server.org")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def chat_set_titlebar_enctext(barejid, enctext):
|
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 barejid: Jabber ID of the recipient
|
||||||
:param enctext: The text to display
|
: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
|
:return: ``True`` if the text was set successfully, ``False`` otherwise
|
||||||
:rtype: boolean
|
:rtype: boolean
|
||||||
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
::
|
::
|
||||||
prof.chat_set_titlebar_enctext("bob@chat.org", "safe")
|
prof.chat_set_titlebar_enctext("bob@chat.org", "safe")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def chat_unset_titlebar_enctext(barejid):
|
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
|
:param barejid: Jabber ID of the recipient
|
||||||
:type barejid: str or unicode
|
:type barejid: str or unicode
|
||||||
@ -661,6 +668,7 @@ def chat_unset_titlebar_enctext(barejid):
|
|||||||
::
|
::
|
||||||
prof.chat_unset_titlebar_enctext("bob@chat.org")
|
prof.chat_unset_titlebar_enctext("bob@chat.org")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def chat_set_incoming_char(barejid, ch):
|
def chat_set_incoming_char(barejid, ch):
|
||||||
@ -673,11 +681,11 @@ def chat_set_incoming_char(barejid, ch):
|
|||||||
:return: ``True`` if the character was set successfully, ``False`` otherwise
|
:return: ``True`` if the character was set successfully, ``False`` otherwise
|
||||||
:rtype: boolean
|
:rtype: boolean
|
||||||
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
::
|
::
|
||||||
prof.chat_set_incoming_char("kristine@chat.org", "*")
|
prof.chat_set_incoming_char("kristine@chat.org", "*")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def chat_unset_incoming_char(barejid):
|
def chat_unset_incoming_char(barejid):
|
||||||
@ -692,6 +700,7 @@ def chat_unset_incoming_char(barejid):
|
|||||||
::
|
::
|
||||||
prof.chat_unset_incoming_char("kristine@chat.org")
|
prof.chat_unset_incoming_char("kristine@chat.org")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def chat_set_outgoing_char(barejid, ch):
|
def chat_set_outgoing_char(barejid, ch):
|
||||||
@ -704,11 +713,11 @@ def chat_set_outgoing_char(barejid, ch):
|
|||||||
:return: ``True`` if the character was set successfully, ``False`` otherwise
|
:return: ``True`` if the character was set successfully, ``False`` otherwise
|
||||||
:rtype: boolean
|
:rtype: boolean
|
||||||
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
::
|
::
|
||||||
prof.chat_set_outgoing_char("david@chat.org", "+")
|
prof.chat_set_outgoing_char("david@chat.org", "+")
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def chat_unset_outgoing_char(barejid):
|
def chat_unset_outgoing_char(barejid):
|
||||||
@ -723,4 +732,68 @@ def chat_unset_outgoing_char(barejid):
|
|||||||
::
|
::
|
||||||
prof.chat_unset_outgoing_char("david@chat.org")
|
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
|
||||||
|
@ -645,3 +645,83 @@ api_chat_unset_outgoing_char(const char *const barejid)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
api_room_set_titlebar_enctext(const char *const roomjid, const char *const enctext)
|
||||||
|
{
|
||||||
|
if (enctext == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (roomjid == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||||
|
if (mucwin == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mucwin_set_enctext(mucwin, enctext);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
api_room_unset_titlebar_enctext(const char *const roomjid)
|
||||||
|
{
|
||||||
|
if (roomjid == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||||
|
if (mucwin == NULL) {
|
||||||
|
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) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(ch) != 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (roomjid == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||||
|
if (mucwin == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mucwin_set_message_char(mucwin, ch);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
api_room_unset_message_char(const char *const roomjid)
|
||||||
|
{
|
||||||
|
if (roomjid == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||||
|
if (mucwin == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mucwin_unset_message_char(mucwin);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@ -104,5 +104,9 @@ 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_unset_incoming_char(const char *const barejid);
|
||||||
int api_chat_set_outgoing_char(const char *const barejid, const char *const ch);
|
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_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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -383,6 +383,30 @@ c_api_chat_unset_outgoing_char(const char *barejid)
|
|||||||
return api_chat_unset_outgoing_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);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
c_command_callback(PluginCommand *command, gchar **args)
|
c_command_callback(PluginCommand *command, gchar **args)
|
||||||
{
|
{
|
||||||
@ -457,6 +481,10 @@ c_api_init(void)
|
|||||||
prof_chat_unset_incoming_char = c_api_chat_unset_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_set_outgoing_char = c_api_chat_set_outgoing_char;
|
||||||
prof_chat_unset_outgoing_char = c_api_chat_unset_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@ -101,3 +101,7 @@ 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_unset_incoming_char)(const char *barejid) = NULL;
|
||||||
int (*prof_chat_set_outgoing_char)(const char *barejid, const char *ch) = 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_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;
|
||||||
|
@ -113,5 +113,9 @@ int (*prof_chat_set_incoming_char)(const char *barejid, const char *ch);
|
|||||||
int (*prof_chat_unset_incoming_char)(const char *barejid);
|
int (*prof_chat_unset_incoming_char)(const char *barejid);
|
||||||
int (*prof_chat_set_outgoing_char)(const char *barejid, const char *ch);
|
int (*prof_chat_set_outgoing_char)(const char *barejid, const char *ch);
|
||||||
int (*prof_chat_unset_outgoing_char)(const char *barejid);
|
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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1190,6 +1190,100 @@ python_api_chat_unset_outgoing_char(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
python_command_callback(PluginCommand *command, gchar **args)
|
python_command_callback(PluginCommand *command, gchar **args)
|
||||||
{
|
{
|
||||||
@ -1305,6 +1399,10 @@ static PyMethodDef apiMethods[] = {
|
|||||||
{ "chat_unset_incoming_char", python_api_chat_unset_incoming_char, METH_VARARGS, "Reset 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_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" },
|
{ "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" },
|
||||||
{ NULL, NULL, 0, NULL }
|
{ NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -479,18 +479,23 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
|
|||||||
ProfWin *window = (ProfWin*)mucwin;
|
ProfWin *window = (ProfWin*)mucwin;
|
||||||
char *mynick = muc_nick(mucwin->roomjid);
|
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_strcmp0(nick, mynick) != 0) {
|
||||||
if (g_slist_length(mentions) > 0) {
|
if (g_slist_length(mentions) > 0) {
|
||||||
win_print(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMMENTION, nick, "");
|
win_print(window, ch, 0, NULL, NO_ME | NO_EOL, THEME_ROOMMENTION, nick, "");
|
||||||
_mucwin_print_mention(window, message, mynick, mentions);
|
_mucwin_print_mention(window, message, mynick, mentions);
|
||||||
} else if (triggers) {
|
} else if (triggers) {
|
||||||
win_print(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMTRIGGER, nick, "");
|
win_print(window, ch, 0, NULL, NO_ME | NO_EOL, THEME_ROOMTRIGGER, nick, "");
|
||||||
_mucwin_print_triggers(window, message, triggers);
|
_mucwin_print_triggers(window, message, triggers);
|
||||||
} else {
|
} else {
|
||||||
win_print(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message);
|
win_print(window, ch, 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
win_print(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message);
|
win_print(window, ch, 0, NULL, 0, THEME_TEXT_ME, nick, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -861,3 +866,39 @@ mucwin_get_string(ProfMucWin *mucwin)
|
|||||||
|
|
||||||
return resstr;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -61,6 +61,7 @@ static void _title_bar_draw(void);
|
|||||||
static void _show_self_presence(void);
|
static void _show_self_presence(void);
|
||||||
static void _show_contact_presence(ProfChatWin *chatwin);
|
static void _show_contact_presence(ProfChatWin *chatwin);
|
||||||
static void _show_privacy(ProfChatWin *chatwin);
|
static void _show_privacy(ProfChatWin *chatwin);
|
||||||
|
static void _show_muc_privacy(ProfMucWin *mucwin);
|
||||||
|
|
||||||
void
|
void
|
||||||
create_title_bar(void)
|
create_title_bar(void)
|
||||||
@ -195,6 +196,10 @@ _title_bar_draw(void)
|
|||||||
if (typing) {
|
if (typing) {
|
||||||
wprintw(win, " (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();
|
_show_self_presence();
|
||||||
@ -303,6 +308,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
|
static void
|
||||||
_show_privacy(ProfChatWin *chatwin)
|
_show_privacy(ProfChatWin *chatwin)
|
||||||
{
|
{
|
||||||
|
@ -199,6 +199,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_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);
|
void mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error);
|
||||||
char* mucwin_get_string(ProfMucWin *mucwin);
|
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
|
// MUC private chat window
|
||||||
void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp);
|
void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp);
|
||||||
|
@ -168,6 +168,8 @@ typedef struct prof_muc_win_t {
|
|||||||
gboolean unread_triggers;
|
gboolean unread_triggers;
|
||||||
gboolean showjid;
|
gboolean showjid;
|
||||||
unsigned long memcheck;
|
unsigned long memcheck;
|
||||||
|
char *enctext;
|
||||||
|
char *message_char;
|
||||||
} ProfMucWin;
|
} ProfMucWin;
|
||||||
|
|
||||||
typedef struct prof_mucconf_win_t {
|
typedef struct prof_mucconf_win_t {
|
||||||
|
@ -191,6 +191,8 @@ win_create_muc(const char *const roomjid)
|
|||||||
} else {
|
} else {
|
||||||
new_win->showjid = FALSE;
|
new_win->showjid = FALSE;
|
||||||
}
|
}
|
||||||
|
new_win->enctext = NULL;
|
||||||
|
new_win->message_char = NULL;
|
||||||
|
|
||||||
new_win->memcheck = PROFMUCWIN_MEMCHECK;
|
new_win->memcheck = PROFMUCWIN_MEMCHECK;
|
||||||
|
|
||||||
@ -440,6 +442,8 @@ win_free(ProfWin* window)
|
|||||||
{
|
{
|
||||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||||
free(mucwin->roomjid);
|
free(mucwin->roomjid);
|
||||||
|
free(mucwin->enctext);
|
||||||
|
free(mucwin->message_char);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WIN_MUC_CONFIG:
|
case WIN_MUC_CONFIG:
|
||||||
|
@ -230,6 +230,11 @@ void mucwin_occupant_presence(ProfMucWin *mucwin, const char * const nick, const
|
|||||||
void mucwin_update_occupants(ProfMucWin *mucwin) {}
|
void mucwin_update_occupants(ProfMucWin *mucwin) {}
|
||||||
void mucwin_show_occupants(ProfMucWin *mucwin) {}
|
void mucwin_show_occupants(ProfMucWin *mucwin) {}
|
||||||
void mucwin_hide_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_show_roster(void) {}
|
||||||
void ui_hide_roster(void) {}
|
void ui_hide_roster(void) {}
|
||||||
void ui_roster_add(const char * const barejid, const char * const name) {}
|
void ui_roster_add(const char * const barejid, const char * const name) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user