Compare commits

..

4 Commits

Author SHA1 Message Date
130bb7d1a0 Buffer size reverted from debug value to current standard. Comments updated.
Some checks failed
CI Code / Check coding style (pull_request) Failing after 11m14s
CI Code / Linux (arch) (pull_request) Successful in 12m44s
CI Code / Check spelling (pull_request) Failing after 14m20s
CI Code / Linux (debian) (pull_request) Successful in 15m35s
CI Code / Linux (ubuntu) (pull_request) Successful in 1h20m31s
2025-10-28 08:17:06 +03:00
073ebfdb91 Added logic to manage unread message indicators and paging state in the UI window component.
Updated paged state handling to ensure accurate tracking of unread messages.

Issues: extra page down needed to clear paged state when at bottom of window with unread messages.
2025-10-22 13:33:28 +03:00
3cdd3846a8 Buffer handling changed while SCROLLING
Temporary test code, that prevents printing and buffer update when user is viewing message history
2025-10-14 17:07:56 +00:00
4ee10d4b21 Reduce buffer size to 20, add "deleting" to the log 2025-10-09 19:32:33 +02:00
23 changed files with 101 additions and 200 deletions

View File

@@ -1,9 +1,6 @@
FROM archlinux
RUN pacman -Syu --noconfirm
RUN pacman -S --needed --noconfirm reflector && reflector --latest 20 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
RUN pacman-key --init
RUN pacman -S --needed --noconfirm \
RUN pacman -Syu --noconfirm && pacman -S --needed --noconfirm \
autoconf \
autoconf-archive \
automake \
@@ -18,7 +15,7 @@ RUN pacman -S --needed --noconfirm \
gcc \
git \
gpgme \
gtk3 \
gtk2 \
libgcrypt \
libmicrohttpd \
libnotify \

View File

