Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
LdapView Class Reference

#include <LdapView.h>

List of all members.

Public Member Functions

LdapDocGetDocument ()
void AddLine (LPCSTR line, const char *dn=NULL)
void ClearLines ()
virtual void OnDraw (CDC *pDC)
virtual BOOL PreCreateWindow (CREATESTRUCT &cs)
virtual ~LdapView ()

Protected Member Functions

 LdapView ()
virtual void OnInitialUpdate ()
afx_msg void OnSize (UINT nType, int cx, int cy)
afx_msg void OnListDoubleClick ()

Private Member Functions

void showProperties (LDAP *ld, char *dn)

Private Attributes

CListBox m_list

Detailed Description

Definition at line 5 of file LdapView.h.


Constructor & Destructor Documentation

LdapView::LdapView ( ) [protected]

Definition at line 35 of file LdapView.cpp.

{
}
LdapView::~LdapView ( ) [virtual]

Definition at line 39 of file LdapView.cpp.

{
}

Member Function Documentation

void LdapView::AddLine ( LPCSTR  line,
const char *  dn = NULL 
)

Definition at line 66 of file LdapView.cpp.

{
       // Add a string to the list box
       int ind = m_list.AddString( line );
       if ( NULL != dn )
              m_list.SetItemDataPtr( ind, (void *)strdup(dn) );
}

Here is the caller graph for this function:

Definition at line 74 of file LdapView.cpp.

{
       // Remove all lines from the list box
       int nCount = m_list.GetCount();
       while ( nCount > 0 )
       {
              char *str = (char *)m_list.GetItemDataPtr( 0 );
              if ( str )
                     free( str );
              nCount = m_list.DeleteString( 0 );
       }
}

Here is the caller graph for this function:

Definition at line 56 of file LdapView.h.

   { return (LdapDoc*)m_pDocument; }

Here is the caller graph for this function:

void LdapView::OnDraw ( CDC *  pDC) [virtual]

Definition at line 51 of file LdapView.cpp.

{
       LdapDoc* pDoc = GetDocument();
       ASSERT_VALID(pDoc);
}

Here is the call graph for this function:

void LdapView::OnInitialUpdate ( ) [protected, virtual]

Definition at line 57 of file LdapView.cpp.

{
       CView::OnInitialUpdate();
       // Create a list box the same size as the client area
       CRect rect;
       GetClientRect( &rect );
       m_list.Create( WS_CHILD|WS_VISIBLE|WS_VSCROLL|LBS_NOTIFY, rect, this, 5000 );
}

Definition at line 177 of file LdapView.cpp.

{
       int ind = m_list.GetCurSel();
       if ( ind >= 0 )
       {
              char *dn = (char *)m_list.GetItemDataPtr( ind );
              if ( NULL != dn )
              {
                     LDAP *ld = ((LdapApp *)AfxGetApp())->GetConnection();
                     if ( NULL != ld )
                            showProperties( ld, dn );
              }
       }
}

Here is the call graph for this function:

void LdapView::OnSize ( UINT  nType,
int  cx,
int  cy 
) [protected]

Definition at line 111 of file LdapView.cpp.

{
       // Make sure the list box is resized along with the View
       CView::OnSize(nType, cx, cy);
       if ( ::IsWindow( m_list.m_hWnd ) )
              m_list.SetWindowPos( &wndTop, 0, 0, cx, cy, SWP_NOZORDER );
}
BOOL LdapView::PreCreateWindow ( CREATESTRUCT &  cs) [virtual]

Definition at line 43 of file LdapView.cpp.

{
       return CView::PreCreateWindow(cs);
}
void LdapView::showProperties ( LDAP *  ld,
char *  dn 
) [private]

Definition at line 120 of file LdapView.cpp.

{
       PropDlg dlg;
       if ( ldap_search( ld, dn, LDAP_SCOPE_BASE, "objectclass=*",
                            NULL, FALSE ) == -1 )
       {
              AfxMessageBox( "Failed to start asynchronous search" );
              return;
       }

       LDAPMessage *res;
       int rc;
       // Process results as they come in
       while ( (rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res ))
              == LDAP_RES_SEARCH_ENTRY )
       {
              LDAPMessage *e = ldap_first_entry( ld, res );
              BerElement           *ber;
              // Loop over attributes in this entry
              for ( char *a = ldap_first_attribute( ld, e, &ber ); a != NULL;
                            a = ldap_next_attribute( ld, e, ber ) )
              {
                     struct berval **bvals;
                     if ( (bvals = ldap_get_values_len( ld, e, a )) != NULL )
                     {
                            dlg.AddLine( a );
                            // Loop over values for this attribute
                            for ( int i = 0; bvals[i] != NULL; i++ )
                            {
                                   CString val;
                                   val.Format( "    %s", bvals[ i ]->bv_val );
                                   dlg.AddLine( val );
                            }
                            ber_bvecfree( bvals );
                     }
              }
              if ( ber != NULL )
                     ber_free( ber, 0 );
              ldap_msgfree( res );
       }
       if ( rc == -1 )
       {
              AfxMessageBox( "Error on ldap_result" );
              return;
       }
       else if (( rc = ldap_result2error( ld, res, 0 )) != LDAP_SUCCESS )
       {
              char *errString = ldap_err2string( rc );
              AfxMessageBox( errString );
       }
       ldap_msgfree( res );
       // Set the title of the dialog to the distinguished name, and display it
       dlg.SetTitle( dn );
       dlg.DoModal();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

CListBox LdapView::m_list [private]

Definition at line 16 of file LdapView.h.


The documentation for this class was generated from the following files: