Even more spelling fixed
[oweals/cde.git] / cde / programs / dtmail / dtmail / PasswordDialogManager.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  *+SNOTICE
25  *
26  *      $XConsortium: PasswordDialogManager.C /main/4 1996/04/21 19:42:53 drk $
27  *
28  *      RESTRICTED CONFIDENTIAL INFORMATION:
29  *      
30  *      The information in this document is subject to special
31  *      restrictions in a confidential disclosure agreement between
32  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
33  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
34  *      Sun's specific written approval.  This document and all copies
35  *      and derivative works thereof must be returned or destroyed at
36  *      Sun's request.
37  *
38  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
39  *
40  *+ENOTICE
41  */
42
43 #include "PasswordDialogManager.h"
44 #include <Xm/SelectioB.h>
45 #include <Xm/TextF.h>
46 #include <Xm/Label.h>
47 #include <Xm/RowColumn.h>
48
49 PasswordDialogManager *thePasswordDialogManager = 
50     new PasswordDialogManager ( "PasswordDialog" );
51
52
53 PasswordDialogManager::PasswordDialogManager ( char   *name ) : 
54                                  PromptDialogManager ( name )
55 {
56     // Empty
57     _pwd[0] = 0;
58     _user = NULL;
59     _password = NULL;
60 }
61
62 Widget PasswordDialogManager::createDialog ( Widget parent )
63 {
64    
65   Widget dialog = XmCreatePromptDialog ( parent, _name, NULL, 0);
66     
67   XtVaSetValues ( dialog,
68                   XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
69                   NULL );
70
71   XtUnmanageChild( XmSelectionBoxGetChild( dialog,
72                                       XmDIALOG_TEXT ) );
73
74   XtUnmanageChild( XmSelectionBoxGetChild( dialog,
75                                       XmDIALOG_SELECTION_LABEL ) );
76
77   Widget rc = XtCreateManagedWidget ( "PasswordArea",
78                                       xmRowColumnWidgetClass,
79                                       dialog,
80                                       NULL, 0 );
81
82   Widget _user_label = XtCreateManagedWidget
83     ( "UserLabel",
84       xmLabelWidgetClass,
85       rc,
86       NULL, 0);
87
88   _user = XtCreateManagedWidget
89     ( "User",
90       xmTextFieldWidgetClass,
91       rc,
92       NULL, 0);
93
94   Widget _password_label = XtCreateManagedWidget
95     ( "PasswordLabel",
96       xmLabelWidgetClass,
97       rc,
98       NULL, 0);
99
100   _password = XtCreateManagedWidget
101     ( "Password",
102       xmTextFieldWidgetClass,
103       rc,
104       NULL, 0);
105
106   XtManageChild( rc );
107   XtAddCallback ( _password,
108                   XmNmodifyVerifyCallback,
109                   (XtCallbackProc )
110                   &PasswordDialogManager::modifyVerifyCallback,
111                   ( XtPointer ) this );
112   return dialog;
113 }
114
115 #ifdef DEAD_WOOD
116 char *
117 PasswordDialogManager::userName(){
118   return ( XmTextFieldGetString( _user ) );
119 }
120
121 char *
122 PasswordDialogManager::password(){
123 //  return ( XmTextFieldGetString( _password ) );
124   return _pwd;
125 }
126 #endif /* DEAD_WOOD */
127
128 void
129 PasswordDialogManager::modifyVerifyCallback( Widget w,
130                       XtPointer clientData,
131                       XmTextVerifyCallbackStruct *cbs ) {
132   PasswordDialogManager *pdm=( PasswordDialogManager * ) clientData;
133   pdm->modifyVerify( w, cbs );
134 }
135                       
136 void
137 PasswordDialogManager::modifyVerify( Widget ,
138                                      XmTextVerifyCallbackStruct *cbs )
139 {
140  int len;
141
142   if ( cbs->text->ptr == NULL ) // Backspace
143     return;
144   for ( len=0; len< cbs->text->length; len++ ) {
145     strncat(_pwd, &cbs->text->ptr[len], 1);
146     cbs->text->ptr[len] = '*';
147   }
148 }
149
150 #ifdef DEAD_WOOD
151 void
152 PasswordDialogManager::resetPassword()
153 {
154     _pwd[0] = 0;
155 }
156 #endif /* DEAD_WOOD */