mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into osx-functional
This commit is contained in:
commit
1db956ae7c
3
.gitignore
vendored
3
.gitignore
vendored
@ -63,3 +63,6 @@ toc_fragment.html
|
||||
|
||||
# valgrind files
|
||||
valgrind.out
|
||||
|
||||
.DS_Store
|
||||
apidocs/c/html/
|
||||
|
@ -1,7 +1,7 @@
|
||||
0.5.0
|
||||
=====
|
||||
|
||||
- Build against libmesode if available
|
||||
- Plugins API supporting C and Python plugins
|
||||
- SSL certificate verification (requires libmesode) (/tls)
|
||||
- Allow auto extended away (/autoaway)
|
||||
- Include last acitvity in initial presence (xep-0256) (/lastactivity)
|
||||
|
2406
apidocs/c/c-prof.conf
Normal file
2406
apidocs/c/c-prof.conf
Normal file
File diff suppressed because it is too large
Load Diff
1
apidocs/c/gen.sh
Executable file
1
apidocs/c/gen.sh
Executable file
@ -0,0 +1 @@
|
||||
rm -rf html && doxygen c-prof.conf && open html/index.html
|
180
apidocs/c/profapi.h
Normal file
180
apidocs/c/profapi.h
Normal file
@ -0,0 +1,180 @@
|
||||
/** @file
|
||||
C plugin API.
|
||||
*/
|
||||
|
||||
/** \mainpage C Plugins API and Hooks
|
||||
List of all API function available to plugins: {@link profapi.h}
|
||||
|
||||
List of all hooks which plugins may implement: {@link profhooks.h}
|
||||
*/
|
||||
|
||||
/** Type representing a window, used for referencing windows created by the plugin */
|
||||
typedef char* PROF_WIN_TAG;
|
||||
|
||||
/** Type representing a function pointer to a command callback
|
||||
@param args The arguments passed to the callback
|
||||
*/
|
||||
typedef void(*CMD_CB)(char **args);
|
||||
|
||||
/** Type representing a function pointer to a timed callback
|
||||
*/
|
||||
typedef void(*TIMED_CB)(void);
|
||||
|
||||
/** Type representing a function pointer to a window callback
|
||||
*/
|
||||
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.
|
||||
@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
|
||||
@param group The group name in the themes file, or NULL
|
||||
@param item The item name within the group, or NULL
|
||||
@param def A default colour if the theme cannot be found, or NULL
|
||||
@param message the message to print
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_cons_show_themed(const char *const group, const char *const item, const char *const def, const char *const message);
|
||||
|
||||
/**
|
||||
Show a message in the console when invalid arguments have been passed to a command.
|
||||
@param cmd The name of the command, including the leading /
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_cons_bad_cmd_usage(const char *const cmd);
|
||||
|
||||
/**
|
||||
Register a plugin command.
|
||||
@param command_name The name of the command, including the leading /
|
||||
@param min_args Minimum arguments valid for the command
|
||||
@param max_args Maximum arguments valid for the command
|
||||
@param synopsis Overview of the command usage
|
||||
@param description A text description of the command
|
||||
@param arguments Description of all arguments
|
||||
@param examples Example command usages
|
||||
@param callback The {@link CMD_CB} function to execute when the command is invoked
|
||||
*/
|
||||
void prof_register_command(const char *command_name, int min_args, int max_args,
|
||||
const char **synopsis, const char *description, const char *arguments[][2], const char **examples,
|
||||
CMD_CB callback);
|
||||
|
||||
/**
|
||||
Register a timed callback function
|
||||
@param callback The {@link TIMED_CB} function to execute
|
||||
@param interval_seconds The interval for calling the function
|
||||
*/
|
||||
void prof_register_timed(TIMED_CB callback, int interval_seconds);
|
||||
|
||||
/**
|
||||
Register an autocompleter.
|
||||
Note that calling this function more than once will add the items to the autocompleter
|
||||
@param key The string used to initiate autocompletion
|
||||
@param items The to autocomplete with
|
||||
*/
|
||||
void prof_register_ac(const char *key, char **items);
|
||||
|
||||
/**
|
||||
Send a desktop notification.
|
||||
@param message The message to show in the notification
|
||||
@param timeout_ms Time in milliseconds until the notification disappears
|
||||
@param category Used as a notification category of the system supports it
|
||||
*/
|
||||
void prof_notify(const char *message, int timeout_ms, const char *category);
|
||||
|
||||
/**
|
||||
Send input to Profanity, equivalent to if the user had entered it.
|
||||
@param line The input to send.
|
||||
*/
|
||||
void prof_send_line(char *line);
|
||||
|
||||
/**
|
||||
Get the current recipient if in a chat window.
|
||||
@return The JID of the recipient, or NULL if not in a chat window
|
||||
*/
|
||||
char* prof_get_current_recipient(void);
|
||||
|
||||
/**
|
||||
Get the current room if in a MUC window.
|
||||
@return The JID of the room, or NULL if not in a MUC window
|
||||
*/
|
||||
char* prof_get_current_muc(void);
|
||||
|
||||
/**
|
||||
Determines if the current window is the console.
|
||||
@return 1 if in the console, 0 otherwise
|
||||
*/
|
||||
int prof_current_win_is_console(void);
|
||||
|
||||
/**
|
||||
Log a DEBUG message to the profanity log
|
||||
@param message The message to log
|
||||
*/
|
||||
void prof_log_debug(const char *message);
|
||||
|
||||
/**
|
||||
Log a INFO message to the profanity log
|
||||
@param message The message to log
|
||||
*/
|
||||
void prof_log_info(const char *message);
|
||||
|
||||
/**
|
||||
Log a WARNING message to the profanity log
|
||||
@param message The message to log
|
||||
*/
|
||||
void prof_log_warning(const char *message);
|
||||
|
||||
/**
|
||||
Log a ERROR message to the profanity log
|
||||
@param message The message to log
|
||||
*/
|
||||
void prof_log_error(const char *message);
|
||||
|
||||
/**
|
||||
Determine if window exist with PROF_WIN_TAG
|
||||
@param win The {@link PROF_WIN_TAG} to check
|
||||
@return 1 if the window exists, 0 otherwise
|
||||
*/
|
||||
int prof_win_exists(PROF_WIN_TAG win);
|
||||
|
||||
/**
|
||||
Create a new window
|
||||
@param win The {@link PROF_WIN_TAG} for the window
|
||||
@param input_handler The WINDOW_CB function to call when input is received for that window
|
||||
*/
|
||||
void prof_win_create(PROF_WIN_TAG win, WINDOW_CB input_handler);
|
||||
|
||||
/**
|
||||
Focus a window
|
||||
@param win The {@link PROF_WIN_TAG} of the window to focus
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_win_focus(PROF_WIN_TAG win);
|
||||
|
||||
/**
|
||||
Show a line in a window
|
||||
@param win The {@link PROF_WIN_TAG} of the window
|
||||
@param line The line to print
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_win_show(PROF_WIN_TAG win, char *line);
|
||||
|
||||
/**
|
||||
Show a message in a window, using the specified theme.
|
||||
Themes can be must be specified in ~/.local/share/profanity/plugin_themes
|
||||
@param win The {@link PROF_WIN_TAG} to print to
|
||||
@param group The group name in the themes file, or NULL
|
||||
@param item The item name within the group, or NULL
|
||||
@param def A default colour if the theme cannot be found, or NULL
|
||||
@param message the message to print
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_win_show_themed(PROF_WIN_TAG tag, char *group, char *key, char *def, char *line);
|
130
apidocs/c/profhooks.h
Normal file
130
apidocs/c/profhooks.h
Normal file
@ -0,0 +1,130 @@
|
||||
/** @file
|
||||
C Hooks.
|
||||
*/
|
||||
|
||||
/**
|
||||
Called when profanity loads the plugin
|
||||
@param version The version of profanity as a string e.g. "0.5.0"
|
||||
@param status The build status, either "development" or "release"
|
||||
*/
|
||||
void prof_init(const char * const version, const char * const status);
|
||||
|
||||
/**
|
||||
Called when profanity starts, after {@link prof_init}
|
||||
*/
|
||||
void prof_on_start(void);
|
||||
|
||||
/**
|
||||
Called when profanity shuts down
|
||||
*/
|
||||
void prof_on_shutdown(void);
|
||||
|
||||
/**
|
||||
Called when an account is connected
|
||||
@param account_name The name of the account
|
||||
@param fulljid The full JID of the account
|
||||
*/
|
||||
void prof_on_connect(const char * const account_name, const char * const fulljid);
|
||||
|
||||
/**
|
||||
Called when an account is disconnected
|
||||
@param account_name The name of the account
|
||||
@param fulljid The full JID of the account
|
||||
*/
|
||||
void prof_on_disconnect(const char * const account_name, const char * const fulljid);
|
||||
|
||||
/**
|
||||
Called before a regular chat message is displayed
|
||||
@param jid The JID of the sender
|
||||
@param message The message received
|
||||
@return The new message, or NULL if no change made to the message
|
||||
*/
|
||||
char* prof_pre_chat_message_display(const char * const jid, const char *message);
|
||||
|
||||
/**
|
||||
Called after a regular chat message is displayed
|
||||
@param jid The JID of the sender
|
||||
@param message The message received
|
||||
*/
|
||||
void prof_post_chat_message_display(const char * const jid, const char *message);
|
||||
|
||||
/**
|
||||
Called before a regular chat message is sent
|
||||
@param jid The JID of the recipient
|
||||
@param message The message to send
|
||||
@return The new message, or NULL if no change made to the message
|
||||
*/
|
||||
char* prof_pre_chat_message_send(const char * const jid, const char *message);
|
||||
|
||||
/**
|
||||
Called after a regular chat message is sent
|
||||
@param jid The JID of the recipient
|
||||
@param message The message sent
|
||||
*/
|
||||
void prof_post_chat_message_send(const char * const jid, const char *message);
|
||||
|
||||
/**
|
||||
Called before a MUC message is displayed
|
||||
@param room The JID of the room
|
||||
@param nick The nickname of the sender
|
||||
@param message The message received
|
||||
@return The new message, or NULL if no change made to the message
|
||||
*/
|
||||
char* prof_pre_room_message_display(const char * const room, const char * const nick, const char *message);
|
||||
|
||||
/**
|
||||
Called after a MUC message is displayed
|
||||
@param room The JID of the room
|
||||
@param nick The nickname of the sender
|
||||
@param message The message received
|
||||
*/
|
||||
void prof_post_room_message_display(const char * const room, const char * const nick, const char *message);
|
||||
|
||||
/**
|
||||
Called before a MUC message is sent
|
||||
@param room The JID of the room
|
||||
@param message The message to send
|
||||
@return The new message, or NULL if no change made to the message
|
||||
*/
|
||||
char* prof_pre_room_message_send(const char * const room, const char *message);
|
||||
|
||||
/**
|
||||
Called after a MUC message is sent
|
||||
@param room The JID of the room
|
||||
@param message The message sent
|
||||
*/
|
||||
void prof_post_room_message_send(const char * const room, const char *message);
|
||||
|
||||
/**
|
||||
Called before a MUC private message is displayed
|
||||
@param room The JID of the room
|
||||
@param nick The nickname of the sender
|
||||
@param message The message received
|
||||
@return The new message, or NULL if no change made to the message
|
||||
*/
|
||||
char* prof_pre_priv_message_display(const char * const room, const char * const nick, const char *message);
|
||||
|
||||
/**
|
||||
Called after a MUC private message is displayed
|
||||
@param room The JID of the room
|
||||
@param nick The nickname of the sender
|
||||
@param message The message received
|
||||
*/
|
||||
void prof_post_priv_message_display(const char * const room, const char * const nick, const char *message);
|
||||
|
||||
/**
|
||||
Called before a MUC private message is sent
|
||||
@param room The JID of the room
|
||||
@param nick The nickname of the recipient
|
||||
@param message The message to send
|
||||
@return The new message, or NULL if no change made to the message
|
||||
*/
|
||||
char* prof_pre_priv_message_send(const char * const room, const char * const nick, const char *message);
|
||||
|
||||
/**
|
||||
Called after a MUC private message is sent
|
||||
@param room The JID of the room
|
||||
@param nick The nickname of the recipient
|
||||
@param message The message sent
|
||||
*/
|
||||
void prof_post_priv_message_send(const char * const room, const char * const nick, const char *message);
|
@ -349,7 +349,7 @@ sv_ev_delayed_private_message(const char *const fulljid, char *message, GDateTim
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_outgoing_carbon(char *barejid, char *message)
|
||||
sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message)
|
||||
{
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (!chatwin) {
|
||||
@ -358,22 +358,20 @@ sv_ev_outgoing_carbon(char *barejid, char *message)
|
||||
|
||||
chat_state_active(chatwin->state);
|
||||
|
||||
chatwin_outgoing_carbon(chatwin, message);
|
||||
#ifdef PROF_HAVE_LIBGPGME
|
||||
if (pgp_message) {
|
||||
char *decrypted = p_gpg_decrypt(pgp_message);
|
||||
if (decrypted) {
|
||||
chatwin_outgoing_carbon(chatwin, decrypted, PROF_MSG_PGP);
|
||||
} else {
|
||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN);
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_incoming_carbon(char *barejid, char *resource, char *message)
|
||||
{
|
||||
gboolean new_win = FALSE;
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (!chatwin) {
|
||||
ProfWin *window = wins_new_chat(barejid);
|
||||
chatwin = (ProfChatWin*)window;
|
||||
new_win = TRUE;
|
||||
} else {
|
||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN);
|
||||
}
|
||||
|
||||
chatwin_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN);
|
||||
chat_log_msg_in(barejid, message, NULL);
|
||||
#else
|
||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PROF_HAVE_LIBGPGME
|
||||
@ -414,7 +412,6 @@ _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, char *barejid, char
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PROF_HAVE_LIBOTR
|
||||
static void
|
||||
_sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message, GDateTime *timestamp)
|
||||
{
|
||||
@ -422,7 +419,6 @@ _sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, char *barejid, cha
|
||||
chat_log_msg_in(barejid, message, timestamp);
|
||||
chatwin->pgp_recv = FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_message, GDateTime *timestamp)
|
||||
@ -484,6 +480,29 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_incoming_carbon(char *barejid, char *resource, char *message, char *pgp_message)
|
||||
{
|
||||
gboolean new_win = FALSE;
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (!chatwin) {
|
||||
ProfWin *window = wins_new_chat(barejid);
|
||||
chatwin = (ProfChatWin*)window;
|
||||
new_win = TRUE;
|
||||
}
|
||||
|
||||
#ifdef PROF_HAVE_LIBGPGME
|
||||
if (pgp_message) {
|
||||
_sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, NULL);
|
||||
} else {
|
||||
_sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, NULL);
|
||||
}
|
||||
#else
|
||||
_sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, NULL);
|
||||
#endif
|
||||
rosterwin_roster();
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_message_receipt(char *barejid, char *id)
|
||||
{
|
||||
|
@ -73,8 +73,8 @@ void sv_ev_room_occupent_kicked(const char *const room, const char *const nick,
|
||||
void sv_ev_room_banned(const char *const room, const char *const actor, const char *const reason);
|
||||
void sv_ev_room_occupent_banned(const char *const room, const char *const nick, const char *const actor,
|
||||
const char *const reason);
|
||||
void sv_ev_outgoing_carbon(char *barejid, char *message);
|
||||
void sv_ev_incoming_carbon(char *barejid, char *resource, char *message);
|
||||
void sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message);
|
||||
void sv_ev_incoming_carbon(char *barejid, char *resource, char *message, char *pgp_message);
|
||||
void sv_ev_xmpp_stanza(const char *const msg);
|
||||
void sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean config_required,
|
||||
const char *const role, const char *const affiliation, const char *const actor, const char *const reason,
|
||||
|
@ -312,11 +312,16 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
|
||||
}
|
||||
|
||||
void
|
||||
chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message)
|
||||
chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_enc_t enc_mode)
|
||||
{
|
||||
assert(chatwin != NULL);
|
||||
|
||||
win_print((ProfWin*)chatwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message);
|
||||
char enc_char = '-';
|
||||
if (enc_mode == PROF_MSG_PGP) {
|
||||
enc_char = prefs_get_pgp_char();
|
||||
}
|
||||
|
||||
win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message);
|
||||
int num = wins_get_num((ProfWin*)chatwin);
|
||||
status_bar_active(num);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ void chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, cons
|
||||
void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id);
|
||||
void chatwin_recipient_gone(ProfChatWin *chatwin);
|
||||
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode);
|
||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message);
|
||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_enc_t enc_mode);
|
||||
void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity);
|
||||
void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status);
|
||||
char* chatwin_get_string(ProfChatWin *chatwin);
|
||||
|
@ -191,8 +191,6 @@ message_send_chat_pgp(const char *const barejid, const char *const msg)
|
||||
stanza_attach_state(ctx, message, state);
|
||||
}
|
||||
|
||||
stanza_attach_carbons_private(ctx, message);
|
||||
|
||||
if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) {
|
||||
stanza_attach_receipt_request(ctx, message);
|
||||
}
|
||||
@ -714,17 +712,25 @@ _handle_carbons(xmpp_stanza_t *const stanza)
|
||||
// check for and deal with message
|
||||
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY);
|
||||
if (body) {
|
||||
char *message = xmpp_stanza_get_text(body);
|
||||
if (message) {
|
||||
char *message_txt = xmpp_stanza_get_text(body);
|
||||
if (message_txt) {
|
||||
// check for pgp encrypted message
|
||||
char *enc_message = NULL;
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(message, STANZA_NS_ENCRYPTED);
|
||||
if (x) {
|
||||
enc_message = xmpp_stanza_get_text(x);
|
||||
}
|
||||
|
||||
// if we are the recipient, treat as standard incoming message
|
||||
if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){
|
||||
sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message);
|
||||
}
|
||||
sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message_txt, enc_message);
|
||||
|
||||
// else treat as a sent message
|
||||
else{
|
||||
sv_ev_outgoing_carbon(jid_to->barejid, message);
|
||||
} else {
|
||||
sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message);
|
||||
}
|
||||
xmpp_free(ctx, message);
|
||||
xmpp_free(ctx, message_txt);
|
||||
xmpp_free(ctx, enc_message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ void ui_disconnected(void) {}
|
||||
void chatwin_recipient_gone(ProfChatWin *chatwin) {}
|
||||
|
||||
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode) {}
|
||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char * const message) {}
|
||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char * const message, prof_enc_t enc_mode) {}
|
||||
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {}
|
||||
|
||||
void privwin_occupant_offline(ProfPrivateWin *privwin) {}
|
||||
|
Loading…
Reference in New Issue
Block a user