[gq-commit] gq/src browse.c,1.69,1.70 dt_entry.c,1.9,1.10 dt_entry.h,1.5,1.6 dt_generic_binary.c,1.9
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2003-10-02 16:16:33
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv4328 Modified Files: browse.c dt_entry.c dt_entry.h dt_generic_binary.c dt_password.c dt_text.c encode.c errorchain.c formfill.c formfill.h input.c input.h search.c tinput.c tinput.h util.c util.h Log Message: * gtk2 - Switching to UTF-8, probably not complete * Added some more "const" keywords where appropriate Index: browse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/browse.c,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** browse.c 1 Oct 2003 22:31:06 -0000 1.69 --- browse.c 2 Oct 2003 16:16:25 -0000 1.70 *************** *** 93,97 **** --- 93,101 ---- { char **exploded_dn = NULL; + #if GTK_MAJOR >= 2 + const char *labels[] = { NULL, NULL }; + #else char *labels[] = { NULL, NULL }; + #endif char *dummy[] = { "dummy", NULL }; dn_browse_entry *new_entry; *************** *** 112,118 **** --- 116,130 ---- goto fail; } + #if GTK_MAJOR >= 2 + labels[0] = exploded_dn[0]; + #else labels[0] = decoded_string(exploded_dn[0]); + #endif } else { + #if GTK_MAJOR >= 2 + labels[0] = dn; + #else labels[0] = decoded_string(dn); + #endif } *************** *** 140,144 **** --- 152,158 ---- fail: + #if GTK_MAJOR < 2 if (labels[0]) free(labels[0]); + #endif if (exploded_dn) gq_exploded_free(exploded_dn); *************** *** 187,190 **** --- 201,205 ---- } + #if GTK_MAJOR < 2 snprintf(message, sizeof(message), _("onelevel search on %s"), *************** *** 192,196 **** if (c) free(c); ! statusbar_msg(message); --- 207,214 ---- if (c) free(c); ! #else ! snprintf(message, sizeof(message), ! _("onelevel search on %s"), entry->dn); ! #endif statusbar_msg(message); *************** *** 425,436 **** { char **exploded_dn = gq_ldap_explode_dn(entry->dn, FALSE); - char *l = decoded_string(exploded_dn[0]); char *g; ! ! gq_exploded_free(exploded_dn); /* impedance match -> malloc to g_malloc */ g = g_strdup(l); free(l); return g; } --- 443,458 ---- { char **exploded_dn = gq_ldap_explode_dn(entry->dn, FALSE); char *g; ! #if GTK_MAJOR >= 2 ! g = g_strdup(exploded_dn[0]); ! #else ! char *l = decoded_string(exploded_dn[0]); /* impedance match -> malloc to g_malloc */ g = g_strdup(l); free(l); + #endif + gq_exploded_free(exploded_dn); + return g; } *************** *** 1120,1127 **** --- 1142,1153 ---- fill_out_search(search_tab, server, NULL); } else if (IS_DN_ENTRY(e)) { + #if GTK_MAJOR >= 2 + fill_out_search(search_tab, server, ((dn_browse_entry *)e)->dn); + #else char *dn_dec = decoded_string(((dn_browse_entry *)e)->dn); fill_out_search(search_tab, server, dn_dec); if (dn_dec) free(dn_dec); + #endif } } *************** *** 1442,1448 **** } ! labels[0] = decoded_string(exploded_dn[0]); ! /* add a new entry - alternatively we could just set --- 1468,1476 ---- } ! #if GTK_MAJOR >= 2 ! labels[0] = exploded_dn[0]; ! #else labels[0] = decoded_string(exploded_dn[0]); ! #endif /* add a new entry - alternatively we could just set *************** *** 1462,1467 **** e, (GtkDestroyNotify) destroy_browse_entry); free(labels[0]); ! /* add dummy node to have something to expand */ labels[0] = "DUMMY"; --- 1490,1496 ---- e, (GtkDestroyNotify) destroy_browse_entry); + #if GTK_MAJOR < 2 free(labels[0]); ! #endif /* add dummy node to have something to expand */ labels[0] = "DUMMY"; Index: dt_entry.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_entry.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dt_entry.c 28 Sep 2003 03:26:25 -0000 1.9 --- dt_entry.c 2 Oct 2003 16:16:25 -0000 1.10 *************** *** 61,66 **** --- 61,72 ---- bervalLDAPMod }, + #if GTK_MAJOR < 2 decode_utf8, /* encode method */ encode_utf8, /* decode method */ + #else + /* gtk2 uses UTF-8 natively! Yipieeh */ + NULL, + NULL, + #endif }; *************** *** 100,103 **** --- 106,110 ---- } + #if GTK_MAJOR < 2 GByteArray *decode_utf8(const char *val, int len) { *************** *** 128,131 **** --- 135,139 ---- return gb; } + #endif /* Index: dt_entry.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_entry.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dt_entry.h 28 Sep 2003 03:26:25 -0000 1.5 --- dt_entry.h 2 Oct 2003 16:16:25 -0000 1.6 *************** *** 52,57 **** --- 52,59 ---- GtkWidget *widget); + #if GTK_MAJOR < 2 GByteArray *encode_utf8(const char *val, int len); GByteArray *decode_utf8(const char *val, int len); + #endif #endif Index: dt_generic_binary.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_generic_binary.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dt_generic_binary.c 29 Sep 2003 19:24:16 -0000 1.9 --- dt_generic_binary.c 2 Oct 2003 16:16:25 -0000 1.10 *************** *** 234,238 **** GtkWidget *data_widget; struct formfill *form; ! char *selected_filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector)); --- 234,238 ---- GtkWidget *data_widget; struct formfill *form; ! const char *selected_filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector)); *************** *** 336,340 **** { GtkWidget *hbox = user_data; ! char *selected_filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector)); --- 336,340 ---- { GtkWidget *hbox = user_data; ! const char *selected_filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector)); Index: dt_password.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_password.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** dt_password.c 29 Sep 2003 19:24:16 -0000 1.14 --- dt_password.c 2 Oct 2003 16:16:25 -0000 1.15 *************** *** 101,106 **** --- 101,112 ---- bervalLDAPMod /* reuse method from dt_entry */ }, + #if GTK_MAJOR < 2 decode_utf8, /* encode method */ /* reuse method from dt_entry */ encode_utf8, /* decode method */ /* reuse method from dt_entry */ + #else + /* gtk2 uses UTF-8 natively! Yipieeh */ + NULL, + NULL, + #endif }; Index: dt_text.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/dt_text.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dt_text.c 30 Sep 2003 17:20:25 -0000 1.10 --- dt_text.c 2 Oct 2003 16:16:26 -0000 1.11 *************** *** 70,75 **** --- 70,81 ---- bervalLDAPMod /* reuse method from dt_entry */ }, + #if GTK_MAJOR < 2 decode_utf8, /* encode method */ /* reuse method from dt_entry */ encode_utf8, /* decode method */ /* reuse method from dt_entry */ + #else + /* gtk2 uses UTF-8 natively! Yipieeh */ + NULL, + NULL, + #endif }; Index: encode.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/encode.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** encode.c 12 Oct 2002 12:17:08 -0000 1.20 --- encode.c 2 Oct 2003 16:16:26 -0000 1.21 *************** *** 80,86 **** #else /* HAVE_ICONV */ strncpy(native_string, ldap_string, len); ! *(native_string + len) = 0; #endif /* HAVE_ICONV */ - #ifdef DEBUG if (debug & GQ_DEBUG_ENCODE) { --- 80,85 ---- #else /* HAVE_ICONV */ strncpy(native_string, ldap_string, len); ! *(native_string + len - 1) = 0; #endif /* HAVE_ICONV */ #ifdef DEBUG if (debug & GQ_DEBUG_ENCODE) { *************** *** 142,145 **** --- 141,146 ---- { char *native_string; + assert(GTK_MAJOR < 2); + if (!string) return NULL; *************** *** 156,159 **** --- 157,162 ---- { char *ldap_string; + /* assert(GTK_MAJOR < 2); */ + if (!string) return NULL; Index: errorchain.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/errorchain.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** errorchain.c 28 Sep 2002 20:04:14 -0000 1.11 --- errorchain.c 2 Oct 2003 16:16:26 -0000 1.12 *************** *** 230,234 **** --- 230,240 ---- cur_msg = chain->msgs; while(cur_msg) { + #if GTK_MAJOR >= 2 msg_label = gtk_label_new(cur_msg->msg); + #else + char *c = decoded_string(cur_msg->msg); + msg_label = gtk_label_new(c); + if (c) free(c); + #endif gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment(GTK_MISC(msg_label), 0, 0.5); Index: formfill.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/formfill.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** formfill.c 28 Sep 2003 23:10:50 -0000 1.34 --- formfill.c 2 Oct 2003 16:16:26 -0000 1.35 *************** *** 163,167 **** } ! GList *formlist_from_entry(struct ldapserver *server, char *dn, int ocvalues_only) { GList *formlist; --- 163,167 ---- } ! GList *formlist_from_entry(struct ldapserver *server, const char *dn, int ocvalues_only) { GList *formlist; *************** *** 174,178 **** char *attr; /* , **vals; */ struct berval **bervals; - char *c = NULL; char *attrs[] = { LDAP_ALL_USER_ATTRIBUTES, LDAP_ALL_OPERATIONAL_ATTRIBUTES, --- 174,177 ---- *************** *** 184,190 **** message = g_string_sized_new(128); g_string_sprintf(message, _("fetching %s from %s"), ! c = decoded_string(dn), server->name); ! if (c) free(c); statusbar_msg(message->str); g_string_free(message, TRUE); --- 183,197 ---- message = g_string_sized_new(128); + #if GTK_MAJOR >= 2 g_string_sprintf(message, _("fetching %s from %s"), ! dn, server->name); ! #else ! { ! char *c = NULL; ! g_string_sprintf(message, _("fetching %s from %s"), ! c = decoded_string(dn), server->name); ! if (c) free(c); ! } ! #endif statusbar_msg(message->str); g_string_free(message, TRUE); Index: formfill.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/formfill.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** formfill.h 28 Sep 2003 23:14:52 -0000 1.25 --- formfill.h 2 Oct 2003 16:16:26 -0000 1.26 *************** *** 108,112 **** void free_formfill_values(struct formfill *form); GList *formlist_append(GList *formlist, struct formfill *form); ! GList *formlist_from_entry(struct ldapserver *server, char *dn, int ocvalues_only); GList *dup_formlist(GList *formlist); void dump_formlist(GList *formlist); --- 108,112 ---- void free_formfill_values(struct formfill *form); GList *formlist_append(GList *formlist, struct formfill *form); ! GList *formlist_from_entry(struct ldapserver *server, const char *dn, int ocvalues_only); GList *dup_formlist(GList *formlist); void dump_formlist(GList *formlist); Index: input.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.c,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** input.c 30 Sep 2003 17:20:25 -0000 1.57 --- input.c 2 Oct 2003 16:16:26 -0000 1.58 *************** *** 573,577 **** --- 573,579 ---- struct formfill *ff; int row, row_arrow, vcnt, currcnt; + #if GTK_MAJOR < 2 char value[MAX_DN_LEN]; + #endif char *decode_buf = NULL; int decode_buf_allocated = 0; *************** *** 616,622 **** gtk_signal_connect_object(GTK_OBJECT(inputbox), "activate", GTK_SIGNAL_FUNC(iform->activate), (gpointer) iform); ! if(iform->dn) gtk_entry_set_text(GTK_ENTRY(inputbox), decode_string(value, iform->dn, strlen(iform->dn))); gtk_signal_connect(GTK_OBJECT(inputbox), "changed", --- 618,629 ---- gtk_signal_connect_object(GTK_OBJECT(inputbox), "activate", GTK_SIGNAL_FUNC(iform->activate), (gpointer) iform); ! if(iform->dn) { ! #if GTK_MAJOR >= 2 ! gtk_entry_set_text(GTK_ENTRY(inputbox), iform->dn); ! #else gtk_entry_set_text(GTK_ENTRY(inputbox), decode_string(value, iform->dn, strlen(iform->dn))); + #endif + } gtk_signal_connect(GTK_OBJECT(inputbox), "changed", *************** *** 818,833 **** ! void edit_entry(struct ldapserver *server, char *dn) { GList *oldlist, *newlist; ! GtkWidget *edit_window, *vbox; ! char *name; struct inputform *iform; ! edit_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); name = decoded_string(dn); gtk_window_set_title(GTK_WINDOW(edit_window), name); free(name); gtk_widget_set_usize(edit_window, 500, 450); --- 825,844 ---- ! void edit_entry(struct ldapserver *server, const char *dn) { GList *oldlist, *newlist; ! GtkWidget *vbox; struct inputform *iform; + GtkWidget* edit_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); ! #if GTK_MAJOR >= 2 ! gtk_window_set_title(GTK_WINDOW(edit_window), dn); ! #else ! char *name; name = decoded_string(dn); gtk_window_set_title(GTK_WINDOW(edit_window), name); free(name); + #endif gtk_widget_set_usize(edit_window, 500, 450); *************** *** 872,876 **** ! void new_from_entry(struct ldapserver *server, char *dn) { GList *formlist; --- 883,887 ---- ! void new_from_entry(struct ldapserver *server, const char *dn) { GList *formlist; *************** *** 1239,1246 **** --- 1250,1261 ---- /* 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 *************** *** 1374,1379 **** g_string_sprintf(message, _("You can only change the RDN of the DN (%s)"), ! c = decoded_string(oldrdn[0])); ! if (c) free(c); error_push(context, message->str); error = 1; --- 1389,1393 ---- g_string_sprintf(message, _("You can only change the RDN of the DN (%s)"), ! oldrdn[0]); error_push(context, message->str); error = 1; *************** *** 1384,1391 **** if(!error) { g_string_sprintfa(message, _("modifying RDN to %s"), c = decoded_string(rdn[0])); - statusbar_msg(message->str); if (c) free(c); /* check to see if the rdn exists as an attribute. If it --- 1398,1409 ---- 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 Index: input.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** input.h 30 Sep 2003 17:20:25 -0000 1.13 --- input.h 2 Oct 2003 16:16:26 -0000 1.14 *************** *** 64,69 **** void build_or_update_inputform(struct inputform *form, gboolean build); void build_inputform(struct inputform *iform); ! void edit_entry(struct ldapserver *server, char *dn); ! void new_from_entry(struct ldapserver *server, char *dn); void update_formlist(struct inputform *iform); void clear_table(struct inputform *iform); --- 64,69 ---- void build_or_update_inputform(struct inputform *form, gboolean build); void build_inputform(struct inputform *iform); ! void edit_entry(struct ldapserver *server, const char *dn); ! void new_from_entry(struct ldapserver *server, const char *dn); void update_formlist(struct inputform *iform); void clear_table(struct inputform *iform); Index: search.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/search.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** search.c 30 Sep 2003 22:34:49 -0000 1.34 --- search.c 2 Oct 2003 16:16:26 -0000 1.35 *************** *** 535,541 **** --- 535,545 ---- if(config.showdn) { + #if GTK_MAJOR >= 2 + strcpy(tolist[0], dn); + #else decoded_value = decoded_string(dn); strcpy(tolist[0], decoded_value); free(decoded_value); + #endif cl[0] = tolist[0]; } *************** *** 568,571 **** --- 572,583 ---- /* that's an awful lot of mallocs in the innermost loop, but then we don't want to count on max valuelen either */ + #if GTK_MAJOR >= 2 + if(i == 0) + strcpy(tolist[cur_col], vals[i]); + else { + strcat(tolist[cur_col], " "); + strcat(tolist[cur_col], vals[i]); + } + #else decoded_value = decoded_string(vals[i]); if(i == 0) *************** *** 576,579 **** --- 588,592 ---- } free(decoded_value); + #endif } ldap_value_free(vals); Index: tinput.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/tinput.c,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** tinput.c 13 Jul 2002 16:47:39 -0000 1.39 --- tinput.c 2 Oct 2003 16:16:26 -0000 1.40 *************** *** 92,96 **** * fetch objectclasses in entry from server and build GList of formfill with it */ ! GList *formfill_from_entry_objectclass(struct ldapserver *server, char *dn) { GList *formlist, *oclist, *tmplist; --- 92,96 ---- * fetch objectclasses in entry from server and build GList of formfill with it */ ! GList *formfill_from_entry_objectclass(struct ldapserver *server, const char *dn) { GList *formlist, *oclist, *tmplist; Index: tinput.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/tinput.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tinput.h 29 Sep 2003 19:24:17 -0000 1.13 --- tinput.h 2 Oct 2003 16:16:26 -0000 1.14 *************** *** 32,36 **** GList *formfill_from_template(struct ldapserver *schemaserver, struct gq_template *template); ! GList *formfill_from_entry_objectclass(struct ldapserver *server, char *dn); GList *add_attrs_by_oc(struct ldapserver *server, GList *oclist); GList *add_schema_attrs(struct ldapserver *server, GList *value_list); --- 32,36 ---- GList *formfill_from_template(struct ldapserver *schemaserver, struct gq_template *template); ! GList *formfill_from_entry_objectclass(struct ldapserver *server, const char *dn); GList *add_attrs_by_oc(struct ldapserver *server, GList *oclist); GList *add_schema_attrs(struct ldapserver *server, GList *value_list); Index: util.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.c,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** util.c 1 Oct 2003 22:32:34 -0000 1.59 --- util.c 2 Oct 2003 16:16:26 -0000 1.60 *************** *** 723,727 **** * GTK event queue */ ! void statusbar_msg(char *message) { if(!context) --- 723,727 ---- * GTK event queue */ ! void statusbar_msg(const char *message) { if(!context) *************** *** 741,747 **** * display message in main window's statusbar, and flushes the * GTK event queue, UTF-8 version */ ! void statusbar_msg_utf8(char *message) { int len = strlen(message); char *buf = g_malloc(len + 10); --- 741,751 ---- * display message in main window's statusbar, and flushes the * GTK event queue, UTF-8 version + * */ ! void statusbar_msg_utf8(const char *message) { + #if GTK_MAJOR >= 2 + statusbar_msg(message); + #else int len = strlen(message); char *buf = g_malloc(len + 10); *************** *** 762,765 **** --- 766,770 ---- g_free(buf); + #endif } Index: util.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** util.h 30 Sep 2003 17:20:26 -0000 1.21 --- util.h 2 Oct 2003 16:16:26 -0000 1.22 *************** *** 66,70 **** const gpointer detokenize_data(struct tokenlist *list, int token); char *get_username(void); ! void statusbar_msg(char *message); struct ldapserver *server_by_name(const char *name); int is_leaf_entry(struct ldapserver *server, char *dn); --- 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); |