UTF-8 capable single/multi-line text area/display field - needs

optimisation, completion of outstanding todos.
Use this to display SSL certificate issuer and subject information.

svn path=/trunk/netsurf/; revision=2647
This commit is contained in:
John Mark Bell 2006-06-26 01:14:33 +00:00
parent f1a1143a24
commit 8db70d8e2d
4 changed files with 1326 additions and 14 deletions

View File

@ -38,9 +38,10 @@ OBJECTS_RISCOS += 401login.o artworks.o assert.o awrender.o bitmap.o \
global_history.o gui.o help.o history.o hotlist.o image.o \
menus.o message.o palettes.o plotters.o plugin.o print.o \
query.o save.o save_complete.o save_draw.o save_text.o \
schedule.o search.o sprite.o sslcert.o textselection.o theme.o \
theme_install.o thumbnail.o treeview.o ucstables.o uri.o \
url_complete.o url_protocol.o wimp.o wimp_event.o window.o # riscos/
schedule.o search.o sprite.o sslcert.o textarea.o \
textselection.o theme.o theme_install.o thumbnail.o \
treeview.o ucstables.o uri.o url_complete.o url_protocol.o \
wimp.o wimp_event.o window.o # riscos/
OBJECTS_RISCOS += con_cache.o con_connect.o con_content.o con_fonts.o \
con_home.o con_image.o con_inter.o con_language.o con_memory.o \
con_secure.o con_theme.o # riscos/configure/

View File

@ -24,6 +24,7 @@
#include "netsurf/desktop/browser.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/textarea.h"
#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
@ -41,9 +42,10 @@
static wimp_window *dialog_cert_template;
struct session_cert {
char version[16], valid_from[32], valid_to[32], type[8], serial[32],
issuer[256], subject[256];
char version[16], valid_from[32], valid_to[32], type[8], serial[32];
char *url;
uintptr_t issuer;
uintptr_t subject;
struct browser_window *bw;
};
@ -79,6 +81,7 @@ void ro_gui_cert_open(struct browser_window *bw, const char *url,
{
struct session_cert *session;
wimp_w w;
os_error *error;
session = malloc(sizeof(struct session_cert));
if (!session) {
@ -105,10 +108,6 @@ void ro_gui_cert_open(struct browser_window *bw, const char *url,
certdata->not_after);
snprintf(session->serial, sizeof session->serial, "%ld",
certdata->serial);
snprintf(session->issuer, sizeof session->issuer, "%s",
certdata->issuer);
snprintf(session->subject, sizeof session->subject, "%s",
certdata->subject);
dialog_cert_template->icons[ICON_CERT_VERSION].data.indirected_text.text = session->version;
dialog_cert_template->icons[ICON_CERT_VERSION].data.indirected_text.size = strlen(session->version) + 1;
@ -120,12 +119,49 @@ void ro_gui_cert_open(struct browser_window *bw, const char *url,
dialog_cert_template->icons[ICON_CERT_VALID_TO].data.indirected_text.size = strlen(session->valid_to) + 1;
dialog_cert_template->icons[ICON_CERT_SERIAL].data.indirected_text.text = session->serial;
dialog_cert_template->icons[ICON_CERT_SERIAL].data.indirected_text.size = strlen(session->serial) + 1;
dialog_cert_template->icons[ICON_CERT_ISSUER].data.indirected_text.text = session->issuer;
dialog_cert_template->icons[ICON_CERT_ISSUER].data.indirected_text.size = strlen(session->issuer) + 1;
dialog_cert_template->icons[ICON_CERT_SUBJECT].data.indirected_text.text = session->subject;
dialog_cert_template->icons[ICON_CERT_SUBJECT].data.indirected_text.size = strlen(session->subject) + 1;
w = wimp_create_window(dialog_cert_template);
error = xwimp_create_window(dialog_cert_template, &w);
if (error) {
LOG(("xwimp_create_window: 0x%x: %s",
error->errnum, error->errmess));
free(session);
warn_user("MiscError", error->errmess);
return;
}
session->issuer = textarea_create(w, ICON_CERT_ISSUER,
TEXTAREA_MULTILINE | TEXTAREA_READONLY, NULL, 0);
if (!session->issuer) {
xwimp_delete_window(w);
free(session);
warn_user("NoMemory", 0);
return;
}
if (!textarea_set_text(session->issuer, certdata->issuer)) {
textarea_destroy(session->issuer);
xwimp_delete_window(w);
free(session);
warn_user("NoMemory", 0);
return;
}
session->subject = textarea_create(w, ICON_CERT_SUBJECT,
TEXTAREA_MULTILINE | TEXTAREA_READONLY, NULL, 0);
if (!session->subject) {
textarea_destroy(session->issuer);
xwimp_delete_window(w);
free(session);
warn_user("NoMemory", 0);
return;
}
if (!textarea_set_text(session->subject, certdata->subject)) {
textarea_destroy(session->subject);
textarea_destroy(session->issuer);
xwimp_delete_window(w);
free(session);
warn_user("NoMemory", 0);
return;
}
ro_gui_wimp_event_register_cancel(w, ICON_CERT_REJECT);
ro_gui_wimp_event_register_ok(w, ICON_CERT_ACCEPT, ro_gui_cert_apply);
@ -147,6 +183,9 @@ void ro_gui_cert_close(wimp_w w)
assert(session);
textarea_destroy(session->subject);
textarea_destroy(session->issuer);
free(session->url);
free(session);

1240
riscos/textarea.c Normal file

File diff suppressed because it is too large Load Diff

32
riscos/textarea.h Normal file
View File

@ -0,0 +1,32 @@
/*
* This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2006 John-Mark Bell <jmb202@ecs.soton.ac.uk>
*/
/** \file
* Single/Multi-line UTF-8 text area (interface)
*/
#ifndef _NETSURF_RISCOS_TEXTAREA_H_
#define _NETSURF_RISCOS_TEXTAREA_H_
/* Text area flags */
#define TEXTAREA_MULTILINE 0x01 /**< Text area is multiline */
#define TEXTAREA_READONLY 0x02 /**< Text area is read only */
uintptr_t textarea_create(wimp_w parent, wimp_i icon, unsigned int flags,
const char *font_family, unsigned int font_size);
void textarea_destroy(uintptr_t self);
bool textarea_set_text(uintptr_t self, const char *text);
int textarea_get_text(uintptr_t self, char *buf, unsigned int len);
void textarea_insert_text(uintptr_t self, unsigned int index,
const char *text);
void textarea_replace_text(uintptr_t self, unsigned int start,
unsigned int end, const char *text);
void textarea_set_caret(uintptr_t self, unsigned int caret);
unsigned int textarea_get_caret(uintptr_t self);
#endif