From fa96c5bacb704e1aea8e9db491d0606744913360 Mon Sep 17 00:00:00 2001 From: "Predrag \"Pele\" Balorda" Date: Mon, 30 Nov 1998 00:01:14 +0000 Subject: [PATCH] updates to gtk-tool, new functionality, uses config cn --- contrib/gtk-tool/ChangeLog | 10 ++++++++++ contrib/gtk-tool/Gtk_LdapItem.h | 4 ++++ contrib/gtk-tool/Gtk_LdapServer.h | 2 +- contrib/gtk-tool/Gtk_LdapTreeItem.cc | 9 +++++---- contrib/gtk-tool/Makefile | 4 ++-- contrib/gtk-tool/My_Window.cc | 17 ++++++++++++++++- contrib/gtk-tool/My_Window.h | 1 + contrib/gtk-tool/main.cc | 24 ++++++------------------ 8 files changed, 45 insertions(+), 26 deletions(-) diff --git a/contrib/gtk-tool/ChangeLog b/contrib/gtk-tool/ChangeLog index dbd38b36de..097ae56707 100644 --- a/contrib/gtk-tool/ChangeLog +++ b/contrib/gtk-tool/ChangeLog @@ -1,5 +1,15 @@ ChangeLog for gtk-tool +29/11/1998 - Pele + * Added Gtk_LdapServer class + * Started using cn=config, ldap_get_option (not sure about get_option + though, cn=config looks much nicer for the future-proofing) + * Can traverse, display and serve two (or possibly/hopefully) more + databases on the local machine - remote machines also possible - + need to use "-s hostname" + * The program needs the "-s" switch! Without it it won't run (temporary + "feature") + 28/11/1998 - Pele * Fixes, enhancements, started using ldap utility api * It now traverses the whole tree at startup, not sure if it's smart diff --git a/contrib/gtk-tool/Gtk_LdapItem.h b/contrib/gtk-tool/Gtk_LdapItem.h index 8d63a1498a..73c1a7cd14 100644 --- a/contrib/gtk-tool/Gtk_LdapItem.h +++ b/contrib/gtk-tool/Gtk_LdapItem.h @@ -9,5 +9,9 @@ class Gtk_LdapItem { public: Gtk_Tree *tree; Gtk_LdapTreeItem *treeitem; + G_List *value_list; + char *attribute_name; + G_List *attribute_list; + char *entry_name; }; #endif diff --git a/contrib/gtk-tool/Gtk_LdapServer.h b/contrib/gtk-tool/Gtk_LdapServer.h index a80dc9fe04..21c1a1ef4b 100644 --- a/contrib/gtk-tool/Gtk_LdapServer.h +++ b/contrib/gtk-tool/Gtk_LdapServer.h @@ -2,7 +2,7 @@ #define GTK_LDAPSERVER_H #include "gtk.h" #include -#include +/*#include */ #include #include #include diff --git a/contrib/gtk-tool/Gtk_LdapTreeItem.cc b/contrib/gtk-tool/Gtk_LdapTreeItem.cc index 7efcb58d6c..5a44bd3ef0 100644 --- a/contrib/gtk-tool/Gtk_LdapTreeItem.cc +++ b/contrib/gtk-tool/Gtk_LdapTreeItem.cc @@ -20,7 +20,7 @@ Gtk_LdapTreeItem::~Gtk_LdapTreeItem() { } void Gtk_LdapTreeItem::setType(int t) { - cout << "Gtk_LdapTreeItem::setType(" << t << ")" << endl; +// cout << "Gtk_LdapTreeItem::setType(" << t << ")" << endl; Gtk_Pixmap *xpm_icon; Gtk_Label *label; if (this->getchild() != NULL) { @@ -46,7 +46,7 @@ void Gtk_LdapTreeItem::setType(int t) { } int Gtk_LdapTreeItem::showDetails() { - cout << "Gtk_LdapTreeItem::showDetails()" << endl; +// cout << "Gtk_LdapTreeItem::showDetails()" << endl; if (this->notebook != NULL) { if (par->viewport->getchild() != NULL) { par->viewport->remove_c(par->viewport->getchild()->gtkobj()); @@ -58,10 +58,11 @@ int Gtk_LdapTreeItem::showDetails() { } else this->getDetails(); this->showDetails(); + return 0; } int Gtk_LdapTreeItem::getDetails() { - cout << "Gtk_LdapTreeItem::getDetails()" << endl; +// cout << "Gtk_LdapTreeItem::getDetails()" << endl; int error, entriesCount; BerElement *ber; LDAPMessage *entry; @@ -99,7 +100,7 @@ int Gtk_LdapTreeItem::getDetails() { } } this->setType(1); - cout << "."; +// cout << "."; return 0; } void Gtk_LdapTreeItem::select_impl() { diff --git a/contrib/gtk-tool/Makefile b/contrib/gtk-tool/Makefile index 65a52f157f..9932f81945 100644 --- a/contrib/gtk-tool/Makefile +++ b/contrib/gtk-tool/Makefile @@ -8,8 +8,8 @@ LIBS=-lXext -lgtkmm -lX11 -lXt -lXxf86dga .EXPORT_ALL_VARIABLES: -SOURCES= My_Window.cc Gtk_LdapTreeItem.cc main.cc -OBJECTS= My_Window.o Gtk_LdapTreeItem.o main.o +SOURCES= My_Window.cc Gtk_LdapTreeItem.cc Gtk_LdapServer.cc main.cc +OBJECTS= My_Window.o Gtk_LdapTreeItem.o Gtk_LdapServer.o main.o ################################################################################ diff --git a/contrib/gtk-tool/My_Window.cc b/contrib/gtk-tool/My_Window.cc index 6fbe8c45c9..cece9bdd8f 100644 --- a/contrib/gtk-tool/My_Window.cc +++ b/contrib/gtk-tool/My_Window.cc @@ -4,6 +4,8 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) { cout << "My_Window(t)" << endl; Gtk_VBox *main_hbox; Gtk_HBox *top_hbox; + Gtk_Menu *menu; + Gtk_MenuItem *file_menu, *menuitem; pane = new Gtk_HPaned(); this->scroller = new Gtk_ScrolledWindow(); @@ -21,6 +23,18 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) { this->scroller2->show(); top_hbox = new Gtk_HBox(); + menu = new Gtk_Menu(); + menuitem = new Gtk_MenuItem("Quit"); + menu->append(*menuitem); + this->menubar = new Gtk_MenuBar(); + file_menu = new Gtk_MenuItem("File"); + file_menu->set_submenu(menu); + this->menubar->append(*file_menu); + menuitem->show(); + menu->show(); + file_menu->show(); +// top_hbox->pack_start(*this->menubar, TRUE, TRUE, 1); + this->menubar->show(); this->urlfield = new Gtk_Entry(); top_hbox->pack_start(*this->urlfield, TRUE, TRUE, 1); this->urlfield->show(); @@ -30,6 +44,7 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) { this->display_button->show(); main_hbox = new Gtk_VBox(); + main_hbox->pack_start(*this->menubar, FALSE, FALSE, 1); main_hbox->pack_start(*top_hbox, FALSE, TRUE, 1); main_hbox->pack_end(*pane, TRUE, TRUE, 1); top_hbox->show(); @@ -54,7 +69,7 @@ void My_Window::expand(Gtk_TreeItem *t) { g_print("%s selected\n", name); } -gint My_Window::delete_event_impl(GdkEventAny *) { +gint My_Window::delete_event_impl(GdkEventAny*) { Gtk_Main::instance()->quit(); return 0; } diff --git a/contrib/gtk-tool/My_Window.h b/contrib/gtk-tool/My_Window.h index f39091ef0a..93b86f8ec8 100644 --- a/contrib/gtk-tool/My_Window.h +++ b/contrib/gtk-tool/My_Window.h @@ -19,6 +19,7 @@ public: Gtk_Entry *urlfield; Gtk_Button *display_button; Gtk_Paned *pane; + Gtk_MenuBar *menubar; My_Window(GtkWindowType t); ~My_Window(); void do_display(); diff --git a/contrib/gtk-tool/main.cc b/contrib/gtk-tool/main.cc index 44c8e41aa5..d473ea01df 100644 --- a/contrib/gtk-tool/main.cc +++ b/contrib/gtk-tool/main.cc @@ -4,16 +4,15 @@ #include #include #include -#include +#include int main(int argc, char **argv) { My_Window *window; Gtk_LdapItem *treeresult; Gtk_Tree *tree, *subtree; - Gtk_LdapTreeItem *treeitem; + Gtk_Tree *machine, *machinetree; + Gtk_LdapServer *treeitem; Gtk_Viewport *viewport; - LDAPMessage **thing; - LDAP *ld; char *host = NULL; char *base_dn = NULL; int c, port = 0; @@ -33,30 +32,19 @@ int main(int argc, char **argv) { } } -// if (base_dn == NULL) base_dn = ldap_get_option(NULL, LDAP_OPT_BASE); - if (base_dn == NULL) base_dn = "o=University of Michigan, c=US"; +// if (base_dn == NULL) base_dn = "o=University of Michigan, c=US"; if (host == NULL) ldap_get_option(NULL, LDAP_OPT_HOST_NAME, host); //host = "localhost"; + cout << host << endl; if (port == 0) port = LDAP_PORT; Gtk_Main m(&argc, &argv); window = new My_Window(GTK_WINDOW_TOPLEVEL); - if ((ld = ldap_open(host, port)) == NULL) { - perror("connection"); - } - tree = new Gtk_Tree(); - treeresult = window->make_tree(window, ld, base_dn); - treeitem = new Gtk_LdapTreeItem(*treeresult->treeitem); -// treeresult->treeitem->setType(ROOT_NODE); + treeitem = new Gtk_LdapServer(window, host, port); tree->append(*treeitem); - if (treeresult->tree != NULL) { - subtree = new Gtk_Tree(*treeresult->tree); - // cout << "Inserting " << base_dn << " into root" << endl; - treeitem->set_subtree(*subtree); - } treeitem->show(); viewport = new Gtk_Viewport(); viewport->add(tree);