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 libraries 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: MailRcSource.C /main/13 1999/03/25 13:41:38 mgreess $ */
27 * RESTRICTED CONFIDENTIAL INFORMATION:
29 * The information in this document is subject to special
30 * restrictions in a confidential disclosure agreement bertween
31 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
32 * document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
33 * Sun's specific written approval. This documment and all copies
34 * and derivative works thereof must be returned or destroyed at
37 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
42 #include <EUSCompat.h>
43 #include <DtMail/PropSource.hh>
44 #include <DtMail/DtMailTypes.h>
45 #include <DtMail/DtVirtArray.hh>
46 #include "str_utils.h"
48 #include "DmxPrintOptions.h"
50 static PropDefaults static_defaults[] ={
51 { "retrieveinterval", "300" },
54 { "headerlines", "15" },
56 { "showmsgnum", "f" },
57 { "popuplines", "24" },
59 { "indentprefix", ">" },
60 { "hideattachments", "f" },
62 { "filefolder", "~" },
63 { "dontunifyselection", "f" },
64 { "dontunifyfileselection", "f" },
65 { "confirmattachments", "f" },
66 { "confirmattachmentthreshold", "64" },
67 { "cachedfilemenusize", "10" },
68 { "dontdisplaycachedfiles", "f" },
70 { "dontlogmessages", "f" },
71 { "keepdeleted", "f" },
72 { "quietdelete", "f" },
74 { "strictmime", "f" },
75 { "cdetooltalklock", "f" },
78 { "usealternates", "f" },
79 { "deaddir", "~/dead_letter" },
80 { "saveinterval", "30" },
81 { DMX_PROPKEY_HEADER_LEFT, DMX_PROPVAL_SUBJECT_HEADER },
82 { DMX_PROPKEY_HEADER_RIGHT, DMX_PROPVAL_EMPTY },
83 { DMX_PROPKEY_FOOTER_LEFT, DMX_PROPVAL_USER_NAME },
84 { DMX_PROPKEY_FOOTER_RIGHT, DMX_PROPVAL_PAGE_NUMBER },
85 { DMX_PROPKEY_MARGIN_TOP, DMX_PROPVAL_DFLT_MARGIN },
86 { DMX_PROPKEY_MARGIN_RIGHT, DMX_PROPVAL_DFLT_MARGIN },
87 { DMX_PROPKEY_MARGIN_BOTTOM, DMX_PROPVAL_DFLT_MARGIN },
88 { DMX_PROPKEY_MARGIN_LEFT, DMX_PROPVAL_DFLT_MARGIN },
89 { DMX_PROPKEY_PRINT_HEADERS, DMX_PROPVAL_STANDARD },
90 { DMX_PROPKEY_MESSAGE_SEPARATOR,DMX_PROPVAL_PAGE_BREAK },
91 { DMX_PROPKEY_SEPARATOR_STRING, "-" },
95 DtVirtArray<PropDefaults*> *PropSource::_dynamic_defaults =
96 new DtVirtArray<PropDefaults*> (20);
98 PropSource::PropSource(DtMail::MailRc *m_rc, char *key)
104 PropSource::~PropSource() {;}
107 PropSource::setDefaultValue(char *key, char *value)
111 for (int i=0; i<_dynamic_defaults->length(); i++)
113 df = (PropDefaults*) (*_dynamic_defaults)[i];
114 if (0 == strcmp(key, df->key))
116 if (NULL != df->value) free((void*) df->value);
117 df->value = strdup(value);
122 df = (PropDefaults*) malloc(sizeof(PropDefaults));
123 df->key = strdup(key);
124 df->value = strdup(value);
125 _dynamic_defaults->append(df);
129 PropSource::getDefaultValue(void)
133 for (int i=0; i<_dynamic_defaults->length(); i++)
135 df = (PropDefaults*) (*_dynamic_defaults)[i];
136 if (0 == strcmp(_key, df->key)) return strdup(df->value);
139 for (df=static_defaults; df->key; df++)
140 if (strcasecmp(_key, df->key) == 0) return strdup(df->value);
142 return strdup(PropSourceDEFAULTVALUE);
145 // MailRcSource::getValue
146 // gets the value from the mailrc hash table and returns it
147 /////////////////////////////////////////////////////////////////
148 const char *MailRcSource::getValue(DtMailBoolean decrypt)
150 const char *value = NULL;
153 _mail_rc->getValue(error, _key , &value, decrypt);
155 if (value == NULL || error.isSet())
157 value = getDefaultValue();
164 // MailRcSource::setValue
165 // Sets the passed value into the mailrc hash tables
166 /////////////////////////////////////////////////////////////////
167 void MailRcSource::setValue(char *value, DtMailBoolean encrypt)
171 const char * d_value = getDefaultValue();
173 if (strcmp(d_value, value))
174 _mail_rc->setValue(error, _key , value, encrypt);
176 _mail_rc->removeValue(error, _key);