void handle_key(struct wdata *data, int c) { if (c == 27) { reset(); states_pop(); } else if (c == 9) { autocomplete_handle(); } else if (c == 13) { execute(data); reset(); states_pop(); } else if (c == 263) { if (cmd_data.bufpos > 0) { autocomplete_clear(); cmd_data.buf[--cmd_data.bufpos] = '\0'; set_message(M_INFO, ":%s", cmd_data.buf); } else { set_message(M_INFO, ""); states_pop(); } } else if (c >= 32) { if (cmd_data.bufpos < CMD_BUFSIZE) { autocomplete_clear(); cmd_data.buf[cmd_data.bufpos++] = c; cmd_data.buf[cmd_data.bufpos] = '\0'; set_message(M_INFO, ":%s", cmd_data.buf); } } }
void roster_clear(void) { autocomplete_clear(name_ac); autocomplete_clear(barejid_ac); autocomplete_clear(fulljid_ac); autocomplete_clear(groups_ac); g_hash_table_destroy(contacts); contacts = g_hash_table_new_full(g_str_hash, (GEqualFunc)_key_equals, g_free, (GDestroyNotify)p_contact_free); g_hash_table_destroy(name_to_barejid); name_to_barejid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); }
void muc_invites_clear(void) { autocomplete_clear(invite_ac); if (invite_passwords) { g_hash_table_remove_all(invite_passwords); } }
int blocked_set_handler(xmpp_stanza_t *stanza) { xmpp_stanza_t *block = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCK); if (block) { xmpp_stanza_t *child = xmpp_stanza_get_children(block); while (child) { if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) { const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); if (jid) { blocked = g_list_append(blocked, strdup(jid)); autocomplete_add(blocked_ac, jid); } } child = xmpp_stanza_get_next(child); } } xmpp_stanza_t *unblock = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_UNBLOCK); if (unblock) { xmpp_stanza_t *child = xmpp_stanza_get_children(unblock); if (!child) { g_list_free_full(blocked, free); blocked = NULL; autocomplete_clear(blocked_ac); } else { while (child) { if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) { const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); if (jid) { GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0); if (found) { blocked = g_list_remove_link(blocked, found); g_list_free_full(found, free); autocomplete_remove(blocked_ac, jid); } } } child = xmpp_stanza_get_next(child); } } } return 1; }
void autocompleters_clear(const char *const plugin_name, const char *key) { GHashTable *key_to_ac = g_hash_table_lookup(plugin_to_acs, plugin_name); if (!key_to_ac) { return; } if (!g_hash_table_contains(key_to_ac, key)) { return; } Autocomplete ac = g_hash_table_lookup(key_to_ac, key); autocomplete_clear(ac); }
void muc_clear_invites(void) { autocomplete_clear(invite_ac); }
void reset() { autocomplete_clear(); cmd_data.buf[(cmd_data.bufpos = 0)] = '\0'; }
void muc_confserver_clear(void) { autocomplete_clear(confservers_ac); }
void presence_clear_sub_requests(void) { autocomplete_clear(sub_requests_ac); }
GHashTable* p_gpg_list_keys(void) { gpgme_error_t error; GHashTable *result = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_p_gpg_free_key); gpgme_ctx_t ctx; error = gpgme_new(&ctx); if (error) { log_error("GPG: Could not list keys. %s %s", gpgme_strsource(error), gpgme_strerror(error)); return NULL; } error = gpgme_op_keylist_start(ctx, NULL, 0); if (error == GPG_ERR_NO_ERROR) { gpgme_key_t key; error = gpgme_op_keylist_next(ctx, &key); while (!error) { gpgme_subkey_t sub = key->subkeys; ProfPGPKey *p_pgpkey = _p_gpg_key_new(); p_pgpkey->id = strdup(sub->keyid); p_pgpkey->name = strdup(key->uids->uid); p_pgpkey->fp = strdup(sub->fpr); if (sub->can_encrypt) p_pgpkey->encrypt = TRUE; if (sub->can_authenticate) p_pgpkey->authenticate = TRUE; if (sub->can_certify) p_pgpkey->certify = TRUE; if (sub->can_sign) p_pgpkey->sign = TRUE; sub = sub->next; while (sub) { if (sub->can_encrypt) p_pgpkey->encrypt = TRUE; if (sub->can_authenticate) p_pgpkey->authenticate = TRUE; if (sub->can_certify) p_pgpkey->certify = TRUE; if (sub->can_sign) p_pgpkey->sign = TRUE; sub = sub->next; } g_hash_table_insert(result, strdup(p_pgpkey->name), p_pgpkey); gpgme_key_unref(key); error = gpgme_op_keylist_next(ctx, &key); } } error = gpgme_op_keylist_start(ctx, NULL, 1); if (error == GPG_ERR_NO_ERROR) { gpgme_key_t key; error = gpgme_op_keylist_next(ctx, &key); while (!error) { gpgme_subkey_t sub = key->subkeys; while (sub) { if (sub->secret) { ProfPGPKey *p_pgpkey = g_hash_table_lookup(result, key->uids->uid); if (p_pgpkey) { p_pgpkey->secret = TRUE; } } sub = sub->next; } gpgme_key_unref(key); error = gpgme_op_keylist_next(ctx, &key); } } gpgme_release(ctx); autocomplete_clear(key_ac); GList *ids = g_hash_table_get_keys(result); GList *curr = ids; while (curr) { ProfPGPKey *key = g_hash_table_lookup(result, curr->data); autocomplete_add(key_ac, key->id); curr = curr->next; } g_list_free(ids); return result; }