@@ -20,13 +20,13 @@
typedef char* PROF_WIN_TAG;
/** Function pointer for command callbacks, accepting an array of arguments. */
typedef void (*CMD_CB)(char** args);
typedef void(*CMD_CB)(char **args);
/** Function pointer for timed callbacks, accepting no arguments. */
typedef void (*TIMED_CB)(void);
typedef void(*TIMED_CB)(void);
/** Function pointer for window callbacks, accepting a window tag and input line. */
typedef void (*WINDOW_CB)(PROF_WIN_TAG win, char* line);
typedef void(*WINDOW_CB)(PROF_WIN_TAG win, char *line);
/** Highlights the console window in the status bar. */
void prof_cons_alert(void);
@@ -41,7 +41,7 @@ void prof_cons_alert(void);
* prof_cons_show("This will appear in the console window");
* @endcode
*/
int prof_cons_show(const char* const message);
int prof_cons_show(const char * const message);
/**
* Shows a message in the console with a specified theme.
@@ -57,7 +57,7 @@ int prof_cons_show(const char* const message);
* prof_cons_show_themed("myplugin", "text", NULL, "Plugin themed message");
* @endcode
*/
int prof_cons_show_themed(const char* const group, const char* const item, const char* const def, const char* const message);
int prof_cons_show_themed(const char *const group, const char *const item, const char *const def, const char *const message);
/**
* Shows a message indicating a command was used incorrectly.
@@ -69,7 +69,7 @@ int prof_cons_show_themed(const char* const group, const char* const item, const
* prof_cons_bad_cmd_usage("/mycommand");
* @endcode
*/
int prof_cons_bad_cmd_usage(const char* const cmd);
int prof_cons_bad_cmd_usage(const char *const cmd);
/**
* Registers a new command with help information and callback.
@@ -91,9 +91,9 @@ int prof_cons_bad_cmd_usage(const char* const cmd);
* prof_register_command("/newcommand", 1, 2, synopsis, "Example command", args, examples, my_function);
* @endcode
*/
void prof_register_command(const char* command_name, int min_args, int max_args,
char** synopsis, const char* description, char* arguments[][2], char** examples,
CMD_CB callback);
void prof_register_command(const char *command_name, int min_args, int max_args,
char **synopsis, const char *description, char *arguments[][2], char **examples,
CMD_CB callback);
/**
* Registers a function to be called periodically by CProof.
@@ -118,7 +118,7 @@ void prof_register_timed(TIMED_CB callback, int interval_seconds);
* prof_completer_add("/mycommand", items);
* @endcode
*/
void prof_completer_add(const char* key, char** items);
void prof_completer_add(const char *key, char **items);
/**
* Removes autocomplete values for a command or argument.
@@ -131,7 +131,7 @@ void prof_completer_add(const char* key, char** items);
* prof_completer_remove("/mycommand", items);
* @endcode
*/
void prof_completer_remove(const char* key, char** items);
void prof_completer_remove(const char *key, char **items);
/**
* Clears all autocomplete values for a command or argument.
@@ -142,7 +142,7 @@ void prof_completer_remove(const char* key, char** items);
* prof_completer_clear("/mycommand");
* @endcode
*/
void prof_completer_clear(const char* key);
void prof_completer_clear(const char *key);
/**
* Adds filepath autocompletion for a command or argument.
@@ -153,7 +153,7 @@ void prof_completer_clear(const char* key);
* prof_filepath_completer_add("/filecmd");
* @endcode
*/
void prof_filepath_completer_add(const char* prefix);
void prof_filepath_completer_add(const char *prefix);
/**
* Sends a desktop notification.
@@ -166,7 +166,7 @@ void prof_filepath_completer_add(const char* prefix);
* prof_notify("Example notification", 5000, "Example plugin");
* @endcode
*/
void prof_notify(const char* message, int timeout_ms, const char* category);
void prof_notify(const char *message, int timeout_ms, const char *category);
/**
* Sends a line of input to CProof to execute.
@@ -177,7 +177,7 @@ void prof_notify(const char* message, int timeout_ms, const char* category);
* prof_send_line("/who online");
* @endcode
*/
void prof_send_line(char* line);
void prof_send_line(char *line);
/**
* Gets the Jabber ID of the current chat recipient.
@@ -185,17 +185,6 @@ void prof_send_line(char* line);
*/
char* prof_get_current_recipient(void);
/**
* Gets the title of the current window as shown in the titlebar.
*
* Special cases:
* - MUC configuration window: Includes "config" and an asterisk if modified (e.g., "room@example.com config *").
* - vCard window: Includes the bare JID and an asterisk if modified (e.g., "vCard user@example.com *").
*
* @return A null-terminated string containing the window title. The caller must free the returned string.
*/
char* prof_get_current_window(void);
/**
* Gets the Jabber ID of the current chat room.
* @return The room Jabber ID (e.g., "metalchat@conference.example.com") or NULL if not in a room.
@@ -209,7 +198,7 @@ char* prof_get_current_muc(void);
int prof_current_win_is_console(void);
/**
* Gets the user's nickname in the current chat room.
* Gets the users nickname in the current chat room.
* @return The nickname (e.g., "eddie") or NULL if not in a room.
*/
char* prof_get_current_nick(void);
@@ -219,14 +208,14 @@ char* prof_get_current_nick(void);
* @param barejid The Jabber ID.
* @return The nickname (e.g., "eddie") or the barejid if not in the roster.
*/
char* prof_get_name_from_roster(const char* barejid);
char* prof_get_name_from_roster(const char *barejid);
/**
* Gets the barejid for a nickname from the roster.
* @param name The nickname.
* @return The barejid (e.g., "eddie@server.tld") or NULL if not in the roster.
*/
char* prof_get_barejid_from_roster(const char* name);
char* prof_get_barejid_from_roster(const char *name);
/**
* Gets nicknames of all occupants in the current chat room.
@@ -236,10 +225,10 @@ char** prof_get_current_occupants(void);
/**
* Gets the current nickname in a chat room.
* @param barejid The room's Jabber ID.
* @param barejid The rooms Jabber ID.
* @return The nickname.
*/
char* prof_get_room_nick(const char* barejid);
char* prof_get_room_nick(const char *barejid);
/**
* Logs a debug message to the CProof log.
@@ -250,7 +239,7 @@ char* prof_get_room_nick(const char* barejid);
* prof_log_debug("Debug message");
* @endcode
*/
void prof_log_debug(const char* message);
void prof_log_debug(const char *message);
/**
* Logs an info message to the CProof log.
@@ -261,7 +250,7 @@ void prof_log_debug(const char* message);
* prof_log_info("Info message");
* @endcode
*/
void prof_log_info(const char* message);
void prof_log_info(const char *message);
/**
* Logs a warning message to the CProof log.
@@ -272,7 +261,7 @@ void prof_log_info(const char* message);
* prof_log_warning("Warning message");
* @endcode
*/
void prof_log_warning(const char* message);
void prof_log_warning(const char *message);
/**
* Logs an error message to the CProof log.
@@ -283,7 +272,7 @@ void prof_log_warning(const char* message);
* prof_log_error("Error message");
* @endcode
*/
void prof_log_error(const char* message);
void prof_log_error(const char *message);
/**
* Creates a plugin window.
@@ -332,7 +321,7 @@ int prof_win_focus(PROF_WIN_TAG win);
* prof_win_show("My Plugin", "Message in plugin window");
* @endcode
*/
int prof_win_show(PROF_WIN_TAG win, char* message);
int prof_win_show(PROF_WIN_TAG win, char *message);
/**
* Shows a message in a plugin window with a specified theme.
@@ -349,7 +338,7 @@ int prof_win_show(PROF_WIN_TAG win, char* message);
* prof_win_show_themed("My Plugin", "myplugin", "text", NULL, "Themed message");
* @endcode
*/
int prof_win_show_themed(PROF_WIN_TAG tag, char* group, char* key, char* def, char* message);
int prof_win_show_themed(PROF_WIN_TAG tag, char *group, char *key, char *def, char *message);
/**
* Sends an XMPP stanza.
@@ -361,7 +350,7 @@ int prof_win_show_themed(PROF_WIN_TAG tag, char* group, char* key, char* def, ch
* prof_send_stanza("<iq to='juliet@capulet.lit' id='s2c1' type='get'><ping xmlns='urn:xmpp:ping'/></iq>");
* @endcode
*/
int prof_send_stanza(char* stanza);
int prof_send_stanza(char *stanza);
/**
* Gets a boolean setting.
@@ -376,7 +365,7 @@ int prof_send_stanza(char* stanza);
* prof_settings_boolean_get("myplugin", "notify", 0);
* @endcode
*/
int prof_settings_boolean_get(char* group, char* key, int def);
int prof_settings_boolean_get(char *group, char *key, int def);
/**
* Sets a boolean setting.
@@ -390,7 +379,7 @@ int prof_settings_boolean_get(char* group, char* key, int def);
* prof_settings_boolean_set("myplugin", "activate", 1);
* @endcode
*/
void prof_settings_boolean_set(char* group, char* key, int value);
void prof_settings_boolean_set(char *group, char *key, int value);
/**
* Gets a string setting.
@@ -405,7 +394,7 @@ void prof_settings_boolean_set(char* group, char* key, int value);
* prof_settings_string_get("myplugin", "prefix", "prefix-->");
* @endcode
*/
char* prof_settings_string_get(char* group, char* key, char* def);
char* prof_settings_string_get(char *group, char *key, char *def);
/**
* Sets a string setting.
@@ -419,7 +408,7 @@ char* prof_settings_string_get(char* group, char* key, char* def);
* prof_settings_string_set("myplugin", "prefix", "myplugin, ");
* @endcode
*/
void prof_settings_string_set(char* group, char* key, char* value);
void prof_settings_string_set(char *group, char *key, char *value);
/**
* Gets a string list setting, separated by semicolons.
@@ -433,7 +422,7 @@ void prof_settings_string_set(char* group, char* key, char* value);
* prof_settings_string_list_get("myplugin", "somelist");
* @endcode
*/
char** prof_settings_string_list_get(char* group, char* key);
char** prof_settings_string_list_get(char *group, char *key);
/**
* Adds an item to a string list setting.
@@ -448,7 +437,7 @@ char** prof_settings_string_list_get(char* group, char* key);
* prof_settings_string_list_add("myplugin", "somelist", "anelement");
* @endcode
*/
void prof_settings_string_list_add(char* group, char* key, char* value);
void prof_settings_string_list_add(char *group, char *key, char *value);
/**
* Removes an item from a string list setting.
@@ -463,7 +452,7 @@ void prof_settings_string_list_add(char* group, char* key, char* value);
* prof_settings_string_list_remove("myplugin", "somelist", "anelement");
* @endcode
*/
int prof_settings_string_list_remove(char* group, char* key, char* value);
int prof_settings_string_list_remove(char *group, char *key, char *value);
/**
* Clears all items from a string list setting.
@@ -477,7 +466,7 @@ int prof_settings_string_list_remove(char* group, char* key, char* value);
* prof_settings_string_list_clear("myplugin", "somelist");
* @endcode
*/
int prof_settings_string_list_clear(char* group, char* key);
int prof_settings_string_list_clear(char *group, char *key);
/**
* Gets an integer setting.
@@ -492,7 +481,7 @@ int prof_settings_string_list_clear(char* group, char* key);
* prof_settings_int_get("myplugin", "timeout", 10);
* @endcode
*/
int prof_settings_int_get(char* group, char* key, int def);
int prof_settings_int_get(char *group, char *key, int def);
/**
* Sets an integer setting.
@@ -506,7 +495,7 @@ int prof_settings_int_get(char* group, char* key, int def);
* prof_settings_int_set("myplugin", "timeout", 100);
* @endcode
*/
void prof_settings_int_set(char* group, char* key, int value);
void prof_settings_int_set(char *group, char *key, int value);
/**
* Triggers handling of an incoming message as if received by CProof.
@@ -519,10 +508,10 @@ void prof_settings_int_set(char* group, char* key, int value);
* prof_incoming_message("bob@server.org", "laptop", "Hello there");
* @endcode
*/
void prof_incoming_message(char* barejid, char* resource, char* message);
void prof_incoming_message(char *barejid, char *resource, char *message);
/**
* Adds a service discovery feature to CProof's supported features.
* Adds a service discovery feature to CProofs supported features.
* Sends a presence update if a session is connected.
* @param feature The feature to add.
*
@@ -531,7 +520,7 @@ void prof_incoming_message(char* barejid, char* resource, char* message);
* prof_disco_add_feature("urn:xmpp:omemo:0:devicelist+notify");
* @endcode
*/
void prof_disco_add_feature(char* feature);
void prof_disco_add_feature(char *feature);
/**
* Ends an encrypted session with a user.
@@ -542,7 +531,7 @@ void prof_disco_add_feature(char* feature);
* prof_encryption_reset("alice@server.org");
* @endcode
*/
void prof_encryption_reset(char* barejid);
void prof_encryption_reset(char *barejid);
/**
* Sets the titlebar encryption indicator text for a recipient.
@@ -555,10 +544,10 @@ void prof_encryption_reset(char* barejid);
* prof_chat_set_titlebar_enctext("bob@example.com", "safe");
* @endcode
*/
int prof_chat_set_titlebar_enctext(char* barejid, char* enctext);
int prof_chat_set_titlebar_enctext(char *barejid, char *enctext);
/**
* Resets the titlebar encryption indicator for a recipient to CProof's default.
* Resets the titlebar encryption indicator for a recipient to CProofs default.
* @param barejid Jabber ID of the recipient.
* @return 1 on success, 0 on failure.
*
@@ -567,7 +556,7 @@ int prof_chat_set_titlebar_enctext(char* barejid, char* enctext);
* prof_chat_unset_titlebar_enctext("bob@example.com");
* @endcode
*/
int prof_chat_unset_titlebar_enctext(char* barejid);
int prof_chat_unset_titlebar_enctext(char *barejid);
/**
* Sets the incoming message prefix character for a contact.
@@ -580,7 +569,7 @@ int prof_chat_unset_titlebar_enctext(char* barejid);
* prof_chat_set_incoming_char("kristine@example.com", "*");
* @endcode
*/
int prof_chat_set_incoming_char(char* barejid, char* ch);
int prof_chat_set_incoming_char(char *barejid, char *ch);
/**
* Resets the incoming message prefix character for a contact.
@@ -592,7 +581,7 @@ int prof_chat_set_incoming_char(char* barejid, char* ch);
* prof_chat_unset_incoming_char("kristine@example.com");
* @endcode
*/
int prof_chat_unset_incoming_char(char* barejid);
int prof_chat_unset_incoming_char(char *barejid);
/**
* Sets the outgoing message prefix character for a contact.
@@ -605,7 +594,7 @@ int prof_chat_unset_incoming_char(char* barejid);
* prof_chat_set_outgoing_char("david@example.com", "+");
* @endcode
*/
int prof_chat_set_outgoing_char(char* barejid, char* ch);
int prof_chat_set_outgoing_char(char *barejid, char *ch);
/**
* Resets the outgoing message prefix character for a contact.
@@ -617,7 +606,7 @@ int prof_chat_set_outgoing_char(char* barejid, char* ch);
* prof_chat_unset_outgoing_char("david@example.com");
* @endcode
*/
int prof_chat_unset_outgoing_char(char* barejid);
int prof_chat_unset_outgoing_char(char *barejid);
/**
* Sets the titlebar encryption indicator text for a room.
@@ -630,10 +619,10 @@ int prof_chat_unset_outgoing_char(char* barejid);
* prof_room_set_titlebar_enctext("generalchat@conference.service.com", "secret");
* @endcode
*/
int prof_room_set_titlebar_enctext(char* roomjid, char* enctext);
int prof_room_set_titlebar_enctext(char *roomjid, char *enctext);
/**
* Resets the titlebar encryption indicator for a room to CProof's default.
* Resets the titlebar encryption indicator for a room to CProofs default.
* @param roomjid Jabber ID of the room.
* @return 1 on success, 0 on failure.
*
@@ -642,7 +631,7 @@ int prof_room_set_titlebar_enctext(char* roomjid, char* enctext);
* prof_room_unset_titlebar_enctext("generalchat@conference.service.com");
* @endcode
*/
int prof_room_unset_titlebar_enctext(char* roomjid);
int prof_room_unset_titlebar_enctext(char *roomjid);
/**
* Sets the message prefix character for a room.
@@ -655,7 +644,7 @@ int prof_room_unset_titlebar_enctext(char* roomjid);
* prof_room_set_message_char("ohnoes@conference.example.com", "^");
* @endcode
*/
int prof_room_set_message_char(char* roomjid, char* ch);
int prof_room_set_message_char(char *roomjid, char *ch);
/**
* Resets the message prefix character for a room.
@@ -667,7 +656,7 @@ int prof_room_set_message_char(char* roomjid, char* ch);
* prof_room_unset_message_char("ohnoes@conference.example.com");
* @endcode
*/
int prof_room_unset_message_char(char* roomjid);
int prof_room_unset_message_char(char *roomjid);
/**
* Shows a message in a chat window.
@@ -680,7 +669,7 @@ int prof_room_unset_message_char(char* roomjid);
* prof_chat_show("bob@server.org", "From a plugin in the chat window");
* @endcode
*/
int prof_chat_show(char* barejid, char* message);
int prof_chat_show(char *barejid, char *message);
/**
* Shows a message in a chat window with a theme and prefix character.
@@ -698,7 +687,7 @@ int prof_chat_show(char* barejid, char* message);
* prof_chat_show_themed("bob@server.org", "myplugin", "text", NULL, "!", "Themed message");
* @endcode
*/
int prof_chat_show_themed(char* barejid, char* group, char* item, char* def, char* ch, char* message);
int prof_chat_show_themed(char *barejid, char *group, char *item, char *def, char *ch, char *message);
/**
* Shows a message in a chat room window.
@@ -711,7 +700,7 @@ int prof_chat_show_themed(char* barejid, char* group, char* item, char* def, cha
* prof_room_show("chat@conference.example.com", "From a plugin in the chat room");
* @endcode
*/
int prof_room_show(char* roomjid, char* message);
int prof_room_show(char *roomjid, char *message);
/**
* Shows a message in a chat room window with a theme and prefix character.
@@ -729,4 +718,4 @@ int prof_room_show(char* roomjid, char* message);
* prof_room_show_themed("chat@conference.example.com", "myplugin", "text", NULL, "!", "Themed message");
* @endcode
*/
int prof_room_show_themed(char* roomjid, char* group, char* item, char* def, char* ch, char* message);
int prof_room_show_themed(char *roomjid, char *group, char *item, char *def, char *ch, char *message);

