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 _propui_array = new DtVirtArray<PropUiItem *>(10);
134 _propui_array_iterator = 0;
136 if (NULL != foldername)
137 _foldername = strdup(foldername);
139 _foldername = strdup(DTMAS_INBOX);
141 _retrieval_tbs = new DtVirtArray<Widget>(10);
142 _custom_options = new DtVirtArray<Widget>(10);
143 _server_options = new DtVirtArray<Widget>(10);
146 // Create FORM to hold the printing options
148 _form = XtVaCreateWidget(
149 "MailRetrievalOptions",
152 XmNbottomAttachment, XmATTACH_FORM,
153 XmNrightAttachment, XmATTACH_FORM,
154 XmNleftAttachment, XmATTACH_FORM,
155 XmNtopAttachment, XmATTACH_FORM,
156 XmNresizePolicy, XmRESIZE_ANY,
159 if (_form == (Widget) NULL)
165 installDestroyHandler();
168 // Create GUI for the INBOX Name Option
170 _inboxpath_tf = XtVaCreateManagedWidget(
172 xmTextFieldWidgetClass, _form,
173 XmNtopAttachment, XmATTACH_FORM,
175 XmNleftAttachment, XmATTACH_POSITION,
177 XmNrightAttachment, XmATTACH_NONE,
181 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 18,"INBOX folder path:"));
182 _inboxpath_label = XtVaCreateManagedWidget(
184 xmLabelWidgetClass, _form,
186 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
188 XmNtopWidget, _inboxpath_tf,
189 XmNleftAttachment, XmATTACH_NONE,
190 XmNrightAttachment, XmATTACH_WIDGET,
192 XmNrightWidget, _inboxpath_tf,
197 // Create PropUiItem for the ServerName Option
199 DtMailObjectSpace space;
201 char *dflt_inboxpath = NULL;
202 d_session->queryImpl(
204 d_session->getDefaultImpl(error),
205 DtMailCapabilityInboxName,
206 &space, &dflt_inboxpath);
208 //MrGENPROPKEY(propkey, "", DTMAS_PROPKEY_INBOXPATH);
209 strcpy(propkey, DTMAS_PROPKEY_INBOXPATH);
210 PropSource::setDefaultValue(propkey, dflt_inboxpath);
211 pui = (PropUiItem *) new InboxTextFieldUiItem(
215 MailRetrievalOptions::isValidInboxPath);
216 _propui_array->append(pui);
217 free(dflt_inboxpath);
220 // Create GUI for the CheckForNewMail Option
222 _checkfornewmail_sb = XtVaCreateManagedWidget(
224 xmSimpleSpinBoxWidgetClass, _form,
225 XmNtopAttachment, XmATTACH_WIDGET,
226 XmNtopWidget, _inboxpath_tf,
228 XmNleftAttachment, XmATTACH_POSITION,
230 XmNrightAttachment, XmATTACH_NONE,
232 XmNincrementValue, 1,
234 XmNmaximumValue, 999999,
236 XmNarrowLayout, XmARROWS_END,
237 XmNspinBoxChildType, XmNUMERIC,
241 xms = XmStringCreateLocalized(
242 GETMSG(Dtb_project_catd, 2, 13, "Check for new mail every:"));
243 _checkfornewmail_label = XtVaCreateManagedWidget(
244 "CheckForNewMailLabel",
245 xmLabelWidgetClass, _form,
246 XmNlabelType, XmSTRING,
248 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
250 XmNtopWidget, _checkfornewmail_sb,
251 XmNleftAttachment, XmATTACH_NONE,
252 XmNrightAttachment, XmATTACH_WIDGET,
254 XmNrightWidget, _checkfornewmail_sb,
259 // Create PropUiItem for the CheckForNewMail Option
261 strcpy(propkey, "retrieveinterval");
262 PropSource::setDefaultValue(propkey, "300");
263 pui = (PropUiItem*) new CheckForMailUiItem(
267 _propui_array->append(pui);
272 w = XtVaCreateManagedWidget(
273 "MailRetrievalSeparator",
274 xmSeparatorGadgetClass, _form,
275 XmNrightAttachment, XmATTACH_FORM,
276 XmNleftAttachment, XmATTACH_FORM,
277 XmNtopAttachment, XmATTACH_WIDGET,
278 XmNtopWidget, _checkfornewmail_sb,
282 xms = XmStringCreateLocalized(
283 GETMSG(DT_catd, 27, 6, "Automatic (system) delivery"));
284 _system_tb = XtVaCreateManagedWidget(
286 xmToggleButtonGadgetClass, _form,
287 XmNrightAttachment, XmATTACH_FORM,
288 XmNleftAttachment, XmATTACH_FORM,
290 XmNtopAttachment, XmATTACH_WIDGET,
293 XmNalignment, XmALIGNMENT_BEGINNING,
301 XmNvalueChangedCallback,
302 MailRetrievalOptions::retrievalTBSValueChangedCB,
306 // Create PropUiItem for the System Option
308 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILVIASYSTEM);
309 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILVIASYSTEM);
310 pui = (PropUiItem *) new CheckBoxUiItem(_system_tb, _FROM_MAILRC, propkey);
311 _propui_array->append(pui);
314 // Create FRAME to hold the server printing options
316 _server_frame = XtVaCreateManagedWidget(
317 "ServerFrame", xmFrameWidgetClass, _form,
318 XmNchildHorizontalAlignment,
319 XmALIGNMENT_BEGINNING,
320 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
321 XmNtopAttachment, XmATTACH_WIDGET,
322 XmNtopWidget, _system_tb,
323 XmNleftAttachment, XmATTACH_FORM,
325 XmNrightAttachment, XmATTACH_FORM,
327 XmNbottomAttachment, XmATTACH_NONE,
330 xms = XmStringCreateLocalized(
331 GETMSG(DT_catd, 27, 7, "Mail server retrieval"));
332 _server_tb = XtVaCreateManagedWidget(
334 xmToggleButtonGadgetClass, _server_frame,
335 XmNchildType, XmFRAME_TITLE_CHILD,
336 XmNchildHorizontalAlignment,
337 XmALIGNMENT_BEGINNING,
338 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
346 XmNvalueChangedCallback,
347 MailRetrievalOptions::retrievalTBSValueChangedCB,
351 // Create PropUiItem for the Server Option
353 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILVIASERVER);
354 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILVIASERVER);
355 pui = (PropUiItem *) new CheckBoxUiItem(_server_tb, _FROM_MAILRC, propkey);
356 _propui_array->append(pui);
358 _serverframe_form = XtVaCreateManagedWidget(
362 //XmNallowOverlap, False,
364 XmNresizePolicy, XmRESIZE_ANY,
368 // Create GUI for the MailServerProtocol Option
370 nitems = MR_ARRAY_SIZE(serverprotocol_values);
371 strings = (char**) XtMalloc(nitems*sizeof(char*));
372 data = (void**) XtMalloc(nitems*sizeof(void*));
373 for (int i=0; i<nitems; i++)
375 data[i] = (void*) serverprotocol_values[i].prop_value_string;
378 serverprotocol_values[i].set_id,
379 serverprotocol_values[i].msg_id,
380 serverprotocol_values[i].dflt_gui_string);
383 _serverprotocol_iom =
384 new IndexedOptionMenu(_serverframe_form, nitems, (char**) strings, data);
386 _serverprotocol_iom->baseWidget(),
387 XmNtopAttachment, XmATTACH_FORM,
388 XmNleftAttachment, XmATTACH_POSITION,
390 XmNrightAttachment, XmATTACH_NONE,
392 _serverprotocol_iom->manage();
393 _serverprotocol_iom->setSpec((void*) DTMAS_PROPDFLT_PROTOCOL);
394 XtFree((char*) strings);
395 XtFree((char*) data);
397 xms = XmStringCreateLocalized(
398 GETMSG(DT_catd, 27, 8, "Server Protocol:"));
399 _serverprotocol_label = XtVaCreateManagedWidget(
400 "ServerProtocolLabel",
401 xmLabelWidgetClass, _serverframe_form,
403 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
405 XmNtopWidget, _serverprotocol_iom->baseWidget(),
406 XmNleftAttachment, XmATTACH_NONE,
407 XmNrightAttachment, XmATTACH_WIDGET,
409 XmNrightWidget, _serverprotocol_iom->baseWidget(),
414 // Create PropUiItem for the Printed Headers option
416 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_PROTOCOL);
417 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_PROTOCOL);
418 pui = (PropUiItem *) new
419 IndexedOptionMenuUiItem(_serverprotocol_iom, _FROM_MAILRC, propkey);
420 _propui_array->append(pui);
423 // Create GUI for the ServerName Option
425 _servername_tf = XtVaCreateManagedWidget(
427 xmTextFieldWidgetClass, _serverframe_form,
428 XmNtopAttachment, XmATTACH_WIDGET,
429 XmNtopWidget, _serverprotocol_iom->baseWidget(),
430 XmNleftAttachment, XmATTACH_POSITION,
432 XmNrightAttachment, XmATTACH_NONE,
436 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 9, "Server Name:"));
437 _servername_label = XtVaCreateManagedWidget(
439 xmLabelWidgetClass, _serverframe_form,
441 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
443 XmNtopWidget, _servername_tf,
444 XmNleftAttachment, XmATTACH_NONE,
445 XmNrightAttachment, XmATTACH_WIDGET,
447 XmNrightWidget, _servername_tf,
452 // Create PropUiItem for the ServerName Option
454 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_SERVERNAME);
455 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_SERVERNAME);
456 pui = (PropUiItem *) new
457 TextFieldUiItem(_servername_tf, _FROM_MAILRC, propkey);
458 _propui_array->append(pui);
461 // Create GUI for the UserName Option
463 _username_tf = XtVaCreateManagedWidget(
465 xmTextFieldWidgetClass, _serverframe_form,
466 XmNtopAttachment, XmATTACH_WIDGET,
467 XmNtopWidget, _servername_tf,
468 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
469 XmNleftWidget, _servername_tf,
470 XmNrightAttachment, XmATTACH_NONE,
474 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 10, "User Name:"));
475 _username_label = XtVaCreateManagedWidget(
477 xmLabelWidgetClass, _serverframe_form,
479 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
480 XmNtopWidget, _username_tf,
481 XmNleftAttachment, XmATTACH_NONE,
482 XmNrightAttachment, XmATTACH_WIDGET,
483 XmNrightWidget, _username_tf,
488 // Create PropUiItem for the UserName Option
491 GetPasswordEntry(pwd);
493 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_USERNAME);
494 PropSource::setDefaultValue(propkey, pwd.pw_name);
495 pui = (PropUiItem *) new
496 TextFieldUiItem(_username_tf, _FROM_MAILRC, propkey);
497 _propui_array->append(pui);
500 // Create GUI for the Password Option
502 _password_tf = XtVaCreateManagedWidget(
504 xmTextFieldWidgetClass, _serverframe_form,
505 XmNtopAttachment, XmATTACH_WIDGET,
506 XmNtopWidget, _username_tf,
507 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
508 XmNleftWidget, _username_tf,
509 XmNrightAttachment, XmATTACH_NONE,
513 xms = XmStringCreateLocalized(GETMSG(DT_catd, 27, 11, "Password:"));
514 _password_label = XtVaCreateManagedWidget(
516 xmLabelWidgetClass, _serverframe_form,
518 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
519 XmNtopWidget, _password_tf,
520 XmNleftAttachment, XmATTACH_NONE,
521 XmNrightAttachment, XmATTACH_WIDGET,
522 XmNrightWidget, _password_tf,
528 // Create a PropUiItem for the Password Option
530 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_PASSWORD);
531 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_PASSWORD);
533 EncryptedTextFieldUiItem(_password_tf, _FROM_MAILRC, propkey);
534 _propui_array->append((PropUiItem*) _password_pui);
537 // Create GUI for the Remember Password Option
539 xms = XmStringCreateLocalized(
540 GETMSG(DT_catd, 27, 12, "Remember password"));
541 _rememberpassword_tb = XtVaCreateManagedWidget(
542 "RememberPasswordTB",
543 xmToggleButtonWidgetClass, _serverframe_form,
544 XmNtopAttachment, XmATTACH_WIDGET,
545 XmNtopWidget, _password_tf,
546 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
547 XmNleftWidget, _password_tf,
548 XmNrightAttachment, XmATTACH_NONE,
549 XmNalignment, XmALIGNMENT_END,
556 _rememberpassword_tb,
557 XmNvalueChangedCallback,
558 MailRetrievalOptions::rememberPasswordChangedCB,
562 // Create PropUiItem for the RememberPassword Option
564 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_REMEMBERPASSWORD);
565 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_REMEMBERPASSWORD);
566 pui = (PropUiItem *) new
567 CheckBoxUiItem(_rememberpassword_tb, _FROM_MAILRC, propkey);
568 _propui_array->append(pui);
571 // Create GUI for the Delete From Server Option
573 xms = XmStringCreateLocalized(
574 GETMSG(DT_catd, 27, 13,
575 "Delete from server after retrieval"));
576 _removeafterdelivery_tb = XtVaCreateManagedWidget(
577 "RemoveAfterDeliveryTB",
578 xmToggleButtonWidgetClass, _serverframe_form,
579 XmNtopAttachment, XmATTACH_WIDGET,
580 XmNtopWidget, _rememberpassword_tb,
581 XmNleftAttachment, XmATTACH_POSITION,
583 XmNrightAttachment, XmATTACH_NONE,
584 XmNalignment, XmALIGNMENT_BEGINNING,
591 // Create PropUiItem for the RemoveAfterDelivery Option
593 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_REMOVEAFTERDELIVERY);
594 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_REMOVEAFTERDELIVERY);
595 pui = (PropUiItem *) new
596 CheckBoxUiItem(_removeafterdelivery_tb, _FROM_MAILRC, propkey);
597 _propui_array->append(pui);
600 // Create GUI for the RetrieveOld Option
602 xms = XmStringCreateLocalized(
603 GETMSG(DT_catd, 27, 14,
604 "Retrieve old messages"));
605 _retrieveold_tb = XtVaCreateManagedWidget(
607 xmToggleButtonWidgetClass, _serverframe_form,
608 XmNtopAttachment, XmATTACH_WIDGET,
609 XmNtopWidget, _removeafterdelivery_tb,
610 XmNleftAttachment, XmATTACH_POSITION,
612 XmNrightAttachment, XmATTACH_NONE,
613 XmNalignment, XmALIGNMENT_BEGINNING,
620 // Create PropUiItem for the RetrieveOld Option
622 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_RETRIEVEOLD);
623 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_RETRIEVEOLD);
624 pui = (PropUiItem *) new
625 CheckBoxUiItem(_retrieveold_tb, _FROM_MAILRC, propkey);
626 _propui_array->append(pui);
629 // Create FRAME to hold the user command printing options
631 _custom_frame = XtVaCreateManagedWidget(
632 "CustomFrame", xmFrameWidgetClass, _form,
633 XmNchildHorizontalAlignment,
634 XmALIGNMENT_BEGINNING,
635 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
636 XmNtopAttachment, XmATTACH_WIDGET,
637 XmNtopWidget, _server_frame,
638 XmNleftAttachment, XmATTACH_FORM,
640 XmNrightAttachment, XmATTACH_FORM,
642 XmNbottomAttachment, XmATTACH_FORM,
646 xms = XmStringCreateLocalized(
647 GETMSG(DT_catd, 27, 15, "Custom retrieval"));
648 _custom_tb = XtVaCreateManagedWidget(
650 xmToggleButtonGadgetClass, _custom_frame,
651 XmNchildType, XmFRAME_TITLE_CHILD,
652 XmNchildHorizontalAlignment,
653 XmALIGNMENT_BEGINNING,
654 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
662 XmNvalueChangedCallback,
663 MailRetrievalOptions::retrievalTBSValueChangedCB,
667 // Create PropUiItem for the Custom Command Option
669 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILVIACOMMAND);
670 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILVIACOMMAND);
671 pui = (PropUiItem *) new CheckBoxUiItem(_custom_tb, _FROM_MAILRC, propkey);
672 _propui_array->append(pui);
674 _customframe_form = XtVaCreateManagedWidget(
676 xmFormWidgetClass, _custom_frame,
677 //XmNallowOverlap, False,
679 XmNresizePolicy, XmRESIZE_ANY,
683 // Create GUI for the User Command Option
685 _customcommand_tf = XtVaCreateManagedWidget(
687 xmTextFieldWidgetClass, _customframe_form,
688 XmNtopAttachment, XmATTACH_FORM,
689 XmNleftAttachment, XmATTACH_POSITION,
691 XmNrightAttachment, XmATTACH_NONE,
695 xms = XmStringCreateLocalized(
696 GETMSG(DT_catd, 27, 16, "User Getmail command:"));
697 _customcommand_label = XtVaCreateManagedWidget(
698 "CustomCommandLabel",
699 xmLabelWidgetClass, _customframe_form,
701 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
703 XmNtopWidget, _customcommand_tf,
704 XmNleftAttachment, XmATTACH_NONE,
705 XmNrightAttachment, XmATTACH_WIDGET,
707 XmNrightWidget, _customcommand_tf,
712 // Create PropUiItem for the ServerName Option
714 MrGENPROPKEY(propkey, _foldername, DTMAS_PROPKEY_GETMAILCOMMAND);
715 PropSource::setDefaultValue(propkey, DTMAS_PROPDFLT_GETMAILCOMMAND);
716 pui = (PropUiItem *) new
717 TextFieldUiItem(_customcommand_tf, _FROM_MAILRC, propkey);
718 _propui_array->append(pui);
721 // Save widgets for manipulation.
723 _retrieval_tbs->append(_system_tb);
724 _retrieval_tbs->append(_server_tb);
725 _retrieval_tbs->append(_custom_tb);
727 _server_options->append(_serverprotocol_label);
728 _server_options->append(_serverprotocol_iom->baseWidget());
729 _server_options->append(_servername_label);
730 _server_options->append(_servername_tf);
731 _server_options->append(_username_label);
732 _server_options->append(_username_tf);
733 _server_options->append(_password_label);
734 _server_options->append(_password_tf);
735 _server_options->append(_rememberpassword_tb);
736 _server_options->append(_removeafterdelivery_tb);
737 _server_options->append(_retrieveold_tb);
739 _custom_options->append(_customcommand_label);
740 _custom_options->append(_customcommand_tf);
745 MailRetrievalOptions::~MailRetrievalOptions (void)
749 IndexedOptionMenu *iom;
753 for (i=0; i<_propui_array->length(); i++)
755 pui = (*_propui_array)[i];
758 delete _propui_array;
761 if (_retrieval_tbs) delete _retrieval_tbs;
762 if (_server_options) delete _server_options;
763 if (_custom_options) delete _custom_options;
764 if (_serverprotocol_iom) delete _serverprotocol_iom;
765 if (_foldername) free(_foldername);
767 if (_w) XtDestroyWidget(_w);
771 MailRetrievalOptions::isValidInboxPath(PropUiItem* pui, void* data)
773 MailSession *ses = theRoamApp.session();
774 DtMail::Session *d_session = ses->session();
776 const char *errmsg = NULL;
777 char *inbox_path = NULL;
779 char *expanded_path = NULL;
783 text = pui->getWidget();
784 if (text) inbox_path = XmTextFieldGetString(text);
785 if (NULL == inbox_path || 0 == strlen(inbox_path))
786 return GETMSG(DT_catd, 27, 17, "Null INBOX path.");
788 tmp = (char*) malloc(strlen(inbox_path)+1);
789 for (s=inbox_path, t=tmp; *s; s++)
801 if (NULL == inbox_path || 0 == strlen(inbox_path))
802 return GETMSG(DT_catd, 27, 17, "Null INBOX path.");
804 if (isalpha(inbox_path[0]))
806 tmp = (char*) malloc(strlen(inbox_path) + 3);
807 sprintf(tmp, "./%s", inbox_path);
812 expanded_path = d_session->expandPath(error, inbox_path);
813 if (expanded_path) XmTextFieldSetString(text, expanded_path);
815 SafePathIsAccessible(error, expanded_path);
818 errmsg = (const char*) error;
819 errmsg = strdup(errmsg);
824 if (inbox_path) free(inbox_path);
825 if (expanded_path) free(expanded_path);
826 return (char*) errmsg;
830 MailRetrievalOptions::initOptionInteractions(void)
833 unsigned char isset, isset_server;
836 XtVaGetValues(_server_tb, XmNset, &isset, NULL);
837 if (XmUNSET == isset)
839 for (i=0; i<_server_options->length(); i++)
841 opt = (*_server_options)[i];
842 XtVaSetValues(opt, XmNsensitive, False, NULL);
847 for (i=0; i<_server_options->length(); i++)
849 opt = (*_server_options)[i];
850 XtVaSetValues(opt, XmNsensitive, True, NULL);
853 isset_server = isset;
855 XtVaGetValues(_custom_tb, XmNset, &isset, NULL);
856 if (XmUNSET == isset)
858 for (i=0; i<_custom_options->length(); i++)
860 opt = (*_custom_options)[i];
861 XtVaSetValues(opt, XmNsensitive, False, NULL);
866 for (i=0; i<_custom_options->length(); i++)
868 opt = (*_custom_options)[i];
869 XtVaSetValues(opt, XmNsensitive, True, NULL);
873 XtVaGetValues(_rememberpassword_tb, XmNset, &isset, NULL);
876 _password_pui->writeAllowed(DTM_TRUE);
878 XtVaSetValues(_password_label, XmNsensitive, True, NULL);
882 _password_pui->writeAllowed(DTM_FALSE);
883 XtVaSetValues(_password_label, XmNsensitive, False, NULL);
888 MailRetrievalOptions::getFirstProp(void)
890 _propui_array_iterator = 0;
891 return getNextProp();
895 MailRetrievalOptions::getNextProp(void)
897 PropUiItem *pui = (PropUiItem *) NULL;
899 if (_propui_array_iterator < _propui_array->length())
901 pui = (*_propui_array)[_propui_array_iterator];
902 _propui_array_iterator++;
908 MailRetrievalOptions::getNumProps(void)
910 return _propui_array->length();
914 MailRetrievalOptions::rememberPasswordChangedCB(
916 XtPointer client_data,
920 *mro = (MailRetrievalOptions*) client_data;
921 XmToggleButtonCallbackStruct
922 *cbs = (XmToggleButtonCallbackStruct*) call_data;
925 if (XmSET == cbs->set)
927 XtVaSetValues(mro->_password_label, XmNsensitive, True, NULL);
928 mro->_password_pui->writeAllowed(DTM_TRUE);
932 XtVaSetValues(mro->_password_label, XmNsensitive, False, NULL);
933 mro->_password_pui->writeAllowed(DTM_FALSE);
936 mro->initOptionInteractions();
941 MailRetrievalOptions::retrievalTBSValueChangedCB(
943 XtPointer client_data,
947 *mro = (MailRetrievalOptions*) client_data;
948 XmToggleButtonCallbackStruct
949 *cbs = (XmToggleButtonCallbackStruct*) call_data;
954 if (XmUNSET == cbs->set)
956 XtVaSetValues(w, XmNset, XmSET, NULL);
960 for (i=0; i<mro->_retrieval_tbs->length(); i++)
962 tb = (*mro->_retrieval_tbs)[i];
963 if (tb != w) XtVaSetValues(tb, XmNset, XmUNSET, NULL);
967 if (w == mro->_system_tb)
969 for (i=0; i<mro->_server_options->length(); i++)
971 opt = (*mro->_server_options)[i];
972 XtVaSetValues(opt, XmNsensitive, False, NULL);
974 for (i=0; i<mro->_custom_options->length(); i++)
976 opt = (*mro->_custom_options)[i];
977 XtVaSetValues(opt, XmNsensitive, False, NULL);
980 else if (w == mro->_server_tb)
982 for (i=0; i<mro->_server_options->length(); i++)
984 opt = (*mro->_server_options)[i];
985 XtVaSetValues(opt, XmNsensitive, True, NULL);
987 for (i=0; i<mro->_custom_options->length(); i++)
989 opt = (*mro->_custom_options)[i];
990 XtVaSetValues(opt, XmNsensitive, False, NULL);
993 else if (w == mro->_custom_tb)
995 for (i=0; i<mro->_server_options->length(); i++)
997 opt = (*mro->_server_options)[i];
998 XtVaSetValues(opt, XmNsensitive, False, NULL);
1000 for (i=0; i<mro->_custom_options->length(); i++)
1002 opt = (*mro->_custom_options)[i];
1003 XtVaSetValues(opt, XmNsensitive, True, NULL);
1007 mro->initOptionInteractions();
1012 MailRetrievalOptions::getPassword(char *foldername)
1014 DtMail::Session *d_session = NULL;
1015 DtMail::MailRc *m_rc = NULL;
1017 const char *string = NULL;
1018 char propkey[MAXPATHLEN];
1020 d_session = theRoamApp.session()->session();
1021 m_rc = d_session->mailRc(error);
1023 MrGENPROPKEY(propkey, foldername, DTMAS_PROPKEY_PASSWORD);
1025 m_rc->getValue(error, propkey , &string, DTM_TRUE);
1026 if (string == NULL || error.isSet()) return NULL;
1028 return (char*) string;