1 /* $TOG: MailRetrievalOptions.C /main/8 1998/07/23 18:13:00 mgreess $ */
6 * RESTRICTED CONFIDENTIAL INFORMATION:
8 * The information in this document is subject to special
9 * restrictions in a confidential disclosure agreement between
10 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
11 * document outside HP, IBM, Sun, USL, SCO, or Univel without
12 * Sun's specific written approval. This document and all copies
13 * and derivative works thereof must be returned or destroyed at
16 * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
21 * Common Desktop Environment
23 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
24 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
25 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
26 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
27 * (c) Copyright 1995 Digital Equipment Corp.
28 * (c) Copyright 1995 Fujitsu Limited
29 * (c) Copyright 1995 Hitachi, Ltd.
32 * RESTRICTED RIGHTS LEGEND
34 *Use, duplication, or disclosure by the U.S. Government is subject to
35 *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
36 *Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
37 *for non-DOD U.S. Government Departments and Agencies are as set forth in
38 *FAR 52.227-19(c)(1,2).
40 *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
41 *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
42 *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
43 *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
44 *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
45 *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
46 *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
51 #include <sys/param.h>
52 #include <X11/Intrinsic.h>
55 #include <Xm/DialogS.h>
57 #include <Xm/ToggleB.h>
58 #include <Dt/PrintOptionsP.h>
60 #include <DtMail/IO.hh>
61 #include "CheckBoxUiItem.hh"
63 #include "DtMailError.hh"
64 #include "InboxTextFieldUiItem.hh"
65 #include "IndexedOptionMenuUiItem.hh"
67 #include "MailRetrievalOptions.h"
69 #include "CheckForMailUiItem.hh"
70 #include "SpinBoxUiItem.hh"
71 #include "TextFieldUiItem.hh"
72 #include "dtmailopts.h"
74 #define MR_ARRAY_SIZE(ary) (sizeof((ary))/sizeof((ary)[0]))
76 static MrPropVal serverprotocol_values[] =
95 #define MrGENPROPKEY(pk, fld, key) DTMAS_CONCAT_MAILRC_KEY(pk, fld, key)
97 MailRetrievalOptions::MailRetrievalOptions (
99 const char *foldername
100 ) : UIComponent( "PrintOptions" )
102 DtMail::Session *d_session = theRoamApp.session()->session();
103 PropUiItem *pui = (PropUiItem *) NULL;
104 Widget *menu_buttons, w;
109 char *propkey = new char[MAXPATHLEN];
111 _propui_array = new DtVirtArray<PropUiItem *>(10);
112 _propui_array_iterator = 0;
114 if (NULL != foldername)
115 _foldername = strdup(foldername);
117 _foldername = strdup(DTMAS_INBOX);
119 _retrieval_tbs = new DtVirtArray<Widget>(10);
120 _custom_options = new DtVirtArray<Widget>(10);
121 _server_options = new DtVirtArray<Widget>(10);
124 // Create FORM to hold the printing options
126 _form = XtVaCreateWidget(
127 "MailRetrievalOptions",
130 XmNbottomAttachment, XmATTACH_FORM,
131 XmNrightAttachment, XmATTACH_FORM,
132 XmNleftAttachment, XmATTACH_FORM,
133 XmNtopAttachment, XmATTACH_FORM,
134 XmNresizePolicy, XmRESIZE_ANY,
137 if (_form == (Widget) NULL)
143 installDestroyHandler();
146 // Create GUI for the INBOX Name Option
148 _inboxpath_tf = XtVaCreateManagedWidget(
150 xmTextFieldWidgetClass, _form,
151 XmNtopAttachment, XmATTACH_FORM,
153 XmNleftAttachment, XmATTACH_POSITION,
155 XmNrightAttachment, XmATTACH_NONE,
159 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 18,"INBOX folder path:"));
160 _inboxpath_label = XtVaCreateManagedWidget(
162 xmLabelWidgetClass, _form,
164 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
166 XmNtopWidget, _inboxpath_tf,
167 XmNleftAttachment, XmATTACH_NONE,
168 XmNrightAttachment, XmATTACH_WIDGET,
170 XmNrightWidget, _inboxpath_tf,
175 // Create PropUiItem for the ServerName Option
177 DtMailObjectSpace space;
179 char *dflt_inboxpath = NULL;
180 d_session->queryImpl(
182 d_session->getDefaultImpl(error),
183 DtMailCapabilityInboxName,
184 &space, &dflt_inboxpath);
186 //MrGENPROPKEY(propkey, "", DTMAS_PROPKEY_INBOXPATH);
187 strcpy(propkey, DTMAS_PROPKEY_INBOXPATH);
188 PropSource::setDefaultValue(propkey, dflt_inboxpath);
189 pui = (PropUiItem *) new InboxTextFieldUiItem(
193 MailRetrievalOptions::isValidInboxPath);
194 _propui_array->append(pui);
195 free(dflt_inboxpath);
198 // Create GUI for the CheckForNewMail Option
200 _checkfornewmail_sb = XtVaCreateManagedWidget(
202 xmSimpleSpinBoxWidgetClass, _form,
203 XmNtopAttachment, XmATTACH_WIDGET,
204 XmNtopWidget, _inboxpath_tf,
206 XmNleftAttachment, XmATTACH_POSITION,
208 XmNrightAttachment, XmATTACH_NONE,
210 XmNincrementValue, 1,
212 XmNmaximumValue, 999999,
214 XmNarrowLayout, XmARROWS_END,
215 XmNspinBoxChildType, XmNUMERIC,
219 xms = XmStringCreateLocalized(
220 GETMSG(Dtb_project_catd, 2, 13, "Check for new mail every:"));
221 _checkfornewmail_label = XtVaCreateManagedWidget(
222 "CheckForNewMailLabel",
223 xmLabelWidgetClass, _form,
224 XmNlabelType, XmSTRING,
226 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
228 XmNtopWidget, _checkfornewmail_sb,
229 XmNleftAttachment, XmATTACH_NONE,
230 XmNrightAttachment, XmATTACH_WIDGET,
232 XmNrightWidget, _checkfornewmail_sb,
237 // Create PropUiItem for the CheckForNewMail Option
239 strcpy(propkey, "retrieveinterval");
240 PropSource::setDefaultValue(propkey, "300");
241 pui = (PropUiItem*) new CheckForMailUiItem(
245 _propui_array->append(pui);
250 w = XtVaCreateManagedWidget(
251 "MailRetrievalSeparator",
252 xmSeparatorGadgetClass, _form,
253 XmNrightAttachment, XmATTACH_FORM,
254 XmNleftAttachment, XmATTACH_FORM,
255 XmNtopAttachment, XmATTACH_WIDGET,
256 XmNtopWidget, _checkfornewmail_sb,
260 xms = XmStringCreateLocalized(
261 GETMSG(DT_catd, 27, 6, "Automatic (system) delivery"));
262 _system_tb = XtVaCreateManagedWidget(
264 xmToggleButtonGadgetClass, _form,
265 XmNrightAttachment, XmATTACH_FORM,
266 XmNleftAttachment, XmATTACH_FORM,
268 XmNtopAttachment, XmATTACH_WIDGET,
271 XmNalignment, XmALIGNMENT_BEGINNING,
279 XmNvalueChangedCallback,
280 MailRetrievalOptions::retrievalTBSValueChangedCB,
284 // Create PropUiItem for the System Option
286 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILVIASYSTEM);
287 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILVIASYSTEM);
288 pui = (PropUiItem *) new CheckBoxUiItem(_system_tb, _FROM_MAILRC, propkey);
289 _propui_array->append(pui);
292 // Create FRAME to hold the server printing options
294 _server_frame = XtVaCreateManagedWidget(
295 "ServerFrame", xmFrameWidgetClass, _form,
296 XmNchildHorizontalAlignment,
297 XmALIGNMENT_BEGINNING,
298 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
299 XmNtopAttachment, XmATTACH_WIDGET,
300 XmNtopWidget, _system_tb,
301 XmNleftAttachment, XmATTACH_FORM,
303 XmNrightAttachment, XmATTACH_FORM,
305 XmNbottomAttachment, XmATTACH_NONE,
308 xms = XmStringCreateLocalized(
309 GETMSG(DT_catd, 27, 7, "Mail server retrieval"));
310 _server_tb = XtVaCreateManagedWidget(
312 xmToggleButtonGadgetClass, _server_frame,
313 XmNchildType, XmFRAME_TITLE_CHILD,
314 XmNchildHorizontalAlignment,
315 XmALIGNMENT_BEGINNING,
316 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
324 XmNvalueChangedCallback,
325 MailRetrievalOptions::retrievalTBSValueChangedCB,
329 // Create PropUiItem for the Server Option
331 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILVIASERVER);
332 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILVIASERVER);
333 pui = (PropUiItem *) new CheckBoxUiItem(_server_tb, _FROM_MAILRC, propkey);
334 _propui_array->append(pui);
336 _serverframe_form = XtVaCreateManagedWidget(
340 //XmNallowOverlap, False,
342 XmNresizePolicy, XmRESIZE_ANY,
346 // Create GUI for the MailServerProtocol Option
348 nitems = MR_ARRAY_SIZE(serverprotocol_values);
349 strings = (char**) XtMalloc(nitems*sizeof(char*));
350 data = (void**) XtMalloc(nitems*sizeof(void*));
351 for (int i=0; i<nitems; i++)
353 data[i] = (void*) serverprotocol_values[i].prop_value_string;
356 serverprotocol_values[i].set_id,
357 serverprotocol_values[i].msg_id,
358 serverprotocol_values[i].dflt_gui_string);
361 _serverprotocol_iom =
362 new IndexedOptionMenu(_serverframe_form, nitems, (char**) strings, data);
364 _serverprotocol_iom->baseWidget(),
365 XmNtopAttachment, XmATTACH_FORM,
366 XmNleftAttachment, XmATTACH_POSITION,
368 XmNrightAttachment, XmATTACH_NONE,
370 _serverprotocol_iom->manage();
371 _serverprotocol_iom->setSpec((void*) DTMAS_PROPDFLT_PROTOCOL);
372 XtFree((char*) strings);
373 XtFree((char*) data);
375 xms = XmStringCreateLocalized(
376 GETMSG(DT_catd, 27, 8, "Server Protocol:"));
377 _serverprotocol_label = XtVaCreateManagedWidget(
378 "ServerProtocolLabel",
379 xmLabelWidgetClass, _serverframe_form,
381 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
383 XmNtopWidget, _serverprotocol_iom->baseWidget(),
384 XmNleftAttachment, XmATTACH_NONE,
385 XmNrightAttachment, XmATTACH_WIDGET,
387 XmNrightWidget, _serverprotocol_iom->baseWidget(),
392 // Create PropUiItem for the Printed Headers option
394 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_PROTOCOL);
395 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_PROTOCOL);
396 pui = (PropUiItem *) new
397 IndexedOptionMenuUiItem(_serverprotocol_iom, _FROM_MAILRC, propkey);
398 _propui_array->append(pui);
401 // Create GUI for the ServerName Option
403 _servername_tf = XtVaCreateManagedWidget(
405 xmTextFieldWidgetClass, _serverframe_form,
406 XmNtopAttachment, XmATTACH_WIDGET,
407 XmNtopWidget, _serverprotocol_iom->baseWidget(),
408 XmNleftAttachment, XmATTACH_POSITION,
410 XmNrightAttachment, XmATTACH_NONE,
414 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 9, "Server Name:"));
415 _servername_label = XtVaCreateManagedWidget(
417 xmLabelWidgetClass, _serverframe_form,
419 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
421 XmNtopWidget, _servername_tf,
422 XmNleftAttachment, XmATTACH_NONE,
423 XmNrightAttachment, XmATTACH_WIDGET,
425 XmNrightWidget, _servername_tf,
430 // Create PropUiItem for the ServerName Option
432 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_SERVERNAME);
433 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_SERVERNAME);
434 pui = (PropUiItem *) new
435 TextFieldUiItem(_servername_tf, _FROM_MAILRC, propkey);
436 _propui_array->append(pui);
439 // Create GUI for the UserName Option
441 _username_tf = XtVaCreateManagedWidget(
443 xmTextFieldWidgetClass, _serverframe_form,
444 XmNtopAttachment, XmATTACH_WIDGET,
445 XmNtopWidget, _servername_tf,
446 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
447 XmNleftWidget, _servername_tf,
448 XmNrightAttachment, XmATTACH_NONE,
452 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 10, "User Name:"));
453 _username_label = XtVaCreateManagedWidget(
455 xmLabelWidgetClass, _serverframe_form,
457 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
458 XmNtopWidget, _username_tf,
459 XmNleftAttachment, XmATTACH_NONE,
460 XmNrightAttachment, XmATTACH_WIDGET,
461 XmNrightWidget, _username_tf,
466 // Create PropUiItem for the UserName Option
469 GetPasswordEntry(pwd);
471 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_USERNAME);
472 PropSource::setDefaultValue(propkey, pwd.pw_name);
473 pui = (PropUiItem *) new
474 TextFieldUiItem(_username_tf, _FROM_MAILRC, propkey);
475 _propui_array->append(pui);
478 // Create GUI for the Password Option
480 _password_tf = XtVaCreateManagedWidget(
482 xmTextFieldWidgetClass, _serverframe_form,
483 XmNtopAttachment, XmATTACH_WIDGET,
484 XmNtopWidget, _username_tf,
485 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
486 XmNleftWidget, _username_tf,
487 XmNrightAttachment, XmATTACH_NONE,
491 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 11, "Password:"));
492 _password_label = XtVaCreateManagedWidget(
494 xmLabelWidgetClass, _serverframe_form,
496 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
497 XmNtopWidget, _password_tf,
498 XmNleftAttachment, XmATTACH_NONE,
499 XmNrightAttachment, XmATTACH_WIDGET,
500 XmNrightWidget, _password_tf,
506 // Create a PropUiItem for the Password Option
508 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_PASSWORD);
509 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_PASSWORD);
511 EncryptedTextFieldUiItem(_password_tf, _FROM_MAILRC, propkey);
512 _propui_array->append((PropUiItem*) _password_pui);
515 // Create GUI for the Remember Password Option
517 xms = XmStringCreateLocalized(
518 GETMSG(DT_catd, 27, 12, "Remember password"));
519 _rememberpassword_tb = XtVaCreateManagedWidget(
520 "RememberPasswordTB",
521 xmToggleButtonWidgetClass, _serverframe_form,
522 XmNtopAttachment, XmATTACH_WIDGET,
523 XmNtopWidget, _password_tf,
524 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
525 XmNleftWidget, _password_tf,
526 XmNrightAttachment, XmATTACH_NONE,
527 XmNalignment, XmALIGNMENT_END,
534 _rememberpassword_tb,
535 XmNvalueChangedCallback,
536 MailRetrievalOptions::rememberPasswordChangedCB,
540 // Create PropUiItem for the RememberPassword Option
542 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_REMEMBERPASSWORD);
543 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_REMEMBERPASSWORD);
544 pui = (PropUiItem *) new
545 CheckBoxUiItem(_rememberpassword_tb, _FROM_MAILRC, propkey);
546 _propui_array->append(pui);
549 // Create GUI for the Delete From Server Option
551 xms = XmStringCreateLocalized(
552 GETMSG(DT_catd, 27, 13,
553 "Delete from server after retrieval"));
554 _removeafterdelivery_tb = XtVaCreateManagedWidget(
555 "RemoveAfterDeliveryTB",
556 xmToggleButtonWidgetClass, _serverframe_form,
557 XmNtopAttachment, XmATTACH_WIDGET,
558 XmNtopWidget, _rememberpassword_tb,
559 XmNleftAttachment, XmATTACH_POSITION,
561 XmNrightAttachment, XmATTACH_NONE,
562 XmNalignment, XmALIGNMENT_BEGINNING,
569 // Create PropUiItem for the RemoveAfterDelivery Option
571 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_REMOVEAFTERDELIVERY);
572 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_REMOVEAFTERDELIVERY);
573 pui = (PropUiItem *) new
574 CheckBoxUiItem(_removeafterdelivery_tb, _FROM_MAILRC, propkey);
575 _propui_array->append(pui);
578 // Create GUI for the RetrieveOld Option
580 xms = XmStringCreateLocalized(
581 GETMSG(DT_catd, 27, 14,
582 "Retrieve old messages"));
583 _retrieveold_tb = XtVaCreateManagedWidget(
585 xmToggleButtonWidgetClass, _serverframe_form,
586 XmNtopAttachment, XmATTACH_WIDGET,
587 XmNtopWidget, _removeafterdelivery_tb,
588 XmNleftAttachment, XmATTACH_POSITION,
590 XmNrightAttachment, XmATTACH_NONE,
591 XmNalignment, XmALIGNMENT_BEGINNING,
598 // Create PropUiItem for the RetrieveOld Option
600 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_RETRIEVEOLD);
601 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_RETRIEVEOLD);
602 pui = (PropUiItem *) new
603 CheckBoxUiItem(_retrieveold_tb, _FROM_MAILRC, propkey);
604 _propui_array->append(pui);
607 // Create FRAME to hold the user command printing options
609 _custom_frame = XtVaCreateManagedWidget(
610 "CustomFrame", xmFrameWidgetClass, _form,
611 XmNchildHorizontalAlignment,
612 XmALIGNMENT_BEGINNING,
613 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
614 XmNtopAttachment, XmATTACH_WIDGET,
615 XmNtopWidget, _server_frame,
616 XmNleftAttachment, XmATTACH_FORM,
618 XmNrightAttachment, XmATTACH_FORM,
620 XmNbottomAttachment, XmATTACH_FORM,
624 xms = XmStringCreateLocalized(
625 GETMSG(DT_catd, 27, 15, "Custom retrieval"));
626 _custom_tb = XtVaCreateManagedWidget(
628 xmToggleButtonGadgetClass, _custom_frame,
629 XmNchildType, XmFRAME_TITLE_CHILD,
630 XmNchildHorizontalAlignment,
631 XmALIGNMENT_BEGINNING,
632 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
640 XmNvalueChangedCallback,
641 MailRetrievalOptions::retrievalTBSValueChangedCB,
645 // Create PropUiItem for the Custom Command Option
647 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILVIACOMMAND);
648 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILVIACOMMAND);
649 pui = (PropUiItem *) new CheckBoxUiItem(_custom_tb, _FROM_MAILRC, propkey);
650 _propui_array->append(pui);
652 _customframe_form = XtVaCreateManagedWidget(
654 xmFormWidgetClass, _custom_frame,
655 //XmNallowOverlap, False,
657 XmNresizePolicy, XmRESIZE_ANY,
661 // Create GUI for the User Command Option
663 _customcommand_tf = XtVaCreateManagedWidget(
665 xmTextFieldWidgetClass, _customframe_form,
666 XmNtopAttachment, XmATTACH_FORM,
667 XmNleftAttachment, XmATTACH_POSITION,
669 XmNrightAttachment, XmATTACH_NONE,
673 xms = XmStringCreateLocalized(
674 GETMSG(DT_catd, 27, 16, "User Getmail command:"));
675 _customcommand_label = XtVaCreateManagedWidget(
676 "CustomCommandLabel",
677 xmLabelWidgetClass, _customframe_form,
679 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
681 XmNtopWidget, _customcommand_tf,
682 XmNleftAttachment, XmATTACH_NONE,
683 XmNrightAttachment, XmATTACH_WIDGET,
685 XmNrightWidget, _customcommand_tf,
690 // Create PropUiItem for the ServerName Option
692 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILCOMMAND);
693 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILCOMMAND);
694 pui = (PropUiItem *) new
695 TextFieldUiItem(_customcommand_tf, _FROM_MAILRC, propkey);
696 _propui_array->append(pui);
699 // Save widgets for manipulation.
701 _retrieval_tbs->append(_system_tb);
702 _retrieval_tbs->append(_server_tb);
703 _retrieval_tbs->append(_custom_tb);
705 _server_options->append(_serverprotocol_label);
706 _server_options->append(_serverprotocol_iom->baseWidget());
707 _server_options->append(_servername_label);
708 _server_options->append(_servername_tf);
709 _server_options->append(_username_label);
710 _server_options->append(_username_tf);
711 _server_options->append(_password_label);
712 _server_options->append(_password_tf);
713 _server_options->append(_rememberpassword_tb);
714 _server_options->append(_removeafterdelivery_tb);
715 _server_options->append(_retrieveold_tb);
717 _custom_options->append(_customcommand_label);
718 _custom_options->append(_customcommand_tf);
723 MailRetrievalOptions::~MailRetrievalOptions (void)
727 IndexedOptionMenu *iom;
731 for (i=0; i<_propui_array->length(); i++)
733 pui = (*_propui_array)[i];
736 delete _propui_array;
739 if (_retrieval_tbs) delete _retrieval_tbs;
740 if (_server_options) delete _server_options;
741 if (_custom_options) delete _custom_options;
742 if (_serverprotocol_iom) delete _serverprotocol_iom;
743 if (_foldername) free(_foldername);
745 if (_w) XtDestroyWidget(_w);
749 MailRetrievalOptions::isValidInboxPath(PropUiItem* pui, void* data)
751 MailSession *ses = theRoamApp.session();
752 DtMail::Session *d_session = ses->session();
754 const char *errmsg = NULL;
755 char *inbox_path = NULL;
757 char *expanded_path = NULL;
761 text = pui->getWidget();
762 if (text) inbox_path = XmTextFieldGetString(text);
763 if (NULL == inbox_path || 0 == strlen(inbox_path))
764 return GETMSG(DT_catd, 27, 17, "Null INBOX path.");
766 tmp = (char*) malloc(strlen(inbox_path)+1);
767 for (s=inbox_path, t=tmp; *s; s++)
779 if (NULL == inbox_path || 0 == strlen(inbox_path))
780 return GETMSG(DT_catd, 27, 17, "Null INBOX path.");
782 if (isalpha(inbox_path[0]))
784 tmp = (char*) malloc(strlen(inbox_path) + 3);
785 sprintf(tmp, "./%s", inbox_path);
790 expanded_path = d_session->expandPath(error, inbox_path);
791 if (expanded_path) XmTextFieldSetString(text, expanded_path);
793 SafePathIsAccessible(error, expanded_path);
796 errmsg = (const char*) error;
797 errmsg = strdup(errmsg);
802 if (inbox_path) free(inbox_path);
803 if (expanded_path) free(expanded_path);
804 return (char*) errmsg;
808 MailRetrievalOptions::initOptionInteractions(void)
811 unsigned char isset, isset_server;
814 XtVaGetValues(_server_tb, XmNset, &isset, NULL);
815 if (XmUNSET == isset)
817 for (i=0; i<_server_options->length(); i++)
819 opt = (*_server_options)[i];
820 XtVaSetValues(opt, XmNsensitive, False, NULL);
825 for (i=0; i<_server_options->length(); i++)
827 opt = (*_server_options)[i];
828 XtVaSetValues(opt, XmNsensitive, True, NULL);
831 isset_server = isset;
833 XtVaGetValues(_custom_tb, XmNset, &isset, NULL);
834 if (XmUNSET == isset)
836 for (i=0; i<_custom_options->length(); i++)
838 opt = (*_custom_options)[i];
839 XtVaSetValues(opt, XmNsensitive, False, NULL);
844 for (i=0; i<_custom_options->length(); i++)
846 opt = (*_custom_options)[i];
847 XtVaSetValues(opt, XmNsensitive, True, NULL);
851 XtVaGetValues(_rememberpassword_tb, XmNset, &isset, NULL);
854 _password_pui->writeAllowed(DTM_TRUE);
856 XtVaSetValues(_password_label, XmNsensitive, True, NULL);
860 _password_pui->writeAllowed(DTM_FALSE);
861 XtVaSetValues(_password_label, XmNsensitive, False, NULL);
866 MailRetrievalOptions::getFirstProp(void)
868 _propui_array_iterator = 0;
869 return getNextProp();
873 MailRetrievalOptions::getNextProp(void)
875 PropUiItem *pui = (PropUiItem *) NULL;
877 if (_propui_array_iterator < _propui_array->length())
879 pui = (*_propui_array)[_propui_array_iterator];
880 _propui_array_iterator++;
886 MailRetrievalOptions::getNumProps(void)
888 return _propui_array->length();
892 MailRetrievalOptions::rememberPasswordChangedCB(
894 XtPointer client_data,
898 *mro = (MailRetrievalOptions*) client_data;
899 XmToggleButtonCallbackStruct
900 *cbs = (XmToggleButtonCallbackStruct*) call_data;
903 if (XmSET == cbs->set)
905 XtVaSetValues(mro->_password_label, XmNsensitive, True, NULL);
906 mro->_password_pui->writeAllowed(DTM_TRUE);
910 XtVaSetValues(mro->_password_label, XmNsensitive, False, NULL);
911 mro->_password_pui->writeAllowed(DTM_FALSE);
914 mro->initOptionInteractions();
919 MailRetrievalOptions::retrievalTBSValueChangedCB(
921 XtPointer client_data,
925 *mro = (MailRetrievalOptions*) client_data;
926 XmToggleButtonCallbackStruct
927 *cbs = (XmToggleButtonCallbackStruct*) call_data;
932 if (XmUNSET == cbs->set)
934 XtVaSetValues(w, XmNset, XmSET, NULL);
938 for (i=0; i<mro->_retrieval_tbs->length(); i++)
940 tb = (*mro->_retrieval_tbs)[i];
941 if (tb != w) XtVaSetValues(tb, XmNset, XmUNSET, NULL);
945 if (w == mro->_system_tb)
947 for (i=0; i<mro->_server_options->length(); i++)
949 opt = (*mro->_server_options)[i];
950 XtVaSetValues(opt, XmNsensitive, False, NULL);
952 for (i=0; i<mro->_custom_options->length(); i++)
954 opt = (*mro->_custom_options)[i];
955 XtVaSetValues(opt, XmNsensitive, False, NULL);
958 else if (w == mro->_server_tb)
960 for (i=0; i<mro->_server_options->length(); i++)
962 opt = (*mro->_server_options)[i];
963 XtVaSetValues(opt, XmNsensitive, True, NULL);
965 for (i=0; i<mro->_custom_options->length(); i++)
967 opt = (*mro->_custom_options)[i];
968 XtVaSetValues(opt, XmNsensitive, False, NULL);
971 else if (w == mro->_custom_tb)
973 for (i=0; i<mro->_server_options->length(); i++)
975 opt = (*mro->_server_options)[i];
976 XtVaSetValues(opt, XmNsensitive, False, NULL);
978 for (i=0; i<mro->_custom_options->length(); i++)
980 opt = (*mro->_custom_options)[i];
981 XtVaSetValues(opt, XmNsensitive, True, NULL);
985 mro->initOptionInteractions();
990 MailRetrievalOptions::getPassword(char *foldername)
992 DtMail::Session *d_session = NULL;
993 DtMail::MailRc *m_rc = NULL;
995 const char *string = NULL;
996 char propkey[MAXPATHLEN];
998 d_session = theRoamApp.session()->session();
999 m_rc = d_session->mailRc(error);
1001 MrGENPROPKEY(propkey, foldername, DTMAS_PROPKEY_PASSWORD);
1003 m_rc->getValue(error, propkey , &string, DTM_TRUE);
1004 if (string == NULL || error.isSet()) return NULL;
1006 return (char*) string;