View File

@@ -830,22 +830,6 @@ def get_current_recipient() -> str | None:
"""
pass
def get_current_window() -> str:
"""Retrieves the title of the current window as shown in the titlebar.
Returns the title of the currently active window, matching the titlebar display.
Special cases:
- For MUC configuration windows, includes "config" and an asterisk if modified (e.g., "room@example.com config \*").
- For vCard windows, includes the bare JID and an asterisk if modified (e.g., "vCard user@example.com \*").
:return: The window title as a string.
Example::
title = prof.get_current_window()
prof.cons_show(f"Current window: {title}")
"""
def get_current_muc() -> str | None:
"""Retrieves the Jabber ID of the current chat room.

View File

@@ -139,9 +139,8 @@ static const struct cmd_t command_defs[] = {
"Show version and license information.")
},
// Max args: account + server <s> + port <p> + tls <t> + auth <a> = 9
{ CMD_PREAMBLE("/connect",
parse_args, 0, 9, NULL)
parse_args, 0, 7, NULL)
CMD_MAINFUNC(cmd_connect)
CMD_TAGS(
CMD_TAG_CONNECTION)
@@ -1903,9 +1902,9 @@ static const struct cmd_t command_defs[] = {
CMD_ARGS(
{ "where", "Show the current log file location." },
{ "rotate on|off", "Rotate log, default on. Does not take effect if you specified a filename yourself when starting Profanity." },
{ "maxsize <bytes>", "With rotate enabled, specifies the max log size, defaults to 10485760 (10MiB)." },
{ "maxsize <bytes>", "With rotate enabled, specifies the max log size, defaults to 10485760 (10MB)." },
{ "shared on|off", "Share logs between all instances, default: on. When off, the process id will be included in the log filename. Does not take effect if you specified a filename yourself when starting Profanity." },
{ "level INFO|DEBUG|WARN|ERROR", "Set the log level. Default is INFO." })
{"level INFO|DEBUG|WARN|ERROR", "Set the log level. Default is INFO. Only works with default log file, not with user provided log file during startup via -f." })
},
{ CMD_PREAMBLE("/carbons",

View File

@@ -5356,8 +5356,6 @@ cmd_time(ProfWin* window, const char* const command, gchar** args)
cons_bad_cmd_usage(command);
return TRUE;
}
if (!set_all)
break;
}
if (!set_all && n == ARRAY_SIZE(time_prefs)) {
cons_bad_cmd_usage(command);
@@ -6273,11 +6271,10 @@ cmd_log(ProfWin* window, const char* const command, gchar** args)
if (strcmp(subcmd, "level") == 0) {
log_level_t prof_log_level;
if (log_level_from_string(value, &prof_log_level) == 0) {
auto_char char* log_file = strdup(get_log_file_location());
log_close();
log_init(prof_log_level, log_file);
log_init(prof_log_level, NULL);
cons_show("Log level changed to: %s (log file: %s).", value, log_file ? log_file : "[default]");
cons_show("Log level changed to: %s.", value);
return TRUE;
}
}

View File

@@ -186,7 +186,7 @@ log_error(const char* const msg, ...)
}
void
log_init(log_level_t filter, const char* const log_file)
log_init(log_level_t filter, char* log_file)
{
level_filter = filter;

View File

@@ -50,7 +50,7 @@ typedef enum {
PROF_LEVEL_ERROR
} log_level_t;
void log_init(log_level_t filter, const char* const log_file);
void log_init(log_level_t filter, char* log_file);
log_level_t log_get_filter(void);
void log_close(void);
const gchar* get_log_file_location(void);

View File

@@ -54,7 +54,6 @@
#include "plugins/settings.h"
#include "plugins/disco.h"
#include "ui/ui.h"
#include "ui/win_types.h"
#include "ui/window_list.h"
#include "xmpp/roster_list.h"
@@ -206,13 +205,6 @@ api_get_current_recipient(void)
}
}
gchar*
api_get_current_window(void)
{
ProfWin* current = wins_get_current();
return win_get_title(current);
}
char*
api_get_current_muc(void)
{

View File

@@ -46,7 +46,6 @@ void api_notify(const char* message, const char* category, int timeout_ms);
void api_send_line(char* line);
char* api_get_current_recipient(void);
gchar* api_get_current_window(void);
char* api_get_current_muc(void);
gboolean api_current_win_is_console(void);
char* api_get_current_nick(void);

View File

@@ -165,12 +165,6 @@ c_api_get_current_recipient(void)
return api_get_current_recipient();
}
static char*
c_api_get_current_window(void)
{
return api_get_current_window();
}
static char*
c_api_get_current_muc(void)
{
@@ -483,7 +477,6 @@ c_api_init(void)
prof_notify = c_api_notify;
prof_send_line = c_api_send_line;
prof_get_current_recipient = c_api_get_current_recipient;
prof_get_current_window = c_api_get_current_window;
prof_get_current_muc = c_api_get_current_muc;
prof_current_win_is_console = c_api_current_win_is_console;
prof_get_current_nick = c_api_get_current_nick;

View File

@@ -62,7 +62,6 @@ void (*prof_notify)(const char* message, int timeout_ms, const char* category) =
void (*prof_send_line)(char* line) = NULL;
char* (*prof_get_current_recipient)(void) = NULL;
char* (*prof_get_current_window)(void) = NULL;
char* (*prof_get_current_muc)(void) = NULL;
int (*prof_current_win_is_console)(void) = NULL;
char* (*prof_get_current_nick)(void) = NULL;

View File

@@ -71,7 +71,6 @@ void (*prof_notify)(const char* message, int timeout_ms, const char* category);
void (*prof_send_line)(char* line);
char* (*prof_get_current_recipient)(void);
char* (*prof_get_current_window)(void);
char* (*prof_get_current_muc)(void);
int (*prof_current_win_is_console)(void);
char* (*prof_get_current_nick)(void);

View File

@@ -415,15 +415,6 @@ python_api_get_current_recipient(PyObject* self, PyObject* args)
}
}
static PyObject*
python_api_get_current_window(PyObject* self, PyObject* args)
{
allow_python_threads();
auto_gchar gchar* recipient = api_get_current_window();
disable_python_threads();
return Py_BuildValue("s", recipient);
}
static PyObject*
python_api_get_current_muc(PyObject* self, PyObject* args)
{
@@ -1539,7 +1530,6 @@ static PyMethodDef apiMethods[] = {
{ "send_line", python_api_send_line, METH_VARARGS, "Send a line of input." },
{ "notify", python_api_notify, METH_VARARGS, "Send desktop notification." },
{ "get_current_recipient", python_api_get_current_recipient, METH_VARARGS, "Return the jid of the recipient of the current window." },
{ "get_current_window", python_api_get_current_window, METH_VARARGS, "Return title of the current window." },
{ "get_current_muc", python_api_get_current_muc, METH_VARARGS, "Return the jid of the room of the current window." },
{ "get_current_nick", python_api_get_current_nick, METH_VARARGS, "Return nickname in current room." },
{ "get_name_from_roster", python_api_get_name_from_roster, METH_VARARGS, "Return nickname in roster of barejid." },

View File

@@ -99,6 +99,7 @@ _buffer_add(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* t
// With 10% margin to ensure overflow prevention
while (buffer->lines >= PAD_SIZE - (PAD_SIZE / 10) && g_slist_length(buffer->entries) > 1) {
log_debug("DELETING");
// Delete message from the opposite size to free buffer
GSList* buffer_entry_to_delete = append ? buffer->entries : g_slist_last(buffer->entries);
ProfBuffEntry* entry_to_delete = (ProfBuffEntry*)buffer_entry_to_delete->data;

View File

@@ -268,7 +268,11 @@ _show_scrolled(ProfWin* current)
wattroff(win, bracket_attrs);
wattron(win, scrolled_attrs);
wprintw(win, "SCROLLED");
if (current->layout->unread_msg == 0) {
wprintw(win, "SCROLLED");
} else {
wprintw(win, "SCROLLED, NEW MESSAGES");
}
wattroff(win, scrolled_attrs);
wattron(win, bracket_attrs);

View File

@@ -120,6 +120,7 @@ typedef struct prof_layout_t
ProfBuff buffer;
int y_pos;
int paged;
int unread_msg;
} ProfLayout;
typedef struct prof_layout_simple_t

View File

@@ -103,6 +103,7 @@ _win_create_simple_layout(void)
layout->base.buffer = buffer_create();
layout->base.y_pos = 0;
layout->base.paged = 0;
layout->base.unread_msg = 0;
scrollok(layout->base.win, TRUE);
return &layout->base;
@@ -120,6 +121,7 @@ _win_create_split_layout(void)
layout->base.buffer = buffer_create();
layout->base.y_pos = 0;
layout->base.paged = 0;
layout->base.unread_msg = 0;
scrollok(layout->base.win, TRUE);
layout->subwin = NULL;
layout->sub_y_pos = 0;
@@ -197,6 +199,7 @@ win_create_muc(const char* const roomjid)
layout->base.buffer = buffer_create();
layout->base.y_pos = 0;
layout->base.paged = 0;
layout->base.unread_msg = 0;
scrollok(layout->base.win, TRUE);
new_win->window.layout = (ProfLayout*)layout;
@@ -709,7 +712,7 @@ win_page_down(ProfWin* window, int scroll_size)
*page_start += scroll_size;
// Scrolled down after reaching the bottom of the page
if ((*page_start > total_rows - page_space || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) {
if (((*page_start > total_rows + window->layout->unread_msg - page_space) || ((*page_start == page_space + window->layout->unread_msg) && *page_start >= (total_rows + window->layout->unread_msg))) && window->type == WIN_CHAT) {
int bf_size = buffer_size(window->layout->buffer);
if (bf_size > 0 && *scroll_state != WIN_SCROLL_REACHED_BOTTOM) {
// How many lines are left until end of the screen
@@ -743,13 +746,15 @@ win_page_down(ProfWin* window, int scroll_size)
window->layout->paged = 1;
// update only if position has changed
if (page_start_initial != *page_start) {
if ((page_start_initial != *page_start) || (window->layout->unread_msg)) {
win_update_virtual(window);
}
// switch off page if last line and space line visible
if (total_rows - *page_start == page_space) {
/*switch off page if no messages left to read
TODO: update buffer end handling to check meassages just after last entry*/
if (*scroll_state == WIN_SCROLL_REACHED_BOTTOM) {
window->layout->paged = 0;
window->layout->unread_msg = 0;
}
}
@@ -810,6 +815,7 @@ win_clear(ProfWin* window)
int* page_start = &(window->layout->y_pos);
*page_start = y;
window->layout->paged = 1;
window->layout->unread_msg = 0;
win_update_virtual(window);
}
@@ -914,6 +920,7 @@ void
win_move_to_end(ProfWin* window)
{
window->layout->paged = 0;
window->layout->unread_msg = 0;
int rows = getmaxy(stdscr);
int y = getcury(window->layout->win);
@@ -1696,6 +1703,13 @@ win_newline(ProfWin* window)
static void
_win_printf(ProfWin* window, const char* show_char, int pad_indent, GDateTime* timestamp, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message_id, const char* const message, ...)
{
/* Prevent printing and buffer update when user is viewing message history [SCROLLING]*/
if ((window->layout->paged) && wins_is_current(window)) {
window->layout->unread_msg++;
return;
}
if (timestamp == NULL) {
timestamp = g_date_time_new_now_local();
} else {

View File

@@ -312,7 +312,6 @@ iq_reg2_cb(xmpp_conn_t* xmpp_conn, xmpp_stanza_t* stanza, void* userdata)
goto quit;
quit:
log_debug("[CONNDBG] iq_reg2_cb: disconnecting after registration completion");
xmpp_disconnect(xmpp_conn);
return 0;
@@ -551,7 +550,6 @@ connection_disconnect(void)
// don't disconnect already disconnected connection,
// or we get infinite loop otherwise
if (conn.conn_last_event == XMPP_CONN_CONNECT) {
log_debug("[CONNDBG] connection_disconnect: user-initiated disconnect (status=%d)", (int)conn.conn_status);
conn.conn_status = JABBER_DISCONNECTING;
xmpp_disconnect(conn.xmpp_conn);
@@ -559,7 +557,6 @@ connection_disconnect(void)
session_process_events();
}
} else {
log_debug("[CONNDBG] connection_disconnect: already disconnected (last_event=%d)", (int)conn.conn_last_event);
conn.conn_status = JABBER_DISCONNECTED;
}
@@ -982,7 +979,6 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status
connection_get_jid();
conn.domain = strdup(conn.jid->domainpart);
log_debug("conn.domain=%s", conn.jid->domainpart);
connection_clear_data();
conn.features_by_jid = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)g_hash_table_destroy);
@@ -1022,9 +1018,6 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status
// disconnected
case XMPP_CONN_DISCONNECT:
log_debug("Connection handler: XMPP_CONN_DISCONNECT");
log_debug("[CONNDBG] disconnect: previous_status=%d error=%d has_stream_error=%s",
(int)conn.conn_status, error,
(stream_error && stream_error->stanza) ? "yes" : "no");
// lost connection for unknown reason
if (conn.conn_status == JABBER_CONNECTED || conn.conn_status == JABBER_DISCONNECTING) {
@@ -1170,32 +1163,3 @@ connection_get_profanity_identifier(void)
{
return prof_identifier;
}
void
connection_debug_print_features()
{
log_debug("=== Connection Features ===");
GHashTableIter iter;
gpointer jid_ptr, features_ptr;
g_hash_table_iter_init(&iter, conn.features_by_jid);
while (g_hash_table_iter_next(&iter, &jid_ptr, &features_ptr)) {
const char* jid = (const char*)jid_ptr;
GHashTable* features = (GHashTable*)features_ptr;
if (!features || g_hash_table_size(features) == 0) {
log_debug("%s:\t(no features)", jid);
continue;
}
GList* feature_keys = g_hash_table_get_keys(features);
for (GList* l = feature_keys; l != NULL; l = l->next) {
const char* feature = (const char*)l->data;
log_debug("%s:\t%s", jid, feature);
}
g_list_free(feature_keys);
}
log_debug("=== End of Features ===");
}

View File

@@ -1417,8 +1417,6 @@ _manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
return 0;
}
static gboolean autoping_error_shown = false;
static int
_autoping_timed_send(xmpp_conn_t* const conn, void* const userdata)
{
@@ -1427,13 +1425,10 @@ _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata)
}
if (connection_supports(XMPP_FEATURE_PING) == FALSE) {
// TODO: do we need to check it on each autoping call?
log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_PING);
if (!autoping_error_shown) {
connection_debug_print_features();
cons_show_error("Server ping not supported (%s). Check log for details.", XMPP_FEATURE_PING);
}
autoping_error_shown = 1;
log_warning("Server doesn't advertise %s feature, disabling autoping.", XMPP_FEATURE_PING);
prefs_set_autoping(0);
cons_show_error("Server ping not supported (%s), autoping disabled.", XMPP_FEATURE_PING);
return 0;
}
if (autoping_wait) {
@@ -1504,7 +1499,7 @@ _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
if (g_strcmp0(errtype, STANZA_TYPE_CANCEL) == 0) {
log_warning("Server ping (id=%s) error type 'cancel', disabling autoping.", id);
prefs_set_autoping(0);
cons_show_error("Autoping is not supported by the server (stanza cancelled). The feature has been disabled automatically.");
cons_show_error("Server ping not supported, autoping disabled.");
xmpp_timed_handler_delete(connection_get_conn(), _autoping_timed_send);
}
@@ -2520,7 +2515,6 @@ _disco_items_result_handler(xmpp_stanza_t* const stanza)
GSList* items = NULL;
if ((g_strcmp0(id, "discoitemsreq") != 0) && (g_strcmp0(id, "discoitemsreq_onconnect") != 0)) {
log_warning("_disco_items_result_handler: Received unexpected disco id: %s", id);
return;
}

View File

@@ -218,7 +218,6 @@ session_connect_with_details(const char* const jid, const char* const passwd, co
void
session_autoping_fail(void)
{
log_debug("[CONNDBG] session_autoping_fail: autoping timeout, triggering lost connection");
session_lost_connection();
}
@@ -265,14 +264,11 @@ session_process_events(void)
if ((reconnect_sec != 0) && reconnect_timer) {
int elapsed_sec = g_timer_elapsed(reconnect_timer, NULL);
if (elapsed_sec > reconnect_sec) {
log_debug("[CONNDBG] session_process_events: auto-reconnect triggered after %d seconds (threshold=%d)",
elapsed_sec, reconnect_sec);
session_reconnect_now();
}
}
break;
case JABBER_RECONNECT:
log_debug("[CONNDBG] session_process_events: JABBER_RECONNECT state, calling session_reconnect_now");
session_reconnect_now();
break;
default:
@@ -331,12 +327,12 @@ session_login_success(gboolean secured)
// logged in with account
if (saved_account.name) {
log_debug("[CONNDBG] Connection handler: logged in with account name: %s", saved_account.name);
log_debug("Connection handler: logged in with account name: %s", saved_account.name);
sv_ev_login_account_success(saved_account.name, secured);
// logged in without account, use details to create new account
} else {
log_debug("[CONNDBG] Connection handler: logged in with jid: %s", saved_details.name);
log_debug("Connection handler: logged in with jid: %s", saved_details.name);
accounts_add(saved_details.name, saved_details.altdomain, saved_details.port, saved_details.tls_policy, saved_details.auth_policy);
accounts_set_jid(saved_details.name, saved_details.jid);
@@ -375,11 +371,11 @@ void
session_login_failed(void)
{
if (reconnect_timer == NULL) {
log_debug("[CONNDBG] Connection handler: No reconnect timer");
log_debug("Connection handler: No reconnect timer");
sv_ev_failed_login();
_session_free_internals();
} else {
log_debug("[CONNDBG] Connection handler: Restarting reconnect timer");
log_debug("Connection handler: Restarting reconnect timer");
if (prefs_get_reconnect() != 0) {
g_timer_start(reconnect_timer);
}
@@ -393,16 +389,12 @@ session_login_failed(void)
void
session_lost_connection(void)
{
log_debug("[CONNDBG] session_lost_connection: connection lost, reconnect_interval=%d",
prefs_get_reconnect());
/* this callback also clears all cached data */
sv_ev_lost_connection();
if (prefs_get_reconnect() != 0) {
assert(reconnect_timer == NULL);
reconnect_timer = g_timer_new();
log_debug("[CONNDBG] session_lost_connection: reconnect timer started");
} else {
log_debug("[CONNDBG] session_lost_connection: auto-reconnect disabled, cleaning up");
_session_free_internals();
}
}

View File

@@ -208,8 +208,6 @@ const char* connection_jid_for_feature(const char* const feature);
const char* connection_get_profanity_identifier(void);
void connection_debug_print_features();
char* message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id);
char* message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id);
char* message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id);

View File

@@ -26,7 +26,7 @@
#include "log.h"
void
log_init(log_level_t filter, const char* const log_file)
log_init(log_level_t filter, char* log_file)
{
}
log_level_t

View File

@@ -156,11 +156,6 @@ connection_get_profanity_identifier(void)
return "profident";
}
void
connection_debug_print_features()
{
}
jabber_conn_status_t
connection_register(const char* const altdomain, int port, const char* const tls_policy,
const char* const username, const char* const password)