mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-04-24 15:32:22 +08:00
Update contrib with the latest.
This commit is contained in:
parent
cddb59b209
commit
d59966a9cb
@ -1,5 +1,25 @@
|
||||
ChangeLog for gtk-tool
|
||||
|
||||
03/12/1998 - Pele
|
||||
* Added support for multiple servers (via multiple -s options)
|
||||
* More testing
|
||||
* Started experimenting with status bar for display of various info
|
||||
* Got rid of many warning and error messages generate by gtk
|
||||
* Added a new icon for objectclass=alias;
|
||||
* Display of some ldap options aquired with ldap_get_option when
|
||||
server selected.
|
||||
* Traversing set to only 1 subtree (then 1 by 1);
|
||||
* Started experimenting with a progress bar for traversal
|
||||
(so users don't get bored while waiting for subtrees to be aquired and
|
||||
constructed)
|
||||
|
||||
02/12/1998 - Pele
|
||||
* Added Gtk_LdapTree class
|
||||
* Added utils (with debug only)
|
||||
* "Smart" traversing of ldap tree (only 2-deep, then add 2 subtrees as
|
||||
the tree gets expanded)
|
||||
* Lots of updates and bug-fixes
|
||||
|
||||
29/11/1998 - Pele
|
||||
* Added Gtk_LdapServer class
|
||||
* Started using cn=config, ldap_get_option (not sure about get_option
|
||||
|
@ -9,10 +9,13 @@ Gtk_LdapServer::Gtk_LdapServer() : Gtk_TreeItem() {
|
||||
}
|
||||
|
||||
Gtk_LdapServer::Gtk_LdapServer(My_Window *w, char *h, int p) : Gtk_TreeItem() {
|
||||
char *s, *s2;
|
||||
this->par = w;
|
||||
this->hostname = h;
|
||||
this->port = p;
|
||||
cout << this->hostname << this->port << endl;
|
||||
this->notebook = NULL;
|
||||
debug("%s %i\n", this->hostname, this->port);
|
||||
this->setType(1);
|
||||
this->getConfig();
|
||||
}
|
||||
|
||||
@ -20,24 +23,27 @@ Gtk_LdapServer::Gtk_LdapServer(GtkTreeItem *t) : Gtk_TreeItem(t) {
|
||||
}
|
||||
|
||||
Gtk_LdapServer::~Gtk_LdapServer() {
|
||||
cout << "Bye" << endl;
|
||||
debug("Bye\n");
|
||||
delete this;
|
||||
}
|
||||
|
||||
void Gtk_LdapServer::setType(int t) {
|
||||
cout << "Gtk_LdapServer::setType(" << t << ")" << endl;
|
||||
debug("Gtk_LdapServer::setType(%i)\n", t);
|
||||
Gtk_Pixmap *xpm_icon;
|
||||
Gtk_Label *label;
|
||||
char *c = NULL;
|
||||
if (this->getchild() != NULL) {
|
||||
xpm_label = new Gtk_HBox(GTK_HBOX(this->getchild()->gtkobj()));
|
||||
xpm_label->remove_c(xpm_label->children()->nth_data(0));
|
||||
xpm_label->remove_c(xpm_label->children()->nth_data(0));
|
||||
}
|
||||
else xpm_label = new Gtk_HBox();
|
||||
cout << this->hostname << endl;
|
||||
debug(this->hostname);
|
||||
if (strcasecmp(this->hostname,"localhost") == 0)
|
||||
xpm_icon=new Gtk_Pixmap(*xpm_label, local_server);
|
||||
else xpm_icon=new Gtk_Pixmap(*xpm_label, remote_server);
|
||||
// sprintf(c, "%s:%i", this->hostname, this->port);
|
||||
// printf("%s\n", c);
|
||||
label = new Gtk_Label(this->hostname);
|
||||
xpm_label->pack_start(*xpm_icon, false, false, 1);
|
||||
xpm_label->pack_start(*label, false, false, 1);
|
||||
@ -48,26 +54,28 @@ void Gtk_LdapServer::setType(int t) {
|
||||
}
|
||||
|
||||
int Gtk_LdapServer::showDetails() {
|
||||
cout << "Gtk_LdapServer::showDetails()" << endl;
|
||||
this->getDetails();
|
||||
/*
|
||||
debug("Gtk_LdapServer::showDetails()\n");
|
||||
if (this->notebook != NULL) {
|
||||
// debug("Have notebook here");
|
||||
if (par->viewport->getchild() != NULL) {
|
||||
// debug(" and viewport has children");
|
||||
par->viewport->remove_c(par->viewport->getchild()->gtkobj());
|
||||
// debug(" which have been removed");
|
||||
}
|
||||
// else debug(" and viewport without children");
|
||||
par->viewport->add(this->notebook);
|
||||
this->notebook->show();
|
||||
par->viewport->show();
|
||||
return 0;
|
||||
}
|
||||
else this->getDetails();
|
||||
if (this->getOptions() != 0) return 1;
|
||||
this->showDetails();
|
||||
*/
|
||||
// debug("done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Gtk_LdapServer::getConfig() {
|
||||
cout << "Gtk_LdapServer::getConfig()" << endl;
|
||||
debug("Gtk_LdapServer::getConfig()\n");
|
||||
int error, entriesCount;
|
||||
LDAPMessage *entry, *result_identifier;
|
||||
BerElement *ber;
|
||||
@ -83,142 +91,235 @@ int Gtk_LdapServer::getConfig() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cout << entriesCount << " entry" << endl;
|
||||
debug("%i entry\n", entriesCount);
|
||||
for (entry = ldap_first_entry(this->ld, result_identifier); entry != NULL; entry = ldap_next_entry(this->ld, result_identifier)) {
|
||||
for (attribute = ldap_first_attribute(this->ld, entry, &ber); attribute != NULL; attribute = ldap_next_attribute(this->ld, entry, ber)) {
|
||||
cout << "Attrib: " << attribute << endl;
|
||||
debug("Attrib: %s\n", attribute);
|
||||
if (strcasecmp(attribute, "database") == 0) {
|
||||
cout << "have database here" << endl;
|
||||
debug("have database here\n");
|
||||
this->databases = new G_List<char>;
|
||||
t = ldap_get_values(this->ld, entry, attribute);
|
||||
for (int i=0; i<ldap_count_values(t); i++) {
|
||||
this->databases->append(strdup(t[i]));
|
||||
}
|
||||
ldap_value_free(t);
|
||||
cout << "databases loaded" << endl;
|
||||
debug("databases loaded\n");
|
||||
for (int i=0; i<this->databases->length(); i++) {
|
||||
cout << "database(" << i << ") " << this->databases->nth_data(i) << endl;
|
||||
debug("database(%i) %s\n", i, this->databases->nth_data(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << "entry done" << endl;
|
||||
debug("entry done\n");
|
||||
}
|
||||
// cout << "got " << entriesCount << " entries" << endl;
|
||||
// debug("got %i entries\n", entriesCount);
|
||||
return entriesCount;
|
||||
}
|
||||
|
||||
int Gtk_LdapServer::getDetails() {
|
||||
cout << "Gtk_LdapServer::getDetails()" << endl;
|
||||
Gtk_HBox *hbox;
|
||||
Gtk_VBox *vbox;
|
||||
char* Gtk_LdapServer::getOptDescription(int option) {
|
||||
debug("Gtk_LdapServer::getOptDescription(%i) ", option);
|
||||
char *c;
|
||||
switch (option) {
|
||||
case LDAP_OPT_API_INFO: c = "API info"; break;
|
||||
case LDAP_OPT_CLIENT_CONTROLS: c = "Client controls"; break;
|
||||
case LDAP_OPT_DEREF: c = "Dereference"; break;
|
||||
case LDAP_OPT_DESC: c = "Description"; break;
|
||||
case LDAP_OPT_DNS: c = "DNS Lookup"; break;
|
||||
case LDAP_OPT_ERROR_NUMBER: c = "Error number"; break;
|
||||
case LDAP_OPT_ERROR_STRING: c = "Error string"; break;
|
||||
case LDAP_OPT_SIZELIMIT: c = "Size limit"; break;
|
||||
case LDAP_OPT_TIMELIMIT: c = "Time limit"; break;
|
||||
case LDAP_OPT_REFERRALS: c = "Referrals"; break;
|
||||
case LDAP_OPT_RESTART: c = "Started"; break;
|
||||
case LDAP_OPT_PROTOCOL_VERSION: c = "Protocol version"; break;
|
||||
case LDAP_OPT_HOST_NAME: c = "Host name"; break;
|
||||
case LDAP_OPT_SERVER_CONTROLS: c = "Server controls"; break;
|
||||
default: c = "No description"; break;
|
||||
}
|
||||
debug("%s\n", c);
|
||||
return c;
|
||||
}
|
||||
|
||||
int Gtk_LdapServer::getOptType(int option) {
|
||||
debug("Gtk_LdapServer::getOptType(%i) ", option);
|
||||
int type; /* 0 = int, 1 = string, 2 = boolean */
|
||||
switch(option) {
|
||||
/* ints */
|
||||
case LDAP_OPT_DEREF:
|
||||
case LDAP_OPT_DESC:
|
||||
case LDAP_OPT_SIZELIMIT:
|
||||
case LDAP_OPT_TIMELIMIT:
|
||||
case LDAP_OPT_ERROR_NUMBER:
|
||||
case LDAP_OPT_PROTOCOL_VERSION: type = 0; break;
|
||||
/* strings */
|
||||
case LDAP_OPT_ERROR_STRING:
|
||||
case LDAP_OPT_HOST_NAME: type = 1; break;
|
||||
/* bools */
|
||||
case LDAP_OPT_REFERRALS:
|
||||
case LDAP_OPT_DNS:
|
||||
case LDAP_OPT_RESTART: type = 2; break;
|
||||
case LDAP_OPT_SERVER_CONTROLS:
|
||||
case LDAP_OPT_CLIENT_CONTROLS:
|
||||
case LDAP_OPT_API_INFO:
|
||||
default: type = 0; break;
|
||||
}
|
||||
debug("%i\n", type);
|
||||
return type;
|
||||
}
|
||||
|
||||
int Gtk_LdapServer::getOptions() {
|
||||
debug("Gtk_LdapServer::getOptions()\n");
|
||||
if (this->notebook != NULL) return 0;
|
||||
Gtk_HBox *hbox, *mini_hbox;
|
||||
Gtk_VBox *vbox, *mini_vbox;
|
||||
Gtk_Table *table;
|
||||
Gtk_Label *label;
|
||||
Gtk_RadioButton *radio1, *radio2;
|
||||
char *val;
|
||||
int ival;
|
||||
char *s_value;
|
||||
int i_value;
|
||||
char *thing;
|
||||
int things[9] = {
|
||||
LDAP_OPT_API_INFO,
|
||||
// LDAP_OPT_CLIENT_CONTROLS,
|
||||
// LDAP_OPT_DESC,
|
||||
LDAP_OPT_DEREF,
|
||||
LDAP_OPT_DNS,
|
||||
// LDAP_OPT_ERROR_NUMBER,
|
||||
// LDAP_OPT_ERROR_STRING,
|
||||
LDAP_OPT_HOST_NAME,
|
||||
LDAP_OPT_PROTOCOL_VERSION,
|
||||
LDAP_OPT_REFERRALS,
|
||||
LDAP_OPT_RESTART,
|
||||
// LDAP_OPT_SERVER_CONTROLS,
|
||||
LDAP_OPT_SIZELIMIT,
|
||||
LDAP_OPT_TIMELIMIT
|
||||
};
|
||||
|
||||
if (GTK_TREE_ITEM(this->gtkobj())->subtree == NULL) {
|
||||
/* if (GTK_TREE_ITEM(this->gtkobj())->subtree == NULL) {
|
||||
this->getSubtree();
|
||||
}
|
||||
} */
|
||||
|
||||
/*
|
||||
cout << "getting ldap options";
|
||||
vbox = new Gtk_VBox();
|
||||
opt_util = new LdapOpts();
|
||||
// debug("getting ldap options");
|
||||
// vbox = new Gtk_VBox();
|
||||
table = new Gtk_Table(11, 2, TRUE);
|
||||
|
||||
for (int i=0; i<sizeof(things); i++) {
|
||||
cout << i << endl;
|
||||
hbox = new Gtk_HBox();
|
||||
label = new Gtk_Label(LdapOpts->getOption(things[i]);
|
||||
for (int i=0; i<9; i++) {
|
||||
// debug("%i\n", i);
|
||||
hbox = new Gtk_HBox(TRUE, 2);
|
||||
hbox->border_width(2);
|
||||
thing = this->getOptDescription(things[i]);
|
||||
label = new Gtk_Label(thing);
|
||||
label->set_justify(GTK_JUSTIFY_LEFT);
|
||||
label->set_alignment(0, 0);
|
||||
hbox->pack_start(*label);
|
||||
label->show();
|
||||
int tipus = opt_util->getType(things[i]);
|
||||
int tipus = this->getOptType(things[i]);
|
||||
switch (tipus) {
|
||||
case 0:
|
||||
ldap_get_option(NULL, things[i], &val);
|
||||
label = new Gtk_Label(val);
|
||||
ldap_get_option(NULL, things[i], &i_value);
|
||||
debug("%s value %d\n", thing, i_value);
|
||||
sprintf(s_value, "%d", i_value);
|
||||
label = new Gtk_Label(s_value);
|
||||
label->set_justify(GTK_JUSTIFY_LEFT);
|
||||
label->set_alignment(0, 0);
|
||||
hbox->pack_end(*label);
|
||||
label->show();
|
||||
break;
|
||||
case 1:
|
||||
ldap_get_option(NULL, numerals[i], &ival);
|
||||
sprintf(val, "%i", ival);
|
||||
label = new Gtk_Label(val);
|
||||
ldap_get_option(this->ld, things[i], &s_value);
|
||||
label = new Gtk_Label(s_value);
|
||||
label->set_justify(GTK_JUSTIFY_LEFT);
|
||||
label->set_alignment(0, 0);
|
||||
hbox->pack_end(*label);
|
||||
label->show();
|
||||
break;
|
||||
case 2:
|
||||
ldap_get_option(NULL, booleans[i], &ival);
|
||||
sprintf(val, "%s", ival == (int) LDAP_OPT_ON ? "on" : "off");
|
||||
label = new Gtk_Label(val);
|
||||
ldap_get_option(this->ld, things[i], &i_value);
|
||||
// sprintf(s_value, "%s", i_value == (int) LDAP_OPT_ON ? "on" : "off");
|
||||
// label = new Gtk_Label(s_value);
|
||||
radio1 = new Gtk_RadioButton(static_cast<GSList*>(0), "Enabled");
|
||||
radio2 = new Gtk_RadioButton(*radio1, "Disabled");
|
||||
if (i_value == 1) radio1->set_state(true);
|
||||
else radio2->set_state(true);
|
||||
mini_hbox = new Gtk_HBox(FALSE, 2);
|
||||
mini_hbox->border_width(2);
|
||||
mini_hbox->pack_start(*radio1);
|
||||
radio1->show();
|
||||
mini_hbox->pack_end(*radio2);
|
||||
radio2->show();
|
||||
hbox->pack_end(*mini_hbox);
|
||||
mini_hbox->show();
|
||||
break;
|
||||
default:
|
||||
label = new Gtk_Label("Nothing");
|
||||
label->set_justify(GTK_JUSTIFY_LEFT);
|
||||
label->set_alignment(0, 0);
|
||||
hbox->pack_end(*label);
|
||||
label->show();
|
||||
break;
|
||||
}
|
||||
|
||||
hbox->pack_start(*label);
|
||||
label->show();
|
||||
vbox->pack_start(*hbox);
|
||||
// hbox->pack_end(*label);
|
||||
// label->show();
|
||||
table->attach_defaults(*hbox, 0, 2, i, i+1);
|
||||
hbox->show();
|
||||
|
||||
}
|
||||
|
||||
vbox->border_width(2);
|
||||
this->notebook = new Gtk_Viewport();
|
||||
this->notebook->add(*vbox);
|
||||
vbox->show();
|
||||
*/
|
||||
this->setType(1);
|
||||
table->border_width(2);
|
||||
this->notebook = new Gtk_Frame("LDAP Options");
|
||||
this->notebook->add(*table);
|
||||
table->show();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Gtk_LdapServer::getSubtree() {
|
||||
cout << "Gtk_LdapServer::getSubtree()" << endl;
|
||||
Gtk_LdapItem *treeresult;
|
||||
Gtk_Tree *tree, *subtree;
|
||||
Gtk_Tree* Gtk_LdapServer::getSubtree() {
|
||||
debug("Gtk_LdapServer::getSubtree()\n");
|
||||
Gtk_LdapTree *tree, *subtree;
|
||||
Gtk_LdapTreeItem *treeitem;
|
||||
int entries;
|
||||
|
||||
cout << "this->hostname=" << this->hostname << endl;
|
||||
cout << "this->port=" << this->port << endl;
|
||||
/* if ((this->ld = ldap_open(this->hostname, this->port)) == NULL) {
|
||||
perror("connection");
|
||||
}
|
||||
*/
|
||||
debug("this->hostname=%s\n", this->hostname);
|
||||
debug("this->port=%i", this->port);
|
||||
|
||||
char *c;
|
||||
char *tok;
|
||||
|
||||
int len = this->databases->length();
|
||||
cout << "this->databases->length()=" << len << endl;
|
||||
debug("this->databases->length()=%i\n", len);
|
||||
|
||||
tree = new Gtk_Tree();
|
||||
tree = new Gtk_LdapTree();
|
||||
for (int i=0; i<len; i++) {
|
||||
tok = strdup(this->databases->nth_data(i));
|
||||
tok = strtok(tok, ":");
|
||||
// c = strtok(NULL, " ");
|
||||
c = strtok(NULL, "\0");
|
||||
cout << "database " << i << " " << c << endl;
|
||||
treeresult = this->par->make_tree(this->par, this->ld, c);
|
||||
treeitem = new Gtk_LdapTreeItem(*treeresult->treeitem);
|
||||
debug("database %i %s\n", i, c);
|
||||
treeitem = new Gtk_LdapTreeItem(c, this->par, this->ld);
|
||||
subtree = treeitem->getSubtree(this->ld, 1);
|
||||
debug("inserting %s into %s\n", treeitem->rdn, this->hostname);
|
||||
tree->append(*treeitem);
|
||||
if (treeresult->tree != NULL) {
|
||||
subtree = new Gtk_Tree(*treeresult->tree);
|
||||
treeitem->set_subtree(*subtree);
|
||||
}
|
||||
treeitem->set_subtree(*subtree);
|
||||
treeitem->show();
|
||||
// tree->show();
|
||||
}
|
||||
this->set_subtree(*tree);
|
||||
cout << "getTree() done" << endl;
|
||||
return 0;
|
||||
// this->set_subtree(*tree);
|
||||
debug("getTree() done\n");
|
||||
return tree;
|
||||
}
|
||||
|
||||
void Gtk_LdapServer::show_impl() {
|
||||
debug("%s showed\n", this->hostname);
|
||||
Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
|
||||
sig->show(GTK_WIDGET(gtkobj()));
|
||||
}
|
||||
|
||||
void Gtk_LdapServer::select_impl() {
|
||||
cout << this->hostname << " selected" << endl;
|
||||
// gtk_item_select(GTK_ITEM(GTK_TREE_ITEM(this->gtkobj())));
|
||||
debug("%s selected\n", this->hostname);
|
||||
Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
|
||||
if (this->showDetails() == 0) debug("%s select_impl done\n", this->hostname);
|
||||
if (!sig->select) return;
|
||||
sig->select(GTK_ITEM(gtkobj()));
|
||||
this->showDetails();
|
||||
}
|
||||
|
||||
void Gtk_LdapServer::collapse_impl() {
|
||||
// cout << this->dn << " collapsed" << endl;
|
||||
debug("%s collapsed\n", this->hostname);
|
||||
Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
|
||||
if (!sig->collapse) return;
|
||||
sig->collapse(GTK_TREE_ITEM(gtkobj()));
|
||||
@ -226,7 +327,7 @@ void Gtk_LdapServer::collapse_impl() {
|
||||
}
|
||||
|
||||
void Gtk_LdapServer::expand_impl() {
|
||||
// cout << this->dn << " expanded" << endl;
|
||||
debug("%s expanded\n", this->hostname);
|
||||
Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
|
||||
if (!sig->expand) return;
|
||||
sig->expand(GTK_TREE_ITEM(gtkobj()));
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef GTK_LDAPSERVER_H
|
||||
#define GTK_LDAPSERVER_H
|
||||
#include "gtk.h"
|
||||
#include "utils.h"
|
||||
#include <My_Window.h>
|
||||
/*#include <LdapOpts.h>*/
|
||||
#include <Gtk_LdapItem.h>
|
||||
#include <Gtk_LdapTree.h>
|
||||
#include <Gtk_LdapTreeItem.h>
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
@ -26,9 +26,10 @@ public:
|
||||
int c, port;
|
||||
My_Window *par;
|
||||
// Gtk_Notebook *notebook;
|
||||
Gtk_Viewport *notebook;
|
||||
Gtk_Frame *notebook;
|
||||
Gtk_HBox *xpm_label;
|
||||
// Gtk_Tree *subtree;
|
||||
Gtk_Menu *popup;
|
||||
G_List<char> *databases;
|
||||
Gtk_LdapServer();
|
||||
Gtk_LdapServer(My_Window *w, char *c, int p);
|
||||
@ -36,9 +37,12 @@ public:
|
||||
~Gtk_LdapServer();
|
||||
void setType(int t);
|
||||
int getConfig();
|
||||
int getSubtree();
|
||||
int getDetails();
|
||||
Gtk_Tree* getSubtree();
|
||||
char* getOptDescription(int option);
|
||||
int getOptType(int option);
|
||||
int getOptions();
|
||||
int showDetails();
|
||||
void show_impl();
|
||||
void select_impl();
|
||||
void collapse_impl();
|
||||
void expand_impl();
|
||||
|
20
contrib/gtk-tool/Gtk_LdapTree.cc
Normal file
20
contrib/gtk-tool/Gtk_LdapTree.cc
Normal file
@ -0,0 +1,20 @@
|
||||
#include <Gtk_LdapTree.h>
|
||||
|
||||
void Gtk_LdapTree::show_impl() {
|
||||
debug("tree show\n");
|
||||
Gtk_LdapTree *tree = NULL;
|
||||
Gtk_LdapTreeItem *item = NULL;
|
||||
Gtk_LdapTree::iterator i;
|
||||
debug("iterator\n");
|
||||
for (i=this->begin(); i!=this->end();i++) {
|
||||
item = (Gtk_LdapTreeItem *)GTK_TREE_ITEM((*i));
|
||||
debug("#%s#\n", item->dn);
|
||||
if (item->gtkobj()->subtree == NULL) {
|
||||
tree = item->getSubtree(item->ld, 1);
|
||||
if (tree != NULL) item->set_subtree(*tree);
|
||||
}
|
||||
}
|
||||
debug("done\n");
|
||||
Gtk_c_signals_Tree *sig=(Gtk_c_signals_Tree *)internal_getsignalbase();
|
||||
sig->show(GTK_WIDGET(gtkobj()));
|
||||
}
|
10
contrib/gtk-tool/Gtk_LdapTree.h
Normal file
10
contrib/gtk-tool/Gtk_LdapTree.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef GTK_LDAP_TREE_H
|
||||
#define GTK_LDAP_TREE_H
|
||||
#include <gtk--/tree.h>
|
||||
#include "utils.h"
|
||||
#include <Gtk_LdapTreeItem.h>
|
||||
|
||||
class Gtk_LdapTree : public Gtk_Tree {
|
||||
void show_impl();
|
||||
};
|
||||
#endif
|
@ -5,10 +5,16 @@ Gtk_LdapTreeItem::Gtk_LdapTreeItem() : Gtk_TreeItem() {
|
||||
this->objectClass = NULL;
|
||||
}
|
||||
|
||||
Gtk_LdapTreeItem::Gtk_LdapTreeItem(char *c, My_Window *w) : Gtk_TreeItem() {
|
||||
this->rdn = c;
|
||||
Gtk_LdapTreeItem::Gtk_LdapTreeItem(char *c, My_Window *w, LDAP *ld) : Gtk_TreeItem() {
|
||||
debug("Gtk_LdapTreeItem::Gtk_LdapTreeItem(%s)\n", c);
|
||||
char **s;
|
||||
this->dn = c;
|
||||
s = ldap_explode_dn(this->dn, 1);
|
||||
this->rdn = g_strdup_printf("%s", s[0]);
|
||||
this->par = w;
|
||||
this->ld = ld;
|
||||
this->objectClass = NULL;
|
||||
this->getDetails();
|
||||
}
|
||||
|
||||
Gtk_LdapTreeItem::Gtk_LdapTreeItem(GtkTreeItem *t) : Gtk_TreeItem(t) {
|
||||
@ -19,8 +25,62 @@ Gtk_LdapTreeItem::~Gtk_LdapTreeItem() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
Gtk_LdapTree* Gtk_LdapTreeItem::getSubtree(LDAP *ld, int counter) {
|
||||
debug("Gtk_LdapTreeItem::getSubtree(%s)\n", this->dn);
|
||||
if (counter <= 0) return NULL;
|
||||
if (this->gtkobj()->subtree != NULL) {
|
||||
return (Gtk_LdapTree *)GTK_TREE(this->gtkobj()->subtree);
|
||||
}
|
||||
counter--;
|
||||
Gtk_LdapTree *subtree = NULL, *tree = NULL;
|
||||
Gtk_LdapTreeItem *subtreeitem = NULL;
|
||||
LDAPMessage *r_i = NULL, *entry = NULL;
|
||||
gchar *c;
|
||||
char **s;
|
||||
int entriesCount = 0, error;
|
||||
|
||||
this->ld = ld;
|
||||
error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_ONELEVEL, "objectclass=*", NULL, 0, &r_i);
|
||||
// printf("%s\n", ldap_err2string(error));
|
||||
entriesCount = ldap_count_entries(this->ld, r_i);
|
||||
debug("%i results\n", entriesCount);
|
||||
if (entriesCount != 0) {
|
||||
tree = new Gtk_LdapTree();
|
||||
tree->set_selection_mode(GTK_SELECTION_BROWSE);
|
||||
tree->set_view_mode(GTK_TREE_VIEW_ITEM);
|
||||
tree->set_view_lines(false);
|
||||
entry = ldap_first_entry(this->ld, r_i);
|
||||
// float i = 1;
|
||||
// float percent = 100/entriesCount;
|
||||
// cout << "percent is " << percent << endl;
|
||||
// this->par->progress.update(0);
|
||||
// this->par->progress.show();
|
||||
while (entry != NULL) {
|
||||
subtreeitem = new Gtk_LdapTreeItem(ldap_get_dn(this->ld, entry), this->par, this->ld);
|
||||
subtree = subtreeitem->getSubtree(this->ld, counter);
|
||||
debug("inserting %s into %s\n",subtreeitem->rdn,this->rdn);
|
||||
tree->append(*subtreeitem);
|
||||
subtreeitem->show();
|
||||
if (subtree != NULL) subtreeitem->set_subtree(*subtree);
|
||||
debug("done\n");
|
||||
entry = ldap_next_entry(this->ld, entry);
|
||||
// gfloat pvalue = (i*percent)/100;
|
||||
// cout << pvalue << " %" << endl;
|
||||
// this->par->progress.update(pvalue);
|
||||
// this->par->progress.show();
|
||||
// i++;
|
||||
}
|
||||
// this->set_subtree(*tree);
|
||||
// this->par->progress.update(0);
|
||||
// this->par->progress->show();
|
||||
}
|
||||
// this->getDetails();
|
||||
debug("done\n");
|
||||
return tree;
|
||||
}
|
||||
|
||||
void Gtk_LdapTreeItem::setType(int t) {
|
||||
// cout << "Gtk_LdapTreeItem::setType(" << t << ")" << endl;
|
||||
debug("Gtk_LdapTreeItem::setType(%i)\n", t);
|
||||
Gtk_Pixmap *xpm_icon;
|
||||
Gtk_Label *label;
|
||||
if (this->getchild() != NULL) {
|
||||
@ -35,6 +95,8 @@ void Gtk_LdapTreeItem::setType(int t) {
|
||||
xpm_icon=new Gtk_Pixmap(*xpm_label, branch_node);
|
||||
else if (strcasecmp(this->objectClass,"person") == 0)
|
||||
xpm_icon=new Gtk_Pixmap(*xpm_label, leaf_node);
|
||||
else if (strcasecmp(this->objectClass,"alias") == 0)
|
||||
xpm_icon=new Gtk_Pixmap(*xpm_label, alias_node);
|
||||
else xpm_icon=new Gtk_Pixmap(*xpm_label, general_node);
|
||||
label = new Gtk_Label(this->rdn);
|
||||
xpm_label->pack_start(*xpm_icon, false, false, 1);
|
||||
@ -46,7 +108,7 @@ void Gtk_LdapTreeItem::setType(int t) {
|
||||
}
|
||||
|
||||
int Gtk_LdapTreeItem::showDetails() {
|
||||
// cout << "Gtk_LdapTreeItem::showDetails()" << endl;
|
||||
debug("Gtk_LdapTreeItem::showDetails()\n");
|
||||
if (this->notebook != NULL) {
|
||||
if (par->viewport->getchild() != NULL) {
|
||||
par->viewport->remove_c(par->viewport->getchild()->gtkobj());
|
||||
@ -62,7 +124,7 @@ int Gtk_LdapTreeItem::showDetails() {
|
||||
}
|
||||
|
||||
int Gtk_LdapTreeItem::getDetails() {
|
||||
// cout << "Gtk_LdapTreeItem::getDetails()" << endl;
|
||||
debug("Gtk_LdapTreeItem::getDetails()\n");
|
||||
int error, entriesCount;
|
||||
BerElement *ber;
|
||||
LDAPMessage *entry;
|
||||
@ -72,8 +134,8 @@ int Gtk_LdapTreeItem::getDetails() {
|
||||
GList *child_list;
|
||||
Gtk_Notebook *g;
|
||||
Gtk_Viewport *viewport;
|
||||
error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, &result_identifier);
|
||||
entriesCount = ldap_count_entries(ld, result_identifier);
|
||||
error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, &this->result_identifier);
|
||||
entriesCount = ldap_count_entries(this->ld, this->result_identifier);
|
||||
if (entriesCount == 0) return 0;
|
||||
notebook = new Gtk_Notebook();
|
||||
notebook->set_tab_pos(GTK_POS_LEFT);
|
||||
@ -94,17 +156,26 @@ int Gtk_LdapTreeItem::getDetails() {
|
||||
}
|
||||
ldap_value_free(values);
|
||||
label = new Gtk_Label(attribute);
|
||||
label->set_alignment(0, 0);
|
||||
label->set_justify(GTK_JUSTIFY_LEFT);
|
||||
notebook->append_page(*table, *label);
|
||||
table->show();
|
||||
label->show();
|
||||
}
|
||||
}
|
||||
this->setType(1);
|
||||
// cout << ".";
|
||||
debug("done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Gtk_LdapTreeItem::show_impl() {
|
||||
debug("%s showed\n", this->dn);
|
||||
Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
|
||||
sig->show(GTK_WIDGET(gtkobj()));
|
||||
}
|
||||
|
||||
void Gtk_LdapTreeItem::select_impl() {
|
||||
// cout << this->dn << " selected" << endl;
|
||||
debug("%s selected\n", this->dn);
|
||||
// gtk_item_select(GTK_ITEM(GTK_TREE_ITEM(this->gtkobj())));
|
||||
Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
|
||||
if (!sig->select) return;
|
||||
@ -113,7 +184,7 @@ void Gtk_LdapTreeItem::select_impl() {
|
||||
}
|
||||
|
||||
void Gtk_LdapTreeItem::collapse_impl() {
|
||||
// cout << this->dn << " collapsed" << endl;
|
||||
debug("%s collapsed\n", this->dn);
|
||||
Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
|
||||
if (!sig->collapse) return;
|
||||
sig->collapse(GTK_TREE_ITEM(gtkobj()));
|
||||
@ -121,7 +192,10 @@ void Gtk_LdapTreeItem::collapse_impl() {
|
||||
}
|
||||
|
||||
void Gtk_LdapTreeItem::expand_impl() {
|
||||
// cout << this->dn << " expanded" << endl;
|
||||
debug("%s expanded\n",this->dn);
|
||||
Gtk_LdapTreeItem *item;
|
||||
G_List<GtkWidget> *list;
|
||||
Gtk_Tree *tree;
|
||||
Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
|
||||
if (!sig->expand) return;
|
||||
sig->expand(GTK_TREE_ITEM(gtkobj()));
|
||||
|
@ -1,13 +1,15 @@
|
||||
#ifndef GTK_LDAPTREEITEM_H
|
||||
#define GTK_LDAPTREEITEM_H
|
||||
#include "gtk.h"
|
||||
#include "utils.h"
|
||||
#include <My_Window.h>
|
||||
#include <Gtk_LdapTree.h>
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
/*#include "XPMLabelBox.h"*/
|
||||
#include "icons/root_node.h"
|
||||
#include "icons/branch_node.h"
|
||||
#include "icons/leaf_node.h"
|
||||
#include "icons/alias_node.h"
|
||||
#include "icons/general_node.h"
|
||||
|
||||
#define ROOT_NODE 1
|
||||
@ -15,6 +17,7 @@
|
||||
#define LEAF_NODE 3
|
||||
|
||||
class My_Window;
|
||||
class Gtk_LdapTree;
|
||||
|
||||
class Gtk_LdapTreeItem : public Gtk_TreeItem {
|
||||
public:
|
||||
@ -27,12 +30,14 @@ public:
|
||||
Gtk_Notebook *notebook;
|
||||
Gtk_HBox *xpm_label;
|
||||
Gtk_LdapTreeItem();
|
||||
Gtk_LdapTreeItem(char *c, My_Window *w);
|
||||
Gtk_LdapTreeItem(char *c, My_Window *w, LDAP *ld);
|
||||
Gtk_LdapTreeItem(GtkTreeItem *t);
|
||||
~Gtk_LdapTreeItem();
|
||||
Gtk_LdapTree* getSubtree(LDAP *ld, int i);
|
||||
void setType(int t);
|
||||
int getDetails();
|
||||
int showDetails();
|
||||
void show_impl();
|
||||
void select_impl();
|
||||
void collapse_impl();
|
||||
void expand_impl();
|
||||
|
@ -1,15 +1,15 @@
|
||||
HOME_LOCATION=$(shell pwd)
|
||||
CC= gcc
|
||||
CPLUS= g++
|
||||
OPTS=-g -DmyDEBUG
|
||||
OPTS=-g #-DDEBUG
|
||||
INCLUDES=`gtkmm-config --cflags` -I.
|
||||
LDFLAGS=`gtkmm-config --libs` -L/usr/lib -L/usr/X11/lib -L/usr/local/gnome/lib -L/usr/local/ldap/lib -lldap -llber -L/usr/local/kerberos/lib -lkrb5 -lkrb4
|
||||
LIBS=-lXext -lgtkmm -lX11 -lXt -lXxf86dga
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
SOURCES= My_Window.cc Gtk_LdapTreeItem.cc Gtk_LdapServer.cc main.cc
|
||||
OBJECTS= My_Window.o Gtk_LdapTreeItem.o Gtk_LdapServer.o main.o
|
||||
SOURCES= My_Window.cc Gtk_LdapTree.cc Gtk_LdapTreeItem.cc Gtk_LdapServer.cc utils.cc main.cc
|
||||
OBJECTS= My_Window.o Gtk_LdapTree.o Gtk_LdapTreeItem.o Gtk_LdapServer.o utils.o main.o
|
||||
|
||||
################################################################################
|
||||
|
||||
|
@ -4,6 +4,7 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) {
|
||||
cout << "My_Window(t)" << endl;
|
||||
Gtk_VBox *main_hbox;
|
||||
Gtk_HBox *top_hbox;
|
||||
Gtk_VBox *bottom_hbox;
|
||||
Gtk_Menu *menu;
|
||||
Gtk_MenuItem *file_menu, *menuitem;
|
||||
|
||||
@ -43,12 +44,20 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) {
|
||||
top_hbox->pack_end(*this->display_button, FALSE, FALSE, 1);
|
||||
this->display_button->show();
|
||||
|
||||
this->status = new Gtk_Statusbar();
|
||||
|
||||
bottom_hbox = new Gtk_VBox();
|
||||
bottom_hbox->pack_start(*pane, TRUE, TRUE, 1);
|
||||
bottom_hbox->pack_end(*status, FALSE, TRUE, 1);
|
||||
pane->show();
|
||||
status->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);
|
||||
main_hbox->pack_end(*bottom_hbox, TRUE, TRUE, 1);
|
||||
top_hbox->show();
|
||||
pane->show();
|
||||
bottom_hbox->show();
|
||||
this->add(main_hbox);
|
||||
main_hbox->show();
|
||||
}
|
||||
@ -58,75 +67,31 @@ My_Window::~My_Window() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
int My_Window::debug(const char *format,...) {
|
||||
#ifdef DEBUG
|
||||
va_list args;
|
||||
int ret;
|
||||
char *c;
|
||||
char buff[50];
|
||||
unsigned int m_context_id;
|
||||
va_start(args, format);
|
||||
ret = vprintf(format, args);
|
||||
/* if (this->status != NULL) {
|
||||
m_context_id = this->status->get_context_id("gtk-tool");
|
||||
ret = vsprintf(c, format, args);
|
||||
g_snprintf(buff, 50, "Action: %s", c);
|
||||
this->status->push(m_context_id, buff);
|
||||
}
|
||||
*/ va_end(args);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
void My_Window::do_display() {
|
||||
cout << this->urlfield->get_text() << endl;
|
||||
}
|
||||
void My_Window::expand(Gtk_TreeItem *t) {
|
||||
gchar *name;
|
||||
GtkLabel *label;
|
||||
label = GTK_LABEL (GTK_BIN (t->gtkobj())->child);
|
||||
gtk_label_get (label, &name);
|
||||
g_print("%s selected\n", name);
|
||||
}
|
||||
|
||||
gint My_Window::delete_event_impl(GdkEventAny*) {
|
||||
Gtk_Main::instance()->quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Gtk_LdapItem* My_Window::make_tree(My_Window *p, LDAP* l_i, char* b_d) {
|
||||
// printf("make_tree(%s)\n", b_d);
|
||||
Gtk_LdapItem *treeresult, *subtreeresult;
|
||||
Gtk_Tree *tree, *subtree, *subsubtree;
|
||||
Gtk_LdapTreeItem *treeitem, *subtreeitem;
|
||||
LDAPMessage *r_i, *entry;
|
||||
gchar *c;
|
||||
char **s;
|
||||
char *c_num;
|
||||
int entriesCount = 0;
|
||||
int error;
|
||||
int r_e_i;
|
||||
|
||||
error = ldap_search_s(l_i, b_d, LDAP_SCOPE_ONELEVEL, "objectclass=*", NULL, 0, &r_i);
|
||||
// printf("%s\n", ldap_err2string(error));
|
||||
entriesCount = ldap_count_entries(l_i, r_i);
|
||||
// printf("%i results\n", entriesCount);
|
||||
s = ldap_explode_dn(b_d, 1);
|
||||
c = g_strdup_printf("%s", s[0]);
|
||||
treeitem = new Gtk_LdapTreeItem(c, p);
|
||||
treeitem->dn = b_d; treeitem->ld = l_i;
|
||||
treeresult = new Gtk_LdapItem();
|
||||
treeitem->getDetails();
|
||||
if (entriesCount == 0) {
|
||||
// treeitem->setType(LEAF_NODE);
|
||||
treeresult->treeitem = new Gtk_LdapTreeItem(*treeitem);
|
||||
treeresult->tree = NULL;
|
||||
return treeresult;
|
||||
}
|
||||
subtree = new Gtk_Tree();
|
||||
subtree->set_selection_mode(GTK_SELECTION_BROWSE);
|
||||
subtree->set_view_mode(GTK_TREE_VIEW_ITEM);
|
||||
subtree->set_view_lines(false);
|
||||
entry = ldap_first_entry(l_i, r_i);
|
||||
while (entry != NULL) {
|
||||
s = ldap_explode_dn(ldap_get_dn(l_i, entry), 1);
|
||||
subtreeresult = make_tree(p, l_i, ldap_get_dn(l_i, entry));
|
||||
subtreeitem = new Gtk_LdapTreeItem(*subtreeresult->treeitem);
|
||||
// printf("inserting %s into %s", s[0], c);
|
||||
subtree->append(*subtreeitem);
|
||||
if (subtreeresult->tree != NULL) {
|
||||
// printf(".");
|
||||
subsubtree = new Gtk_Tree(*subtreeresult->tree);
|
||||
// printf(".");
|
||||
subtreeitem->set_subtree(*subsubtree);
|
||||
// printf(".");
|
||||
}
|
||||
subtreeitem->show();
|
||||
// printf("\n");
|
||||
entry = ldap_next_entry(l_i, entry);
|
||||
}
|
||||
// treeitem->setType(BRANCH_NODE);
|
||||
treeresult->treeitem = new Gtk_LdapTreeItem(*treeitem);
|
||||
treeresult->tree = new Gtk_Tree(*subtree);
|
||||
return treeresult;
|
||||
}
|
||||
|
@ -2,14 +2,6 @@
|
||||
#define MY_WINDOW_H
|
||||
#include "cpluscommon.h"
|
||||
#include "gtk.h"
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
/*#include "My_Scroller.h"*/
|
||||
#include "Gtk_LdapItem.h"
|
||||
#include "Gtk_LdapTreeItem.h"
|
||||
class Gtk_LdapTreeItem;
|
||||
class Gtk_LdapItem;
|
||||
class My_Scroller;
|
||||
|
||||
class My_Window : public Gtk_Window {
|
||||
public:
|
||||
@ -20,11 +12,12 @@ public:
|
||||
Gtk_Button *display_button;
|
||||
Gtk_Paned *pane;
|
||||
Gtk_MenuBar *menubar;
|
||||
// Gtk_ProgressBar progress;
|
||||
Gtk_Statusbar *status;
|
||||
My_Window(GtkWindowType t);
|
||||
~My_Window();
|
||||
int debug(const char *c,...);
|
||||
void do_display();
|
||||
void expand(Gtk_TreeItem *t);
|
||||
gint delete_event_impl(GdkEventAny *);
|
||||
Gtk_LdapItem* make_tree(My_Window *p, LDAP* l_i, char* b_d);
|
||||
};
|
||||
#endif
|
||||
|
@ -6,24 +6,27 @@ read TODO!
|
||||
|
||||
Just type 'make' to compile and if you have all the necessary stuff it'll do so.
|
||||
You do need the latest version of Gtk+ and Gtk-- (which may be tricky to build).
|
||||
You can also edit the Makefile and under "OPTS=-g" add " -DDEBUG" (line should
|
||||
read "OPTS=-g -DDEBUG") to get a trace of what the gtk-tool is doing (getting
|
||||
entries, traversing trees etc...)
|
||||
After that, hopefully all goes well, you start the thing by doing:
|
||||
./main
|
||||
./main -s localhost
|
||||
|
||||
It will default to base of o=University of Michigan, c=US", localhost, and
|
||||
LDAP_PORT (389). This is because OpenLDAP comes with the UMICH ldif and the
|
||||
assumption is that many of you have actually created a test db with that data
|
||||
(to see that people don't lie when they say OpenLDAP actually works or
|
||||
something). If you want to change any of these do ./main -h and it will give
|
||||
you a list of supported parameters.
|
||||
It no longer has a default base, instead it reads cn=config off your slapd
|
||||
and accordignly inserts all available databases under "localhost". If you are
|
||||
not running slapd on your local machine, then supply it with a "-s hostname"
|
||||
i.e.:
|
||||
./main -s server02.nowhere.net
|
||||
|
||||
In short this is what you can do:
|
||||
or if you feel like having an adventure try multiple servers
|
||||
i.e.:
|
||||
./main -s server02.nowhere.net -s server03.nowhere.com:322
|
||||
|
||||
./main -h ldap-server.somewhere.net -p 28345 -b "o=OpenLDAP Foundation, c=US"
|
||||
|
||||
I really couldn't think of anything else to put here (at the moment
|
||||
that is). But please feel free to add whatever else you consider
|
||||
neccessary to understanding how this thing works. Enjoy, and I hope
|
||||
this can be useful to you in some miniscule way.
|
||||
etc...
|
||||
It does not accept -b switch as it no longer needs it to aquire databases.
|
||||
But please feel free to add whatever else you consider neccessary to
|
||||
understanding how this thing works. Enjoy, and I hope this can be useful to
|
||||
you in some miniscule way.
|
||||
|
||||
All emails to -devel list, and plase make sure you put "GTK-TOOL"
|
||||
in the subject line, so other people who are not interested don't
|
||||
|
@ -1,7 +1,9 @@
|
||||
LOADS!!!
|
||||
|
||||
Priorities:
|
||||
Make it useful!
|
||||
Now that we have cn=config we can start using ldap_get_option propperly
|
||||
and be able to run/stop server from the gtk-tool. Other things like
|
||||
new entries would now come in handy.
|
||||
Implement searches
|
||||
port to autoconf (anyone? it should be easy)
|
||||
|
||||
|
@ -13,29 +13,36 @@ int main(int argc, char **argv) {
|
||||
Gtk_Tree *machine, *machinetree;
|
||||
Gtk_LdapServer *treeitem;
|
||||
Gtk_Viewport *viewport;
|
||||
char *host = NULL;
|
||||
char *host = NULL, *prt = NULL;
|
||||
char *base_dn = NULL;
|
||||
int c, port = 0;
|
||||
G_List<char> *hosts;
|
||||
int host_count = 0;
|
||||
char *pair[2];
|
||||
|
||||
while ((c = getopt(argc, argv, "b:s:p:h")) != -1) {
|
||||
hosts = new G_List<char>();
|
||||
while ((c = getopt(argc, argv, "s:p:h")) != -1) {
|
||||
switch (c) {
|
||||
case 'b':
|
||||
base_dn = optarg; break;
|
||||
case 's':
|
||||
host = strdup(optarg); break;
|
||||
cout << "host" << endl;
|
||||
hosts = hosts->append(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]);
|
||||
fprintf(stderr, "Usage: %s ([-s server[:port]])*\n", argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
cout << hosts->length() << "hosts" << endl;
|
||||
for (int f=0; f<hosts->length(); f++) {
|
||||
debug("%s\n", hosts->nth_data(f));
|
||||
}
|
||||
if (hosts->length() == 0) {
|
||||
ldap_get_option(NULL, LDAP_OPT_HOST_NAME, host);
|
||||
hosts = hosts->append(host);
|
||||
}
|
||||
if (port == 0) port = LDAP_PORT;
|
||||
|
||||
Gtk_Main m(&argc, &argv);
|
||||
@ -43,22 +50,28 @@ int main(int argc, char **argv) {
|
||||
window = new My_Window(GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
tree = new Gtk_Tree();
|
||||
treeitem = new Gtk_LdapServer(window, host, port);
|
||||
tree->append(*treeitem);
|
||||
treeitem->show();
|
||||
for (int f=0; f<hosts->length(); f++) {
|
||||
host = strtok(hosts->nth_data(f), ":");
|
||||
prt = strtok(NULL, "\0");
|
||||
if (prt != NULL) port = atoi(prt);
|
||||
else port = LDAP_PORT;
|
||||
treeitem = new Gtk_LdapServer(window, host, port);
|
||||
subtree = treeitem->getSubtree();
|
||||
tree->append(*treeitem);
|
||||
treeitem->set_subtree(*subtree);
|
||||
treeitem->show();
|
||||
}
|
||||
viewport = new Gtk_Viewport();
|
||||
viewport->add(tree);
|
||||
window->scroller->add(viewport);
|
||||
tree->show();
|
||||
viewport->show();
|
||||
window->scroller->show();
|
||||
treeitem->showDetails();
|
||||
// treeitem->showDetails();
|
||||
// treeitem->select();
|
||||
window->set_title("Hello");
|
||||
window->set_title("gtk-tool");
|
||||
window->activate();
|
||||
|
||||
window->set_usize(600, 500);
|
||||
|
||||
window->show();
|
||||
|
||||
m.run();
|
||||
|
13
contrib/gtk-tool/utils.cc
Normal file
13
contrib/gtk-tool/utils.cc
Normal file
@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int debug(const char *format,...) {
|
||||
#ifdef DEBUG
|
||||
va_list args;
|
||||
int ret;
|
||||
va_start(args, format);
|
||||
ret = vprintf(format, args);
|
||||
va_end(args);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
4
contrib/gtk-tool/utils.h
Normal file
4
contrib/gtk-tool/utils.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef MY_UTIL_H
|
||||
#define MY_UTIL_H
|
||||
int debug(const char *format,...);
|
||||
#endif /* MY_UTIL_H */
|
Loading…
x
Reference in New Issue
Block a user