2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: MailRetrievalOptions.C /main/8 1998/07/23 18:13:00 mgreess $ */
28 * RESTRICTED CONFIDENTIAL INFORMATION:
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
38 * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
43 * Common Desktop Environment
45 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
46 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
47 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
48 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
49 * (c) Copyright 1995 Digital Equipment Corp.
50 * (c) Copyright 1995 Fujitsu Limited
51 * (c) Copyright 1995 Hitachi, Ltd.
54 * RESTRICTED RIGHTS LEGEND
56 *Use, duplication, or disclosure by the U.S. Government is subject to
57 *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
58 *Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
59 *for non-DOD U.S. Government Departments and Agencies are as set forth in
60 *FAR 52.227-19(c)(1,2).
62 *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
63 *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
64 *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
65 *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
66 *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
67 *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
68 *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
73 #include <sys/param.h>
74 #include <X11/Intrinsic.h>
77 #include <Xm/DialogS.h>
79 #include <Xm/ToggleB.h>
80 #include <Dt/PrintOptionsP.h>
82 #include <DtMail/IO.hh>
83 #include "CheckBoxUiItem.hh"
85 #include "DtMailError.hh"
86 #include "InboxTextFieldUiItem.hh"
87 #include "IndexedOptionMenuUiItem.hh"
89 #include "MailRetrievalOptions.h"
91 #include "CheckForMailUiItem.hh"
92 #include "SpinBoxUiItem.hh"
93 #include "TextFieldUiItem.hh"
94 #include "dtmailopts.h"
96 #define MR_ARRAY_SIZE(ary) (sizeof((ary))/sizeof((ary)[0]))
98 static MrPropVal serverprotocol_values[] =
117 #define MrGENPROPKEY(pk, fld, key) DTMAS_CONCAT_MAILRC_KEY(pk, fld, key)
119 MailRetrievalOptions::MailRetrievalOptions (
121 const char *foldername
122 ) : UIComponent( "PrintOptions" )
124 DtMail::Session *d_session = theRoamApp.session()->session();
125 PropUiItem *pui = (PropUiItem *) NULL;
126 Widget *menu_buttons, w;
131 char *propkey = new char[MAXPATHLEN];
133 _password_pui = NULL;
134 _inboxpath_label = NULL;
135 _inboxpath_tf = NULL;
136 _checkfornewmail_label = NULL;
137 _checkfornewmail_sb = NULL;
139 _server_frame = NULL;
141 _serverframe_form = NULL;
142 _serverprotocol_label = NULL;
143 _serverprotocol_iom = NULL;
144 _servername_label = NULL;
145 _servername_tf = NULL;
146 _username_label = NULL;
148 _password_label = NULL;
150 _rememberpassword_tb = NULL;
151 _removeafterdelivery_tb = NULL;
152 _retrieveold_tb = NULL;
153 _custom_frame = NULL;
155 _customframe_form = NULL;
156 _customcommand_label = NULL;
157 _customcommand_tf = NULL;
160 _propui_array = new DtVirtArray<PropUiItem *>(10);
161 _propui_array_iterator = 0;
163 if (NULL != foldername)
164 _foldername = strdup(foldername);
166 _foldername = strdup(DTMAS_INBOX);
168 _retrieval_tbs = new DtVirtArray<Widget>(10);
169 _custom_options = new DtVirtArray<Widget>(10);
170 _server_options = new DtVirtArray<Widget>(10);
173 // Create FORM to hold the printing options
175 _form = XtVaCreateWidget(
176 "MailRetrievalOptions",
179 XmNbottomAttachment, XmATTACH_FORM,
180 XmNrightAttachment, XmATTACH_FORM,
181 XmNleftAttachment, XmATTACH_FORM,
182 XmNtopAttachment, XmATTACH_FORM,
183 XmNresizePolicy, XmRESIZE_ANY,
186 if (_form == (Widget) NULL)
192 installDestroyHandler();
195 // Create GUI for the INBOX Name Option
197 _inboxpath_tf = XtVaCreateManagedWidget(
199 xmTextFieldWidgetClass, _form,
200 XmNtopAttachment, XmATTACH_FORM,
202 XmNleftAttachment, XmATTACH_POSITION,
204 XmNrightAttachment, XmATTACH_NONE,
208 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 18,"INBOX folder path:"));
209 _inboxpath_label = XtVaCreateManagedWidget(
211 xmLabelWidgetClass, _form,
213 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
215 XmNtopWidget, _inboxpath_tf,
216 XmNleftAttachment, XmATTACH_NONE,
217 XmNrightAttachment, XmATTACH_WIDGET,
219 XmNrightWidget, _inboxpath_tf,
224 // Create PropUiItem for the ServerName Option
226 DtMailObjectSpace space;
228 char *dflt_inboxpath = NULL;
229 d_session->queryImpl(
231 d_session->getDefaultImpl(error),
232 DtMailCapabilityInboxName,
233 &space, &dflt_inboxpath);
235 //MrGENPROPKEY(propkey, "", DTMAS_PROPKEY_INBOXPATH);
236 strcpy(propkey, DTMAS_PROPKEY_INBOXPATH);
237 PropSource::setDefaultValue(propkey, dflt_inboxpath);
238 pui = (PropUiItem *) new InboxTextFieldUiItem(
242 MailRetrievalOptions::isValidInboxPath);
243 _propui_array->append(pui);
244 free(dflt_inboxpath);
247 // Create GUI for the CheckForNewMail Option
249 _checkfornewmail_sb = XtVaCreateManagedWidget(
251 xmSimpleSpinBoxWidgetClass, _form,
252 XmNtopAttachment, XmATTACH_WIDGET,
253 XmNtopWidget, _inboxpath_tf,
255 XmNleftAttachment, XmATTACH_POSITION,
257 XmNrightAttachment, XmATTACH_NONE,
259 XmNincrementValue, 1,
261 XmNmaximumValue, 999999,
263 XmNarrowLayout, XmARROWS_END,
264 XmNspinBoxChildType, XmNUMERIC,
268 xms = XmStringCreateLocalized(
269 GETMSG(Dtb_project_catd, 2, 13, "Check for new mail every:"));
270 _checkfornewmail_label = XtVaCreateManagedWidget(
271 "CheckForNewMailLabel",
272 xmLabelWidgetClass, _form,
273 XmNlabelType, XmSTRING,
275 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
277 XmNtopWidget, _checkfornewmail_sb,
278 XmNleftAttachment, XmATTACH_NONE,
279 XmNrightAttachment, XmATTACH_WIDGET,
281 XmNrightWidget, _checkfornewmail_sb,
286 // Create PropUiItem for the CheckForNewMail Option
288 strcpy(propkey, "retrieveinterval");
289 PropSource::setDefaultValue(propkey, "300");
290 pui = (PropUiItem*) new CheckForMailUiItem(
294 _propui_array->append(pui);
299 w = XtVaCreateManagedWidget(
300 "MailRetrievalSeparator",
301 xmSeparatorGadgetClass, _form,
302 XmNrightAttachment, XmATTACH_FORM,
303 XmNleftAttachment, XmATTACH_FORM,
304 XmNtopAttachment, XmATTACH_WIDGET,
305 XmNtopWidget, _checkfornewmail_sb,
309 xms = XmStringCreateLocalized(
310 GETMSG(DT_catd, 27, 6, "Automatic (system) delivery"));
311 _system_tb = XtVaCreateManagedWidget(
313 xmToggleButtonGadgetClass, _form,
314 XmNrightAttachment, XmATTACH_FORM,
315 XmNleftAttachment, XmATTACH_FORM,
317 XmNtopAttachment, XmATTACH_WIDGET,
320 XmNalignment, XmALIGNMENT_BEGINNING,
328 XmNvalueChangedCallback,
329 MailRetrievalOptions::retrievalTBSValueChangedCB,
333 // Create PropUiItem for the System Option
335 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILVIASYSTEM);
336 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILVIASYSTEM);
337 pui = (PropUiItem *) new CheckBoxUiItem(_system_tb, _FROM_MAILRC, propkey);
338 _propui_array->append(pui);
341 // Create FRAME to hold the server printing options
343 _server_frame = XtVaCreateManagedWidget(
344 "ServerFrame", xmFrameWidgetClass, _form,
345 XmNchildHorizontalAlignment,
346 XmALIGNMENT_BEGINNING,
347 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
348 XmNtopAttachment, XmATTACH_WIDGET,
349 XmNtopWidget, _system_tb,
350 XmNleftAttachment, XmATTACH_FORM,
352 XmNrightAttachment, XmATTACH_FORM,
354 XmNbottomAttachment, XmATTACH_NONE,
357 xms = XmStringCreateLocalized(
358 GETMSG(DT_catd, 27, 7, "Mail server retrieval"));
359 _server_tb = XtVaCreateManagedWidget(
361 xmToggleButtonGadgetClass, _server_frame,
362 XmNchildType, XmFRAME_TITLE_CHILD,
363 XmNchildHorizontalAlignment,
364 XmALIGNMENT_BEGINNING,
365 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
373 XmNvalueChangedCallback,
374 MailRetrievalOptions::retrievalTBSValueChangedCB,
378 // Create PropUiItem for the Server Option
380 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILVIASERVER);
381 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILVIASERVER);
382 pui = (PropUiItem *) new CheckBoxUiItem(_server_tb, _FROM_MAILRC, propkey);
383 _propui_array->append(pui);
385 _serverframe_form = XtVaCreateManagedWidget(
389 //XmNallowOverlap, False,
391 XmNresizePolicy, XmRESIZE_ANY,
395 // Create GUI for the MailServerProtocol Option
397 nitems = MR_ARRAY_SIZE(serverprotocol_values);
398 strings = (char**) XtMalloc(nitems*sizeof(char*));
399 data = (void**) XtMalloc(nitems*sizeof(void*));
400 for (int i=0; i<nitems; i++)
402 data[i] = (void*) serverprotocol_values[i].prop_value_string;
405 serverprotocol_values[i].set_id,
406 serverprotocol_values[i].msg_id,
407 serverprotocol_values[i].dflt_gui_string);
410 _serverprotocol_iom =
411 new IndexedOptionMenu(_serverframe_form, nitems, (char**) strings, data);
413 _serverprotocol_iom->baseWidget(),
414 XmNtopAttachment, XmATTACH_FORM,
415 XmNleftAttachment, XmATTACH_POSITION,
417 XmNrightAttachment, XmATTACH_NONE,
419 _serverprotocol_iom->manage();
420 _serverprotocol_iom->setSpec((void*) DTMAS_PROPDFLT_PROTOCOL);
421 XtFree((char*) strings);
422 XtFree((char*) data);
424 xms = XmStringCreateLocalized(
425 GETMSG(DT_catd, 27, 8, "Server Protocol:"));
426 _serverprotocol_label = XtVaCreateManagedWidget(
427 "ServerProtocolLabel",
428 xmLabelWidgetClass, _serverframe_form,
430 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
432 XmNtopWidget, _serverprotocol_iom->baseWidget(),
433 XmNleftAttachment, XmATTACH_NONE,
434 XmNrightAttachment, XmATTACH_WIDGET,
436 XmNrightWidget, _serverprotocol_iom->baseWidget(),
441 // Create PropUiItem for the Printed Headers option
443 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_PROTOCOL);
444 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_PROTOCOL);
445 pui = (PropUiItem *) new
446 IndexedOptionMenuUiItem(_serverprotocol_iom, _FROM_MAILRC, propkey);
447 _propui_array->append(pui);
450 // Create GUI for the ServerName Option
452 _servername_tf = XtVaCreateManagedWidget(
454 xmTextFieldWidgetClass, _serverframe_form,
455 XmNtopAttachment, XmATTACH_WIDGET,
456 XmNtopWidget, _serverprotocol_iom->baseWidget(),
457 XmNleftAttachment, XmATTACH_POSITION,
459 XmNrightAttachment, XmATTACH_NONE,
463 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 9, "Server Name:"));
464 _servername_label = XtVaCreateManagedWidget(
466 xmLabelWidgetClass, _serverframe_form,
468 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
470 XmNtopWidget, _servername_tf,
471 XmNleftAttachment, XmATTACH_NONE,
472 XmNrightAttachment, XmATTACH_WIDGET,
474 XmNrightWidget, _servername_tf,
479 // Create PropUiItem for the ServerName Option
481 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_SERVERNAME);
482 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_SERVERNAME);
483 pui = (PropUiItem *) new
484 TextFieldUiItem(_servername_tf, _FROM_MAILRC, propkey);
485 _propui_array->append(pui);
488 // Create GUI for the UserName Option
490 _username_tf = XtVaCreateManagedWidget(
492 xmTextFieldWidgetClass, _serverframe_form,
493 XmNtopAttachment, XmATTACH_WIDGET,
494 XmNtopWidget, _servername_tf,
495 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
496 XmNleftWidget, _servername_tf,
497 XmNrightAttachment, XmATTACH_NONE,
501 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 10, "User Name:"));
502 _username_label = XtVaCreateManagedWidget(
504 xmLabelWidgetClass, _serverframe_form,
506 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
507 XmNtopWidget, _username_tf,
508 XmNleftAttachment, XmATTACH_NONE,
509 XmNrightAttachment, XmATTACH_WIDGET,
510 XmNrightWidget, _username_tf,
515 // Create PropUiItem for the UserName Option
518 GetPasswordEntry(pwd);
520 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_USERNAME);
521 PropSource::setDefaultValue(propkey, pwd.pw_name);
522 pui = (PropUiItem *) new
523 TextFieldUiItem(_username_tf, _FROM_MAILRC, propkey);
524 _propui_array->append(pui);
527 // Create GUI for the Password Option
529 _password_tf = XtVaCreateManagedWidget(
531 xmTextFieldWidgetClass, _serverframe_form,
532 XmNtopAttachment, XmATTACH_WIDGET,
533 XmNtopWidget, _username_tf,
534 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
535 XmNleftWidget, _username_tf,
536 XmNrightAttachment, XmATTACH_NONE,
540 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 11, "Password:"));
541 _password_label = XtVaCreateManagedWidget(
543 xmLabelWidgetClass, _serverframe_form,
545 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
546 XmNtopWidget, _password_tf,
547 XmNleftAttachment, XmATTACH_NONE,
548 XmNrightAttachment, XmATTACH_WIDGET,
549 XmNrightWidget, _password_tf,
555 // Create a PropUiItem for the Password Option
557 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_PASSWORD);
558 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_PASSWORD);
560 EncryptedTextFieldUiItem(_password_tf, _FROM_MAILRC, propkey);
561 _propui_array->append((PropUiItem*) _password_pui);
564 // Create GUI for the Remember Password Option
566 xms = XmStringCreateLocalized(
567 GETMSG(DT_catd, 27, 12, "Remember password"));
568 _rememberpassword_tb = XtVaCreateManagedWidget(
569 "RememberPasswordTB",
570 xmToggleButtonWidgetClass, _serverframe_form,
571 XmNtopAttachment, XmATTACH_WIDGET,
572 XmNtopWidget, _password_tf,
573 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
574 XmNleftWidget, _password_tf,
575 XmNrightAttachment, XmATTACH_NONE,
576 XmNalignment, XmALIGNMENT_END,
583 _rememberpassword_tb,
584 XmNvalueChangedCallback,
585 MailRetrievalOptions::rememberPasswordChangedCB,
589 // Create PropUiItem for the RememberPassword Option
591 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_REMEMBERPASSWORD);
592 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_REMEMBERPASSWORD);
593 pui = (PropUiItem *) new
594 CheckBoxUiItem(_rememberpassword_tb, _FROM_MAILRC, propkey);
595 _propui_array->append(pui);
598 // Create GUI for the Delete From Server Option
600 xms = XmStringCreateLocalized(
601 GETMSG(DT_catd, 27, 13,
602 "Delete from server after retrieval"));
603 _removeafterdelivery_tb = XtVaCreateManagedWidget(
604 "RemoveAfterDeliveryTB",
605 xmToggleButtonWidgetClass, _serverframe_form,
606 XmNtopAttachment, XmATTACH_WIDGET,
607 XmNtopWidget, _rememberpassword_tb,
608 XmNleftAttachment, XmATTACH_POSITION,
610 XmNrightAttachment, XmATTACH_NONE,
611 XmNalignment, XmALIGNMENT_BEGINNING,
618 // Create PropUiItem for the RemoveAfterDelivery Option
620 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_REMOVEAFTERDELIVERY);
621 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_REMOVEAFTERDELIVERY);
622 pui = (PropUiItem *) new
623 CheckBoxUiItem(_removeafterdelivery_tb, _FROM_MAILRC, propkey);
624 _propui_array->append(pui);
627 // Create GUI for the RetrieveOld Option
629 xms = XmStringCreateLocalized(
630 GETMSG(DT_catd, 27, 14,
631 "Retrieve old messages"));
632 _retrieveold_tb = XtVaCreateManagedWidget(
634 xmToggleButtonWidgetClass, _serverframe_form,
635 XmNtopAttachment, XmATTACH_WIDGET,
636 XmNtopWidget, _removeafterdelivery_tb,
637 XmNleftAttachment, XmATTACH_POSITION,
639 XmNrightAttachment, XmATTACH_NONE,
640 XmNalignment, XmALIGNMENT_BEGINNING,
647 // Create PropUiItem for the RetrieveOld Option
649 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_RETRIEVEOLD);
650 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_RETRIEVEOLD);
651 pui = (PropUiItem *) new
652 CheckBoxUiItem(_retrieveold_tb, _FROM_MAILRC, propkey);
653 _propui_array->append(pui);
656 // Create FRAME to hold the user command printing options
658 _custom_frame = XtVaCreateManagedWidget(
659 "CustomFrame", xmFrameWidgetClass, _form,
660 XmNchildHorizontalAlignment,
661 XmALIGNMENT_BEGINNING,
662 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
663 XmNtopAttachment, XmATTACH_WIDGET,
664 XmNtopWidget, _server_frame,
665 XmNleftAttachment, XmATTACH_FORM,
667 XmNrightAttachment, XmATTACH_FORM,
669 XmNbottomAttachment, XmATTACH_FORM,
673 xms = XmStringCreateLocalized(
674 GETMSG(DT_catd, 27, 15, "Custom retrieval"));
675 _custom_tb = XtVaCreateManagedWidget(
677 xmToggleButtonGadgetClass, _custom_frame,
678 XmNchildType, XmFRAME_TITLE_CHILD,
679 XmNchildHorizontalAlignment,
680 XmALIGNMENT_BEGINNING,
681 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
689 XmNvalueChangedCallback,
690 MailRetrievalOptions::retrievalTBSValueChangedCB,
694 // Create PropUiItem for the Custom Command Option
696 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILVIACOMMAND);
697 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILVIACOMMAND);
698 pui = (PropUiItem *) new CheckBoxUiItem(_custom_tb, _FROM_MAILRC, propkey);
699 _propui_array->append(pui);
701 _customframe_form = XtVaCreateManagedWidget(
703 xmFormWidgetClass, _custom_frame,
704 //XmNallowOverlap, False,
706 XmNresizePolicy, XmRESIZE_ANY,
710 // Create GUI for the User Command Option
712 _customcommand_tf = XtVaCreateManagedWidget(
714 xmTextFieldWidgetClass, _customframe_form,
715 XmNtopAttachment, XmATTACH_FORM,
716 XmNleftAttachment, XmATTACH_POSITION,
718 XmNrightAttachment, XmATTACH_NONE,
722 xms = XmStringCreateLocalized(
723 GETMSG(DT_catd, 27, 16, "User Getmail command:"));
724 _customcommand_label = XtVaCreateManagedWidget(
725 "CustomCommandLabel",
726 xmLabelWidgetClass, _customframe_form,
728 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
730 XmNtopWidget, _customcommand_tf,
731 XmNleftAttachment, XmATTACH_NONE,
732 XmNrightAttachment, XmATTACH_WIDGET,
734 XmNrightWidget, _customcommand_tf,
739 // Create PropUiItem for the ServerName Option
741 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILCOMMAND);
742 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILCOMMAND);
743 pui = (PropUiItem *) new
744 TextFieldUiItem(_customcommand_tf, _FROM_MAILRC, propkey);
745 _propui_array->append(pui);
748 // Save widgets for manipulation.
750 _retrieval_tbs->append(_system_tb);
751 _retrieval_tbs->append(_server_tb);
752 _retrieval_tbs->append(_custom_tb);
754 _server_options->append(_serverprotocol_label);
755 _server_options->append(_serverprotocol_iom->baseWidget());
756 _server_options->append(_servername_label);
757 _server_options->append(_servername_tf);
758 _server_options->append(_username_label);
759 _server_options->append(_username_tf);
760 _server_options->append(_password_label);
761 _server_options->append(_password_tf);
762 _server_options->append(_rememberpassword_tb);
763 _server_options->append(_removeafterdelivery_tb);
764 _server_options->append(_retrieveold_tb);
766 _custom_options->append(_customcommand_label);
767 _custom_options->append(_customcommand_tf);
772 MailRetrievalOptions::~MailRetrievalOptions (void)
776 IndexedOptionMenu *iom;
780 for (i=0; i<_propui_array->length(); i++)
782 pui = (*_propui_array)[i];
785 delete _propui_array;
788 if (_retrieval_tbs) delete _retrieval_tbs;
789 if (_server_options) delete _server_options;
790 if (_custom_options) delete _custom_options;
791 if (_serverprotocol_iom) delete _serverprotocol_iom;
792 if (_foldername) free(_foldername);
794 if (_w) XtDestroyWidget(_w);
798 MailRetrievalOptions::isValidInboxPath(PropUiItem* pui, void* data)
800 MailSession *ses = theRoamApp.session();
801 DtMail::Session *d_session = ses->session();
803 const char *errmsg = NULL;
804 char *inbox_path = NULL;
806 char *expanded_path = NULL;
810 text = pui->getWidget();
811 if (text) inbox_path = XmTextFieldGetString(text);
812 if (NULL == inbox_path || 0 == strlen(inbox_path))
813 return GETMSG(DT_catd, 27, 17, "Null INBOX path.");
815 tmp = (char*) malloc(strlen(inbox_path)+1);
816 for (s=inbox_path, t=tmp; *s; s++)
828 if (NULL == inbox_path || 0 == strlen(inbox_path))
829 return GETMSG(DT_catd, 27, 17, "Null INBOX path.");
831 if (isalpha(inbox_path[0]))
833 tmp = (char*) malloc(strlen(inbox_path) + 3);
834 sprintf(tmp, "./%s", inbox_path);
839 expanded_path = d_session->expandPath(error, inbox_path);
840 if (expanded_path) XmTextFieldSetString(text, expanded_path);
842 SafePathIsAccessible(error, expanded_path);
845 errmsg = (const char*) error;
846 errmsg = strdup(errmsg);
851 if (inbox_path) free(inbox_path);
853 return (char*) errmsg;
857 MailRetrievalOptions::initOptionInteractions(void)
860 unsigned char isset, isset_server;
863 XtVaGetValues(_server_tb, XmNset, &isset, NULL);
864 if (XmUNSET == isset)
866 for (i=0; i<_server_options->length(); i++)
868 opt = (*_server_options)[i];
869 XtVaSetValues(opt, XmNsensitive, False, NULL);
874 for (i=0; i<_server_options->length(); i++)
876 opt = (*_server_options)[i];
877 XtVaSetValues(opt, XmNsensitive, True, NULL);
880 isset_server = isset;
882 XtVaGetValues(_custom_tb, XmNset, &isset, NULL);
883 if (XmUNSET == isset)
885 for (i=0; i<_custom_options->length(); i++)
887 opt = (*_custom_options)[i];
888 XtVaSetValues(opt, XmNsensitive, False, NULL);
893 for (i=0; i<_custom_options->length(); i++)
895 opt = (*_custom_options)[i];
896 XtVaSetValues(opt, XmNsensitive, True, NULL);
900 XtVaGetValues(_rememberpassword_tb, XmNset, &isset, NULL);
903 _password_pui->writeAllowed(DTM_TRUE);
905 XtVaSetValues(_password_label, XmNsensitive, True, NULL);
909 _password_pui->writeAllowed(DTM_FALSE);
910 XtVaSetValues(_password_label, XmNsensitive, False, NULL);
915 MailRetrievalOptions::getFirstProp(void)
917 _propui_array_iterator = 0;
918 return getNextProp();
922 MailRetrievalOptions::getNextProp(void)
924 PropUiItem *pui = (PropUiItem *) NULL;
926 if (_propui_array_iterator < _propui_array->length())
928 pui = (*_propui_array)[_propui_array_iterator];
929 _propui_array_iterator++;
935 MailRetrievalOptions::getNumProps(void)
937 return _propui_array->length();
941 MailRetrievalOptions::rememberPasswordChangedCB(
943 XtPointer client_data,
947 *mro = (MailRetrievalOptions*) client_data;
948 XmToggleButtonCallbackStruct
949 *cbs = (XmToggleButtonCallbackStruct*) call_data;
952 if (XmSET == cbs->set)
954 XtVaSetValues(mro->_password_label, XmNsensitive, True, NULL);
955 mro->_password_pui->writeAllowed(DTM_TRUE);
959 XtVaSetValues(mro->_password_label, XmNsensitive, False, NULL);
960 mro->_password_pui->writeAllowed(DTM_FALSE);
963 mro->initOptionInteractions();
968 MailRetrievalOptions::retrievalTBSValueChangedCB(
970 XtPointer client_data,
974 *mro = (MailRetrievalOptions*) client_data;
975 XmToggleButtonCallbackStruct
976 *cbs = (XmToggleButtonCallbackStruct*) call_data;
981 if (XmUNSET == cbs->set)
983 XtVaSetValues(w, XmNset, XmSET, NULL);
987 for (i=0; i<mro->_retrieval_tbs->length(); i++)
989 tb = (*mro->_retrieval_tbs)[i];
990 if (tb != w) XtVaSetValues(tb, XmNset, XmUNSET, NULL);
994 if (w == mro->_system_tb)
996 for (i=0; i<mro->_server_options->length(); i++)
998 opt = (*mro->_server_options)[i];
999 XtVaSetValues(opt, XmNsensitive, False, NULL);
1001 for (i=0; i<mro->_custom_options->length(); i++)
1003 opt = (*mro->_custom_options)[i];
1004 XtVaSetValues(opt, XmNsensitive, False, NULL);
1007 else if (w == mro->_server_tb)
1009 for (i=0; i<mro->_server_options->length(); i++)
1011 opt = (*mro->_server_options)[i];
1012 XtVaSetValues(opt, XmNsensitive, True, NULL);
1014 for (i=0; i<mro->_custom_options->length(); i++)
1016 opt = (*mro->_custom_options)[i];
1017 XtVaSetValues(opt, XmNsensitive, False, NULL);
1020 else if (w == mro->_custom_tb)
1022 for (i=0; i<mro->_server_options->length(); i++)
1024 opt = (*mro->_server_options)[i];
1025 XtVaSetValues(opt, XmNsensitive, False, NULL);
1027 for (i=0; i<mro->_custom_options->length(); i++)
1029 opt = (*mro->_custom_options)[i];
1030 XtVaSetValues(opt, XmNsensitive, True, NULL);
1034 mro->initOptionInteractions();
1039 MailRetrievalOptions::getPassword(char *foldername)
1041 DtMail::Session *d_session = NULL;
1042 DtMail::MailRc *m_rc = NULL;
1044 const char *string = NULL;
1045 char propkey[MAXPATHLEN];
1047 d_session = theRoamApp.session()->session();
1048 m_rc = d_session->mailRc(error);
1050 MrGENPROPKEY(propkey, foldername, DTMAS_PROPKEY_PASSWORD);
1052 m_rc->getValue(error, propkey , &string, DTM_TRUE);
1053 if (string == NULL || error.isSet()) return NULL;
1055 return (char*) string;