1998-11-24 13:01:09 -05:00
|
|
|
#include "cpluscommon.h"
|
|
|
|
|
#include "gtk.h"
|
|
|
|
|
#include <lber.h>
|
|
|
|
|
#include <ldap.h>
|
|
|
|
|
#include <My_Window.h>
|
|
|
|
|
#include <Gtk_LdapItem.h>
|
|
|
|
|
#include <Gtk_LdapTreeItem.h>
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
My_Window *window;
|
|
|
|
|
Gtk_LdapItem *treeresult;
|
|
|
|
|
Gtk_Tree *tree, *subtree;
|
|
|
|
|
Gtk_LdapTreeItem *treeitem;
|
|
|
|
|
LDAPMessage **thing;
|
|
|
|
|
LDAP *ld;
|
1998-11-26 08:23:06 -05:00
|
|
|
char *host = NULL;
|
|
|
|
|
char *base_dn = NULL;
|
|
|
|
|
int c, port = 0;
|
|
|
|
|
|
|
|
|
|
while ((c = getopt(argc, argv, "b:s:p:h")) != -1) {
|
|
|
|
|
switch (c) {
|
|
|
|
|
case 'b':
|
|
|
|
|
base_dn = optarg; break;
|
|
|
|
|
case 's':
|
|
|
|
|
host = strdup(optarg); break;
|
|
|
|
|
case 'p':
|
|
|
|
|
port = atoi(optarg); break;
|
|
|
|
|
case 'h':
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr, "Usage: %s [-s server] [-p port] [-b base_dn]\n", argv[0]);
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (base_dn == NULL) base_dn = "o=University of Michigan, c=US";
|
|
|
|
|
if (host == NULL) host = "localhost";
|
|
|
|
|
if (port == 0) port = LDAP_PORT;
|
1998-11-24 13:01:09 -05:00
|
|
|
|
|
|
|
|
Gtk_Main m(&argc, &argv);
|
|
|
|
|
|
|
|
|
|
window = new My_Window(GTK_WINDOW_TOPLEVEL);
|
|
|
|
|
|
1998-11-26 08:23:06 -05:00
|
|
|
if ((ld = ldap_open(host, port)) == NULL) {
|
1998-11-24 13:01:09 -05:00
|
|
|
perror("connection");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tree = new Gtk_Tree();
|
|
|
|
|
treeresult = window->make_tree(window, ld, base_dn);
|
|
|
|
|
treeitem = new Gtk_LdapTreeItem(*treeresult->treeitem);
|
1998-11-26 19:56:29 -05:00
|
|
|
// treeitem->remove_c(treeitem->getchild()->gtkobj());
|
|
|
|
|
// gtk_widget_destroy(GTK_WIDGET(treeitem->xpm_label->gtkobj()));
|
|
|
|
|
treeresult->treeitem->setType(ROOT_NODE);
|
|
|
|
|
tree->append(*treeitem);
|
1998-11-24 13:01:09 -05:00
|
|
|
if (treeresult->tree != NULL) {
|
|
|
|
|
subtree = new Gtk_Tree(*treeresult->tree);
|
|
|
|
|
printf("inserting %s into root\n", base_dn);
|
1998-11-26 07:21:23 -05:00
|
|
|
treeitem->set_subtree(*subtree);
|
1998-11-24 13:01:09 -05:00
|
|
|
}
|
|
|
|
|
treeitem->show();
|
|
|
|
|
window->scroller->add(tree);
|
|
|
|
|
tree->show();
|
|
|
|
|
window->scroller->show();
|
1998-11-26 19:56:29 -05:00
|
|
|
treeitem->getDetails();
|
1998-11-24 13:01:09 -05:00
|
|
|
window->set_title("Hello");
|
|
|
|
|
window->activate();
|
|
|
|
|
|
1998-11-26 19:56:29 -05:00
|
|
|
window->set_usize(600, 500);
|
1998-11-24 13:01:09 -05:00
|
|
|
|
|
|
|
|
window->show();
|
|
|
|
|
|
|
|
|
|
m.run();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|