gqclient-commit Mailing List for GQ LDAP client (Page 10)
Status: Beta
Brought to you by:
sur5r
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
(14) |
Jul
(38) |
Aug
(5) |
Sep
(29) |
Oct
(30) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(30) |
Oct
(217) |
Nov
(24) |
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
(53) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sta...@us...> - 2003-10-09 05:39:02
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv8333 Modified Files: util.c Log Message: * Got rid of the nasty communication widget used for popup dialogs. I must have been completly mad when I wrote this code initially. Am I glad this is gone! Index: util.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.c,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** util.c 9 Oct 2003 05:26:20 -0000 1.65 --- util.c 9 Oct 2003 05:38:58 -0000 1.66 *************** *** 1251,1272 **** } /* gtk2 checked (multiple destroy callbacks safety), confidence 0.7 */ ! static void query_destroy(GtkWidget *button, GtkWidget *comm) { assert(comm); if (!comm) return; ! if (! gtk_object_get_data(GTK_OBJECT(comm), "ended")) gtk_main_quit(); /* quits only nested main loop */ ! ! gtk_object_set_data(GTK_OBJECT(comm), "destroyed", "1"); } ! static void query_ok(GtkWidget *button, GtkObject *comm) { gtk_main_quit(); ! gtk_object_set_data(GTK_OBJECT(comm), "rc", "1"); } ! static void query_cancel(GtkWidget *button, GtkObject *comm) { gtk_main_quit(); ! gtk_object_set_data(GTK_OBJECT(comm), "rc", (void*) NULL); } --- 1251,1290 ---- } + struct popup_comm { + int destroyed; + int ended; + int rc; + }; + + static struct popup_comm *new_popup_comm() + { + struct popup_comm *n = g_malloc0(sizeof(struct popup_comm)); + n->ended = n->destroyed = n->rc = 0; + return n; + } + + static void free_popup_comm(struct popup_comm *c) + { + assert(c); + g_free(c); + } + /* gtk2 checked (multiple destroy callbacks safety), confidence 0.7 */ ! static void query_destroy(GtkWidget *window, struct popup_comm *comm) { assert(comm); if (!comm) return; ! if (!comm->ended) gtk_main_quit(); /* quits only nested main loop */ ! comm->destroyed = 1; } ! static void query_ok(GtkWidget *button, struct popup_comm *comm) { gtk_main_quit(); ! comm->rc = 1; } ! static void query_cancel(GtkWidget *button, struct popup_comm *comm) { gtk_main_quit(); ! comm->rc = 0; } *************** *** 1279,1284 **** int rc; GtkWidget *f = gtk_grab_get_current(); ! GtkWidget *comm; /* communication widget, not shown but used to ! associate data with */ /* This is a BAD hack - it solves a problem with the query popup --- 1297,1301 ---- int rc; GtkWidget *f = gtk_grab_get_current(); ! struct popup_comm *comm = new_popup_comm(); /* This is a BAD hack - it solves a problem with the query popup *************** *** 1293,1298 **** } - comm = gtk_entry_new(); - window = gtk_dialog_new(); gtk_container_border_width(GTK_CONTAINER(window), CONTAINER_BORDER_WIDTH); --- 1310,1313 ---- *************** *** 1323,1327 **** gtk_widget_show(inputbox); gtk_signal_connect(GTK_OBJECT(inputbox), "activate", ! GTK_SIGNAL_FUNC(query_ok), GTK_OBJECT(comm)); gtk_box_pack_end(GTK_BOX(vbox1), inputbox, TRUE, TRUE, 5); --- 1338,1342 ---- gtk_widget_show(inputbox); gtk_signal_connect(GTK_OBJECT(inputbox), "activate", ! GTK_SIGNAL_FUNC(query_ok), comm); gtk_box_pack_end(GTK_BOX(vbox1), inputbox, TRUE, TRUE, 5); *************** *** 1341,1345 **** gtk_signal_connect(GTK_OBJECT(button), "clicked", ! GTK_SIGNAL_FUNC(query_ok), GTK_OBJECT(comm)); gtk_box_pack_start(GTK_BOX(hbox0), button, FALSE, FALSE, 0); GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); --- 1356,1360 ---- gtk_signal_connect(GTK_OBJECT(button), "clicked", ! GTK_SIGNAL_FUNC(query_ok), comm); gtk_box_pack_start(GTK_BOX(hbox0), button, FALSE, FALSE, 0); GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); *************** *** 1356,1360 **** gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(query_cancel), ! GTK_OBJECT(comm)); gtk_box_pack_end(GTK_BOX(hbox0), button, FALSE, FALSE, 0); --- 1371,1375 ---- gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(query_cancel), ! comm); gtk_box_pack_end(GTK_BOX(hbox0), button, FALSE, FALSE, 0); *************** *** 1370,1388 **** gtk_main(); ! gtk_object_set_data(GTK_OBJECT(comm), "ended", "1"); ! ! rc = gtk_object_get_data(GTK_OBJECT(comm), "rc") != NULL; ! if (! gtk_object_get_data(GTK_OBJECT(comm), "destroyed") && rc) { *outbuf = gtk_editable_get_chars(GTK_EDITABLE(inputbox), 0, -1); } else { - rc = 0; *outbuf = NULL; } ! if (! gtk_object_get_data(GTK_OBJECT(comm), "destroyed")) { gtk_widget_destroy(window); } ! gtk_widget_unref(comm); return rc; --- 1385,1402 ---- gtk_main(); ! comm->ended = 1; ! if (! comm->destroyed && comm->rc) { *outbuf = gtk_editable_get_chars(GTK_EDITABLE(inputbox), 0, -1); } else { *outbuf = NULL; } ! if (! comm->destroyed ) { gtk_widget_destroy(window); } ! ! rc = comm->rc; ! free_popup_comm(comm); return rc; *************** *** 1400,1405 **** GdkBitmap *warning_mask; GtkWidget *f = gtk_grab_get_current(); ! GtkWidget *comm; /* communication widget, not shown but used to ! associate data with */ /* This is a BAD hack - it solves a problem with the query popup --- 1414,1418 ---- GdkBitmap *warning_mask; GtkWidget *f = gtk_grab_get_current(); ! struct popup_comm *comm = new_popup_comm(); /* This is a BAD hack - it solves a problem with the query popup *************** *** 1414,1419 **** } - comm = gtk_entry_new(); - window = gtk_dialog_new(); gtk_container_border_width(GTK_CONTAINER(window), CONTAINER_BORDER_WIDTH); --- 1427,1430 ---- *************** *** 1458,1462 **** button = gq_button_new_with_label(_("_Yes")); gtk_signal_connect(GTK_OBJECT(button), "clicked", ! GTK_SIGNAL_FUNC(query_ok), GTK_OBJECT(comm)); gtk_box_pack_start(GTK_BOX(hbox0), button, FALSE, FALSE, 0); GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); --- 1469,1473 ---- button = gq_button_new_with_label(_("_Yes")); gtk_signal_connect(GTK_OBJECT(button), "clicked", ! GTK_SIGNAL_FUNC(query_ok), comm); gtk_box_pack_start(GTK_BOX(hbox0), button, FALSE, FALSE, 0); GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); *************** *** 1468,1472 **** gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(query_cancel), ! GTK_OBJECT(comm)); gtk_box_pack_end(GTK_BOX(hbox0), button, FALSE, FALSE, 0); --- 1479,1483 ---- gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(query_cancel), ! comm); gtk_box_pack_end(GTK_BOX(hbox0), button, FALSE, FALSE, 0); *************** *** 1481,1499 **** gtk_main(); ! gtk_object_set_data(GTK_OBJECT(comm), "ended", "1"); ! ! rc = gtk_object_get_data(GTK_OBJECT(comm), "rc") != NULL; ! ! /* if (! gtk_object_get_data(GTK_OBJECT(comm), "destroyed") && rc) { */ ! /* *outbuf = gtk_editable_get_chars(GTK_EDITABLE(inputbox), 0, -1); */ ! /* } else { */ ! /* rc = 0; */ ! /* *outbuf = NULL; */ ! /* } */ ! if (! gtk_object_get_data(GTK_OBJECT(comm), "destroyed")) { gtk_widget_destroy(window); } ! gtk_widget_unref(comm); return rc; --- 1492,1503 ---- gtk_main(); ! comm->ended = 1; ! if (! comm->destroyed) { gtk_widget_destroy(window); } ! ! rc = comm->rc; ! free_popup_comm(comm); return rc; |
From: <sta...@us...> - 2003-10-09 05:26:24
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv6889 Modified Files: common.h util.c util.h Log Message: * Moved the tokenlist struct into util.h (where the related utilities are) and added const whereever appropriate Index: common.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/common.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** common.h 5 Oct 2003 13:33:02 -0000 1.24 --- common.h 9 Oct 2003 05:26:20 -0000 1.25 *************** *** 123,133 **** }; - - struct tokenlist { - int token; - char keyword[32]; - gpointer data; - }; - #ifdef USE_G_SNPRINTF # include <stdio.h> --- 123,126 ---- Index: util.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.c,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** util.c 9 Oct 2003 05:15:06 -0000 1.64 --- util.c 9 Oct 2003 05:26:20 -0000 1.65 *************** *** 649,657 **** ! int tokenize(struct tokenlist *list, const char *keyword) { int i; ! for(i = 0; strlen(list[i].keyword); i++) if(!strcasecmp(list[i].keyword, keyword)) return(list[i].token); --- 649,657 ---- ! int tokenize(const struct tokenlist *list, const char *keyword) { int i; ! for(i = 0; list[i].keyword && strlen(list[i].keyword); i++) if(!strcasecmp(list[i].keyword, keyword)) return(list[i].token); *************** *** 661,669 **** ! const char *detokenize(struct tokenlist *list, int token) { int i; ! for(i = 0; strlen(list[i].keyword); i++) if(list[i].token == token) return(list[i].keyword); --- 661,669 ---- ! const char *detokenize(const struct tokenlist *list, int token) { int i; ! for(i = 0; list[i].keyword && strlen(list[i].keyword); i++) if(list[i].token == token) return(list[i].keyword); *************** *** 672,676 **** } ! const gpointer detokenize_data(struct tokenlist *list, int token) { int i; --- 672,677 ---- } ! ! const gpointer detokenize_data(const struct tokenlist *list, int token) { int i; Index: util.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** util.h 8 Oct 2003 22:01:13 -0000 1.23 --- util.h 9 Oct 2003 05:26:20 -0000 1.24 *************** *** 58,69 **** const char *none, const char *one, const char *many, ...) ! __attribute__ ((format (printf, 5, 6))); #endif int close_on_esc(GtkWidget *widget, GdkEventKey *event, gpointer obj); int func_on_esc(GtkWidget *widget, GdkEventKey *event, GtkWidget *window); ! int tokenize(struct tokenlist *list, const char *keyword); ! const char *detokenize(struct tokenlist *list, int token); ! const gpointer detokenize_data(struct tokenlist *list, int token); char *get_username(void); /* G_GNUC_PRINTF is the __attribute__ ((format (printf, 1, 2))) stuff, --- 58,78 ---- const char *none, const char *one, const char *many, ...) ! G_GNUC_PRINTF(5, 6); #endif int close_on_esc(GtkWidget *widget, GdkEventKey *event, gpointer obj); int func_on_esc(GtkWidget *widget, GdkEventKey *event, GtkWidget *window); ! ! struct tokenlist { ! int token; ! char keyword[32]; ! gpointer data; ! }; ! ! /* tokenlist funtions */ ! int tokenize(const struct tokenlist *list, const char *keyword); ! const char *detokenize(const struct tokenlist *list, int token); ! const gpointer detokenize_data(const struct tokenlist *list, int token); ! char *get_username(void); /* G_GNUC_PRINTF is the __attribute__ ((format (printf, 1, 2))) stuff, |
From: <sta...@us...> - 2003-10-09 05:19:43
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv6137 Modified Files: xmlparse.c Log Message: * Fixed a wrong conditional compilation: libxml2 does not have to correlate with gtk2. This is what we have HAVE_LIBXML2 for Index: xmlparse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/xmlparse.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** xmlparse.c 5 Oct 2003 22:19:09 -0000 1.5 --- xmlparse.c 9 Oct 2003 05:19:39 -0000 1.6 *************** *** 279,283 **** } ! #if GTK_MAJOR >= 2 static int inputReadCallback(FILE *context, char *buffer, --- 279,283 ---- } ! #ifdef HAVE_LIBXML2 static int inputReadCallback(FILE *context, char *buffer, *************** *** 316,320 **** int rc; int handler_is_local = 0; ! #if GTK_MAJOR >= 2 FILE *fp; #endif --- 316,320 ---- int rc; int handler_is_local = 0; ! #ifdef HAVE_LIBXML2 FILE *fp; #endif |
From: <sta...@us...> - 2003-10-09 05:18:13
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv6014 Modified Files: errorchain.h Log Message: * Use portable way to specify the printf format attribute for printf-style vararg function Index: errorchain.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/errorchain.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** errorchain.h 5 Oct 2003 13:38:06 -0000 1.7 --- errorchain.h 9 Oct 2003 05:18:10 -0000 1.8 *************** *** 31,36 **** int error_new_context(const char *title); ! void error_push_production(int context, const char *msg, ...) ! __attribute__ ((format (printf, 2, 3))); #ifdef DEBUG --- 31,37 ---- int error_new_context(const char *title); ! void error_push_production(int context, const char *msg, ...) ! G_GNUC_PRINTF(2, 3); ! /* __attribute__ ((format (printf, 2, 3))); */ #ifdef DEBUG |
From: <sta...@us...> - 2003-10-09 05:15:11
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv5388 Modified Files: dt_clist.c dt_time.c errorchain.c filter.c input.c mainwin.c prefs.c util.c Log Message: * Introduced GTK2 stock buttons. Those buttons have nice icons attached and make the GUI more friendly Index: dt_clist.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_clist.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dt_clist.c 29 Sep 2003 19:24:16 -0000 1.4 --- dt_clist.c 9 Oct 2003 05:15:06 -0000 1.5 *************** *** 193,197 **** gtk_box_pack_end(GTK_BOX(vbox), hbox1, FALSE, FALSE, 0); ! ok_button = gtk_button_new_with_label(_("OK")); gtk_widget_show(ok_button); gtk_box_pack_start(GTK_BOX(hbox1), ok_button, FALSE, FALSE, 0); --- 193,201 ---- gtk_box_pack_end(GTK_BOX(vbox), hbox1, FALSE, FALSE, 0); ! #if GTK_MAJOR >= 2 ! ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! ok_button = gq_button_new_with_label(_("_OK")); ! #endif gtk_widget_show(ok_button); gtk_box_pack_start(GTK_BOX(hbox1), ok_button, FALSE, FALSE, 0); Index: dt_time.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_time.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dt_time.c 29 Sep 2003 19:24:16 -0000 1.7 --- dt_time.c 9 Oct 2003 05:15:06 -0000 1.8 *************** *** 397,401 **** gtk_widget_show(hbox2); ! button2 = gtk_button_new_with_label(_("OK")); gtk_widget_show(button2); gtk_signal_connect(GTK_OBJECT(button2), "clicked", --- 397,405 ---- gtk_widget_show(hbox2); ! #if GTK_MAJOR >= 2 ! button2 = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! button2 = gq_button_new_with_label(_("_OK")); ! #endif gtk_widget_show(button2); gtk_signal_connect(GTK_OBJECT(button2), "clicked", *************** *** 406,410 **** gtk_widget_grab_default(button2); ! button2 = gtk_button_new_with_label(_("Cancel")); gtk_box_pack_end(GTK_BOX(hbox2), button2, FALSE, TRUE, 0); gtk_signal_connect_object(GTK_OBJECT(button2), "clicked", --- 410,418 ---- gtk_widget_grab_default(button2); ! #if GTK_MAJOR >= 2 ! button2 = gtk_button_new_from_stock(GTK_STOCK_CANCEL); ! #else ! button2 = gq_button_new_with_label(_("_Cancel")); ! #endif gtk_box_pack_end(GTK_BOX(hbox2), button2, FALSE, TRUE, 0); gtk_signal_connect_object(GTK_OBJECT(button2), "clicked", Index: errorchain.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/errorchain.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** errorchain.c 8 Oct 2003 22:01:07 -0000 1.15 --- errorchain.c 9 Oct 2003 05:15:06 -0000 1.16 *************** *** 268,272 **** gtk_widget_show(hbox0); ! okbutton = gtk_button_new_with_label(_("OK")); gtk_signal_connect_object(GTK_OBJECT(okbutton), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), --- 268,276 ---- gtk_widget_show(hbox0); ! #if GTK_MAJOR >= 2 ! okbutton = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! okbutton = gq_button_new_with_label(_("_OK")); ! #endif gtk_signal_connect_object(GTK_OBJECT(okbutton), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), Index: filter.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/filter.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** filter.c 5 Oct 2003 13:39:35 -0000 1.20 --- filter.c 9 Oct 2003 05:15:06 -0000 1.21 *************** *** 249,253 **** gtk_box_pack_start(GTK_BOX(vbox2), hbox0, TRUE, TRUE, 0); ! button = gtk_button_new_with_label(_("OK")); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(add_filter), GTK_OBJECT(filternamebox)); --- 249,257 ---- gtk_box_pack_start(GTK_BOX(vbox2), hbox0, TRUE, TRUE, 0); ! #if GTK_MAJOR >= 2 ! button = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! button = gq_button_new_with_label(_("_OK")); ! #endif gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(add_filter), GTK_OBJECT(filternamebox)); *************** *** 340,344 **** --- 344,352 ---- gtk_box_pack_start(GTK_BOX(hbox0), hbox1, FALSE, FALSE, 0); + #if GTK_MAJOR >= 2 + new_button = gtk_button_new_from_stock(GTK_STOCK_NEW); + #else new_button = gq_button_new_with_label(_("_New")); + #endif GTK_WIDGET_UNSET_FLAGS(new_button, GTK_CAN_DEFAULT); #ifdef OLD_FOCUS_HANDLING *************** *** 348,352 **** --- 356,364 ---- gtk_box_pack_start(GTK_BOX(hbox1), new_button, FALSE, FALSE, 0); + #if GTK_MAJOR >= 2 + delete_button = gtk_button_new_from_stock(GTK_STOCK_DELETE); + #else delete_button = gq_button_new_with_label(_("_Delete")); + #endif GTK_WIDGET_UNSET_FLAGS(delete_button, GTK_CAN_DEFAULT); #ifdef OLD_FOCUS_HANDLING *************** *** 356,360 **** --- 368,376 ---- gtk_box_pack_start(GTK_BOX(hbox1), delete_button, FALSE, FALSE, 5); + #if GTK_MAJOR >= 2 + copy_button = gtk_button_new_from_stock(GTK_STOCK_COPY); + #else copy_button = gq_button_new_with_label(_("_Copy")); + #endif GTK_WIDGET_UNSET_FLAGS(copy_button, GTK_CAN_DEFAULT); GTK_WIDGET_UNSET_FLAGS(copy_button, GTK_CAN_FOCUS); *************** *** 401,405 **** gtk_box_pack_start(GTK_BOX(vbox1), hbox2, FALSE, FALSE, 5); ! ok_button = gtk_button_new_with_label(_("OK")); gtk_widget_show(ok_button); gtk_box_pack_start(GTK_BOX(hbox2), ok_button, FALSE, FALSE, 0); --- 417,425 ---- gtk_box_pack_start(GTK_BOX(vbox1), hbox2, FALSE, FALSE, 5); ! #if GTK_MAJOR >= 2 ! ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! ok_button = gq_button_new_with_label(_("_OK")); ! #endif gtk_widget_show(ok_button); gtk_box_pack_start(GTK_BOX(hbox2), ok_button, FALSE, FALSE, 0); *************** *** 702,706 **** --- 722,730 ---- gtk_box_pack_start(GTK_BOX(vbox1), hbox2, FALSE, FALSE, 0); + #if GTK_MAJOR >= 2 + save = gtk_button_new_from_stock(GTK_STOCK_SAVE); + #else save = gq_button_new_with_label(_("_Save")); + #endif gtk_signal_connect_object(GTK_OBJECT(save), "clicked", GTK_SIGNAL_FUNC(save_filter), GTK_OBJECT(window)); *************** *** 711,715 **** gtk_widget_show(save); ! cancel = gtk_button_new_with_label(_("Cancel")); GTK_WIDGET_UNSET_FLAGS(cancel, GTK_CAN_FOCUS); gtk_box_pack_end(GTK_BOX(hbox2), cancel, FALSE, FALSE, 0); --- 735,743 ---- gtk_widget_show(save); ! #if GTK_MAJOR >= 2 ! cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); ! #else ! cancel = gq_button_new_with_label(_("_Cancel")); ! #endif GTK_WIDGET_UNSET_FLAGS(cancel, GTK_CAN_FOCUS); gtk_box_pack_end(GTK_BOX(hbox2), cancel, FALSE, FALSE, 0); Index: input.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.c,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** input.c 8 Oct 2003 22:01:10 -0000 1.61 --- input.c 9 Oct 2003 05:15:06 -0000 1.62 *************** *** 266,270 **** --- 266,274 ---- if(iform->edit) { + #if GTK_MAJOR >= 2 + button = gtk_button_new_from_stock(GTK_STOCK_APPLY); + #else button = gq_button_new_with_label(_("_Apply")); + #endif gtk_widget_show(button); gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 0); *************** *** 286,290 **** --- 290,298 ---- iform->add_as_new_button = button; + #if GTK_MAJOR >= 2 + button = gtk_button_new_from_stock(GTK_STOCK_REFRESH); + #else button = gq_button_new_with_label(_("_Refresh")); + #endif /* gtk_widget_set_sensitive(button, FALSE); */ /* GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); */ *************** *** 299,303 **** if(iform->close_window) { ! button = gtk_button_new_with_label(_("Close")); gtk_widget_show(button); gtk_box_pack_end(GTK_BOX(hbox2), button, FALSE, FALSE, 0); --- 307,315 ---- if(iform->close_window) { ! #if GTK_MAJOR >= 2 ! button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); ! #else ! button = gq_button_new_with_label(_("_Close")); ! #endif gtk_widget_show(button); gtk_box_pack_end(GTK_BOX(hbox2), button, FALSE, FALSE, 0); *************** *** 315,319 **** } else { ! button = gtk_button_new_with_label(_("OK")); gtk_widget_show(button); gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 0); --- 327,335 ---- } else { ! #if GTK_MAJOR >= 2 ! button = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! button = gq_button_new_with_label(_("_OK")); ! #endif gtk_widget_show(button); gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 0); *************** *** 337,341 **** /* (gpointer) iform); */ ! button = gtk_button_new_with_label(_("Cancel")); gtk_widget_show(button); gtk_box_pack_end(GTK_BOX(hbox2), button, FALSE, FALSE, 0); --- 353,361 ---- /* (gpointer) iform); */ ! #if GTK_MAJOR >= 2 ! button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); ! #else ! button = gq_button_new_with_label(_("_Cancel")); ! #endif gtk_widget_show(button); gtk_box_pack_end(GTK_BOX(hbox2), button, FALSE, FALSE, 0); *************** *** 2047,2051 **** gtk_box_pack_start(GTK_BOX(vbox2), hbox0, TRUE, TRUE, 0); ! button = gtk_button_new_with_label(_("OK")); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(attr_ok), &comm); --- 2067,2075 ---- gtk_box_pack_start(GTK_BOX(vbox2), hbox0, TRUE, TRUE, 0); ! #if GTK_MAJOR >= 2 ! button = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! button = gq_button_new_with_label(_("_OK")); ! #endif gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(attr_ok), &comm); *************** *** 2056,2060 **** gtk_widget_show(button); ! button = gtk_button_new_with_label(_("Cancel")); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(attr_cancel), --- 2080,2088 ---- gtk_widget_show(button); ! #if GTK_MAJOR >= 2 ! button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); ! #else ! button = gq_button_new_with_label(_("_Cancel")); ! #endif gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(attr_cancel), Index: mainwin.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/mainwin.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** mainwin.c 5 Oct 2003 22:21:37 -0000 1.37 --- mainwin.c 9 Oct 2003 05:15:06 -0000 1.38 *************** *** 675,679 **** gtk_box_pack_start(GTK_BOX(vbox2), hbox0, TRUE, FALSE, 0); ! ok_button = gtk_button_new_with_label(_("OK")); gtk_widget_show(ok_button); gtk_box_pack_start(GTK_BOX(hbox0), ok_button, --- 675,683 ---- gtk_box_pack_start(GTK_BOX(vbox2), hbox0, TRUE, FALSE, 0); ! #if GTK_MAJOR >= 2 ! ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! ok_button = gq_button_new_with_label(_("_OK")); ! #endif gtk_widget_show(ok_button); gtk_box_pack_start(GTK_BOX(hbox0), ok_button, *************** *** 762,766 **** TRUE, FALSE, 0); ! about_ok_button = gtk_button_new_with_label(_("OK")); gtk_widget_show(about_ok_button); gtk_box_pack_start(GTK_BOX(hbox0), about_ok_button, --- 766,774 ---- TRUE, FALSE, 0); ! #if GTK_MAJOR >= 2 ! about_ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! about_ok_button = gq_button_new_with_label(_("_OK")); ! #endif gtk_widget_show(about_ok_button); gtk_box_pack_start(GTK_BOX(hbox0), about_ok_button, Index: prefs.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/prefs.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** prefs.c 5 Oct 2003 22:20:58 -0000 1.35 --- prefs.c 9 Oct 2003 05:15:06 -0000 1.36 *************** *** 900,904 **** gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, TRUE, 10); ! okbutton = gtk_button_new_with_label(_("OK")); gtk_widget_show(okbutton); gtk_signal_connect(GTK_OBJECT(okbutton), "clicked", --- 900,908 ---- gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, TRUE, 10); ! #if GTK_MAJOR >= 2 ! okbutton = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! okbutton = gq_button_new_with_label(_("_OK")); ! #endif gtk_widget_show(okbutton); gtk_signal_connect(GTK_OBJECT(okbutton), "clicked", *************** *** 909,913 **** gtk_widget_grab_default(okbutton); ! cancelbutton = gtk_button_new_with_label(_("Cancel")); gtk_widget_show(cancelbutton); gtk_signal_connect(GTK_OBJECT(cancelbutton), "clicked", --- 913,921 ---- gtk_widget_grab_default(okbutton); ! #if GTK_MAJOR >= 2 ! cancelbutton = gtk_button_new_from_stock(GTK_STOCK_CANCEL); ! #else ! cancelbutton = gq_button_new_with_label(_("_Cancel")); ! #endif gtk_widget_show(cancelbutton); gtk_signal_connect(GTK_OBJECT(cancelbutton), "clicked", *************** *** 1206,1210 **** /* gtk_container_border_width(GTK_CONTAINER(hbox_buttons), 10); */ ! okbutton = gtk_button_new_with_label(_("OK")); gtk_widget_show(okbutton); gtk_signal_connect_object(GTK_OBJECT(okbutton), "clicked", --- 1214,1222 ---- /* gtk_container_border_width(GTK_CONTAINER(hbox_buttons), 10); */ ! #if GTK_MAJOR >= 2 ! okbutton = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! okbutton = gq_button_new_with_label(_("_OK")); ! #endif gtk_widget_show(okbutton); gtk_signal_connect_object(GTK_OBJECT(okbutton), "clicked", *************** *** 1216,1220 **** gtk_widget_grab_default(okbutton); ! cancelbutton = gtk_button_new_with_label(_("Cancel")); gtk_widget_show(cancelbutton); gtk_box_pack_end(GTK_BOX(hbox_buttons), cancelbutton, FALSE, TRUE, 0); --- 1228,1236 ---- gtk_widget_grab_default(okbutton); ! #if GTK_MAJOR >= 2 ! cancelbutton = gtk_button_new_from_stock(GTK_STOCK_CANCEL); ! #else ! cancelbutton = gq_button_new_with_label(_("_Cancel")); ! #endif gtk_widget_show(cancelbutton); gtk_box_pack_end(GTK_BOX(hbox_buttons), cancelbutton, FALSE, TRUE, 0); *************** *** 1277,1281 **** --- 1293,1303 ---- /* New button */ + + #if GTK_MAJOR >= 2 + button_new = gtk_button_new_from_stock(GTK_STOCK_NEW); + #else button_new = gq_button_new_with_label(_("_New")); + #endif + #ifdef OLD_FOCUS_HANDLING GTK_WIDGET_UNSET_FLAGS(button_new, GTK_CAN_FOCUS); *************** *** 1391,1395 **** --- 1413,1422 ---- /* New button */ + #if GTK_MAJOR >= 2 + button_new = gtk_button_new_from_stock(GTK_STOCK_NEW); + #else button_new = gq_button_new_with_label(_("_New")); + #endif + #ifdef OLD_FOCUS_HANDLING GTK_WIDGET_UNSET_FLAGS(button_new, GTK_CAN_FOCUS); *************** *** 1415,1419 **** --- 1442,1450 ---- /* Delete button */ + #if GTK_MAJOR >= 2 + button_delete = gtk_button_new_from_stock(GTK_STOCK_DELETE); + #else button_delete = gq_button_new_with_label(_("_Delete")); + #endif #ifdef OLD_FOCUS_HANDLING GTK_WIDGET_UNSET_FLAGS(button_delete, GTK_CAN_FOCUS); Index: util.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.c,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** util.c 8 Oct 2003 22:01:13 -0000 1.63 --- util.c 9 Oct 2003 05:15:06 -0000 1.64 *************** *** 968,972 **** gtk_box_pack_start(GTK_BOX(vbox3), hbox0, TRUE, TRUE, 0); ! ok_button = gtk_button_new_with_label(_("OK")); gtk_signal_connect_object(GTK_OBJECT(ok_button), "clicked", (GtkSignalFunc) gtk_widget_destroy, --- 968,976 ---- gtk_box_pack_start(GTK_BOX(vbox3), hbox0, TRUE, TRUE, 0); ! #if GTK_MAJOR >= 2 ! ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! ok_button = gq_button_new_with_label(_("_OK")); ! #endif gtk_signal_connect_object(GTK_OBJECT(ok_button), "clicked", (GtkSignalFunc) gtk_widget_destroy, *************** *** 1329,1333 **** gtk_box_pack_start(GTK_BOX(vbox2), hbox0, TRUE, TRUE, 0); ! button = gtk_button_new_with_label(_("OK")); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(query_ok), GTK_OBJECT(comm)); --- 1333,1342 ---- gtk_box_pack_start(GTK_BOX(vbox2), hbox0, TRUE, TRUE, 0); ! #if GTK_MAJOR >= 2 ! button = gtk_button_new_from_stock(GTK_STOCK_OK); ! #else ! button = gq_button_new_with_label(_("_OK")); ! #endif ! gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(query_ok), GTK_OBJECT(comm)); *************** *** 1338,1342 **** gtk_widget_show(button); ! button = gtk_button_new_with_label(_("Cancel")); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(query_cancel), --- 1347,1356 ---- gtk_widget_show(button); ! #if GTK_MAJOR >= 2 ! button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); ! #else ! button = gq_button_new_with_label(_("_Cancel")); ! #endif ! gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(query_cancel), |
From: <sta...@us...> - 2003-10-08 22:58:50
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv17712 Modified Files: dt_binary.c Log Message: * Fixed an un-needed translation Index: dt_binary.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_binary.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dt_binary.c 29 Sep 2003 19:24:16 -0000 1.12 --- dt_binary.c 8 Oct 2003 22:58:46 -0000 1.13 *************** *** 181,185 **** for(i = 0; encodings[i].token ; i++) { ! item = gtk_radio_menu_item_new_with_label(group, _(encodings[i].keyword)); group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(item)); --- 181,187 ---- for(i = 0; encodings[i].token ; i++) { ! item = gtk_radio_menu_item_new_with_label(group, ! encodings[i].keyword); ! group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(item)); |
From: <sta...@us...> - 2003-10-08 22:51:57
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv15890 Modified Files: configfile.c state.c configfile.h Log Message: * Make the writeconfig more OO (new_writeconfig, frer_writeconfig) * Never overwrite any configfile, wrtie temp and rename Index: configfile.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/configfile.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** configfile.c 5 Oct 2003 22:24:47 -0000 1.36 --- configfile.c 8 Oct 2003 22:51:53 -0000 1.37 *************** *** 233,236 **** --- 233,252 ---- } + struct writeconfig *new_writeconfig() + { + struct writeconfig *wc = g_malloc0(sizeof(struct writeconfig)); + wc->indent = 0; + wc->outfile = NULL; + return wc; + } + + void free_writeconfig(struct writeconfig *wc) + { + if (wc) { + if (wc->outfile) fclose(wc->outfile); + wc->outfile = NULL; + } + g_free(wc); + } /* just a pretty printer */ *************** *** 349,354 **** } ! wc = MALLOC(sizeof(struct writeconfig), "struct writeconfig"); ! wc->indent = 0; /* write to temp file... */ --- 365,369 ---- } ! wc = new_writeconfig(); /* write to temp file... */ *************** *** 527,546 **** config_write(wc, "</gq-config>\n"); ! fclose(wc->outfile); ! FREE(wc, "struct writeconfig"); /* rename temp to final config file */ ! if (rename(tmprcpath, rcpath) != 0) { error_push(write_context, _("Could not replace old configuration (%1$s) with the new one (%2$s):\n%3$s\n"), rcpath, tmprcpath, strerror(errno)); - g_free(tmprcpath); - return; } g_free(tmprcpath); - - cfg->changed = 0; } --- 542,558 ---- config_write(wc, "</gq-config>\n"); ! free_writeconfig(wc); /* rename temp to final config file */ ! if (rename(tmprcpath, rcpath) == 0) { ! cfg->changed = 0; ! } else { error_push(write_context, _("Could not replace old configuration (%1$s) with the new one (%2$s):\n%3$s\n"), rcpath, tmprcpath, strerror(errno)); } g_free(tmprcpath); } Index: state.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/state.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** state.c 5 Oct 2003 22:15:31 -0000 1.1 --- state.c 8 Oct 2003 22:51:53 -0000 1.2 *************** *** 26,36 **** */ - - /* A hash mapping state-names to hashes containing mappings of - settings to lists of values. - - This is not elegant, but just the data structure required. - */ - #include "config.h" #include <stdlib.h> --- 26,29 ---- *************** *** 265,274 **** if (config->restore_window_sizes) { ! gtk_window_set_default_size(GTK_WINDOW(wid), ! lookup_state_value_get_int(name, ! "width", w), ! lookup_state_value_get_int(name, ! "height", h)); ! } else { gtk_window_set_default_size(GTK_WINDOW(wid), w, h); } --- 258,266 ---- if (config->restore_window_sizes) { ! w = lookup_state_value_get_int(name, "width", w); ! h = lookup_state_value_get_int(name, "height", h); ! } ! ! if (w != -1 && h != -1) { gtk_window_set_default_size(GTK_WINDOW(wid), w, h); } *************** *** 311,316 **** } - - static void save_single_value(const char *value_name, struct state_value *v, --- 303,306 ---- *************** *** 385,390 **** } ! wc = g_malloc0(sizeof(struct writeconfig)); ! wc->indent = 0; /* write to temp file... */ --- 375,379 ---- } ! wc = new_writeconfig(); /* write to temp file... */ *************** *** 435,442 **** config_write(wc, "</gq-state>\n"); ! fclose(wc->outfile); ! g_free(wc); ! rename(tmpstatefile, statefile); g_free(tmpstatefile); } --- 424,435 ---- config_write(wc, "</gq-state>\n"); ! free_writeconfig(wc); ! if (rename(tmpstatefile, statefile) != 0) { ! error_push(save_context, ! _("Could not replace old configuration (%1$s) with the new one (%2$s):\n%3$s\n"), ! statefile, tmpstatefile, strerror(errno)); ! } ! g_free(tmpstatefile); } *************** *** 553,558 **** } } - - static struct xml_tag state_tags[] = { --- 546,549 ---- Index: configfile.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/configfile.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** configfile.h 5 Oct 2003 22:24:47 -0000 1.25 --- configfile.h 8 Oct 2003 22:51:53 -0000 1.26 *************** *** 119,122 **** --- 119,125 ---- + struct writeconfig *new_writeconfig(); + void free_writeconfig(struct writeconfig *wc); + void config_write(struct writeconfig *wc, const char *string); void config_write_bool(struct writeconfig *wc, |
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv5544 Modified Files: browse-dnd.c browse.c dt_oc.c errorchain.c formfill.c input.c schema.c schemabrowse.c search.c tinput.c util.c util.h Log Message: * The statusbar_msg function now takes a printf style format and arguments. This is great whereever we used to allocate a message buffer for a variable message, filled it out, called statusbar_msg and free'd the message buffer again. It also helps with too short message-buffers * changed all calls to statusbar_msg to the new interface, getting rid of message buffers along the way * fixed a nasty bug in error_free regarding the deleting of an error context Index: browse-dnd.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/browse-dnd.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** browse-dnd.c 28 Sep 2003 23:01:52 -0000 1.13 --- browse-dnd.c 8 Oct 2003 22:01:04 -0000 1.14 *************** *** 478,487 **** const char *new_dn) { ! int len = strlen(from_dn) + strlen(to_dn) + 80; ! char *msg = g_malloc(len); ! /* snprintf(msg, len, "Moved %s to %s", from_dn, to_dn); */ ! snprintf(msg, len, _("Created %s"), new_dn); ! statusbar_msg(msg); ! g_free(msg); } --- 478,482 ---- const char *new_dn) { ! statusbar_msg(_("Created %s"), new_dn); } Index: browse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/browse.c,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** browse.c 5 Oct 2003 13:25:59 -0000 1.72 --- browse.c 8 Oct 2003 22:01:04 -0000 1.73 *************** *** 202,215 **** #if GTK_MAJOR < 2 ! snprintf(message, sizeof(message), ! _("onelevel search on %s"), ! c = decoded_string(entry->dn)); if (c) free(c); #else ! snprintf(message, sizeof(message), ! _("onelevel search on %s"), entry->dn); #endif - statusbar_msg(message); msg = ldap_search(ld, entry->dn, LDAP_SCOPE_ONELEVEL, --- 202,212 ---- #if GTK_MAJOR < 2 ! statusbar_msg(_("onelevel search on %s"), ! c = decoded_string(entry->dn)); if (c) free(c); #else ! statusbar_msg(_("onelevel search on %s"), entry->dn); #endif msg = ldap_search(ld, entry->dn, LDAP_SCOPE_ONELEVEL, *************** *** 217,221 **** if(msg == -1) { ! statusbar_msg(ldap_err2string(msg)); close_connection(server, FALSE); gtk_clist_thaw(GTK_CLIST(ctree)); --- 214,218 ---- if(msg == -1) { ! statusbar_msg("%s", ldap_err2string(msg)); close_connection(server, FALSE); gtk_clist_thaw(GTK_CLIST(ctree)); *************** *** 239,246 **** update_counter++; if(update_counter >= 100) { ! snprintf(message, sizeof(message), ! ngettext("One entry found (running)", ! "%d entries found (running)", ! num_children), num_children); /* make_message(message, sizeof(message), */ --- 236,242 ---- update_counter++; if(update_counter >= 100) { ! statusbar_msg(ngettext("One entry found (running)", ! "%d entries found (running)", ! num_children), num_children); /* make_message(message, sizeof(message), */ *************** *** 249,253 **** /* _("%d entries found (running)"), */ /* num_children); */ ! statusbar_msg(message); update_counter = 0; } --- 245,249 ---- /* _("%d entries found (running)"), */ /* num_children); */ ! update_counter = 0; } *************** *** 1001,1005 **** struct ldapserver *server; int server_cnt = 0; - char message[128]; GList *I; --- 997,1000 ---- *************** *** 1010,1020 **** } ! snprintf(message, sizeof(message), ! ngettext("One server found", ! "%d servers found", server_cnt), ! server_cnt); ! ! statusbar_msg(message); ! } --- 1005,1011 ---- } ! statusbar_msg(ngettext("One server found", ! "%d servers found", server_cnt), ! server_cnt); } *************** *** 1099,1103 **** GtkCTreeNode *node; struct ldapserver *server; - char msg[256]; ctree = BROWSETAB(tab)->ctreeroot; --- 1090,1093 ---- *************** *** 1106,1114 **** close_connection(server, TRUE); ! snprintf(msg, sizeof(msg), _("Closed connection to server %s"), ! server->name); ! ! statusbar_msg(msg); ! } --- 1096,1100 ---- close_connection(server, TRUE); ! statusbar_msg(_("Closed connection to server %s"), server->name); } *************** *** 1796,1801 **** gmessage = g_string_sized_new(256); for (I = g_list_first(bases) ; I ; I = g_list_next(I)) { ! g_string_sprintf(gmessage, _("subtree search on %s"), (char *) I->data); ! statusbar_msg(gmessage->str); msg = ldap_search_s(ld, (char *) I->data, LDAP_SCOPE_SUBTREE, --- 1782,1786 ---- gmessage = g_string_sized_new(256); for (I = g_list_first(bases) ; I ; I = g_list_next(I)) { ! statusbar_msg(_("subtree search on %s"), (char *) I->data); msg = ldap_search_s(ld, (char *) I->data, LDAP_SCOPE_SUBTREE, *************** *** 1840,1849 **** } ! snprintf(message, sizeof(message), ! ngettext("One entry exported to %2$s", ! "%1$d entries exported to %2$s", num_entries), ! num_entries, filename); ! ! statusbar_msg(message); } --- 1825,1831 ---- } ! statusbar_msg(ngettext("One entry exported to %2$s", ! "%1$d entries exported to %2$s", num_entries), ! num_entries, filename); } Index: dt_oc.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_oc.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** dt_oc.c 5 Oct 2003 13:36:11 -0000 1.16 --- dt_oc.c 8 Oct 2003 22:01:07 -0000 1.17 *************** *** 201,205 **** LDAPAttributeType *at; char **cp; - char msg[80]; /* printf("changed: %s->%s\n", oldtext, newtext); */ --- 201,204 ---- *************** *** 342,348 **** } } ! snprintf(msg, sizeof(msg), ! _("Marked %d attribute(s) to be obsolete"), n); ! statusbar_msg(msg); } } --- 341,345 ---- } } ! statusbar_msg(_("Marked %d attribute(s) to be obsolete"), n); } } *************** *** 415,421 **** ci->iform->formlist = formlist; } ! snprintf(msg, sizeof(msg), ! _("Added %d attribute(s) from new objectClass"), n); ! statusbar_msg(msg); g_free(oldtext); --- 412,416 ---- ci->iform->formlist = formlist; } ! statusbar_msg(_("Added %d attribute(s) from new objectClass"), n); g_free(oldtext); Index: errorchain.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/errorchain.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** errorchain.c 5 Oct 2003 13:38:06 -0000 1.14 --- errorchain.c 8 Oct 2003 22:01:07 -0000 1.15 *************** *** 177,187 **** { struct errchain *chain; - GList *I; chain = error_chain_by_context(context); assert(chain); ! I = g_list_find(chains, chain); ! chains = g_list_remove(chains, I); free_errchain(chain); --- 177,185 ---- { struct errchain *chain; chain = error_chain_by_context(context); assert(chain); ! chains = g_list_remove(chains, chain); free_errchain(chain); Index: formfill.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/formfill.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** formfill.c 5 Oct 2003 13:40:53 -0000 1.37 --- formfill.c 8 Oct 2003 22:01:08 -0000 1.38 *************** *** 167,171 **** { GList *formlist; - GString *message; LDAP *ld; LDAPMessage *res, *entry; --- 167,170 ---- *************** *** 183,200 **** set_busycursor(); - message = g_string_sized_new(128); #if GTK_MAJOR >= 2 ! g_string_sprintf(message, _("fetching %1$s from %2$s"), ! dn, server->name); #else { char *c = NULL; ! g_string_sprintf(message, _("fetching %1$s from %2$s"), ! c = decoded_string(dn), server->name); if (c) free(c); } #endif - statusbar_msg(message->str); - g_string_free(message, TRUE); if( (ld = open_connection(server)) == NULL) { --- 182,195 ---- set_busycursor(); #if GTK_MAJOR >= 2 ! statusbar_msg(_("fetching %1$s from %2$s"), dn, server->name); #else { char *c = NULL; ! statusbar_msg(_("fetching %1$s from %2$s"), ! c = decoded_string(dn), server->name); if (c) free(c); } #endif if( (ld = open_connection(server)) == NULL) { *************** *** 211,215 **** if(msg != LDAP_SUCCESS) { ! statusbar_msg(ldap_err2string(msg)); set_normalcursor(); close_connection(server, FALSE); --- 206,210 ---- if(msg != LDAP_SUCCESS) { ! statusbar_msg("%s", ldap_err2string(msg)); set_normalcursor(); close_connection(server, FALSE); Index: input.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.c,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** input.c 5 Oct 2003 13:43:39 -0000 1.60 --- input.c 8 Oct 2003 22:01:10 -0000 1.61 *************** *** 348,352 **** } ! statusbar_msg(""); error_flush(detail_context); } --- 348,352 ---- } ! statusbar_msg_clear(); error_flush(detail_context); } *************** *** 1228,1232 **** { GList *newlist, *oldlist; - GString *message; LDAPMod **mods; LDAP *ld; --- 1228,1231 ---- *************** *** 1249,1261 **** dn = iform->dn; ! /* prepare message with olddn - in case we change the DN */ ! message = g_string_sized_new(256); ! #if GTK_MAJOR >= 2 ! g_string_sprintfa(message, _("modified %s"), iform->olddn); ! #else ! c = decoded_string(iform->olddn); ! g_string_sprintfa(message, _("modified %s"), c); ! if(c) free(c); ! #endif /* obtain all needed stuff from the iform ASAP, as it might be --- 1248,1253 ---- dn = iform->dn; ! /* store olddn to use with message later on - in case we change the DN */ ! olddn = g_strdup(iform->olddn); /* obtain all needed stuff from the iform ASAP, as it might be *************** *** 1271,1275 **** if( (ld = open_connection(server)) == NULL) { ! g_string_free(message, TRUE); return; } --- 1263,1267 ---- if( (ld = open_connection(server)) == NULL) { ! g_free(olddn); return; } *************** *** 1293,1299 **** error = 1; goto done; } - statusbar_msg(message->str); } --- 1285,1291 ---- error = 1; + g_free(olddn); goto done; } } *************** *** 1324,1330 **** } /* free memory */ ! statusbar_msg(message->str); if(iform->close_window) destroy_editwindow(iform); --- 1316,1331 ---- } + + #if GTK_MAJOR >= 2 + statusbar_msg(_("modified %s"), olddn); + #else + c = decoded_string(olddn); + statusbar_msg(_("modified %s"), c); + if(c) free(c); + #endif /* free memory */ ! g_free(olddn); ! if(iform->close_window) destroy_editwindow(iform); *************** *** 1338,1342 **** close_connection(server, FALSE); - if (message) g_string_free(message, TRUE); /* refresh visual if requested by browse mode */ --- 1339,1342 ---- *************** *** 1344,1351 **** refresh_subtree_new_dn(ctreeroot, node, dn, 0); } - } - int change_rdn(struct inputform *iform, int context) { --- 1344,1349 ---- *************** *** 1400,1410 **** if(!error) { #if GTK_MAJOR >= 2 ! g_string_sprintfa(message, _("modifying RDN to %s"), rdn[0]); #else ! g_string_sprintfa(message, _("modifying RDN to %s"), ! c = decoded_string(rdn[0])); if (c) free(c); #endif - statusbar_msg(message->str); /* check to see if the rdn exists as an attribute. If it --- 1398,1407 ---- if(!error) { #if GTK_MAJOR >= 2 ! statusbar_msg(_("modifying RDN to %s"), rdn[0]); #else ! statusbar_msg(_("modifying RDN to %s"), ! c = decoded_string(rdn[0])); if (c) free(c); #endif /* check to see if the rdn exists as an attribute. If it Index: schema.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/schema.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** schema.c 4 Oct 2003 09:59:09 -0000 1.18 --- schema.c 8 Oct 2003 22:01:12 -0000 1.19 *************** *** 97,101 **** char *attr, **vals; const char *errp; ! char subschema[60], message[80]; char *subschemasubentry[] = { "subschemaSubentry", NULL }; --- 97,101 ---- char *attr, **vals; const char *errp; ! char subschema[100]; char *subschemasubentry[] = { "subschemaSubentry", NULL }; *************** *** 124,128 **** server->server_down++; } ! statusbar_msg(ldap_err2string(msg)); close_connection(server, FALSE); return(NULL); --- 124,128 ---- server->server_down++; } ! statusbar_msg("%s", ldap_err2string(msg)); close_connection(server, FALSE); return(NULL); *************** *** 130,134 **** if(res == NULL) { ! statusbar_msg(_("no schema information found")); close_connection(server, FALSE); return(NULL); --- 130,134 ---- if(res == NULL) { ! statusbar_msg("%s", _("no schema information found")); close_connection(server, FALSE); return(NULL); *************** *** 153,163 **** if(subschema[0] == 0) { ! statusbar_msg(_("no schema information found")); close_connection(server, FALSE); return(NULL); } ! snprintf(message, sizeof(message), _("Schema search on %s"), subschema); ! statusbar_msg(message); msg = ldap_search_s(ld, subschema, LDAP_SCOPE_BASE, "(objectclass=*)", schema_attrs, 0, &res); --- 153,163 ---- if(subschema[0] == 0) { ! statusbar_msg("%s", _("no schema information found")); close_connection(server, FALSE); return(NULL); } ! statusbar_msg(_("Schema search on %s"), subschema); ! msg = ldap_search_s(ld, subschema, LDAP_SCOPE_BASE, "(objectclass=*)", schema_attrs, 0, &res); *************** *** 167,171 **** server->server_down++; } ! statusbar_msg(ldap_err2string(msg)); close_connection(server, FALSE); return(NULL); --- 167,171 ---- server->server_down++; } ! statusbar_msg("%s", ldap_err2string(msg)); close_connection(server, FALSE); return(NULL); *************** *** 173,177 **** if(res == NULL) { ! statusbar_msg(_("no schema information found")); close_connection(server, FALSE); return(NULL); --- 173,177 ---- if(res == NULL) { ! statusbar_msg("%s", _("no schema information found")); close_connection(server, FALSE); return(NULL); Index: schemabrowse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/schemabrowse.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** schemabrowse.c 5 Oct 2003 13:46:50 -0000 1.18 --- schemabrowse.c 8 Oct 2003 22:01:12 -0000 1.19 *************** *** 112,116 **** struct ldapserver *server; int server_cnt = 0; - char message[128]; GList *I; --- 112,115 ---- *************** *** 121,129 **** } ! snprintf(message, sizeof(message), ! ngettext("One server found", "%d servers found", server_cnt), ! server_cnt); ! ! statusbar_msg(message); } --- 120,126 ---- } ! statusbar_msg(ngettext("One server found", "%d servers found", ! server_cnt), ! server_cnt); } *************** *** 390,394 **** GTK_SIGNAL_FUNC(attach_server_schema), NULL); } - } --- 387,390 ---- *************** *** 668,672 **** gtk_widget_show(scrwin); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrwin), ! GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); /* just about right for four lines in the top clist */ --- 664,669 ---- gtk_widget_show(scrwin); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrwin), ! GTK_POLICY_AUTOMATIC, ! GTK_POLICY_AUTOMATIC); /* just about right for four lines in the top clist */ Index: search.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/search.c,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** search.c 6 Oct 2003 06:42:06 -0000 1.41 --- search.c 8 Oct 2003 22:01:12 -0000 1.42 *************** *** 426,430 **** struct attrs *attrlist; gchar *cur_servername, *cur_searchbase, *enc_searchbase, *querystring, *cl[MAX_NUM_ATTRIBUTES]; ! char tolist[MAX_NUM_ATTRIBUTES][128], message[MAX_LDAPFILTER_LEN + 128]; char *filter, *attr, *dn, **vals, *searchterm; int msg, rc, i, row; --- 426,430 ---- struct attrs *attrlist; gchar *cur_servername, *cur_searchbase, *enc_searchbase, *querystring, *cl[MAX_NUM_ATTRIBUTES]; ! char tolist[MAX_NUM_ATTRIBUTES][128]; char *filter, *attr, *dn, **vals, *searchterm; int msg, rc, i, row; *************** *** 469,474 **** free(querystring); ! snprintf(message, sizeof(message), _("searching for %s"), filter); ! statusbar_msg(message); searchbase_combo = SEARCHTAB(tab)->searchbase_combo; --- 469,473 ---- free(querystring); ! statusbar_msg(_("searching for %s"), filter); searchbase_combo = SEARCHTAB(tab)->searchbase_combo; *************** *** 491,495 **** server->server_down++; } ! statusbar_msg(ldap_err2string(msg == -1 ? LDAP_OTHER : msg)); g_free(searchterm); close_connection(server, FALSE); --- 490,494 ---- server->server_down++; } ! statusbar_msg("%s", ldap_err2string(msg == -1 ? LDAP_OTHER : msg)); g_free(searchterm); close_connection(server, FALSE); *************** *** 657,666 **** if(rc == -1) ! statusbar_msg(ldap_err2string(msg)); else { ! snprintf(message, sizeof(message), ! ngettext("One entry found", "%d entries found", row), ! row); ! statusbar_msg(message); } --- 656,663 ---- if(rc == -1) ! statusbar_msg("%s", ldap_err2string(msg)); else { ! statusbar_msg(ngettext("One entry found", "%d entries found", row), ! row); } Index: tinput.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/tinput.c,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** tinput.c 2 Oct 2003 16:16:26 -0000 1.40 --- tinput.c 8 Oct 2003 22:01:12 -0000 1.41 *************** *** 119,123 **** server->server_down++; } ! statusbar_msg(ldap_err2string(msg)); set_normalcursor(); close_connection(server, FALSE); --- 119,123 ---- server->server_down++; } ! statusbar_msg("%s", ldap_err2string(msg)); set_normalcursor(); close_connection(server, FALSE); Index: util.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.c,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** util.c 5 Oct 2003 13:51:35 -0000 1.62 --- util.c 8 Oct 2003 22:01:13 -0000 1.63 *************** *** 216,220 **** _("GQ was compiled without Kerberos support.\n" "Run 'configure --help' for more information\n")); ! statusbar_msg(""); ldap_unbind(ld); ld = NULL; --- 216,220 ---- _("GQ was compiled without Kerberos support.\n" "Run 'configure --help' for more information\n")); ! statusbar_msg_clear(); ldap_unbind(ld); ld = NULL; *************** *** 228,232 **** _("GQ was compiled without SASL support.\n" "Run 'configure --help' for more information\n")); ! statusbar_msg(""); ldap_unbind(ld); ld = NULL; --- 228,232 ---- _("GQ was compiled without SASL support.\n" "Run 'configure --help' for more information\n")); ! statusbar_msg_clear(); ldap_unbind(ld); ld = NULL; *************** *** 250,254 **** ldap_err2string(rc)); push_ldap_addl_error(ld, open_context); ! statusbar_msg(""); /* might as well clean this up */ ldap_unbind(ld); --- 250,254 ---- ldap_err2string(rc)); push_ldap_addl_error(ld, open_context); ! statusbar_msg_clear(); /* might as well clean this up */ ldap_unbind(ld); *************** *** 343,354 **** if(server->ldapport == 389) { ! snprintf(message, sizeof(message), ! _("connecting to %s"), server->ldaphost); } else { ! snprintf(message, sizeof(message), ! _("connecting to %1$s port %2$d"), ! server->ldaphost, server->ldapport); } - statusbar_msg(message); ld = NULL; --- 343,351 ---- if(server->ldapport == 389) { ! statusbar_msg(_("connecting to %s"), server->ldaphost); } else { ! statusbar_msg(_("connecting to %1$s port %2$d"), ! server->ldaphost, server->ldapport); } ld = NULL; *************** *** 522,527 **** } ! snprintf(message, sizeof(message), _("deleting: %s"), dn); ! statusbar_msg(message); msg = ldap_delete_s(ld, dn); --- 519,523 ---- } ! statusbar_msg(_("deleting: %s"), dn); msg = ldap_delete_s(ld, dn); *************** *** 537,543 **** } else { ! snprintf(message, sizeof(message), ! _("deleted %s"), dn); ! statusbar_msg(message); } --- 533,537 ---- } else { ! statusbar_msg(_("deleted %s"), dn); } *************** *** 713,725 **** * GTK event queue */ ! void statusbar_msg(const char *message) { ! if(!context) ! context = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), ! "mainwin"); ! if(msgid) ! gtk_statusbar_remove(GTK_STATUSBAR(statusbar), context, msgid); ! msgid = gtk_statusbar_push(GTK_STATUSBAR(statusbar), context, message); /* make sure statusbar gets updated right away */ --- 707,745 ---- * GTK event queue */ ! void statusbar_msg(const char *fmt, ...) { ! /* do not use g_string_sprintf, as it usually does not support ! numbered arguments */ ! int len = strlen(fmt) * 2; ! char *buf; ! int n; ! if (len > 0) { ! for (;;) { ! va_list ap; ! buf = g_malloc(len); ! *buf = 0; ! ! va_start(ap, fmt); ! n = vsnprintf(buf, len, fmt, ap); ! va_end(ap); ! ! if (n > len || n == -1) { ! g_free(buf); ! len *= 2; ! continue; ! } ! break; ! } ! } else { ! buf = g_strdup(""); ! } ! ! statusbar_msg_clear(); ! ! msgid = gtk_statusbar_push(GTK_STATUSBAR(mainwin.statusbar), ! context, buf); ! ! g_free(buf); /* make sure statusbar gets updated right away */ *************** *** 728,731 **** --- 748,763 ---- } + void statusbar_msg_clear() + { + if(!context) + context = + gtk_statusbar_get_context_id(GTK_STATUSBAR(mainwin.statusbar), + "mainwin"); + if(msgid) + gtk_statusbar_remove(GTK_STATUSBAR(mainwin.statusbar), + context, msgid); + } + + #if 0 /* not needed anymore */ /* * display message in main window's statusbar, and flushes the *************** *** 744,753 **** if(!context) ! context = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "mainwin"); if(msgid) ! gtk_statusbar_remove(GTK_STATUSBAR(statusbar), context, msgid); ! msgid = gtk_statusbar_push(GTK_STATUSBAR(statusbar), context, buf); /* make sure statusbar gets updated right away */ --- 776,785 ---- if(!context) ! context = gtk_statusbar_get_context_id(GTK_STATUSBAR(mainwin.statusbar), "mainwin"); if(msgid) ! gtk_statusbar_remove(GTK_STATUSBAR(mainwin.statusbar), context, msgid); ! msgid = gtk_statusbar_push(GTK_STATUSBAR(mainwin.statusbar), context, buf); /* make sure statusbar gets updated right away */ *************** *** 758,762 **** #endif } ! /* --- 790,794 ---- #endif } ! #endif /* *************** *** 794,798 **** LDAP *ld; LDAPMessage *res; - GString *gmessage; int msg, is_leaf; --- 826,829 ---- *************** *** 806,813 **** } ! gmessage = g_string_sized_new(128); ! g_string_sprintf(gmessage, _("checking subtree for %s"), dn); ! statusbar_msg(gmessage->str); ! g_string_free(gmessage, TRUE); msg = ldap_search(ld, dn, LDAP_SCOPE_ONELEVEL, "(objectclass=*)", --- 837,841 ---- } ! statusbar_msg(_("checking subtree for %s"), dn); msg = ldap_search(ld, dn, LDAP_SCOPE_ONELEVEL, "(objectclass=*)", *************** *** 822,826 **** close_connection(server, FALSE); set_normalcursor(); ! statusbar_msg(""); return(is_leaf); --- 850,854 ---- close_connection(server, FALSE); set_normalcursor(); ! statusbar_msg_clear(); return(is_leaf); *************** *** 1468,1472 **** int msg, i; int num_suffixes = 0; ! char **vals, message[128]; char *ldapv3_config[] = { "namingcontexts", --- 1496,1500 ---- int msg, i; int num_suffixes = 0; ! char **vals; char *ldapv3_config[] = { "namingcontexts", *************** *** 1565,1573 **** close_connection(server, FALSE); ! snprintf(message, sizeof(message), ! ngettext("One suffix found", "%d suffixes found", ! num_suffixes), ! num_suffixes); ! statusbar_msg(message); return g_list_first(suffixes); --- 1593,1599 ---- close_connection(server, FALSE); ! statusbar_msg(ngettext("One suffix found", "%d suffixes found", ! num_suffixes), ! num_suffixes); return g_list_first(suffixes); Index: util.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** util.h 2 Oct 2003 16:16:26 -0000 1.22 --- util.h 8 Oct 2003 22:01:13 -0000 1.23 *************** *** 30,33 **** --- 30,34 ---- #include "config.h" + #include <glib.h> #include <gtk/gtk.h> #include <ldap.h> *************** *** 66,70 **** const gpointer detokenize_data(struct tokenlist *list, int token); char *get_username(void); ! void statusbar_msg(const char *message); struct ldapserver *server_by_name(const char *name); int is_leaf_entry(struct ldapserver *server, char *dn); --- 67,75 ---- const gpointer detokenize_data(struct tokenlist *list, int token); char *get_username(void); ! /* G_GNUC_PRINTF is the __attribute__ ((format (printf, 1, 2))) stuff, ! but portable */ ! void statusbar_msg(const char *fmt, ...) G_GNUC_PRINTF(1, 2); ! void statusbar_msg_clear(); ! struct ldapserver *server_by_name(const char *name); int is_leaf_entry(struct ldapserver *server, char *dn); |
From: <sta...@us...> - 2003-10-07 14:07:31
|
Update of /cvsroot/gqclient/gq In directory sc8-pr-cvs1:/tmp/cvs-serv3182 Modified Files: TODO Log Message: * Updated TODO to allow people to check if they can do something... Index: TODO =================================================================== RCS file: /cvsroot/gqclient/gq/TODO,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** TODO 30 Sep 2003 17:20:24 -0000 1.31 --- TODO 7 Oct 2003 14:07:25 -0000 1.32 *************** *** 2,5 **** --- 2,6 ---- NOTE: [1.0] denotes features to be implemented for 1.0 + [1.x] denotes features to be implemented for 1.0 or later INTERESTING BUGS *************** *** 20,27 **** * Honor RFC2253 and the possible hex-encoding there even for OpenLDAP 2.0.x More generally: Deal with special characters in DNs. ! * [1.0] Better error reporting of LDAP error situations. Currently we handle LDAP_SUCCESS and LDAP_SERVER_DOWN but ignore the rest. Pointed out indirectly by Bernhard Reiter <ber...@in...>. ! * [1.0] Think about the moving stuff in browse mode: Either - Should move deletion out of the moving business and delay --- 21,28 ---- * Honor RFC2253 and the possible hex-encoding there even for OpenLDAP 2.0.x More generally: Deal with special characters in DNs. ! * [1.x] Better error reporting of LDAP error situations. Currently we handle LDAP_SUCCESS and LDAP_SERVER_DOWN but ignore the rest. Pointed out indirectly by Bernhard Reiter <ber...@in...>. ! * [1.x] Think about the moving stuff in browse mode: Either - Should move deletion out of the moving business and delay *************** *** 75,91 **** Wed, 09 Oct 2002 19:40:37 +0200. ! * [1.0] never do ldap_add when moving trees. Use triangulation like with the towers of hanoi ! * [1.0] More displaytypes + PKCS7 and PKCS12 browsers ! * [1.0] Rewrite drag-and-drop: - _only_ use ldap_modrdn when moving trees within one server. This allows to take care of hidden attributes implicitly - * Rewrite the schema browser to also use the GtkCTree widget. - - * [1.0] Improve LDAP error reporting BLUE SKY --- 76,97 ---- Wed, 09 Oct 2002 19:40:37 +0200. ! ! * Rewrite the schema browser to also use the GtkCTree widget. ! ! * [1.0] Improve LDAP error reporting ! ! * [1.0] work towards gtk2 - mostly done, need the XML parser change ! (see below) for encoding reasons. ! ! * [1.x] never do ldap_add when moving trees. Use triangulation like with the towers of hanoi ! * [1.x] More displaytypes + PKCS7 and PKCS12 browsers ! * [1.x] Rewrite drag-and-drop: - _only_ use ldap_modrdn when moving trees within one server. This allows to take care of hidden attributes implicitly BLUE SKY *************** *** 93,101 **** * schema designer (when OpenLDAP supports writable schema) * generate change and undo log in LDIF - * [post 1.0] work towards gtk2 -------------------------------------------------------------------------- FIXED BUGS / IMPLEMENTED ENHANCEMENTS * search mode: --- 99,114 ---- * schema designer (when OpenLDAP supports writable schema) * generate change and undo log in LDIF -------------------------------------------------------------------------- FIXED BUGS / IMPLEMENTED ENHANCEMENTS + + * [1.0] Switch to a proper XML parser for configuration file + parsing. MUST DO THIS or we will end in an encoding mess when using + gtk2. When first starting up, the encoding of an old configuration + file must be found out. The only way to do this is by using the default + codepage setting. The need to switch to a proper parser also arises + due to the requirement to properly parse multi-byte characters in + config files. This does not really work currently. * search mode: |
From: <sta...@us...> - 2003-10-06 06:42:15
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv5749 Modified Files: search.c Log Message: * Fixed and "almost bufferoverflow" (if it wasn't for snprintf) Index: search.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/search.c,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** search.c 5 Oct 2003 13:47:43 -0000 1.40 --- search.c 6 Oct 2003 06:42:06 -0000 1.41 *************** *** 359,362 **** --- 359,363 ---- } else if(g_utf8_strchr(querystring, -1, '=')) { + l += 3; filter = g_malloc(l); snprintf(filter, l, "(%s)", querystring); |
From: <sta...@us...> - 2003-10-05 22:25:11
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv8252 Modified Files: Makefile.am Log Message: * Added new source files Index: Makefile.am =================================================================== RCS file: /cvsroot/gqclient/gq/src/Makefile.am,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Makefile.am 4 Oct 2003 10:10:47 -0000 1.26 --- Makefile.am 5 Oct 2003 22:25:07 -0000 1.27 *************** *** 42,46 **** i18n.c \ gq-xml.c \ ! xmlparse.c gq_LDADD = COPYING.o --- 42,48 ---- i18n.c \ gq-xml.c \ ! xmlparse.c \ ! xmlutil.c \ ! state.c gq_LDADD = COPYING.o *************** *** 86,89 **** --- 88,93 ---- xmlparse.h \ gq-xml.h \ + state.h \ + xmlutil.h \ COPYING.h |
From: <sta...@us...> - 2003-10-05 22:24:53
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv8078 Modified Files: configfile.c configfile.h Log Message: * Support to write the new GUI prefs * Reintroduced several config-write routines into the global namespace Index: configfile.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/configfile.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** configfile.c 5 Oct 2003 13:34:49 -0000 1.35 --- configfile.c 5 Oct 2003 22:24:47 -0000 1.36 *************** *** 73,85 **** }; - static void config_write(struct writeconfig *wc, const char *string); - static void config_write_bool(struct writeconfig *wc, - int value, const char *entity); - static void config_write_int(struct writeconfig *wc, - int value, const char *entity); - static void config_write_string(struct writeconfig *wc, - const char *value, const char *entity); - static void config_write_string_ne(struct writeconfig *wc, - const char *value, const char *entity); /* malloc ldapserver struct */ --- 73,76 ---- *************** *** 148,151 **** --- 139,143 ---- } + /* returns the homedir-path, returned string must be g_free'd */ char *homedir(void) { *************** *** 155,159 **** pwent = getpwuid(getuid()); if(pwent && pwent->pw_dir) ! result = strdup(pwent->pw_dir); else result = NULL; --- 147,151 ---- pwent = getpwuid(getuid()); if(pwent && pwent->pw_dir) ! result = g_strdup(pwent->pw_dir); else result = NULL; *************** *** 181,185 **** sprintf(rcpath, "%s/%s", home, RCFILE); ! free(home); return(rcpath); --- 173,177 ---- sprintf(rcpath, "%s/%s", home, RCFILE); ! g_free(home); return(rcpath); *************** *** 243,247 **** /* just a pretty printer */ ! static void config_write(struct writeconfig *wc, const char *string) { int i; --- 235,239 ---- /* just a pretty printer */ ! void config_write(struct writeconfig *wc, const char *string) { int i; *************** *** 255,259 **** ! static void config_write_bool(struct writeconfig *wc, int value, const char *entity) { char outstr[128]; --- 247,251 ---- ! void config_write_bool(struct writeconfig *wc, int value, const char *entity) { char outstr[128]; *************** *** 266,270 **** ! static void config_write_int(struct writeconfig *wc, int value, const char *entity) { char outstr[128]; --- 258,262 ---- ! void config_write_int(struct writeconfig *wc, int value, const char *entity) { char outstr[128]; *************** *** 277,281 **** ! static void config_write_string(struct writeconfig *wc, const char *value, const char *entity) { GString *outstr; --- 269,273 ---- ! void config_write_string(struct writeconfig *wc, const char *value, const char *entity) { GString *outstr; *************** *** 316,320 **** ! static void config_write_string_ne(struct writeconfig *wc, const char *value, const char *entity) { if(value && strlen(value)) --- 308,313 ---- ! void config_write_string_ne(struct writeconfig *wc, ! const char *value, const char *entity) { if(value && strlen(value)) *************** *** 373,377 **** if(!wc->outfile) { error_push(write_context, ! _("unable to open %1$s for writing:\n%2$s\n"), rcpath, strerror(errno)); g_free(tmprcpath); --- 366,370 ---- if(!wc->outfile) { error_push(write_context, ! _("Unable to open %1$s for writing:\n%2$s\n"), rcpath, strerror(errno)); g_free(tmprcpath); *************** *** 413,416 **** --- 406,417 ---- config_write_bool(wc, cfg->sort_search, "sort-search-mode"); config_write_bool(wc, cfg->sort_browse, "sort-browse-mode"); + + config_write_bool(wc, cfg->restore_window_sizes, + "restore-window-sizes"); + config_write_bool(wc, cfg->restore_window_positions, + "restore-window-positions"); + config_write_bool(wc, cfg->restore_search_history, + "restore-search-history"); + config_write_string(wc, detokenize(token_ldifformat, cfg->ldifformat), "ldif-format"); if(strlen(cfg->schemaserver)) Index: configfile.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/configfile.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** configfile.h 5 Oct 2003 13:34:49 -0000 1.24 --- configfile.h 5 Oct 2003 22:24:47 -0000 1.25 *************** *** 37,111 **** #define RCFILE ".gq" ! ! #if 0 ! /* do not forget to set T_HIGHEST to the highest used token value below */ ! ! /* tokens for config file */ ! #define T_UNKNOWN 0 ! #define T_XML_VERSION 1 ! #define T_COMMENT 2 ! #define T_GQ_CONFIG 10 ! ! #define T_CONFIRM_MOD 11 ! #define T_SEARCH_ARGUMENT 12 ! #define T_SHOWDN 13 ! #define T_SHOWOC 14 ! #define T_SORT_SEARCH 15 ! #define T_SORT_BROWSE 16 ! #define T_SHOW_RDN_ONLY 17 ! #define T_SCHEMASERVER 18 ! ! ! /* per-server tokens */ ! #define T_LDAPSERVER 20 ! #define T_NAME 21 ! #define T_LDAPHOST 22 ! #define T_LDAPPORT 23 ! #define T_BASEDN 24 ! #define T_BINDDN 25 ! #define T_BINDPW 26 ! #define T_BINDTYPE 27 ! #define T_SASLMECHANISM 54 ! #define T_SEARCHATTR 28 ! #define T_MAXENTRIES 29 ! #define T_CACHECONN 30 ! #define T_ENABLETLS 31 ! #define T_LDIF_FORMAT 32 ! #define T_LOCAL_CACHE_TIMEOUT 33 ! #define T_ASK_PW 34 ! #define T_HIDE_INTERNAL 35 ! #define T_SHOW_REF 36 ! #define T_PWENCODING 37 ! ! /* template tokens */ ! #define T_TEMPLATE 40 ! /* T_NAME already defined in per-server tokens */ ! #define T_OBJECTCLASS 41 ! ! /* filter tokens */ ! #define T_FILTER 42 ! /* T_NAME already defined in per-server tokens */ ! #define T_LDAPFILTER 43 ! #define T_SERVERNAME 44 ! ! /* defaults tokens */ ! #define T_DEFAULTS 45 ! #define T_DISPLAY_TYPES 46 ! #define T_DISPLAY_TYPE 47 ! #define T_DT_ATTRIBUTE 48 ! #define T_DT_DEFAULT 49 ! ! #define T_DATA 50 ! ! #define T_CONFIG_VERSION 51 ! #define T_ASKED_CONFIG_VERSION 52 ! #define T_LAST_ASKED 53 ! ! #define T_HIGHEST 54 /* bitwise flags used in keywordlist.flags */ #define NEEDS_CLOSE 1 #define NEEDS_DATA 2 - #endif --- 37,45 ---- #define RCFILE ".gq" ! #define STATEFILE ".gq-state" /* bitwise flags used in keywordlist.flags */ #define NEEDS_CLOSE 1 #define NEEDS_DATA 2 *************** *** 163,166 **** --- 97,103 ---- int show_rdn_only; char *schemaserver; + int restore_window_sizes; + int restore_window_positions; + int restore_search_history; GHashTable *defaultDT; *************** *** 174,206 **** }; - #if 0 - enum parselevel { - TOP, IN_TAG, END - }; - - enum entitytype { - IGNORE, OPEN, CLOSE - }; - - struct configfile { - char *rcfile; - int p; - int line; - enum parselevel status; - char cur_string[128]; - int cur_token; - int cur_token_flags; - enum entitytype cur_entity_type; - int stack[16]; - int sp; - - int err_context; - - struct ldapserver *cur_ldapserver; - struct gq_template *cur_template; - struct gq_filter *cur_filter; - char *cur_dt_attr; - }; - #endif /* handy for writing config file */ --- 111,114 ---- *************** *** 209,212 **** --- 117,131 ---- int indent; }; + + + void config_write(struct writeconfig *wc, const char *string); + void config_write_bool(struct writeconfig *wc, + int value, const char *entity); + void config_write_int(struct writeconfig *wc, + int value, const char *entity); + void config_write_string(struct writeconfig *wc, + const char *value, const char *entity); + void config_write_string_ne(struct writeconfig *wc, + const char *value, const char *entity); |
From: <sta...@us...> - 2003-10-05 22:23:33
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv7986 Modified Files: gq-xml.c Log Message: * Added the new GUI preferences to the configuration * Moved the warning / error message handler out into xmlutil.[ch] Index: gq-xml.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/gq-xml.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gq-xml.c 5 Oct 2003 13:42:10 -0000 1.3 --- gq-xml.c 5 Oct 2003 22:23:28 -0000 1.4 *************** *** 38,41 **** --- 38,42 ---- #include "gq-xml.h" #include "xmlparse.h" + #include "xmlutil.h" #include "configfile.h" #include "util.h" *************** *** 48,56 **** #include "common.h" - struct cf_comm { - int error_context; - int severity; - struct gq_config *config; - }; static void gq_configS(struct parser_context *ctx, --- 49,52 ---- *************** *** 65,74 **** { if (ctx->user_data) { ! struct cf_comm *comm = (struct cf_comm *)ctx->user_data; ! if (comm->config) { ! free_config(comm->config); } ! comm->config = e->data; e->data = NULL; --- 61,70 ---- { if (ctx->user_data) { ! struct parser_comm *comm = (struct parser_comm *)ctx->user_data; ! if (comm->result) { ! free_config(comm->result); } ! comm->result = e->data; e->data = NULL; *************** *** 195,199 **** --- 191,220 ---- } + static void restore_window_sizesE(struct parser_context *ctx, + struct tagstack_entry *e) + { + struct gq_config *c = peek_tag(ctx->stack, 1)->data; + + int b = booleanCDATA(ctx, e); + if (b >= 0) c->restore_window_sizes = b; + } + + static void restore_window_positionsE(struct parser_context *ctx, + struct tagstack_entry *e) + { + struct gq_config *c = peek_tag(ctx->stack, 1)->data; + + int b = booleanCDATA(ctx, e); + if (b >= 0) c->restore_window_positions = b; + } + + static void restore_search_historyE(struct parser_context *ctx, + struct tagstack_entry *e) + { + struct gq_config *c = peek_tag(ctx->stack, 1)->data; + int b = booleanCDATA(ctx, e); + if (b >= 0) c->restore_search_history = b; + } static void ldif_formatE(struct parser_context *ctx, *************** *** 206,211 **** } - - static void search_argumentE(struct parser_context *ctx, struct tagstack_entry *e) --- 227,230 ---- *************** *** 377,381 **** } - static void ldapserver_cache_connectionE(struct parser_context *ctx, struct tagstack_entry *e) --- 396,399 ---- *************** *** 548,552 **** ! struct xml_tag config_tags[] = { { "gq-config", 0, --- 566,570 ---- ! static struct xml_tag config_tags[] = { { "gq-config", 0, *************** *** 605,608 **** --- 623,641 ---- }, { + "restore-window-sizes", 0, + NULL, restore_window_sizesE, + { "gq-config", NULL }, + }, + { + "restore-window-positions", 0, + NULL, restore_window_positionsE, + { "gq-config", NULL }, + }, + { + "restore-search-history", 0, + NULL, restore_search_historyE, + { "gq-config", NULL }, + }, + { "ldif-format", 0, NULL, ldif_formatE, *************** *** 786,843 **** }; - static void XMLmessageHandler(struct parser_context *ctx, - int severity, - const char *type, - const char *format, va_list ap) - { - struct cf_comm *comm = ctx->user_data; - if (comm) { - int len = 1024, pos = 0, i; - char *buf = g_malloc(len); - - snprintf(buf, len, "%s: ", type); - i = strlen(buf); - pos += i; /* OK for UTF-8 */ - - vsnprintf(buf + pos, len - pos, format, ap); - error_push(comm->error_context, buf); - - fprintf(stderr, "%s\n", buf); - - g_free(buf); - - comm->severity = severity; - } - } - - static void XMLwarningHandler(struct parser_context *ctx, - const char *fmt, ...) - { - va_list args; - - va_start(args, fmt); - XMLmessageHandler(ctx, 1, _("Warning"), fmt, args); - va_end(args); - } - - static void XMLerrorHandler(struct parser_context *ctx, - const char *fmt, ...) - { - va_list args; - - va_start(args, fmt); - XMLmessageHandler(ctx, 2, _("Error"), fmt, args); - va_end(args); - } - - static void XMLfatalErrorHandler(struct parser_context *ctx, - const char *fmt, ...) - { - va_list args; - - va_start(args, fmt); - XMLmessageHandler(ctx, 3, _("Fatal Error"), fmt, args); - va_end(args); - } static int dot_gq_upgrade_hack(int error_context, const char *filename) --- 819,822 ---- *************** *** 1004,1011 **** xmlSAXHandler *handler = g_malloc0(sizeof(xmlSAXHandler)); int rc; ! struct cf_comm comm; comm.error_context = error_context; ! comm.config = NULL; handler->error = (errorSAXFunc) XMLerrorHandler; --- 983,990 ---- xmlSAXHandler *handler = g_malloc0(sizeof(xmlSAXHandler)); int rc; ! struct parser_comm comm; comm.error_context = error_context; ! comm.result = NULL; handler->error = (errorSAXFunc) XMLerrorHandler; *************** *** 1018,1026 **** g_free(handler); if (rc != 0) { ! free_config(comm.config); ! comm.config = NULL; } ! return comm.config; } --- 997,1005 ---- g_free(handler); if (rc != 0) { ! free_config(comm.result); ! comm.result = NULL; } ! return comm.result; } |
From: <sta...@us...> - 2003-10-05 22:22:16
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv7811 Modified Files: gq.c Log Message: * Support for reading/writing GUI state information Index: gq.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/gq.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** gq.c 5 Oct 2003 13:42:36 -0000 1.18 --- gq.c 5 Oct 2003 22:22:12 -0000 1.19 *************** *** 44,47 **** --- 44,48 ---- #include "encode.h" #include "debug.h" + #include "state.h" GdkFont *big_fixed; *************** *** 121,124 **** --- 122,126 ---- init_config(); + init_state(); setup_fonts(); *************** *** 154,157 **** --- 156,161 ---- free_config(config); config = NULL; + + save_state(); gtk_exit(0); |
From: <sta...@us...> - 2003-10-05 22:21:41
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv7662 Modified Files: mainwin.c Log Message: * Made the main window state persistent Index: mainwin.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/mainwin.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** mainwin.c 5 Oct 2003 13:44:21 -0000 1.36 --- mainwin.c 5 Oct 2003 22:21:37 -0000 1.37 *************** *** 44,47 **** --- 44,48 ---- #include "debug.h" #include "input.h" + #include "state.h" #include "../icons/logo.xpm" *************** *** 171,176 **** struct gq_filter *filter; ! mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); ! gtk_window_set_default_size(GTK_WINDOW(mainwin), 770, 478); gtk_container_border_width(GTK_CONTAINER(mainwin), 0); gtk_signal_connect(GTK_OBJECT(mainwin), "destroy", --- 172,181 ---- struct gq_filter *filter; ! /* mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); */ ! /* gtk_window_set_default_size(GTK_WINDOW(mainwin), 770, 478); */ ! ! mainwin = stateful_gtk_window_new(GTK_WINDOW_TOPLEVEL, ! "mainwin", 770, 478); ! gtk_container_border_width(GTK_CONTAINER(mainwin), 0); gtk_signal_connect(GTK_OBJECT(mainwin), "destroy", |
From: <sta...@us...> - 2003-10-05 22:21:05
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv7500 Modified Files: prefs.c Log Message: * Make the preferences window state persistent * Added a new "GUI" tab to the preferences dialog, allowing what to restore at startup Index: prefs.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/prefs.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** prefs.c 5 Oct 2003 13:45:58 -0000 1.34 --- prefs.c 5 Oct 2003 22:20:58 -0000 1.35 *************** *** 48,51 **** --- 48,52 ---- #include "browse.h" #include "utf8-compat.h" + #include "state.h" struct ldapserver *current_selected_server = NULL; *************** *** 62,65 **** --- 63,67 ---- static void destroy_edit_server_window(GtkWidget *this, gpointer data); + static void create_guitab(GtkWidget *target, GtkWidget *targetwindow); *************** *** 1069,1072 **** --- 1071,1096 ---- config->ldifformat = type; + /* GUI: */ + + /* restore window sizes */ + widget = gtk_object_get_data(GTK_OBJECT(this), "restore_window_sizes"); + config->restore_window_sizes = GTK_TOGGLE_BUTTON(widget)->active ? 1 : 0; + + /* restore window positions */ + widget = gtk_object_get_data(GTK_OBJECT(this), + "restore_window_positions"); + config->restore_window_positions = + GTK_TOGGLE_BUTTON(widget)->active ? 1 : 0; + + /* restore search history */ + widget = gtk_object_get_data(GTK_OBJECT(this), + "restore_search_history"); + config->restore_search_history = + GTK_TOGGLE_BUTTON(widget)->active ? 1 : 0; + + /* restore window sizes */ + widget = gtk_object_get_data(GTK_OBJECT(this), "restore_window_sizes"); + config->restore_window_sizes = GTK_TOGGLE_BUTTON(widget)->active ? 1 : 0; + combo = gtk_object_get_data(GTK_OBJECT(this), "schemaserver"); if(combo) { *************** *** 1086,1094 **** GtkWidget *label, *vbox2; GtkWidget *notebook; ! GtkWidget *vbox_search_options, *vbox_browse_options, *vbox_servers, *vbox_templates, *vbox_ldif; GtkWidget *hbox_buttons, *okbutton, *cancelbutton; ! prefswindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); ! gtk_widget_set_usize(prefswindow, 520, 470); gtk_container_border_width(GTK_CONTAINER(prefswindow), CONTAINER_BORDER_WIDTH); --- 1110,1122 ---- GtkWidget *label, *vbox2; GtkWidget *notebook; ! GtkWidget *vbox_search_options, *vbox_browse_options, *vbox_servers, *vbox_templates, *vbox_ldif, *vbox_gui; GtkWidget *hbox_buttons, *okbutton, *cancelbutton; ! /* prefswindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); */ ! /* gtk_widget_set_usize(prefswindow, 520, 470); */ ! ! prefswindow = stateful_gtk_window_new(GTK_WINDOW_TOPLEVEL, ! "prefswindow", 520, 470); ! gtk_container_border_width(GTK_CONTAINER(prefswindow), CONTAINER_BORDER_WIDTH); *************** *** 1160,1163 **** --- 1188,1203 ---- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_ldif, label); + + /* GUI tab */ + vbox_gui = gtk_vbox_new(FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(vbox_gui), + CONTAINER_BORDER_WIDTH); + create_guitab(vbox_gui, prefswindow); + gtk_widget_show(vbox_gui); + label = gq_label_new(_("_GUI")); + gtk_widget_show(label); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_gui, label); + + /* OK and Cancel buttons outside notebook */ hbox_buttons = gtk_hbutton_box_new(); /* FALSE, 0); */ *************** *** 1618,1621 **** --- 1658,1716 ---- } + + + static void create_guitab(GtkWidget *target, GtkWidget *targetwindow) + { + GtkWidget *persistframe; + GtkWidget *vbox1, *button; + + /* Persistency frame */ + persistframe = gtk_frame_new(_("Persistency")); + gtk_widget_show(persistframe); + gtk_box_pack_start(GTK_BOX(target), persistframe, FALSE, TRUE, 5); + + vbox1 = gtk_vbox_new(FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(vbox1), + CONTAINER_BORDER_WIDTH); + gtk_container_add(GTK_CONTAINER(persistframe), vbox1); + gtk_widget_show(vbox1); + + /* Restore Window Sizes checkbox */ + button = gq_check_button_new_with_label(_("Restore Window Si_zes")); + gtk_object_set_data(GTK_OBJECT(targetwindow), + "restore_window_sizes", button); + if(config->restore_window_sizes) + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE); + #ifdef OLD_FOCUS_HANDLING + GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); + #endif + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox1), button, FALSE, TRUE, 5); + + /* Restore Window Positions checkbox */ + button = gq_check_button_new_with_label(_("Restore Window Pos_itions")); + gtk_object_set_data(GTK_OBJECT(targetwindow), + "restore_window_positions", button); + if(config->restore_window_positions) + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE); + #ifdef OLD_FOCUS_HANDLING + GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); + #endif + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox1), button, FALSE, TRUE, 5); + + /* Restore Search History checkbox */ + button = gq_check_button_new_with_label(_("Restore Search _History")); + gtk_object_set_data(GTK_OBJECT(targetwindow), + "restore_search_history", button); + if(config->restore_search_history) + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE); + #ifdef OLD_FOCUS_HANDLING + GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); + #endif + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox1), button, FALSE, TRUE, 5); + } + |
From: <sta...@us...> - 2003-10-05 22:19:17
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv7216 Modified Files: xmlparse.c Log Message: * Fixed a bug that caused NULL's to be stored where there used to be allocated buffers, thus causing SIGSEGVs * Do not crash if the file to be parsed cannot be opened Index: xmlparse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/xmlparse.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** xmlparse.c 5 Oct 2003 13:53:02 -0000 1.4 --- xmlparse.c 5 Oct 2003 22:19:09 -0000 1.5 *************** *** 47,50 **** --- 47,51 ---- #include <string.h> + #include <errno.h> /* This is the only part specific to GTK, I hope */ *************** *** 101,104 **** --- 102,107 ---- stack->entries[stack->sp++] = e; e->tag = strdup(tag); + e->cdata = strdup(""); + e->len = 1; return e; *************** *** 348,356 **** xmlFreeParserCtxt(parser); } else { ! XMLhandleFatalError(&ctx, "Cannot open file"); rc = -1; } ! fclose(fp); /* inputCloseCallbackDummy does not close fp. That way ! we can be sure that fp gets closed only once. */ #else rc = xmlSAXUserParseFile(handler, &ctx, file); --- 351,360 ---- xmlFreeParserCtxt(parser); } else { ! XMLhandleFatalError(&ctx, "Cannot open file '%s': %s", ! file, strerror(errno)); rc = -1; } ! if (fp) fclose(fp); /* inputCloseCallbackDummy does not close fp. That way ! we can be sure that fp gets closed only once. */ #else rc = xmlSAXUserParseFile(handler, &ctx, file); |
From: <sta...@us...> - 2003-10-05 22:15:46
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv6431 Added Files: state.c state.h Log Message: * An experimental framework for GUI state persistency --- NEW FILE: state.c --- /* GQ -- a GTK-based LDAP client is Copyright (C) 1998-2003 Bert Vermeulen Copyright (C) 2002-2003 Peter Stamfest This file is Copyright (c) 2003 by Peter Stamfest <pe...@st...> This program is released under the Gnu General Public License with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* A hash mapping state-names to hashes containing mappings of settings to lists of values. This is not elegant, but just the data structure required. */ #include "config.h" #include <stdlib.h> #include <assert.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <gtk/gtk.h> #include "xmlparse.h" #include "configfile.h" #include "util.h" #include "errorchain.h" #include "xmlutil.h" #include "i18n.h" enum state_value_type { SV_int = 1, SV_char = 2, SV_list = 3, }; static struct tokenlist token_value_type_names[] = { { SV_int, "integer" }, { SV_char, "string" }, { SV_list, "list" }, { 0, "" } }; /* Oh-uh, It looks like a registry! I would't wonder if this file would always end up having 666 lines... */ struct state_entity { GHashTable *values; GHashTable *entities; /* sub entities */ }; struct state_value { enum state_value_type type; union { int *int_val; char *char_val; GList *list_val; } val; void (*free_list_element)(void *); }; static GHashTable *entities = NULL; struct state_value *new_state_value(enum state_value_type t) { struct state_value *v = g_malloc0(sizeof(struct state_value)); v->type = t; switch (t) { case SV_int: v->val.int_val = g_malloc0(sizeof(int)); break; case SV_char: v->val.char_val = g_strdup(""); break; case SV_list: v->val.list_val = NULL; break; default: abort(); } return v; } void free_state_value(struct state_value *v) { assert(v); switch (v->type) { case SV_int: g_free(v->val.int_val); break; case SV_char: if (v->val.char_val) g_free(v->val.char_val); break; case SV_list: if (v->val.list_val && v->free_list_element) { g_list_foreach(v->val.list_val, (GFunc) v->free_list_element, NULL); } if (v->val.list_val) { g_list_free(v->val.list_val); } break; default: abort(); } g_free(v); } struct state_entity *new_state_entity() { struct state_entity *e = g_malloc0(sizeof(struct state_entity)); e->values = g_hash_table_new(g_str_hash, g_str_equal); e->entities = g_hash_table_new(g_str_hash, g_str_equal); return e; } static gboolean ghr_free_value(char *key, struct state_value *v, gpointer ud) { g_free_if(key); free_state_value(v); return TRUE; } void free_state_entity(struct state_entity *e); static gboolean ghr_free_entity(char *key, struct state_entity *e, gpointer ud) { g_free_if(key); free_state_entity(e); return TRUE; } void free_state_entity(struct state_entity *e) { assert(e); g_hash_table_foreach_remove(e->values, (GHRFunc) ghr_free_value, NULL); g_hash_table_foreach_remove(e->entities, (GHRFunc) ghr_free_entity, NULL); g_hash_table_destroy(e->values); g_hash_table_destroy(e->entities); } struct state_entity *lookup_entity(const char *entity_name) { struct state_entity *e; if (!entities) { entities = g_hash_table_new(g_str_hash, g_str_equal); } e = g_hash_table_lookup(entities, entity_name); if (e) { return e; } e = new_state_entity(); g_hash_table_insert(entities, g_strdup(entity_name), e); return e; } int lookup_state_value_get_int(const char *state_name, const char *value_name, int def) { struct state_value *val; struct state_entity *e = lookup_entity(state_name); assert(e); assert(e->values); val = g_hash_table_lookup(e->values, value_name); if (val) { if (val->type == SV_int) { return *(val->val.int_val); } } else { val = new_state_value(SV_int); *(val->val.int_val) = def; g_hash_table_insert(e->values, g_strdup(value_name), val); } return def; } void state_value_set_int(const char *state_name, const char *value_name, int n) { struct state_value *val; struct state_entity *e = lookup_entity(state_name); assert(e); assert(e->values); val = g_hash_table_lookup(e->values, value_name); if (val) { if (val->type == SV_int) { *(val->val.int_val) = n; } } else { val = new_state_value(SV_int); *(val->val.int_val) = n; g_hash_table_insert(e->values, g_strdup(value_name), val); } } static void width_height_state(GtkWidget *w, GtkAllocation *allocation, char *name) { state_value_set_int(name, "width", allocation->width); state_value_set_int(name, "height", allocation->height); } static void window_realized(GtkWidget *w, char *name) { GdkWindow *win = w->window; if (win && config->restore_window_positions) { int x = lookup_state_value_get_int(name, "x", -1); int y = lookup_state_value_get_int(name, "y", -1); if (x >= 0 && y >= 0) gdk_window_move(win, x, y); } } static void window_unrealized(GtkWidget *w, char *name) { GdkWindow *win = w->window; if (win) { int x, y; gdk_window_get_position(win, &x, &y); state_value_set_int(name, "x", x); state_value_set_int(name, "y", y); } } GtkWidget *stateful_gtk_window_new(GtkWindowType type, const char *name, int w, int h) { GtkWidget *wid = gtk_window_new(type); char *ud = g_strdup(name); gtk_object_set_data_full(GTK_OBJECT(wid), "name", ud, g_free); if (config->restore_window_sizes) { gtk_window_set_default_size(GTK_WINDOW(wid), lookup_state_value_get_int(name, "width", w), lookup_state_value_get_int(name, "height", h)); } else { gtk_window_set_default_size(GTK_WINDOW(wid), w, h); } gtk_signal_connect(GTK_OBJECT(wid), "size-allocate", GTK_SIGNAL_FUNC(width_height_state), (gpointer) ud); gtk_signal_connect_after(GTK_OBJECT(wid), "realize", GTK_SIGNAL_FUNC(window_realized), (gpointer) ud); gtk_signal_connect(GTK_OBJECT(wid), "unrealize", GTK_SIGNAL_FUNC(window_unrealized), (gpointer) ud); return wid; } /* filename_config returns the name of the config file. The returned pointer must g_free'd. */ gchar *filename_state(int context) { gchar *rcpath = NULL; char *home; home = homedir(); if(home == NULL) { error_push(context, _("you have no home directory!")); return(NULL); } /* need add'l "/", thus add some extra chars */ rcpath = g_malloc(strlen(home) + strlen(STATEFILE) + 3); sprintf(rcpath, "%s/%s", home, STATEFILE); g_free(home); return(rcpath); } static void save_single_value(const char *value_name, struct state_value *v, struct writeconfig *wc) { int len = strlen(value_name) + 80; char *msg = g_malloc(len); snprintf(msg, len, "<state-value name='%s' type='%s'>\n", value_name, detokenize(token_value_type_names, v->type)); config_write(wc, msg); wc->indent++; switch (v->type) { case SV_int: snprintf(msg, len, "%d\n", *(v->val.int_val)); config_write(wc, msg); break; case SV_char: if (v->val.char_val) { config_write(wc, v->val.char_val); } break; case SV_list: abort(); break; default: abort(); } g_free(msg); wc->indent--; config_write(wc, "</state-value>\n"); } static void save_single_entity(const char *state_name, struct state_entity *e, struct writeconfig *wc) { int len = strlen(state_name) + 80; char *msg = g_malloc(len); snprintf(msg, len, "<entity name='%s'>\n", state_name); config_write(wc, msg); g_free(msg); wc->indent++; g_hash_table_foreach(e->values, (GHFunc) save_single_value, wc); g_hash_table_foreach(e->entities, (GHFunc) save_single_entity, wc); wc->indent--; config_write(wc, "</entity>\n"); } void save_state() { int save_context = error_new_context(_("Error saving statefile")); struct writeconfig *wc; gchar *statefile = filename_state(save_context); struct stat sfile; int mode = S_IRUSR|S_IWUSR; int fd; char *tmpstatefile = NULL; if (!statefile) { error_flush(save_context); return; } wc = g_malloc0(sizeof(struct writeconfig)); wc->indent = 0; /* write to temp file... */ tmpstatefile = g_malloc(strlen(statefile) + 10); strcpy(tmpstatefile, statefile); strcat(tmpstatefile, ".new"); /* check mode of original file. */ if(stat(statefile, &sfile) == 0) { mode = sfile.st_mode & (S_IRUSR|S_IWUSR); } fd = open(tmpstatefile, O_CREAT | O_WRONLY, mode); if (fd < 0) { error_push(save_context, _("Unable to open %1$s for writing:\n%2$s\n"), tmpstatefile, strerror(errno)); g_free(tmpstatefile); return; } wc->outfile = fdopen(fd, "w"); #if GTK_MAJOR >= 2 config_write(wc, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"); #else { char xmldecl[255]; extern const char *gq_codeset; snprintf(xmldecl, sizeof(xmldecl), "<?xml version=\"1.0\" encoding=\"%s\" standalone=\"yes\"?>\n", gq_codeset); config_write(wc, xmldecl); } #endif config_write(wc, "<gq-state>\n"); wc->indent++; g_hash_table_foreach(entities, (GHFunc) save_single_entity, wc); wc->indent--; config_write(wc, "</gq-state>\n"); fclose(wc->outfile); g_free(wc); rename(tmpstatefile, statefile); g_free(tmpstatefile); } static void gq_stateS(struct parser_context *ctx, struct tagstack_entry *e) { e->data = g_hash_table_new(g_str_hash, g_str_equal); e->free_data = (free_func) g_hash_table_destroy; } static void gq_stateE(struct parser_context *ctx, struct tagstack_entry *e) { if (ctx->user_data) { struct parser_comm *comm = (struct parser_comm *)ctx->user_data; comm->result = e->data; e->data = NULL; e->free_data = NULL; } else { /* FIXME: the free callback should clean up */ } } static void entityS(struct parser_context *ctx, struct tagstack_entry *e) { struct state_entity *ent = new_state_entity(); e->data = ent; e->free_data = (free_func) free_state_entity; } static void entityE(struct parser_context *ctx, struct tagstack_entry *e) { GHashTable *entities = peek_tag(ctx->stack, 1)->data; struct state_entity *ent = e->data; int i; for (i = 0 ; e->attrs[i] ; i += 2) { if (strcmp("name", e->attrs[i]) == 0) { g_hash_table_insert(entities, g_strdup(e->attrs[i+1]), ent); e->data = NULL; e->free_data = NULL; break; } } } static void entity_entityE(struct parser_context *ctx, struct tagstack_entry *e) { struct state_entity *parent = peek_tag(ctx->stack, 1)->data; struct state_entity *ent = e->data; int i; for (i = 0 ; e->attrs[i] ; i += 2) { if (strcmp("name", e->attrs[i]) == 0) { g_hash_table_insert(parent->entities, g_strdup(e->attrs[i+1]), ent); e->data = NULL; e->free_data = NULL; break; } } } static void state_valueE(struct parser_context *ctx, struct tagstack_entry *e) { struct state_entity *ent = peek_tag(ctx->stack, 1)->data; const char *n = NULL; enum state_value_type t = 0; int i; for (i = 0 ; e->attrs[i] ; i += 2) { if (strcmp("name", e->attrs[i]) == 0) { n = e->attrs[i+1]; } else if (strcmp("type", e->attrs[i]) == 0) { t = tokenize(token_value_type_names, e->attrs[i+1]); } } if (n != NULL && t != 0) { struct state_value *v = new_state_value(t); char *ep; switch (t) { case SV_int: *(v->val.int_val) = strtol(e->cdata, &ep, 10); /* FIXME handle error */ break; case SV_char: v->val.char_val = g_strdup(e->cdata); break; case SV_list: abort(); break; default: abort(); } g_hash_table_insert(ent->values, g_strdup(n), v); } } static struct xml_tag state_tags[] = { { "gq-state", 0, gq_stateS, gq_stateE, { NULL }, }, { "entity", 0, entityS, entityE, { "gq-state", NULL }, }, { "entity", 0, entityS, entity_entityE, { "entity", NULL }, }, { "state-value", 0, NULL, state_valueE, { "entity", NULL }, }, { NULL } }; GHashTable *process_statefile_XML(int error_context, const char *filename) { xmlSAXHandler *handler = g_malloc0(sizeof(xmlSAXHandler)); int rc; struct parser_comm comm; comm.error_context = error_context; comm.result = NULL; handler->error = (errorSAXFunc) XMLerrorHandler; handler->fatalError = (fatalErrorSAXFunc) XMLfatalErrorHandler; handler->warning = (warningSAXFunc) XMLwarningHandler; rc = XMLparse(state_tags, handler, &comm, filename); g_free(handler); if (rc != 0) { /* FIXME - cleanup failed parsing attempt */ comm.result = NULL; } return comm.result; } void init_state() { int load_context = error_new_context(_("Error loading statefile")); gchar *statefile = filename_state(load_context); if (statefile) { struct stat sfile; if (stat(statefile, &sfile) == 0) { entities = process_statefile_XML(load_context, statefile); } g_free(statefile); } error_flush(load_context); } --- NEW FILE: state.h --- /* GQ -- a GTK-based LDAP client Copyright (C) 1998-2003 Bert Vermeulen Copyright (C) 2002-2003 by Peter Stamfest This program is released under the Gnu General Public License with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* $Id: state.h,v 1.1 2003/10/05 22:15:31 stamfest Exp $ */ #ifndef GQ_STATE_H_INCLUDED #define GQ_STATE_H_INCLUDED #include "config.h" GtkWidget *stateful_gtk_window_new(GtkWindowType type, const char *name, int w, int h); void init_state(); void save_state(); #endif /* Local Variables: c-basic-offset: 4 End: */ |
From: <sta...@us...> - 2003-10-05 22:14:03
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv6204 Added Files: xmlutil.c xmlutil.h Log Message: * Moved the warning / error handlers into their own module - they are reusable --- NEW FILE: xmlutil.c --- /* GQ -- a GTK-based LDAP client is Copyright (C) 1998-2003 Bert Vermeulen Copyright (C) 2002-2003 Peter Stamfest This file is Copyright (c) 2003 by Peter Stamfest <pe...@st...> This program is released under the Gnu General Public License with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "config.h" #include <string.h> #include "xmlutil.h" #include "errorchain.h" #include "i18n.h" /* gq-specific XML parser utilities */ void XMLmessageHandler(struct parser_context *ctx, int severity, const char *type, const char *format, va_list ap) { struct parser_comm *comm = ctx->user_data; if (comm) { int len = 1024, pos = 0, i; char *buf = g_malloc(len); snprintf(buf, len, "%s: ", type); i = strlen(buf); pos += i; /* OK for UTF-8 */ vsnprintf(buf + pos, len - pos, format, ap); error_push(comm->error_context, buf); fprintf(stderr, "%s\n", buf); g_free(buf); if (severity > comm->severity) { comm->severity = severity; } } } void XMLwarningHandler(struct parser_context *ctx, const char *fmt, ...) { va_list args; va_start(args, fmt); XMLmessageHandler(ctx, SEVERITY_WARNING, _("Warning"), fmt, args); va_end(args); } void XMLerrorHandler(struct parser_context *ctx, const char *fmt, ...) { va_list args; va_start(args, fmt); XMLmessageHandler(ctx, SEVERITY_ERROR, _("Error"), fmt, args); va_end(args); } void XMLfatalErrorHandler(struct parser_context *ctx, const char *fmt, ...) { va_list args; va_start(args, fmt); XMLmessageHandler(ctx, SEVERITY_FATAL_ERROR, _("Fatal Error"), fmt, args); va_end(args); } --- NEW FILE: xmlutil.h --- /* GQ -- a GTK-based LDAP client Copyright (C) 1998-2001 Bert Vermeulen Copyright (C) 2002 Bert Vermeulen and Peter Stamfest <pe...@st...> This program is released under the Gnu General Public License with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* $Id: xmlutil.h,v 1.1 2003/10/05 22:13:59 stamfest Exp $ */ #ifndef GQ_XMLUTIL_H_INCLUDED #define GQ_XMLUTIL_H_INCLUDED #include "config.h" #include <stdarg.h> #include "xmlparse.h" /* gq specific XML utils */ #define SEVERITY_NONE 0 #define SEVERITY_WARNING 1 #define SEVERITY_ERROR 2 #define SEVERITY_FATAL_ERROR 3 /* the user_data for any parser used by gq */ struct parser_comm { int error_context; /* error_context for the various warning/error handlers */ int severity; /* The gq-specific warning/error handlers set this to the maximum severity of the warning/error */ void *result; /* A pointer to whatever result the parser provides */ }; void XMLmessageHandler(struct parser_context *ctx, int severity, const char *type, const char *format, va_list ap); void XMLwarningHandler(struct parser_context *ctx, const char *fmt, ...); void XMLerrorHandler(struct parser_context *ctx, const char *fmt, ...); void XMLfatalErrorHandler(struct parser_context *ctx, const char *fmt, ...); #endif /* Local Variables: c-basic-offset: 5 End: */ |
From: <sta...@us...> - 2003-10-05 13:57:55
|
Update of /cvsroot/gqclient/gq In directory sc8-pr-cvs1:/tmp/cvs-serv10719 Modified Files: ChangeLog Log Message: * Recent changes Index: ChangeLog =================================================================== RCS file: /cvsroot/gqclient/gq/ChangeLog,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** ChangeLog 4 Oct 2003 10:19:00 -0000 1.42 --- ChangeLog 5 Oct 2003 13:57:47 -0000 1.43 *************** *** 1,2 **** --- 1,16 ---- + 2003-10-05 Peter Stamfest <pe...@st...> + * Restructured the errorchain handling. At least for me it looks + saner now: error_push allows for printf-style variable argument + lists, very convenient + * Got rid of most hand-knit linked list implementations, replaced + them with GLists (errorchains, config->ldapservers, etc.) + * Many object types now have constructors and destructors of the + form new_<type> and free_<type>. Use them instead of + self-allocating and freeing memory as it was done + before. Removed all such old style object handling + * Removed the old parser from configfile.c entirely + * Got rid of many, many fixed size buffers. These might have been + problematic with variable length characters (as in the standard + UTF-8 encoding) 2003-10-03 Peter Stamfest <pe...@st...> * Added a libxml/libxml2 based XML config file parser (SAX |
From: <sta...@us...> - 2003-10-05 13:57:32
|
Update of /cvsroot/gqclient/gq In directory sc8-pr-cvs1:/tmp/cvs-serv10638 Modified Files: configure.in Log Message: * more UTF-8 related functions get checked for * checking both snprintf and g_snprintf for reorderable arguments * Check if snprintf follows the C99 standard or not * Removing redundant -I options from CPPFLAGS and CFLAGS, I hope it works. It shortens the compiler commandline considerably. I like it like this. Index: configure.in =================================================================== RCS file: /cvsroot/gqclient/gq/configure.in,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** configure.in 4 Oct 2003 10:18:13 -0000 1.46 --- configure.in 5 Oct 2003 13:57:19 -0000 1.47 *************** *** 188,196 **** ,[#include <glib/gunicode.h>]) ! AC_CHECK_FUNCS(g_unichar_isspace g_unichar_isdigit) ! AC_CHECK_LIB(xml2, xmlSAXUserParseFile, [AC_DEFINE(HAVE_LIBXML2,,[Define if libxml2 is available on your system]) XML_CFLAGS=`$PKG_CONFIG --cflags libxml-2.0` --- 188,196 ---- ,[#include <glib/gunicode.h>]) ! AC_CHECK_FUNCS(g_unichar_isspace g_unichar_isdigit g_utf8_strchr g_string_append_unichar g_string_new_len) ! AC_CHECK_LIB(xml2, xmlCreateIOParserCtxt, [AC_DEFINE(HAVE_LIBXML2,,[Define if libxml2 is available on your system]) XML_CFLAGS=`$PKG_CONFIG --cflags libxml-2.0` *************** *** 204,227 **** LIBS="-lxml $LIBS"]) - - - - - - - - - - - - - - - - - - - - DEBUG=1 AC_ARG_ENABLE(debugging, --- 204,207 ---- *************** *** 511,541 **** dnl in i18n message catalogs) ! AC_CACHE_CHECK([reorderable printf arguments], gq_cv_print_reordering, ! [ ! AC_TRY_RUN([ ! #include <stdio.h> ! #include <string.h> ! int main(int argc, char **argv) { ! char buf[80]; ! sprintf(buf, "%2\$d %1\$d", 1, 2); ! if (strcmp(buf, "2 1") == 0) ! return 0; ! return 1; ! } ! ], ! gq_cv_print_reordering=yes, ! gq_cv_print_reordering=no, ! gq_cv_print_reordering=no ! ) ! ] ! ) ! if test "$gq_cv_print_reordering" = no ; then ! AC_CHECK_FUNC(g_snprintf, [HAVE_G_SNPRINTF=1]) ! AC_CHECK_FUNCS(g_printf g_sprintf) ! if test "x$HAVE_G_SNPRINTF" != "x" ; then ! gq_cv_print_reordering=yes ! AC_DEFINE(USE_G_PRINTF,1,[Define if the standard C *printf functions should be replaced their glib versions]) fi --- 491,523 ---- dnl in i18n message catalogs) ! for PRINTF in snprintf g_snprintf; do ! AC_CACHE_CHECK([reorderable $PRINTF arguments], gq_cv_${PRINTF}_reordering, ! [ ! AC_TRY_RUN([ ! #include <stdio.h> ! #include <string.h> ! int main(int argc, char **argv) { ! char buf[80]; ! $PRINTF(buf, sizeof(buf), "%2\$d %1\$d", 1, 2); ! if (strcmp(buf, "2 1") == 0) ! return 0; ! return 1; ! } ! ], ! eval "gq_cv_${PRINTF}_reordering=yes", ! eval "gq_cv_${PRINTF}_reordering=no", ! eval "gq_cv_${PRINTF}_reordering=no" ! ) ! ] ! ) ! done ! if test "$gq_cv_snprintf_reordering" = no ; then ! dnl AC_CHECK_FUNC(g_snprintf, [HAVE_G_SNPRINTF=1]) ! dnl AC_CHECK_FUNCS(g_printf g_sprintf) ! if test "gq_cv_g_snprintf_reordering" == "yes" ; then ! gq_cv_snprintf_reordering=yes ! AC_DEFINE(USE_G_SNPRINTF,1,[Define if the standard C snprintf function should be replaced its glib version]) fi *************** *** 580,585 **** --- 562,647 ---- fi + + + + + AC_CACHE_CHECK([if snprinf follow the C99 standard], gq_cv_c99_snprintf, + [ + AC_TRY_RUN([ + #include <stdio.h> + #include <string.h> + int main(int argc, char **argv) { + char buf[4]; + size_t rc; + rc = snprintf(buf, 4, "12345"); + if (rc == 6) return 0; + return 1; + } + ], + gq_cv_c99_snprintf=yes, + gq_cv_c99_snprintf=no, + gq_cv_c99_snprintf=no + ) + ] + ) + if test "$gq_cv_c99_snprintf" = yes ; then + AC_DEFINE(HAVE_C99_SNPRINTF,1, + [Define if the standard C snprintf function behaves C99 conformant]) + fi + + + + + + + + + + + + + + + + + + + + + dnl delay this assignment for as long as possible to not interfere with tests CFLAGS="$CFLAGS -DLOCALEDIR=\\\"$localedir\\\"" + + # clean up CPPFLAGS and CFLAGS + + INCLS="" + + AC_MSG_NOTICE([removing redundant -I options from CPPFLAGS and CFLAGS]) + + for META in CPPFLAGS CFLAGS ; do + FLAGS="" + for CF in `eval 'echo $'$META`; do + case "$CF" in + -I*) for IN in $INCLS ; do + if test "$IN" = "$CF" ; then + # double -I detected + AC_MSG_NOTICE([removing multiply used $CF from $META]) + CF= + break; + fi + done + if test "x$CF" != x ; then + INCLS="$INCLS $CF" + fi + ;; + + *) : ;; + esac + if test "x$CF" != x ; then + FLAGS="$FLAGS $CF" + fi + done + eval "$META='$FLAGS'" + done AC_OUTPUT([ |
From: <sta...@us...> - 2003-10-05 13:53:06
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv10142 Modified Files: xmlparse.c Log Message: * Moved the .gq upgrade hack from xmlparse.c to gq-xml.c * Added some philosophical stuff at the top of the file * removed unneeded prototypes * UTF-8 safety improvements Index: xmlparse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/xmlparse.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** xmlparse.c 5 Oct 2003 02:13:59 -0000 1.3 --- xmlparse.c 5 Oct 2003 13:53:02 -0000 1.4 *************** *** 26,71 **** */ ! #include <string.h> ! #include <sys/types.h> ! #include <sys/stat.h> ! #include <unistd.h> ! ! #include <gtk/gtk.h> ! ! #include "xmlparse.h" ! ! #define malloc g_malloc ! #define malloc0 g_malloc0 ! #define calloc(n,s) g_malloc0(n * s) ! ! #define TAGSTACK_INCR 20 ! ! ! #if 0 ! void free_tagstack_entry(struct tagstack_entry *e); ! ! struct tagstack *new_tagstack(); ! void free_tagstack(struct tagstack *stack); ! ! struct tagstack_entry *push_tag(struct tagstack *stack, ! const xmlChar *tag, const xmlChar **attrs); ! ! void pop_tag(struct tagstack *stack); ! /* retrieve the n-th tagstack entry. 0 = the top entry, 1 = the ! next-to-top entry, etc... */ ! ! #endif ! ! ! ! ! static void free_tagstack_entry(struct tagstack_entry *e) --- 26,59 ---- */ ! /* ! A gq-independent higher level XML parser interface around a SAX parser. + No code specific to any given parser should be put into this file. + This parser interface allows to process a XML file in a SAX like + fashion, but much more comfortably as it provides for different + callbacks for start and end tags based on the tag name. It also + provides the start-tag attributes for end-tag handlers, takes care + of character data assembly for tags and provides for + context-sensitivity out-of-the box: It is trivial to have different + handlers for the same tag in different semantic contexts (that is: + with different parent tags). + A stack of tag-related data allows handlers to store arbitrary data + with any tag. That data is available through the tagstack to child + elements as well. This feature really makes it simple to create a + XML parser. + */ + #include <string.h> + /* This is the only part specific to GTK, I hope */ + #include <gtk/gtk.h> + #define malloc g_malloc + #define calloc(n,s) g_malloc0(n * s) + #include "xmlparse.h" + #define TAGSTACK_INCR 20 static void free_tagstack_entry(struct tagstack_entry *e) *************** *** 101,107 **** } - static struct tagstack_entry *push_tag(struct tagstack *stack, ! const xmlChar *tag, const xmlChar **attrs) { struct tagstack_entry *e = calloc(1, sizeof (struct tagstack_entry)); --- 89,95 ---- } static struct tagstack_entry *push_tag(struct tagstack *stack, ! const xmlChar *tag, ! const xmlChar **attrs) { struct tagstack_entry *e = calloc(1, sizeof (struct tagstack_entry)); *************** *** 109,113 **** stack->size += TAGSTACK_INCR; stack->entries = realloc(stack->entries, ! sizeof(struct tagstack_entry *) * stack->size); } stack->entries[stack->sp++] = e; --- 97,101 ---- stack->size += TAGSTACK_INCR; stack->entries = realloc(stack->entries, ! sizeof(struct tagstack_entry*) * stack->size); } stack->entries[stack->sp++] = e; *************** *** 232,236 **** xmlChar *p = e->cdata, *n = NULL; ! for(c = g_utf8_get_char(p) ; c ; p = g_utf8_next_char(p), c = *p) { if (!g_unichar_isspace(c)) { memmove(e->cdata, p, e->len - (p - e->cdata) + 1); --- 220,226 ---- xmlChar *p = e->cdata, *n = NULL; ! /* trim leading whitespace */ ! for(c = g_utf8_get_char(p) ; c ; ! p = g_utf8_next_char(p), c = g_utf8_get_char(p)) { if (!g_unichar_isspace(c)) { memmove(e->cdata, p, e->len - (p - e->cdata) + 1); *************** *** 239,244 **** } p = e->cdata; ! for(c = g_utf8_get_char(p) ; c ; p = g_utf8_next_char(p), c = *p) { if (g_unichar_isspace(c)) { if (n == NULL) n = p; --- 229,236 ---- } + /* trim trailing whitespace */ p = e->cdata; ! for(c = g_utf8_get_char(p) ; c ; ! p = g_utf8_next_char(p), c = g_utf8_get_char(p)) { if (g_unichar_isspace(c)) { if (n == NULL) n = p; *************** *** 296,299 **** --- 288,292 ---- } + #if 0 static int inputCloseCallback(FILE *context) { *************** *** 304,307 **** --- 297,308 ---- #endif + /* A dummy callback doing nothing */ + static int inputCloseCallbackDummy(FILE *fp) + { + return 0; + } + + #endif + int XMLparse(struct xml_tag *tags, xmlSAXHandler *handler, *************** *** 310,317 **** struct parser_context ctx; struct tagstack *stack = new_tagstack(); ! struct stat sfile; ! char *cfgbuf; ! GString *newbuf; ! int rc, i, changed; int handler_is_local = 0; #if GTK_MAJOR >= 2 --- 311,315 ---- struct parser_context ctx; struct tagstack *stack = new_tagstack(); ! int rc; int handler_is_local = 0; #if GTK_MAJOR >= 2 *************** *** 341,441 **** fp = fopen(file, "r"); if (fp) { ! /* nasty heuristics, but the interface does not allow to do it ! differently */ ! ! char firstline[255]; ! fgets(firstline, sizeof(firstline) - 1, fp); ! ! rewind(fp); ! ! if (strstr(firstline, "encoding=") == NULL ) { ! /* more nastiness... since this config file was written by a ! pre-UTF-8 version of GQ, it's not going to have <>&'" escaped ! properly... fudge this now: silently rewrite the config ! file on disk, then reopen it for the XML parser */ ! changed = 0; ! stat(file, &sfile); ! cfgbuf = g_malloc(sfile.st_size + 1); ! fread(cfgbuf, 1, sfile.st_size, fp); ! cfgbuf[sfile.st_size] = 0; ! newbuf = g_string_sized_new(sfile.st_size + 128); ! for(i = 0; cfgbuf[i]; i++) { ! switch(cfgbuf[i]) { ! case '\\': ! /* < and > used to be escaped with a \ */ ! if(cfgbuf[i + 1] == '<') { ! g_string_append(newbuf, "<"); ! changed++; ! i++; ! } ! else if(cfgbuf[i + 1] == '>') { ! g_string_append(newbuf, ">"); ! changed++; ! i++; ! } ! else ! g_string_append_c(newbuf, cfgbuf[i]); ! break; ! case '"': ! /* this wasn't escaped at all */ ! if(i > strlen(firstline)) { ! /* only escape it if it's not in the ! first line *argh* */ ! g_string_append(newbuf, """); ! changed++; ! } ! else ! g_string_append_c(newbuf, '"'); ! break; ! case '\'': ! /* neither was this */ ! g_string_append(newbuf, "'"); ! changed++; ! break; ! case '&': ! /* if it's not the start of an XML escape, it ! must be an illegal & */ ! if(strncmp(cfgbuf + i + 1, "amp;", 4) && ! strncmp(cfgbuf + i + 1, "lt;", 3) && ! strncmp(cfgbuf + i + 1, "gt;", 3) && ! strncmp(cfgbuf + i + 1, "apos;", 5) && ! strncmp(cfgbuf + i + 1, "quot;", 5)) { ! g_string_append(newbuf, "&"); ! changed++; ! } ! else ! g_string_append_c(newbuf, cfgbuf[i]); ! break; ! default: ! g_string_append_c(newbuf, cfgbuf[i]); ! } ! } ! ! if(changed) { ! fclose(fp); ! fp = fopen(file, "w"); ! fwrite(newbuf->str, 1, newbuf->len, fp); ! fclose(fp); ! fp = fopen(file, "r"); ! } ! else ! rewind(fp); ! ! g_free(cfgbuf); ! g_string_free(newbuf, TRUE); ! } ! ! xmlParserCtxtPtr parser = xmlCreateIOParserCtxt(handler, ! &ctx, ! (xmlInputReadCallback) inputReadCallback, ! (xmlInputCloseCallback) inputCloseCallback, ! fp, 0); ! ! if (strstr(firstline, "encoding=") == NULL ) { ! /* no encoding specified, heuristics needed */ ! extern const char *gq_codeset; ! xmlSwitchEncoding(parser, xmlParseCharEncoding(gq_codeset)); ! } ! rc = xmlParseDocument(parser); xmlFreeParserCtxt(parser); --- 339,348 ---- fp = fopen(file, "r"); if (fp) { ! xmlParserCtxtPtr parser = ! xmlCreateIOParserCtxt(handler, ! &ctx, ! (xmlInputReadCallback) inputReadCallback, ! (xmlInputCloseCallback) inputCloseCallbackDummy, ! fp, 0); rc = xmlParseDocument(parser); xmlFreeParserCtxt(parser); *************** *** 444,447 **** --- 351,356 ---- rc = -1; } + fclose(fp); /* inputCloseCallbackDummy does not close fp. That way + we can be sure that fp gets closed only once. */ #else rc = xmlSAXUserParseFile(handler, &ctx, file); *************** *** 453,455 **** return rc; } - --- 362,363 ---- |
From: <sta...@us...> - 2003-10-05 13:51:43
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv9963 Modified Files: util.c Log Message: * now error_push allows for printf-style variable argument lists, very convenient: no more dealing with an extra message buffer for variable messages. Got rid of many such buffers * UTF-8 safety improvements * Got rid of most hand-knit linked list implementations, replaced them with GLists (errorchains, config->ldapservers, etc.) Index: util.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.c,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** util.c 4 Oct 2003 10:12:27 -0000 1.61 --- util.c 5 Oct 2003 13:51:35 -0000 1.62 *************** *** 61,64 **** --- 61,65 ---- #include "mainwin.h" #include "input.h" + #include "utf8-compat.h" #include "../icons/warning.xpm" *************** *** 86,90 **** { LDAP *ld = NULL; - char message[128]; char *binddn = NULL, *bindpw = NULL; int rc = LDAP_SUCCESS; --- 87,90 ---- *************** *** 96,100 **** *ld_out = NULL; ! if (strchr(server->ldaphost, ':') != NULL) { #ifdef HAVE_LDAP_INITIALIZE rc = ldap_initialize(&ld, server->ldaphost); --- 96,100 ---- *ld_out = NULL; ! if (g_utf8_strchr(server->ldaphost, -1, ':') != NULL) { #ifdef HAVE_LDAP_INITIALIZE rc = ldap_initialize(&ld, server->ldaphost); *************** *** 104,110 **** #else ld = NULL; ! snprintf(message, sizeof(message), ! _("Sorry. No URI support available. Your LDAP toolkit does not support LDAP URIs.")); ! error_push(open_context, message); #endif } else { --- 104,109 ---- #else ld = NULL; ! error_push(open_context, ! _("Sorry. No URI support available. Your LDAP toolkit does not support LDAP URIs.")); #endif } else { *************** *** 113,119 **** if(!ld) { ! snprintf(message, sizeof(message), ! _("Failed to initialize LDAP structure.")); ! error_push(open_context, message); } else { --- 112,117 ---- if(!ld) { ! error_push(open_context, ! _("Failed to initialize LDAP structure.")); } else { *************** *** 150,156 **** { if (server->version != LDAP_VERSION3) { ! snprintf(message, sizeof(message), ! _("Couldn't set protocol version to LDAPv3.")); ! error_push(open_context, message); } } --- 148,153 ---- { if (server->version != LDAP_VERSION3) { ! error_push(open_context, ! _("Couldn't set protocol version to LDAPv3.")); } } *************** *** 159,166 **** rc = ldap_start_tls_s(ld, NULL, NULL); if(rc != LDAP_SUCCESS) { ! snprintf(message, sizeof(message), ! _("Couldn't enable TLS on the LDAP connection: %s"), ! ldap_err2string(rc)); ! error_push(open_context, message); push_ldap_addl_error(ld, open_context); ldap_unbind(ld); --- 156,162 ---- rc = ldap_start_tls_s(ld, NULL, NULL); if(rc != LDAP_SUCCESS) { ! error_push(open_context, ! _("Couldn't enable TLS on the LDAP connection: %s"), ! ldap_err2string(rc)); push_ldap_addl_error(ld, open_context); ldap_unbind(ld); *************** *** 169,176 **** } #else ! snprintf(message, sizeof(message), ! _("TLS was not found to be supported by your LDAP libraries.\n" ! "See README.TLS for more information.\n")); ! error_push(open_context, message); #endif /* defined(HAVE_TLS) */ } --- 165,171 ---- } #else ! error_push(open_context, ! _("TLS was not found to be supported by your LDAP libraries.\n" ! "See README.TLS for more information.\n")); #endif /* defined(HAVE_TLS) */ } *************** *** 181,188 **** DEFAULT_LOCAL_CACHE_SIZE); #else ! snprintf(message, sizeof(message), ! _("OpenLDAP client-side caching was not enabled.\n" ! "See configure --help for more information.\n")); ! error_push(open_context, message); #endif } --- 176,182 ---- DEFAULT_LOCAL_CACHE_SIZE); #else ! error_push(open_context, ! _("OpenLDAP client-side caching was not enabled.\n" ! "See configure --help for more information.\n")); #endif } *************** *** 251,261 **** if (rc != LDAP_SUCCESS) { /* Maybe we cannot use LDAPv3 ... try again */ - - ! snprintf(message, sizeof(message), ! _("Couldn't bind LDAP connection: %s"), ! ldap_err2string(rc)); ! error_push(open_context, message); push_ldap_addl_error(ld, open_context); statusbar_msg(""); --- 245,252 ---- if (rc != LDAP_SUCCESS) { /* Maybe we cannot use LDAPv3 ... try again */ ! error_push(open_context, ! _("Couldn't bind LDAP connection: %s"), ! ldap_err2string(rc)); push_ldap_addl_error(ld, open_context); statusbar_msg(""); *************** *** 334,355 **** /* server->bindpw[0] == 0 && */ server->enteredpw[0] == 0) { ! char *ret; ! snprintf(message, sizeof(message), ! _("Password for server %s"), server->ldaphost); ! ! if (query_popup(message, &ret, TRUE /* is_password */)) { ! if (ret) { ! strncpy(server->enteredpw, ret, ! sizeof(server->enteredpw) - 1); ! g_free(ret); ! newpw = 1; ! } else { ! server->enteredpw[0] = 0; ! } ! } else { ! return NULL; ! } } ! if(server->ldapport == 389) { snprintf(message, sizeof(message), --- 325,345 ---- /* server->bindpw[0] == 0 && */ server->enteredpw[0] == 0) { ! char *ret; ! snprintf(message, sizeof(message), ! _("Password for server %s"), server->ldaphost); ! ! if (query_popup(message, &ret, TRUE /* is_password */)) { ! if (ret) { ! g_free_if(server->enteredpw); ! server->enteredpw = ret; ! newpw = 1; ! } else { ! server->enteredpw[0] = 0; ! } ! } else { ! return NULL; ! } } ! if(server->ldapport == 389) { snprintf(message, sizeof(message), *************** *** 776,788 **** { struct ldapserver *server; ! if(name == NULL || name[0] == '\0') return(NULL); ! server = config->ldapservers; ! while(server) { if(!strcmp(server->name, name)) return(server); - server = server->next; } --- 766,778 ---- { struct ldapserver *server; ! GList *I; ! if(name == NULL || name[0] == '\0') return(NULL); ! for (I = config->servers ; I ; I = g_list_next(I)) { ! server = (struct ldapserver *) I->data; if(!strcmp(server->name, name)) return(server); } *************** *** 843,847 **** { /* SHOULD use gq_ldap_explode_dn for this */ ! char *c = strchr(child, ','); if (c && (strcasecmp(c + 1, possible_parent) == 0)) return TRUE; return FALSE; --- 833,837 ---- { /* SHOULD use gq_ldap_explode_dn for this */ ! char *c = g_utf8_strchr(child, -1, ','); if (c && (strcasecmp(c + 1, possible_parent) == 0)) return TRUE; return FALSE; *************** *** 1188,1206 **** struct gq_template *find_template_by_name(const char *templatename) { ! GList *templatelist; ! struct gq_template *template; ! template = NULL; ! templatelist = config->templates; ! while(templatelist) { ! template = (struct gq_template *) templatelist->data; if(!strcasecmp(templatename, template->name)) ! break; ! else ! template = NULL; ! templatelist = templatelist->next; } ! ! return(template); } --- 1178,1190 ---- struct gq_template *find_template_by_name(const char *templatename) { ! GList *I; ! for(I = config->templates ; I ; I = g_list_next(I)) { ! struct gq_template *template = ! (struct gq_template *) I->data; if(!strcasecmp(templatename, template->name)) ! return template; } ! return NULL; } |
From: <sta...@us...> - 2003-10-05 13:50:28
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv9847 Modified Files: utf8-compat.h Log Message: * More "UTF-8" for gtk 1.x support (that is: provide wrappers for gtk 1.x) Index: utf8-compat.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/utf8-compat.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** utf8-compat.h 4 Oct 2003 10:06:44 -0000 1.1 --- utf8-compat.h 5 Oct 2003 13:50:24 -0000 1.2 *************** *** 46,49 **** --- 46,62 ---- #endif + #ifndef HAVE_G_UTF8_STRCHR + # define g_utf8_strchr(haystack,len,needle) strchr((haystack),(needle)) + #endif + + + #ifndef HAVE_G_STRING_APPEND_UNICODE + # define g_string_append_unichar g_string_append_c + #endif + + #ifndef HAVE_G_STRING_NEW_LEN + # define g_string_new_len(s,l) g_string_assign(g_string_sized_new(l), (s)) + #endif + #endif |
From: <sta...@us...> - 2003-10-05 13:49:34
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv9519 Modified Files: template.c template.h Log Message: * Got rid of many, many fixed size buffers. These might have been problematic with variable length characters (as in the standard UTF-8 encoding) * Many object types now have constructors and destructors of the form new_<type> and free_<type>. Use them instead of self-allocating and freeing memory as it was done before. Removed all such old style object handling * Got rid of most hand-knit linked list implementations, replaced them with GLists (errorchains, config->ldapservers, etc.) Index: template.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/template.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** template.c 4 Oct 2003 09:59:09 -0000 1.10 --- template.c 5 Oct 2003 13:49:29 -0000 1.11 *************** *** 50,57 **** extern GtkWidget *current_template_clist; ! static GtkWidget *templatewin; void create_template_edit_window(struct ldapserver *server, --- 50,78 ---- extern GtkWidget *current_template_clist; + static GtkWidget *templatewin; + + /* malloc and init gq_template struct */ + struct gq_template *new_template(void) + { + struct gq_template *tmpl; + tmpl = g_malloc0(sizeof(struct gq_template)); ! tmpl->name = g_strdup(""); ! tmpl->objectclasses = NULL; ! ! return tmpl; ! } + void free_template(struct gq_template *tmpl) + { + g_free_if(tmpl->name); + + if (tmpl->objectclasses) { + g_list_foreach(tmpl->objectclasses, (GFunc) g_free, NULL); + } + g_list_free(tmpl->objectclasses); + g_free(tmpl); + } void create_template_edit_window(struct ldapserver *server, *************** *** 549,574 **** } else { ! /* update existing template */ old_tmpl = find_template_by_name(old_template_name); if(old_tmpl) { ! ! g_list_free(old_tmpl->objectclasses); ! old_tmpl->objectclasses = tmpl->objectclasses; ! ! if(strcmp(old_template_name, tmpl->name)) { ! /* template name was changed too */ ! strncpy(old_tmpl->name, tmpl->name, 128); ! } ! ! /* tmpl is not inserted into global config, so we don't need it any more */ ! FREE(tmpl, "struct gq_template"); ! ! } ! else { /* hmmmm... template was deleted while editing it. Just add it in then */ config->templates = g_list_append(config->templates, tmpl); } - } --- 570,590 ---- } else { ! GList *l; /* update existing template */ old_tmpl = find_template_by_name(old_template_name); + + /* In order to encapsulate knowledge about the internal + structure of a template object, updating is done via + delete/insert. This is less optimal than the old + behaviour to change the filter in-place + */ if(old_tmpl) { ! l = g_list_find(config->templates, old_tmpl); ! free_template(old_tmpl); ! l->data = tmpl; ! } else { /* hmmmm... template was deleted while editing it. Just add it in then */ config->templates = g_list_append(config->templates, tmpl); } } *************** *** 593,596 **** --- 609,613 ---- int i; char *objectclass; + const char *c; if( (templatelist = gtk_object_get_data(GTK_OBJECT(window), "templatelist")) == NULL) *************** *** 600,607 **** return(NULL); ! if( (tmpl = MALLOC(sizeof(struct gq_template), "struct gq_template")) == NULL) return(NULL); ! strncpy(tmpl->name, gtk_entry_get_text(GTK_ENTRY(templatenamebox)), 128); list = NULL; --- 617,626 ---- return(NULL); ! if( (tmpl = new_template()) == NULL) return(NULL); ! ! c = gtk_entry_get_text(GTK_ENTRY(templatenamebox)); ! g_free_and_dup(tmpl->name, c); list = NULL; *************** *** 684,685 **** --- 703,710 ---- #endif /* HAVE_LDAP_STR2OBJECTCLASS */ + + /* + Local Variables: + c-basic-offset: 5 + End: + */ Index: template.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/template.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** template.h 29 Sep 2003 19:24:17 -0000 1.3 --- template.h 5 Oct 2003 13:49:29 -0000 1.4 *************** *** 31,37 **** struct gq_template { ! char name[128]; ! GList *objectclasses; }; void create_template_edit_window(struct ldapserver *server, --- 31,40 ---- struct gq_template { ! char *name; ! GList *objectclasses; }; + + struct gq_template *new_template(void); + void free_template(struct gq_template *); void create_template_edit_window(struct ldapserver *server, |