diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command/command.c | 20 | ||||
-rw-r--r-- | src/command/commands.c | 38 | ||||
-rw-r--r-- | src/command/commands.h | 1 | ||||
-rw-r--r-- | src/server_events.c | 6 | ||||
-rw-r--r-- | src/server_events.h | 1 | ||||
-rw-r--r-- | src/ui/core.c | 71 | ||||
-rw-r--r-- | src/ui/ui.h | 6 | ||||
-rw-r--r-- | src/ui/window.h | 1 | ||||
-rw-r--r-- | src/ui/windows.c | 28 | ||||
-rw-r--r-- | src/ui/windows.h | 1 | ||||
-rw-r--r-- | src/xmpp/message.c | 29 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 1 |
12 files changed, 3 insertions, 200 deletions
diff --git a/src/command/command.c b/src/command/command.c index 7e868938..c5f76f83 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -502,17 +502,6 @@ static struct cmd_t command_defs[] = "Example : /tiny http://www.profanity.im", NULL } } }, - { "/duck", - cmd_duck, parse_args_with_freetext, 1, 1, NULL, - { "/duck query", "Perform search using DuckDuckGo chatbot.", - { "/duck query", - "-----------", - "Send a search query to the DuckDuckGo chatbot.", - "Your chat service must be federated, i.e. allow message to be sent/received outside of its domain.", - "", - "Example : /duck dennis ritchie", - NULL } } }, - { "/who", cmd_who, parse_args, 0, 2, NULL, { "/who [status] [group]", "Show contacts/room participants with chosen status.", @@ -1693,15 +1682,6 @@ cmd_execute_default(const char * inp) cons_show("Unknown command: %s", inp); break; - case WIN_DUCK: - if (status != JABBER_CONNECTED) { - ui_current_print_line("You are not currently connected."); - } else { - message_send_duck(inp); - ui_duck(inp); - } - break; - default: break; } diff --git a/src/command/commands.c b/src/command/commands.c index 32d36f58..9cc2214d 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -582,7 +582,7 @@ cmd_help(gchar **args, struct cmd_help_t help) _cmd_show_filtered_help("Basic commands", filter, ARRAY_SIZE(filter)); } else if (strcmp(args[0], "chatting") == 0) { - gchar *filter[] = { "/chlog", "/otr", "/duck", "/gone", "/history", + gchar *filter[] = { "/chlog", "/otr", "/gone", "/history", "/info", "/intype", "/msg", "/notify", "/outtype", "/status", "/close", "/clear", "/tiny" }; _cmd_show_filtered_help("Chat commands", filter, ARRAY_SIZE(filter)); @@ -616,7 +616,7 @@ cmd_help(gchar **args, struct cmd_help_t help) _cmd_show_filtered_help("Settings commands", filter, ARRAY_SIZE(filter)); } else if (strcmp(args[0], "other") == 0) { - gchar *filter[] = { "/duck", "/vercheck" }; + gchar *filter[] = { "/vercheck" }; _cmd_show_filtered_help("Other commands", filter, ARRAY_SIZE(filter)); } else if (strcmp(args[0], "navigation") == 0) { @@ -1405,40 +1405,6 @@ cmd_roster(gchar **args, struct cmd_help_t help) } gboolean -cmd_duck(gchar **args, struct cmd_help_t help) -{ - char *query = args[0]; - - jabber_conn_status_t conn_status = jabber_get_connection_status(); - - if (conn_status != JABBER_CONNECTED) { - cons_show("You are not currently connected."); - return TRUE; - } - - // if no duck win open, create it and send a help command - if (!ui_duck_exists()) { - ui_create_duck_win(); - - if (query != NULL) { - message_send_duck(query); - ui_duck(query); - } - - // window exists, send query - } else { - ui_open_duck_win(); - - if (query != NULL) { - message_send_duck(query); - ui_duck(query); - } - } - - return TRUE; -} - -gboolean cmd_status(gchar **args, struct cmd_help_t help) { char *usr = args[0]; diff --git a/src/command/commands.h b/src/command/commands.h index 4494017c..757a09cc 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -79,7 +79,6 @@ gboolean cmd_decline(gchar **args, struct cmd_help_t help); gboolean cmd_disco(gchar **args, struct cmd_help_t help); gboolean cmd_disconnect(gchar **args, struct cmd_help_t help); gboolean cmd_dnd(gchar **args, struct cmd_help_t help); -gboolean cmd_duck(gchar **args, struct cmd_help_t help); gboolean cmd_flash(gchar **args, struct cmd_help_t help); gboolean cmd_gone(gchar **args, struct cmd_help_t help); gboolean cmd_grlog(gchar **args, struct cmd_help_t help); diff --git a/src/server_events.c b/src/server_events.c index 0ff5514e..3d949430 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -296,12 +296,6 @@ handle_room_message(const char * const room_jid, const char * const nick, } void -handle_duck_result(const char * const result) -{ - ui_duck_result(result); -} - -void handle_incoming_message(char *from, char *message, gboolean priv) { #ifdef HAVE_LIBOTR diff --git a/src/server_events.h b/src/server_events.h index 15b49260..333543fb 100644 --- a/src/server_events.h +++ b/src/server_events.h @@ -71,7 +71,6 @@ void handle_room_role_set_error(const char * const room, const char * const nick const char * const error); void handle_room_role_set(const char * const from, const char * const nick, const char * const role); void handle_room_kick_result_error(const char * const room, const char * const nick, const char * const error); -void handle_duck_result(const char * const result); void handle_incoming_message(char *from, char *message, gboolean priv); void handle_delayed_message(char *from, char *message, GTimeVal tv_stamp, gboolean priv); diff --git a/src/ui/core.c b/src/ui/core.c index 24461ad3..0ab87f13 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -234,12 +234,6 @@ _ui_win_exists(int index) } static gboolean -_ui_duck_exists(void) -{ - return wins_duck_exists(); -} - -static gboolean _ui_xmlconsole_exists(void) { return wins_xmlconsole_exists(); @@ -1235,15 +1229,6 @@ _ui_new_chat_win(const char * const to) } static void -_ui_create_duck_win(void) -{ - ProfWin *window = wins_new("DuckDuckGo search", WIN_DUCK); - int num = wins_get_num(window); - ui_switch_win(num); - win_save_println(window, "Type ':help' to find out more."); -} - -static void _ui_create_xmlconsole_win(void) { ProfWin *window = wins_new("XML Console", WIN_XML); @@ -1262,57 +1247,6 @@ _ui_open_xmlconsole_win(void) } static void -_ui_open_duck_win(void) -{ - ProfWin *window = wins_get_by_recipient("DuckDuckGo search"); - if (window != NULL) { - int num = wins_get_num(window); - ui_switch_win(num); - } -} - -static void -_ui_duck(const char * const query) -{ - ProfWin *window = wins_get_by_recipient("DuckDuckGo search"); - if (window != NULL) { - win_save_println(window, ""); - win_save_print(window, '-', NULL, NO_EOL, COLOUR_ME, "", "Query : "); - win_save_print(window, '-', NULL, NO_DATE, 0, "", query); - } -} - -static void -_ui_duck_result(const char * const result) -{ - ProfWin *window = wins_get_by_recipient("DuckDuckGo search"); - - if (window != NULL) { - win_save_print(window, '-', NULL, NO_EOL, COLOUR_THEM, "", "Result : "); - - glong offset = 0; - while (offset < g_utf8_strlen(result, -1)) { - gchar *ptr = g_utf8_offset_to_pointer(result, offset); - gunichar unichar = g_utf8_get_char(ptr); - if (unichar == '\n') { - win_save_newline(window); - win_save_print(window, '-', NULL, NO_EOL, 0, "", ""); - } else { - gchar *string = g_ucs4_to_utf8(&unichar, 1, NULL, NULL, NULL); - if (string != NULL) { - win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", string); - g_free(string); - } - } - - offset++; - } - - win_save_newline(window); - } -} - -static void _ui_outgoing_msg(const char * const from, const char * const to, const char * const message) { @@ -2993,7 +2927,6 @@ ui_init_module(void) ui_resize = _ui_resize; ui_load_colours = _ui_load_colours; ui_win_exists = _ui_win_exists; - ui_duck_exists = _ui_duck_exists; ui_contact_typing = _ui_contact_typing; ui_get_recipients = _ui_get_recipients; ui_incoming_msg = _ui_incoming_msg; @@ -3027,10 +2960,6 @@ ui_init_module(void) ui_print_system_msg_from_recipient = _ui_print_system_msg_from_recipient; ui_recipient_gone = _ui_recipient_gone; ui_new_chat_win = _ui_new_chat_win; - ui_create_duck_win = _ui_create_duck_win; - ui_open_duck_win = _ui_open_duck_win; - ui_duck = _ui_duck; - ui_duck_result = _ui_duck_result; ui_outgoing_msg = _ui_outgoing_msg; ui_room_join = _ui_room_join; ui_room_roster = _ui_room_roster; diff --git a/src/ui/ui.h b/src/ui/ui.h index 9781d1b6..9c1888f6 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -209,12 +209,6 @@ void (*ui_info)(void); void (*ui_status_private)(void); void (*ui_info_private)(void); -void (*ui_create_duck_win)(void); -void (*ui_open_duck_win)(void); -void (*ui_duck)(const char * const query); -void (*ui_duck_result)(const char * const result); -gboolean (*ui_duck_exists)(void); - void (*ui_tidy_wins)(void); void (*ui_prune_wins)(void); gboolean (*ui_swap_wins)(int source_win, int target_win); diff --git a/src/ui/window.h b/src/ui/window.h index 68bab0e7..185bdd6e 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -62,7 +62,6 @@ typedef enum { WIN_MUC, WIN_MUC_CONFIG, WIN_PRIVATE, - WIN_DUCK, WIN_XML } win_type_t; diff --git a/src/ui/windows.c b/src/ui/windows.c index 0542f3da..c9f04cb5 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -343,25 +343,6 @@ wins_show_subwin(ProfWin *window) } gboolean -wins_duck_exists(void) -{ - GList *values = g_hash_table_get_values(windows); - GList *curr = values; - - while (curr != NULL) { - ProfWin *window = curr->data; - if (window->type == WIN_DUCK) { - g_list_free(values); - return TRUE; - } - curr = g_list_next(curr); - } - - g_list_free(values); - return FALSE; -} - -gboolean wins_xmlconsole_exists(void) { GList *values = g_hash_table_get_values(windows); @@ -585,7 +566,6 @@ wins_create_summary(void) GString *priv_string; GString *muc_string; GString *muc_config_string; - GString *duck_string; GString *xml_string; switch (window->type) @@ -663,14 +643,6 @@ wins_create_summary(void) break; - case WIN_DUCK: - duck_string = g_string_new(""); - g_string_printf(duck_string, "%d: DuckDuckGo search", ui_index); - result = g_slist_append(result, strdup(duck_string->str)); - g_string_free(duck_string, TRUE); - - break; - case WIN_XML: xml_string = g_string_new(""); g_string_printf(xml_string, "%d: XML console", ui_index); diff --git a/src/ui/windows.h b/src/ui/windows.h index 7b3a94f8..0b72ee0e 100644 --- a/src/ui/windows.h +++ b/src/ui/windows.h @@ -52,7 +52,6 @@ gboolean wins_is_current(ProfWin *window); ProfWin * wins_new(const char * const from, win_type_t type); int wins_get_total_unread(void); void wins_resize_all(void); -gboolean wins_duck_exists(void); GSList * wins_get_chat_recipients(void); GSList * wins_get_prune_recipients(void); void wins_lost_connection(void); diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 16a51829..b0b17214 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -136,18 +136,6 @@ _message_send_groupchat_subject(const char * const room, const char * const subj } static void -_message_send_duck(const char * const query) -{ - xmpp_conn_t * const conn = connection_get_conn(); - xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *message = stanza_create_message(ctx, "im@ddg.gg", - STANZA_TYPE_CHAT, query, NULL); - - xmpp_send(conn, message); - xmpp_stanza_release(message); -} - -static void _message_send_invite(const char * const room, const char * const contact, const char * const reason) { @@ -438,22 +426,8 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); Jid *jid = jid_create(from); - // handle ddg searches - if (strcmp(jid->barejid, "im@ddg.gg") == 0) { - xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); - if (body != NULL) { - char *message = xmpp_stanza_get_text(body); - if (message != NULL) { - handle_duck_result(message); - xmpp_free(ctx, message); - } - } - - jid_destroy(jid); - return 1; - // private message from chat room use full jid (room/nick) - } else if (muc_active(jid->barejid)) { + if (muc_active(jid->barejid)) { // determine if the notifications happened whilst offline GTimeVal tv_stamp; gboolean delayed = stanza_get_delay(stanza, &tv_stamp); @@ -533,7 +507,6 @@ message_init_module(void) { message_send = _message_send; message_send_groupchat = _message_send_groupchat; - message_send_duck = _message_send_duck; message_send_invite = _message_send_invite; message_send_composing = _message_send_composing; message_send_paused = _message_send_paused; diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 798cb339..1d391cbc 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -164,7 +164,6 @@ void (*message_send_paused)(const char * const recipient); void (*message_send_gone)(const char * const recipient); void (*message_send_invite)(const char * const room, const char * const contact, const char * const reason); -void (*message_send_duck)(const char * const query); // presence functions void (*presence_subscription)(const char * const jid, const jabber_subscr_t action); |