Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
405
cde/programs/dtmail/dtmail/AliasListUiItem.C
Normal file
405
cde/programs/dtmail/dtmail/AliasListUiItem.C
Normal file
@@ -0,0 +1,405 @@
|
||||
/* $TOG: AliasListUiItem.C /main/6 1997/09/03 17:33:31 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: AliasListUiItem.C /main/6 1997/09/03 17:33:31 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/List.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include "options_ui.h"
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
#include <DtMail/AliasListUiItem.hh>
|
||||
|
||||
extern Boolean props_changed;
|
||||
void alias_stuffing_func(char * key, void * data, void * client_data);
|
||||
void handleAliasSelection(Widget w, XtPointer clientdata, XtPointer calldata);
|
||||
|
||||
// AliasListUiItem::AliasListUiItem
|
||||
// AliasListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
AliasListUiItem::AliasListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
Widget key_entry_widget,
|
||||
Widget value_entry_widget):ListUiItem(w, source, search_key, NULL)
|
||||
{
|
||||
source = source; search_key = search_key;
|
||||
|
||||
key_widget = key_entry_widget;
|
||||
value_widget = value_entry_widget;
|
||||
|
||||
list_items = NULL;
|
||||
deleted_items = NULL;
|
||||
|
||||
XtVaSetValues(w,
|
||||
XmNuserData, this,
|
||||
XmNautomaticSelection, True,
|
||||
XmNselectionPolicy, XmBROWSE_SELECT,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(w,
|
||||
XmNbrowseSelectionCallback,
|
||||
(XtCallbackProc)handleAliasSelection,
|
||||
(XtPointer)this);
|
||||
|
||||
}
|
||||
|
||||
//-----------------======================-----------------
|
||||
void handleAliasSelection(Widget w, XtPointer, XtPointer calldata)
|
||||
{
|
||||
AliasListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{ // motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getKeyWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(item->getValueWidget(),
|
||||
XmNvalue,pair->value,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AliasListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AliasListUiItem::writeFromUiToSource()
|
||||
{
|
||||
Widget w = this->getWidget();
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
int i, num_items;
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
num_items = deleted_items->length();
|
||||
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->removeAlias(error,(*deleted_items)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
num_items = list_items->length();
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
|
||||
mail_rc->setAlias(error,(*list_items)[i]->label,
|
||||
(*list_items)[i]->value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// AliasListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
static int cmp_prop_string_pair(const void *v1, const void *v2)
|
||||
{
|
||||
PropStringPair *p1 = *((PropStringPair **) v1);
|
||||
PropStringPair *p2 = *((PropStringPair **) v2);
|
||||
int ret;
|
||||
|
||||
ret = strcmp((const char *) p1->label, (const char *) p2->label);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AliasListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
Widget w = this->getWidget();
|
||||
const char *list_str = NULL;
|
||||
DtVirtArray<char *> list_str_list(10);
|
||||
char *buf = NULL;
|
||||
int list_len, i;
|
||||
const char *value = NULL;
|
||||
PropStringPair **prop_pairs = NULL;
|
||||
|
||||
XmListDeleteAllItems(w);
|
||||
|
||||
if (deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
|
||||
if (list_items != NULL)
|
||||
delete list_items;
|
||||
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
mail_rc->getAliasList(alias_stuffing_func, list_items);
|
||||
|
||||
list_len = list_items->length();
|
||||
if (list_len)
|
||||
{
|
||||
prop_pairs =
|
||||
(PropStringPair**) XtMalloc(list_len * sizeof(PropStringPair*));
|
||||
|
||||
for (i = 0; i < list_len; i++)
|
||||
{
|
||||
prop_pairs[i] = (*list_items)[0];
|
||||
list_items->remove(0);
|
||||
}
|
||||
|
||||
qsort(
|
||||
prop_pairs,
|
||||
list_len,
|
||||
sizeof(PropStringPair*),
|
||||
cmp_prop_string_pair);
|
||||
|
||||
for (i = 0; i < list_len; i++)
|
||||
list_items->append(prop_pairs[i]);
|
||||
|
||||
if (NULL != prop_pairs)
|
||||
XtFree((char*) prop_pairs);
|
||||
}
|
||||
|
||||
for (i = 0; i < list_len; i++)
|
||||
list_str_list.append(
|
||||
formatPropPair( (*list_items)[i]->label, (*list_items)[i]->value ));
|
||||
|
||||
options_list_init(w, &list_str_list);
|
||||
}
|
||||
//
|
||||
// callback for creating alias list...
|
||||
void alias_stuffing_func(char * key, void * data, void * client_data)
|
||||
{
|
||||
DtVirtArray<PropStringPair *> *alias_list = (DtVirtArray<PropStringPair *> *)client_data;
|
||||
PropStringPair *new_pair;
|
||||
|
||||
new_pair = new PropStringPair;
|
||||
|
||||
new_pair->label = strdup(key);
|
||||
new_pair->value = strdup((char *)data);
|
||||
|
||||
alias_list->append(new_pair);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
void AliasListUiItem::handleAddButtonPress()
|
||||
{
|
||||
char *key_str = NULL;
|
||||
char *value_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
|
||||
XtVaGetValues(key_widget,
|
||||
XmNvalue, &key_str,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(value_widget,
|
||||
XmNvalue, &value_str,
|
||||
NULL);
|
||||
|
||||
if(key_str != NULL)
|
||||
if(strlen(key_str) > 0)
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
new_pair->label = strdup(key_str);
|
||||
|
||||
if(value_str != NULL)
|
||||
new_pair->value = strdup(value_str);
|
||||
else
|
||||
new_pair->value = NULL;
|
||||
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(
|
||||
formatPropPair(
|
||||
new_pair->label,
|
||||
new_pair->value)),
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
pos_list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,0);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(
|
||||
formatPropPair(
|
||||
new_pair->label,
|
||||
new_pair->value)),
|
||||
1);
|
||||
XmListSelectPos(this->getWidget(),
|
||||
1,
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
1);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void AliasListUiItem::handleChangeButtonPress()
|
||||
{
|
||||
char *key_str = NULL;
|
||||
char *value_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
XmString replace_string;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
// if nothing selected nothing to change...
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
XtVaGetValues(key_widget,
|
||||
XmNvalue, &key_str,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(value_widget,
|
||||
XmNvalue, &value_str,
|
||||
NULL);
|
||||
|
||||
if(key_str != NULL)
|
||||
if(strlen(key_str) > 0)
|
||||
{
|
||||
|
||||
new_pair = (*list_items)[pos_list[0] - 1];
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[pos_list[0] -1]->label));
|
||||
|
||||
free(new_pair->label);
|
||||
new_pair->label = strdup(key_str);
|
||||
|
||||
if(new_pair->value != NULL)
|
||||
{
|
||||
free(new_pair->value);
|
||||
if(value_str != NULL)
|
||||
new_pair->value = strdup(value_str);
|
||||
else
|
||||
new_pair->value = NULL;
|
||||
}
|
||||
|
||||
replace_string = XmStringCreateLocalized(
|
||||
formatPropPair(new_pair->label,
|
||||
new_pair->value));
|
||||
|
||||
XmListReplaceItemsPos(this->getWidget(),
|
||||
&replace_string,
|
||||
1,
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void AliasListUiItem::handleDeleteButtonPress()
|
||||
{
|
||||
Widget list_widget = this->getWidget();
|
||||
int *p_list, p_count;
|
||||
|
||||
// get the selected position
|
||||
if(XmListGetSelectedPos(list_widget,
|
||||
&p_list,
|
||||
&p_count))
|
||||
{
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[p_list[0] -1]->label));
|
||||
|
||||
// delete the item from our list
|
||||
this->list_items->remove(p_list[0] - 1); // remove only first
|
||||
|
||||
// delete the item from the widget
|
||||
XmListDeletePos(list_widget, p_list[0]);
|
||||
|
||||
XtVaSetValues(this->getKeyWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(this->getValueWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
|
||||
XmListSelectPos(list_widget,
|
||||
p_list[0],
|
||||
TRUE);
|
||||
|
||||
props_changed = TRUE;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
346
cde/programs/dtmail/dtmail/AlternatesListUiItem.C
Normal file
346
cde/programs/dtmail/dtmail/AlternatesListUiItem.C
Normal file
@@ -0,0 +1,346 @@
|
||||
/* $XConsortium: AlternatesListUiItem.C /main/3 1995/11/06 16:03:45 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/List.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include "options_ui.h"
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
#include <DtMail/AlternatesListUiItem.hh>
|
||||
|
||||
extern Boolean props_changed;
|
||||
void handleAlternateSelection(Widget w, XtPointer clientdata, XtPointer calldata);
|
||||
|
||||
// AlternatesListUiItem::AlternatesListUiItem
|
||||
// AlternatesListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
AlternatesListUiItem::AlternatesListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
Widget text_entry_widget):ListUiItem(w, source, search_key, NULL)
|
||||
{
|
||||
source = source; search_key = search_key;
|
||||
|
||||
entry_field_widget = text_entry_widget;
|
||||
|
||||
list_items = NULL;
|
||||
deleted_items = NULL;
|
||||
|
||||
XtVaSetValues(w,
|
||||
XmNuserData, this,
|
||||
XmNautomaticSelection, True,
|
||||
XmNselectionPolicy, XmBROWSE_SELECT,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(w,
|
||||
XmNbrowseSelectionCallback,
|
||||
(XtCallbackProc)handleAlternateSelection,
|
||||
(XtPointer)this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
void handleAlternateSelection(Widget w, XtPointer clientdata, XtPointer calldata)
|
||||
{
|
||||
AlternatesListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
clientdata = clientdata;
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
// motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getEntryFieldWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// AlternatesListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::writeFromUiToSource()
|
||||
{
|
||||
Widget w = this->getWidget();
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
int i, num_items;
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
num_items = deleted_items->length();
|
||||
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->removeAlternate(error,(*deleted_items)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
num_items = list_items->length();
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->setAlternate(error,(*list_items)[i]->label);
|
||||
}
|
||||
}
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// AlternatesListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
Widget w = this->getWidget();
|
||||
const char *list_str = NULL;
|
||||
DtVirtArray<char *> *char_list = NULL;
|
||||
PropStringPair *new_pair;
|
||||
char *token, *buf = NULL;
|
||||
|
||||
XmListDeleteAllItems(w);
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
delete list_items;
|
||||
list_items = NULL;
|
||||
}
|
||||
|
||||
if ((list_str = mail_rc->getAlternates(error)) == NULL) {
|
||||
list_str = strdup("");
|
||||
}
|
||||
|
||||
if ((buf = (char *) malloc(strlen(list_str) + 1)) == NULL)
|
||||
return;
|
||||
strcpy(buf, (char *)list_str);
|
||||
|
||||
if((token = (char *) strtok(buf, " ")))
|
||||
{
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
char_list = new DtVirtArray<char *>(10);
|
||||
|
||||
new_pair = new PropStringPair;
|
||||
new_pair->label = strdup(token);
|
||||
new_pair->value = NULL;
|
||||
list_items->append(new_pair);
|
||||
|
||||
char_list->append(strdup(token));
|
||||
|
||||
while(token = (char *)strtok(NULL, " "))
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
new_pair->label = strdup(token);
|
||||
new_pair->value = NULL;
|
||||
list_items->append(new_pair);
|
||||
|
||||
char_list->append(strdup(token));
|
||||
}
|
||||
}
|
||||
|
||||
options_list_init(w, char_list);
|
||||
|
||||
delete char_list;
|
||||
|
||||
if(list_str != NULL)
|
||||
free((void *)list_str);
|
||||
|
||||
if(buf != NULL)
|
||||
free((void *)buf);
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::handleAddButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if(strlen(test_str) > 1)
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
new_pair->label = strdup(test_str);
|
||||
new_pair->value = NULL;
|
||||
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
pos_list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,0);
|
||||
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
1);
|
||||
XmListSelectPos(this->getWidget(),
|
||||
1,
|
||||
TRUE);
|
||||
XmListSetPos(this->getWidget(),
|
||||
1);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::handleChangeButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
XmString replace_string;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
// if nothing selected nothing to change...
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if(strlen(test_str) > 1)
|
||||
{
|
||||
|
||||
new_pair = (*list_items)[pos_list[0] - 1];
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[pos_list[0] -1]->label));
|
||||
|
||||
free(new_pair->label);
|
||||
new_pair->label = strdup(test_str);
|
||||
|
||||
replace_string = XmStringCreateLocalized(new_pair->label);
|
||||
|
||||
XmListReplaceItemsPos(this->getWidget(),
|
||||
&replace_string,
|
||||
1,
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::handleDeleteButtonPress()
|
||||
{
|
||||
Widget list_widget = this->getWidget();
|
||||
int *p_list, p_count;
|
||||
|
||||
// get the selected position
|
||||
if(XmListGetSelectedPos(list_widget,
|
||||
&p_list,
|
||||
&p_count))
|
||||
{
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[p_list[0] -1]->label));
|
||||
|
||||
// delete the item from our list
|
||||
this->list_items->remove(p_list[0] - 1); // remove only first
|
||||
|
||||
// delete the item from the widget
|
||||
XmListDeletePos(list_widget, p_list[0]);
|
||||
|
||||
XtVaSetValues(this->getEntryFieldWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
XmListSelectPos(list_widget,
|
||||
p_list[0],
|
||||
TRUE);
|
||||
|
||||
props_changed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
85
cde/programs/dtmail/dtmail/AntiCheckBoxUiItem.C
Normal file
85
cde/programs/dtmail/dtmail/AntiCheckBoxUiItem.C
Normal file
@@ -0,0 +1,85 @@
|
||||
/* $TOG: AntiCheckBoxUiItem.C /main/4 1997/04/29 15:57:39 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/AntiCheckBoxUiItem.hh>
|
||||
|
||||
// AntiCheckBoxUiItem::AntiCheckBoxUiItem
|
||||
// AntiCheckBoxUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
AntiCheckBoxUiItem::AntiCheckBoxUiItem(
|
||||
Widget w,
|
||||
int source,
|
||||
char *search_key
|
||||
):CheckBoxUiItem(w, source, search_key)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
// AntiCheckBoxUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AntiCheckBoxUiItem::writeFromUiToSource()
|
||||
{
|
||||
Boolean checkbox_value;
|
||||
Widget w = this->getWidget();
|
||||
PropSource *p_s = this->getPropSource();
|
||||
|
||||
checkbox_value = options_checkbox_get_value(w);
|
||||
|
||||
if(checkbox_value == TRUE) // make sure the value is in the table
|
||||
{
|
||||
p_s->setValue("f");
|
||||
}
|
||||
else
|
||||
{
|
||||
p_s->setValue("");
|
||||
}
|
||||
}
|
||||
|
||||
// AntiCheckBoxUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AntiCheckBoxUiItem::writeFromSourceToUi()
|
||||
{
|
||||
char *value = NULL;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
PropSource *p_s = this->getPropSource();
|
||||
|
||||
value = (char *)p_s->getValue();
|
||||
|
||||
//
|
||||
// this will have to be made more robust...
|
||||
//
|
||||
// This assumes that a non-null value means that the
|
||||
// value is set and that a non-null means turn on the CB
|
||||
if (strcmp(value, "f") == 0)
|
||||
options_checkbox_set_value(w, TRUE, this->dirty_bit);
|
||||
else if (value == NULL || strcmp(value, "") == 0)
|
||||
options_checkbox_set_value(w, FALSE, this->dirty_bit);
|
||||
|
||||
if (NULL != NULL)
|
||||
free((void*) value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
1717
cde/programs/dtmail/dtmail/AttachArea.C
Normal file
1717
cde/programs/dtmail/dtmail/AttachArea.C
Normal file
File diff suppressed because it is too large
Load Diff
307
cde/programs/dtmail/dtmail/AttachArea.h
Normal file
307
cde/programs/dtmail/dtmail/AttachArea.h
Normal file
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: AttachArea.h /main/3 1995/11/06 16:04:04 rswiston $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef ATTACHAREA_H
|
||||
#define ATTACHAREA_H
|
||||
|
||||
#ifndef I_HAVE_NO_IDENT
|
||||
#endif
|
||||
|
||||
#define TYPETEXT 0 /* unformatted text */
|
||||
#define TYPEMULTIPART 1 /* multiple part */
|
||||
#define TYPEMESSAGE 2 /* encapsulated message */
|
||||
#define TYPEAPPLICATION 3 /* application data */
|
||||
#define TYPEAUDIO 4 /* audio */
|
||||
#define TYPEIMAGE 5 /* static image */
|
||||
#define TYPEVIDEO 6 /* video */
|
||||
#define TYPEOTHER 7 /* unknown */
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include "UIComponent.h"
|
||||
#include "UndoCmd.h"
|
||||
#include "CmdList.h"
|
||||
#include "MenuBar.h"
|
||||
#include "DtMailHelp.hh"
|
||||
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include <DtMail/DtMail.hh>
|
||||
|
||||
typedef enum { NOTSET, ADD, SAVEAS } FSState;
|
||||
|
||||
class Attachment;
|
||||
class DtMailEditor;
|
||||
|
||||
class RoamMenuWindow;
|
||||
class SendMsgDialog;
|
||||
class ViewMsgDialog;
|
||||
|
||||
class AttachArea : public UIComponent {
|
||||
|
||||
private:
|
||||
|
||||
enum AAreaSState {AA_SEL_NONE=0, AA_SEL_SINGLE=1, AA_SEL_ALL=2};
|
||||
static void inputCallback( Widget, XtPointer, XtPointer );
|
||||
static void MenuButtonHandler(Widget, XtPointer, XEvent *, Boolean *);
|
||||
static void resizeCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
void popupAttachmentMenu(XEvent *event);
|
||||
|
||||
void resize(Dimension); // Called when the user click a button
|
||||
unsigned int _iconCount;
|
||||
unsigned int _iconSelectedCount;
|
||||
unsigned int _deleteCount;
|
||||
Attachment **_attachmentList;// The list of attachments
|
||||
|
||||
FSState _fsState; // State of the File Selection Box
|
||||
Widget _fsDialog;
|
||||
Widget _renameDialog;
|
||||
Widget _descriptionDialog;
|
||||
Widget _no_attachments_label;
|
||||
Widget _attachments_label;
|
||||
Widget _size_attachments_label;
|
||||
Widget _no_selected_label;
|
||||
Widget _selected_label;
|
||||
DtMailEditor *_myOwner; // The class that owns it
|
||||
Widget _parent; // The parent widget
|
||||
Widget rowOfAttachmentsStatus;
|
||||
Widget _attachments_status;
|
||||
Widget _attachments_summary;
|
||||
RoamMenuWindow *_myRMW;
|
||||
ViewMsgDialog *_myVMD;
|
||||
SendMsgDialog *_mySMD;
|
||||
Boolean _pendingAction;
|
||||
int _numPendingActions;
|
||||
|
||||
// Selection State of Attach Area
|
||||
AAreaSState _attach_area_selection_state;
|
||||
Attachment *_cache_single_attachment; // single selected attachment
|
||||
DtMail::MailBox *_mailbox;
|
||||
Dimension _attachAreaWidth; // The width of the AA
|
||||
Dimension _attachAreaHeight; // The height of the AA
|
||||
void valueChanged( XtPointer );
|
||||
static void valueChangedCallback( Widget, XtPointer, XtPointer );
|
||||
void dragSlider( XtPointer );
|
||||
static void dragCallback( Widget, XtPointer, XtPointer );
|
||||
unsigned int _lastRow; // The current last row
|
||||
unsigned int _currentRow; // The current row
|
||||
unsigned int _attachmentsSize; // Size of all attachments
|
||||
unsigned int _selectedAttachmentsSize; // Size of all
|
||||
XtPointer _clientData;
|
||||
// selected attachments
|
||||
char * calcKbytes(unsigned int);
|
||||
|
||||
protected:
|
||||
|
||||
Widget _rc; // The RowColumn widget that manages
|
||||
// the attachments
|
||||
Widget _sw; // The ScrolledWindow widget
|
||||
Widget _vsb; // The vertical scrollbar of the ScrolledWindow
|
||||
Widget _message;
|
||||
Widget _clipWindow;
|
||||
Cmd *_open;
|
||||
Cmd *_saveas;
|
||||
Cmd *_selectall;
|
||||
Cmd *_unselectall;
|
||||
MenuBar *_menuBar;
|
||||
Pixel _background;
|
||||
Pixel _foreground;
|
||||
Pixel _appBackground;
|
||||
Pixel _appForeground;
|
||||
CmdList* _fileCmdList;
|
||||
CmdList* _editCmdList;
|
||||
Widget _size_selected_label;
|
||||
Widget _format_button;
|
||||
|
||||
public:
|
||||
AttachArea (Widget, DtMailEditor*, char *);
|
||||
virtual ~AttachArea();
|
||||
|
||||
void initialize();
|
||||
void addToRowOfAttachmentsStatus();
|
||||
void attachment_summary(int, int);
|
||||
// Inline functions
|
||||
Cmd* openCmd() { return ( _open ); }
|
||||
Widget getVerticalSB() { return ( _vsb ); }
|
||||
unsigned int getIconCount() { return ( _iconCount ); }
|
||||
unsigned int getUndeletedIconCount()
|
||||
{ return (_iconCount - _deleteCount); }
|
||||
unsigned int getIconSelectedCount()
|
||||
{ return ( _iconSelectedCount ); }
|
||||
|
||||
unsigned int getDeleteCount(){ return ( _deleteCount ); }
|
||||
void incIconCount() { _iconCount++; }
|
||||
void decIconCount() { _iconCount--; }
|
||||
void incIconSelectedCount()
|
||||
{ _iconSelectedCount++; }
|
||||
void decIconSelectedCount()
|
||||
{ _iconSelectedCount--; }
|
||||
void incDeleteCount(){ _deleteCount++; }
|
||||
void decDeleteCount(){ _deleteCount--; }
|
||||
Attachment** getList() { return ( _attachmentList ); }
|
||||
|
||||
FSState getFsState() { return (_fsState ); }
|
||||
void setFsState( FSState state )
|
||||
{ ( _fsState = state ); }
|
||||
void setFsDialog( Widget w )
|
||||
{ _fsDialog = w; }
|
||||
void setRenameDialog( Widget w )
|
||||
{ _renameDialog = w; }
|
||||
void setDescriptionDialog( Widget w )
|
||||
{ _descriptionDialog = w; }
|
||||
Widget getFsDialog() { return (_fsDialog ); }
|
||||
Widget getRenameDialog() { return (_renameDialog ); }
|
||||
|
||||
Widget getDescriptionDialog()
|
||||
{ return (_descriptionDialog );}
|
||||
virtual const char *const className() { return ( "AttachArea" ); }
|
||||
|
||||
|
||||
void addToList( Attachment * );
|
||||
void addToDeletedList( Attachment *);
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
void undeleteAllDeletedAttachments(DtMailEnv &);
|
||||
#endif /* DEAD_WOOD */
|
||||
void undeleteLastDeletedAttachment(DtMailEnv &);
|
||||
|
||||
void removeLastDeletedAttachment();
|
||||
|
||||
virtual void attachmentFeedback(Boolean);
|
||||
|
||||
virtual void activateDeactivate();
|
||||
Widget getRc() { return (_rc ); }
|
||||
Widget getClipWindow() { return (_clipWindow ); }
|
||||
Widget getSWWindow() { return (_sw ); }
|
||||
Pixel getBackground() { return (_background ); }
|
||||
Pixel getForeground() { return (_foreground ); }
|
||||
Pixel getAppBackground(){ return (_appBackground ); }
|
||||
Pixel getAppForeground(){ return (_appForeground ); }
|
||||
Dimension getAAWidth() { return (_attachAreaWidth); }
|
||||
Dimension getAAHeight() { return (_attachAreaHeight); }
|
||||
DtMailEditor* owner() { return ( _myOwner ); }
|
||||
|
||||
Attachment* addAttachment(
|
||||
DtMail::Message *,
|
||||
DtMail::BodyPart *,
|
||||
char *filename,
|
||||
char *
|
||||
);
|
||||
|
||||
Attachment* addAttachment(DtMail::Message *,
|
||||
DtMail::BodyPart *,
|
||||
String,
|
||||
DtMailBuffer);
|
||||
|
||||
Attachment* addAttachment(String name, DtMail::BodyPart *);
|
||||
|
||||
void addAttachmentActions(
|
||||
char **,
|
||||
int
|
||||
);
|
||||
DtMail::MailBox* get_mailbox() { return ( _mailbox ); }
|
||||
String getRenameMessageString()
|
||||
{ return ("RenameMessageString"); }
|
||||
String getDescriptionMessageString()
|
||||
{ return ("DescriptionMessageString"); }
|
||||
unsigned int getAttachmentsSize()
|
||||
{ return ( _attachmentsSize ); }
|
||||
unsigned int getSelectedAttachmentsSize()
|
||||
{ return ( _selectedAttachmentsSize ); }
|
||||
void setAttachmentsSize( unsigned int size )
|
||||
{ ( _attachmentsSize = size ); }
|
||||
void setSelectedAttachmentsSize( unsigned int size )
|
||||
{ ( _selectedAttachmentsSize = size ); }
|
||||
|
||||
void selectAllAttachments();
|
||||
|
||||
Attachment* getSelectedAttachment();
|
||||
void unselectOtherSelectedAttachments(Attachment *);
|
||||
#ifdef DEAD_WOOD
|
||||
void deleteAttachments();
|
||||
#endif /* DEAD_WOOD */
|
||||
void manageList();
|
||||
void CalcSizeOfAttachPane( );
|
||||
#ifdef DEAD_WOOD
|
||||
void CalcAttachmentPosition(Attachment *);
|
||||
#endif /* DEAD_WOOD */
|
||||
void CalcAllAttachmentPositions();
|
||||
void DisplayAttachmentsInRow(unsigned int);
|
||||
void calculate_attachment_position(
|
||||
Attachment *,
|
||||
Attachment *);
|
||||
void CalcLastRow();
|
||||
unsigned int getLastRow() { return ( _lastRow); }
|
||||
unsigned int getCurrentRow() { return ( _currentRow); }
|
||||
void SetScrollBarSize(unsigned int );
|
||||
void AdjustCurrentRow();
|
||||
void initialize(Widget);
|
||||
void initialize_send(Widget);
|
||||
void initialize_view(Widget);
|
||||
#ifdef DEAD_WOOD
|
||||
void setAttachmentsLabel( );
|
||||
#endif /* DEAD_WOOD */
|
||||
int getSelectedIconCount();
|
||||
#ifdef DEAD_WOOD
|
||||
void CalcAttachmentsSize( );
|
||||
void add_attachment( Attachment * );
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
// Methods for parsing the attachments in a DtMail::Message
|
||||
|
||||
void parseAttachments(
|
||||
DtMailEnv &,
|
||||
DtMail::Message *,
|
||||
Boolean,
|
||||
int);
|
||||
|
||||
// SR -- Added methods below
|
||||
|
||||
void attachmentSelected(Attachment *);
|
||||
void manage();
|
||||
void unmanage();
|
||||
void removeCurrentAttachments();
|
||||
void clearAttachArea();
|
||||
#ifdef DEAD_WOOD
|
||||
void saveAttachmentToFile(DtMailEnv &, char *);
|
||||
#endif /* DEAD_WOOD */
|
||||
void deleteSelectedAttachments(DtMailEnv &);
|
||||
Widget ownerShellWidget();
|
||||
void setOwnerShell(RoamMenuWindow *);
|
||||
void setOwnerShell(ViewMsgDialog *);
|
||||
void setOwnerShell(SendMsgDialog *);
|
||||
Boolean isOwnerShellEditable();
|
||||
|
||||
void setPendingAction(Boolean);
|
||||
void resetPendingAction();
|
||||
int getNumPendingActions();
|
||||
|
||||
XmString getSelectedAttachName();
|
||||
void setSelectedAttachName(XmString );
|
||||
|
||||
int handleQuestionDialog(char *title,
|
||||
char *buf,
|
||||
char *helpId = DTMAILHELPERROR);
|
||||
|
||||
int handleErrorDialog(char *title,
|
||||
char *buf,
|
||||
char *helpId = DTMAILHELPERROR);
|
||||
};
|
||||
#endif
|
||||
|
||||
1042
cde/programs/dtmail/dtmail/AttachCmds.C
Normal file
1042
cde/programs/dtmail/dtmail/AttachCmds.C
Normal file
File diff suppressed because it is too large
Load Diff
290
cde/programs/dtmail/dtmail/AttachCmds.h
Normal file
290
cde/programs/dtmail/dtmail/AttachCmds.h
Normal file
@@ -0,0 +1,290 @@
|
||||
/* $XConsortium: AttachCmds.h /main/3 1995/11/06 16:04:23 rswiston $ */
|
||||
#include <Xm/Xm.h>
|
||||
#include "UIComponent.h"
|
||||
#include "Cmd.h"
|
||||
#include "AttachArea.h"
|
||||
#include "DialogManager.h"
|
||||
|
||||
#ifndef ATTACHADDCMD_H
|
||||
#define ATTACHADDCMD_H
|
||||
|
||||
typedef enum { OK, ERR, CONFIRM } SaveFileState;
|
||||
|
||||
class AttachAddCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
Widget _clipWindow;
|
||||
Widget _parent;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
void ok( Widget, XtPointer );// Called when the OK button is pressed
|
||||
void add_file(char *);
|
||||
AttachArea *_attachArea;
|
||||
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachAddCmd ( AttachArea *, Widget, Widget, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachAddCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef ATTACHFETCHCMD_H
|
||||
#define ATTACHFETCHCMD_H
|
||||
|
||||
class AttachFetchCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
Widget _clipWindow;
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachFetchCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachFetchCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHDELETECMD_H
|
||||
#define ATTACHDELETECMD_H
|
||||
|
||||
class AttachDeleteCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachDeleteCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachDeleteCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHOPENCMD_H
|
||||
#define ATTACHOPENCMD_H
|
||||
|
||||
class AttachOpenCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
Widget _clipWindow;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
void ok( XtPointer ); // Called when the OK button is pressed
|
||||
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachOpenCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachOpenCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHRENAMECMD_H
|
||||
#define ATTACHRENAMECMD_H
|
||||
|
||||
class AttachRenameCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
void ok( XtPointer ); // Called when the OK button is pressed
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachRenameCmd ( AttachArea *, Widget, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachRenameCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef ATTACHDESCRIPTIONCMD_H
|
||||
#define ATTACHDESCRIPTIONCMD_H
|
||||
|
||||
class AttachDescriptionCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
void ok( XtPointer ); // Called when the OK button is pressed
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachDescriptionCmd ( AttachArea *, Widget, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachDescriptionCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHSAVEASCMD_H
|
||||
#define ATTACHSAVEASCMD_H
|
||||
|
||||
class AttachSaveAsCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
Widget _parent;
|
||||
Widget _clipWindow;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
void ok( XtPointer ); // Called when the OK button is pressed
|
||||
AttachArea *_attachArea;
|
||||
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachSaveAsCmd ( AttachArea *, Widget, Widget, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachSaveAsCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHSELECTALLCMD_H
|
||||
#define ATTACHSELECTALLCMD_H
|
||||
|
||||
class AttachSelectAllCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachSelectAllCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachSelectAllCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHUNDELETECMD_H
|
||||
#define ATTACHUNDELETECMD_H
|
||||
|
||||
class AttachUndeleteCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachUndeleteCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachUndeleteCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHUNSELECTALLCMD_H
|
||||
#define ATTACHUNSELECTALLCMD_H
|
||||
|
||||
class AttachUnselectAllCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachUnselectAllCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachUnselectAllCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef ATTACHINFOCMD_H
|
||||
#define ATTACHINFOCMD_H
|
||||
|
||||
class AttachInfoCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
Widget _info_dialog;
|
||||
DialogManager *_attachInfoDialogManager;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachInfoCmd ( AttachArea *, char *, int );
|
||||
~AttachInfoCmd();
|
||||
|
||||
virtual const char *const className () { return "AttachInfoCmd"; }
|
||||
};
|
||||
#endif
|
||||
1279
cde/programs/dtmail/dtmail/Attachment.C
Normal file
1279
cde/programs/dtmail/dtmail/Attachment.C
Normal file
File diff suppressed because it is too large
Load Diff
201
cde/programs/dtmail/dtmail/Attachment.h
Normal file
201
cde/programs/dtmail/dtmail/Attachment.h
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Attachment.h /main/8 1998/05/06 15:54:12 rafi $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef ATTACHMENT_H
|
||||
#define ATTACHMENT_H
|
||||
|
||||
#include <Dt/Dts.h>
|
||||
#include <Dt/Action.h>
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include <DtMail/DtVirtArray.hh>
|
||||
|
||||
#include "UIComponent.h"
|
||||
#include "AttachArea.h"
|
||||
|
||||
#define MARGIN 2
|
||||
|
||||
typedef enum { ROAM_CACHED, ROAM_LOCAL, ROAM_AVAILABLE, ROAM_UNAVAILABLE } ACState;
|
||||
|
||||
typedef enum { DONTKNOW, EXECUTABLE, NOTEXECUTABLE } ExecState;
|
||||
|
||||
class Icon;
|
||||
class Attachment;
|
||||
|
||||
class ActionCallback {
|
||||
friend class Attachment;
|
||||
public:
|
||||
ActionCallback(DtMailObjectKey, Attachment *);
|
||||
~ActionCallback();
|
||||
|
||||
private:
|
||||
DtMailObjectKey _myKey;
|
||||
Attachment *_myAttachment;
|
||||
};
|
||||
|
||||
class Attachment : public UIComponent {
|
||||
|
||||
public:
|
||||
|
||||
// This version takes a filename as a parameter
|
||||
|
||||
Attachment ( AttachArea *, String, DtMail::BodyPart *, int);
|
||||
|
||||
virtual ~Attachment(); // Destructor
|
||||
virtual void initialize();
|
||||
void action(
|
||||
DtActionInvocationID,
|
||||
DtActionArg *,
|
||||
int,
|
||||
int );
|
||||
void invokeAction(int);
|
||||
|
||||
int operator==(const Attachment&);
|
||||
|
||||
// Accessors
|
||||
//
|
||||
// Note: functions calling getLabel are responsible for freeing
|
||||
// the XmString it returns
|
||||
//
|
||||
XmString getLabel() { return ( XmStringCopy ( _label ) ); }
|
||||
void rename(XmString);
|
||||
void *getContents();
|
||||
|
||||
|
||||
unsigned long getContentsSize()
|
||||
{ return ( _myContentsSize ); }
|
||||
|
||||
Dimension getWidth() { return ( _attachmentWidth ); }
|
||||
Dimension getHeight() { return ( _attachmentHeight );}
|
||||
Position getX() { return ( _positionX ); }
|
||||
Position getY() { return ( _positionY );}
|
||||
int getRow() { return ( _row ); }
|
||||
|
||||
Boolean isManaged() { return ( XtIsManaged(_w) ); }
|
||||
Boolean isDeleted() { return ( _deleted ); }
|
||||
AttachArea* parent() { return ( _parent ); }
|
||||
Widget getIconWidget() { return ( _w); }
|
||||
void manageIconWidget(void);
|
||||
void unmanageIconWidget(void);
|
||||
|
||||
String getSaveAsFilename()
|
||||
{ return ( _saveAsFilename ); }
|
||||
char* getCeName() { return ( _ce_name ); }
|
||||
unsigned short getType() { return ( _type ); }
|
||||
String getSubType() { return ( _subtype ); }
|
||||
DtMail::BodyPart *getBodyPart() { return ( _body_part ); }
|
||||
Boolean isBinary() { return ( _binary ); }
|
||||
Boolean isSelected() { return ( _selected ); }
|
||||
|
||||
|
||||
void saveToFile(DtMailEnv & error,char *filename);
|
||||
virtual const char *const className() { return ( "Attachment" ); }
|
||||
|
||||
// Mutators
|
||||
void setLabel( XmString str );
|
||||
|
||||
void setX(Position);
|
||||
#ifdef DEAD_WOOD
|
||||
void setY(Position);
|
||||
void setRow(int);
|
||||
#else /* ! DEAD_WOOD */
|
||||
void setY(Position);
|
||||
void setRow(int row) { _row = row; }
|
||||
#endif /* ! DEAD_WOOD */
|
||||
|
||||
void deleteIt();
|
||||
void undeleteIt();
|
||||
void setSaveAsFilename(String str)
|
||||
{ ( _saveAsFilename = str); }
|
||||
|
||||
void set_binary(Boolean binary)
|
||||
{ ( _binary = binary); }
|
||||
|
||||
void handleDoubleClick();
|
||||
|
||||
void name_to_type();
|
||||
void setAttachArea(AttachArea *);
|
||||
#ifdef DEAD_WOOD
|
||||
Boolean check_if_binary(String, unsigned long);
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
// SR -- Added methods below
|
||||
|
||||
void primitive_select();
|
||||
void set_selected();
|
||||
Boolean is_selected();
|
||||
|
||||
void setContents();
|
||||
|
||||
void unselect();
|
||||
|
||||
void quit();
|
||||
|
||||
void registerAction(DtActionInvocationID);
|
||||
void unregisterAction(DtActionInvocationID);
|
||||
protected:
|
||||
static void actionCallback(
|
||||
DtActionInvocationID id,
|
||||
XtPointer client_data,
|
||||
DtActionArg *actionArgPtr,
|
||||
int actionArgCount,
|
||||
DtActionStatus status
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
Icon* myIcon; // my Icon instance
|
||||
|
||||
Pixel _background; // The background color
|
||||
Pixel _foreground; // The foreground color
|
||||
AttachArea *_parent; // The Parent class
|
||||
XmString _label; // The name (no absolute path)
|
||||
DtMail::BodyPart *_body_part; // Pointer to back end body part.
|
||||
|
||||
Dimension _attachmentWidth; // The width of the attachment
|
||||
Dimension _attachmentHeight; // The height of the attachment
|
||||
Position _positionX; // The X Position
|
||||
Position _positionY; // The Y Position
|
||||
|
||||
Boolean _deleted; // True is it has been deleted
|
||||
Boolean _selected; // True if selected.
|
||||
int _row; // Which row this is displayed in
|
||||
String _saveAsFilename; // Name for Save As
|
||||
int _index; // Index in attachArea
|
||||
char *_ce_name;
|
||||
char *_ce_type;
|
||||
unsigned short _type;
|
||||
String _subtype;
|
||||
Boolean _binary;
|
||||
|
||||
Boolean _executable;
|
||||
Boolean _haveContents;
|
||||
char *_myAllocContents;
|
||||
const void *_myContents;
|
||||
unsigned long _myContentsSize;
|
||||
char * _myType;
|
||||
Boolean _canKillSelf;
|
||||
|
||||
char ** _myActionsList;
|
||||
DtVirtArray<DtActionInvocationID> _myActionIds;
|
||||
DtMailObjectKey _key;
|
||||
void _setMyContents(const void * data, int size);
|
||||
};
|
||||
|
||||
#endif
|
||||
83
cde/programs/dtmail/dtmail/CheckBoxUiItem.C
Normal file
83
cde/programs/dtmail/dtmail/CheckBoxUiItem.C
Normal file
@@ -0,0 +1,83 @@
|
||||
/* $TOG: CheckBoxUiItem.C /main/5 1997/04/29 15:58:33 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/CheckBoxUiItem.hh>
|
||||
|
||||
// CheckBoxUiItem::CheckBoxUiItem
|
||||
// CheckBoxUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
CheckBoxUiItem::CheckBoxUiItem(Widget w, int source, char *search_key):PropUiItem(w, source, search_key)
|
||||
{
|
||||
#ifdef DEAD_WOOD
|
||||
data_source = source;
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
options_checkbox_init(w, &(this->dirty_bit));
|
||||
|
||||
}
|
||||
|
||||
// CheckBoxUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckBoxUiItem::writeFromUiToSource()
|
||||
{
|
||||
Boolean checkbox_value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
checkbox_value = options_checkbox_get_value(w);
|
||||
|
||||
if(checkbox_value == TRUE) // make sure the value is in the table
|
||||
{
|
||||
prop_source->setValue("");
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_source->setValue("f");
|
||||
}
|
||||
}
|
||||
|
||||
// CheckBoxUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckBoxUiItem::writeFromSourceToUi()
|
||||
{
|
||||
char *value = NULL;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
value = (char *)prop_source->getValue();
|
||||
|
||||
//
|
||||
// this will have to be made more robust...
|
||||
//
|
||||
// This assumes that a non-null value means that the
|
||||
// value is set and that a non-null means turn on the CB
|
||||
if (strcmp(value, "") == 0)
|
||||
options_checkbox_set_value(w, TRUE, this->dirty_bit);
|
||||
else if (NULL == value || strcmp(value, "f") == 0)
|
||||
options_checkbox_set_value(w, FALSE, this->dirty_bit);
|
||||
|
||||
if (NULL != NULL)
|
||||
free((void*) value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
97
cde/programs/dtmail/dtmail/CheckForMailUiItem.C
Normal file
97
cde/programs/dtmail/dtmail/CheckForMailUiItem.C
Normal file
@@ -0,0 +1,97 @@
|
||||
/* $TOG: CheckForMailUiItem.C /main/1 1998/02/17 15:19:56 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/XmAll.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/CheckForMailUiItem.hh>
|
||||
#include <DtMail/SpinBoxUiItem.hh>
|
||||
|
||||
int CheckForMailUiItem::_initialized = 0;
|
||||
DtVirtArray<CheckForMailUiItem*> *CheckForMailUiItem::_checkformail_ui = NULL;
|
||||
|
||||
CheckForMailUiItem::CheckForMailUiItem(Widget w, int source, char *search_key):
|
||||
SpinBoxUiItem(w, source, search_key)
|
||||
{
|
||||
Widget textfield;
|
||||
|
||||
if (! _initialized)
|
||||
{
|
||||
_initialized = 1;
|
||||
_checkformail_ui = new DtVirtArray<CheckForMailUiItem*> (3);
|
||||
}
|
||||
|
||||
options_spinbox_init(w, &(this->dirty_bit));
|
||||
XtVaGetValues(w, XmNtextField, &textfield, NULL);
|
||||
XtAddCallback(
|
||||
textfield,
|
||||
XmNvalueChangedCallback,
|
||||
CheckForMailUiItem::valueChangedCB,
|
||||
this);
|
||||
|
||||
_checkformail_ui->append(this);
|
||||
}
|
||||
|
||||
//
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckForMailUiItem::valueChangedCB(Widget w, XtPointer client, XtPointer)
|
||||
{
|
||||
CheckForMailUiItem *cui = (CheckForMailUiItem*) client;
|
||||
cui->_valueChanged = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckForMailUiItem::writeFromUiToSource()
|
||||
{
|
||||
int spinbox_value;
|
||||
Widget w = this->getWidget();
|
||||
char val_str[64];
|
||||
|
||||
if (!_valueChanged) return;
|
||||
|
||||
spinbox_value = options_spinbox_get_value(w);
|
||||
sprintf(val_str, "%d", spinbox_value);
|
||||
prop_source->setValue(val_str);
|
||||
|
||||
for (int i = 0; i < _checkformail_ui->length(); i++)
|
||||
{
|
||||
CheckForMailUiItem *cui = (*_checkformail_ui)[i];
|
||||
if (cui != this) cui->writeFromSourceToUi();
|
||||
}
|
||||
_valueChanged = FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckForMailUiItem::writeFromSourceToUi()
|
||||
{
|
||||
const char *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
value = prop_source->getValue();
|
||||
options_spinbox_set_value(w, atoi(value), this->dirty_bit);
|
||||
_valueChanged = FALSE;
|
||||
|
||||
if (NULL != value) free((void*) value);
|
||||
}
|
||||
870
cde/programs/dtmail/dtmail/ComposeCmds.C
Normal file
870
cde/programs/dtmail/dtmail/ComposeCmds.C
Normal file
@@ -0,0 +1,870 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: ComposeCmds.C /main/11 1998/10/21 17:23:13 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <EUSCompat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(NEED_MMAP_WRAPPER)
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <sys/mman.h>
|
||||
#if defined(NEED_MMAP_WRAPPER)
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <pwd.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xm/FileSBP.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Xm/PushBG.h>
|
||||
#include <Xm/PanedW.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Dt/Dts.h>
|
||||
#include <Dt/Action.h>
|
||||
#include <DtMail/IO.hh>
|
||||
#include "RoamMenuWindow.h"
|
||||
#include "SendMsgDialog.h"
|
||||
#include "Undelete.hh"
|
||||
#include "RoamCmds.h"
|
||||
#include "ComposeCmds.hh"
|
||||
#include "Application.h"
|
||||
#include "RoamApp.h"
|
||||
#include "DtMailWDM.hh"
|
||||
#include "FindDialog.h"
|
||||
#include "MsgScrollingList.hh"
|
||||
#include "MsgHndArray.hh"
|
||||
#include "MemUtils.hh"
|
||||
#include "MailMsg.h"
|
||||
#include "EUSDebug.hh"
|
||||
#include "DtMailGenDialog.hh"
|
||||
#include "DtMailHelp.hh"
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include "Help.hh"
|
||||
#include <Dt/Help.h>
|
||||
#include "Attachment.h"
|
||||
#include "str_utils.h"
|
||||
|
||||
ComposeFamily::ComposeFamily(char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window)
|
||||
: RoamCmd(name, label, active, window)
|
||||
{
|
||||
_parent = window;
|
||||
}
|
||||
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
ComposeFamily::~ComposeFamily( void )
|
||||
{
|
||||
}
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
|
||||
// Append a formatted message to Compose's Text area.
|
||||
// This routine is essentially the same as MsgScollingList::display_message()
|
||||
// except for two major differences:
|
||||
// 1. No RoamMenuWindow reference (so that Compose can be standalone).
|
||||
// 2. Indent string can be used for "include" and "forward".
|
||||
void
|
||||
ComposeFamily::Display_entire_msg(DtMailMessageHandle msgno,
|
||||
SendMsgDialog *compose,
|
||||
char *format
|
||||
)
|
||||
{
|
||||
DtMailEnv error;
|
||||
|
||||
int num_bodyParts;
|
||||
DtMail::MailBox *mbox = _menuwindow->mailbox();
|
||||
DtMail::Message *msg = mbox->getMessage(error, msgno);
|
||||
DtMail::Envelope *env = msg->getEnvelope(error);
|
||||
DtMail::BodyPart *tmpBP = NULL;
|
||||
DtMailBuffer tmpBuffer;
|
||||
void *buffer = NULL;
|
||||
unsigned long size = 0;
|
||||
|
||||
Editor::InsertFormat ins_format = Editor::IF_NONE;
|
||||
Editor::BracketFormat brackets = Editor::BF_NONE;
|
||||
|
||||
// Do not need to wrap "include", "forward", and "indent" with
|
||||
// catgets().
|
||||
if ( strcmp(format, "include") == 0 ) {
|
||||
ins_format = Editor::IF_BRACKETED;
|
||||
brackets = Editor::BF_INCLUDE;
|
||||
} else if ( strcmp(format, "forward") == 0 ) {
|
||||
ins_format = Editor::IF_BRACKETED;
|
||||
brackets = Editor::BF_FORWARD;
|
||||
} else if ( strcmp(format, "indent") == 0 ) {
|
||||
ins_format = Editor::IF_INDENTED;
|
||||
}
|
||||
|
||||
// Get the editor to display the body of message with the appropriate
|
||||
// insert/bracket formatting.
|
||||
// We only include the first body part of the message. Attachments,
|
||||
// etc. are "FORWARD"-ed but not "INCLUDE"-ed
|
||||
|
||||
char * status_string;
|
||||
DtMailBoolean firstBPHandled =
|
||||
compose->get_editor()->textEditor()->set_message(
|
||||
msg,
|
||||
&status_string,
|
||||
Editor::HF_ABBREV,
|
||||
ins_format,
|
||||
brackets);
|
||||
|
||||
// Now need to handle the unhandled body parts of the message.
|
||||
|
||||
num_bodyParts = msg->getBodyCount(error);
|
||||
if (error.isSet()) {
|
||||
// do something
|
||||
}
|
||||
|
||||
if (strcmp(format, "forward") == 0) {
|
||||
// If the message has attachments, then let the attach pane
|
||||
// handle attachments but not the first bodyPart (which has
|
||||
// already been handled here).
|
||||
|
||||
if ((num_bodyParts > 1) || (!firstBPHandled)) {
|
||||
|
||||
tmpBP = msg->getFirstBodyPart(error);
|
||||
if (firstBPHandled) {
|
||||
// The first bodyPart has already been handled.
|
||||
// The others, beginning from the second, need to be parsed
|
||||
// and put into the attachPane.
|
||||
|
||||
compose->setInclMsgHnd(msg, TRUE);
|
||||
tmpBP = msg->getNextBodyPart(error, tmpBP);
|
||||
|
||||
} else {
|
||||
// The first bodyPart was not handled.
|
||||
// It may not have been of type text.
|
||||
// The attachment pane needs to handle all the bodyParts
|
||||
// beginning with the first.
|
||||
|
||||
compose->setInclMsgHnd(msg, FALSE);
|
||||
}
|
||||
|
||||
char *name;
|
||||
while (tmpBP != NULL) {
|
||||
tmpBP->getContents(
|
||||
error, (const void **) &tmpBuffer.buffer,
|
||||
&tmpBuffer.size,
|
||||
NULL,
|
||||
&name,
|
||||
NULL,
|
||||
NULL);
|
||||
if (error.isSet()) {
|
||||
// Do something
|
||||
}
|
||||
// It's possible for an attachment to not have a name.
|
||||
if (!name) {
|
||||
name = "NoName";
|
||||
}
|
||||
|
||||
compose->add_att(name, tmpBuffer);
|
||||
tmpBP = msg->getNextBodyPart(error, tmpBP);
|
||||
if (error.isSet()) {
|
||||
// do something
|
||||
}
|
||||
|
||||
if (strcmp(name, "NoName") != 0) {
|
||||
free(name);
|
||||
}
|
||||
}
|
||||
if (error.isSet()) {
|
||||
|
||||
// do something
|
||||
}
|
||||
|
||||
// Need to call this after calling parseAttachments().
|
||||
|
||||
compose->get_editor()->manageAttachArea();
|
||||
|
||||
// This message has attachment and is being included/forwarded,
|
||||
// so need to fill the Compose Message Handle with attachment
|
||||
// BodyParts.
|
||||
// See function for further details.
|
||||
|
||||
// compose->updateMsgHndAtt();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the message has attachments, then let the attach pane
|
||||
// handle attachments but not the first bodyPart (which has
|
||||
// already been handled here).
|
||||
|
||||
if ((num_bodyParts > 1) || (!firstBPHandled))
|
||||
{
|
||||
char *att;
|
||||
Editor *editor = compose->get_editor()->textEditor();
|
||||
|
||||
att = GETMSG(
|
||||
DT_catd, 1, 255,
|
||||
"------------------ Attachments ------------------\n");
|
||||
|
||||
tmpBP = msg->getFirstBodyPart(error);
|
||||
if (firstBPHandled)
|
||||
tmpBP = msg->getNextBodyPart(error, tmpBP);
|
||||
|
||||
editor->append_to_contents(att, strlen(att));
|
||||
while (tmpBP != NULL)
|
||||
{
|
||||
editor->set_attachment(tmpBP, ins_format, brackets);
|
||||
tmpBP = msg->getNextBodyPart(error, tmpBP);
|
||||
if (error.isSet()) {
|
||||
// do something
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Leave it up to check point routine for update or do it now???
|
||||
compose->updateMsgHnd();
|
||||
}
|
||||
|
||||
void
|
||||
ComposeFamily::appendSignature(SendMsgDialog * compose)
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
|
||||
const char * value = NULL;
|
||||
mail_rc->getValue(error, "signature", &value);
|
||||
if (error.isSet()) {
|
||||
return;
|
||||
}
|
||||
|
||||
char * fullpath = d_session->expandPath(error, value);
|
||||
compose->get_editor()->textEditor()->append_to_contents(fullpath);
|
||||
if (NULL != fullpath)
|
||||
free((void*) fullpath);
|
||||
if (NULL != NULL)
|
||||
free((void*) value);
|
||||
|
||||
compose->get_editor()->textEditor()->set_to_top();
|
||||
}
|
||||
|
||||
char *
|
||||
ComposeFamily::valueToAddrString(DtMailValueSeq & value)
|
||||
{
|
||||
int max_len = 0;
|
||||
|
||||
for (int count = 0; count < value.length(); count++) {
|
||||
max_len += strlen(*(value[count]));
|
||||
}
|
||||
|
||||
char * str = new char[max_len + count + 1];
|
||||
str[0] = 0;
|
||||
|
||||
DtMailBoolean need_comma = DTM_FALSE;
|
||||
|
||||
for (int cat = 0; cat < value.length(); cat++)
|
||||
{
|
||||
DtMailValue * val = value[cat];
|
||||
DtMailAddressSeq *addr_seq = val->toAddress();
|
||||
|
||||
for (int ad = 0; ad < addr_seq->length(); ad++)
|
||||
{
|
||||
DtMailValueAddress * addr = (*addr_seq)[ad];
|
||||
|
||||
// Deal with mail address parser shortcomings
|
||||
if ( strcmp(addr->dtm_address, ",") == 0 )
|
||||
continue ;
|
||||
|
||||
if (need_comma) {
|
||||
strcat(str, ", ");
|
||||
}
|
||||
|
||||
need_comma = DTM_TRUE;
|
||||
|
||||
strcat(str, addr->dtm_address);
|
||||
}
|
||||
|
||||
delete addr_seq;
|
||||
}
|
||||
|
||||
return(str);
|
||||
}
|
||||
|
||||
|
||||
// Container menu "Compose==>New Message"
|
||||
ComposeCmd::ComposeCmd(
|
||||
char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window
|
||||
) : ComposeFamily( name, label, active, window )
|
||||
{
|
||||
}
|
||||
|
||||
// Put up a blank compose window.
|
||||
void
|
||||
ComposeCmd::doit()
|
||||
{
|
||||
SendMsgDialog * newsend = theCompose.getWin();
|
||||
if (newsend == NULL) {
|
||||
DtMailGenDialog * dialog = _parent->genDialog();
|
||||
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 203, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 204, "Unable to create a compose window."));
|
||||
char * helpId = DTMAILHELPNOCOMPOSE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
}
|
||||
|
||||
appendSignature(newsend);
|
||||
}
|
||||
|
||||
// Container menu "Compose==>New, Include All" and "Compose==>Forward Message"
|
||||
// The last parameter is a switch for "include" or "forward" format.
|
||||
ForwardCmd::ForwardCmd(
|
||||
char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window,
|
||||
int forward
|
||||
) : ComposeFamily(name, label, active, window)
|
||||
{
|
||||
_forward = forward;
|
||||
}
|
||||
|
||||
// Forward or Include selected messages.
|
||||
// For Include message(s), all Compose window header fields are left blank.
|
||||
// For Forward message(s), the Compose window "Subject" header field is filled
|
||||
// with the subject of the last selected message.
|
||||
void
|
||||
ForwardCmd::doit()
|
||||
{
|
||||
FORCE_SEGV_DECL(MsgHndArray, msgList);
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS);
|
||||
DtMailMessageHandle msgno;
|
||||
|
||||
// Get a Compose window.
|
||||
SendMsgDialog *newsend = theCompose.getWin();
|
||||
if ( newsend == NULL ) {
|
||||
DtMailGenDialog * dialog = _parent->genDialog();
|
||||
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 205, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 206, "Unable to create a compose window."));
|
||||
char * helpId = DTMAILHELPNOCOMPOSE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
}
|
||||
|
||||
// Put the signature above the message.
|
||||
//
|
||||
appendSignature(newsend);
|
||||
|
||||
// For Forwarding subject
|
||||
DtMail::MailBox * mbox = _menuwindow->mailbox();
|
||||
DtMail::Message * msg;
|
||||
DtMail::Envelope * env;
|
||||
DtMailValueSeq value;
|
||||
DtMailEnv error;
|
||||
|
||||
// For each selected message, put it in the Compose window.
|
||||
if ( msgList = _menuwindow->list()->selected() ) {
|
||||
for ( int k = 0; k < msgList->length(); k++ ) {
|
||||
tmpMS = msgList->at(k);
|
||||
msgno = tmpMS->message_handle;
|
||||
if ( _forward ) {
|
||||
msg = mbox->getMessage(error, msgno);
|
||||
env = msg->getEnvelope(error);
|
||||
value.clear();
|
||||
env->getHeader(error, DtMailMessageSubject, DTM_TRUE, value);
|
||||
if (!error.isSet()) {
|
||||
const char *subject = *(value[0]);
|
||||
newsend->setHeader("Subject", subject);
|
||||
newsend->setTitle((char*) subject);
|
||||
newsend->setIconTitle((char*) subject);
|
||||
}
|
||||
Display_entire_msg(msgno, newsend, "forward");
|
||||
} else {
|
||||
Display_entire_msg(msgno, newsend, "indent");
|
||||
}
|
||||
}
|
||||
}
|
||||
newsend->get_editor()->textEditor()->set_to_top();
|
||||
}
|
||||
|
||||
// Container menu "Compose==>Reply to Semder" and
|
||||
// "Compose==>Reply to Sender, Include"
|
||||
// The last parameter is a switch for including the selected message or not.
|
||||
ReplyCmd::ReplyCmd (
|
||||
char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window,
|
||||
int include
|
||||
) : ComposeFamily ( name, label, active, window )
|
||||
{
|
||||
_include = include;
|
||||
}
|
||||
|
||||
// For each message selected, reply to sender.
|
||||
void
|
||||
ReplyCmd::doit()
|
||||
{
|
||||
FORCE_SEGV_DECL(MsgHndArray, msgList);
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS);
|
||||
DtMailMessageHandle msgno;
|
||||
FORCE_SEGV_DECL(char, from);
|
||||
FORCE_SEGV_DECL(char, subject);
|
||||
FORCE_SEGV_DECL(char, cc);
|
||||
DtMailEnv error;
|
||||
DtMail::MailBox * mbox = _menuwindow->mailbox();
|
||||
|
||||
// Initialize the error.
|
||||
error.clear();
|
||||
|
||||
if (msgList = _menuwindow->list()->selected())
|
||||
{
|
||||
for ( int i=0; i < msgList->length(); i++ ) {
|
||||
tmpMS = msgList->at(i);
|
||||
msgno = tmpMS->message_handle;
|
||||
SendMsgDialog *newsend = theCompose.getWin();
|
||||
if ( newsend == NULL ) {
|
||||
DtMailGenDialog * dialog = _parent->genDialog();
|
||||
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 207, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 208, "Unable to create a compose window."));
|
||||
char * helpId = DTMAILHELPNOCOMPOSE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
}
|
||||
XmUpdateDisplay( newsend->baseWidget() );
|
||||
|
||||
DtMail::Message * msg = mbox->getMessage(error, msgno);
|
||||
DtMail::Envelope * env = msg->getEnvelope(error);
|
||||
|
||||
DtMailValueSeq value;
|
||||
|
||||
env->getHeader(error, DtMailMessageSender, DTM_TRUE, value);
|
||||
if (error.isSet()) {
|
||||
newsend->setHeader("To", "nobody@nowhere");
|
||||
}
|
||||
else {
|
||||
char * addr_str = valueToAddrString(value);
|
||||
newsend->setHeader("To", addr_str);
|
||||
delete [] addr_str;
|
||||
}
|
||||
|
||||
value.clear();
|
||||
env->getHeader(error, DtMailMessageSubject, DTM_TRUE, value);
|
||||
if (error.isSet()) {
|
||||
subject = new char[200];
|
||||
strcpy(subject, "Re: ");
|
||||
DtMailValueSeq sent;
|
||||
env->getHeader(error,
|
||||
DtMailMessageSentTime,
|
||||
DTM_TRUE,
|
||||
sent);
|
||||
if (error.isSet()) {
|
||||
strcat(subject, "Your Message");
|
||||
}
|
||||
else {
|
||||
strcat(subject, "Your Message Sent on ");
|
||||
strcat(subject, *(sent[0]));
|
||||
}
|
||||
newsend->setHeader("Subject", subject);
|
||||
}
|
||||
else {
|
||||
// Get the BE store of header. It may contain newlines or
|
||||
// tab chars which can munge the scrolling list's display!
|
||||
|
||||
const char * orig = *(value[0]);
|
||||
|
||||
int fc;
|
||||
int orig_length;
|
||||
char *tmp_subj;
|
||||
|
||||
// Check if BE store contains the funky chars.
|
||||
|
||||
for (fc = 0, orig_length = strlen(orig),
|
||||
tmp_subj = (char *) orig;
|
||||
fc < orig_length;
|
||||
fc++, tmp_subj++) {
|
||||
|
||||
char c = *tmp_subj;
|
||||
if ((c == '\n')
|
||||
|| (c == '\t')
|
||||
|| (c == '\r')) {
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subject = new char[fc+6];
|
||||
|
||||
if (strncasecmp(orig, "Re:", 3)) {
|
||||
strcpy(subject, "Re: ");
|
||||
}
|
||||
else {
|
||||
*subject = 0;
|
||||
}
|
||||
|
||||
strncat((char *)subject, orig, fc);
|
||||
|
||||
newsend->setHeader("Subject", subject);
|
||||
}
|
||||
|
||||
newsend->setTitle(subject);
|
||||
newsend->setIconTitle(subject);
|
||||
delete [] subject;
|
||||
|
||||
if ( _include ) {
|
||||
Display_entire_msg(msgno, newsend, "indent");
|
||||
newsend->get_editor()->textEditor()->set_to_top();
|
||||
}
|
||||
appendSignature(newsend);
|
||||
newsend->setInputFocus(1);
|
||||
}
|
||||
|
||||
delete msgList;
|
||||
}
|
||||
}
|
||||
|
||||
// Container menu "Compose==>Reply to All" and "Compose==>Reply to All, Include"
|
||||
// The last parameter is a switch for including the selected message or not.
|
||||
ReplyAllCmd::ReplyAllCmd(
|
||||
char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window,
|
||||
int include
|
||||
) : ComposeFamily( name, label, active, window )
|
||||
{
|
||||
_include = include;
|
||||
}
|
||||
|
||||
// For each message selected, reply to everybody.
|
||||
void
|
||||
ReplyAllCmd::doit()
|
||||
{
|
||||
FORCE_SEGV_DECL(MsgHndArray, msgList);
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS);
|
||||
FORCE_SEGV_DECL(char, subject);
|
||||
FORCE_SEGV_DECL(char, to);
|
||||
FORCE_SEGV_DECL(char, buffer);
|
||||
DtMailMessageHandle msgno;
|
||||
DtMail::MailBox *mbox = _menuwindow->mailbox();
|
||||
DtMailEnv error;
|
||||
char *currentCcValue;
|
||||
SendMsgDialog *newsend;
|
||||
DtMailGenDialog * dialog;
|
||||
DtMail::Message *msg;
|
||||
DtMail::Envelope *env;
|
||||
|
||||
|
||||
// Initialize the mail_error.
|
||||
error.clear();
|
||||
|
||||
|
||||
if ( msgList = _menuwindow->list()->selected() )
|
||||
for ( int k = 0; k < msgList->length(); k++ ) {
|
||||
DtMailValueSeq value ;
|
||||
|
||||
tmpMS = msgList->at(k);
|
||||
msgno = tmpMS->message_handle;
|
||||
newsend = theCompose.getWin();
|
||||
if ( newsend == NULL ) {
|
||||
dialog = _parent->genDialog();
|
||||
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 209, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 210, "Unable to create a compose window."));
|
||||
char * helpId = DTMAILHELPNOCOMPOSE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
}
|
||||
msg = mbox->getMessage(error, msgno);
|
||||
env = msg->getEnvelope(error);
|
||||
|
||||
env->getHeader(
|
||||
error,
|
||||
DtMailMessageToReply,
|
||||
DTM_TRUE,
|
||||
value);
|
||||
|
||||
env->getHeader(
|
||||
error,
|
||||
DtMailMessageSender,
|
||||
DTM_TRUE,
|
||||
value);
|
||||
|
||||
char * addr_str = valueToAddrString(value);
|
||||
newsend->setHeader("To", addr_str);
|
||||
delete [] addr_str;
|
||||
value.clear();
|
||||
env->getHeader(
|
||||
error,
|
||||
DtMailMessageSubject,
|
||||
DTM_TRUE,
|
||||
value);
|
||||
if ( error.isSet() ) {
|
||||
subject = new char[200];
|
||||
strcpy(subject, "Re: ");
|
||||
DtMailValueSeq sent;
|
||||
env->getHeader(error,
|
||||
DtMailMessageSentTime,
|
||||
DTM_TRUE,
|
||||
sent);
|
||||
if (error.isSet()) {
|
||||
strcat(subject, "Your Message");
|
||||
}
|
||||
else {
|
||||
strcat(subject, "Your Message Sent on ");
|
||||
strcat(subject, *(sent[0]));
|
||||
}
|
||||
newsend->setHeader("Subject", subject);
|
||||
} else {
|
||||
// Get the BE store of header. It may contain newlines or
|
||||
// tab chars which can munge the scrolling list's display!
|
||||
|
||||
const char * orig = *(value[0]);
|
||||
|
||||
|
||||
int fc = 0;
|
||||
int orig_length;
|
||||
char *tmp_subj;
|
||||
|
||||
// Check if BE store contains the funky chars.
|
||||
|
||||
for (fc = 0, orig_length = strlen(orig),
|
||||
tmp_subj = (char *)orig;
|
||||
fc < orig_length;
|
||||
fc++, tmp_subj++) {
|
||||
|
||||
char c = *tmp_subj;
|
||||
if ((c == '\n')
|
||||
|| (c == '\t')
|
||||
|| (c == '\r')) {
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subject = new char[fc+6];
|
||||
|
||||
if (strncasecmp(orig, "Re:", 3)) {
|
||||
strcpy(subject, "Re: ");
|
||||
}
|
||||
else {
|
||||
*subject = 0;
|
||||
}
|
||||
|
||||
strncat((char *)subject, orig, fc);
|
||||
|
||||
newsend->setHeader("Subject", subject);
|
||||
}
|
||||
value.clear();
|
||||
env->getHeader(
|
||||
error,
|
||||
DtMailMessageCcReply,
|
||||
DTM_TRUE,
|
||||
value);
|
||||
if (!error.isSet()) {
|
||||
// Strip out newlines from the cc line. They *may* be
|
||||
// present.
|
||||
currentCcValue = valueToAddrString(value);
|
||||
|
||||
newsend->setHeader("Cc", currentCcValue);
|
||||
delete [] currentCcValue ;
|
||||
}
|
||||
|
||||
newsend->setTitle(subject);
|
||||
newsend->setIconTitle(subject);
|
||||
delete [] subject;
|
||||
|
||||
if ( _include ) {
|
||||
Display_entire_msg(msgno, newsend, "indent");
|
||||
newsend->get_editor()->textEditor()->set_to_top();
|
||||
}
|
||||
appendSignature(newsend);
|
||||
newsend->setInputFocus(1);
|
||||
}
|
||||
}
|
||||
|
||||
TemplateCmd::TemplateCmd(char *name,
|
||||
char *label,
|
||||
int active,
|
||||
SendMsgDialog * compose,
|
||||
const char * file)
|
||||
: NoUndoCmd(name, label, active)
|
||||
{
|
||||
_compose = compose;
|
||||
|
||||
if (*file != '/' && *file != '~') {
|
||||
// Relative path. Should be relative to home directory
|
||||
_file = (char *)malloc(strlen(file) + 4);
|
||||
if (_file != NULL) {
|
||||
strcpy(_file, "~/");
|
||||
strcat(_file, file);
|
||||
}
|
||||
} else {
|
||||
_file = strdup(file);
|
||||
}
|
||||
}
|
||||
|
||||
TemplateCmd::~TemplateCmd(void)
|
||||
{
|
||||
free(_file);
|
||||
}
|
||||
|
||||
void
|
||||
TemplateCmd::doit()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMailGenDialog * dialog = _compose->genDialog();
|
||||
DtMailBuffer mbuf;
|
||||
|
||||
char * fullpath = d_session->expandPath(error, _file);
|
||||
|
||||
// Map the file and try to parse it as a message. If it is a message,
|
||||
// then load it with headers. Otherwise, throw everything into the
|
||||
// editor.
|
||||
//
|
||||
int fd = SafeOpen(fullpath, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 211, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 212, "The template does not exist."));
|
||||
char * helpId = DTMAILHELPNOTEMPLATE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
struct stat buf;
|
||||
if (SafeFStat(fd, &buf) < 0) {
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 213, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 214, "The template appears to be corrupt."));
|
||||
char * helpId = DTMAILHELPCORRUPTTEMPLATE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
SafeClose(fd);
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
int page_size = (int)sysconf(_SC_PAGESIZE);
|
||||
size_t map_size = (size_t) (buf.st_size +
|
||||
(page_size - (buf.st_size % page_size)));
|
||||
|
||||
int free_buf = 0;
|
||||
mbuf.size = buf.st_size;
|
||||
#ifdef __osf__
|
||||
// This version of mmap does NOT allow requested length to be
|
||||
// greater than the file size ... in contradiction to the
|
||||
// documentation (don't round up).
|
||||
mbuf.buffer = mmap(0, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
#else
|
||||
mbuf.buffer = mmap(0, map_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
#endif
|
||||
if (mbuf.buffer == (char *)-1) {
|
||||
free_buf = 1;
|
||||
mbuf.buffer = new char[mbuf.size];
|
||||
if (mbuf.buffer == NULL) {
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 215, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 216, "There is not enough memory to load the template."));
|
||||
char * helpId = DTMAILHELPNOMEMTEMPLATE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
SafeClose(fd);
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (SafeRead(fd, mbuf.buffer, (unsigned int)mbuf.size) < mbuf.size) {
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 217, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 218, "The template appears to be corrupt."));
|
||||
char * helpId = DTMAILHELPERROR;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
SafeClose(fd);
|
||||
delete [] mbuf.buffer;
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Now we ask the library to parse it. If this fails for any reason, this
|
||||
// is not a message, so we give up.
|
||||
//
|
||||
DtMail::Message * msg = d_session->messageConstruct(error,
|
||||
DtMailBufferObject,
|
||||
&mbuf,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
if (error.isSet()) {
|
||||
_compose->get_editor()->textEditor()->append_to_contents((char *)mbuf.buffer,
|
||||
mbuf.size);
|
||||
}
|
||||
else {
|
||||
_compose->loadHeaders(msg, DTM_TRUE);
|
||||
|
||||
DtMail::BodyPart * bp = msg->getFirstBodyPart(error);
|
||||
if (error.isNotSet()) {
|
||||
const void * contents;
|
||||
unsigned long length;
|
||||
|
||||
bp->getContents(error,
|
||||
&contents,
|
||||
&length,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
_compose->get_editor()->textEditor()->append_to_contents(
|
||||
(char *)contents, length);
|
||||
}
|
||||
}
|
||||
|
||||
free(fullpath);
|
||||
|
||||
if (free_buf) {
|
||||
free(mbuf.buffer);
|
||||
}
|
||||
else {
|
||||
munmap((char *)mbuf.buffer, map_size);
|
||||
}
|
||||
|
||||
SafeClose(fd);
|
||||
}
|
||||
|
||||
HideShowCmd::HideShowCmd(char *name,
|
||||
char *widgetlabel,
|
||||
int active,
|
||||
SendMsgDialog * compose,
|
||||
const char * label)
|
||||
: NoUndoCmd(name, (char *)widgetlabel, active)
|
||||
{
|
||||
_compose = compose;
|
||||
_header = strdup(label);
|
||||
}
|
||||
|
||||
HideShowCmd::~HideShowCmd(void)
|
||||
{
|
||||
if (_header) {
|
||||
free(_header);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HideShowCmd::doit(void)
|
||||
{
|
||||
_compose->changeHeaderState(_header);
|
||||
}
|
||||
110
cde/programs/dtmail/dtmail/ComposeCmds.hh
Normal file
110
cde/programs/dtmail/dtmail/ComposeCmds.hh
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: ComposeCmds.hh /main/3 1995/11/06 16:05:11 rswiston $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef COMPOSECMDS_HH
|
||||
#define COMPOSECMDS_HH
|
||||
|
||||
class ComposeFamily : public RoamCmd {
|
||||
private:
|
||||
RoamMenuWindow * _parent;
|
||||
|
||||
public:
|
||||
ComposeFamily(char * name, char *label, int active, RoamMenuWindow *);
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
~ComposeFamily( void );
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
void Display_entire_msg(DtMailMessageHandle, SendMsgDialog *, char *);
|
||||
void appendSignature(SendMsgDialog *);
|
||||
char * valueToAddrString(DtMailValueSeq & value);
|
||||
};
|
||||
|
||||
class ComposeCmd : public ComposeFamily {
|
||||
private:
|
||||
RoamMenuWindow * _parent;
|
||||
|
||||
public:
|
||||
virtual void doit();
|
||||
ComposeCmd( char *, char *, int, RoamMenuWindow * );
|
||||
virtual const char *const className () { return "ComposeCmd"; }
|
||||
};
|
||||
|
||||
class ForwardCmd : public ComposeFamily {
|
||||
private:
|
||||
RoamMenuWindow *_parent;
|
||||
int _forward;
|
||||
public:
|
||||
virtual void doit();
|
||||
ForwardCmd( char *, char *, int, RoamMenuWindow *, int );
|
||||
virtual const char *const className () { return "ForwardCmd"; }
|
||||
};
|
||||
|
||||
class ReplyAllCmd : public ComposeFamily {
|
||||
private:
|
||||
RoamMenuWindow *_parent;
|
||||
int _include;
|
||||
public:
|
||||
virtual void doit();
|
||||
ReplyAllCmd( char *, char *, int, RoamMenuWindow *, int );
|
||||
virtual const char *const className () { return "ReplyAllCmd"; }
|
||||
};
|
||||
|
||||
class ReplyCmd : public ComposeFamily {
|
||||
private:
|
||||
RoamMenuWindow *_parent;
|
||||
int _include;
|
||||
public:
|
||||
virtual void doit();
|
||||
ReplyCmd( char *, char *, int, RoamMenuWindow *, int );
|
||||
virtual const char *const className () { return "ReplyCmd"; }
|
||||
};
|
||||
|
||||
class TemplateCmd : public NoUndoCmd {
|
||||
private:
|
||||
SendMsgDialog *_compose;
|
||||
char *_file;
|
||||
|
||||
public:
|
||||
virtual void doit();
|
||||
TemplateCmd(char * name,
|
||||
char *label,
|
||||
int active,
|
||||
SendMsgDialog *,
|
||||
const char * file);
|
||||
virtual ~TemplateCmd();
|
||||
virtual const char *const className() { return "TemplateCmd"; }
|
||||
};
|
||||
|
||||
class HideShowCmd : public NoUndoCmd {
|
||||
private:
|
||||
SendMsgDialog *_compose;
|
||||
char *_header;
|
||||
|
||||
public:
|
||||
virtual void doit(void);
|
||||
HideShowCmd(char * name,
|
||||
char *widgetlabel,
|
||||
int active,
|
||||
SendMsgDialog *,
|
||||
const char * label);
|
||||
virtual ~HideShowCmd(void);
|
||||
virtual const char *const className() { return "HideShowCmd"; }
|
||||
};
|
||||
|
||||
#endif
|
||||
404
cde/programs/dtmail/dtmail/CustomListUiItem.C
Normal file
404
cde/programs/dtmail/dtmail/CustomListUiItem.C
Normal file
@@ -0,0 +1,404 @@
|
||||
/* $TOG: CustomListUiItem.C /main/6 1997/09/03 17:34:40 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: CustomListUiItem.C /main/6 1997/09/03 17:34:40 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/List.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include "options_ui.h"
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
#include <DtMail/CustomListUiItem.hh>
|
||||
|
||||
extern void handleCustSelection(Widget, XtPointer, XtPointer );
|
||||
extern Boolean props_changed;
|
||||
|
||||
// CustomListUiItem::CustomListUiItem
|
||||
// CustomListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
CustomListUiItem::CustomListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
Widget key_entry_widget,
|
||||
Widget value_entry_widget):ListUiItem(w, source, search_key, NULL)
|
||||
{
|
||||
source = source; search_key = search_key;
|
||||
|
||||
key_widget = key_entry_widget;
|
||||
value_widget = value_entry_widget;
|
||||
|
||||
list_items = NULL;
|
||||
deleted_items = NULL;
|
||||
|
||||
XtVaSetValues(w,
|
||||
XmNuserData, this,
|
||||
XmNautomaticSelection, True,
|
||||
XmNselectionPolicy, XmBROWSE_SELECT,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(w,
|
||||
XmNbrowseSelectionCallback,
|
||||
(XtCallbackProc)handleCustSelection,
|
||||
(XtPointer)this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
//-----------------======================-----------------
|
||||
void handleDoubleSelection(Widget w, XtPointer clientdata, XtPointer calldata)
|
||||
{
|
||||
CustomListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{ // motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getKeyWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(item->getValueWidget(),
|
||||
XmNvalue,pair->value,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
//-----------------======================-----------------
|
||||
void handleCustSelection(Widget w, XtPointer, XtPointer calldata)
|
||||
{
|
||||
CustomListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{ // motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getKeyWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(item->getValueWidget(),
|
||||
XmNvalue,pair->value,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
// CustomListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::writeFromUiToSource()
|
||||
{
|
||||
Widget w = this->getWidget();
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
int i, num_items;
|
||||
char *cf_str = NULL;
|
||||
|
||||
if(list_items != NULL) {
|
||||
if(list_items->length() > 0)
|
||||
{
|
||||
num_items = list_items->length();
|
||||
// calc mailrc strlen...
|
||||
int total_len = 1; // add space for the terminator...
|
||||
for(i = 0; i < num_items; i++) {
|
||||
int num_blanks=0;
|
||||
for (char *ptr = (*list_items)[i]->value;
|
||||
ptr && *ptr; ptr++)
|
||||
if (*ptr == ' ') num_blanks++;
|
||||
// strlen(label) strlen(value) + space + colon +
|
||||
// potential \'s that precede the blank character
|
||||
if((*list_items)[i]->label != NULL)
|
||||
total_len = total_len + strlen(":") +
|
||||
(strlen("\\") * num_blanks) +
|
||||
strlen((*list_items)[i]->label) + 2;
|
||||
|
||||
if((*list_items)[i]->value != NULL)
|
||||
total_len = total_len + strlen((*list_items)[i]->value);
|
||||
}
|
||||
cf_str = (char *)malloc(total_len);
|
||||
cf_str[0] = '\0';
|
||||
|
||||
for(i = 0; i < num_items; i++) {
|
||||
if((*list_items)[i]->label != NULL)
|
||||
strcat(cf_str, (*list_items)[i]->label);
|
||||
strcat(cf_str, ":");
|
||||
if((*list_items)[i]->value != NULL) {
|
||||
if (strchr((char*)(*list_items)[i]->value, ' ')) {
|
||||
char *token, *tmpbuf;
|
||||
tmpbuf = strdup((*list_items)[i]->value);
|
||||
if (token = (char *)strtok(tmpbuf, " ")) {
|
||||
strcat(cf_str, token);
|
||||
while(token = (char *)strtok(NULL, " ")) {
|
||||
strcat(cf_str, "\\ ");
|
||||
strcat(cf_str, token);
|
||||
}
|
||||
}
|
||||
free(tmpbuf);
|
||||
}
|
||||
else
|
||||
strcat(cf_str, (*list_items)[i]->value);
|
||||
}
|
||||
strcat(cf_str, " ");
|
||||
}
|
||||
mail_rc->setValue(error, "additionalfields", cf_str);
|
||||
}
|
||||
else
|
||||
mail_rc->removeValue(error, "additionalfields");
|
||||
}
|
||||
else
|
||||
mail_rc->removeValue(error, "additionalfields");
|
||||
|
||||
}
|
||||
|
||||
// CustomListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
Widget w = this->getWidget();
|
||||
const char *list_str = NULL;
|
||||
DtVirtArray<char *> list_str_list(10);
|
||||
char *buf = NULL;
|
||||
int list_len, i;
|
||||
const char *value = NULL;
|
||||
|
||||
XmListDeleteAllItems(w);
|
||||
|
||||
mail_rc->getValue(error, "additionalfields", &value);
|
||||
|
||||
if(list_items != NULL)
|
||||
delete list_items;
|
||||
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
parsePropString(value, *list_items);
|
||||
|
||||
list_len = list_items->length();
|
||||
for(i = 0; i < list_len; i++)
|
||||
list_str_list.append(formatPropPair((*list_items)[i]->label,
|
||||
(*list_items)[i]->value));
|
||||
|
||||
options_list_init(w, &list_str_list);
|
||||
|
||||
if (value != NULL)
|
||||
free((void *)value);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::handleAddButtonPress()
|
||||
{
|
||||
char *key_str = NULL;
|
||||
char *value_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
|
||||
XtVaGetValues(key_widget,
|
||||
XmNvalue, &key_str,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(value_widget,
|
||||
XmNvalue, &value_str,
|
||||
NULL);
|
||||
|
||||
if(key_str != NULL)
|
||||
if(strlen(key_str) > 0)
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
new_pair->label = strdup(key_str);
|
||||
|
||||
if(value_str != NULL)
|
||||
new_pair->value = strdup(value_str);
|
||||
else
|
||||
new_pair->value = NULL;
|
||||
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(
|
||||
formatPropPair(
|
||||
new_pair->label,
|
||||
new_pair->value)),
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
pos_list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,0);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(
|
||||
formatPropPair(
|
||||
new_pair->label,
|
||||
new_pair->value)),
|
||||
1);
|
||||
XmListSelectPos(this->getWidget(),
|
||||
1,
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
1);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::handleChangeButtonPress()
|
||||
{
|
||||
char *key_str = NULL;
|
||||
char *value_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
XmString replace_string;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
// if nothing selected nothing to change...
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
XtVaGetValues(key_widget,
|
||||
XmNvalue, &key_str,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(value_widget,
|
||||
XmNvalue, &value_str,
|
||||
NULL);
|
||||
|
||||
if(key_str != NULL)
|
||||
if(strlen(key_str) > 0)
|
||||
{
|
||||
|
||||
new_pair = (*list_items)[pos_list[0] - 1];
|
||||
|
||||
free(new_pair->label);
|
||||
new_pair->label = strdup(key_str);
|
||||
|
||||
if(new_pair->value != NULL)
|
||||
{
|
||||
free(new_pair->value);
|
||||
if(value_str != NULL)
|
||||
new_pair->value = strdup(value_str);
|
||||
else
|
||||
new_pair->value = NULL;
|
||||
}
|
||||
|
||||
replace_string = XmStringCreateLocalized(
|
||||
formatPropPair(new_pair->label,
|
||||
new_pair->value));
|
||||
|
||||
XmListReplaceItemsPos(this->getWidget(),
|
||||
&replace_string,
|
||||
1,
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::handleDeleteButtonPress()
|
||||
{
|
||||
Widget list_widget = this->getWidget();
|
||||
int *p_list, p_count;
|
||||
|
||||
// get the selected position
|
||||
if(XmListGetSelectedPos(list_widget,
|
||||
&p_list,
|
||||
&p_count))
|
||||
{
|
||||
|
||||
// delete the item from our list
|
||||
this->list_items->remove(p_list[0] - 1); // remove only first
|
||||
|
||||
// delete the item from the widget
|
||||
XmListDeletePos(list_widget, p_list[0]);
|
||||
|
||||
XtVaSetValues(this->getKeyWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(this->getValueWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
|
||||
XmListSelectPos(list_widget,
|
||||
p_list[0],
|
||||
TRUE);
|
||||
|
||||
props_changed = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
18
cde/programs/dtmail/dtmail/DebugBento
Normal file
18
cde/programs/dtmail/dtmail/DebugBento
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/csh
|
||||
#
|
||||
# A script that aids in debugging and testing dtmail
|
||||
#
|
||||
if ( `uname -s` != SunOS ) then
|
||||
echo "Only support SunOS"
|
||||
exit 1
|
||||
endif
|
||||
set echo
|
||||
setenv DT_MAIL /home/dougr/INBOX
|
||||
setenv DEFAULT_BACKEND Bento
|
||||
setenv LD_LIBRARY_PATH ../libDtMail:../../../lib/Bento:../../../binstall/lib:$LD_LIBRARY_PATH
|
||||
ldd -r dtmail
|
||||
if ( -f core ) then
|
||||
exec debugger dtmail core &
|
||||
else
|
||||
exec debugger dtmail &
|
||||
endif
|
||||
20
cde/programs/dtmail/dtmail/DebugMime
Normal file
20
cde/programs/dtmail/dtmail/DebugMime
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/csh
|
||||
#
|
||||
# A script that aids in debugging and testing dtmail
|
||||
#
|
||||
if ( `uname -s` != SunOS ) then
|
||||
echo "Only support SunOS"
|
||||
exit 1
|
||||
endif
|
||||
|
||||
set echo
|
||||
setenv LD_LIBRARY_PATH ../libDtMail:../../../binstall/lib:$LD_LIBRARY_PATH
|
||||
ldd -r dtmail
|
||||
|
||||
setenv ARGS "$*"
|
||||
if ( -f core ) then
|
||||
exec debugger dtmail core &
|
||||
else
|
||||
exec debugger dtmail &
|
||||
endif
|
||||
exit 1
|
||||
151
cde/programs/dtmail/dtmail/Dialog.C
Normal file
151
cde/programs/dtmail/dtmail/Dialog.C
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Dialog.C /main/4 1996/04/21 19:41:15 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include "Dialog.h"
|
||||
#include "Application.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
#include <Xm/DialogS.h>
|
||||
#include <assert.h>
|
||||
#include "Help.hh"
|
||||
|
||||
// The following header is private to CDE and should NOT be required
|
||||
// but unfortunately is.
|
||||
//
|
||||
extern "C" {
|
||||
#include <Dt/HourGlass.h>
|
||||
}
|
||||
|
||||
|
||||
Dialog::Dialog(char *name, RoamMenuWindow *parent) : UIComponent(name)
|
||||
{
|
||||
_parent = parent;
|
||||
_workArea = NULL;
|
||||
|
||||
_w = XtCreatePopupShell(_name,
|
||||
xmDialogShellWidgetClass,
|
||||
parent->baseWidget(),
|
||||
NULL, 0 );
|
||||
|
||||
XtVaSetValues(_w, XmNdefaultPosition, False, NULL);
|
||||
|
||||
assert( theApplication != NULL );
|
||||
}
|
||||
|
||||
Dialog::Dialog(RoamMenuWindow *parent) : UIComponent("")
|
||||
{
|
||||
_parent = parent;
|
||||
_workArea=NULL;
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Dialog::initialize()
|
||||
{
|
||||
|
||||
|
||||
|
||||
XtVaSetValues( _w,
|
||||
XmNdefaultPosition, False, NULL );
|
||||
|
||||
XtAddCallback( _w,
|
||||
XmNpopupCallback,
|
||||
( XtCallbackProc ) &Dialog::popupCallback,
|
||||
XtPointer( this ) );
|
||||
|
||||
XtAddCallback( _w,
|
||||
XmNpopdownCallback,
|
||||
( XtCallbackProc ) &Dialog::popdownCallback,
|
||||
XtPointer( this ) );
|
||||
|
||||
_workArea = createWorkArea ( _w );
|
||||
assert ( _workArea != NULL );
|
||||
printHelpId("_workArea", _workArea);
|
||||
/* add help callback */
|
||||
// XtAddCallback(_workArea, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
if ( !XtIsManaged ( _workArea ) )
|
||||
XtManageChild ( _workArea );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dialog::title(
|
||||
char *text
|
||||
)
|
||||
{
|
||||
XtVaSetValues ( _w, XmNtitle, text, NULL );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dialog::popupCallback( Widget ,
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *
|
||||
)
|
||||
{
|
||||
Dialog *window=( Dialog * ) clientData;
|
||||
|
||||
window->popped_up();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dialog::popdownCallback( Widget , // w
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *
|
||||
)
|
||||
{
|
||||
Dialog *window=( Dialog * ) clientData;
|
||||
|
||||
window->popped_down();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Dialog::manage()
|
||||
{
|
||||
if ( !XtIsManaged ( _workArea ) )
|
||||
XtManageChild ( _workArea );
|
||||
UIComponent::manage();
|
||||
}
|
||||
|
||||
void
|
||||
Dialog::busyCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized.
|
||||
|
||||
if (XtIsRealized(_w)) {
|
||||
_DtTurnOnHourGlass(_w);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Dialog::normalCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized
|
||||
|
||||
if (XtIsRealized(_w)) {
|
||||
_DtTurnOffHourGlass(_w);
|
||||
}
|
||||
}
|
||||
68
cde/programs/dtmail/dtmail/Dialog.h
Normal file
68
cde/programs/dtmail/dtmail/Dialog.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Dialog.h /main/4 1996/04/21 19:41:19 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <UIComponent.h>
|
||||
|
||||
class RoamMenuWindow;
|
||||
|
||||
class Dialog : public UIComponent {
|
||||
|
||||
public:
|
||||
Dialog(char *, RoamMenuWindow *);
|
||||
Dialog(RoamMenuWindow *); // For custom dialogs.
|
||||
|
||||
virtual ~Dialog();
|
||||
virtual void initialize();
|
||||
|
||||
// Accessors
|
||||
|
||||
RoamMenuWindow *parent() { return _parent; };
|
||||
Widget work_area(){ return _workArea; }
|
||||
|
||||
// Mutators
|
||||
|
||||
virtual void title( char * );
|
||||
virtual void popped_up()=0;
|
||||
virtual void popped_down()=0;
|
||||
virtual void popup()=0;
|
||||
virtual void popdown()=0;
|
||||
virtual void manage();
|
||||
virtual void busyCursor();
|
||||
virtual void normalCursor();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual Widget createWorkArea( Widget ) = 0;
|
||||
static void popdownCallback ( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
static void popupCallback( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
|
||||
private:
|
||||
|
||||
Widget _workArea;
|
||||
RoamMenuWindow *_parent;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
177
cde/programs/dtmail/dtmail/DialogShell.C
Normal file
177
cde/programs/dtmail/dtmail/DialogShell.C
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DialogShell.C /main/10 1998/02/03 12:10:06 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Xmu/Editres.h>
|
||||
#include <Xm/Protocols.h>
|
||||
#include <Xm/AtomMgr.h>
|
||||
|
||||
#include <Dt/Wsm.h>
|
||||
#include <Dt/Session.h>
|
||||
#include <DtMail/IO.hh>
|
||||
|
||||
// The following headers are private to CDE and should NOT be required
|
||||
// but unfortunately are.
|
||||
//
|
||||
extern "C" {
|
||||
#include <Dt/HourGlass.h>
|
||||
}
|
||||
#include <Dt/Icon.h>
|
||||
#include <Dt/IconP.h>
|
||||
#include <Dt/IconFile.h>
|
||||
|
||||
#include "DialogShell.h"
|
||||
#include "Application.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
|
||||
|
||||
DialogShell::DialogShell(char *name, RoamMenuWindow *parent, WidgetClass wc)
|
||||
: UIComponent(name)
|
||||
{
|
||||
_parent=parent;
|
||||
_workArea=NULL;
|
||||
_widgetClass=wc;
|
||||
|
||||
assert( theApplication != NULL );
|
||||
}
|
||||
|
||||
DialogShell::~DialogShell()
|
||||
{
|
||||
Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ),
|
||||
"WM_DELETE_WINDOW",
|
||||
False );
|
||||
XmRemoveWMProtocolCallback( _w,
|
||||
WM_DELETE_WINDOW,
|
||||
( XtCallbackProc ) quitCallback,
|
||||
NULL );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::initialize()
|
||||
{
|
||||
_w = XtVaCreatePopupShell(
|
||||
_name, _widgetClass, _parent->baseWidget(),
|
||||
XmNdefaultPosition, False,
|
||||
NULL, 0 );
|
||||
#ifdef USE_EDITRES
|
||||
XtAddEventHandler(
|
||||
_w, (EventMask) 0, True,
|
||||
(XtEventHandler) _XEditResCheckMessages, NULL);
|
||||
#endif
|
||||
|
||||
installDestroyHandler();
|
||||
_workArea = createWorkArea ( _w );
|
||||
assert ( _workArea != NULL );
|
||||
|
||||
XtVaSetValues( _w, XmNdefaultPosition, False, NULL );
|
||||
XtAddCallback( _w,
|
||||
XmNpopupCallback,
|
||||
( XtCallbackProc ) &DialogShell::popupCallback,
|
||||
XtPointer( this ) );
|
||||
XtAddCallback( _w,
|
||||
XmNpopdownCallback,
|
||||
( XtCallbackProc ) &DialogShell::popdownCallback,
|
||||
XtPointer( this ) );
|
||||
|
||||
Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ),
|
||||
"WM_DELETE_WINDOW",
|
||||
False );
|
||||
|
||||
XmAddWMProtocolCallback( _w,
|
||||
WM_DELETE_WINDOW,
|
||||
( XtCallbackProc ) quitCallback,
|
||||
this );
|
||||
|
||||
// if (!XtIsManaged(_workArea)) XtManageChild(_workArea);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::title(
|
||||
char *text
|
||||
)
|
||||
{
|
||||
XtVaSetValues ( _w, XmNtitle, text, NULL );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::popupCallback( Widget ,
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *
|
||||
)
|
||||
{
|
||||
DialogShell *obj=( DialogShell * ) clientData;
|
||||
obj->popped_up();
|
||||
obj->displayInCurrentWorkspace();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::popdownCallback( Widget ,
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *
|
||||
)
|
||||
{
|
||||
DialogShell *obj=( DialogShell * ) clientData;
|
||||
obj->popped_down();
|
||||
}
|
||||
|
||||
void
|
||||
DialogShell::manage()
|
||||
{
|
||||
if (NULL == _workArea) return;
|
||||
if (!XtIsManaged(_workArea )) XtManageChild(_workArea);
|
||||
UIComponent::manage();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::quitCallback( Widget,
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *)
|
||||
{
|
||||
DialogShell *dlg = ( DialogShell *) clientData;
|
||||
dlg->quit();
|
||||
}
|
||||
|
||||
void
|
||||
DialogShell::busyCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized
|
||||
|
||||
if (XtIsRealized(_w)) {
|
||||
_DtTurnOnHourGlass(_w);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DialogShell::normalCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized
|
||||
|
||||
if (XtIsRealized ( _w ))
|
||||
{
|
||||
_DtTurnOffHourGlass(_w);
|
||||
}
|
||||
}
|
||||
71
cde/programs/dtmail/dtmail/DialogShell.h
Normal file
71
cde/programs/dtmail/dtmail/DialogShell.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DialogShell.h /main/5 1998/01/28 18:35:07 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DIALOGSHELL_H
|
||||
#define DIALOGSHELL_H
|
||||
|
||||
#include <Xm/DialogS.h>
|
||||
#include "UIComponent.h"
|
||||
|
||||
class RoamMenuWindow;
|
||||
|
||||
class DialogShell : public UIComponent {
|
||||
|
||||
public:
|
||||
DialogShell(
|
||||
char *name,
|
||||
RoamMenuWindow *parent,
|
||||
WidgetClass wc = xmDialogShellWidgetClass);
|
||||
virtual ~DialogShell();
|
||||
virtual void initialize();
|
||||
|
||||
// Accessors
|
||||
|
||||
RoamMenuWindow *parent() { return _parent; };
|
||||
Widget work_area(){ return _workArea; }
|
||||
|
||||
// Mutators
|
||||
|
||||
virtual void title( char * );
|
||||
virtual void popped_up()=0;
|
||||
virtual void popped_down()=0;
|
||||
virtual void manage();
|
||||
virtual void busyCursor();
|
||||
virtual void normalCursor();
|
||||
|
||||
virtual void quit()=0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual Widget createWorkArea( Widget ) = 0;
|
||||
static void popdownCallback ( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
static void popupCallback( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
Widget _workArea;
|
||||
|
||||
private:
|
||||
|
||||
static void quitCallback( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
|
||||
RoamMenuWindow *_parent;
|
||||
WidgetClass _widgetClass;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
55
cde/programs/dtmail/dtmail/DialogWindow.h
Normal file
55
cde/programs/dtmail/dtmail/DialogWindow.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: DialogWindow.h /main/4 1996/04/21 19:41:28 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DIALOGWINDOW_H
|
||||
#define DIALOGWINDOW_H
|
||||
|
||||
#include "UIComponent.h"
|
||||
|
||||
class RoamMenuWindow;
|
||||
|
||||
class DialogWindow : public UIComponent {
|
||||
|
||||
static void popdownCallback ( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
static void popupCallback( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
|
||||
protected:
|
||||
|
||||
Widget _workArea;
|
||||
RoamMenuWindow *_parent;
|
||||
virtual Widget createWorkArea( Widget ) = 0;
|
||||
|
||||
public:
|
||||
DialogWindow( char *, RoamMenuWindow * );
|
||||
virtual ~DialogWindow();
|
||||
virtual void initialize();
|
||||
|
||||
// Accessors
|
||||
|
||||
RoamMenuWindow *parent() { return _parent; };
|
||||
|
||||
// Mutators
|
||||
|
||||
virtual void title( char * );
|
||||
virtual void popup()=0;
|
||||
virtual void popdown()=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
198
cde/programs/dtmail/dtmail/Dmx.h
Normal file
198
cde/programs/dtmail/dtmail/Dmx.h
Normal file
@@ -0,0 +1,198 @@
|
||||
/* $XConsortium: Dmx.h /main/4 1996/04/21 19:55:42 drk $ */
|
||||
|
||||
#ifndef _DMX_HH
|
||||
#define _DMX_HH
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include <DtMail/DtMailValues.hh>
|
||||
#include <Dt/Dts.h>
|
||||
|
||||
extern const char *const dmxversion;
|
||||
|
||||
typedef enum {
|
||||
DMX_NONE_STRING,
|
||||
DMX_CC_HEADER_STRING,
|
||||
DMX_DATE_HEADER_STRING,
|
||||
DMX_FROM_HEADER_STRING,
|
||||
DMX_SUBJECT_HEADER_STRING,
|
||||
DMX_TO_HEADER_STRING,
|
||||
DMX_PAGE_NUMBER_STRING,
|
||||
DMX_USER_NAME_STRING,
|
||||
/*
|
||||
* KEEP THIS LAST
|
||||
*/
|
||||
DMX_NUM_STRING_TYPE_ENUM
|
||||
} DmxStringTypeEnum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DMX_SEPARATOR_NEW_LINE,
|
||||
DMX_SEPARATOR_BLANK_LINE,
|
||||
DMX_SEPARATOR_CHARACTER_LINE,
|
||||
DMX_SEPARATOR_PAGE_BREAK,
|
||||
DMX_SEPARATOR_NEW_JOB,
|
||||
/*
|
||||
* KEEP THIS LAST
|
||||
*/
|
||||
DMX_NUM_MSG_SEPARATOR_ENUM
|
||||
} DmxMsgSeparatorEnum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DMX_PRINT_HEADERS_NONE,
|
||||
DMX_PRINT_HEADERS_STANDARD,
|
||||
DMX_PRINT_HEADERS_ABBREV,
|
||||
DMX_PRINT_HEADERS_ALL,
|
||||
/*
|
||||
* KEEP THIS LAST
|
||||
*/
|
||||
DMX_NUM_PRINT_HEADERS_ENUM
|
||||
} DmxPrintHeadersEnum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DMXCC,
|
||||
DMXFROM,
|
||||
DMXSUBJ,
|
||||
DMXCLENGTH,
|
||||
DMXSTATUS,
|
||||
DMXDATE,
|
||||
DMXTO,
|
||||
DMXV3CHARSET,
|
||||
DMXCONTENTTYPE,
|
||||
DMXNUMHDRS
|
||||
} DmxHeaders;
|
||||
|
||||
// utils
|
||||
char *convertValueToString (DtMailValueSeq *, int);
|
||||
DtMailBoolean handleError (DtMailEnv &, char *);
|
||||
char *getStandardHeaders (DtMailHeaderLine &);
|
||||
char *errorString (DmxHeaders);
|
||||
|
||||
class DmxMsg
|
||||
{
|
||||
public:
|
||||
|
||||
typedef void (*DmxPrintOutputProc)(XtPointer, char*);
|
||||
|
||||
DmxMsg (void);
|
||||
|
||||
void display (DmxPrintHeadersEnum, DmxPrintOutputProc, XtPointer);
|
||||
void setHandle (DtMailMessageHandle &);
|
||||
void setHeader (DtMailHeaderLine &);
|
||||
void setMessage (DtMail::Message *);
|
||||
void setInfo (char *);
|
||||
void parse (void);
|
||||
char *getPrintedHeaders (DmxPrintHeadersEnum);
|
||||
char *getHeaders (DtMailBoolean);
|
||||
char *getMessageHeader (DmxHeaders);
|
||||
|
||||
|
||||
DtMailMessageHandle msgHandle;
|
||||
DtMailHeaderLine msgHeader;
|
||||
DtMail::Message *message;
|
||||
|
||||
DtMail::BodyPart **bodyParts;
|
||||
int numBPs;
|
||||
|
||||
char *addlInfo;
|
||||
DtMailBoolean cachedValues;
|
||||
DtMailBoolean isNew;
|
||||
// other flags for status (read, unopened, etc.)
|
||||
};
|
||||
|
||||
|
||||
class DmxMailbox
|
||||
{
|
||||
private:
|
||||
void createHeaderRequest (DtMailHeaderRequest &);
|
||||
void printMailboxInfo (void);
|
||||
|
||||
static const int _firstIndex;
|
||||
char *_fileName;
|
||||
DtMail::MailBox *_mbox;
|
||||
DmxMsg _messages[2048];
|
||||
DmxMsg *_message;
|
||||
int _messageCount;
|
||||
public:
|
||||
DmxMailbox (char*);
|
||||
~DmxMailbox (void);
|
||||
|
||||
void loadMessages (void);
|
||||
inline DmxMsg *firstMessage (void)
|
||||
{
|
||||
return (_message = &_messages[_firstIndex]);
|
||||
}
|
||||
inline DmxMsg *nextMessage (void)
|
||||
{
|
||||
_message++;
|
||||
return ((_message <= &_messages[_messageCount]) ?
|
||||
_message :
|
||||
(DmxMsg*)NULL);
|
||||
}
|
||||
inline int numMessages (void) { return _messageCount; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // _DMX_HH
|
||||
212
cde/programs/dtmail/dtmail/DmxMailbox.C
Normal file
212
cde/programs/dtmail/dtmail/DmxMailbox.C
Normal file
@@ -0,0 +1,212 @@
|
||||
/* $XConsortium: DmxMailbox.C /main/3 1996/04/21 19:55:45 drk $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "Dmx.h"
|
||||
#include "MemUtils.hh"
|
||||
#include "RoamApp.h"
|
||||
|
||||
const int DmxMailbox::_firstIndex = 1;
|
||||
|
||||
DmxMailbox::DmxMailbox (char *filename)
|
||||
{
|
||||
_mbox = NULL;
|
||||
_messageCount = 0;
|
||||
_fileName = strdup_n(filename);
|
||||
}
|
||||
|
||||
DmxMailbox::~DmxMailbox (void)
|
||||
{
|
||||
delete(_fileName);
|
||||
if (_mbox)
|
||||
delete (_mbox);
|
||||
}
|
||||
|
||||
void
|
||||
DmxMailbox::loadMessages (void)
|
||||
{
|
||||
DtMailEnv env;
|
||||
DtMailBoolean moreMessages = DTM_TRUE;
|
||||
DtMail::Session *session = theRoamApp.session()->session();
|
||||
|
||||
// try to construct _mbox
|
||||
_mbox = session->mailBoxConstruct (
|
||||
env,
|
||||
DtMailFileObject,
|
||||
_fileName,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if (handleError (env, "new DtMail::MailBox") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
// open the mailbox
|
||||
// (O_RDONLY for now)
|
||||
_mbox->open (env, /* DtMailEnv */
|
||||
DTM_FALSE, /* auto_create */
|
||||
O_RDONLY, /* open(2) flag */
|
||||
(mode_t) 0, /* create(2) mode */
|
||||
DTM_FALSE, /* lock_flag */
|
||||
DTM_TRUE /* auto_parse */
|
||||
);
|
||||
|
||||
if (handleError (env, "open mailbox") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
// get the first message handle
|
||||
DtMailMessageHandle first = NULL, next = NULL, prev = NULL;
|
||||
DtMailHeaderRequest request;
|
||||
DtMailHeaderLine hdrline;
|
||||
int i = _firstIndex;
|
||||
DtMail::Message *m = NULL; // temporary
|
||||
|
||||
createHeaderRequest (request);
|
||||
|
||||
first = _mbox->getFirstMessageSummary (env, request, hdrline);
|
||||
|
||||
if (handleError (env, "get first msg summary") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
if (first == NULL)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"loadMessages: error w/1st message...exiting.\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
// this makes hash of the caching strategy, but oh well....
|
||||
m = _mbox->getMessage (env, first);
|
||||
if (handleError (env, "get first msg") == DTM_TRUE)
|
||||
exit (1);
|
||||
_messages [i].setMessage (m);
|
||||
|
||||
prev = first;
|
||||
|
||||
_messages [i].setHandle (first);
|
||||
_messages [i].setHeader (hdrline);
|
||||
|
||||
while (moreMessages == DTM_TRUE)
|
||||
{
|
||||
next = _mbox->getNextMessageSummary (env, prev,
|
||||
request, hdrline);
|
||||
|
||||
if (next == NULL)
|
||||
{
|
||||
moreMessages = DTM_FALSE;
|
||||
if (handleError (env, "msgLoop") == DTM_TRUE)
|
||||
exit (1);
|
||||
break; // break out if error
|
||||
} else {
|
||||
i++;
|
||||
_messages [i].setHandle (next);
|
||||
_messages [i].setHeader (hdrline);
|
||||
}
|
||||
|
||||
prev = next;
|
||||
}
|
||||
|
||||
_messageCount = i;
|
||||
|
||||
|
||||
// fill in the remaining message structures .. temporary, honest!
|
||||
for (int j = _firstIndex; j <= _messageCount; j++)
|
||||
{
|
||||
m = _mbox->getMessage (env, _messages [j].msgHandle);
|
||||
if (handleError (env, "getMessage loop") == DTM_TRUE)
|
||||
{
|
||||
printf ("fatal error...bailing...\n");
|
||||
exit (1);
|
||||
}
|
||||
_messages [j].setMessage (m);
|
||||
|
||||
char tmp [100];
|
||||
sprintf (tmp, "%d", j); // ick
|
||||
_messages [j].setInfo (tmp);
|
||||
}
|
||||
|
||||
// free header request structure
|
||||
int k;
|
||||
// this assumes that you have allocated all of the possible headers
|
||||
// in the DmxHeaders -- a bad assumption, but currently true
|
||||
for (k = 0; k < DMXNUMHDRS; k++)
|
||||
{
|
||||
free (request.header_name [k]);
|
||||
}
|
||||
delete request.header_name;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMailbox::createHeaderRequest (DtMailHeaderRequest &request)
|
||||
{
|
||||
// set up default headers
|
||||
request.number_of_names = DMXNUMHDRS;
|
||||
request.header_name = new (char* [DMXNUMHDRS]);
|
||||
request.header_name[DMXCC] = strdup(DtMailMessageCc);
|
||||
request.header_name[DMXFROM] = strdup(DtMailMessageSender);
|
||||
request.header_name[DMXSUBJ] = strdup(DtMailMessageSubject);
|
||||
request.header_name[DMXDATE] = strdup(DtMailMessageReceivedTime);
|
||||
request.header_name[DMXCLENGTH] = strdup(DtMailMessageContentLength);
|
||||
request.header_name[DMXSTATUS] = strdup(DtMailMessageStatus);
|
||||
request.header_name[DMXTO] = strdup(DtMailMessageTo);
|
||||
request.header_name[DMXV3CHARSET] = strdup(DtMailMessageV3charset);
|
||||
request.header_name[DMXCONTENTTYPE] = strdup(DtMailMessageContentType);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMailbox::printMailboxInfo (void)
|
||||
{
|
||||
printf ("\"%s\": %d messages\n", _fileName, _messageCount);
|
||||
return;
|
||||
}
|
||||
593
cde/programs/dtmail/dtmail/DmxMessage.C
Normal file
593
cde/programs/dtmail/dtmail/DmxMessage.C
Normal file
@@ -0,0 +1,593 @@
|
||||
/* $TOG: DmxMessage.C /main/6 1998/07/24 16:18:17 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include "Dmx.h"
|
||||
// For CHARSET
|
||||
#include <LocaleXlate.h>
|
||||
#include <locale.h>
|
||||
#if !defined(USL) && !defined(__uxp__)
|
||||
#include <strings.h>
|
||||
#else
|
||||
#include <EUSCompat.h>
|
||||
#endif
|
||||
|
||||
#include "Application.h"
|
||||
#include "DtMail/DtMail.hh"
|
||||
#include "DtMailTypes.h"
|
||||
#include "MailSession.hh"
|
||||
#include "RoamApp.h"
|
||||
#include "str_utils.h"
|
||||
|
||||
|
||||
DmxMsg::DmxMsg (void)
|
||||
{
|
||||
// initialize everything
|
||||
message = NULL;
|
||||
addlInfo = NULL;
|
||||
numBPs = 0;
|
||||
cachedValues = DTM_FALSE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::setHandle (DtMailMessageHandle &h)
|
||||
{
|
||||
msgHandle = h;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::setHeader (DtMailHeaderLine &h)
|
||||
{
|
||||
msgHeader = h;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::setMessage (DtMail::Message *m)
|
||||
{
|
||||
message = m;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::setInfo (char *info)
|
||||
{
|
||||
addlInfo = strdup (info);
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
DmxMsg::getMessageHeader (DmxHeaders which)
|
||||
{
|
||||
int i = 0, length = 0;
|
||||
int buflength = 0;
|
||||
char *rtn;
|
||||
const char *str;
|
||||
|
||||
if (which >= DMXNUMHDRS)
|
||||
return (char *) NULL;
|
||||
|
||||
length = msgHeader.header_values[which].length ();
|
||||
if (length == 0)
|
||||
str = errorString(which);
|
||||
else
|
||||
str = *((msgHeader.header_values[which])[0]);
|
||||
|
||||
//need to free this after using it
|
||||
rtn = strdup(str);
|
||||
return (rtn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char *
|
||||
DmxMsg::getHeaders (DtMailBoolean abbreviated_only)
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session *m_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc *mail_rc = m_session->mailRc(error);
|
||||
DtMail::Envelope *env = message->getEnvelope(error);
|
||||
|
||||
DtMailHeaderHandle hdr_hnd;
|
||||
char *name;
|
||||
DtMailValueSeq value;
|
||||
|
||||
// Code from MsgScrollingList - display_message().
|
||||
// We're trying to reduce heap size by not allocating and
|
||||
// deleting space in every loop iteration. So just have a
|
||||
// fixed size buffer initially.
|
||||
//
|
||||
|
||||
// Initial line size. When not enough, allocate more.
|
||||
int buffer_size = 2048;
|
||||
char *buffer = new char [buffer_size];
|
||||
int count = 0;
|
||||
int hdr_num = 0;
|
||||
char *newline = "\n";
|
||||
char *separator = ": ";
|
||||
int val = 0;
|
||||
|
||||
//
|
||||
// Iterate through each header in the message and add it
|
||||
// to the buffer.
|
||||
//
|
||||
for (hdr_hnd = env->getFirstHeader(error, &name, value), *buffer = '\0';
|
||||
hdr_hnd && !error.isSet();
|
||||
hdr_hnd = env->getNextHeader(error, hdr_hnd, &name, value), hdr_num++)
|
||||
{
|
||||
if (abbreviated_only == DTM_TRUE &&
|
||||
(hdr_num != 0 || strcmp(name, "From") != 0))
|
||||
{
|
||||
DtMailEnv ierror;
|
||||
if (mail_rc->ignore(ierror, name))
|
||||
{
|
||||
free(name);
|
||||
value.clear();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (val=0; val<value.length(); val++)
|
||||
count += strlen(name) +
|
||||
strlen(*(value[val])) +
|
||||
strlen(separator) +
|
||||
strlen(newline) + 1;
|
||||
|
||||
if (count > buffer_size)
|
||||
{
|
||||
// Need to increase buffer size.
|
||||
char *new_buffer;
|
||||
|
||||
buffer_size *= 2;
|
||||
new_buffer = new char [buffer_size];
|
||||
memset(new_buffer, 0, buffer_size);
|
||||
|
||||
strcpy(new_buffer, buffer);
|
||||
delete [] buffer;
|
||||
buffer = new_buffer;
|
||||
}
|
||||
|
||||
for (val=0; val<value.length(); val++)
|
||||
{
|
||||
strcat(buffer, name);
|
||||
|
||||
if (hdr_num != 0 || strcmp(name, "From") != 0)
|
||||
strcat(buffer, separator);
|
||||
else
|
||||
strcat(buffer, " ");
|
||||
|
||||
strcat(buffer, *(value[val]));
|
||||
strcat(buffer, newline);
|
||||
}
|
||||
value.clear();
|
||||
free(name);
|
||||
}
|
||||
|
||||
//
|
||||
// Need to free this after using;
|
||||
//
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char *
|
||||
DmxMsg::getPrintedHeaders (DmxPrintHeadersEnum header_format)
|
||||
{
|
||||
char *newline = "\n";
|
||||
char *buffer = NULL;
|
||||
|
||||
switch (header_format)
|
||||
{
|
||||
case DMX_PRINT_HEADERS_NONE:
|
||||
buffer = new char [strlen(newline) + 1];
|
||||
strcpy(buffer, (const char *) newline);
|
||||
break;
|
||||
case DMX_PRINT_HEADERS_STANDARD:
|
||||
buffer = getStandardHeaders(msgHeader);
|
||||
break;
|
||||
case DMX_PRINT_HEADERS_ABBREV:
|
||||
buffer = getHeaders(DTM_TRUE);
|
||||
break;
|
||||
case DMX_PRINT_HEADERS_ALL:
|
||||
buffer = getHeaders(DTM_FALSE);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "error in DmxMsg::display\n");
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Need to free this after using;
|
||||
//
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxMsg::display (
|
||||
DmxPrintHeadersEnum header_format,
|
||||
DmxPrintOutputProc print_proc,
|
||||
XtPointer stream)
|
||||
{
|
||||
DtMailEnv env;
|
||||
DtMailBoolean FirstIsText = DTM_FALSE;
|
||||
DtMail::BodyPart *firstPart = NULL, *nextpart = NULL;
|
||||
char *buf = NULL,
|
||||
*description = NULL,
|
||||
*name = NULL,
|
||||
*newline = NULL,
|
||||
*sunDataDescription = NULL,
|
||||
*type = NULL;
|
||||
|
||||
void *contents = NULL;
|
||||
unsigned long length = 0;
|
||||
int mode = 0;
|
||||
|
||||
// For CHARSET
|
||||
char v3_cs[64],
|
||||
*mime_cs = NULL,
|
||||
*from_cs = NULL,
|
||||
*to_cs = NULL;
|
||||
|
||||
|
||||
// read in body part info
|
||||
if (cachedValues != DTM_TRUE)
|
||||
parse ();
|
||||
|
||||
firstPart = bodyParts [0];
|
||||
|
||||
firstPart->getContents(env,
|
||||
(const void **) &contents,
|
||||
&length,
|
||||
NULL, //type
|
||||
NULL, //name
|
||||
NULL, //mode
|
||||
NULL); //description
|
||||
|
||||
if (handleError(env, "getContents") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
// For CHARSET
|
||||
DtMailValueSeq value;
|
||||
DtMailBoolean err = DTM_FALSE;
|
||||
|
||||
// Get the bodypart's charset - Try MIME first then V3
|
||||
firstPart->getHeader(env, DtMailMessageContentType, DTM_TRUE, value);
|
||||
if (env.isNotSet()) {
|
||||
mime_cs = firstPart->csFromContentType(value);
|
||||
} else {
|
||||
env.clear();
|
||||
value.clear();
|
||||
firstPart->getHeader(env, DtMailMessageV3charset, DTM_TRUE, value);
|
||||
if (env.isNotSet()) {
|
||||
strcpy(v3_cs, *(value[0]));
|
||||
} else {
|
||||
err = DTM_TRUE;
|
||||
env.clear();
|
||||
value.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// If cannot obtain bodypart's charset header, then maybe this message
|
||||
// has only one bodypart, then in this case the charset header maybe
|
||||
// among the message's envelope (main message headers).
|
||||
// Get the envelope of the message (in order to access the headers)
|
||||
DtMail::Envelope *envelope = NULL;
|
||||
if (err == DTM_TRUE) {
|
||||
envelope = message->getEnvelope(env);
|
||||
err = DTM_FALSE;
|
||||
#ifdef DEBUG
|
||||
env.logError(
|
||||
DTM_FALSE,
|
||||
"DEBUG dtmailpr: Looking at main message header\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check for MIME charset header and then for V3 charset header
|
||||
if (envelope != NULL) {
|
||||
envelope->getHeader(env, DtMailMessageContentType, DTM_TRUE, value);
|
||||
if (env.isNotSet()) {
|
||||
mime_cs = firstPart->csFromContentType(value);
|
||||
} else {
|
||||
err = DTM_TRUE;
|
||||
env.clear();
|
||||
}
|
||||
if (mime_cs == NULL || err == DTM_TRUE) {
|
||||
value.clear();
|
||||
envelope->getHeader(env, DtMailMessageV3charset, DTM_TRUE, value);
|
||||
if (env.isNotSet()) {
|
||||
strcpy(v3_cs, *(value[0]));
|
||||
} else {
|
||||
err = DTM_TRUE;
|
||||
env.clear();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: envelope is null\n");
|
||||
#endif
|
||||
env.clear();
|
||||
}
|
||||
|
||||
// Default codeset in case mime_cs and v3_cs are both null.
|
||||
if ((mime_cs == NULL) && (strlen(v3_cs) == 0)) {
|
||||
char *ret = NULL;
|
||||
firstPart->DtXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,
|
||||
setlocale(LC_CTYPE, NULL),
|
||||
NULL,
|
||||
NULL,
|
||||
&ret);
|
||||
strcpy(v3_cs, "DEFAULT");
|
||||
strcat(v3_cs, ".");
|
||||
strcat(v3_cs, ret);
|
||||
if (ret)
|
||||
free(ret);
|
||||
}
|
||||
|
||||
// Get iconv from and to codeset and do conversion.
|
||||
int converted = 0;
|
||||
if (mime_cs) {
|
||||
from_cs = firstPart->csToConvName(mime_cs);
|
||||
#ifdef DEBUG
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: mime_cs = %s\n", mime_cs);
|
||||
#endif
|
||||
} else {
|
||||
from_cs = firstPart->csToConvName(v3_cs);
|
||||
#ifdef DEBUG
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: v3_cs = %s\n", v3_cs);
|
||||
#endif
|
||||
}
|
||||
to_cs = firstPart->locToConvName();
|
||||
|
||||
#ifdef DEBUG
|
||||
if ( from_cs == NULL )
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: from_cs is NULL\n");
|
||||
else
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: from_cs = %s\n", from_cs);
|
||||
|
||||
if ( to_cs == NULL )
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: to_cs is NULL\n");
|
||||
else
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: to_cs = %s\n", to_cs);
|
||||
#endif
|
||||
|
||||
if ( from_cs && to_cs ) {
|
||||
if ( strcasecmp(from_cs, to_cs) != 0 ) {
|
||||
converted = firstPart->csConvert(
|
||||
(char **)&contents,
|
||||
length,
|
||||
0,
|
||||
from_cs,
|
||||
to_cs);
|
||||
#ifdef DEBUG
|
||||
env.logError(DTM_FALSE,
|
||||
"DEBUG dtmailpr: converted = %d\n", converted);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if ( mime_cs )
|
||||
free ( mime_cs );
|
||||
if ( from_cs )
|
||||
free( from_cs );
|
||||
if ( to_cs )
|
||||
free ( to_cs );
|
||||
|
||||
// End of For CHARSET
|
||||
|
||||
newline = new char [2];
|
||||
newline[0] = '\n';
|
||||
newline[1] = '\0';
|
||||
|
||||
//
|
||||
// Print out the message headers.
|
||||
//
|
||||
buf = getPrintedHeaders(header_format);
|
||||
print_proc(stream, buf);
|
||||
print_proc(stream, newline);
|
||||
delete buf;
|
||||
|
||||
//
|
||||
// Print out the message body.
|
||||
//
|
||||
buf = new char [length + 1];
|
||||
memset (buf, 0, (unsigned int) length + 1);
|
||||
memmove (buf, contents, (unsigned int) length);
|
||||
buf [length] = '\0'; // null-terminate that puppy
|
||||
print_proc(stream, buf);
|
||||
print_proc(stream, newline);
|
||||
delete [] buf;
|
||||
|
||||
// For CHARSET
|
||||
if (converted && contents)
|
||||
free(contents);
|
||||
|
||||
// No attachments? We're done.
|
||||
if (numBPs < 2)
|
||||
return;
|
||||
|
||||
int i = 0, attbuflen = 0;
|
||||
char *attbuf = NULL;
|
||||
char *sunbuf = NULL;
|
||||
|
||||
print_proc(stream, newline);
|
||||
for (i = 1; i < numBPs ; i++)
|
||||
{
|
||||
nextpart = bodyParts [i];
|
||||
|
||||
if (nextpart == NULL)
|
||||
fprintf (stderr, "Error getting part!\n");
|
||||
|
||||
length = 0;
|
||||
type = "";
|
||||
sunDataDescription = "";
|
||||
description = "";
|
||||
name = "";
|
||||
mode = -1;
|
||||
|
||||
nextpart->getContents(env,
|
||||
NULL,
|
||||
&length,
|
||||
&type,
|
||||
&name,
|
||||
&mode,
|
||||
&sunDataDescription);
|
||||
if (handleError (env, "getContents") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
if (type == NULL)
|
||||
type = "(type unknown)";
|
||||
|
||||
if (name == NULL)
|
||||
name = "(name unknown)";
|
||||
|
||||
if (sunDataDescription == NULL)
|
||||
{
|
||||
description = "";
|
||||
} else {
|
||||
// should add bracket or something
|
||||
sunbuf = new char [strlen (sunDataDescription) + 10];
|
||||
sprintf(sunbuf, " (%s)", sunDataDescription);
|
||||
description = sunbuf;
|
||||
}
|
||||
|
||||
attbuflen = strlen(name) + strlen(type) + strlen(description);
|
||||
attbuf = new char [attbuflen + 64];
|
||||
sprintf(attbuf,
|
||||
"[%d] \"%s\"%s, %s, %ld bytes",
|
||||
i,
|
||||
name,
|
||||
description,
|
||||
type,
|
||||
length);
|
||||
print_proc(stream, attbuf);
|
||||
print_proc(stream, newline);
|
||||
delete [] attbuf;
|
||||
|
||||
if (sunbuf != NULL)
|
||||
delete [] sunbuf;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::parse (void)
|
||||
{
|
||||
// store the body parts for later reference
|
||||
|
||||
DtMailEnv env;
|
||||
DtMailBoolean FirstIsText = DTM_FALSE;
|
||||
DtMail::BodyPart *part = NULL, *nextpart = NULL;
|
||||
char *type = NULL, *attr = NULL;
|
||||
|
||||
int bc = message->getBodyCount (env);
|
||||
if (handleError (env, "getBodyCount") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
part = message->getFirstBodyPart (env);
|
||||
if (handleError (env, "getFirstBodyPart") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
part->getContents (env, NULL, NULL, &type, NULL, NULL, NULL);
|
||||
if (handleError (env, "getContents") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
bodyParts = new (DtMail::BodyPart *[bc]);
|
||||
cachedValues = DTM_TRUE;
|
||||
|
||||
// cache values
|
||||
bodyParts [0] = part;
|
||||
numBPs++;
|
||||
|
||||
|
||||
if (type != NULL)
|
||||
{
|
||||
attr = DtDtsDataTypeToAttributeValue (type,
|
||||
DtDTS_DA_IS_TEXT,
|
||||
NULL);
|
||||
if (attr != NULL)
|
||||
{
|
||||
FirstIsText = DTM_TRUE;
|
||||
}
|
||||
//free (type); // it's allocating some data for us
|
||||
} else {
|
||||
FirstIsText = DTM_FALSE;
|
||||
}
|
||||
|
||||
// No attachments? We're done.
|
||||
if (bc < 2)
|
||||
return;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 1; i < bc; i++)
|
||||
{
|
||||
nextpart = NULL;
|
||||
nextpart = message->getNextBodyPart (env,
|
||||
part);
|
||||
if (handleError (env, "getNextBodyPart") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
if (nextpart == NULL)
|
||||
fprintf (stderr, "Error getting part!\n");
|
||||
|
||||
|
||||
bodyParts [i] = nextpart;
|
||||
numBPs++;
|
||||
|
||||
part = nextpart;
|
||||
}
|
||||
}
|
||||
|
||||
1127
cde/programs/dtmail/dtmail/DmxPrintJob.C
Normal file
1127
cde/programs/dtmail/dtmail/DmxPrintJob.C
Normal file
File diff suppressed because it is too large
Load Diff
129
cde/programs/dtmail/dtmail/DmxPrintJob.h
Normal file
129
cde/programs/dtmail/dtmail/DmxPrintJob.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/* $XConsortium: DmxPrintJob.h /main/3 1996/04/12 14:12:32 mgreess $ */
|
||||
|
||||
#ifndef _DMX_PRINT_JOB_H
|
||||
#define _DMX_PRINT_JOB_H
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include "Dmx.h"
|
||||
#include "DmxPrintOptions.h"
|
||||
#include "DmxPrintOutput.h"
|
||||
#include "DmxPrintSetup.h"
|
||||
#include "DtMailTypes.h"
|
||||
#include "MainWindow.h"
|
||||
#include "OptCmd.h"
|
||||
#include "UIComponent.h"
|
||||
|
||||
typedef struct _dmx_msg_info
|
||||
{
|
||||
int end_position;
|
||||
DmxMsg *msg;
|
||||
} DmxMsgInfo;
|
||||
|
||||
class DmxPrintJob : public UIComponent
|
||||
{
|
||||
private:
|
||||
DmxMsg *_next_msg;
|
||||
char *_filename;
|
||||
DmxMailbox *_mailbox;
|
||||
MainWindow *_parent;
|
||||
DmxPrintOutput *_print_output;
|
||||
DmxPrintSetup *_print_setup;
|
||||
DtPrintSetupData *_print_data;
|
||||
Widget _pshell;
|
||||
DtMailBoolean _silent;
|
||||
|
||||
DmxMsgInfo *_spool_msg_info;
|
||||
int _spool_nmsgs_done;
|
||||
int _spool_nmsgs_total;
|
||||
int _spool_npages_done;
|
||||
int _spool_npages_total;
|
||||
|
||||
#ifndef USE_XP_SERVER
|
||||
Widget _nextpage_shell;
|
||||
Widget _nextpage_button;
|
||||
#endif
|
||||
static void cancelCB (Widget, XtPointer, XtPointer);
|
||||
static void closeDisplayCB (Widget, XtPointer, XtPointer);
|
||||
static void pdmNotificationCB (Widget, XtPointer, XtPointer);
|
||||
static void pdmSetupCB (Widget, XtPointer, XtPointer);
|
||||
static void printCB (Widget, XtPointer, XtPointer);
|
||||
static void printOnePageCB (Widget, XtPointer, XtPointer);
|
||||
|
||||
void createPrintShell (void);
|
||||
void createOutputWidgets (void);
|
||||
void doPrint (void);
|
||||
static void finishedPrintToFile(
|
||||
Display*,
|
||||
XPContext,
|
||||
XPGetDocStatus,
|
||||
XPointer);
|
||||
char * getPageHeaderString( DmxMsg*, DmxStringTypeEnum);
|
||||
Boolean loadOutputWidgets (void);
|
||||
void updatePageHeaders(
|
||||
DmxMsg*,
|
||||
DmxStringTypeEnum,
|
||||
DmxStringTypeEnum,
|
||||
DmxStringTypeEnum,
|
||||
DmxStringTypeEnum);
|
||||
public:
|
||||
DmxPrintJob (char*, DtMailBoolean, MainWindow*);
|
||||
~DmxPrintJob (void);
|
||||
|
||||
void cancel (void);
|
||||
void execute (void);
|
||||
};
|
||||
|
||||
#endif // _DMX_PRINT_JOB_H
|
||||
694
cde/programs/dtmail/dtmail/DmxPrintOptions.C
Normal file
694
cde/programs/dtmail/dtmail/DmxPrintOptions.C
Normal file
@@ -0,0 +1,694 @@
|
||||
/* $TOG: DmxPrintOptions.C /main/8 1997/04/30 09:44:12 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Dt/PrintOptionsP.h>
|
||||
|
||||
#include "Dmx.h"
|
||||
#include "DmxPrintOptions.h"
|
||||
#include "DtMail.hh"
|
||||
#include "DtMailError.hh"
|
||||
#include "dtmailopts.h"
|
||||
#include "IndexedOptionMenuUiItem.hh"
|
||||
#include "MailMsg.h"
|
||||
#include "RoamApp.h"
|
||||
#include "TextFieldUiItem.hh"
|
||||
|
||||
#define DMX_ARRAY_SIZE(ary) (sizeof((ary))/sizeof((ary)[0]))
|
||||
|
||||
static DmxpoPropKey hdrftr_keys[] =
|
||||
{
|
||||
{ (int) DTPRINT_OPTION_HEADER_LEFT,
|
||||
DMX_PROPKEY_HEADER_LEFT,
|
||||
DMX_PROPVAL_SUBJECT_HEADER
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_HEADER_RIGHT,
|
||||
DMX_PROPKEY_HEADER_RIGHT,
|
||||
DMX_PROPVAL_EMPTY
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_FOOTER_LEFT,
|
||||
DMX_PROPKEY_FOOTER_LEFT,
|
||||
DMX_PROPVAL_USER_NAME
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_FOOTER_RIGHT,
|
||||
DMX_PROPKEY_FOOTER_RIGHT,
|
||||
DMX_PROPVAL_PAGE_NUMBER
|
||||
}
|
||||
};
|
||||
|
||||
static DmxpoPropKey margin_keys[] =
|
||||
{
|
||||
{ (int) DTPRINT_OPTION_MARGIN_TOP,
|
||||
DMX_PROPKEY_MARGIN_TOP,
|
||||
DMX_PROPVAL_DFLT_MARGIN
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_MARGIN_LEFT,
|
||||
DMX_PROPKEY_MARGIN_LEFT,
|
||||
DMX_PROPVAL_DFLT_MARGIN
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_MARGIN_BOTTOM,
|
||||
DMX_PROPKEY_MARGIN_BOTTOM,
|
||||
DMX_PROPVAL_DFLT_MARGIN
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_MARGIN_RIGHT,
|
||||
DMX_PROPKEY_MARGIN_RIGHT,
|
||||
DMX_PROPVAL_DFLT_MARGIN
|
||||
}
|
||||
};
|
||||
|
||||
static DmxpoPropValue hdrftr_values[] =
|
||||
{
|
||||
{ (int) DMX_NONE_STRING,
|
||||
DMX_PROPVAL_EMPTY,
|
||||
22, 1, "Empty"
|
||||
},
|
||||
{ (int) DMX_CC_HEADER_STRING,
|
||||
DMX_PROPVAL_CC_HEADER,
|
||||
22, 2, "CC Header"
|
||||
},
|
||||
{ (int) DMX_DATE_HEADER_STRING,
|
||||
DMX_PROPVAL_DATE_HEADER,
|
||||
22, 3, "Date Header"
|
||||
},
|
||||
{ (int) DMX_FROM_HEADER_STRING,
|
||||
DMX_PROPVAL_FROM_HEADER,
|
||||
22, 4, "From Header"
|
||||
},
|
||||
{ (int) DMX_SUBJECT_HEADER_STRING,
|
||||
DMX_PROPVAL_SUBJECT_HEADER,
|
||||
22, 5, "Subject Header"
|
||||
},
|
||||
{ (int) DMX_TO_HEADER_STRING,
|
||||
DMX_PROPVAL_TO_HEADER,
|
||||
22, 6, "To Header"
|
||||
},
|
||||
{ (int) DMX_PAGE_NUMBER_STRING,
|
||||
DMX_PROPVAL_PAGE_NUMBER,
|
||||
22, 7, "Page Number"
|
||||
},
|
||||
{ (int) DMX_USER_NAME_STRING,
|
||||
DMX_PROPVAL_USER_NAME,
|
||||
22, 8, "User Name"
|
||||
}
|
||||
};
|
||||
|
||||
static DmxpoPropValue prthdr_values[] =
|
||||
{
|
||||
{ (int) DMX_PRINT_HEADERS_NONE,
|
||||
DMX_PROPVAL_NONE,
|
||||
23, 1, "None" },
|
||||
{ (int) DMX_PRINT_HEADERS_STANDARD,
|
||||
DMX_PROPVAL_STANDARD,
|
||||
23, 2, "Standard" },
|
||||
{ (int) DMX_PRINT_HEADERS_ABBREV,
|
||||
DMX_PROPVAL_ABBREVIATED,
|
||||
23, 3, "Abbreviated" },
|
||||
{ (int) DMX_PRINT_HEADERS_ALL,
|
||||
DMX_PROPVAL_ALL,
|
||||
23, 4, "All" }
|
||||
};
|
||||
|
||||
static DmxpoPropValue msgsep_values[] =
|
||||
{
|
||||
{ (int) DMX_SEPARATOR_NEW_LINE,
|
||||
DMX_PROPVAL_NEW_LINE,
|
||||
24, 1, "New Line" },
|
||||
{ (int) DMX_SEPARATOR_BLANK_LINE,
|
||||
DMX_PROPVAL_BLANK_LINE,
|
||||
24, 2, "Blank Line" },
|
||||
{ (int) DMX_SEPARATOR_CHARACTER_LINE,
|
||||
DMX_PROPVAL_CHARACTER_LINE,
|
||||
24, 3, "Character Line" },
|
||||
{ (int) DMX_SEPARATOR_PAGE_BREAK,
|
||||
DMX_PROPVAL_PAGE_BREAK,
|
||||
24, 4, "New Page" }
|
||||
};
|
||||
|
||||
|
||||
|
||||
DmxPrintOptions::DmxPrintOptions (
|
||||
Widget parent
|
||||
) : UIComponent( "PrintOptions" )
|
||||
{
|
||||
IndexedOptionMenu *iom = (IndexedOptionMenu *) NULL;
|
||||
PropUiItem *pui = (PropUiItem *) NULL;
|
||||
Widget *menu_buttons, w;
|
||||
int nitems;
|
||||
char **strings;
|
||||
void **data;
|
||||
XmString xms;
|
||||
|
||||
_iom_array = new DtVirtArray<IndexedOptionMenu *>(10);
|
||||
_propui_array = new DtVirtArray<PropUiItem *>(10);
|
||||
_propui_array_iterator = 0;
|
||||
_parent = parent;
|
||||
|
||||
//
|
||||
// Create form to hold the printing options
|
||||
//
|
||||
_form = XtVaCreateWidget(
|
||||
"PrintingOptionsPane",
|
||||
xmFormWidgetClass,
|
||||
_parent,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNresizePolicy, XmRESIZE_ANY,
|
||||
NULL
|
||||
);
|
||||
if (_form == (Widget) NULL) return;
|
||||
_w = _form;
|
||||
installDestroyHandler();
|
||||
|
||||
//
|
||||
// Create GUI for the Header/Footer options
|
||||
//
|
||||
nitems = DMX_ARRAY_SIZE(hdrftr_values);;
|
||||
strings = (char **) XtMalloc( nitems * sizeof(char*) );
|
||||
data = (void **) XtMalloc( nitems * sizeof(void*) );
|
||||
for (int i=0; i<nitems; i++)
|
||||
{
|
||||
data[i] = (void*) hdrftr_values[i].prop_string;
|
||||
strings[i] = GETMSG(
|
||||
DT_catd,
|
||||
hdrftr_values[i].set_id,
|
||||
hdrftr_values[i].msg_id,
|
||||
hdrftr_values[i].dflt_string
|
||||
);
|
||||
}
|
||||
|
||||
_hdrftr_frame = _DtPrintCreateHdrFtrFrame( _form, nitems, strings, data);
|
||||
XtVaSetValues(
|
||||
_hdrftr_frame,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL
|
||||
);
|
||||
XtManageChild(_hdrftr_frame);
|
||||
|
||||
//
|
||||
// Create PropUiItem's for the Header/Footer options
|
||||
//
|
||||
menu_buttons = NULL;
|
||||
_DtPrintHdrFtrFrameMenuWidgets( _hdrftr_frame, NULL, NULL, &menu_buttons);
|
||||
for (int j=0, nhdrftrs=DMX_ARRAY_SIZE(hdrftr_keys); j<nhdrftrs; j++)
|
||||
{
|
||||
w = _DtPrintHdrFtrFrameEnumToWidget(
|
||||
_hdrftr_frame,
|
||||
(_DtPrintHdrFtrEnum) hdrftr_keys[j].which
|
||||
);
|
||||
iom =
|
||||
new IndexedOptionMenu(w, nitems, (char**)strings, data, menu_buttons);
|
||||
iom->manage();
|
||||
_iom_array->append(iom);
|
||||
|
||||
pui = (PropUiItem *) new IndexedOptionMenuUiItem(
|
||||
iom,
|
||||
_FROM_MAILRC,
|
||||
hdrftr_keys[j].key
|
||||
);
|
||||
_propui_array->append(pui);
|
||||
}
|
||||
XtFree((char*) menu_buttons);
|
||||
XtFree((char*) data);
|
||||
XtFree((char*) strings);
|
||||
|
||||
|
||||
//
|
||||
// Create GUI for the Margin options
|
||||
//
|
||||
_margin_frame = _DtPrintCreateMarginFrame(_form);
|
||||
XtVaSetValues(
|
||||
_margin_frame,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _hdrftr_frame,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL
|
||||
);
|
||||
XtManageChild(_margin_frame);
|
||||
|
||||
//
|
||||
// Create PropUiItem's for the Margin options
|
||||
//
|
||||
nitems = DMX_ARRAY_SIZE(margin_keys);
|
||||
for (j=0; j<nitems; j++)
|
||||
{
|
||||
w = _DtPrintMarginFrameEnumToWidget(
|
||||
_margin_frame,
|
||||
(_DtPrintMarginEnum) margin_keys[j].which
|
||||
);
|
||||
pui = (PropUiItem *) new TextFieldUiItem(
|
||||
w,
|
||||
_FROM_MAILRC,
|
||||
margin_keys[j].key,
|
||||
DmxPrintOptions::isValidMarginSpec,
|
||||
(void*) margin_keys[j].which);
|
||||
_propui_array->append(pui);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Create GUI for the Printed Headers option
|
||||
//
|
||||
nitems = DMX_ARRAY_SIZE(prthdr_values);;
|
||||
strings = (char **) XtMalloc( nitems * sizeof(char*) );
|
||||
data = (void **) XtMalloc( nitems * sizeof(void*) );
|
||||
for (i=0; i<nitems; i++)
|
||||
{
|
||||
data[i] = (void*) prthdr_values[i].prop_string;
|
||||
strings[i] = GETMSG(
|
||||
DT_catd,
|
||||
prthdr_values[i].set_id,
|
||||
prthdr_values[i].msg_id,
|
||||
prthdr_values[i].dflt_string
|
||||
);
|
||||
}
|
||||
|
||||
iom = new IndexedOptionMenu(_form, nitems, (char**) strings, data);
|
||||
xms = XmStringCreateLocalized(
|
||||
GETMSG(DT_catd, 25, 1, "Printed Message Headers: ")
|
||||
);
|
||||
XtVaSetValues(
|
||||
iom->baseWidget(),
|
||||
XmNlabelString, xms,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _margin_frame,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL
|
||||
);
|
||||
iom->manage();
|
||||
_prthdr_iom = iom;
|
||||
_iom_array->append(iom);
|
||||
|
||||
XmStringFree(xms);
|
||||
XtFree((char*) strings);
|
||||
XtFree((char*) data);
|
||||
|
||||
//
|
||||
// Create PropUiItem for the Printed Headers option
|
||||
//
|
||||
pui = (PropUiItem *) new IndexedOptionMenuUiItem(
|
||||
iom,
|
||||
_FROM_MAILRC,
|
||||
DMX_PROPKEY_PRINT_HEADERS
|
||||
);
|
||||
_propui_array->append(pui);
|
||||
|
||||
|
||||
//
|
||||
// Create GUI for the Message Separator option
|
||||
//
|
||||
nitems = DMX_ARRAY_SIZE(msgsep_values);;
|
||||
strings = (char **) XtMalloc( nitems * sizeof(char*) );
|
||||
data = (void **) XtMalloc( nitems * sizeof(void*) );
|
||||
for (i=0; i<nitems; i++)
|
||||
{
|
||||
data[i] = (void*) msgsep_values[i].prop_string;
|
||||
strings[i] = GETMSG(
|
||||
DT_catd,
|
||||
msgsep_values[i].set_id,
|
||||
msgsep_values[i].msg_id,
|
||||
msgsep_values[i].dflt_string
|
||||
);
|
||||
}
|
||||
|
||||
iom = new IndexedOptionMenu(_form, nitems, (char**) strings, data);
|
||||
xms = XmStringCreateLocalized(
|
||||
GETMSG( DT_catd, 25, 2, "Separate Multiple Messages With: ")
|
||||
);
|
||||
XtVaSetValues(
|
||||
iom->baseWidget(),
|
||||
XmNlabelString, xms,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _prthdr_iom->baseWidget(),
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL
|
||||
);
|
||||
iom->manage();
|
||||
_iom_array->append(iom);
|
||||
_msgsep_iom = iom;
|
||||
|
||||
XmStringFree(xms);
|
||||
XtFree((char*) strings);
|
||||
XtFree((char*) data);
|
||||
|
||||
//
|
||||
// Create PropUiItem for the Message Separator option
|
||||
//
|
||||
pui = (PropUiItem *) new IndexedOptionMenuUiItem(
|
||||
iom,
|
||||
_FROM_MAILRC,
|
||||
DMX_PROPKEY_MESSAGE_SEPARATOR);
|
||||
_propui_array->append(pui);
|
||||
|
||||
//XtRealizeWidget(_w);
|
||||
//XtManageChild(_w);
|
||||
}
|
||||
|
||||
|
||||
DmxPrintOptions::~DmxPrintOptions (void)
|
||||
{
|
||||
int i;
|
||||
PropUiItem *pui;;
|
||||
IndexedOptionMenu *iom;
|
||||
|
||||
if (_propui_array)
|
||||
for (i=0; i<_propui_array->length(); i++)
|
||||
{
|
||||
pui = (*_propui_array)[i];
|
||||
delete pui;
|
||||
}
|
||||
|
||||
if (_iom_array)
|
||||
for (i=0; i<_iom_array->length(); i++)
|
||||
{
|
||||
iom = (*_iom_array)[i];
|
||||
delete iom;
|
||||
}
|
||||
|
||||
if (_w)
|
||||
XtDestroyWidget(_w);
|
||||
}
|
||||
|
||||
PropUiItem *
|
||||
DmxPrintOptions::getFirstProp(void)
|
||||
{
|
||||
_propui_array_iterator = 0;
|
||||
return getNextProp();
|
||||
}
|
||||
|
||||
PropUiItem *
|
||||
DmxPrintOptions::getNextProp(void)
|
||||
{
|
||||
PropUiItem *pui = (PropUiItem *) NULL;
|
||||
|
||||
if (_propui_array_iterator < _propui_array->length())
|
||||
{
|
||||
pui = (*_propui_array)[_propui_array_iterator];
|
||||
_propui_array_iterator++;
|
||||
}
|
||||
return pui;
|
||||
}
|
||||
|
||||
int
|
||||
DmxPrintOptions::getNumProps(void)
|
||||
{
|
||||
return _propui_array->length();
|
||||
}
|
||||
|
||||
const char *
|
||||
DmxPrintOptions::getSeparatorString(void)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
const char *string = NULL;
|
||||
char *dflt = "-";
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
m_rc->getValue(error, DMX_PROPKEY_SEPARATOR_STRING, &string);
|
||||
if (string == NULL || error.isSet())
|
||||
return strdup(dflt);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
DmxStringTypeEnum
|
||||
DmxPrintOptions::getHdrFtrSpec(_DtPrintHdrFtrEnum which)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
DmxpoPropKey *key;
|
||||
const char *string = NULL;
|
||||
DmxpoPropValue *value = NULL;
|
||||
DmxStringTypeEnum rtn = DMX_NONE_STRING;
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
key = DmxPrintOptions::enumToPropKey(
|
||||
which,
|
||||
DMX_ARRAY_SIZE(hdrftr_keys),
|
||||
hdrftr_keys
|
||||
);
|
||||
|
||||
if (key != NULL)
|
||||
{
|
||||
m_rc->getValue(error, key->key , &string);
|
||||
if (string == NULL || error.isSet())
|
||||
string = strdup(key->dflt_prop_string);
|
||||
}
|
||||
else
|
||||
return rtn;
|
||||
|
||||
value = stringToPropValue(
|
||||
string,
|
||||
DMX_ARRAY_SIZE(hdrftr_values),
|
||||
hdrftr_values);
|
||||
if (value != NULL)
|
||||
rtn = (DmxStringTypeEnum) value->which;
|
||||
|
||||
if (NULL != string)
|
||||
free((void*) string);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
const char *
|
||||
DmxPrintOptions::getMarginSpec(_DtPrintMarginEnum which)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
DmxpoPropKey *key;
|
||||
const char *string = NULL;
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
key = DmxPrintOptions::enumToPropKey(
|
||||
which,
|
||||
DMX_ARRAY_SIZE(margin_keys),
|
||||
margin_keys
|
||||
);
|
||||
|
||||
if (key == NULL)
|
||||
return DMX_PROPVAL_DFLT_MARGIN;
|
||||
|
||||
m_rc->getValue(error, key->key , &string);
|
||||
if (string == NULL || error.isSet())
|
||||
string = strdup(key->dflt_prop_string);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
DmxMsgSeparatorEnum
|
||||
DmxPrintOptions::getMessageSeparator(void)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
const char *string = NULL;
|
||||
DmxpoPropValue *value = NULL;
|
||||
DmxMsgSeparatorEnum rtn = DMX_SEPARATOR_PAGE_BREAK;
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
m_rc->getValue(error, DMX_PROPKEY_MESSAGE_SEPARATOR , &string);
|
||||
if (string == NULL || error.isSet())
|
||||
return rtn;
|
||||
|
||||
value = stringToPropValue(
|
||||
string,
|
||||
DMX_ARRAY_SIZE(msgsep_values),
|
||||
msgsep_values);
|
||||
if (value != NULL)
|
||||
rtn = (DmxMsgSeparatorEnum) value->which;
|
||||
|
||||
if (NULL != string)
|
||||
free((void*) string);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
DmxPrintHeadersEnum
|
||||
DmxPrintOptions::getPrintedHeaders(void)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
const char *string = NULL;
|
||||
DmxpoPropValue *value = NULL;
|
||||
DmxPrintHeadersEnum rtn = DMX_PRINT_HEADERS_STANDARD;
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
m_rc->getValue(error, DMX_PROPKEY_PRINT_HEADERS , &string);
|
||||
if (string == NULL || error.isSet())
|
||||
return rtn;
|
||||
|
||||
value = stringToPropValue(
|
||||
string,
|
||||
DMX_ARRAY_SIZE(prthdr_values),
|
||||
prthdr_values);
|
||||
if (value != NULL)
|
||||
rtn = (DmxPrintHeadersEnum) value->which;
|
||||
|
||||
if (NULL != string)
|
||||
free((void*) string);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
DmxpoPropKey *
|
||||
DmxPrintOptions::enumToPropKey(int which, int nkeys, DmxpoPropKey *keys)
|
||||
{
|
||||
for (int i=0; i<nkeys; i++)
|
||||
if (keys[i].which == which)
|
||||
return &(keys[i]);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PropUiItem *
|
||||
DmxPrintOptions::propKeyToPropItem(char *key)
|
||||
{
|
||||
for (int i=0; i<_propui_array->length(); i++)
|
||||
{
|
||||
PropUiItem *pui;
|
||||
char *puikey;
|
||||
|
||||
pui = (*_propui_array)[i];
|
||||
puikey = pui->getKey();
|
||||
if (strcmp(puikey, key) == 0)
|
||||
return pui;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DmxpoPropValue *
|
||||
DmxPrintOptions::stringToPropValue(
|
||||
const char *string,
|
||||
int nvalues,
|
||||
DmxpoPropValue *values
|
||||
)
|
||||
{
|
||||
for (int i=0; i<nvalues; i++)
|
||||
if (strcmp(values[i].prop_string, string) == 0)
|
||||
return &(values[i]);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
DmxPrintOptions::isValidMarginSpec(PropUiItem* pui, void* data)
|
||||
{
|
||||
char *i18nMsg;
|
||||
char *errMsg = NULL;
|
||||
char *marginSpec = NULL;
|
||||
XtEnum parseError;
|
||||
Widget text;
|
||||
_DtPrintMarginEnum which = (_DtPrintMarginEnum) data;
|
||||
|
||||
text = pui->getWidget();
|
||||
if (text)
|
||||
marginSpec = _DtPrintGetMarginSpec(text);
|
||||
|
||||
parseError = FALSE;
|
||||
if (marginSpec == NULL || strcmp("", marginSpec) == 0)
|
||||
parseError = TRUE;
|
||||
else
|
||||
(void) XmConvertStringToUnits(
|
||||
XtScreenOfObject(text),
|
||||
marginSpec,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&parseError);
|
||||
|
||||
if (! parseError) return NULL;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_MARGIN_TOP:
|
||||
i18nMsg =
|
||||
GETMSG(DT_catd, 26, 1, "Top Margin specifier is invalid: ");
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_RIGHT:
|
||||
i18nMsg =
|
||||
GETMSG(DT_catd, 26, 2, "Right Margin specifier is invalid: ");
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_BOTTOM:
|
||||
i18nMsg =
|
||||
GETMSG(DT_catd, 26, 3, "Bottom Margin specifier is invalid: ");
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_LEFT:
|
||||
i18nMsg =
|
||||
GETMSG(DT_catd, 26, 4, "Left Margin specifier is invalid: ");
|
||||
break;
|
||||
}
|
||||
errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
|
||||
sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
|
||||
|
||||
return errMsg;
|
||||
}
|
||||
165
cde/programs/dtmail/dtmail/DmxPrintOptions.h
Normal file
165
cde/programs/dtmail/dtmail/DmxPrintOptions.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/* $XConsortium: DmxPrintOptions.h /main/6 1996/09/23 13:15:43 mgreess $ */
|
||||
|
||||
#ifndef _DMX_PRINT_OPTIONS_H
|
||||
#define _DMX_PRINT_OPTIONS_H
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <Dt/PrintOptionsP.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include "Dmx.h"
|
||||
#include "IndexedOptionMenu.h"
|
||||
#include "UIComponent.h"
|
||||
|
||||
#define DMX_PROPKEY_HEADER_LEFT "headerleft"
|
||||
#define DMX_PROPKEY_HEADER_RIGHT "headerright"
|
||||
#define DMX_PROPKEY_FOOTER_LEFT "footerleft"
|
||||
#define DMX_PROPKEY_FOOTER_RIGHT "footerright"
|
||||
|
||||
#define DMX_PROPKEY_MARGIN_TOP "margintop"
|
||||
#define DMX_PROPKEY_MARGIN_RIGHT "marginright"
|
||||
#define DMX_PROPKEY_MARGIN_BOTTOM "marginbottom"
|
||||
#define DMX_PROPKEY_MARGIN_LEFT "marginleft"
|
||||
|
||||
#define DMX_PROPKEY_PRINT_HEADERS "printheaders"
|
||||
#define DMX_PROPKEY_MESSAGE_SEPARATOR "messageseparator"
|
||||
#define DMX_PROPKEY_SEPARATOR_STRING "separatorstring"
|
||||
|
||||
#define DMX_PROPVAL_EMPTY "Empty"
|
||||
#define DMX_PROPVAL_CC_HEADER "CCHeader"
|
||||
#define DMX_PROPVAL_DATE_HEADER "DateHeader"
|
||||
#define DMX_PROPVAL_FROM_HEADER "FromHeader"
|
||||
#define DMX_PROPVAL_SUBJECT_HEADER "SubjectHeader"
|
||||
#define DMX_PROPVAL_TO_HEADER "ToHeader"
|
||||
#define DMX_PROPVAL_PAGE_NUMBER "PageNumber"
|
||||
#define DMX_PROPVAL_USER_NAME "UserName"
|
||||
|
||||
#define DMX_PROPVAL_DFLT_MARGIN "1.0 in"
|
||||
|
||||
#define DMX_PROPVAL_NONE "None"
|
||||
#define DMX_PROPVAL_STANDARD "Standard"
|
||||
#define DMX_PROPVAL_ABBREVIATED "Abbreviated"
|
||||
#define DMX_PROPVAL_ALL "All"
|
||||
|
||||
#define DMX_PROPVAL_NEW_LINE "NewLine"
|
||||
#define DMX_PROPVAL_BLANK_LINE "BlankLine"
|
||||
#define DMX_PROPVAL_CHARACTER_LINE "CharacterLine"
|
||||
#define DMX_PROPVAL_PAGE_BREAK "PageBreak"
|
||||
#define DMX_PROPVAL_NEW_JOB "NewJob"
|
||||
|
||||
struct DmxpoPropKey
|
||||
{
|
||||
int which;
|
||||
char *key;
|
||||
char *dflt_prop_string;
|
||||
};
|
||||
|
||||
struct DmxpoPropValue
|
||||
{
|
||||
int which;
|
||||
char *prop_string;
|
||||
int set_id;
|
||||
int msg_id;
|
||||
char *dflt_string;
|
||||
};
|
||||
|
||||
class DmxPrintOptions : public UIComponent
|
||||
{
|
||||
|
||||
private:
|
||||
DtVirtArray<IndexedOptionMenu *>
|
||||
*_iom_array;
|
||||
DtVirtArray<PropUiItem *>
|
||||
*_propui_array;
|
||||
int _propui_array_iterator;
|
||||
|
||||
Widget _parent;
|
||||
Widget _form;
|
||||
|
||||
Widget _hdrftr_frame;
|
||||
Widget _margin_frame;
|
||||
|
||||
IndexedOptionMenu *_msgsep_iom;
|
||||
IndexedOptionMenu *_prthdr_iom;
|
||||
|
||||
PropSource *_prop_source;
|
||||
|
||||
PropUiItem *propKeyToPropItem(char*);
|
||||
static DmxpoPropKey *enumToPropKey(int, int, DmxpoPropKey*);
|
||||
static DmxpoPropValue *stringToPropValue(
|
||||
const char*,
|
||||
int,
|
||||
DmxpoPropValue*);
|
||||
static char *isValidMarginSpec(
|
||||
PropUiItem*,
|
||||
void*);
|
||||
public:
|
||||
|
||||
DmxPrintOptions ( Widget );
|
||||
~DmxPrintOptions (void);
|
||||
|
||||
PropUiItem *getFirstProp(void);
|
||||
PropUiItem *getNextProp(void);
|
||||
int getNumProps(void);
|
||||
|
||||
static DmxStringTypeEnum getHdrFtrSpec(_DtPrintHdrFtrEnum which);
|
||||
static const char *getMarginSpec(_DtPrintMarginEnum which);
|
||||
static DmxMsgSeparatorEnum getMessageSeparator(void);
|
||||
static DmxPrintHeadersEnum getPrintedHeaders(void);
|
||||
static const char *getSeparatorString(void);
|
||||
};
|
||||
|
||||
#endif // _DMX_PRINT_OPTIONS_H
|
||||
763
cde/programs/dtmail/dtmail/DmxPrintOutput.C
Normal file
763
cde/programs/dtmail/dtmail/DmxPrintOutput.C
Normal file
@@ -0,0 +1,763 @@
|
||||
/* $TOG: DmxPrintOutput.C /main/6 1997/07/07 13:57:21 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/Print.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Dt/Editor.h>
|
||||
|
||||
#include "Dmx.h"
|
||||
#include "DmxPrintOutput.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
|
||||
//
|
||||
// Used to initialize the top, right, bottom, and left margins
|
||||
// between the outside edge of the page (_form) and the inner
|
||||
// page that is written on.
|
||||
//
|
||||
const char *const DmxPrintOutput::_default_margin = ".5in";
|
||||
|
||||
DmxPrintOutput::DmxPrintOutput (
|
||||
Widget pshell
|
||||
) : UIComponent( "PrintOutput" )
|
||||
{
|
||||
Widget w;
|
||||
DtMailBoolean parse_error;
|
||||
|
||||
_w = NULL;
|
||||
_pshell = pshell;
|
||||
|
||||
w = XtVaCreateWidget("Page",
|
||||
xmFormWidgetClass,
|
||||
_pshell,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
_form = w;
|
||||
_w = _form;
|
||||
|
||||
w = XtVaCreateWidget("InnerPage",
|
||||
xmFormWidgetClass,
|
||||
_form,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
_inner_form = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("HeaderLeft",
|
||||
xmLabelWidgetClass,
|
||||
_inner_form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
_header_left = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("HeaderRight",
|
||||
xmLabelWidgetClass,
|
||||
_inner_form,
|
||||
XmNalignment, XmALIGNMENT_END,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, _header_left,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
_header_right = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("Editor",
|
||||
#ifdef USE_DTEDITOR
|
||||
dtEditorWidgetClass,
|
||||
#else
|
||||
xmTextWidgetClass,
|
||||
#endif
|
||||
_inner_form,
|
||||
DtNscrollVertical, FALSE,
|
||||
DtNscrollHorizontal, FALSE,
|
||||
DtNshowStatusLine, FALSE,
|
||||
DtNwordWrap, TRUE,
|
||||
XmNeditMode, XmMULTI_LINE_EDIT,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _header_left,
|
||||
NULL);
|
||||
_editor = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("FooterLeft",
|
||||
xmLabelWidgetClass,
|
||||
_inner_form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
_footer_left = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("FooterRight",
|
||||
xmLabelWidgetClass,
|
||||
_inner_form,
|
||||
XmNalignment, XmALIGNMENT_END,
|
||||
XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, _footer_left,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
_footer_right = w;
|
||||
|
||||
XtVaSetValues(
|
||||
_editor,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _footer_left,
|
||||
NULL);
|
||||
|
||||
installDestroyHandler();
|
||||
XtManageChild(_inner_form);
|
||||
XtManageChild(_form);
|
||||
|
||||
setPageMargins(
|
||||
_default_margin,
|
||||
_default_margin,
|
||||
_default_margin,
|
||||
_default_margin,
|
||||
&parse_error );
|
||||
assert(!parse_error);
|
||||
}
|
||||
|
||||
DmxPrintOutput::~DmxPrintOutput (void)
|
||||
{
|
||||
//
|
||||
// Don't destroy anything here.
|
||||
// The BasicComponent class takes care of destroying
|
||||
// the _form widget.
|
||||
//
|
||||
}
|
||||
|
||||
void DmxPrintOutput::hideFooters (void)
|
||||
{
|
||||
XtUnmanageChild(_footer_left);
|
||||
XtUnmanageChild(_footer_right);
|
||||
XtVaSetValues(_editor, XmNbottomAttachment, XmATTACH_FORM, NULL);
|
||||
}
|
||||
|
||||
void DmxPrintOutput::showFooters (void)
|
||||
{
|
||||
XtManageChild(_footer_left);
|
||||
XtManageChild(_footer_right);
|
||||
XtVaSetValues(
|
||||
_editor,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _footer_left,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void DmxPrintOutput::hideHeaders (void)
|
||||
{
|
||||
XtUnmanageChild(_header_left);
|
||||
XtUnmanageChild(_header_right);
|
||||
XtVaSetValues(_editor, XmNtopAttachment, XmATTACH_FORM, NULL);
|
||||
}
|
||||
|
||||
void DmxPrintOutput::showHeaders (void)
|
||||
{
|
||||
XtManageChild(_header_left);
|
||||
XtManageChild(_header_right);
|
||||
XtVaSetValues(
|
||||
_editor,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _header_left,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintOutput::setHdrFtrString (_DtPrintHdrFtrEnum which, char *label)
|
||||
{
|
||||
Widget w;
|
||||
XmString xms;
|
||||
|
||||
if (label == (char *) NULL)
|
||||
return;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_HEADER_LEFT:
|
||||
w = _header_left;
|
||||
break;
|
||||
case DTPRINT_OPTION_HEADER_RIGHT:
|
||||
w = _header_right;
|
||||
break;
|
||||
case DTPRINT_OPTION_FOOTER_LEFT:
|
||||
w = _footer_left;
|
||||
break;
|
||||
case DTPRINT_OPTION_FOOTER_RIGHT:
|
||||
w = _footer_right;
|
||||
break;
|
||||
default:
|
||||
// TBD: Need to log an error.
|
||||
return;
|
||||
}
|
||||
|
||||
xms = XmStringCreateLocalized(label);
|
||||
XtVaSetValues(w, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setHdrFtrStrings (
|
||||
char *hdr_left,
|
||||
char *hdr_right,
|
||||
char *ftr_left,
|
||||
char *ftr_right
|
||||
)
|
||||
{
|
||||
XmString xms;
|
||||
|
||||
if (hdr_left)
|
||||
{
|
||||
xms = XmStringCreateLocalized(hdr_left);
|
||||
XtVaSetValues(_header_left, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
if (hdr_right)
|
||||
{
|
||||
xms = XmStringCreateLocalized(hdr_right);
|
||||
XtVaSetValues(_header_right, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
if (ftr_left)
|
||||
{
|
||||
xms = XmStringCreateLocalized(ftr_left);
|
||||
XtVaSetValues(_footer_left, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
if (ftr_right)
|
||||
{
|
||||
xms = XmStringCreateLocalized(ftr_right);
|
||||
XtVaSetValues(_footer_right, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setPageMargin (
|
||||
_DtPrintMarginEnum which,
|
||||
const char *margin,
|
||||
DtMailBoolean *parse_error
|
||||
)
|
||||
{
|
||||
int pixels = 0;
|
||||
XtEnum xt_parse_error = FALSE;
|
||||
char *marginstring = strdup(margin);
|
||||
|
||||
if (parse_error)
|
||||
*parse_error = DTM_FALSE;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_MARGIN_TOP:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
marginstring,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
_margin_top = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_RIGHT:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
marginstring,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
_margin_right = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_BOTTOM:
|
||||
_margin_bottom = pixels;
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
marginstring,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
_margin_bottom = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_LEFT:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
marginstring,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
_margin_left = pixels;
|
||||
break;
|
||||
default:
|
||||
// TBD: Need to log an error.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!xt_parse_error)
|
||||
setInnerPageDimensions(
|
||||
_margin_top,
|
||||
_margin_right,
|
||||
_margin_bottom,
|
||||
_margin_left);
|
||||
else
|
||||
*parse_error = DTM_TRUE;
|
||||
|
||||
free(marginstring);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setPageMargin (_DtPrintMarginEnum which, int margin)
|
||||
{
|
||||
Dimension pixels = (Dimension) margin;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_MARGIN_TOP:
|
||||
_margin_top = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_RIGHT:
|
||||
_margin_right = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_BOTTOM:
|
||||
_margin_bottom = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_LEFT:
|
||||
_margin_left = pixels;
|
||||
break;
|
||||
default:
|
||||
// TBD: Need to log an error.
|
||||
return;
|
||||
}
|
||||
|
||||
setInnerPageDimensions(
|
||||
_margin_top,
|
||||
_margin_right,
|
||||
_margin_bottom,
|
||||
_margin_left);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setPageMargins (
|
||||
const char *top,
|
||||
const char *right,
|
||||
const char *bottom,
|
||||
const char *left,
|
||||
DtMailBoolean *parse_error
|
||||
)
|
||||
{
|
||||
int pixels = 0;
|
||||
XtEnum xt_parse_error = FALSE;
|
||||
char *margin;
|
||||
|
||||
*parse_error = DTM_FALSE;
|
||||
|
||||
margin = strdup(top);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
margin,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
free(margin);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
{
|
||||
_margin_top = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parse_error = DTM_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
margin = strdup(right);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
margin,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
free(margin);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
{
|
||||
_margin_right = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parse_error = DTM_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
margin = strdup(bottom);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
margin,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
free(margin);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
{
|
||||
_margin_bottom = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parse_error = DTM_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
margin = strdup(left);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
margin,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
free(margin);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
{
|
||||
_margin_left = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parse_error = DTM_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
setInnerPageDimensions(
|
||||
_margin_top,
|
||||
_margin_right,
|
||||
_margin_bottom,
|
||||
_margin_left);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setPageMargins (
|
||||
int top,
|
||||
int right,
|
||||
int bottom,
|
||||
int left
|
||||
)
|
||||
{
|
||||
_margin_top = (top > 0) ? (Dimension) top : _margin_top;
|
||||
_margin_right = (right > 0) ? (Dimension) right : _margin_right;
|
||||
_margin_bottom = (bottom > 0) ? (Dimension) bottom : _margin_bottom;
|
||||
_margin_left = (left > 0) ? (Dimension) left : _margin_left;
|
||||
|
||||
setInnerPageDimensions(
|
||||
_margin_top,
|
||||
_margin_right,
|
||||
_margin_bottom,
|
||||
_margin_left);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setWrapToFit (DtMailBoolean onoff)
|
||||
{
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaSetValues(_editor, DtNwordWrap, onoff, NULL);
|
||||
#else
|
||||
XtVaSetValues(_editor, XmNwordWrap, onoff, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DmxPrintOutput::getCharactersPerLine ()
|
||||
{
|
||||
short columns = 0;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaGetValues(_editor, DtNcolumns, &columns, NULL);
|
||||
#else
|
||||
XtVaGetValues(_editor, XmNcolumns, &columns, NULL);
|
||||
#endif
|
||||
return((int) columns);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DmxPrintOutput::getNumLines ()
|
||||
{
|
||||
int total = 0;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
#else
|
||||
XtVaGetValues(_editor, XmNtotalLines, &total, NULL);
|
||||
//
|
||||
// Correct for off by one error.
|
||||
//
|
||||
total -= 1;
|
||||
#endif
|
||||
return(total);
|
||||
}
|
||||
|
||||
|
||||
int DmxPrintOutput::getLastPosition ()
|
||||
{
|
||||
XmTextPosition last;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
last = DtEditorGetLastPosition(_editor);
|
||||
#else
|
||||
last = XmTextGetLastPosition(_editor);
|
||||
#endif
|
||||
return((int) last);
|
||||
}
|
||||
|
||||
int DmxPrintOutput::getTopPosition ()
|
||||
{
|
||||
XmTextPosition top;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaGetValues(_editor, DtNtopCharacter, &top, NULL);
|
||||
#else
|
||||
top = XmTextGetTopCharacter(_editor);
|
||||
#endif
|
||||
return((int) top);
|
||||
}
|
||||
|
||||
DtMailBoolean DmxPrintOutput::pageUp ()
|
||||
{
|
||||
XmTextPosition top_before, top_after;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
return DTM_FALSE;
|
||||
#else
|
||||
top_before = XmTextGetTopCharacter(_editor);
|
||||
XmTextScroll(_editor, -1 * _lines_per_page);
|
||||
top_after = XmTextGetTopCharacter(_editor);
|
||||
|
||||
return (top_before > top_after) ? DTM_TRUE : DTM_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
DtMailBoolean DmxPrintOutput::pageDown ()
|
||||
{
|
||||
XmTextPosition top_before, top_after;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
return DTM_FALSE;
|
||||
#else
|
||||
top_before = XmTextGetTopCharacter(_editor);
|
||||
XmTextScroll(_editor, _lines_per_page);
|
||||
top_after = XmTextGetTopCharacter(_editor);
|
||||
|
||||
return (top_before < top_after) ? DTM_TRUE : DTM_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void DmxPrintOutput::setTopPosition ( int pos )
|
||||
{
|
||||
XmTextPosition top = (XmTextPosition) pos;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaSetValues(_editor, DtNtopCharacter, top, NULL);
|
||||
#else
|
||||
XmTextSetTopCharacter(_editor, top);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DmxPrintOutput::appendContents (void* stream, char *contents)
|
||||
{
|
||||
DmxPrintOutput *thisOutput = (DmxPrintOutput *) stream;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
DtEditorContentRec rec;
|
||||
|
||||
rec.type = DtEDITOR_TEXT;
|
||||
rec.value.string = contents;
|
||||
DtEditorInsert(thisOutput->_editor, &rec);
|
||||
#else
|
||||
XmTextPosition pos;
|
||||
|
||||
pos = XmTextGetLastPosition(thisOutput->_editor);
|
||||
XmTextInsert(thisOutput->_editor, pos, contents);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DmxPrintOutput::appendNewLine ()
|
||||
{
|
||||
#ifdef PRINT_TO_VIDEO
|
||||
char *contents = "=========== NewLine ==========\n";
|
||||
#else
|
||||
char *contents = "\n";
|
||||
#endif
|
||||
appendContents((XtPointer) this, contents);
|
||||
}
|
||||
|
||||
void DmxPrintOutput::appendPageBreak ()
|
||||
{
|
||||
char * buf;
|
||||
char *contents = "\n";
|
||||
int nlines, missing;
|
||||
|
||||
nlines = getNumLines();
|
||||
missing = ((nlines % _lines_per_page) > 0) ?
|
||||
(_lines_per_page - (nlines % _lines_per_page)) :
|
||||
0;
|
||||
|
||||
if (! missing)
|
||||
return;
|
||||
|
||||
#ifdef PRINT_TO_VIDEO
|
||||
for (int i=0; i<missing; i++)
|
||||
{
|
||||
char buffer[128];
|
||||
|
||||
sprintf(buffer, "Page Break Line: %d\n", i);
|
||||
appendContents((XtPointer) this, buffer);
|
||||
}
|
||||
fprintf(
|
||||
stdout,
|
||||
"Total Lines: %d; Lines Per Page: %d; Missing Lines: %d\n",
|
||||
nlines,
|
||||
_lines_per_page,
|
||||
missing);
|
||||
#else
|
||||
buf = (char *) malloc((missing * 2) + 1);
|
||||
for (int i=0; i<missing; i++)
|
||||
strcat(buf, contents);
|
||||
|
||||
appendContents(this, contents);
|
||||
|
||||
free(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DmxPrintOutput::clearContents (void)
|
||||
{
|
||||
#ifdef USE_DTEDITOR
|
||||
DtEditorContentRec content;
|
||||
|
||||
content.type = DtEDITOR_TEXT;
|
||||
rec.value.string = NULL;
|
||||
status = DtEditorSetContents(my_text, &content);
|
||||
#else
|
||||
XmTextSetString(_editor, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Private class methods
|
||||
*/
|
||||
int
|
||||
DmxPrintOutput::doGetLinesPerPage ()
|
||||
{
|
||||
Dimension lpp;
|
||||
|
||||
XtVaGetValues(_editor, XmNrows, &lpp, NULL);
|
||||
return ((int) lpp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintOutput::setInnerPageDimensions (
|
||||
Dimension top,
|
||||
Dimension right,
|
||||
Dimension bottom,
|
||||
Dimension left
|
||||
)
|
||||
{
|
||||
Dimension inner_height, inner_width, inner_x, inner_y,
|
||||
outer_height, outer_width,
|
||||
editor_height, footer_height, header_height;
|
||||
|
||||
XtVaGetValues(_form,
|
||||
XmNheight, &outer_height,
|
||||
XmNwidth, &outer_width,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(_header_left,
|
||||
XmNheight, &header_height,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(_footer_left,
|
||||
XmNheight, &footer_height,
|
||||
NULL);
|
||||
|
||||
inner_x = left;
|
||||
inner_y = top;
|
||||
inner_height = ((int) outer_height > (top + bottom)) ?
|
||||
(outer_height - (top + bottom)) :
|
||||
outer_height;
|
||||
inner_width = ((int) outer_width > (left + right)) ?
|
||||
(outer_width - (left + right)) :
|
||||
outer_width;
|
||||
editor_height = ((int) inner_height > (header_height + footer_height)) ?
|
||||
(inner_height - (header_height + footer_height)) :
|
||||
inner_height;
|
||||
|
||||
XtVaSetValues(_editor, XmNheight, editor_height, NULL);
|
||||
|
||||
XtVaSetValues(_inner_form,
|
||||
XmNleftAttachment, XmATTACH_NONE,
|
||||
XmNtopAttachment, XmATTACH_NONE,
|
||||
XmNx, inner_x,
|
||||
XmNy, inner_y,
|
||||
XmNheight, inner_height,
|
||||
XmNwidth, inner_width,
|
||||
NULL);
|
||||
|
||||
_lines_per_page = doGetLinesPerPage();
|
||||
}
|
||||
139
cde/programs/dtmail/dtmail/DmxPrintOutput.h
Normal file
139
cde/programs/dtmail/dtmail/DmxPrintOutput.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/* $TOG: DmxPrintOutput.h /main/3 1997/07/07 13:58:26 mgreess $ */
|
||||
|
||||
#ifndef _DMX_PRINT_OUTPUT_H
|
||||
#define _DMX_PRINT_OUTPUT_H
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <Dt/PrintOptionsP.h>
|
||||
#include "DtMailTypes.h"
|
||||
#include "UIComponent.h"
|
||||
|
||||
class DmxPrintOutput : public UIComponent
|
||||
{
|
||||
public:
|
||||
|
||||
DmxPrintOutput ( Widget );
|
||||
~DmxPrintOutput (void);
|
||||
|
||||
void hideFooters (void);
|
||||
void showFooters (void);
|
||||
void hideHeaders (void);
|
||||
void showHeaders (void);
|
||||
void setHdrFtrString (_DtPrintHdrFtrEnum, char*);
|
||||
void setHdrFtrStrings (char *, char *, char *, char *);
|
||||
|
||||
void setPageMargin (
|
||||
_DtPrintMarginEnum,
|
||||
const char*,
|
||||
DtMailBoolean*
|
||||
);
|
||||
void setPageMargin (_DtPrintMarginEnum, int);
|
||||
void setPageMargins (int, int, int, int);
|
||||
void setPageMargins (
|
||||
const char*,
|
||||
const char*,
|
||||
const char*,
|
||||
const char*,
|
||||
DtMailBoolean*
|
||||
);
|
||||
|
||||
void setWrapToFit (DtMailBoolean);
|
||||
|
||||
int getCharactersPerLine(void);
|
||||
inline int getLinesPerPage(void) { return _lines_per_page; }
|
||||
int getNumLines(void);
|
||||
int getLastPosition(void);
|
||||
int getTopPosition(void);
|
||||
DtMailBoolean pageUp(void);
|
||||
DtMailBoolean pageDown(void);
|
||||
void setTopPosition(int);
|
||||
|
||||
static void appendContents(void*, char*);
|
||||
void appendNewLine();
|
||||
void appendPageBreak();
|
||||
void clearContents(void);
|
||||
|
||||
private:
|
||||
static const char* const
|
||||
_default_margin;
|
||||
|
||||
Widget _pshell;
|
||||
Widget _form;
|
||||
Widget _inner_form;
|
||||
Widget _header_left;
|
||||
Widget _header_right;
|
||||
Widget _editor;
|
||||
Widget _footer_left;
|
||||
Widget _footer_right;
|
||||
|
||||
int _lines_per_page;
|
||||
Dimension _margin_top;
|
||||
Dimension _margin_right;
|
||||
Dimension _margin_bottom;
|
||||
Dimension _margin_left;
|
||||
|
||||
int doGetLinesPerPage();
|
||||
void setInnerPageDimensions(
|
||||
Dimension,
|
||||
Dimension,
|
||||
Dimension,
|
||||
Dimension
|
||||
);
|
||||
};
|
||||
|
||||
#endif // _DMX_PRINT_OUTPUT_H
|
||||
499
cde/programs/dtmail/dtmail/DmxPrintSetup.C
Normal file
499
cde/programs/dtmail/dtmail/DmxPrintSetup.C
Normal file
@@ -0,0 +1,499 @@
|
||||
/* $TOG: DmxPrintSetup.C /main/17 1997/09/03 17:34:59 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <Dt/Print.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Xm/ToggleBG.h>
|
||||
|
||||
#include "Dmx.h"
|
||||
#include "DmxPrintOptions.h"
|
||||
#include "DmxPrintSetup.h"
|
||||
#include "DtMailHelp.hh"
|
||||
#include "MailMsg.h"
|
||||
#include "OptCmd.h"
|
||||
#include "RoamApp.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
|
||||
static DtMailBoolean DmxPrintSetup_print_separately = DTM_FALSE;
|
||||
static DtMailBoolean DmxPrintSetup_use_word_wrap = DTM_TRUE;
|
||||
static DtMailBoolean DmxPrintSetup_print_to_file = DTM_FALSE;
|
||||
static char *DmxPrintSetup_printer_name = NULL;
|
||||
#ifdef REUSE_PRINT_SETUP_DIALOGS
|
||||
static Widget DmxPrintSetup_default_dtprint_setup = NULL;
|
||||
#endif
|
||||
|
||||
DmxPrintSetup::DmxPrintSetup (
|
||||
Widget window,
|
||||
XtCallbackProc printCB, XtPointer printClosure,
|
||||
XtCallbackProc cancelCB, XtPointer cancelClosure,
|
||||
XtCallbackProc closeDisplayCB, XtPointer closeDisplayClosure,
|
||||
XtCallbackProc pdmSetupCB, XtPointer pdmSetupClosure)
|
||||
{
|
||||
_parent = window;
|
||||
_dtprint_setup = (Widget) NULL;
|
||||
_widgets = (PrintSetupWidgets *) NULL;
|
||||
_use_word_wrap = DmxPrintSetup_use_word_wrap;
|
||||
_print_separately = DmxPrintSetup_print_separately;
|
||||
_print_to_file = DmxPrintSetup_print_to_file;
|
||||
if (NULL != DmxPrintSetup_printer_name)
|
||||
_printer_name = strdup(DmxPrintSetup_printer_name);
|
||||
else
|
||||
_printer_name = NULL;
|
||||
|
||||
_filename = (char*) malloc(MAXPATHLEN+1);
|
||||
if (NULL != _filename)
|
||||
sprintf(_filename, "%s/dtmail_messages.ps", getenv("HOME"));
|
||||
|
||||
_printCB = printCB;
|
||||
_cancelCB = cancelCB;
|
||||
_closeDisplayCB = closeDisplayCB;
|
||||
_pdmSetupCB = pdmSetupCB;
|
||||
|
||||
_printClosure = printClosure;
|
||||
_cancelClosure = cancelClosure;
|
||||
_closeDisplayClosure = closeDisplayClosure;
|
||||
_pdmSetupClosure = pdmSetupClosure;
|
||||
|
||||
attachPrintSetupDialog();
|
||||
XtRealizeWidget(_dtprint_setup);
|
||||
}
|
||||
|
||||
DmxPrintSetup::~DmxPrintSetup (void)
|
||||
{
|
||||
if (NULL != _printer_name)
|
||||
free(_printer_name);
|
||||
|
||||
if (NULL != _filename)
|
||||
free(_filename);
|
||||
|
||||
detachPrintSetupDialog();
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintSetup::setPrintToFileName (char *filename)
|
||||
{
|
||||
if (NULL != _filename)
|
||||
free(_filename);
|
||||
|
||||
_filename = strdup(filename);
|
||||
|
||||
if (NULL != _filename)
|
||||
XtVaSetValues(_dtprint_setup, DtNfileName, _filename, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintSetup::display (void)
|
||||
{
|
||||
if (_dtprint_setup == NULL) return;
|
||||
|
||||
#ifdef REUSE_PRINT_SETUP_DIALOGS
|
||||
Position x1, y1, x2, y2;
|
||||
Dimension w1, h1, w2, h2;
|
||||
XtVaGetValues(
|
||||
XtParent(_dtprint_setup),
|
||||
XmNx, &x1, XmNy, &y1,
|
||||
XmNwidth, &w1, XmNheight, &h1,
|
||||
NULL);
|
||||
XtVaGetValues(
|
||||
_parent,
|
||||
XmNx, &x2, XmNy, &y2,
|
||||
XmNwidth, &w2, XmNheight, &h2,
|
||||
NULL);
|
||||
XtVaSetValues(
|
||||
XtParent(_dtprint_setup),
|
||||
XmNx, x2 + (w2 - w1) / 2, XmNy, y2 + (h2 - h1) / 2,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
XtManageChild(_dtprint_setup);
|
||||
|
||||
if (NULL != _printer_name)
|
||||
XtVaSetValues(_widgets->printer_name_tf, XmNvalue, _printer_name, NULL);
|
||||
}
|
||||
|
||||
DtMailBoolean
|
||||
DmxPrintSetup::getDefaultPrintData (DtPrintSetupData *print_data)
|
||||
{
|
||||
if (_dtprint_setup == NULL || print_data == NULL) return DTM_FALSE;
|
||||
if (DtPRINT_SUCCESS == DtPrintFillSetupData(_dtprint_setup, print_data))
|
||||
return DTM_TRUE;
|
||||
else
|
||||
return DTM_FALSE;
|
||||
}
|
||||
|
||||
DtMailBoolean
|
||||
DmxPrintSetup::printSeparately (void)
|
||||
{
|
||||
if (DTM_TRUE != _print_to_file)
|
||||
return _print_separately;
|
||||
|
||||
return DTM_FALSE;
|
||||
}
|
||||
|
||||
DtMailBoolean
|
||||
DmxPrintSetup::useWordWrap (void)
|
||||
{
|
||||
return _use_word_wrap;
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintSetup::attachPrintSetupDialog (void)
|
||||
{
|
||||
unsigned char is_set;
|
||||
Widget dialog;
|
||||
|
||||
#ifdef REUSE_PRINT_SETUP_DIALOGS
|
||||
if (DmxPrintSetup_default_dtprint_setup != NULL)
|
||||
{
|
||||
//
|
||||
// Attempt to reuse the last print setup and print display connection.
|
||||
//
|
||||
_dtprint_setup = DmxPrintSetup_default_dtprint_setup;
|
||||
DmxPrintSetup_default_dtprint_setup = NULL;
|
||||
}
|
||||
else
|
||||
_dtprint_setup = createPrintSetupDialog(theRoamApp.baseWidget());
|
||||
#else
|
||||
_dtprint_setup = createPrintSetupDialog(_parent);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Copy the information about the widgets into the setup.
|
||||
//
|
||||
XtVaGetValues(_dtprint_setup, XmNuserData, &_widgets, NULL);
|
||||
|
||||
//
|
||||
// Add the setup-specific callbacks
|
||||
//
|
||||
XtAddCallback(
|
||||
_dtprint_setup,
|
||||
DtNprintCallback,
|
||||
DmxPrintSetup::printCB,
|
||||
(XtPointer) this);
|
||||
XtAddCallback(
|
||||
_dtprint_setup,
|
||||
DtNcancelCallback,
|
||||
_cancelCB,
|
||||
(XtPointer) _cancelClosure);
|
||||
XtAddCallback(
|
||||
_dtprint_setup,
|
||||
DtNclosePrintDisplayCallback,
|
||||
_closeDisplayCB,
|
||||
(XtPointer) _closeDisplayClosure);
|
||||
XtAddCallback(
|
||||
_dtprint_setup,
|
||||
DtNsetupCallback,
|
||||
_pdmSetupCB,
|
||||
(XtPointer) _pdmSetupClosure);
|
||||
|
||||
is_set = (_print_separately) ? XmSET : XmUNSET;
|
||||
XtVaSetValues(_widgets->print_separately_tb, XmNset, is_set, NULL);
|
||||
|
||||
is_set = (_use_word_wrap) ? XmSET : XmUNSET;
|
||||
XtVaSetValues(_widgets->use_word_wrap_tb, XmNset, is_set, NULL);
|
||||
|
||||
if (DTM_TRUE == _print_to_file)
|
||||
XtVaSetValues(
|
||||
_dtprint_setup,
|
||||
DtNprintDestination, DtPRINT_TO_FILE,
|
||||
NULL);
|
||||
else
|
||||
XtVaSetValues(
|
||||
_dtprint_setup,
|
||||
DtNprintDestination, DtPRINT_TO_PRINTER,
|
||||
NULL);
|
||||
|
||||
if (NULL != _printer_name)
|
||||
XtVaSetValues(_dtprint_setup, DtNprinterName, _printer_name, NULL);
|
||||
|
||||
if (NULL != _filename)
|
||||
XtVaSetValues(_dtprint_setup, DtNfileName, _filename, NULL);
|
||||
|
||||
dialog = XtParent(_dtprint_setup);
|
||||
if (NULL != dialog && XtIsShell(dialog))
|
||||
{
|
||||
char *title = (char*) GETMSG(DT_catd, 21, 21, "Mailer - Print Setup");
|
||||
XtVaSetValues(dialog, XmNtitle, title, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Print Setup box is not parented to a shell\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Widget
|
||||
DmxPrintSetup::createPrintSetupDialog (Widget parent)
|
||||
{
|
||||
PrintSetupWidgets *widgets;
|
||||
XmString xms;
|
||||
|
||||
//
|
||||
// Create the app-specific widgets for the Setup Dialog.
|
||||
widgets = (PrintSetupWidgets *) XtMalloc(sizeof(PrintSetupWidgets));
|
||||
|
||||
//
|
||||
// Create the DtPrintSetupDialog and specify that the application
|
||||
// specific area be located below the generic area.
|
||||
// Save the PrintSetupWidgets record as UserData so it can be
|
||||
// retrieved later.
|
||||
//
|
||||
widgets->dtprint_setup =
|
||||
DtCreatePrintSetupDialog(parent, "Setup", NULL, 0);
|
||||
|
||||
XtVaSetValues(
|
||||
widgets->dtprint_setup,
|
||||
DtNworkAreaLocation, DtWORK_AREA_BOTTOM,
|
||||
XmNuserData, widgets,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(
|
||||
widgets->dtprint_setup,
|
||||
XmNhelpCallback,
|
||||
HelpCB,
|
||||
DTMAILPRINTSETUPDIALOG);
|
||||
|
||||
XtAddCallback(
|
||||
widgets->dtprint_setup,
|
||||
XmNdestroyCallback,
|
||||
&DmxPrintSetup::destroyPrintSetupDialogCB,
|
||||
(XtPointer) widgets);
|
||||
|
||||
widgets->form = XtVaCreateWidget(
|
||||
"PrintSetupForm",
|
||||
xmFormWidgetClass,
|
||||
widgets->dtprint_setup,
|
||||
NULL);
|
||||
|
||||
xms = XmStringCreateLocalized(GETMSG(DT_catd, 21, 12, "Print Separately"));
|
||||
widgets->print_separately_tb = XtVaCreateManagedWidget(
|
||||
"PrintSeparatelyTB",
|
||||
xmToggleButtonWidgetClass,
|
||||
widgets->form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNlabelString, xms,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
XmStringFree(xms);
|
||||
|
||||
xms = XmStringCreateLocalized(GETMSG(DT_catd, 21, 13, "Use Word Wrap"));
|
||||
widgets->use_word_wrap_tb = XtVaCreateManagedWidget(
|
||||
"UseWordWrapTB",
|
||||
xmToggleButtonWidgetClass,
|
||||
widgets->form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNlabelString, xms,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, widgets->print_separately_tb,
|
||||
NULL);
|
||||
XmStringFree(xms);
|
||||
|
||||
xms = XmStringCreateLocalized(GETMSG(DT_catd, 21, 20, "More ..."));
|
||||
widgets->more_options_pb = XtVaCreateManagedWidget(
|
||||
"PrintOptionsPB",
|
||||
xmPushButtonWidgetClass,
|
||||
widgets->form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNlabelString, xms,
|
||||
XmNleftAttachment, XmATTACH_NONE,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, widgets->use_word_wrap_tb,
|
||||
NULL);
|
||||
XmStringFree(xms);
|
||||
|
||||
XtAddCallback(
|
||||
widgets->more_options_pb,
|
||||
XmNactivateCallback,
|
||||
&DmxPrintSetup::moreOptionsCB,
|
||||
(XtPointer) NULL);
|
||||
|
||||
widgets->checkbox_tb =
|
||||
XtNameToWidget(widgets->dtprint_setup, "DestRadioBox.button_1");
|
||||
widgets->printer_name_tf = XtNameToWidget(widgets->dtprint_setup, "Name");
|
||||
|
||||
if (NULL != widgets->checkbox_tb)
|
||||
XtAddCallback(
|
||||
widgets->checkbox_tb,
|
||||
XmNvalueChangedCallback,
|
||||
&DmxPrintSetup::destinationChangedCB,
|
||||
(XtPointer) widgets);
|
||||
|
||||
XtManageChild(widgets->form);
|
||||
return(widgets->dtprint_setup);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::detachPrintSetupDialog (void)
|
||||
{
|
||||
XtRemoveCallback(
|
||||
_dtprint_setup,
|
||||
DtNprintCallback,
|
||||
DmxPrintSetup::printCB,
|
||||
(XtPointer) this);
|
||||
XtRemoveCallback(
|
||||
_dtprint_setup,
|
||||
DtNcancelCallback,
|
||||
_cancelCB,
|
||||
(XtPointer) _cancelClosure);
|
||||
XtRemoveCallback(
|
||||
_dtprint_setup,
|
||||
DtNclosePrintDisplayCallback,
|
||||
_closeDisplayCB,
|
||||
(XtPointer) _closeDisplayClosure);
|
||||
XtRemoveCallback(
|
||||
_dtprint_setup,
|
||||
DtNsetupCallback,
|
||||
_pdmSetupCB,
|
||||
(XtPointer) _pdmSetupClosure);
|
||||
|
||||
//
|
||||
// Leave the Print Setup Dialog for the next print job.
|
||||
//
|
||||
#ifdef REUSE_PRINT_SETUP_DIALOGS
|
||||
if (DmxPrintSetup_default_dtprint_setup != NULL)
|
||||
{
|
||||
XtDestroyWidget(DmxPrintSetup_default_dtprint_setup);
|
||||
DmxPrintSetup_default_dtprint_setup = NULL;
|
||||
}
|
||||
DmxPrintSetup_default_dtprint_setup = _dtprint_setup;
|
||||
#else
|
||||
XtDestroyWidget(_dtprint_setup);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::savePrintSetupOptions(DtPrintSetupData *print_data)
|
||||
{
|
||||
unsigned char is_set;
|
||||
|
||||
XtVaGetValues(_widgets->print_separately_tb, XmNset, &is_set, NULL);
|
||||
_print_separately = (is_set == XmSET) ? DTM_TRUE : DTM_FALSE;
|
||||
DmxPrintSetup_print_separately = _print_separately;
|
||||
|
||||
XtVaGetValues(_widgets->use_word_wrap_tb, XmNset, &is_set, NULL);
|
||||
_use_word_wrap = (is_set == XmSET) ? DTM_TRUE : DTM_FALSE;
|
||||
DmxPrintSetup_use_word_wrap = _use_word_wrap;
|
||||
|
||||
_print_to_file =
|
||||
(DtPRINT_TO_FILE == print_data->destination) ? DTM_TRUE : DTM_FALSE;
|
||||
DmxPrintSetup_print_to_file = _print_to_file;
|
||||
|
||||
if (NULL != _printer_name)
|
||||
free(_printer_name);
|
||||
_printer_name = strdup(print_data->printer_name);
|
||||
|
||||
if (NULL != DmxPrintSetup_printer_name)
|
||||
free(DmxPrintSetup_printer_name);
|
||||
DmxPrintSetup_printer_name = strdup(_printer_name);
|
||||
|
||||
if (NULL != _filename)
|
||||
free(_filename);
|
||||
_filename = strdup(print_data->dest_info);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::destinationChangedCB(
|
||||
Widget checkbox_tb,
|
||||
XtPointer client_data,
|
||||
XtPointer)
|
||||
{
|
||||
PrintSetupWidgets *widgets = (PrintSetupWidgets*) client_data;
|
||||
Boolean toggleFlag;
|
||||
|
||||
if (NULL == checkbox_tb) return;
|
||||
|
||||
XtVaGetValues(checkbox_tb, XmNset, &toggleFlag, NULL);
|
||||
if(toggleFlag)
|
||||
XtVaSetValues(
|
||||
widgets->print_separately_tb,
|
||||
XmNsensitive, False,
|
||||
XmNset, False,
|
||||
NULL);
|
||||
else
|
||||
XtVaSetValues(widgets->print_separately_tb, XmNsensitive, True, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::destroyPrintSetupDialogCB(Widget, XtPointer widgets, XtPointer)
|
||||
{
|
||||
XtFree((char *) widgets);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::moreOptionsCB(Widget, XtPointer, XtPointer)
|
||||
{
|
||||
OptCmd *optCmd = (OptCmd *) theRoamApp.mailOptions();
|
||||
|
||||
optCmd->displayPrintingOptionsPane();
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintSetup::printCB(Widget w, XtPointer client_data, XtPointer call_data)
|
||||
{
|
||||
DmxPrintSetup *thisSetup = (DmxPrintSetup*) client_data;
|
||||
DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*) call_data;
|
||||
|
||||
thisSetup->_printCB(w, thisSetup->_printClosure, call_data);
|
||||
thisSetup->savePrintSetupOptions(pbs->print_data);
|
||||
}
|
||||
135
cde/programs/dtmail/dtmail/DmxPrintSetup.h
Normal file
135
cde/programs/dtmail/dtmail/DmxPrintSetup.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/* $TOG: DmxPrintSetup.h /main/9 1997/08/14 15:53:59 mgreess $ */
|
||||
|
||||
#ifndef _DMX_PRINT_SETUP_H
|
||||
#define _DMX_PRINT_SETUP_H
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <Dt/Print.h>
|
||||
#include "UIComponent.h"
|
||||
|
||||
class DmxPrintSetup
|
||||
{
|
||||
private:
|
||||
typedef struct print_setup_widgets
|
||||
{
|
||||
//
|
||||
// Widgets from the dtmail-specific portion of the PrintSetup Dialog.
|
||||
//
|
||||
Widget dtprint_setup;
|
||||
Widget form;
|
||||
Widget print_separately_tb;
|
||||
Widget use_word_wrap_tb;
|
||||
Widget more_options_pb;
|
||||
|
||||
//
|
||||
// Widgets from the generic portion of the PrintSetup Dialog.
|
||||
//
|
||||
Widget printer_name_tf;
|
||||
Widget checkbox_rc;
|
||||
Widget checkbox_tb;
|
||||
Widget filename_tf;
|
||||
} PrintSetupWidgets;
|
||||
|
||||
Widget _parent;
|
||||
Widget _dtprint_setup;
|
||||
PrintSetupWidgets *_widgets;
|
||||
|
||||
XtCallbackProc _printCB;
|
||||
XtCallbackProc _cancelCB;
|
||||
XtCallbackProc _closeDisplayCB;
|
||||
XtCallbackProc _pdmSetupCB;
|
||||
|
||||
XtPointer _printClosure;
|
||||
XtPointer _cancelClosure;
|
||||
XtPointer _closeDisplayClosure;
|
||||
XtPointer _pdmSetupClosure;
|
||||
|
||||
// Print options specific to this print job.
|
||||
DtMailBoolean _print_separately;
|
||||
DtMailBoolean _use_word_wrap;
|
||||
DtMailBoolean _print_to_file;
|
||||
char *_printer_name;
|
||||
char *_filename;
|
||||
|
||||
void attachPrintSetupDialog(void);
|
||||
Widget createPrintSetupDialog(Widget);
|
||||
void detachPrintSetupDialog(void);
|
||||
void savePrintSetupOptions(DtPrintSetupData*);
|
||||
|
||||
static void destinationChangedCB(Widget, XtPointer, XtPointer);
|
||||
static void destroyPrintSetupDialogCB(Widget, XtPointer, XtPointer);
|
||||
static void moreOptionsCB(Widget, XtPointer, XtPointer);
|
||||
static void printCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
public:
|
||||
DmxPrintSetup (
|
||||
Widget,
|
||||
XtCallbackProc, XtPointer,
|
||||
XtCallbackProc, XtPointer,
|
||||
XtCallbackProc, XtPointer,
|
||||
XtCallbackProc, XtPointer
|
||||
);
|
||||
~DmxPrintSetup (void);
|
||||
|
||||
void setPrintToFileName (char*);
|
||||
void display(void);
|
||||
DtMailBoolean getDefaultPrintData(DtPrintSetupData*);
|
||||
DtMailBoolean printSeparately(void);
|
||||
DtMailBoolean useWordWrap(void);
|
||||
};
|
||||
|
||||
#endif // _DMX_PRINT_SETUP_H
|
||||
342
cde/programs/dtmail/dtmail/DmxUtils.C
Normal file
342
cde/programs/dtmail/dtmail/DmxUtils.C
Normal file
@@ -0,0 +1,342 @@
|
||||
/* $XConsortium: DmxUtils.C /main/3 1996/04/21 19:55:51 drk $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include "Dmx.h"
|
||||
|
||||
// fn proto for mailx fn
|
||||
static char * dispname(const char *hdr);
|
||||
|
||||
// error-handling: should do something with minor codes
|
||||
|
||||
DtMailBoolean
|
||||
handleError (DtMailEnv &dterror, char *msg)
|
||||
{
|
||||
if (dterror.isSet () == DTM_TRUE)
|
||||
{
|
||||
fprintf (stderr, "dtmailpr: (%s) %s\n",
|
||||
msg, (const char *)dterror);
|
||||
dterror.logError (DTM_FALSE, "dtmailpr: (%s) %s\n",
|
||||
msg, (const char *)dterror);
|
||||
|
||||
dterror.clear ();
|
||||
return DTM_TRUE;
|
||||
}
|
||||
|
||||
dterror.clear ();
|
||||
return DTM_FALSE;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
errorString (DmxHeaders hdr)
|
||||
{
|
||||
switch (hdr)
|
||||
{
|
||||
case DMXFROM:
|
||||
return "(unknown)";
|
||||
case DMXSUBJ:
|
||||
return "(no subject)";
|
||||
case DMXCLENGTH:
|
||||
return "0";
|
||||
case DMXSTATUS:
|
||||
return " ";
|
||||
case DMXDATE:
|
||||
return "(unknown date)";
|
||||
case DMXTO:
|
||||
return " ";
|
||||
case DMXNUMHDRS:
|
||||
default:
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
getStandardHeaders (DtMailHeaderLine &info)
|
||||
{
|
||||
int i = 0, length = 0;
|
||||
int buflength = 0;
|
||||
char *fbuf;
|
||||
|
||||
const char *header [DMXNUMHDRS];
|
||||
|
||||
for (i = 0; i < DMXNUMHDRS; i++)
|
||||
{
|
||||
length = info.header_values[i].length ();
|
||||
if (length == 0)
|
||||
{
|
||||
header [i] = errorString ((DmxHeaders) i);
|
||||
} else {
|
||||
header [i] = *((info.header_values[i])[0]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < DMXNUMHDRS; i++)
|
||||
{
|
||||
buflength += strlen (header [i]);
|
||||
}
|
||||
|
||||
fbuf = new char [buflength + 64];
|
||||
|
||||
sprintf(fbuf,
|
||||
"From: %s\nDate: %s\nTo: %s\nSubject: %s\n",
|
||||
dispname (header [DMXFROM]),
|
||||
header [DMXDATE],
|
||||
header [DMXTO],
|
||||
header [DMXSUBJ]);
|
||||
|
||||
return (fbuf); //need to free this after using it
|
||||
}
|
||||
|
||||
// stuff grabbed from mailx...it's ugly, but it looks pretty
|
||||
|
||||
#define NOSTR ((char *) 0) /* Nill string pointer */
|
||||
#define LINESIZE 5120 /* max readable line width */
|
||||
static char *phrase(char *, int , int );
|
||||
|
||||
/*
|
||||
* Return a pointer to a dynamic copy of the argument.
|
||||
*/
|
||||
// changed salloc to malloc
|
||||
char *
|
||||
savestr(char *str)
|
||||
{
|
||||
register char *cp, *cp2, *top;
|
||||
|
||||
for (cp = str; *cp; cp++)
|
||||
;
|
||||
top = (char *)malloc((unsigned)(cp-str + 1));
|
||||
if (top == NOSTR)
|
||||
return(NOSTR);
|
||||
for (cp = str, cp2 = top; *cp; cp++)
|
||||
*cp2++ = *cp;
|
||||
*cp2 = 0;
|
||||
return(top);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
skin(char *name)
|
||||
{
|
||||
return phrase(name, 0, 0);
|
||||
}
|
||||
/*
|
||||
* Return the full name from an RFC-822 header line
|
||||
* or the last two (or one) component of the address.
|
||||
*/
|
||||
|
||||
static char *
|
||||
dispname(const char *hdr)
|
||||
// made it a const char * instead of a char *
|
||||
{
|
||||
char *cp, *cp2;
|
||||
|
||||
if (hdr == 0)
|
||||
return 0;
|
||||
if (((cp = strchr(hdr, '<')) != 0) && (cp > hdr)) {
|
||||
*cp = 0;
|
||||
if ((*hdr == '"') && ((cp = strrchr(++hdr, '"')) != 0))
|
||||
*cp = 0;
|
||||
return (char *)hdr;
|
||||
} else if ((cp = strchr(hdr, '(')) != 0) {
|
||||
hdr = ++cp;
|
||||
if ((cp = strchr(hdr, '+')) != 0)
|
||||
*cp = 0;
|
||||
if ((cp = strrchr(hdr, ')')) != 0)
|
||||
*cp = 0;
|
||||
return (char *)hdr;
|
||||
}
|
||||
cp = skin((char *)hdr);
|
||||
if ((cp2 = strrchr(cp, '!')) != 0) {
|
||||
while (cp2 >= cp && *--cp2 != '!');
|
||||
cp = ++cp2;
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
|
||||
#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
|
||||
|
||||
/*
|
||||
* Skin an arpa net address according to the RFC 822 interpretation
|
||||
* of "host-phrase."
|
||||
*/
|
||||
// changed salloc to malloc
|
||||
static char *
|
||||
phrase(char *name, int token, int comma)
|
||||
{
|
||||
register char c;
|
||||
register char *cp, *cp2;
|
||||
char *bufend, *nbufp;
|
||||
int gotlt, lastsp, didq;
|
||||
char nbuf[LINESIZE];
|
||||
int nesting;
|
||||
|
||||
if (name == NOSTR)
|
||||
return(NOSTR);
|
||||
if (strlen(name) >= (unsigned)LINESIZE)
|
||||
nbufp = (char *)malloc(strlen(name));
|
||||
else
|
||||
nbufp = nbuf;
|
||||
gotlt = 0;
|
||||
lastsp = 0;
|
||||
bufend = nbufp;
|
||||
for (cp = name, cp2 = bufend; (c = *cp++) != 0;) {
|
||||
switch (c) {
|
||||
case '(':
|
||||
/*
|
||||
Start of a comment, ignore it.
|
||||
*/
|
||||
nesting = 1;
|
||||
while ((c = *cp) != 0) {
|
||||
cp++;
|
||||
switch(c) {
|
||||
case '\\':
|
||||
if (*cp == 0) goto outcm;
|
||||
cp++;
|
||||
break;
|
||||
case '(':
|
||||
nesting++;
|
||||
break;
|
||||
case ')':
|
||||
--nesting;
|
||||
break;
|
||||
}
|
||||
if (nesting <= 0) break;
|
||||
}
|
||||
outcm:
|
||||
lastsp = 0;
|
||||
break;
|
||||
case '"':
|
||||
/*
|
||||
Start a quoted string.
|
||||
Copy it in its entirety.
|
||||
*/
|
||||
didq = 0;
|
||||
while ((c = *cp) != 0) {
|
||||
cp++;
|
||||
switch (c) {
|
||||
case '\\':
|
||||
if ((c = *cp) == 0) goto outqs;
|
||||
cp++;
|
||||
break;
|
||||
case '"':
|
||||
goto outqs;
|
||||
}
|
||||
if (gotlt == 0 || gotlt == '<') {
|
||||
if (lastsp) {
|
||||
lastsp = 0;
|
||||
*cp2++ = ' ';
|
||||
}
|
||||
if (!didq) {
|
||||
*cp2++ = '"';
|
||||
didq++;
|
||||
}
|
||||
*cp2++ = c;
|
||||
}
|
||||
}
|
||||
outqs:
|
||||
if (didq)
|
||||
*cp2++ = '"';
|
||||
lastsp = 0;
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
if (token && (!comma || c == '\n')) {
|
||||
done:
|
||||
cp[-1] = 0;
|
||||
return cp;
|
||||
}
|
||||
lastsp = 1;
|
||||
break;
|
||||
|
||||
case ',':
|
||||
*cp2++ = c;
|
||||
if (gotlt != '<') {
|
||||
if (token)
|
||||
goto done;
|
||||
bufend = cp2 + 1;
|
||||
gotlt = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case '<':
|
||||
cp2 = bufend;
|
||||
gotlt = c;
|
||||
lastsp = 0;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
if (gotlt == '<') {
|
||||
gotlt = c;
|
||||
break;
|
||||
}
|
||||
|
||||
/* FALLTHROUGH . . . */
|
||||
|
||||
default:
|
||||
if (gotlt == 0 || gotlt == '<') {
|
||||
if (lastsp) {
|
||||
lastsp = 0;
|
||||
*cp2++ = ' ';
|
||||
}
|
||||
*cp2++ = c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*cp2 = 0;
|
||||
return (token ? --cp : equal(name, nbufp) ? name :
|
||||
nbufp == nbuf ? savestr(nbuf) : nbufp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
816
cde/programs/dtmail/dtmail/DtEditor.C
Normal file
816
cde/programs/dtmail/dtmail/DtEditor.C
Normal file
@@ -0,0 +1,816 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtEditor.C /main/11 1998/02/03 10:28:15 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef I_HAVE_NO_IDENT
|
||||
#else
|
||||
#endif
|
||||
|
||||
#ifdef DTEDITOR
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <X11/IntrinsicP.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xm/CutPaste.h>
|
||||
|
||||
#include "Help.hh"
|
||||
#include "RoamApp.h"
|
||||
#include "DtEditor.hh"
|
||||
#include "MailMsg.h" // DT_catd defined here
|
||||
|
||||
CDEM_DtWidgetEditor::CDEM_DtWidgetEditor(
|
||||
Widget parent,
|
||||
DtMailEditor *owner_of_editor
|
||||
)
|
||||
{
|
||||
my_parent = parent;
|
||||
my_owner = owner_of_editor;
|
||||
my_text = NULL;
|
||||
my_text_core = NULL;
|
||||
_modified_text = NULL;
|
||||
_modified_text_buflen = 0;
|
||||
|
||||
begin_ins_bracket = NULL;
|
||||
indent_str = NULL;
|
||||
end_ins_bracket = NULL;
|
||||
_auto_show_cursor = FALSE;
|
||||
|
||||
_buffer = NULL;
|
||||
_buf_len = (unsigned long) 0;
|
||||
text_already_selected = FALSE;
|
||||
}
|
||||
|
||||
CDEM_DtWidgetEditor::~CDEM_DtWidgetEditor()
|
||||
{
|
||||
if (my_text) {
|
||||
// No DtEditor API equivalent
|
||||
// Remove the callbacks first.
|
||||
|
||||
XtRemoveCallback(my_text, DtNtextSelectCallback,
|
||||
&CDEM_DtWidgetEditor::text_selected_callback, this);
|
||||
XtRemoveCallback(my_text, DtNtextDeselectCallback,
|
||||
&CDEM_DtWidgetEditor::text_unselected_callback, this);
|
||||
XtRemoveCallback( my_text, XmNhelpCallback, HelpTexteditCB, this ) ;
|
||||
|
||||
XtDestroyWidget(my_text);
|
||||
}
|
||||
if (_buffer) {
|
||||
delete _buffer;
|
||||
_buffer = NULL;
|
||||
}
|
||||
|
||||
if(_modified_text ) {
|
||||
if(_modified_text->ptr) {
|
||||
free(_modified_text->ptr);
|
||||
_modified_text->ptr = NULL;
|
||||
}
|
||||
free(_modified_text);
|
||||
_modified_text = NULL;
|
||||
}
|
||||
if (NULL != indent_str)
|
||||
free((void*) indent_str);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::initialize()
|
||||
{
|
||||
|
||||
int i = 0;
|
||||
|
||||
Arg args[10];
|
||||
int n = 0;
|
||||
|
||||
#if 0
|
||||
short rows, cols;
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mailrc = d_session->mailRc(error);
|
||||
|
||||
const char * value = NULL;
|
||||
mailrc->getValue(error, "popuplines", &value);
|
||||
if (error.isSet()) {
|
||||
value = strdup("24");
|
||||
}
|
||||
rows = strtol(value, NULL, 10);
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
|
||||
// If toolcols is set, overwrite the column width with "toolcols" value.
|
||||
// Otherwise, default resource value will be used.
|
||||
value = NULL;
|
||||
mailrc->getValue(error, "toolcols", &value);
|
||||
if (!error.isSet()){
|
||||
cols = strtol(value, NULL, 10);
|
||||
XtSetArg(args[i], DtNcolumns, cols); i++;
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
} else {
|
||||
/*
|
||||
* Default XmNcolumns
|
||||
* MB_CUR_MAX == 1 : SingleByteLanguage
|
||||
* MB_CUR_MAX > 1 : MultiByteLanguage
|
||||
*/
|
||||
if ( MB_CUR_MAX == 1 )
|
||||
value = "80";
|
||||
else
|
||||
value = "40";
|
||||
|
||||
cols = strtol(value, NULL, 10);
|
||||
XtSetArg(args[i], DtNcolumns, cols); i++;
|
||||
}
|
||||
#endif
|
||||
|
||||
XtSetArg(args[i], DtNeditable, FALSE); i++;
|
||||
XtSetArg(args[i], DtNrows, 24); i++;
|
||||
if ( MB_CUR_MAX == 1 ) {
|
||||
XtSetArg(args[i], DtNcolumns, 80); i++;
|
||||
} else {
|
||||
XtSetArg(args[i], DtNcolumns, 40); i++;
|
||||
}
|
||||
XtSetArg(args[i], DtNcursorPositionVisible, FALSE); i++;
|
||||
|
||||
my_text = DtCreateEditor(my_parent, "Text", args, i);
|
||||
|
||||
update_display_from_props();
|
||||
XtAddCallback(my_text, DtNtextSelectCallback,
|
||||
&CDEM_DtWidgetEditor::text_selected_callback, this);
|
||||
XtAddCallback(my_text, DtNtextDeselectCallback,
|
||||
&CDEM_DtWidgetEditor::text_unselected_callback, this);
|
||||
XtAddCallback( my_text, XmNhelpCallback, HelpTexteditCB, this ) ;
|
||||
|
||||
XtAddEventHandler(my_text, ButtonPressMask,
|
||||
FALSE, MenuButtonHandler,
|
||||
(XtPointer) this);
|
||||
|
||||
XtManageChild(my_text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
CDEM_DtWidgetEditor::get_contents()
|
||||
{
|
||||
|
||||
DtEditorErrorCode status;
|
||||
static DtEditorContentRec content;
|
||||
|
||||
content.type = DtEDITOR_TEXT;
|
||||
|
||||
// Get the contents with hardCarriageReturns = TRUE and
|
||||
// markContentsAsSaved = TRUE.
|
||||
|
||||
/*
|
||||
* If hardCarriageReturns = TRUE, the performace of DtEditorGetContents()
|
||||
* suffers since according to man 3 DtEditorGetContents,
|
||||
*
|
||||
* The hardCarriageReturns argument, if set to True, indicates
|
||||
* that the DtEditor widget should replace any soft line feeds
|
||||
* (word wraps) with <newline>s when saving the data. When
|
||||
* hardCarriageReturns is set to False, any line wrapped
|
||||
* because it reaches the right edge of the window is saved as
|
||||
* one complete line.
|
||||
*
|
||||
* And current default value of DtNwordWrap is TRUE. See dtmail/Dtmail.
|
||||
* My temporary and non-good solution is
|
||||
* - Change default to False.
|
||||
* - If DtNwordWarp == TRUE,
|
||||
* call DtEditorGetContents(my_text, &content, TRUE, TRUE)
|
||||
* if not,
|
||||
* call DtEditorGetContents(my_text, &content, False, TRUE)
|
||||
* This value can be controllable by a resource file or Format menu.
|
||||
*
|
||||
* Goofy ? but...................;-(
|
||||
*/
|
||||
Arg args[1];
|
||||
Boolean ww;
|
||||
|
||||
XtSetArg( args[0], DtNwordWrap, &ww );
|
||||
XtGetValues( my_text, args, 1 );
|
||||
status = DtEditorGetContents(my_text, &content, ww, TRUE);
|
||||
|
||||
return(content.value.string);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_contents(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
)
|
||||
{
|
||||
DtEditorContentRec content;
|
||||
DtEditorErrorCode status;
|
||||
|
||||
this->my_owner->needBuf(&_buffer, &_buf_len, len + 1);
|
||||
this->my_owner->stripCRLF(&_buffer, contents, len);
|
||||
|
||||
content.type = DtEDITOR_TEXT;
|
||||
content.value.string = _buffer;
|
||||
status = DtEditorSetContents(my_text, &content);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_contents(
|
||||
const char *path
|
||||
)
|
||||
{
|
||||
DtEditorSetContentsFromFile(my_text, (char *)path);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::clear_contents()
|
||||
{
|
||||
|
||||
// Doesn't work yet. Work around with setting an empty string...
|
||||
// DtEditorReset(my_text);
|
||||
|
||||
DtEditorContentRec content;
|
||||
DtEditorErrorCode status;
|
||||
|
||||
content.type = DtEDITOR_TEXT;
|
||||
content.value.string = NULL;
|
||||
status = DtEditorSetContents(my_text, &content);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::append_to_contents(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
)
|
||||
{
|
||||
DtEditorContentRec rec;
|
||||
|
||||
rec.type = DtEDITOR_TEXT;
|
||||
|
||||
if ( contents[len - 1] == 0 ) {
|
||||
rec.value.string = (char *)contents;
|
||||
} else {
|
||||
this->my_owner->needBuf(&_buffer, &_buf_len, len + 1);
|
||||
this->my_owner->stripCRLF(&_buffer, contents, len);
|
||||
rec.value.string = _buffer;
|
||||
}
|
||||
|
||||
DtEditorInsert(my_text, &rec);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::append_to_contents(
|
||||
const char *path
|
||||
)
|
||||
{
|
||||
|
||||
DtEditorAppendFromFile(my_text, (char *)path);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::append_at_cursor(
|
||||
const char *path
|
||||
)
|
||||
{
|
||||
DtEditorInsertFromFile(my_text, (char *) path);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::append_at_cursor(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
)
|
||||
{
|
||||
DtEditorContentRec rec;
|
||||
|
||||
rec.type = DtEDITOR_TEXT;
|
||||
|
||||
if ( contents[len - 1] == 0 ) {
|
||||
rec.value.string = (char *)contents;
|
||||
} else {
|
||||
this->my_owner->needBuf(&_buffer, &_buf_len, len + 1);
|
||||
this->my_owner->stripCRLF(&_buffer, contents, len);
|
||||
rec.value.string = _buffer;
|
||||
}
|
||||
//DtEditorAppend(my_text, &rec);
|
||||
// Fix for the defect 179186 05-25-95
|
||||
// The above API will insert "contents" to the end of the buffer
|
||||
// (appending). It should change to DtEditorInsert which insert
|
||||
// string to the current position (the cursor's position)
|
||||
DtEditorInsert(my_text, &rec);
|
||||
}
|
||||
|
||||
Widget
|
||||
CDEM_DtWidgetEditor::get_text_widget()
|
||||
{
|
||||
// We actually need to return the text widget contained
|
||||
// within DtEditor. For now, just return the DtEditor.
|
||||
|
||||
return(my_text);
|
||||
}
|
||||
|
||||
Pixel
|
||||
CDEM_DtWidgetEditor::get_text_foreground()
|
||||
{
|
||||
Pixel fg;
|
||||
|
||||
XtVaGetValues(my_text,
|
||||
DtNtextForeground, &fg,
|
||||
NULL);
|
||||
|
||||
return(fg);
|
||||
}
|
||||
|
||||
|
||||
// DtEditor returns the bg color of the Form widget, not the
|
||||
// text widget that the Form contains.
|
||||
// This explains why the attachment pane color is that of the scroll bar...
|
||||
// DtEditor needs to return the color of its text widget.
|
||||
// OBTW, DtNtextBackground and DtNtextForeground don't work. They
|
||||
// return uninitialized values
|
||||
|
||||
Pixel
|
||||
CDEM_DtWidgetEditor::get_text_background()
|
||||
{
|
||||
Pixel bg;
|
||||
|
||||
XtVaGetValues(my_text,
|
||||
DtNtextBackground, &bg,
|
||||
NULL);
|
||||
|
||||
return(bg);
|
||||
}
|
||||
|
||||
XmFontList
|
||||
CDEM_DtWidgetEditor::get_text_fontList()
|
||||
{
|
||||
XmFontList fl;
|
||||
|
||||
XtVaGetValues(my_text,
|
||||
DtNtextFontList, &fl,
|
||||
NULL);
|
||||
|
||||
return(fl);
|
||||
}
|
||||
|
||||
Dimension
|
||||
CDEM_DtWidgetEditor::get_text_width()
|
||||
{
|
||||
Dimension wid;
|
||||
|
||||
XtVaGetValues(my_text,
|
||||
XmNwidth, &wid,
|
||||
NULL);
|
||||
return (wid);
|
||||
}
|
||||
|
||||
|
||||
Widget
|
||||
CDEM_DtWidgetEditor::get_editor()
|
||||
{
|
||||
return(my_text);
|
||||
}
|
||||
|
||||
int
|
||||
CDEM_DtWidgetEditor::get_columns()
|
||||
{
|
||||
short ncolumns;
|
||||
XtVaGetValues(my_text, DtNcolumns, &ncolumns, NULL);
|
||||
return (int) ncolumns;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
CDEM_DtWidgetEditor::get_rows()
|
||||
{
|
||||
short nrows;
|
||||
XtVaGetValues(my_text, DtNrows, &nrows, NULL);
|
||||
return (int) nrows;
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_editable(Boolean bval)
|
||||
{
|
||||
XtVaSetValues(my_text,
|
||||
DtNeditable, bval,
|
||||
DtNcursorPositionVisible, bval,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_columns(int ncolumns)
|
||||
{
|
||||
XtVaSetValues(my_text, DtNcolumns, ncolumns, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_rows(int nrows)
|
||||
{
|
||||
XtVaSetValues(my_text, DtNrows, nrows, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::undo_edit()
|
||||
{
|
||||
|
||||
DtEditorUndoEdit(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::cut_selection()
|
||||
{
|
||||
|
||||
DtEditorCutToClipboard(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::copy_selection()
|
||||
{
|
||||
|
||||
DtEditorCopyToClipboard(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::paste_from_clipboard()
|
||||
{
|
||||
|
||||
DtEditorPasteFromClipboard(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::paste_special_from_clipboard(
|
||||
Editor::InsertFormat format
|
||||
)
|
||||
{
|
||||
int status;
|
||||
unsigned long length, recvd;
|
||||
char *clipboard_data;
|
||||
Display *dpy = XtDisplayOfObject(my_text);
|
||||
Window window = XtWindowOfObject(my_text);
|
||||
|
||||
do {
|
||||
status = XmClipboardInquireLength(dpy, window, "STRING", &length);
|
||||
} while (status == ClipboardLocked);
|
||||
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
clipboard_data = XtMalloc((unsigned)length);
|
||||
|
||||
do {
|
||||
status = XmClipboardRetrieve(
|
||||
dpy, window, "STRING", clipboard_data,
|
||||
length, &recvd, NULL
|
||||
);
|
||||
} while (status == ClipboardLocked);
|
||||
|
||||
if (status != ClipboardSuccess || recvd != length) {
|
||||
// Couldn't get all
|
||||
|
||||
XtFree(clipboard_data);
|
||||
return;
|
||||
}
|
||||
|
||||
// Now modify the data such that the necessary formatting occurs
|
||||
// within it. Bracketting will cause a line at the beginning and
|
||||
// end of the data. Indenting will prepend a ">" before each line,
|
||||
// realigning the lines if necessary.
|
||||
// The results are stored in _modified_text so clipboard_data can
|
||||
// be freed immediately after this call.
|
||||
|
||||
this->modifyData(clipboard_data, (unsigned) length, format);
|
||||
XtFree(clipboard_data);
|
||||
|
||||
// Now copy the modified data stripped of CRLFs to a buffer.
|
||||
// Put that buffer into the structure appropriate for DtEditor.
|
||||
|
||||
DtEditorContentRec rec;
|
||||
|
||||
rec.type = DtEDITOR_TEXT;
|
||||
|
||||
// Length needs to be reset since the text now contains
|
||||
// new characters that do the necessary formatting.
|
||||
|
||||
length = _modified_text->length;
|
||||
|
||||
if ( _modified_text->ptr[(unsigned) length - 1] == 0 ) {
|
||||
rec.value.string = (char *)_modified_text->ptr;
|
||||
} else {
|
||||
this->my_owner->needBuf(
|
||||
&_buffer, &_buf_len,
|
||||
(unsigned) length + 1
|
||||
);
|
||||
this->my_owner->stripCRLF(
|
||||
&_buffer, _modified_text->ptr,
|
||||
(unsigned) length);
|
||||
rec.value.string = _buffer;
|
||||
}
|
||||
|
||||
DtEditorInsert(my_text, &rec);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::clear_selection()
|
||||
{
|
||||
|
||||
DtEditorClearSelection(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::delete_selection()
|
||||
{
|
||||
DtEditorDeleteSelection(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_word_wrap(
|
||||
Boolean bval
|
||||
)
|
||||
{
|
||||
XtVaSetValues(my_text, DtNwordWrap, bval, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_to_top()
|
||||
{
|
||||
XtVaSetValues(my_text,
|
||||
DtNtopCharacter, 0,
|
||||
DtNcursorPosition, 0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::text_selected_callback(
|
||||
Widget,
|
||||
void * clientData,
|
||||
void *
|
||||
)
|
||||
{
|
||||
|
||||
CDEM_DtWidgetEditor *obj=(CDEM_DtWidgetEditor *) clientData;
|
||||
|
||||
obj->text_selected();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::text_unselected_callback(
|
||||
Widget,
|
||||
void * clientData,
|
||||
void *
|
||||
)
|
||||
{
|
||||
|
||||
CDEM_DtWidgetEditor *obj=(CDEM_DtWidgetEditor *) clientData;
|
||||
|
||||
obj->text_unselected();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::text_selected()
|
||||
{
|
||||
|
||||
if (!text_already_selected) {
|
||||
text_already_selected = TRUE;
|
||||
my_owner->owner()->text_selected();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::text_unselected()
|
||||
{
|
||||
|
||||
my_owner->owner()->text_unselected();
|
||||
text_already_selected = FALSE;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::find_change()
|
||||
{
|
||||
DtEditorInvokeFindChangeDialog(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::spell()
|
||||
{
|
||||
DtEditorInvokeSpellDialog(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::format()
|
||||
{
|
||||
DtEditorInvokeFormatDialog(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::auto_show_cursor_off()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::auto_show_cursor_restore()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::select_all()
|
||||
{
|
||||
DtEditorSelectAll(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_to_bottom()
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
CDEM_DtWidgetEditor::no_text()
|
||||
{
|
||||
char *text = get_contents();
|
||||
int text_len = strlen(text);
|
||||
int result = 1;
|
||||
|
||||
for ( int k = 0; k < text_len; k++ ) {
|
||||
if ( isgraph(text[k]) ) {
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XtFree(text);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::disable_redisplay()
|
||||
{
|
||||
DtEditorDisableRedisplay(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::enable_redisplay()
|
||||
{
|
||||
|
||||
DtEditorEnableRedisplay(my_text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This fucntion modifies the pasted data
|
||||
* with an indent prefix before each new line or brackets it.
|
||||
*/
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::modifyData(
|
||||
char *sp, // source pointer to the insert string
|
||||
int length, // length does not include '\0' char
|
||||
Editor::InsertFormat insert_format
|
||||
)
|
||||
{
|
||||
if(_modified_text == NULL)
|
||||
_modified_text = (XmTextBlockRec *)calloc(1,sizeof(XmTextBlockRec));
|
||||
|
||||
char *maxsp = sp + length; // maxmimum source ptr
|
||||
|
||||
// Allocate memory rounded off to the nearest BUFINC
|
||||
size_t size_req = (size_t)(((length/BUFINC)+1)*BUFINC);
|
||||
if((_modified_text_buflen < size_req) ||
|
||||
((_modified_text_buflen > CDEM_DtWidgetEditor::MAXBUFSZ) &&
|
||||
(size_req < CDEM_DtWidgetEditor::MAXBUFSZ)) )
|
||||
reallocPasteBuf(size_req);
|
||||
|
||||
if(_modified_text->ptr == NULL)
|
||||
return; // No memory available
|
||||
|
||||
switch( insert_format) {
|
||||
case IF_INDENTED:
|
||||
{
|
||||
DtMailEnv error;
|
||||
int ip = 0;
|
||||
|
||||
// Get the indent prefix string
|
||||
DtMail::Session *m_session = theRoamApp.session()->session();
|
||||
m_session->mailRc(error)->getValue(error,"indentprefix", &indent_str);
|
||||
if (error.isSet() || NULL == indent_str)
|
||||
indent_str = strdup("> ");
|
||||
|
||||
size_t indlen = strlen(indent_str);
|
||||
|
||||
// Copy the src buf into dest, inserting indent before '\n'
|
||||
while(sp < maxsp) {
|
||||
|
||||
// Make sure there is enough space
|
||||
// for an indent prefix, one char and a terminating '\0'
|
||||
if(!((ip+indlen+2) < _modified_text_buflen) ) {
|
||||
size_req = (size_t)((((_modified_text_buflen +
|
||||
indlen+2)/BUFINC)+1)*BUFINC);
|
||||
reallocPasteBuf(size_req);
|
||||
if(_modified_text->ptr == NULL)
|
||||
return; // No memory available
|
||||
}
|
||||
|
||||
// Copy the indent string at the beginning
|
||||
if(!ip) {
|
||||
memcpy(_modified_text->ptr, indent_str, indlen);
|
||||
ip += indlen;
|
||||
}
|
||||
|
||||
// Copy the next byte and check for new line
|
||||
_modified_text->ptr[ip++] = *sp++;
|
||||
if(*(sp-1) == '\n') {
|
||||
memcpy(&_modified_text->ptr[ip], indent_str, indlen);
|
||||
ip += indlen;
|
||||
}
|
||||
|
||||
}
|
||||
_modified_text->ptr[ip] = '\0'; // terminate with a null char
|
||||
_modified_text->length = ip; // Do not include '\0' char in len
|
||||
}
|
||||
break;
|
||||
case IF_BRACKETED:
|
||||
{
|
||||
|
||||
if( !begin_ins_bracket)
|
||||
begin_ins_bracket = GETMSG(DT_catd, 1, 201,
|
||||
"\n------------- Begin Included Message -------------\n");
|
||||
if(!end_ins_bracket)
|
||||
end_ins_bracket = GETMSG(DT_catd, 1, 202,
|
||||
"\n------------- End Included Message -------------\n");
|
||||
|
||||
size_t begin_len = strlen(begin_ins_bracket);
|
||||
size_t end_len = strlen(end_ins_bracket);
|
||||
|
||||
// Make sure there is enough space
|
||||
if((size_req = length + begin_len + end_len + 1) >
|
||||
_modified_text_buflen) {
|
||||
size_req = (size_t) ((((size_req)/BUFINC)+1)*BUFINC);
|
||||
reallocPasteBuf(size_req);
|
||||
}
|
||||
|
||||
if(_modified_text->ptr == NULL)
|
||||
return;
|
||||
|
||||
strcpy(_modified_text->ptr, begin_ins_bracket);
|
||||
strncat(_modified_text->ptr,sp,length);
|
||||
strcat(_modified_text->ptr, end_ins_bracket);
|
||||
_modified_text->length = end_len + begin_len + length;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::MenuButtonHandler(
|
||||
Widget ,
|
||||
XtPointer cd,
|
||||
XEvent *event,
|
||||
Boolean *)
|
||||
{
|
||||
CDEM_DtWidgetEditor *obj = (CDEM_DtWidgetEditor *)cd;
|
||||
|
||||
if(event->xany.type != ButtonPress)
|
||||
return;
|
||||
|
||||
XButtonEvent *be = (XButtonEvent *)event;
|
||||
|
||||
if(be->button == Button3)
|
||||
obj->my_owner->owner()->postTextPopup(event);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
157
cde/programs/dtmail/dtmail/DtEditor.hh
Normal file
157
cde/programs/dtmail/dtmail/DtEditor.hh
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtEditor.hh /main/9 1998/02/03 10:28:23 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DTEDITOR_HH
|
||||
#define DTEDITOR_HH
|
||||
|
||||
// Include the DtWidgetEditor .h file given by HP.
|
||||
|
||||
#include <Dt/Editor.h>
|
||||
|
||||
#include "Editor.hh"
|
||||
#include "DtMailEditor.hh"
|
||||
|
||||
class CDEM_DtWidgetEditor : public Editor
|
||||
{
|
||||
|
||||
public:
|
||||
CDEM_DtWidgetEditor(
|
||||
Widget parent,
|
||||
DtMailEditor *owner_of_editor);
|
||||
~CDEM_DtWidgetEditor();
|
||||
|
||||
// Pure virtual functions of class Editor
|
||||
//
|
||||
virtual void initialize();
|
||||
|
||||
virtual void set_contents(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
);
|
||||
|
||||
virtual void set_contents(const char *path);
|
||||
|
||||
virtual char* get_contents();
|
||||
|
||||
virtual void append_to_contents(
|
||||
const char *new_contents,
|
||||
const unsigned long len
|
||||
);
|
||||
|
||||
virtual void append_to_contents(const char *path);
|
||||
|
||||
virtual void append_at_cursor(const char *path);
|
||||
|
||||
virtual void append_at_cursor(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
);
|
||||
|
||||
virtual void clear_contents();
|
||||
virtual int no_text();
|
||||
|
||||
virtual Widget get_text_widget();
|
||||
virtual Pixel get_text_foreground();
|
||||
virtual Pixel get_text_background();
|
||||
virtual Dimension get_text_width();
|
||||
virtual XmFontList get_text_fontList();
|
||||
virtual Widget get_editor();
|
||||
|
||||
virtual int get_columns();
|
||||
virtual int get_rows();
|
||||
virtual void set_columns(int ncolumns);
|
||||
virtual void set_editable(Boolean value);
|
||||
virtual void set_rows(int nrows);
|
||||
|
||||
virtual void auto_show_cursor_off();
|
||||
virtual void auto_show_cursor_restore();
|
||||
|
||||
virtual void set_to_top();
|
||||
virtual void set_to_bottom();
|
||||
|
||||
virtual void cut_selection();
|
||||
virtual void copy_selection();
|
||||
virtual void paste_from_clipboard();
|
||||
virtual void paste_special_from_clipboard(Editor::InsertFormat);
|
||||
virtual void clear_selection();
|
||||
virtual void delete_selection();
|
||||
virtual void select_all();
|
||||
|
||||
virtual void disable_redisplay();
|
||||
virtual void enable_redisplay();
|
||||
|
||||
//
|
||||
// End of Pure virtual functions for class Editor.
|
||||
|
||||
// Pure virtual functions of class AbstractEditorParent
|
||||
virtual void text_selected();
|
||||
virtual void text_unselected();
|
||||
|
||||
// Functions specific to DtEditor
|
||||
virtual void set_word_wrap(Boolean value);
|
||||
virtual void undo_edit();
|
||||
virtual void find_change();
|
||||
virtual void spell();
|
||||
virtual void format();
|
||||
|
||||
static void MenuButtonHandler(Widget, XtPointer, XEvent *, Boolean *);
|
||||
|
||||
protected:
|
||||
|
||||
// modify verify callback used during Paste Special
|
||||
static void modify_verify_callback(Widget, XtPointer, XtPointer);
|
||||
|
||||
static void text_selected_callback(Widget, void *, void *);
|
||||
static void text_unselected_callback(Widget, void *, void *);
|
||||
|
||||
|
||||
private:
|
||||
struct PSClientData {
|
||||
CDEM_DtWidgetEditor *obj;
|
||||
Editor::InsertFormat insert_format;
|
||||
};
|
||||
XmTextBlockRec *_modified_text;
|
||||
size_t _modified_text_buflen;
|
||||
enum PasteSpecBuf { MAXBUFSZ = 2048, BUFINC = 512};
|
||||
void modifyData(char *, int, Editor::InsertFormat);
|
||||
void reallocPasteBuf(size_t size_req) {
|
||||
_modified_text->ptr =
|
||||
(char *)realloc((void *)_modified_text->ptr, size_req);
|
||||
_modified_text_buflen = size_req;
|
||||
}
|
||||
|
||||
const char *indent_str;
|
||||
const char *begin_ins_bracket;
|
||||
const char *end_ins_bracket;
|
||||
|
||||
Widget my_parent;
|
||||
Widget my_text;
|
||||
Widget my_text_core;
|
||||
|
||||
DtMailEditor *my_owner;
|
||||
Boolean text_already_selected;
|
||||
Boolean _auto_show_cursor;
|
||||
|
||||
char * _buffer;
|
||||
unsigned long _buf_len;
|
||||
|
||||
};
|
||||
|
||||
#endif // DTEDITOR_HH
|
||||
1162
cde/programs/dtmail/dtmail/DtMail.msg
Normal file
1162
cde/programs/dtmail/dtmail/DtMail.msg
Normal file
File diff suppressed because it is too large
Load Diff
91
cde/programs/dtmail/dtmail/DtMailDialogCallbackData.hh
Normal file
91
cde/programs/dtmail/dtmail/DtMailDialogCallbackData.hh
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: DtMailDialogCallbackData.hh /main/4 1996/04/21 19:41:35 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// DtMailDialogCallbackData.h: Auxiliary class used by DtMailGenDialog
|
||||
//////////////////////////////////////////////////////////////
|
||||
#ifndef DTMAILDIALOGCALLBACKDATA
|
||||
#define DTMAILDIALOGCALLBACKDATA
|
||||
|
||||
class DtMailGenDialog;
|
||||
|
||||
typedef void (*DialogCallback)( void * );
|
||||
|
||||
class DtMailDialogCallbackData {
|
||||
|
||||
private:
|
||||
|
||||
DtMailGenDialog *_dialog;
|
||||
DialogCallback _ok;
|
||||
DialogCallback _help;
|
||||
DialogCallback _cancel;
|
||||
DialogCallback _other;
|
||||
void *_clientData;
|
||||
Widget _other_w;
|
||||
|
||||
public:
|
||||
|
||||
DtMailDialogCallbackData ( DtMailGenDialog *dialog,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback other,
|
||||
DialogCallback help,
|
||||
Widget other_w)
|
||||
{
|
||||
_dialog = dialog;
|
||||
_ok = ok;
|
||||
_help = help;
|
||||
_cancel = cancel;
|
||||
_other = other;
|
||||
_clientData = clientData;
|
||||
_other_w = other_w;
|
||||
}
|
||||
|
||||
DtMailGenDialog *dialog() { return _dialog; }
|
||||
DialogCallback ok() { return _ok; }
|
||||
DialogCallback help() { return _help; }
|
||||
DialogCallback cancel() { return _cancel; }
|
||||
DialogCallback other() { return _other; }
|
||||
void *clientData() { return _clientData; }
|
||||
Widget other_w() { return _other_w; }
|
||||
};
|
||||
#endif
|
||||
|
||||
580
cde/programs/dtmail/dtmail/DtMailEditor.C
Normal file
580
cde/programs/dtmail/dtmail/DtMailEditor.C
Normal file
@@ -0,0 +1,580 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtMailEditor.C /main/10 1998/07/24 16:05:41 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef I_HAVE_NO_IDENT
|
||||
#else
|
||||
#endif
|
||||
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/SeparatoG.h>
|
||||
#include <Dt/Dnd.h>
|
||||
#include "DtMailEditor.hh"
|
||||
#include "XmTextEditor.h"
|
||||
#include "AttachArea.h"
|
||||
#include "Attachment.h"
|
||||
#ifdef DTEDITOR
|
||||
#include "DtEditor.hh"
|
||||
#endif
|
||||
|
||||
#include "EUSDebug.hh"
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern XtPointer _XmStringUngenerate (
|
||||
XmString string,
|
||||
XmStringTag tag,
|
||||
XmTextType tag_type,
|
||||
XmTextType output_type);
|
||||
}
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(x) (((x) > 0) ? (x) : (-(x)))
|
||||
#endif
|
||||
|
||||
#ifndef DRAG_THRESHOLD
|
||||
#define DRAG_THRESHOLD 4
|
||||
#endif
|
||||
|
||||
DtMailEditor::DtMailEditor(
|
||||
Widget parent,
|
||||
AbstractEditorParent *owner
|
||||
) : UIComponent("DtMailEditor")
|
||||
{
|
||||
_myOwner = owner;
|
||||
|
||||
// Create a manager widget (say a form) and set it to the private
|
||||
// variable _container. Parent private instances to this widget.
|
||||
// Expose only _container externally (for attachment stuff...)
|
||||
|
||||
_w = XmCreateForm(parent, "DtMailEditor", NULL, 0);
|
||||
installDestroyHandler();
|
||||
|
||||
#ifdef DTEDITOR
|
||||
if ( use_XmTextEditor ) {
|
||||
_myTextEditor = new XmTextEditor(_w, this);
|
||||
} else {
|
||||
_myTextEditor = new CDEM_DtWidgetEditor(_w, this);
|
||||
}
|
||||
#else
|
||||
_myTextEditor = new XmTextEditor(_w, this);
|
||||
#endif
|
||||
|
||||
_myAttachArea = new AttachArea(_w, this, "AttachPane");
|
||||
|
||||
_showAttachArea = TRUE;
|
||||
_doingDrag = FALSE;
|
||||
_separator = NULL;
|
||||
_msgHandle = NULL;
|
||||
_dragX = -1;
|
||||
_dragY = -1;
|
||||
_editable = FALSE;
|
||||
|
||||
}
|
||||
|
||||
DtMailEditor::~DtMailEditor()
|
||||
{
|
||||
unmanageAttachArea();
|
||||
delete _myAttachArea;
|
||||
delete _myTextEditor;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::initialize()
|
||||
{
|
||||
|
||||
Widget editor_widget;
|
||||
|
||||
_myTextEditor->initialize();
|
||||
|
||||
_separator = XtVaCreateManagedWidget("Sep1",
|
||||
xmSeparatorGadgetClass,
|
||||
_w,
|
||||
XmNtopOffset, 1,
|
||||
XmNbottomOffset, 1,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
// Create an *UNMANAGED* attachArea.
|
||||
// If the message has an attachment, the DtMailEditor instance
|
||||
// will receive a manageAttachArea where it will adjust the
|
||||
// attachments and manage the attachArea accordingly
|
||||
|
||||
_myAttachArea->initialize();
|
||||
|
||||
attachDropRegister();
|
||||
if (!_editable)
|
||||
attachDropDisable();
|
||||
|
||||
editor_widget = _myTextEditor->get_editor();
|
||||
|
||||
XtVaSetValues(editor_widget,
|
||||
XmNtopAttachment,XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _separator,
|
||||
XmNrightAttachment,XmATTACH_FORM,
|
||||
XmNrightOffset, 4,
|
||||
XmNleftAttachment,XmATTACH_FORM,
|
||||
XmNleftOffset, 3,
|
||||
NULL );
|
||||
|
||||
XtVaSetValues(_myAttachArea->baseWidget(),
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNrightOffset, 3,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNleftOffset, 5,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(_separator,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _myAttachArea->baseWidget(),
|
||||
NULL);
|
||||
|
||||
// Unmanage the attachArea. If a message has attachments,
|
||||
// manageAttachArea() will get called by the consumer of this
|
||||
// class.
|
||||
|
||||
this->unmanageAttachArea();
|
||||
|
||||
XtManageChild(_w);
|
||||
|
||||
}
|
||||
|
||||
AbstractEditorParent *
|
||||
DtMailEditor::owner()
|
||||
{
|
||||
return (_myOwner);
|
||||
}
|
||||
|
||||
Editor*
|
||||
DtMailEditor::textEditor()
|
||||
{
|
||||
return(_myTextEditor);
|
||||
}
|
||||
|
||||
AttachArea*
|
||||
DtMailEditor::attachArea()
|
||||
{
|
||||
return(_myAttachArea);
|
||||
}
|
||||
|
||||
Widget
|
||||
DtMailEditor::container()
|
||||
{
|
||||
return(_w);
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::setEditable(Boolean bval)
|
||||
{
|
||||
textEditor()->set_editable(bval);
|
||||
_editable = bval;
|
||||
if (_editable)
|
||||
attachDropEnable();
|
||||
else
|
||||
attachDropDisable();
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::manageAttachArea()
|
||||
{
|
||||
|
||||
if (!_showAttachArea && (_myAttachArea->getIconCount() == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_myAttachArea->manage();
|
||||
XtManageChild(_separator);
|
||||
|
||||
Widget editor_widget = _myTextEditor->get_editor();
|
||||
|
||||
XtVaSetValues(editor_widget,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _separator,
|
||||
NULL );
|
||||
|
||||
XtVaSetValues(_separator,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _myAttachArea->baseWidget(),
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(_myAttachArea->baseWidget(),
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::unmanageAttachArea()
|
||||
{
|
||||
|
||||
// Already unmanaged?
|
||||
if (!XtIsManaged(_myAttachArea->baseWidget())) return;
|
||||
|
||||
Widget editor_widget = _myTextEditor->get_editor();
|
||||
|
||||
XtVaSetValues(editor_widget,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL );
|
||||
|
||||
_myAttachArea->unmanage();
|
||||
|
||||
XtUnmanageChild(_separator);
|
||||
|
||||
}
|
||||
|
||||
// Initialize _msgHandle
|
||||
void
|
||||
DtMailEditor::setMsgHnd(DtMail::Message * msgHandle)
|
||||
{
|
||||
_msgHandle = msgHandle;
|
||||
}
|
||||
|
||||
// attachTransferCallback
|
||||
//
|
||||
// Handles the transfer of data that is dropped on the attachment list.
|
||||
// The data is turned into an attachment and appended to the list.
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachTransferCallback(
|
||||
Widget /* widget */,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
DtDndTransferCallbackStruct *transferInfo =
|
||||
(DtDndTransferCallbackStruct *) call_data;
|
||||
DtDndContext *dropData = transferInfo->dropData;
|
||||
int numItems = dropData->numItems, ii;
|
||||
DtMailEditor *editor = (DtMailEditor *) client_data;
|
||||
DtMailEnv mail_error;
|
||||
DtMailBuffer buf;
|
||||
char *attachname;
|
||||
|
||||
DebugPrintf(3, "In DtMailEditor::attachTransferCallback\n");
|
||||
|
||||
// Initialize mail_error.
|
||||
mail_error.clear();
|
||||
|
||||
switch (transferInfo->dropData->protocol) {
|
||||
|
||||
case DtDND_FILENAME_TRANSFER:
|
||||
|
||||
// Loop through the dropped files and turn each
|
||||
// into an attachment.
|
||||
|
||||
for (ii = 0; ii < numItems; ii++) {
|
||||
editor->owner()->add_att(dropData->data.files[ii]);
|
||||
}
|
||||
break;
|
||||
|
||||
case DtDND_BUFFER_TRANSFER:
|
||||
|
||||
// Loop through the dropped buffers and turn each
|
||||
// into an attachment.
|
||||
|
||||
for (ii = 0; ii < numItems; ii++) {
|
||||
|
||||
buf.buffer = (char *)dropData->data.buffers[ii].bp;
|
||||
buf.size = (unsigned long)dropData->data.buffers[ii].size;
|
||||
attachname = dropData->data.buffers[ii].name;
|
||||
|
||||
if (!attachname)
|
||||
attachname = "Untitled";
|
||||
|
||||
editor->owner()->add_att(attachname, buf);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
transferInfo->status = DtDND_FAILURE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// attachDropRegister
|
||||
//
|
||||
// Register the attachment list to accept drops of buffer and files
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachDropRegister()
|
||||
{
|
||||
static XtCallbackRec transferCBRec[] = {
|
||||
{&DtMailEditor::attachTransferCallback, NULL}, {NULL, NULL} };
|
||||
|
||||
// Pass the DtMailEditor object (this) as clientData.
|
||||
transferCBRec[0].closure = (XtPointer) this;
|
||||
|
||||
DtDndVaDropRegister(_myAttachArea->baseWidget(),
|
||||
DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER,
|
||||
(unsigned char)(XmDROP_COPY), transferCBRec,
|
||||
DtNtextIsBuffer, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
// attachDropEnable
|
||||
//
|
||||
// Enable the attachment list for drops by restoring the operation
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachDropEnable()
|
||||
{
|
||||
Arg args[1];
|
||||
|
||||
XtSetArg(args[0], XmNdropSiteOperations, XmDROP_MOVE | XmDROP_COPY);
|
||||
XmDropSiteUpdate(_myAttachArea->baseWidget(), args, 1);
|
||||
}
|
||||
|
||||
// attachDropDisable
|
||||
//
|
||||
// Disable the attachment list for drops by setting the operation to noop
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachDropDisable()
|
||||
{
|
||||
Arg args[1];
|
||||
|
||||
XtSetArg(args[0], XmNdropSiteOperations, XmDROP_NOOP);
|
||||
XmDropSiteUpdate(_myAttachArea->baseWidget(), args, 1);
|
||||
}
|
||||
|
||||
// attachConvertCallback
|
||||
//
|
||||
// Provides the selected attachments for the drag
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachConvertCallback(
|
||||
Widget /* dragContext */,
|
||||
XtPointer clientData,
|
||||
XtPointer callData)
|
||||
{
|
||||
DtDndConvertCallbackStruct *convertInfo =
|
||||
(DtDndConvertCallbackStruct *) callData;
|
||||
DtDndBuffer *buffers = convertInfo->dragData->data.buffers;
|
||||
DtMailEditor *editor = (DtMailEditor *) clientData;
|
||||
int numIcons = editor->attachArea()->getIconCount();
|
||||
Attachment **list = editor->attachArea()->getList();
|
||||
int ii, current = 0;
|
||||
char *name = NULL;
|
||||
XmString str;
|
||||
DtMailEnv mail_error;
|
||||
|
||||
|
||||
DebugPrintf(3, "In DtMailEditor::attachConvertCallback\n");
|
||||
|
||||
switch(convertInfo->reason) {
|
||||
case DtCR_DND_CONVERT_DATA:
|
||||
for (ii = 0; ii < numIcons; ii++) {
|
||||
if (!list[ii]->isDeleted() && list[ii]->isSelected()) {
|
||||
buffers[current].bp = list[ii]->getContents();
|
||||
buffers[current].size = (int)list[ii]->getContentsSize();
|
||||
str = list[ii]->getLabel();
|
||||
buffers[current].name =
|
||||
(char *) _XmStringUngenerate(
|
||||
str, NULL,
|
||||
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
|
||||
XmStringFree(str);
|
||||
current++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DtCR_DND_CONVERT_DELETE:
|
||||
editor->attachArea()->deleteSelectedAttachments(mail_error);
|
||||
break;
|
||||
|
||||
default:
|
||||
convertInfo->status = DtDND_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// attachDragFinishCallback
|
||||
//
|
||||
// Clean up from the convert callback and restore state
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachDragFinishCallback(
|
||||
Widget /* widget */,
|
||||
XtPointer clientData,
|
||||
XtPointer callData)
|
||||
{
|
||||
DtDndDragFinishCallbackStruct *finishInfo =
|
||||
(DtDndDragFinishCallbackStruct *) callData;
|
||||
DtDndContext *dragData = finishInfo->dragData;
|
||||
DtMailEditor *editor = (DtMailEditor *) clientData;
|
||||
int ii;
|
||||
|
||||
DebugPrintf(3, "In DtMailEditor::attachDragFinishCallback\n");
|
||||
|
||||
editor->setDoingDrag(FALSE);
|
||||
editor->setDragX(-1);
|
||||
editor->setDragY(-1);
|
||||
|
||||
if (editor->editable())
|
||||
editor->attachDropEnable();
|
||||
|
||||
for (ii = 0; ii < dragData->numItems; ii++) {
|
||||
XtFree((char *)dragData->data.buffers[ii].name);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::attachDragStart( Widget widget,
|
||||
XEvent *event)
|
||||
{
|
||||
static XtCallbackRec convertCBRec[] = {
|
||||
{&DtMailEditor::attachConvertCallback, NULL}, {NULL, NULL} };
|
||||
static XtCallbackRec dragFinishCBRec[] = {
|
||||
{&DtMailEditor::attachDragFinishCallback, NULL}, {NULL, NULL} };
|
||||
int itemCount;
|
||||
unsigned char operations;
|
||||
|
||||
convertCBRec[0].closure = (XtPointer) this;
|
||||
dragFinishCBRec[0].closure = (XtPointer) this;
|
||||
|
||||
attachDropDisable();
|
||||
|
||||
// Count the number of items to be dragged.
|
||||
itemCount = attachArea()->getSelectedIconCount();
|
||||
|
||||
setDoingDrag(TRUE);
|
||||
|
||||
if (editable()) {
|
||||
operations = (unsigned char)(XmDROP_COPY | XmDROP_MOVE);
|
||||
} else {
|
||||
operations = (unsigned char)(XmDROP_COPY);
|
||||
}
|
||||
|
||||
if (DtDndVaDragStart(widget, event, DtDND_BUFFER_TRANSFER, itemCount,
|
||||
operations, convertCBRec, dragFinishCBRec,
|
||||
// DtNsourceIcon, dragIcon,
|
||||
NULL)
|
||||
== NULL) {
|
||||
|
||||
DebugPrintf(3, "DragStart returned NULL.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::attachDragMotionHandler(
|
||||
Widget widget,
|
||||
XEvent *event)
|
||||
{
|
||||
int diffX, diffY;
|
||||
|
||||
if (!doingDrag()) {
|
||||
// If the drag is just starting, set initial button down coordinates.
|
||||
if (dragX() == -1 && dragY() == -1) {
|
||||
setDragX(event->xmotion.x);
|
||||
setDragY(event->xmotion.y);
|
||||
}
|
||||
|
||||
// Find out how far the pointer has moved since the button press.
|
||||
diffX = dragX() - event->xmotion.x;
|
||||
diffY = dragY() - event->xmotion.y;
|
||||
|
||||
if ((ABS(diffX) >= DRAG_THRESHOLD) ||
|
||||
(ABS(diffY) >= DRAG_THRESHOLD)) {
|
||||
attachDragStart(widget, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef notdef
|
||||
void
|
||||
DtMailEditor::attachDragSetup()
|
||||
{
|
||||
Boolean btn1_transfer;
|
||||
Widget widget = _myAttachArea->baseWidget();
|
||||
|
||||
DebugPrintf(3, "In DtMailEditor::attachDragSetup()\n");
|
||||
|
||||
XtAddEventHandler(widget, Button1MotionMask, FALSE,
|
||||
(XtEventHandler)&DtMailEditor::attachDragMotionHandler,
|
||||
(XtPointer)this);
|
||||
|
||||
XtVaGetValues(
|
||||
(Widget)XmGetXmDisplay(XtDisplayOfObject(widget)),
|
||||
"enableBtn1Transfer", &btn1_transfer,
|
||||
NULL);
|
||||
|
||||
if (!btn1_transfer) {
|
||||
XtAddEventHandler(widget, Button2MotionMask, FALSE,
|
||||
(XtEventHandler)&DtMailEditor::attachDragMotionHandler,
|
||||
(XtPointer)this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
DtMailEditor::stripCRLF(char **buffer, const char * buf, const unsigned long len)
|
||||
{
|
||||
char * out = *buffer;
|
||||
int _len;
|
||||
|
||||
|
||||
for (const char * in = buf; in < (buf + len);) {
|
||||
_len = mblen( in, MB_CUR_MAX );
|
||||
if ( _len <= 0 )
|
||||
break;
|
||||
if ( ( _len == 1 ) && ( *in == '\r' ) ){
|
||||
in += 1;
|
||||
continue;
|
||||
}
|
||||
strncpy( out, in, _len );
|
||||
out += _len, in += _len;
|
||||
}
|
||||
*out = 0;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::needBuf(char **buffer, unsigned long *buflen, unsigned long newlen)
|
||||
{
|
||||
if (newlen > *buflen) {
|
||||
// Need a bigger buffer.
|
||||
if (*buffer) {
|
||||
delete [] *buffer;
|
||||
}
|
||||
|
||||
*buffer = new char[newlen];
|
||||
*buflen = newlen;
|
||||
} else {
|
||||
// Clear buffer content -- get ready for new data
|
||||
if (*buffer) {
|
||||
memset(*buffer, 0, (unsigned int)*buflen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::showAttachArea()
|
||||
{
|
||||
_showAttachArea = TRUE;
|
||||
this->manageAttachArea();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::hideAttachArea()
|
||||
{
|
||||
_showAttachArea = FALSE;
|
||||
this->unmanageAttachArea();
|
||||
}
|
||||
93
cde/programs/dtmail/dtmail/DtMailEditor.hh
Normal file
93
cde/programs/dtmail/dtmail/DtMailEditor.hh
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtMailEditor.hh /main/5 1997/06/06 12:45:31 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DTMAILEDITOR_H
|
||||
#define DTMAILEDITOR_H
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include "Editor.hh"
|
||||
#include "AttachArea.h"
|
||||
|
||||
|
||||
class DtMailEditor : public UIComponent {
|
||||
|
||||
public:
|
||||
|
||||
DtMailEditor(
|
||||
Widget,
|
||||
AbstractEditorParent *
|
||||
);
|
||||
virtual ~DtMailEditor();
|
||||
|
||||
void initialize();
|
||||
AbstractEditorParent *owner();
|
||||
|
||||
Editor *textEditor();
|
||||
AttachArea *attachArea();
|
||||
|
||||
Widget container();
|
||||
|
||||
void showAttachArea();
|
||||
void hideAttachArea();
|
||||
void manageAttachArea();
|
||||
void unmanageAttachArea();
|
||||
void setMsgHnd( DtMail::Message *);
|
||||
static void attachTransferCallback(Widget, XtPointer, XtPointer );
|
||||
void attachDropRegister();
|
||||
void attachDropEnable();
|
||||
void attachDropDisable();
|
||||
static void attachConvertCallback(Widget, XtPointer, XtPointer);
|
||||
static void attachDragFinishCallback(Widget, XtPointer, XtPointer);
|
||||
void attachDragStart(Widget, XEvent *);
|
||||
void attachDragMotionHandler(Widget, XEvent *);
|
||||
//void attachDragSetup();
|
||||
void setEditable(Boolean);
|
||||
Boolean editable() { return _editable; }
|
||||
Boolean doingDrag() { return _doingDrag; }
|
||||
void setDoingDrag(Boolean doingDrag) { _doingDrag = doingDrag; }
|
||||
void setDragX(int n) { _dragX = n; }
|
||||
void setDragY(int n) { _dragY = n; }
|
||||
int dragX() { return _dragX; }
|
||||
int dragY() { return _dragY; }
|
||||
|
||||
// Routines to null terminate buffer.
|
||||
void needBuf(char **, unsigned long *, unsigned long len);
|
||||
void stripCRLF(char **, const char * buf, const unsigned long len);
|
||||
|
||||
private:
|
||||
|
||||
DtMail::Message *_msgHandle;
|
||||
Editor *_myTextEditor;
|
||||
AttachArea *_myAttachArea;
|
||||
Widget _container;
|
||||
Widget _separator;
|
||||
|
||||
Boolean _editable;
|
||||
Boolean _showAttachArea;
|
||||
Boolean _doingDrag;
|
||||
int _dragX;
|
||||
int _dragY;
|
||||
|
||||
// Can be RMW or VMD or SMD
|
||||
AbstractEditorParent *_myOwner;
|
||||
|
||||
};
|
||||
|
||||
#endif // DTMAILEDITOR_HH
|
||||
890
cde/programs/dtmail/dtmail/DtMailGenDialog.C
Normal file
890
cde/programs/dtmail/dtmail/DtMailGenDialog.C
Normal file
@@ -0,0 +1,890 @@
|
||||
/* $TOG: DtMailGenDialog.C /main/15 1999/07/07 15:08:18 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtMailGenDialog.C /main/15 1999/07/07 15:08:18 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
//////////////////////////////////////////////////////////
|
||||
// DtMailGenDialog.C: Generic dialog based on MessageBox
|
||||
//////////////////////////////////////////////////////////
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <Dt/Dt.h>
|
||||
#include <Dt/Icon.h>
|
||||
#include <Dt/IconP.h>
|
||||
#include <Dt/IconFile.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include <Xm/PushBG.h>
|
||||
#include <Xm/MwmUtil.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "DtMailGenDialog.hh"
|
||||
#include "DtMailHelp.hh"
|
||||
#include "Help.hh"
|
||||
#include "MailMsg.h"
|
||||
|
||||
static const char *ABOUT_TITLE = NULL;
|
||||
static char *DTMAIL_VERSION = NULL;
|
||||
static const char *credits = "Dtmail was brought to you by: ";
|
||||
static int doCredits = 0;
|
||||
|
||||
DtMailGenDialog::DtMailGenDialog(char *name, Widget parent, int style)
|
||||
: UIComponent(name)
|
||||
{
|
||||
|
||||
_w = XmCreateMessageDialog(parent, name, NULL, 0);
|
||||
XtVaSetValues(_w, XmNdialogStyle, style, NULL);
|
||||
|
||||
// Disable the frame menu from all dialogs. We don't want
|
||||
// the user to be able to dismiss dialogs through the frame
|
||||
// menu.
|
||||
//
|
||||
XtVaSetValues(
|
||||
XtParent(_w),
|
||||
XmNmwmDecorations, MWM_DECOR_ALL | MWM_DECOR_MENU,
|
||||
NULL);
|
||||
|
||||
_info_dialog = 0;
|
||||
_otherWidget = (Widget) NULL;
|
||||
_textField = (Widget) NULL;
|
||||
_maxTextlen = 0;
|
||||
_clearText = NULL;
|
||||
|
||||
_parentshell = parent;
|
||||
while (_parentshell && !XtIsShell(_parentshell))
|
||||
_parentshell = XtParent(_parentshell);
|
||||
}
|
||||
|
||||
|
||||
Widget
|
||||
DtMailGenDialog::post(void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback other,
|
||||
DialogCallback help,
|
||||
char *helpId)
|
||||
{
|
||||
// _w is the MessageBox widget created in the constructor...
|
||||
|
||||
Widget dialog = _w;
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert (dialog != NULL);
|
||||
|
||||
// Make sure the dialog buttons are managed
|
||||
Widget ok_button = XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON);
|
||||
Widget cancel_button = XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON);
|
||||
Widget help_button = XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON);
|
||||
|
||||
// Create an object to carry the additional data needed
|
||||
// to cache the dialogs.
|
||||
|
||||
DtMailDialogCallbackData *dcb = new DtMailDialogCallbackData(
|
||||
(DtMailGenDialog *) this,
|
||||
clientData,
|
||||
ok,
|
||||
cancel,
|
||||
other,
|
||||
help,
|
||||
_otherWidget);
|
||||
// Install callback function for each button
|
||||
// support by Motif dialogs. If there is no help callback
|
||||
// unmanage the corresponding button instead, if possible.
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
XtAddCallback(
|
||||
dialog,
|
||||
XmNokCallback, &DtMailGenDialog::okCallback,
|
||||
(XtPointer) dcb);
|
||||
if (!XtIsManaged(ok_button)) XtManageChild(ok_button);
|
||||
}
|
||||
else XtUnmanageChild(ok_button);
|
||||
|
||||
if (cancel)
|
||||
{
|
||||
XtAddCallback(
|
||||
dialog,
|
||||
XmNcancelCallback, &DtMailGenDialog::cancelCallback,
|
||||
(XtPointer) dcb);
|
||||
if (!XtIsManaged(cancel_button)) XtManageChild(cancel_button);
|
||||
}
|
||||
else XtUnmanageChild(cancel_button);
|
||||
|
||||
|
||||
if (other)
|
||||
{
|
||||
XtAddCallback(
|
||||
_otherWidget,
|
||||
XmNactivateCallback, &DtMailGenDialog::otherCallback,
|
||||
(XtPointer) dcb);
|
||||
}
|
||||
else if (_otherWidget) XtUnmanageChild(_otherWidget);
|
||||
|
||||
|
||||
if (help)
|
||||
{
|
||||
XtAddCallback(
|
||||
dialog,
|
||||
XmNhelpCallback, &HelpErrorCB,
|
||||
(XtPointer) helpId);
|
||||
if (!XtIsManaged (help_button)) XtManageChild(help_button);
|
||||
} else XtUnmanageChild(help_button);
|
||||
|
||||
//
|
||||
// Make sure the parent dialog is popped up and occupying the
|
||||
// current workspace.
|
||||
//
|
||||
if (NULL != _parentshell)
|
||||
{
|
||||
XtPopup(_parentshell, XtGrabNone);
|
||||
displayInCurrentWorkspace(_parentshell);
|
||||
}
|
||||
|
||||
// Post the dialog.
|
||||
XtManageChild(dialog);
|
||||
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XmProcessTraversal(_textField, XmTRAVERSE_CURRENT);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::okCallback(Widget w, XtPointer clientData, XtPointer cbs)
|
||||
{
|
||||
XmPushButtonCallbackStruct * pbcs = (XmPushButtonCallbackStruct *)cbs;
|
||||
|
||||
DtMailDialogCallbackData *dcd = (DtMailDialogCallbackData *) clientData;
|
||||
DtMailGenDialog *obj = (DtMailGenDialog *) dcd->dialog();
|
||||
DialogCallback callback;
|
||||
|
||||
// If caller specified an ok callback, call the function
|
||||
|
||||
if ((callback=dcd->ok()) != NULL) (*callback)(dcd->clientData());
|
||||
|
||||
// If the help widget was popped up, destroy it.
|
||||
Widget helpWidget = getErrorHelpWidget();
|
||||
if (helpWidget)
|
||||
{
|
||||
XtUnmanageChild (helpWidget);
|
||||
XtDestroyWidget (helpWidget);
|
||||
clearErrorHelpWidget();
|
||||
}
|
||||
|
||||
// Reset for the next time
|
||||
|
||||
Widget ow = dcd->other_w();
|
||||
if (ow != NULL)
|
||||
XtRemoveCallback(
|
||||
ow,
|
||||
XmNactivateCallback,
|
||||
&DtMailGenDialog::otherCallback,
|
||||
(XtPointer) dcd);
|
||||
|
||||
obj->cleanup(w, dcd);
|
||||
|
||||
if (obj->_info_dialog &&
|
||||
(pbcs->event->xbutton.state & (ShiftMask | ControlMask)))
|
||||
{
|
||||
#ifdef NEVER
|
||||
// Don't do credits for now
|
||||
doCredits = 1;
|
||||
#endif
|
||||
doCredits = 0;
|
||||
obj->setToAboutDialog();
|
||||
// char * helpId = "About";
|
||||
char * helpId = NULL;
|
||||
int answer = obj->post_and_return(GETMSG(DT_catd, 1, 180, "OK"),
|
||||
helpId);
|
||||
}
|
||||
}
|
||||
|
||||
void DtMailGenDialog::cancelCallback(Widget w, XtPointer clientData, XtPointer)
|
||||
{
|
||||
DtMailDialogCallbackData *dcd = (DtMailDialogCallbackData *) clientData;
|
||||
DtMailGenDialog *obj = (DtMailGenDialog *) dcd->dialog();
|
||||
DialogCallback callback;
|
||||
|
||||
if ((callback=dcd->cancel()) != NULL) (*callback)(dcd->clientData());
|
||||
|
||||
// If the help widget was popped up, destroy it.
|
||||
Widget helpWidget = getErrorHelpWidget();
|
||||
if (helpWidget)
|
||||
{
|
||||
XtUnmanageChild (helpWidget);
|
||||
XtDestroyWidget (helpWidget);
|
||||
clearErrorHelpWidget();
|
||||
}
|
||||
|
||||
|
||||
Widget ow = dcd->other_w();
|
||||
if (ow != NULL)
|
||||
XtRemoveCallback ( ow,
|
||||
XmNactivateCallback,
|
||||
&DtMailGenDialog::otherCallback,
|
||||
(XtPointer) dcd );
|
||||
|
||||
obj->cleanup(w, dcd);
|
||||
}
|
||||
|
||||
void DtMailGenDialog::otherCallback(Widget w, XtPointer clientData, XtPointer)
|
||||
{
|
||||
DtMailDialogCallbackData *dcd = (DtMailDialogCallbackData *) clientData;
|
||||
DtMailGenDialog *obj = (DtMailGenDialog *) dcd->dialog();
|
||||
DialogCallback callback;
|
||||
|
||||
if ((callback=dcd->other()) != NULL) (*callback)(dcd->clientData());
|
||||
|
||||
XtRemoveCallback(
|
||||
w,
|
||||
XmNactivateCallback,
|
||||
&DtMailGenDialog::otherCallback,
|
||||
(XtPointer) dcd);
|
||||
|
||||
Widget pw = XtParent(w);
|
||||
obj->cleanup(pw, dcd);
|
||||
}
|
||||
|
||||
void DtMailGenDialog::helpCallback(Widget, XtPointer clientData, XtPointer)
|
||||
{
|
||||
DtMailDialogCallbackData *dcd = (DtMailDialogCallbackData *) clientData;
|
||||
DtMailGenDialog *obj = (DtMailGenDialog *) dcd->dialog();
|
||||
DialogCallback callback;
|
||||
|
||||
if ((callback=dcd->help()) != NULL) (*callback)(dcd->clientData());
|
||||
}
|
||||
|
||||
void DtMailGenDialog::verifyCallback(Widget, XtPointer clientD, XtPointer callD)
|
||||
{
|
||||
DtMailGenDialog *obj = (DtMailGenDialog*) clientD;
|
||||
XmTextVerifyPtr cbs = (XmTextVerifyPtr) callD;
|
||||
|
||||
obj->verify(cbs);
|
||||
}
|
||||
|
||||
void DtMailGenDialog::verify(XmTextVerifyPtr cbs)
|
||||
{
|
||||
int i;
|
||||
static char buffer[MAXPATHLEN];
|
||||
register char *s, *t;
|
||||
|
||||
#if defined(SHROUDED_TEXTFIELD_DEBUG)
|
||||
printf(
|
||||
"currInsert=%d newInsert=%d startPos=%d endPos=%d\n",
|
||||
cbs->currInsert,cbs->newInsert,cbs->startPos, cbs->endPos);
|
||||
if (cbs->text->ptr) printf("text->ptr=%s\n", cbs->text->ptr);
|
||||
printf("_clearText=%s\n", _clearText);
|
||||
#endif
|
||||
|
||||
for (i=0, s=buffer, t=_clearText; (*t && i<cbs->startPos); i++, s++, t++)
|
||||
*s = *t;
|
||||
|
||||
if (cbs->text->ptr)
|
||||
{
|
||||
strcpy(s, cbs->text->ptr);
|
||||
s += cbs->text->length;
|
||||
}
|
||||
else
|
||||
*s = '\0';
|
||||
|
||||
if (strlen(_clearText) >= cbs->endPos)
|
||||
{
|
||||
t = _clearText+cbs->endPos;
|
||||
if (strlen(t))
|
||||
strcpy(s, t);
|
||||
}
|
||||
|
||||
if (strlen(buffer) >= _maxTextlen)
|
||||
{
|
||||
_maxTextlen *= 2;
|
||||
_clearText = (char*) realloc((void*) _clearText, (size_t) _maxTextlen);
|
||||
assert(NULL!=_clearText);
|
||||
}
|
||||
strcpy(_clearText, buffer);
|
||||
|
||||
if (_shroudText && cbs->text->ptr)
|
||||
for (i=0, s=cbs->text->ptr; i<cbs->text->length; i++, s++)
|
||||
*s = '*';
|
||||
|
||||
#if defined(SHROUDED_TEXTFIELD_DEBUG)
|
||||
printf("text=%s\n", _clearText);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void DtMailGenDialog::cleanup(Widget w, DtMailDialogCallbackData *dcd)
|
||||
{
|
||||
// Remove all callbacks to avoid having duplicate
|
||||
// callback functions installed.
|
||||
|
||||
XtRemoveCallback(
|
||||
w,
|
||||
XmNokCallback, &DtMailGenDialog::okCallback,
|
||||
(XtPointer) dcd );
|
||||
|
||||
XtRemoveCallback(
|
||||
w,
|
||||
XmNcancelCallback, &DtMailGenDialog::cancelCallback,
|
||||
(XtPointer) dcd);
|
||||
|
||||
if (XtHasCallbacks(w, XmNhelpCallback) == XtCallbackHasSome)
|
||||
XtRemoveAllCallbacks(w, XmNhelpCallback);
|
||||
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
// Delete the DtMailDialogCallbackData instance for this posting
|
||||
delete dcd;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::forceUpdate( Widget w )
|
||||
{
|
||||
Widget diashell, topshell;
|
||||
Window diawindow, topwindow;
|
||||
|
||||
Display *dpy;
|
||||
XWindowAttributes xwa;
|
||||
|
||||
if (!w) return;
|
||||
|
||||
XtAppContext cxt=XtWidgetToApplicationContext( w );
|
||||
for (diashell=w;!XtIsShell(diashell);diashell=XtParent(diashell));
|
||||
for (topshell=diashell;
|
||||
XtIsTopLevelShell(topshell);
|
||||
topshell=XtParent(topshell));
|
||||
|
||||
dpy=XtDisplay(diashell);
|
||||
diawindow=XtWindow(diashell);
|
||||
topwindow=XtWindow(topshell);
|
||||
while (XGetWindowAttributes(dpy,diawindow,&xwa) &&
|
||||
xwa.map_state != IsViewable && XEventsQueued(dpy,QueuedAlready))
|
||||
{
|
||||
XtAppProcessEvent(cxt, XtIMAll );
|
||||
}
|
||||
XmUpdateDisplay(topshell);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Added this extra functionality
|
||||
|
||||
void
|
||||
genDialogOKCallback( int *data )
|
||||
{
|
||||
*data=1;
|
||||
}
|
||||
|
||||
void
|
||||
genDialogCancelCallback( int *data )
|
||||
{
|
||||
*data=2;
|
||||
}
|
||||
|
||||
void
|
||||
genDialogOtherCallback( int *data )
|
||||
{
|
||||
*data=3;
|
||||
}
|
||||
// post_and_return takes a helpId, which is a string that is used to
|
||||
// reference the related help in the Mailer help volume. The helpId
|
||||
// is passed to post(), which will attach help to the help button in
|
||||
// the dialog.
|
||||
int
|
||||
DtMailGenDialog::post_and_return(char *helpId)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel, cancelLabel;
|
||||
|
||||
// They may have been set via the overloaded post_and_return()
|
||||
// method before. Reset them to their default values...
|
||||
|
||||
okLabel = XmStringCreateLocalized(GETMSG(DT_catd, 1, 181, "OK"));
|
||||
cancelLabel = XmStringCreateLocalized(GETMSG(DT_catd, 1, 182, "Cancel"));
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( _w != NULL );
|
||||
|
||||
XtVaSetValues(_w,
|
||||
XmNokLabelString, okLabel,
|
||||
XmNcancelLabelString, cancelLabel,
|
||||
NULL);
|
||||
XmStringFree( okLabel);
|
||||
XmStringFree( cancelLabel);
|
||||
|
||||
Widget dialog;
|
||||
if (helpId) {
|
||||
dialog =
|
||||
this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) &HelpErrorCB,
|
||||
helpId
|
||||
);
|
||||
} else {
|
||||
dialog =
|
||||
this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
{
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
}
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
|
||||
// post_and_return(char *, char *) takes the string to be used for the
|
||||
// OK button and the string that contains the helpId for the dialog being
|
||||
// created, and passes them to post().
|
||||
int
|
||||
DtMailGenDialog::post_and_return(
|
||||
char *okLabelString,
|
||||
char *helpId
|
||||
)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel;
|
||||
|
||||
okLabel = XmStringCreateLocalized(okLabelString);
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( _w != NULL );
|
||||
|
||||
XtVaSetValues(_w,
|
||||
XmNokLabelString, okLabel,
|
||||
NULL);
|
||||
XmStringFree( okLabel);
|
||||
|
||||
Widget dialog;
|
||||
if (helpId) {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) &HelpErrorCB,
|
||||
helpId
|
||||
);
|
||||
} else {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
{
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
}
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
|
||||
// post_and_return(char*, char*, char*) takes the OK button label, Cancel
|
||||
// button label, and the help id for the dialog and passes them to post().
|
||||
int
|
||||
DtMailGenDialog::post_and_return(
|
||||
char *okLabelString,
|
||||
char *cancelLabelString,
|
||||
char *helpId
|
||||
)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel, cancelLabel;
|
||||
|
||||
okLabel = XmStringCreateLocalized(okLabelString);
|
||||
cancelLabel = XmStringCreateLocalized(cancelLabelString);
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( _w != NULL );
|
||||
|
||||
XtVaSetValues(_w,
|
||||
XmNokLabelString, okLabel,
|
||||
XmNcancelLabelString, cancelLabel,
|
||||
NULL);
|
||||
XmStringFree( okLabel);
|
||||
XmStringFree( cancelLabel);
|
||||
|
||||
Widget dialog = NULL;
|
||||
if (helpId) {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) &HelpErrorCB,
|
||||
helpId
|
||||
);
|
||||
} else {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
{
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll);
|
||||
}
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll);
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
DtMailGenDialog::post_and_return(
|
||||
char *okLabelString,
|
||||
char *cancelLabelString,
|
||||
char *otherLabelString,
|
||||
char *helpId
|
||||
)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel, cancelLabel, otherLabel;
|
||||
|
||||
okLabel = XmStringCreateLocalized(okLabelString);
|
||||
cancelLabel = XmStringCreateLocalized(cancelLabelString);
|
||||
otherLabel = XmStringCreateLocalized(otherLabelString);
|
||||
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( _w != NULL );
|
||||
|
||||
Widget dialog = NULL;
|
||||
Widget cancel_w = XmMessageBoxGetChild ( _w, XmDIALOG_CANCEL_BUTTON );
|
||||
|
||||
if (_otherWidget == NULL) {
|
||||
_otherWidget = XtVaCreateWidget(otherLabelString,
|
||||
xmPushButtonGadgetClass, _w,
|
||||
XmNleftAttachment, XmMessageBoxGetChild ( _w,
|
||||
XmDIALOG_OK_BUTTON ),
|
||||
XmNrightAttachment, cancel_w,
|
||||
NULL);
|
||||
XtManageChild (_otherWidget);
|
||||
}
|
||||
|
||||
if (!XtIsManaged(_otherWidget)) {
|
||||
XtManageChild (_otherWidget);
|
||||
}
|
||||
if (!XtIsManaged ( cancel_w ) ) {
|
||||
XtManageChild ( cancel_w );
|
||||
}
|
||||
|
||||
XtVaSetValues(_w,
|
||||
XmNokLabelString, okLabel,
|
||||
XmNcancelLabelString, cancelLabel,
|
||||
NULL);
|
||||
XtVaSetValues(_otherWidget,
|
||||
XmNlabelString, otherLabel,
|
||||
NULL);
|
||||
XmStringFree( okLabel);
|
||||
XmStringFree( cancelLabel);
|
||||
XmStringFree( otherLabel);
|
||||
|
||||
if (helpId) {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) &genDialogOtherCallback,
|
||||
( DialogCallback ) &HelpErrorCB,
|
||||
helpId
|
||||
);
|
||||
} else {
|
||||
dialog =
|
||||
this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) &genDialogOtherCallback,
|
||||
( DialogCallback ) NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
{
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
}
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
void
|
||||
DtMailGenDialog::setDialog(char * title, char * text, unsigned char type)
|
||||
{
|
||||
XmString titleStr = XmStringCreateLocalized (title);
|
||||
XmString xmStr = XmStringCreateLocalized(text);
|
||||
XtVaSetValues ( _w,
|
||||
XmNmessageString, xmStr,
|
||||
XmNdialogTitle, titleStr,
|
||||
XmNdialogType, type,
|
||||
NULL );
|
||||
XmStringFree(xmStr);
|
||||
XmStringFree ( titleStr );
|
||||
_info_dialog = 0;
|
||||
}
|
||||
|
||||
char *
|
||||
DtMailGenDialog::getTextFieldValue()
|
||||
{
|
||||
if (_clearText) return strdup(_clearText);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToTextFieldDialog(
|
||||
char *title,
|
||||
char *text,
|
||||
int shroud
|
||||
)
|
||||
{
|
||||
if (NULL != _textField)
|
||||
{
|
||||
if (NULL != _clearText) *_clearText = '\0';
|
||||
XtVaSetValues(_textField, XmNvalue, "", NULL);
|
||||
XtManageChild(_textField);
|
||||
}
|
||||
else
|
||||
{
|
||||
_textField = XtVaCreateManagedWidget(
|
||||
"GenDialogTF", xmTextFieldWidgetClass, _w,
|
||||
XmNcolumns, 30,
|
||||
NULL);
|
||||
XtAddCallback(
|
||||
_textField,
|
||||
XmNmodifyVerifyCallback,DtMailGenDialog::verifyCallback,
|
||||
this);
|
||||
_maxTextlen = 256;
|
||||
_clearText = (char*) malloc(_maxTextlen);
|
||||
memset(_clearText, 0, _maxTextlen);
|
||||
assert(NULL!=_clearText);
|
||||
}
|
||||
_shroudText = shroud;
|
||||
setDialog(title, text, XmDIALOG_QUESTION);
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToQuestionDialog(
|
||||
char *title,
|
||||
char *text
|
||||
)
|
||||
{
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
setDialog(title, text, XmDIALOG_QUESTION);
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToWarningDialog(
|
||||
char *title,
|
||||
char *text
|
||||
)
|
||||
{
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
setDialog(title, text, XmDIALOG_WARNING);
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToErrorDialog(
|
||||
char *title,
|
||||
char *text
|
||||
)
|
||||
{
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
setDialog(title, text, XmDIALOG_ERROR);
|
||||
}
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
void
|
||||
DtMailGenDialog::setToInfoDialog(
|
||||
char *title,
|
||||
char *text
|
||||
)
|
||||
{
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
setDialog(title, text, XmDIALOG_INFORMATION);
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
extern "C" Pixmap _DtGetMask(Screen * screen, char * image_name);
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToAboutDialog(void)
|
||||
{
|
||||
if (doCredits) {
|
||||
setDialog((char *)"Credits",
|
||||
(char *)credits,
|
||||
XmDIALOG_INFORMATION);
|
||||
doCredits = 0;
|
||||
}
|
||||
else {
|
||||
if (NULL == ABOUT_TITLE) {
|
||||
char *version;
|
||||
|
||||
ABOUT_TITLE = GETMSG(DT_catd, 1, 235, "Mailer - About Mailer");
|
||||
version = GETMSG(DT_catd, 1, 236, "Mailer Version %d.%d.%d");
|
||||
|
||||
DTMAIL_VERSION = new char [strlen(version) + 16];
|
||||
sprintf(
|
||||
DTMAIL_VERSION, version,
|
||||
DtVERSION, DtREVISION, DtUPDATE_LEVEL);
|
||||
}
|
||||
setDialog((char *)ABOUT_TITLE,
|
||||
(char *)DTMAIL_VERSION,
|
||||
XmDIALOG_INFORMATION);
|
||||
}
|
||||
|
||||
_info_dialog = 1;
|
||||
|
||||
char * icon_filename = XmGetIconFileName(XtScreen(_w),
|
||||
NULL,
|
||||
"DtMail",
|
||||
NULL,
|
||||
DtLARGE);
|
||||
|
||||
if (icon_filename == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pixmap fg, bg;
|
||||
|
||||
XtVaGetValues (_w,
|
||||
XmNforeground, &fg,
|
||||
XmNbackground, &bg,
|
||||
NULL);
|
||||
|
||||
Pixmap icon = XmGetPixmap(XtScreen(_w),
|
||||
icon_filename,
|
||||
fg, bg);
|
||||
|
||||
Pixmap icon_mask = _DtGetMask(XtScreen(_w), icon_filename);
|
||||
|
||||
Pixmap clipped_icon = icon;
|
||||
if (icon_mask) {
|
||||
Window root;
|
||||
int x, y;
|
||||
unsigned int width, height, border_width, depth;
|
||||
XGetGeometry(XtDisplay(_w),
|
||||
icon,
|
||||
&root,
|
||||
&x, &y,
|
||||
&width, &height,
|
||||
&border_width, &depth);
|
||||
|
||||
XtRealizeWidget(_w);
|
||||
|
||||
clipped_icon = XCreatePixmap(XtDisplay(_w),
|
||||
XtWindow(_w),
|
||||
width,
|
||||
height,
|
||||
depth);
|
||||
|
||||
XGCValues gc_vals;
|
||||
GC gc;
|
||||
memset(&gc_vals, 0, sizeof(gc_vals));
|
||||
gc_vals.background = bg;
|
||||
gc_vals.foreground = bg;
|
||||
gc_vals.fill_style = FillSolid;
|
||||
gc = XCreateGC(XtDisplay(_w),
|
||||
XtWindow(_w),
|
||||
GCForeground | GCBackground | GCFillStyle,
|
||||
&gc_vals);
|
||||
|
||||
XFillRectangle(XtDisplay(_w),
|
||||
clipped_icon,
|
||||
gc,
|
||||
0, 0,
|
||||
width, height);
|
||||
|
||||
XFreeGC(XtDisplay(_w), gc);
|
||||
|
||||
memset(&gc_vals, 0, sizeof(gc_vals));
|
||||
gc_vals.background = bg;
|
||||
gc = XCreateGC(XtDisplay(_w),
|
||||
XtWindow(_w),
|
||||
GCBackground,
|
||||
&gc_vals);
|
||||
|
||||
XSetClipMask(XtDisplay(_w), gc, icon_mask);
|
||||
|
||||
XCopyArea(XtDisplay(_w),
|
||||
icon,
|
||||
clipped_icon,
|
||||
gc,
|
||||
0, 0,
|
||||
width, height,
|
||||
0, 0);
|
||||
XFreeGC(XtDisplay(_w), gc);
|
||||
}
|
||||
|
||||
XtVaSetValues ( _w,
|
||||
XmNsymbolPixmap, clipped_icon,
|
||||
NULL );
|
||||
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
}
|
||||
88
cde/programs/dtmail/dtmail/DtMailGenDialog.hh
Normal file
88
cde/programs/dtmail/dtmail/DtMailGenDialog.hh
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtMailGenDialog.hh /main/7 1998/02/04 18:38:09 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// DtMailGenDialog.hh: A generic dialog based on MessageBox
|
||||
//////////////////////////////////////////////////////////
|
||||
#ifndef DTMAILGENDIALOG_HH
|
||||
#define DTMAILGENDIALOG_HH
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <Xm/TextF.h>
|
||||
#include "UIComponent.h"
|
||||
#include "DtMailDialogCallbackData.hh"
|
||||
|
||||
class DtMailGenDialog : public UIComponent {
|
||||
|
||||
private:
|
||||
int _info_dialog;
|
||||
Widget _otherWidget;
|
||||
Widget _parentshell;
|
||||
|
||||
Widget _textField;
|
||||
int _shroudText;
|
||||
int _maxTextlen;
|
||||
char *_clearText;
|
||||
|
||||
void cleanup ( Widget, DtMailDialogCallbackData* );
|
||||
|
||||
protected:
|
||||
|
||||
void forceUpdate( Widget );
|
||||
|
||||
static void okCallback(Widget, XtPointer, XtPointer);
|
||||
static void cancelCallback(Widget, XtPointer, XtPointer);
|
||||
static void helpCallback(Widget, XtPointer, XtPointer);
|
||||
static void otherCallback(Widget, XtPointer, XtPointer);
|
||||
|
||||
static void verifyCallback(Widget, XtPointer, XtPointer);
|
||||
void verify(XmTextVerifyPtr cbs);
|
||||
|
||||
void setDialog(char * title, char * text, unsigned char type);
|
||||
|
||||
public:
|
||||
|
||||
DtMailGenDialog(char*,Widget, int style=XmDIALOG_PRIMARY_APPLICATION_MODAL);
|
||||
~DtMailGenDialog() { if (NULL != _clearText) free(_clearText); };
|
||||
|
||||
char *getTextFieldValue(void);
|
||||
|
||||
void setToTextFieldDialog(char *, char *, int shroud = FALSE);
|
||||
void setToQuestionDialog(char *, char *);
|
||||
#ifdef DEAD_WOOD
|
||||
void setToInfoDialog(char *, char *);
|
||||
#endif /* DEAD_WOOD */
|
||||
void setToErrorDialog(char *, char *);
|
||||
void setToWarningDialog(char *, char *);
|
||||
void setToAboutDialog(void);
|
||||
|
||||
virtual Widget post (
|
||||
void *clientData = NULL,
|
||||
DialogCallback ok = NULL,
|
||||
DialogCallback cancel = NULL,
|
||||
DialogCallback other = NULL,
|
||||
DialogCallback help = NULL,
|
||||
char *helpId = NULL);
|
||||
virtual int post_and_return(char *);
|
||||
virtual int post_and_return(char *, char *);
|
||||
virtual int post_and_return(char *, char *, char *);
|
||||
virtual int post_and_return(char *, char *, char *, char *);
|
||||
};
|
||||
#endif
|
||||
138
cde/programs/dtmail/dtmail/DtMailHelp.hh
Normal file
138
cde/programs/dtmail/dtmail/DtMailHelp.hh
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: DtMailHelp.hh /main/5 1996/04/21 19:41:42 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DTMAILHELP_HH
|
||||
#define DTMAILHELP_HH
|
||||
|
||||
// Help Ids for dtmail.
|
||||
|
||||
#define DTMAILWINDOWID "_HOMETOPIC"
|
||||
|
||||
// RoamMenuWindow
|
||||
#define DTMAILWINDOWMAILBOXMENU "DTMAILVIEWMAINWINDOWMENUBARFILE"
|
||||
#define DTMAILWINDOWMESSAGEMENU "DTMAILVIEWMAINWINDOWMENUBARMESSAGE"
|
||||
#define DTMAILWINDOWEDITMENU "DTMAILVIEWMAINWINDOWMENUBAREDIT"
|
||||
#define DTMAILWINDOWATTACHMENTSMENU "DTMAILVIEWMAINWINDOWMENUBARATTACH"
|
||||
#define DTMAILWINDOWVIEWMENU "DTMAILVIEWMAINWINDOWMENUBARVIEW"
|
||||
#define DTMAILWINDOWCOMPOSEMENU "DTMAILVIEWMAINWINDOWMENUBARCOMPOSE"
|
||||
#define DTMAILWINDOWMOVEMENU "DTMAILVIEWMAINWINDOWMENUBARMOVE"
|
||||
#define DTMAILWINDOWROWOFLABELSID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWOFLABELS"
|
||||
#define DTMAILMSGLISTID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2MESSAGELISTSWMESSAGELIST"
|
||||
#define DTMAILNEXTBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNNEXT"
|
||||
#define DTMAILPREVBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNPREVIOUS"
|
||||
#define DTMAILDELBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNDELETE"
|
||||
#define DTMAILPRINTBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNPRINT"
|
||||
#define DTMAILREPLYBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNREPLY"
|
||||
#define APP_MENU_ID "onApplicationMenu"
|
||||
#define VER_MENU_ID "_copyright"
|
||||
|
||||
// SendMsgDialog
|
||||
#define DTMAILCOMPOSEWINDOW "DTMAILCOMPOSEWINDOW"
|
||||
#define DTMAILCOMPOSEFILEMENU "DTMAILCOMPOSEWINDOWMENUBARFILE"
|
||||
#define DTMAILCOMPOSEEDITMENU "DTMAILCOMPOSEWINDOWMENUBAREDIT"
|
||||
#define DTMAILCOMPOSEATTACHMENU "DTMAILCOMPOSEWINDOWMENUBARATTACH"
|
||||
#define DTMAILCOMPOSEFORMATMENU "DTMAILCOMPOSEWINDOWMENUBARFORMAT"
|
||||
|
||||
// Find Message Dialog
|
||||
#define DTMAILFINDDIALOG "DTMAILVIEWMAINWINDOWMESSAGEFIND"
|
||||
|
||||
// Other Mailboxes Dialog
|
||||
#define DTMAILOTHERMAILBOXESDIALOG "DTMAILVIEWMAINWINDOWMOVEMAILBOX"
|
||||
|
||||
// Undelete Messages From List Dialog
|
||||
#define DTMAILUNDELETEFROMLISTDIALOG "DTMAILVIEWMAINWINDOWMESSAGEUNDELETELIST"
|
||||
|
||||
// Rename Attachment Dialog
|
||||
#define DTMAILRENAMEATTACHMENTDIALOG "DTMAILVIEWMAINWINDOWATTACHRENAME"
|
||||
|
||||
// Mailer Format Settings Dialog
|
||||
#define DTMAILCOMPOSEFORMATDIALOG "DTMAILCOMPOSEWINDOWFORMATSETTINGS"
|
||||
|
||||
// Mailer PrintSetupDialog
|
||||
#define DTMAILPRINTSETUPDIALOG "DTMAILPRINTSETUPDIALOG"
|
||||
|
||||
// Mailer Options Dialogs
|
||||
#define DTMAILOPTIONSHEADERLISTDIALOG "DTMAILMAILBOXOPTIONSMESSAGEHEADERLIST"
|
||||
#define DTMAILOPTIONSVIEWDIALOG "DTMAILMAILBOXOPTIONSMESSAGEVIEW"
|
||||
#define DTMAILOPTIONSCOMPOSEDIALOG "DTMAILMAILBOXOPTIONSCOMPOSEWINDOW"
|
||||
#define DTMAILOPTIONSMESSAGEFILINGDIALOG "DTMAILMAILBOXOPTIONSMESSAGEFILING"
|
||||
#define DTMAILOPTIONSVACATIONDIALOG "DTMAILMAILBOXOPTIONSVACATION"
|
||||
#define DTMAILOPTIONSTEMPLATESDIALOG "DTMAILMAILBOXOPTIONSTEMPLATES"
|
||||
#define DTMAILOPTIONSALIASDIALOG "DTMAILMAILBOXOPTIONSALIASES"
|
||||
#define DTMAILOPTIONSADVANCEDDIALOG "DTMAILMAILBOXOPTIONSADVANCED"
|
||||
|
||||
// These helpIds are for the help button in dialogs.
|
||||
#define DTMAILHELPCANTINITTOOLTALK "DTMAILHELPCANTINITTOOLTALK"
|
||||
#define DTMAILHELPCREATEINBOX "DTMAILHELPCREATEINBOX"
|
||||
#define DTMAILHELPCONVERTINBOX "DTMAILHELPCONVERTINBOX"
|
||||
#define DTMAILHELPCREATECONTAINER "DTMAILCREATECONTAINERHELP"
|
||||
#define DTMAILHELPTAKELOCK "DTMAILHELPTAKELOCK"
|
||||
#define DTMAILHELPBADGROUPID "DTMAILHELPNOINSTALLMAIL"
|
||||
#define DTMAILHELPUNKNOWNSTATE "DTMAILHELPUNKNOWNSTATE"
|
||||
#define DTMAILHELPFATALERROR "DTMAILHELPFATALERROR"
|
||||
#define DTMAILHELPERROR "DTMAILHELPERROR"
|
||||
#define DTMAILHELPCLOSECOMPOSEWINDOW "DTMAILHELPCLOSECOMPOSEWINDOW"
|
||||
#define DTMAILHELPPENDINGACTIONS "DTMAILHELPSENDLOSEATTACH"
|
||||
#define DTMAILHELPSELECTONEATTACH "DTMAILHELPSELECTONEATTACH"
|
||||
#define DTMAILHELPBADADDRESS "DTMAILHELPUNKNOWNUSER"
|
||||
#define DTMAILHELPNOMEMORY "DTMAILHELPNOMEMORY"
|
||||
#define DTMAILHELPTRANSPORTFAILED "DTMAILHELPNOSEND"
|
||||
#define DTMAILHELPOKSTARTVACATION "DTMAILHELPOKSTARTVACATION"
|
||||
#define DTMAILHELPREMOVEVACATION "DTMAILHELPREMOVEVACATION"
|
||||
#define DTMAILHELPNOWRITEVACATION "DTMAILHELPNOWRITEVACATION"
|
||||
#define DTMAILHELPEXISTSVACATION "DTMAILHELPEXISTSVACATION"
|
||||
#define DTMAILHELPNOCOMPOSE "DTMAILHELPNOCOMPOSE"
|
||||
#define DTMAILHELPNOTEMPLATE "DTMAILHELPNOTEMPLATE"
|
||||
#define DTMAILHELPCORRUPTTEMPLATE "DTMAILHELPCORRUPTTEMPLATE"
|
||||
#define DTMAILHELPNOMEMTEMPLATE "DTMAILHELPNOMEMTEMPLATE"
|
||||
#define DTMAILHELPNOVIEW "DTMAILHELPNOVIEW"
|
||||
#define DTMAILHELPDIRECTORYONLY "DTMAILHELPDIRECTORYONLY"
|
||||
#define DTMAILHELPSELECTATTACH "DTMAILHELPSELECTATTACH"
|
||||
#define DTMAILHELPDESTROYMARKMSG "DTMAILHELPDESTROYMARKMSG"
|
||||
#define DTMAILHELPNOOPEN "DTMAILHELPNOOPEN"
|
||||
#define DTMAILHELPNOALLOCMEM "DTMAILHELPNOALLOCMEM"
|
||||
#define DTMAILHELPALREADYEXISTS "DTMAILHELPALREADYEXISTS"
|
||||
#define DTMAILHELPNOREPLACE "DTMAILHELPNOREPLACE"
|
||||
#define DTMAILHELPNOCREATE "DTMAILHELPNOCREATE"
|
||||
#define DTMAILHELPNOOVERWRITE "DTMAILHELPNOOVERWRITE"
|
||||
#define DTMAILHELPNOWRITE "DTMAILHELPNOWRITE"
|
||||
#define DTMAILHELPNOLOADVACATION "DTMAILHELPNOLOADVACATION"
|
||||
#define DTMAILHELPCORRUPTVACATION "DTMAILHELPCORRUPTVACATION"
|
||||
#define DTMAILHELPNEEDADDRESSEE "DTMAILHELPNEEDADDRESSEE"
|
||||
#define DTMAILHELPEXECUTEOK "DTMAILHELPEXECUTEOK"
|
||||
#define DTMAILHELPOPENREADONLY "DTMAILHELPOPENREADONLY"
|
||||
#define DTMAILHELPOPENREADWRITEOVERRIDE "DTMAILHELPOPENREADWRITEOVERRIDE"
|
||||
|
||||
// Option defines for menubar help access
|
||||
#define HELP_MAILER_TASKS "Tasks"
|
||||
#define HELP_MAILER_REFERENCE "Reference"
|
||||
|
||||
char *getHelpId(Widget);
|
||||
void printHelpId(char *, Widget);
|
||||
#ifdef DEAD_WOOD
|
||||
void HelpMenuCB(Widget, XtPointer, XtPointer);
|
||||
#endif /* DEAD_WOOD */
|
||||
void HelpCB(Widget, XtPointer, XtPointer);
|
||||
extern void DisplayMain(Widget, char *, char *);
|
||||
extern void DisplayVersion(Widget, char *, char *);
|
||||
static void CloseMainCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
#endif
|
||||
|
||||
122
cde/programs/dtmail/dtmail/DtMailWDM.C
Normal file
122
cde/programs/dtmail/dtmail/DtMailWDM.C
Normal file
@@ -0,0 +1,122 @@
|
||||
/* $XConsortium: DtMailWDM.C /main/3 1996/04/21 19:41:45 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// DtMailWDM.C
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "DtMailWDM.hh"
|
||||
#include "Application.h"
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include "BusyPixmap.h"
|
||||
#include <assert.h>
|
||||
|
||||
DtMailWDM *theDtMailWDM =
|
||||
new DtMailWDM ( "DtMailWDM" );
|
||||
|
||||
DtMailWDM::DtMailWDM ( char *name )
|
||||
: WorkingDialogManager ( name )
|
||||
{
|
||||
_text = NULL;
|
||||
}
|
||||
|
||||
|
||||
Widget
|
||||
DtMailWDM::post (char *title,
|
||||
char *text,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help )
|
||||
{
|
||||
// The the dialog already exists, and is currently in use,
|
||||
// just return this dialog. The DtMailWDM
|
||||
// only supports one dialog.
|
||||
|
||||
if ( _w && XtIsManaged ( _w ) )
|
||||
return _w;
|
||||
|
||||
// Pass the message on to the base class
|
||||
|
||||
DialogManager::post (title, text, clientData, ok, cancel, help );
|
||||
|
||||
forceUpdate( _w );
|
||||
return _w;
|
||||
}
|
||||
|
||||
Widget
|
||||
DtMailWDM::post (char *title,
|
||||
char *text,
|
||||
Widget wid,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help )
|
||||
{
|
||||
// The the dialog already exists, and is currently in use,
|
||||
// just return this dialog. The DtMailWDM
|
||||
// only supports one dialog.
|
||||
|
||||
if ( _w && XtIsManaged ( _w ) )
|
||||
return _w;
|
||||
|
||||
// Pass the message on to the base class
|
||||
|
||||
DialogManager::post (title, text, wid, clientData, ok, cancel, help );
|
||||
|
||||
forceUpdate( _w );
|
||||
return _w;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DtMailWDM::updateAnimation()
|
||||
{
|
||||
if (_w) {
|
||||
XtVaSetValues ( _w,
|
||||
// XmNsymbolPixmap, _busyPixmaps->next(),
|
||||
NULL );
|
||||
forceUpdate( _w );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DtMailWDM::updateDialog(
|
||||
char *text
|
||||
)
|
||||
{
|
||||
|
||||
if ( _w )
|
||||
{
|
||||
|
||||
// Just change the string displayed in the dialog
|
||||
|
||||
XmString xmstr = XmStringCreateLocalized ( text );
|
||||
|
||||
// Update the pixmap too...
|
||||
XtVaSetValues ( _w,
|
||||
// XmNsymbolPixmap, _busyPixmaps->next(),
|
||||
XmNmessageString, xmstr,
|
||||
NULL );
|
||||
XmStringFree ( xmstr );
|
||||
|
||||
}
|
||||
|
||||
forceUpdate( _w );
|
||||
}
|
||||
60
cde/programs/dtmail/dtmail/DtMailWDM.hh
Normal file
60
cde/programs/dtmail/dtmail/DtMailWDM.hh
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: DtMailWDM.hh /main/4 1996/04/21 19:41:48 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// DtMailWDM.hh
|
||||
//////////////////////////////////////////////////////////
|
||||
#ifndef DTMAILWDM_HH
|
||||
#define DTMAILWDM_HH
|
||||
|
||||
#include "WorkingDialogManager.h"
|
||||
|
||||
class DtMailWDM : public WorkingDialogManager {
|
||||
|
||||
protected:
|
||||
|
||||
char *_text;
|
||||
|
||||
public:
|
||||
|
||||
DtMailWDM ( char * );
|
||||
|
||||
virtual Widget post (char *,
|
||||
char *,
|
||||
Widget ,
|
||||
void *clientData = NULL,
|
||||
DialogCallback ok = NULL,
|
||||
DialogCallback cancel = NULL,
|
||||
DialogCallback help = NULL );
|
||||
|
||||
virtual Widget post (char *,
|
||||
char *,
|
||||
void *clientData = NULL,
|
||||
DialogCallback ok = NULL,
|
||||
DialogCallback cancel = NULL,
|
||||
DialogCallback help = NULL );
|
||||
|
||||
void updateAnimation();
|
||||
void updateDialog(char *msg);
|
||||
};
|
||||
|
||||
extern DtMailWDM *theDtMailWDM;
|
||||
|
||||
#endif
|
||||
314
cde/programs/dtmail/dtmail/Dtmail
Normal file
314
cde/programs/dtmail/dtmail/Dtmail
Normal file
@@ -0,0 +1,314 @@
|
||||
!######################################################################
|
||||
!#
|
||||
!# Dtmail
|
||||
!#
|
||||
!# Common Desktop Environment (CDE)
|
||||
!#
|
||||
!# Application Defaults for the CDE Mailer
|
||||
!#
|
||||
!# (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
!# (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
!# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
!# (c) Copyright 1993, 1994 Novell, Inc.
|
||||
!#
|
||||
!#
|
||||
!######################################################################
|
||||
#include "Dt"
|
||||
|
||||
Dtmail*Font: %|nls-107-#Font#|
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# Formatting for the printing output.
|
||||
!#
|
||||
!######################################################################
|
||||
!#
|
||||
!# Formatting when printing to printer.
|
||||
!#
|
||||
|
||||
!# Sizes the PrintShell.
|
||||
Dtmail*Print.width: 8.5in
|
||||
Dtmail*Print.height: 11.0in
|
||||
Dtmail*Print.Page*foreground: black
|
||||
Dtmail*Print.Page*background: white
|
||||
|
||||
!# Places a border around the text portion of the output.
|
||||
Dtmail*Print.Page*shadowThickness: 2
|
||||
Dtmail*Print.Page*topShadowColor: black
|
||||
Dtmail*Print.Page*bottomShadowColor: black
|
||||
|
||||
!# Controls margins and background of the header and footer labels.
|
||||
Dtmail*Print.Page*XmLabel.marginBottom: 0.0in
|
||||
Dtmail*Print.Page*XmLabel.marginTop: 0.0in
|
||||
!Dtmail*Print.Page*XmLabel.background: grey
|
||||
|
||||
!# Fonts for headers, footers, and text.
|
||||
Dtmail*Print.Page*XmLabel.renderTable: %|nls-105-#HeaderLeft#|
|
||||
Dtmail*Print.Page*Editor.renderTable: %|nls-106-#Editor#|
|
||||
|
||||
!#
|
||||
!# Formatting when "printing" to video.
|
||||
!# Debugging only
|
||||
!#
|
||||
Dtmail*PrintVideo.width: 8.5in
|
||||
Dtmail*PrintVideo.height: 9.5in
|
||||
Dtmail*PrintVideo.Page.width: 8.5in
|
||||
Dtmail*PrintVideo.Page.height: 9.5in
|
||||
Dtmail*PrintVideo.Page*foreground: black
|
||||
Dtmail*PrintVideo.Page*background: white
|
||||
|
||||
Dtmail*PrintVideo.Page*shadowThickness: 2
|
||||
Dtmail*PrintVideo.Page*topShadowColor: black
|
||||
Dtmail*PrintVideo.Page*bottomShadowColor: black
|
||||
|
||||
Dtmail*PrintVideo.Page*XmLabel.marginTop: 0.0
|
||||
Dtmail*PrintVideo.Page*XmLabel.marginBottom: 0.0
|
||||
!Dtmail*PrintVideo.Page*XmLabel.background: grey
|
||||
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# Formatting for the Print Setup dialog.
|
||||
!#
|
||||
!######################################################################
|
||||
Dtmail*PrintingOptionsPane*leftOffset: 50
|
||||
Dtmail*PrintingOptionsPane*verticalSpacing: 5
|
||||
|
||||
Dtmail*Message_List*doubleClickInterval: 400
|
||||
|
||||
!######
|
||||
!# Examples of overriding default values
|
||||
!#
|
||||
!# Dtmail*UserFont: -b&h-lucidatypewriter-medium-r-*-sans-*-120-*-*-*-*-*
|
||||
!# Dtmail*SystemFont: -b&h-lucida-medium-r-*-sans-*-120-*-*-*-*-*-*
|
||||
!# Dtmail*GlyphFont: -adobe-symbol-*-*-*-*-*-100-*-*-*-*-adobe-fontspecific
|
||||
!#
|
||||
!# Dtmail*Work_Area*Text*foreground: black
|
||||
!# Dtmail*Work_Area*Text*background: white
|
||||
!# Dtmail*Message_List*foreground: black
|
||||
!# Dtmail*Message_List*background: white
|
||||
|
||||
|
||||
!#
|
||||
!# The width of header fields in the compose window.
|
||||
!#
|
||||
!# The following is changed by IBM.
|
||||
!# Dtmail*ComposeDialog*HeaderArea*form_*columns: 70
|
||||
Dtmail*ComposeDialog*HeaderArea*form_*columns: %|nls-200-#IBM#|
|
||||
|
||||
|
||||
!# The text fields column width in Find dialog
|
||||
Dtmail*find*To.columns: 1
|
||||
Dtmail*find*From.columns: 1
|
||||
Dtmail*find*Subject.columns: 1
|
||||
Dtmail*find*Cc.columns: 1
|
||||
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# The Compose Dialog accelerators and Text for those accelerators
|
||||
!#
|
||||
Dtmail*Send.acceleratorText: %|nls-1-#F3#|
|
||||
Dtmail*menubar*Send.accelerator: %|nls-2-#<Key>F3#|
|
||||
Dtmail*ComposeDialog*menubar*File.Close.acceleratorText: %|nls-3-#Alt+F4#|
|
||||
Dtmail*ComposeDialog*menubar*File.Close.accelerator: %|nls-4-#Alt<Key>F4#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Undo.acceleratorText: %|nls-5-#Ctrl+Z#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Undo.accelerator: %|nls-6-#Ctrl<Key>Z#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Cut.acceleratorText: %|nls-7-#Ctrl+X#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Cut.accelerator: %|nls-8-#Ctrl<Key>X#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Copy.acceleratorText: %|nls-9-#Ctrl+C#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Copy.accelerator: %|nls-10-#Ctrl<Key>C#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Paste.acceleratorText: %|nls-11-#Ctrl+v#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Paste.accelerator: %|nls-12-#Ctrl<Key>V#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Delete.acceleratorText: %|nls-13-#Delete#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Delete.accelerator: %|nls-14-#Delete#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Find/Change.acceleratorText: %|nls-15-#Ctrl+F#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Find/Change.accelerator: %|nls-16-#Ctrl<Key>F#|
|
||||
|
||||
|
||||
!#############################################################
|
||||
!#
|
||||
!# The Main Mailer accelerators and Text for those accelerators
|
||||
!#
|
||||
Dtmail*menubar*Mailbox.Check_for_New_Mail.acceleratorText: %|nls-17-#Ctrl+M#|
|
||||
Dtmail*menubar*Mailbox.Check_for_New_Mail.accelerator: %|nls-18-#Ctrl<Key>M#|
|
||||
Dtmail*menubar*Mailbox.Mail_Options.acceleratorText: %|nls-19-#Ctrl+I#|
|
||||
Dtmail*menubar*Mailbox.Mail_Options.accelerator: %|nls-20-#Ctrl<Key>I#|
|
||||
Dtmail*menubar*Mailbox.Close.acceleratorText: %|nls-21-#Alt+F4#|
|
||||
Dtmail*menubar*Mailbox.Close.accelerator: %|nls-22-#Alt<Key>F4#|
|
||||
Dtmail*menubar*Message*Print.acceleratorText: %|nls-23-#Ctrl+P#|
|
||||
Dtmail*menubar*Message*Print.accelerator: %|nls-24-#Ctrl<Key>P#|
|
||||
Dtmail*menubar*Edit.Copy.acceleratorText: %|nls-25-#Ctrl+C#|
|
||||
Dtmail*menubar*Edit.Copy.accelerator: %|nls-26-#Ctrl<Key>C#|
|
||||
Dtmail*menubar*Compose.New_Message.acceleratorText: %|nls-27-#Ctrl+N#|
|
||||
Dtmail*menubar*Compose.New_Message.accelerator: %|nls-28-#Ctrl<Key>N#|
|
||||
Dtmail*menubar*Compose.Reply_to_Sender.acceleratorText: %|nls-29-#Ctrl+R#|
|
||||
Dtmail*menubar*Compose.Reply_to_Sender.accelerator: %|nls-30-#Ctrl<Key>R#|
|
||||
|
||||
!#############################################################
|
||||
!#
|
||||
!# The Compose Dialog's mnemonic's
|
||||
!#
|
||||
Dtmail*ComposeDialog*menubar*File.mnemonic: %|nls-31-#F#|
|
||||
Dtmail*ComposeDialog*menubar*File.Include.mnemonic: %|nls-32-#I#|
|
||||
Dtmail*Save_As.mnemonic: %|nls-33-#A#|
|
||||
Dtmail*ComposeDialog*menubar*File.Log_Message.mnemonic: %|nls-34-#L#|
|
||||
Dtmail*menubar*Send.mnemonic: %|nls-35-#S#|
|
||||
Dtmail*ComposeDialog*menubar*File.Send_As.mnemonic: %|nls-36-#n#|
|
||||
Dtmail*ComposeDialog*menubar*File.Close.mnemonic: %|nls-37-#C#|
|
||||
Dtmail*ComposeDialog*Undo.mnemonic: %|nls-38-#U#|
|
||||
Dtmail*ComposeDialog*Cut.mnemonic: %|nls-39-#t#|
|
||||
Dtmail*Copy.mnemonic: %|nls-40-#C#|
|
||||
Dtmail*ComposeDialog*Paste.mnemonic: %|nls-41-#P#|
|
||||
Dtmail*menubar*Delete.mnemonic: %|nls-42-#D#|
|
||||
Dtmail*RoamMsgsPopup*Delete.mnemonic: %|nls-42-#D#|
|
||||
Dtmail*Select_All.mnemonic: %|nls-43-#S#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Find/Change.mnemonic: %|nls-44-#F#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Check_Spelling.mnemonic: %|nls-45-#k#|
|
||||
Dtmail*ComposeDialog*Add_File.mnemonic: %|nls-46-#F#|
|
||||
Dtmail*ComposeDialog*Undelete.mnemonic: %|nls-47-#U#|
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Rename.mnemonic: %|nls-48-#R#|
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Show_List.mnemonic: %|nls-49-#L#|
|
||||
Dtmail*ComposeDialog*menubar*Format.mnemonic: %|nls-50-#r#|
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.mnemonic: %|nls-51-#W#|
|
||||
Dtmail*ComposeDialog*menubar*Format.Settings.mnemonic: %|nls-52-#S#|
|
||||
Dtmail*ComposeDialog*menubar*Format.Templates.mnemonic: %|nls-53-#T#|
|
||||
Dtmail*ComposeDialog*menubar*Format.Add_Bcc.mnemonic: %|nls-54-#B#|
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# The Main Mailer mnemonic's
|
||||
!#
|
||||
Dtmail*menubar*Mailbox.mnemonic: %|nls-55-#x#|
|
||||
Dtmail*menubar*Check_for_New_Mail.mnemonic: %|nls-56-#M#|
|
||||
Dtmail*RoamMsgsPopup*Check_for_New_Mail.mnemonic: %|nls-56-#M#|
|
||||
Dtmail*menubar*Mailbox.Open_Inbox.mnemonic: %|nls-57-#I#|
|
||||
Dtmail*menubar*Mailbox.New.mnemonic: %|nls-58-#N#|
|
||||
Dtmail*menubar*Mailbox.Open.mnemonic: %|nls-59-#O#|
|
||||
Dtmail*menubar*Mailbox.Destroy_Deleted_Message.mnemonic: %|nls-60-#D#|
|
||||
Dtmail*menubar*Mailbox.Mail_Options.mnemonic: %|nls-61-#p#|
|
||||
Dtmail*menubar*Mailbox.Close.mnemonic: %|nls-62-#C#|
|
||||
Dtmail*menubar*Message.mnemonic: %|nls-63-#M#|
|
||||
Dtmail*menubar*Message*Open.mnemonic: %|nls-64-#O#|
|
||||
Dtmail*menubar*Save_As_Text.mnemonic: %|nls-65-#A#|
|
||||
Dtmail*RoamMsgsPopup*Save_As_Text.mnemonic: %|nls-65-#A#|
|
||||
Dtmail*menubar*Message*Copy_To.mnemonic: %|nls-66-#C#|
|
||||
Dtmail*menubar*Print.mnemonic: %|nls-67-#P#|
|
||||
Dtmail*RoamMsgsPopup*Print.mnemonic: %|nls-67-#P#|
|
||||
Dtmail*menubar*Message*Find.mnemonic: %|nls-68-#F#|
|
||||
Dtmail**menubar*Undelete_Last.mnemonic: %|nls-69-#L#|
|
||||
Dtmail*RoamMsgsPopup*Undelete_Last.menemonic: %|nls-69-#L#|
|
||||
Dtmail*menubar*Message*Undelete_From_List.mnemonic: %|nls-70-#U#|
|
||||
Dtmail*menubar*Edit.mnemonic: %|nls-71-#E#|
|
||||
Dtmail*menubar*Attachments.mnemonic: %|nls-72-#A#|
|
||||
Dtmail*menubar*View.mnemonic: %|nls-73-#V#|
|
||||
Dtmail*menubar*View.Next.mnemonic: %|nls-74-#N#|
|
||||
Dtmail*menubar*View.Previous.mnemonic: %|nls-75-#P#|
|
||||
Dtmail*menubar*View.Abbreviated_Headers.mnemonic: %|nls-76-#A#|
|
||||
Dtmail*menubar*View.By_Date/Time.mnemonic: %|nls-77-#D#|
|
||||
Dtmail*menubar*View.By_Sender.mnemonic: %|nls-78-#S#|
|
||||
Dtmail*menubar*View.By_Subject.mnemonic: %|nls-79-#b#|
|
||||
Dtmail*menubar*View.By_Size.mnemonic: %|nls-80-#z#|
|
||||
Dtmail*menubar*View.By_Status.mnemonic: %|nls-81-#t#|
|
||||
Dtmail*menubar*Compose.mnemonic: %|nls-82-#p#|
|
||||
Dtmail*menubar*Compose.New_Message.mnemonic: %|nls-83-#M#|
|
||||
Dtmail*menubar*Compose.New__Include_All.mnemonic: %|nls-84-#N#|
|
||||
Dtmail*menubar*Compose.Forward_Message.mnemonic: %|nls-85-#F#|
|
||||
Dtmail*menubar*Reply_to_Sender.mnemonic: %|nls-86-#R#|
|
||||
Dtmail*RoamMsgsPopup*Reply_to_Sender.mnemonic: %|nls-86-#R#|
|
||||
Dtmail*menubar*Compose.Reply_to_All.mnemonic: %|nls-87-#A#|
|
||||
Dtmail*menubar*Compose.Reply_to_Sender__Include.mnemonic: %|nls-88-#S#|
|
||||
Dtmail*menubar*Compose.Reply_to_All__Include.mnemonic: %|nls-89-#I#|
|
||||
Dtmail*menubar*Move.mnemonic: %|nls-90-#o#|
|
||||
Dtmail*RoamMsgsPopup*Move.mnemonic: %|nls-90-#o#|
|
||||
Dtmail*Inbox.mnemonic: %|nls-91-#I#|
|
||||
Dtmail*Other_Mailboxes.mnemonic: %|nls-92-#O#|
|
||||
Dtmail*menubar*Help.mnemonic: %|nls-93-#H#|
|
||||
Dtmail*menubar*Help.Overview.mnemonic: %|nls-94-#v#|
|
||||
Dtmail*menubar*Help.Tasks.mnemonic: %|nls-95-#T#|
|
||||
Dtmail*menubar*Help.Reference.mnemonic: %|nls-96-#R#|
|
||||
Dtmail*menubar*Help.On_Item.mnemonic: %|nls-97-#O#|
|
||||
Dtmail*menubar*Help.Using_Help.mnemonic: %|nls-98-#U#|
|
||||
Dtmail*menubar*Help.About_Mailer.mnemonic: %|nls-99-#A#|
|
||||
|
||||
!##################################################################################
|
||||
####
|
||||
!#
|
||||
!# Some more Main Mailer accelerators and Text
|
||||
!#
|
||||
Dtmail*menubar*Message*Delete.acceleratorText: %|nls-100-#Ctrl+D#|
|
||||
Dtmail*menubar*Message*Delete.accelerator: %|nls-101-#Ctrl<Key>D#|
|
||||
|
||||
!##################################################################################
|
||||
####
|
||||
!# More Mnemonics for Compose window Edit menu
|
||||
Dtmail*ComposeDialog*Clear.mnemonic: %|nls-102-#e#|
|
||||
|
||||
!##################################################################################
|
||||
!! Default column width for Compose window and Main Mailer
|
||||
Dtmail*ComposeDialog*Text*columns: %|nls-103-#80#|
|
||||
Dtmail*Work_Area*Text*columns: %|nls-104-#80#|
|
||||
|
||||
!################################################################
|
||||
!#
|
||||
!# Other Mailer resources
|
||||
!#
|
||||
Dtmail*interval: 5
|
||||
Dtmail*Next: True
|
||||
Dtmail*Next*default: True
|
||||
Dtmail*Start*default: True
|
||||
Dtmail*Message_List*scrollBarDisplayPolicy: STATIC
|
||||
Dtmail*Message_List*visibleItemCount: 15
|
||||
Dtmail*Message_List*width: 600
|
||||
Dtmail*Message_List*listSizePolicy: VARIABLE
|
||||
Dtmail*Message_List*viewHeight: 7
|
||||
Dtmail*Message_List*selectionPolicy: EXTENDED_SELECT
|
||||
Dtmail*Work_Area*Text*editMode: MULTI_LINE_EDIT
|
||||
Dtmail*Message_Send*scrollHorizontal: False
|
||||
!!Dtmail*Message_Send*wordWrap: True
|
||||
Dtmail*ComposeDialog*Work_Area*Text*wordWrap: False
|
||||
Dtmail*Message_View*scrollHorizontal: False
|
||||
Dtmail*Message_View*wordWrap: True
|
||||
Dtmail*Mail_View*scrollVertical: True
|
||||
Dtmail*menubar*tearOffModel: TEAR_OFF_DISABLED
|
||||
!!
|
||||
!!Dtmail*menubar*Compose.tearOffModel: TEAR_OFF_ENABLED
|
||||
!!Dtmail*menubar*Move.tearOffModel: TEAR_OFF_ENABLED
|
||||
!!
|
||||
Dtmail*View*Separator*separatorType: SHADOW_ETCHED_IN
|
||||
Dtmail*ComposeDialog*menubar*File.Log_Message.indicatorType: XmONE_OF_MANY
|
||||
Dtmail*ComposeDialog*menubar*File.Log_Message.set: TRUE
|
||||
Dtmail*ComposeDialog*menubar*File.Log_Message.visibleWhenOff: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Show_List.indicatorType: XmONE_OF_MANY
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Show_List.set: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Show_List.visibleWhenOff: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.indicatorType: XmONE_OF_MANY
|
||||
!!Dtmail*ComposeDialog*menubar*Format.Word_Wrap.set: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.set: False
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.set: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.visibleWhenOff: TRUE
|
||||
Dtmail*menubar*View.Abbreviated_Headers.indicatorType: XmONE_OF_MANY
|
||||
Dtmail*menubar*View.Abbreviated_Headers.set: TRUE
|
||||
Dtmail*menubar*View.Abbreviated_Headers.visibleWhenOff: TRUE
|
||||
*Message_View*Work_Area.width: 600
|
||||
*Message_View*Work_Area.height: 400
|
||||
Dtmail*separateViewWindow*Work_Area.width: 600
|
||||
Dtmail*separateViewWindow*Work_Area.height: 400
|
||||
!########################### eof ###########################
|
||||
!
|
||||
Dtmail*dtb_options_fields_hide.columns: %|nls-201-#IBM#|
|
||||
Dtmail*dtb_options_deadletter_field.dtb_options_deadletter_field_field.columns: %|nls-202-#IBM#|
|
||||
Dtmail*dtb_options_indent_str_tf.columns: %|nls-203-#IBM#|
|
||||
Dtmail*dtb_options_hdr_field.columns: %|nls-204-#IBM#|
|
||||
Dtmail*dtb_options_def_value_field.columns: %|nls-205-#IBM#|
|
||||
Dtmail*dtb_options_sent_mail_tf.columns: %|nls-206-#IBM#|
|
||||
Dtmail*dtb_options_path_file_name_tf.columns: %|nls-207-#IBM#|
|
||||
Dtmail*dtb_options_srt_looking_tf.columns: %|nls-208-#IBM#|
|
||||
Dtmail*dtb_options_vacation_msg_tp_pane.columns: %|nls-209-#IBM#|
|
||||
Dtmail*dtb_options_subject_tf.columns: %|nls-210-#IBM#|
|
||||
Dtmail*dtb_options_menu_label.columns: %|nls-211-#IBM#|
|
||||
Dtmail*dtb_options_path_filename_label.columns: %|nls-212-#IBM#|
|
||||
Dtmail*dtb_options_alias_tf.columns: %|nls-213-#IBM#|
|
||||
Dtmail*dtb_options_addresses_tf.columns: %|nls-214-#IBM#|
|
||||
Dtmail*dtb_options_local_name_tf.columns: %|nls-215-#IBM#|
|
||||
|
||||
448
cde/programs/dtmail/dtmail/Editor.C
Normal file
448
cde/programs/dtmail/dtmail/Editor.C
Normal file
@@ -0,0 +1,448 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Editor.C /main/11 1998/07/24 16:06:00 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <EUSCompat.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Dt/Dts.h>
|
||||
|
||||
#include "RoamApp.h"
|
||||
#include "MailMsg.h"
|
||||
#include "Editor.hh"
|
||||
#include "str_utils.h"
|
||||
|
||||
Editor::Editor()
|
||||
: UIComponent("Editor")
|
||||
{
|
||||
}
|
||||
|
||||
Editor::~Editor()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AbstractEditorParent::AbstractEditorParent() {
|
||||
_attachmentPopupMenu = NULL;
|
||||
_textPopupMenu = NULL;
|
||||
_menuPopupAtt = NULL;
|
||||
_menuPopupText = NULL;
|
||||
}
|
||||
|
||||
AbstractEditorParent::~AbstractEditorParent()
|
||||
{
|
||||
delete _menuPopupAtt;
|
||||
delete _menuPopupText;
|
||||
}
|
||||
|
||||
DtMailBoolean
|
||||
Editor::set_message(DtMail::Message * msg,
|
||||
char ** status_string,
|
||||
HeaderFormat header_format,
|
||||
InsertFormat format,
|
||||
BracketFormat brackets)
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session *m_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = m_session->mailRc(error);
|
||||
|
||||
*status_string = NULL;
|
||||
|
||||
DtMail::Envelope *env = msg->getEnvelope(error);
|
||||
|
||||
DtMailHeaderHandle hdr_hnd;
|
||||
char *name;
|
||||
DtMailValueSeq value;
|
||||
|
||||
// Here is not the place for getting the indent string
|
||||
// but it'll do for now.
|
||||
const char *indent_str = NULL;
|
||||
mail_rc->getValue(error, "indentprefix", &indent_str);
|
||||
if (error.isSet())
|
||||
indent_str = strdup("> ");
|
||||
|
||||
disable_redisplay();
|
||||
|
||||
int indent = 0;
|
||||
|
||||
if (format == IF_BRACKETED) {
|
||||
char * ins_bracket;
|
||||
switch (brackets) {
|
||||
case BF_FORWARD:
|
||||
ins_bracket = GETMSG(DT_catd, 1, 195, "------------- Begin Forwarded Message -------------\n\n");
|
||||
break;
|
||||
|
||||
case BF_INCLUDE:
|
||||
default:
|
||||
ins_bracket = GETMSG(DT_catd, 1, 196, "------------- Begin Included Message -------------\n\n");
|
||||
break;
|
||||
}
|
||||
|
||||
append_to_contents(ins_bracket, strlen(ins_bracket));
|
||||
}
|
||||
|
||||
// Code from MsgScrollingList - display_message().
|
||||
// We're trying to reduce heap size by not allocating and
|
||||
// deleting space in every loop iteration. So just have a
|
||||
// fixed size buffer initially.
|
||||
//
|
||||
|
||||
// Initial line size. When not enough, allocate more.
|
||||
int line_size = 1024;
|
||||
int tmp_count = 0;
|
||||
char *line = new char[line_size];
|
||||
int hdr_num = 0;
|
||||
|
||||
if (header_format != HF_NONE) {
|
||||
for ( hdr_hnd = env->getFirstHeader(
|
||||
error,
|
||||
&name,
|
||||
value);
|
||||
hdr_hnd && !error.isSet();
|
||||
hdr_hnd = env->getNextHeader(
|
||||
error,
|
||||
hdr_hnd,
|
||||
&name,
|
||||
value), hdr_num++ ) {
|
||||
|
||||
|
||||
if ((header_format == HF_ABBREV)
|
||||
&& (hdr_num != 0 || strcmp(name, "From") != 0)) {
|
||||
DtMailEnv ierror;
|
||||
if (mail_rc->ignore(ierror, name)) {
|
||||
free(name);
|
||||
value.clear();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for ( int val = 0; val < value.length(); val++ ) {
|
||||
tmp_count = strlen(name) +
|
||||
strlen(*(value[val])) +
|
||||
strlen(indent_str) +
|
||||
5;
|
||||
if ( tmp_count > line_size ) { // Need to increase line size.
|
||||
delete [] line;
|
||||
line_size = tmp_count;
|
||||
line = new char[line_size];
|
||||
}
|
||||
memset(line, 0, line_size);
|
||||
if (format == IF_INDENTED) {
|
||||
strcpy(line, indent_str);
|
||||
strcat(line, name);
|
||||
} else {
|
||||
strcpy(line, name);
|
||||
}
|
||||
|
||||
if (hdr_num != 0 || strcmp(name, "From") != 0) {
|
||||
strcat(line, ": ");
|
||||
}
|
||||
else {
|
||||
strcat(line, " ");
|
||||
}
|
||||
|
||||
strcat(line, *(value[val]));
|
||||
strcat(line, "\n");
|
||||
append_to_contents(line, strlen(line));
|
||||
}
|
||||
value.clear();
|
||||
free(name);
|
||||
}
|
||||
}
|
||||
// Don't delete line yet, because it's used below.
|
||||
|
||||
if (format == IF_INDENTED) {
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
}
|
||||
|
||||
if (header_format != HF_NONE) {
|
||||
append_to_contents("\n", 1);
|
||||
}
|
||||
|
||||
DtMail::BodyPart *bp = msg->getFirstBodyPart(error);
|
||||
|
||||
char *type;
|
||||
DtMailBoolean firstBPHandled = DTM_FALSE;
|
||||
|
||||
bp->getContents(error, NULL, NULL, &type, NULL, NULL, NULL);
|
||||
if ( type ) {
|
||||
char *attr = DtDtsDataTypeToAttributeValue(
|
||||
type,
|
||||
DtDTS_DA_IS_TEXT,
|
||||
NULL);
|
||||
if ((attr && strcasecmp(attr, "true") == 0)
|
||||
|| strcoll(type, DtDTS_DT_UNKNOWN) == 0 ) {
|
||||
const void *contents;
|
||||
unsigned long size;
|
||||
bp->lockContents(error, DtMailLockRead);
|
||||
bp->getContents(error, &contents, &size, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (format == IF_INDENTED) {
|
||||
int byte_count = 0;
|
||||
int content_count = (int) size;
|
||||
const char *last = NULL, *content_ptr = NULL;
|
||||
// Parse the result of getContents().
|
||||
// Spit out indent string with each line.
|
||||
// Is contents NULL terminated???
|
||||
for ( last = (const char *)contents,
|
||||
content_ptr = (const char *)contents;
|
||||
content_count > 0;
|
||||
content_ptr++,
|
||||
byte_count++,
|
||||
content_count-- ) {
|
||||
if ((*content_ptr == '\n') ||
|
||||
(content_count == 1) ) {
|
||||
// 2 for null terminator and new line.
|
||||
tmp_count = strlen(indent_str) + byte_count + 2;
|
||||
if ( tmp_count > line_size ) {
|
||||
// Need to increase line size.
|
||||
delete [] line;
|
||||
line_size = tmp_count;
|
||||
line = new char[line_size];
|
||||
}
|
||||
memset(line, 0, line_size);
|
||||
strcpy(line, indent_str);
|
||||
strncat(line, last, byte_count + 1);
|
||||
// Copy the '\n' also
|
||||
append_to_contents(line, strlen(line));
|
||||
last = content_ptr + 1;
|
||||
byte_count = -1;
|
||||
}
|
||||
} // end of for loop
|
||||
} else {
|
||||
append_to_contents((const char *)contents, size);
|
||||
}
|
||||
bp->unlockContents(error);
|
||||
firstBPHandled = DTM_TRUE;
|
||||
if (attr) {
|
||||
DtDtsFreeAttributeValue(attr);
|
||||
attr = NULL;
|
||||
}
|
||||
}
|
||||
free(type);
|
||||
|
||||
// DLP: We will turn off this test for now. We need to study the problem
|
||||
// of text checksums more.
|
||||
//
|
||||
//if (bp->checksum(error) == DtMailCheckBad) {
|
||||
// *status_string = GETMSG(DT_catd, 1, -1, "Digital signature did not match.");
|
||||
//}
|
||||
}
|
||||
delete [] line;
|
||||
|
||||
if (format == IF_BRACKETED) {
|
||||
char * ins_bracket;
|
||||
switch (brackets) {
|
||||
case BF_FORWARD:
|
||||
ins_bracket = GETMSG(DT_catd, 1, 197, "------------- End Forwarded Message -------------\n\n");
|
||||
break;
|
||||
|
||||
case BF_INCLUDE:
|
||||
default:
|
||||
ins_bracket = GETMSG(DT_catd, 1, 198, "------------- End Included Message -------------\n\n");
|
||||
break;
|
||||
}
|
||||
|
||||
append_to_contents(ins_bracket, strlen(ins_bracket));
|
||||
}
|
||||
|
||||
enable_redisplay();
|
||||
|
||||
if (NULL != indent_str)
|
||||
free((void*) indent_str);
|
||||
|
||||
return(firstBPHandled);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::append_newline_to_contents()
|
||||
{
|
||||
append_to_contents("\n", strlen("\n"));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Editor::set_attachment(
|
||||
DtMail::BodyPart *bp,
|
||||
InsertFormat format,
|
||||
BracketFormat brackets)
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session *m_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = m_session->mailRc(error);
|
||||
DtMailValueSeq value;
|
||||
|
||||
char *input, *name, *dttype, *description, *mimetype;
|
||||
const char *indent_str = NULL;
|
||||
unsigned long len;
|
||||
|
||||
if (format == IF_INDENTED)
|
||||
{
|
||||
mail_rc->getValue(error, "indentprefix", &indent_str);
|
||||
if (error.isSet())
|
||||
indent_str = strdup("> ");
|
||||
}
|
||||
|
||||
disable_redisplay();
|
||||
if ((format == IF_BRACKETED) && (brackets == BF_INCLUDE))
|
||||
{
|
||||
char * ins_bracket =
|
||||
GETMSG(
|
||||
DT_catd, 1, 249,
|
||||
"------------- Begin Included Attachment -------------\n\n");
|
||||
|
||||
append_to_contents(ins_bracket, strlen(ins_bracket));
|
||||
}
|
||||
else if (format == IF_INDENTED)
|
||||
{
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
bp->getContents(error, NULL, &len, &dttype, &name, NULL, &description);
|
||||
|
||||
if ((NULL != name) && (0 != strlen(name)))
|
||||
{
|
||||
if (NULL != indent_str)
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
input = GETMSG(DT_catd, 1, 251, " Attachment Name: ");
|
||||
append_to_contents(input, strlen(input));
|
||||
append_to_contents(name, strlen(name));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
if ((NULL != dttype) && (0 != strlen(dttype)))
|
||||
{
|
||||
if (NULL != indent_str)
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
input = GETMSG(DT_catd, 1, 252, " Attachment DtType: ");
|
||||
append_to_contents(input, strlen(input));
|
||||
append_to_contents(dttype, strlen(dttype));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
bp->getContentType(error, &mimetype);
|
||||
if ((NULL != mimetype) && (0 != strlen(mimetype)))
|
||||
{
|
||||
if (NULL != indent_str)
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
input = GETMSG(DT_catd, 1, 253, "Attachment ContentType: ");
|
||||
append_to_contents(input, strlen(input));
|
||||
append_to_contents(mimetype, strlen(mimetype));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
if ((NULL != description) && (0 != strlen(description)))
|
||||
{
|
||||
if (NULL != indent_str)
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
input = GETMSG(DT_catd, 1, 254, "Attachment Description: ");
|
||||
append_to_contents(input, strlen(input));
|
||||
append_to_contents(description, strlen(description));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
if ((format == IF_BRACKETED) && (brackets == BF_INCLUDE))
|
||||
{
|
||||
char * ins_bracket =
|
||||
GETMSG(
|
||||
DT_catd, 1, 250,
|
||||
"------------- End Included Attachment -------------\n\n");
|
||||
|
||||
append_to_contents(ins_bracket, strlen(ins_bracket));
|
||||
}
|
||||
else if (format == IF_INDENTED)
|
||||
{
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
enable_redisplay();
|
||||
|
||||
if (NULL != indent_str)
|
||||
free((void*) indent_str);
|
||||
if (NULL != name)
|
||||
free((void*) name);
|
||||
if (NULL != dttype)
|
||||
free((void*) dttype);
|
||||
if (NULL != mimetype)
|
||||
free((void*) mimetype);
|
||||
if (NULL != description)
|
||||
free((void*) description);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::update_display_from_props(void)
|
||||
{
|
||||
int rows, cols;
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mailrc = d_session->mailRc(error);
|
||||
const char * value = NULL;
|
||||
|
||||
mailrc->getValue(error, "popuplines", &value);
|
||||
if (error.isSet()) {
|
||||
value = strdup("24");
|
||||
}
|
||||
rows = (int) strtol(value, NULL, 10);
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
set_rows(rows);
|
||||
|
||||
// If toolcols is set, overwrite the column width with "toolcols" value.
|
||||
// Otherwise, default resource value will be used.
|
||||
value = NULL;
|
||||
error.clear();
|
||||
mailrc->getValue(error, "toolcols", &value);
|
||||
if (!error.isSet()){
|
||||
cols = (int) strtol(value, NULL, 10);
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
} else {
|
||||
/*
|
||||
* MB_CUR_MAX == 1 : SingleByteLanguage
|
||||
* MB_CUR_MAX > 1 : MultiByteLanguage
|
||||
*/
|
||||
if ( MB_CUR_MAX == 1 )
|
||||
cols = 80;
|
||||
else
|
||||
cols = 40;
|
||||
}
|
||||
set_columns(cols);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AbstractEditorParent::postAttachmentPopup(XEvent *event)
|
||||
{
|
||||
XmMenuPosition(_attachmentPopupMenu, (XButtonEvent *)event);
|
||||
XtManageChild(_attachmentPopupMenu);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractEditorParent::postTextPopup(XEvent *event)
|
||||
{
|
||||
if (_textPopupMenu == NULL)
|
||||
return;
|
||||
|
||||
XmMenuPosition(_textPopupMenu, (XButtonEvent *)event);
|
||||
XtManageChild(_textPopupMenu);
|
||||
}
|
||||
|
||||
185
cde/programs/dtmail/dtmail/Editor.hh
Normal file
185
cde/programs/dtmail/dtmail/Editor.hh
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Editor.hh /main/11 1998/02/03 10:28:56 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef EDITOR_H
|
||||
#define EDITOR_H
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include "MenuBar.h"
|
||||
|
||||
// Get all the Bento-related API and types (CMContainer, etc.)
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include "UIComponent.h"
|
||||
|
||||
extern int use_XmTextEditor;
|
||||
|
||||
class DtMailEditor;
|
||||
|
||||
class Editor : public UIComponent {
|
||||
|
||||
public:
|
||||
Editor();
|
||||
virtual ~Editor();
|
||||
|
||||
virtual void initialize() = 0;
|
||||
|
||||
virtual void set_contents(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
) = 0;
|
||||
|
||||
virtual void set_contents(const char * path) = 0;
|
||||
|
||||
virtual char * get_contents() = 0;
|
||||
|
||||
virtual void append_to_contents(
|
||||
const char *new_contents,
|
||||
const unsigned long len
|
||||
) = 0;
|
||||
|
||||
virtual void append_to_contents(const char * path) = 0;
|
||||
|
||||
virtual void append_at_cursor(const char *path) = 0;
|
||||
virtual void append_at_cursor(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
) = 0;
|
||||
|
||||
enum InsertFormat {
|
||||
IF_NONE, // No special format
|
||||
IF_INDENTED, // Indented with indent_prefix
|
||||
IF_BRACKETED // Bracketed
|
||||
};
|
||||
|
||||
enum BracketFormat {
|
||||
BF_NONE, // No bracketing
|
||||
BF_INCLUDE, // As included message,
|
||||
BF_FORWARD // As forwarded message
|
||||
};
|
||||
|
||||
enum HeaderFormat {
|
||||
HF_NONE, // Do not insert headers in message body.
|
||||
HF_FULL, // Insert all headers.
|
||||
HF_ABBREV // Do not insert ignored headers.
|
||||
};
|
||||
|
||||
virtual void append_newline_to_contents();
|
||||
virtual DtMailBoolean set_message(
|
||||
DtMail::Message * msg,
|
||||
char ** status_string,
|
||||
HeaderFormat header_format = HF_ABBREV,
|
||||
InsertFormat format = IF_NONE,
|
||||
BracketFormat brackets = BF_NONE);
|
||||
|
||||
virtual void set_attachment(
|
||||
DtMail::BodyPart * body_part,
|
||||
InsertFormat format = IF_NONE,
|
||||
BracketFormat brackets = BF_NONE);
|
||||
|
||||
virtual void clear_contents() = 0;
|
||||
virtual int no_text() = 0;
|
||||
|
||||
virtual Widget get_editor() = 0;
|
||||
virtual Widget get_text_widget() = 0;
|
||||
virtual Pixel get_text_foreground() = 0;
|
||||
virtual Pixel get_text_background() = 0;
|
||||
virtual Dimension get_text_width() = 0;
|
||||
virtual XmFontList get_text_fontList() = 0;
|
||||
|
||||
virtual int get_columns() = 0;
|
||||
virtual int get_rows() = 0;
|
||||
virtual void set_columns(int ncolumns) = 0;
|
||||
virtual void set_editable(Boolean value) = 0;
|
||||
virtual void set_rows(int nrows) = 0;
|
||||
virtual void update_display_from_props(void);
|
||||
|
||||
virtual void auto_show_cursor_off() = 0;
|
||||
virtual void auto_show_cursor_restore() = 0;
|
||||
|
||||
virtual void set_to_top() = 0;
|
||||
virtual void set_to_bottom() = 0;
|
||||
|
||||
virtual void find_change() = 0;
|
||||
virtual void spell() = 0;
|
||||
virtual void format() = 0;
|
||||
virtual void set_word_wrap(Boolean value) = 0;
|
||||
virtual void undo_edit() = 0;
|
||||
virtual void cut_selection() = 0;
|
||||
virtual void copy_selection() = 0;
|
||||
virtual void paste_from_clipboard() = 0;
|
||||
virtual void paste_special_from_clipboard(InsertFormat) = 0;
|
||||
virtual void clear_selection() = 0;
|
||||
virtual void delete_selection() = 0;
|
||||
virtual void select_all() = 0;
|
||||
|
||||
virtual void disable_redisplay() = 0;
|
||||
virtual void enable_redisplay() = 0;
|
||||
|
||||
};
|
||||
|
||||
class AbstractEditorParent {
|
||||
protected:
|
||||
Widget _attachmentPopupMenu;
|
||||
Widget _textPopupMenu;
|
||||
MenuBar *_menuPopupAtt;
|
||||
MenuBar *_menuPopupText;
|
||||
public:
|
||||
|
||||
AbstractEditorParent();
|
||||
virtual ~AbstractEditorParent();
|
||||
|
||||
virtual const char *const className()
|
||||
{ return "AbstractEditorParent"; }
|
||||
|
||||
virtual DtMailEditor * get_editor() = 0;
|
||||
|
||||
// Text/attachment (de)selection methods
|
||||
|
||||
virtual void text_selected() = 0;
|
||||
virtual void text_unselected() = 0;
|
||||
virtual void attachment_selected() = 0;
|
||||
virtual void all_attachments_deselected() = 0;
|
||||
virtual void all_attachments_selected() = 0;
|
||||
virtual void add_att(char *) = 0;
|
||||
virtual void add_att(char *, DtMailBuffer) = 0;
|
||||
virtual void add_att(DtMailBuffer) = 0;
|
||||
|
||||
virtual void postAttachmentPopup(XEvent *event);
|
||||
virtual void postTextPopup(XEvent *event);
|
||||
|
||||
virtual void addAttachmentActions(
|
||||
char **,
|
||||
int
|
||||
) = 0;
|
||||
virtual void invokeAttachmentAction(int) = 0;
|
||||
virtual void removeAttachmentActions() = 0;
|
||||
|
||||
virtual void selectAllAttachments() = 0;
|
||||
|
||||
virtual void showAttachArea() = 0;
|
||||
virtual void hideAttachArea() = 0;
|
||||
|
||||
virtual void attachmentFeedback(Boolean) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // EDITOR_HH
|
||||
194
cde/programs/dtmail/dtmail/EncryptedTextFieldUiItem.C
Normal file
194
cde/programs/dtmail/dtmail/EncryptedTextFieldUiItem.C
Normal file
@@ -0,0 +1,194 @@
|
||||
/* $TOG: EncryptedTextFieldUiItem.C /main/2 1997/11/13 13:25:10 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
#include <Xm/TextF.h>
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/EncryptedTextFieldUiItem.hh>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/DtMailServer.hh>
|
||||
#include <DtMail/DtMailTypes.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
EncryptedTextFieldUiItem::EncryptedTextFieldUiItem(
|
||||
Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
PropUiCallback validator,
|
||||
void *validator_data)
|
||||
: PropUiItem(w, source, search_key, validator, validator_data)
|
||||
{
|
||||
_loading = DTM_FALSE;
|
||||
_maxtextlen = 256;
|
||||
_text = (char*) malloc(_maxtextlen);
|
||||
assert(NULL!=_text);
|
||||
_writeAllowed = DTM_FALSE;
|
||||
|
||||
XtVaSetValues(
|
||||
w,
|
||||
XmNeditable, False,
|
||||
XmNvalue, "",
|
||||
NULL);
|
||||
XtAddCallback(
|
||||
w,
|
||||
XmNmodifyVerifyCallback, EncryptedTextFieldUiItem::verifyCB,
|
||||
(XtPointer) this);
|
||||
|
||||
options_field_init(w, &(this->dirty_bit));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::writeAllowed(DtMailBoolean allowed)
|
||||
{
|
||||
Widget w = getWidget();
|
||||
|
||||
if (_writeAllowed == allowed) return;
|
||||
|
||||
_writeAllowed = allowed;
|
||||
if (DTM_TRUE == _writeAllowed)
|
||||
{
|
||||
char *s;
|
||||
char *value = strdup(_text);
|
||||
|
||||
for (s=value; *s; s++) *s = '*';
|
||||
|
||||
_loading = DTM_TRUE;
|
||||
XtVaSetValues(w, XmNeditable, True, XmNsensitive, True, NULL);
|
||||
options_field_set_value(w, value, this->dirty_bit);
|
||||
_loading = DTM_FALSE;
|
||||
setDirtyBit(True);
|
||||
free(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loading = DTM_TRUE;
|
||||
XtVaSetValues(w, XmNeditable, False, XmNsensitive, False, NULL);
|
||||
options_field_set_value(w, "", this->dirty_bit);
|
||||
_loading = DTM_FALSE;
|
||||
setDirtyBit(True);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::writeFromUiToSource()
|
||||
{
|
||||
if (DTM_TRUE == _writeAllowed)
|
||||
prop_source->setValue(_text, DTM_TRUE);
|
||||
else
|
||||
prop_source->setValue(DTMAS_PROPDFLT_PASSWORD, DTM_TRUE);
|
||||
}
|
||||
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::writeFromSourceToUi()
|
||||
{
|
||||
int i;
|
||||
char *s, *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
value = (char *)prop_source->getValue(DTM_TRUE);
|
||||
if (! strcmp(value, PropSourceDEFAULTVALUE)) return;
|
||||
|
||||
validateLength(strlen(value));
|
||||
strcpy(_text, value);
|
||||
|
||||
for (i=0, s=value; i<strlen(value); i++, s++)
|
||||
*s = '*';
|
||||
|
||||
_loading = DTM_TRUE;
|
||||
options_field_set_value(w, value, this->dirty_bit);
|
||||
if (NULL != value) free((void*) value);
|
||||
_loading = DTM_FALSE;
|
||||
}
|
||||
|
||||
// Verifies that the _text array is sufficiently long for a string
|
||||
// of the specified size.
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::validateLength(int length)
|
||||
{
|
||||
length++; // Account for the '\0'
|
||||
if (length >= _maxtextlen)
|
||||
{
|
||||
_maxtextlen *= 2;
|
||||
_text = (char*) realloc((void*) _text, (size_t) _maxtextlen);
|
||||
assert(NULL!=_text);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::verify(XmTextVerifyPtr cbs)
|
||||
{
|
||||
int i;
|
||||
static char buffer[MAXPATHLEN];
|
||||
register char *s, *t;
|
||||
|
||||
#if defined(ENCRYPTED_TEXTFIELD_DEBUG)
|
||||
printf(
|
||||
"currInsert=%d newInsert=%d startPos=%d endPos=%d\n",
|
||||
cbs->currInsert,cbs->newInsert,cbs->startPos, cbs->endPos);
|
||||
if (cbs->text->ptr) printf("text->ptr=%s\n", cbs->text->ptr);
|
||||
printf("_text->ptr=%s\n", _text);
|
||||
#endif
|
||||
|
||||
for (i=0, s=buffer, t=_text; (*t && i<cbs->startPos); i++, s++, t++)
|
||||
*s = *t;
|
||||
|
||||
if (cbs->text->ptr)
|
||||
{
|
||||
strcpy(s, cbs->text->ptr);
|
||||
s += cbs->text->length;
|
||||
}
|
||||
else
|
||||
*s = '\0';
|
||||
|
||||
if (strlen(_text) >= cbs->endPos)
|
||||
{
|
||||
t = _text+cbs->endPos;
|
||||
if (strlen(t))
|
||||
strcpy(s, t);
|
||||
}
|
||||
|
||||
validateLength(strlen(buffer));
|
||||
strcpy(_text, buffer);
|
||||
|
||||
if (cbs->text->ptr)
|
||||
for (i=0, s=cbs->text->ptr; i<cbs->text->length; i++, s++)
|
||||
*s = '*';
|
||||
|
||||
#if defined(ENCRYPTED_TEXTFIELD_DEBUG)
|
||||
printf("text=%s\n", _text);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ValueChangedCallback for the text field. Saves the user input
|
||||
// and echos *'s.
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::verifyCB(
|
||||
Widget w,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
EncryptedTextFieldUiItem *etf = (EncryptedTextFieldUiItem*) client_data;
|
||||
XmTextVerifyCallbackStruct *cbs = (XmTextVerifyCallbackStruct*) call_data;
|
||||
|
||||
if (DTM_FALSE == etf->_loading) etf->verify(cbs);
|
||||
}
|
||||
879
cde/programs/dtmail/dtmail/FindDialog.C
Normal file
879
cde/programs/dtmail/dtmail/FindDialog.C
Normal file
@@ -0,0 +1,879 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: FindDialog.C /main/7 1998/07/23 17:59:06 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include <Xm/TextF.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/PanedW.h>
|
||||
#include <Xm/LabelG.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xm/SeparatoG.h>
|
||||
#include <DtMail/DtMail.h>
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include "FindDialog.h"
|
||||
#include "RoamApp.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
#include "RoamCmds.h"
|
||||
#include "Help.hh"
|
||||
#include "MailMsg.h"
|
||||
#include <EUSCompat.h>
|
||||
#include "str_utils.h"
|
||||
|
||||
|
||||
//
|
||||
// Clear out the data. After this function is complete the
|
||||
// data should look as if the constructor was just called and
|
||||
// before initialize().
|
||||
//
|
||||
void
|
||||
FindDialog::clear()
|
||||
{
|
||||
register unsigned int offset;
|
||||
|
||||
//
|
||||
if (_text_labels != NULL) {
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_labels[offset] != NULL) {
|
||||
free(_text_labels[offset]);
|
||||
}
|
||||
}
|
||||
delete _text_labels;
|
||||
}
|
||||
|
||||
//
|
||||
if (_text_values != NULL) {
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_values[offset] != NULL) {
|
||||
free(_text_values[offset]);
|
||||
}
|
||||
}
|
||||
delete _text_values;
|
||||
}
|
||||
|
||||
//
|
||||
if (_text_abstract_name != NULL) {
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_abstract_name[offset] != NULL) {
|
||||
free(_text_abstract_name[offset]);
|
||||
}
|
||||
}
|
||||
delete _text_abstract_name;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
if (_buttonData != NULL) {
|
||||
for (offset = 0; offset < _num_buttons; offset++) {
|
||||
if (_buttonData[offset].label != NULL) {
|
||||
free(_buttonData[offset].label);
|
||||
}
|
||||
}
|
||||
delete _buttonData;
|
||||
}
|
||||
|
||||
if (_text_fields != NULL) {
|
||||
delete _text_fields;
|
||||
}
|
||||
|
||||
if (_text_names != NULL) {
|
||||
delete _text_names;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// The only constructor.
|
||||
//
|
||||
FindDialog::FindDialog(RoamMenuWindow *parent) : Dialog("find", parent)
|
||||
{
|
||||
_roamWindow = parent;
|
||||
_num_text_fields = 4;
|
||||
_num_buttons = 5;
|
||||
|
||||
//
|
||||
// Allocate storage for labels, widgets, and data.
|
||||
//
|
||||
_text_labels = new char *[_num_text_fields];
|
||||
_text_names = new char *[_num_text_fields];
|
||||
_text_values = new char *[_num_text_fields];
|
||||
_text_abstract_name = new char *[_num_text_fields];
|
||||
_text_fields = new Widget[_num_text_fields];
|
||||
_buttonData = new ActionAreaItem[_num_buttons];
|
||||
_searchForward = TRUE;
|
||||
|
||||
//
|
||||
// Initialize the buttons.
|
||||
//
|
||||
_buttonData[0].label = strdup(GETMSG(DT_catd, 1, 183, "Find"));
|
||||
_buttonData[0].callback = findCallback;
|
||||
_buttonData[0].data = (caddr_t) this;
|
||||
|
||||
#ifdef NL_OBSOLETE
|
||||
/*
|
||||
* NL_COMMENT
|
||||
* This is an obsolete message. Replaced by message 220 in set 1
|
||||
*/
|
||||
_buttonData[1].label = strdup(GETMSG(DT_catd, 1, 184, "Find & Select All"));
|
||||
#endif
|
||||
/*
|
||||
* NL_COMMENT
|
||||
* This message replaces message 184 in set 1
|
||||
*/
|
||||
_buttonData[1].label = strdup(GETMSG(DT_catd, 1, 220, "Select All"));
|
||||
_buttonData[1].callback = findSelectAllCallback;
|
||||
_buttonData[1].data = (caddr_t) this;
|
||||
|
||||
_buttonData[2].label = strdup(GETMSG(DT_catd, 1, 185, "Clear"));
|
||||
_buttonData[2].callback = clearCallback;
|
||||
_buttonData[2].data = (caddr_t) this;
|
||||
|
||||
_buttonData[3].label = strdup(GETMSG(DT_catd, 1, 186, "Close"));
|
||||
_buttonData[3].callback = closeCallback;
|
||||
_buttonData[3].data = (caddr_t) this;
|
||||
|
||||
_buttonData[4].label = strdup(GETMSG(DT_catd, 1, 187, "Help"));
|
||||
_buttonData[4].callback = HelpCB;
|
||||
_buttonData[4].data = (caddr_t) DTMAILFINDDIALOG;
|
||||
|
||||
_text_labels[0] = strdup(GETMSG(DT_catd, 1, 188, "To:"));
|
||||
_text_labels[1] = strdup(GETMSG(DT_catd, 1, 189, "From:"));
|
||||
_text_labels[2] = strdup(GETMSG(DT_catd, 1, 190, "Subject:"));
|
||||
_text_labels[3] = strdup(GETMSG(DT_catd, 1, 191, "Cc:"));
|
||||
|
||||
// These strings should not be translated. They are
|
||||
// the Motif names for the widgets that will be created (they are
|
||||
// not the labels).
|
||||
_text_names[0] = "To";
|
||||
_text_names[1] = "From";
|
||||
_text_names[2] = "Subject";
|
||||
_text_names[3] = "Cc";
|
||||
|
||||
//
|
||||
// Initialize the names of the fields to the abstract
|
||||
// names used by libDtMail.
|
||||
//
|
||||
_text_abstract_name[0] = strdup(DtMailMessageTo);
|
||||
_text_abstract_name[1] = strdup(DtMailMessageSender);
|
||||
_text_abstract_name[2] = strdup(DtMailMessageSubject);
|
||||
_text_abstract_name[3] = strdup(DtMailMessageCc);
|
||||
}
|
||||
|
||||
//
|
||||
// Print a string in the status line of the find dialog.
|
||||
//
|
||||
void
|
||||
FindDialog::setStatus(const char * str)
|
||||
{
|
||||
char *tmpstr = strdup(str);
|
||||
XmString label = XmStringCreateLocalized(tmpstr);
|
||||
|
||||
XtVaSetValues(_status_text,
|
||||
XmNlabelString, label,
|
||||
NULL);
|
||||
|
||||
XmUpdateDisplay(baseWidget());
|
||||
XmStringFree(label);
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the status line of the find dialog.
|
||||
//
|
||||
void
|
||||
FindDialog::clearStatus(void)
|
||||
{
|
||||
setStatus(" ");
|
||||
}
|
||||
|
||||
//
|
||||
// Create the guts of the dialog
|
||||
//
|
||||
Widget
|
||||
FindDialog::createWorkArea(Widget dialog)
|
||||
{
|
||||
// TODO - CHECK ERROR!!!
|
||||
Widget *label = new Widget[_num_text_fields];
|
||||
|
||||
|
||||
register unsigned int offset;
|
||||
|
||||
_name = GETMSG(DT_catd, 1, 192, "Mailer - Find");
|
||||
|
||||
title(_name);
|
||||
|
||||
// make this a modal dialog
|
||||
/*
|
||||
XtVaSetValues (dialog,
|
||||
XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
|
||||
NULL);
|
||||
*/
|
||||
|
||||
printHelpId("dialog", dialog);
|
||||
|
||||
/* add help callback */
|
||||
// XtAddCallback(dialog, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
Widget fd_pane = XtVaCreateWidget ("fd_pane",
|
||||
xmPanedWindowWidgetClass,
|
||||
dialog,
|
||||
XmNsashWidth, 1,
|
||||
XmNsashHeight, 1,
|
||||
NULL);
|
||||
|
||||
printHelpId ("fd_pane", fd_pane);
|
||||
// add help callback
|
||||
// XtAddCallback (fd_pane, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
Widget fd_form = XtVaCreateWidget ("fd_form",
|
||||
xmFormWidgetClass,
|
||||
fd_pane,
|
||||
XmNfractionBase, 100,
|
||||
NULL);
|
||||
|
||||
printHelpId ("fd_form", fd_form);
|
||||
// add help callback
|
||||
// XtAddCallback (fd_form, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
|
||||
Widget _fd_labelbox = XtVaCreateManagedWidget ("_fd_labelbox",
|
||||
xmRowColumnWidgetClass,
|
||||
fd_form,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_POSITION,
|
||||
XmNrightAttachment, XmATTACH_POSITION,
|
||||
XmNleftPosition, 5,
|
||||
XmNrightPosition, 95,
|
||||
XmNpacking, XmPACK_COLUMN,
|
||||
XmNnumColumns, 2,
|
||||
XmNorientation, XmVERTICAL,
|
||||
XmNisAligned, True,
|
||||
XmNentryAlignment, XmALIGNMENT_END,
|
||||
XmNentryVerticalAlignment, XmALIGNMENT_CENTER,
|
||||
NULL);
|
||||
printHelpId ("_fd_labelbox", _fd_labelbox);
|
||||
// add help callback
|
||||
// XtAddCallback (_fd_labelbox, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
|
||||
Widget *_fd_labels = new Widget [_num_text_fields];
|
||||
|
||||
int _fd_i = 0;
|
||||
for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++)
|
||||
{
|
||||
_fd_labels [_fd_i] = XtVaCreateManagedWidget (
|
||||
_text_labels [_fd_i],
|
||||
xmLabelGadgetClass,
|
||||
_fd_labelbox,
|
||||
NULL);
|
||||
|
||||
printHelpId ("_fd_labels [%s]", _fd_labels [_fd_i]);
|
||||
// naturally, this is bogus --must be fixed to return proper label
|
||||
// add help callback
|
||||
// XtAddCallback(_fd_labels [_fd_i], XmNhelpCallback, HelpCB, helpId);
|
||||
}
|
||||
|
||||
for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++)
|
||||
{
|
||||
_text_fields [_fd_i] = XtVaCreateManagedWidget (
|
||||
_text_names [_fd_i],
|
||||
xmTextFieldWidgetClass,
|
||||
_fd_labelbox,
|
||||
NULL);
|
||||
printHelpId ("_text_fields [%s]", _text_fields [_fd_i]);
|
||||
// naturally, this is bogus --must be fixed to return proper label
|
||||
// add help callback
|
||||
// XtAddCallback(_text_fields [_fd_i], XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
XtAddCallback(_text_fields [_fd_i], XmNactivateCallback,
|
||||
(XtCallbackProc)textFieldCallback, (XtPointer)this);
|
||||
}
|
||||
|
||||
|
||||
XmString strForward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 193, "Forward"));
|
||||
XmString strBackward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 194, "Backward"));
|
||||
|
||||
Widget fd_direction
|
||||
= XmVaCreateSimpleRadioBox(fd_form,
|
||||
"Direction",
|
||||
0, // Initial selection
|
||||
directionCallback,
|
||||
//NULL,
|
||||
XmVaRADIOBUTTON, strForward, NULL, NULL, NULL,
|
||||
XmVaRADIOBUTTON, strBackward, NULL, NULL, NULL,
|
||||
XmNuserData, this,
|
||||
XmNsensitive, True,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _fd_labelbox,
|
||||
XmNorientation, XmHORIZONTAL,
|
||||
XmNleftAttachment, XmATTACH_POSITION,
|
||||
XmNleftPosition, 33,
|
||||
NULL);
|
||||
printHelpId ("fd_direction", fd_direction);
|
||||
// add help callback
|
||||
//XtAddCallback (fd_direction, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
XmStringFree(strForward);
|
||||
XmStringFree(strBackward);
|
||||
|
||||
//
|
||||
// Now create the Action Area.
|
||||
//
|
||||
#define TIGHTNESS 20
|
||||
|
||||
register Widget widget;
|
||||
|
||||
Widget fd_action = XtVaCreateWidget("actionArea",
|
||||
xmFormWidgetClass,
|
||||
fd_pane,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNfractionBase, TIGHTNESS * _num_buttons-1,
|
||||
NULL);
|
||||
printHelpId ("actionArea", fd_action);
|
||||
// add help callback
|
||||
//XtAddCallback (fd_action, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
for (offset = 0; offset < _num_buttons; offset++)
|
||||
{ widget = XtVaCreateManagedWidget(_buttonData[offset].label,
|
||||
xmPushButtonWidgetClass, fd_action,
|
||||
|
||||
XmNleftAttachment,
|
||||
offset ? XmATTACH_POSITION:XmATTACH_FORM,
|
||||
|
||||
XmNleftPosition, TIGHTNESS * offset,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
|
||||
XmNrightAttachment,
|
||||
offset != _num_buttons - 1 ? XmATTACH_POSITION : XmATTACH_FORM,
|
||||
|
||||
XmNrightPosition,
|
||||
TIGHTNESS * offset + (TIGHTNESS - 1),
|
||||
|
||||
XmNshowAsDefault, offset == 0,
|
||||
NULL);
|
||||
|
||||
// again, bogus -- doesn't each one need a unique tag?
|
||||
printHelpId ("widget", widget);
|
||||
// add help callback
|
||||
//XtAddCallback (widget, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
if (_buttonData[offset].callback != NULL) {
|
||||
XtAddCallback(widget, XmNactivateCallback,
|
||||
_buttonData[offset].callback,
|
||||
_buttonData[offset].data);
|
||||
}
|
||||
|
||||
|
||||
if (offset == 0) {
|
||||
Dimension height;
|
||||
Dimension margin;
|
||||
|
||||
XtVaGetValues(fd_action, XmNmarginHeight, &margin, NULL);
|
||||
XtVaGetValues(widget, XmNheight, &height, NULL);
|
||||
height +=2 * margin;
|
||||
XtVaSetValues(fd_action,
|
||||
XmNdefaultButton, widget,
|
||||
XmNpaneMaximum, height,
|
||||
XmNpaneMinimum, height,
|
||||
NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
_status_text = XtVaCreateManagedWidget("StatusLabel",
|
||||
xmLabelWidgetClass, fd_pane,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
NULL);
|
||||
|
||||
Dimension height;
|
||||
XtWidgetGeometry size;
|
||||
|
||||
size.request_mode = CWHeight;
|
||||
XtQueryGeometry(_status_text, NULL, &size);
|
||||
XtVaSetValues(_status_text,
|
||||
XmNpaneMaximum, size.height,
|
||||
XmNpaneMinimum, size.height,
|
||||
NULL);
|
||||
|
||||
clearStatus();
|
||||
|
||||
XtManageChild (fd_form);
|
||||
XtManageChild (fd_direction);
|
||||
XtManageChild(fd_action);
|
||||
XtManageChild(fd_pane);
|
||||
|
||||
XtManageChild(dialog);
|
||||
|
||||
// Make sure get the height of the dialog after it has been
|
||||
// managed.
|
||||
XtVaGetValues(dialog, XmNheight, &height, NULL);
|
||||
XtVaSetValues(dialog,
|
||||
XmNmappedWhenManaged, True,
|
||||
XmNminHeight, height,
|
||||
NULL);
|
||||
XtRealizeWidget(dialog);
|
||||
|
||||
return (fd_pane);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Look for all matching messages.
|
||||
//
|
||||
Boolean
|
||||
FindDialog::findMatching(Boolean findAll)
|
||||
{
|
||||
// TODO - CHECK ERROR!!!
|
||||
DtMailEnv error;
|
||||
unsigned int matchCount = 0;
|
||||
|
||||
/* NL_COMMENT
|
||||
* This string is displayed on the find dialog status line
|
||||
* when searching for a matching message.
|
||||
*/
|
||||
|
||||
setStatus(GETMSG(DT_catd, 1, 231, "Searching..."));
|
||||
busyCursor();
|
||||
theRoamApp.busyAllWindows(NULL);
|
||||
|
||||
//
|
||||
// Get the active list.
|
||||
//
|
||||
MsgScrollingList * displayList = _roamWindow->list();
|
||||
|
||||
//
|
||||
// Find the max. number of messages that we are to find matching.
|
||||
//
|
||||
int numberMessages = displayList->get_num_messages();
|
||||
|
||||
//
|
||||
// Are there any messages?
|
||||
//
|
||||
if (numberMessages > 0) {
|
||||
|
||||
//
|
||||
// A pointer to the currently interesting message.
|
||||
//
|
||||
register DtMailMessageHandle currentHandle = NULL;
|
||||
|
||||
//
|
||||
// The offset of the currentHandle in the MsgScrollingList.
|
||||
//
|
||||
register int handleOffset;
|
||||
|
||||
//
|
||||
// Find the current message. We would always start from the
|
||||
// currently selected message.
|
||||
//
|
||||
// Get the handle to the currently displaied message.
|
||||
//
|
||||
DtMailMessageHandle initialHandle = displayList->current_msg_handle();
|
||||
|
||||
//
|
||||
// Get the list of DtMailMessageHandle's.
|
||||
|
||||
MsgHndArray * msgHandles = displayList->get_messages();
|
||||
|
||||
//
|
||||
// Up to all of them can match, allocate and clear the list.
|
||||
//
|
||||
DtMailMessageHandle * matchList = NULL;
|
||||
if (findAll) {
|
||||
matchList = new DtMailMessageHandle[numberMessages+1];
|
||||
}
|
||||
unsigned int matchOffset = 0;
|
||||
|
||||
//
|
||||
// Deselect all messages.
|
||||
//
|
||||
XmListDeselectAllItems(displayList->baseWidget());
|
||||
|
||||
//
|
||||
// Start the search from the initially displaied message (+1).
|
||||
//
|
||||
handleOffset = displayList->position(initialHandle) - 1;
|
||||
if (_searchForward) {
|
||||
handleOffset++;
|
||||
if (handleOffset >= numberMessages) {
|
||||
handleOffset = 0;
|
||||
}
|
||||
} else {
|
||||
handleOffset--;
|
||||
if (handleOffset < 0) {
|
||||
handleOffset = numberMessages - 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (; handleOffset < numberMessages;) {
|
||||
currentHandle = msgHandles->at(handleOffset)->message_handle;
|
||||
|
||||
//
|
||||
// See if this message is a match, if it is...
|
||||
//
|
||||
if (compareMessage(currentHandle)) {
|
||||
matchCount++;
|
||||
|
||||
//
|
||||
// If we are finding all, then add to the list.
|
||||
// If not, then display this message and we are done.
|
||||
//
|
||||
if (findAll) {
|
||||
matchList[matchOffset++] = currentHandle;
|
||||
} else {
|
||||
XmListDeselectAllItems(displayList->baseWidget());
|
||||
//displayList->set_selected_item_position(handleOffset);
|
||||
displayList->display_and_select_message(error, currentHandle);
|
||||
break; // Only one.
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we have looped back to the initial
|
||||
// message (handle), then we are done.
|
||||
//
|
||||
if (currentHandle == initialHandle) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the next message.
|
||||
//
|
||||
// If we have reached the end, start over.
|
||||
// (as if the list was a circular list)
|
||||
//
|
||||
// We loop forward (_searchForward == TRUE) else we loop backward.
|
||||
//
|
||||
if (_searchForward) {
|
||||
handleOffset++;
|
||||
if (handleOffset >= numberMessages) {
|
||||
handleOffset = 0;
|
||||
}
|
||||
} else {
|
||||
handleOffset--;
|
||||
if (handleOffset < 0) {
|
||||
handleOffset = numberMessages - 1;
|
||||
}
|
||||
}
|
||||
currentHandle = msgHandles->at(handleOffset)->message_handle;
|
||||
}
|
||||
|
||||
//
|
||||
// Select all the messages that match, and display the last
|
||||
// one in the list.
|
||||
//
|
||||
if (findAll) {
|
||||
|
||||
displayList->select_all_and_display_last(error, matchList, matchCount);
|
||||
if (matchCount > 0) {
|
||||
char *line = new char[80];
|
||||
/* NL_COMMENT
|
||||
* These strings are displayed on the find dialog status line
|
||||
* when one or more matching messages are found. The first
|
||||
* string is displayed when there is one matching message,
|
||||
* and the second string is displayed when there is more than
|
||||
* one. The %d is the number of messages that matched.
|
||||
*/
|
||||
if (matchCount == 1) {
|
||||
strcpy(line, GETMSG(DT_catd, 1, 232, "1 message selected"));
|
||||
} else {
|
||||
sprintf(line, GETMSG(DT_catd, 1, 233, "%d messages selected"),
|
||||
matchCount);
|
||||
}
|
||||
setStatus(line);
|
||||
delete [] line;
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
delete matchList;
|
||||
matchList = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
normalCursor();
|
||||
theRoamApp.unbusyAllWindows();
|
||||
if (error.isNotSet()) {
|
||||
if (matchCount > 0) {
|
||||
if (!findAll) {
|
||||
clearStatus();
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
/* NL_COMMENT
|
||||
* This string is displayed on the find dialog status line when
|
||||
* no matching messages were found.
|
||||
*/
|
||||
setStatus(GETMSG(DT_catd, 1, 234, "No matches were found"));
|
||||
return(False);
|
||||
}
|
||||
|
||||
Boolean
|
||||
FindDialog::compareMessage(DtMailMessageHandle handle)
|
||||
{
|
||||
Boolean found = False;
|
||||
register unsigned int offset;
|
||||
|
||||
//
|
||||
// Check for something to do.
|
||||
//
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_values[offset] != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If all fields are empty then we match anything
|
||||
if (offset >= _num_text_fields) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (offset < _num_text_fields && handle != NULL) {
|
||||
|
||||
// TODO - CHECK ERROR!!!
|
||||
DtMailEnv error;
|
||||
|
||||
//
|
||||
// Get the mail box.
|
||||
//
|
||||
DtMail::MailBox * mbox = _roamWindow->mailbox();
|
||||
|
||||
//
|
||||
// Get the DtMail::Message and Envelope for this handle.
|
||||
//
|
||||
DtMail::Message * message = mbox->getMessage(error, handle);
|
||||
DtMail::Envelope * envelope = message->getEnvelope(error);
|
||||
|
||||
//
|
||||
// Get the meassage header.
|
||||
//
|
||||
DtMailValueSeq header;
|
||||
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_values[offset] != NULL) {
|
||||
if (_text_abstract_name[offset] != NULL) {
|
||||
envelope->getHeader(error, _text_abstract_name[offset],
|
||||
DTM_TRUE, header);
|
||||
found = TRUE;
|
||||
} else {
|
||||
envelope->getHeader(error, _text_names[offset],
|
||||
DTM_FALSE, header);
|
||||
found = TRUE;
|
||||
}
|
||||
if (!compareHeader(error, header, _text_values[offset])) {
|
||||
found = False;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// Problem: if we have multiple search fields ... and use
|
||||
// the same "header" array ... "compareHeader" looks for
|
||||
// each "find" field in each (available) header field.
|
||||
// So, make sure only one is available for searching.
|
||||
// Really "offset" should be passed to "compareHeader" ...
|
||||
// That way, correct comparison can be done and the
|
||||
// memory for this array can be released correctly via the
|
||||
// destructor .... since "remove" fails to do so.
|
||||
header.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (offset > _num_text_fields) {
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
return(found);
|
||||
}
|
||||
|
||||
//
|
||||
// See if string 'toFind' is anyware in string 'str'.
|
||||
// A case-insensitive version of strstr().
|
||||
//
|
||||
static const char *
|
||||
strcasestr(const char *str, const char *toFind)
|
||||
{
|
||||
const char *result = NULL; // Default to not found.
|
||||
|
||||
if (str && toFind) { // Sanity check
|
||||
register int offset = 0;
|
||||
register int lenToFind = strlen(toFind);
|
||||
register int lenStr = strlen(str);
|
||||
|
||||
//
|
||||
// If toFind == "", then return the entire string (like strstr()).
|
||||
//
|
||||
if (lenToFind == 0) {
|
||||
result = str;
|
||||
} else {
|
||||
//
|
||||
// Start at each position in the string and look for
|
||||
// toFind - ignore case.
|
||||
//
|
||||
for (offset = 0; offset + lenToFind <= lenStr; offset++) {
|
||||
if (strncasecmp(&str[offset], toFind, lenToFind) == 0) {
|
||||
result = &str[offset];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
Boolean
|
||||
FindDialog::compareHeader(DtMailEnv & error,
|
||||
DtMailValueSeq & header,
|
||||
const char * cmpToString)
|
||||
{
|
||||
register int headerOffset = header.length() - 1;
|
||||
|
||||
error.clear();
|
||||
|
||||
while(headerOffset >= 0) {
|
||||
if ((strcasestr(*(header[headerOffset]), cmpToString)) != NULL) {
|
||||
return(TRUE);
|
||||
}
|
||||
headerOffset--;
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
|
||||
//
|
||||
// Pull all fields out of the dialog and store in the class.
|
||||
//
|
||||
void
|
||||
FindDialog::getAllFields()
|
||||
{
|
||||
register unsigned int offset;
|
||||
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_fields[offset] != NULL) {
|
||||
_text_values[offset] = XmTextFieldGetString(_text_fields[offset]);
|
||||
|
||||
// Ignore zero length strings.
|
||||
if (_text_values[offset] != NULL) {
|
||||
if (strlen(_text_values[offset]) == 0) {
|
||||
_text_values[offset] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::textFieldCallback(
|
||||
Widget field,
|
||||
XtPointer data,
|
||||
XtPointer)
|
||||
{
|
||||
char *s;
|
||||
FindDialog *findData = (FindDialog *)data;
|
||||
|
||||
if (*(s = XmTextGetString(field)) == '\0') {
|
||||
// Empty field. Traverse
|
||||
(void) XmProcessTraversal(field, XmTRAVERSE_NEXT_TAB_GROUP);
|
||||
} else {
|
||||
// Field not empty. Do search
|
||||
findData->getAllFields();
|
||||
if (!findData->findMatching(False)) {
|
||||
XBell(XtDisplay(field), 0);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::directionCallback(Widget widget,
|
||||
XtPointer closure,
|
||||
XtPointer)
|
||||
{
|
||||
int which = (int) ((long) closure); // closure contains button #
|
||||
FindDialog *find;
|
||||
|
||||
// Client data is actually on the @!$?@* parent, not the toggle item
|
||||
XtVaGetValues(XtParent(widget), XmNuserData, &find, NULL);
|
||||
|
||||
if (which == 0) {
|
||||
find->setSearchForward(TRUE);
|
||||
} else {
|
||||
find->setSearchForward(False);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::findCallback(Widget /*button*/,
|
||||
XtPointer closure,
|
||||
XtPointer /*call_data*/)
|
||||
{
|
||||
FindDialog *findData = (FindDialog *)closure;
|
||||
|
||||
findData->getAllFields();
|
||||
findData->findMatching(False);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FindDialog::findSelectAllCallback(Widget /*button*/,
|
||||
XtPointer closure,
|
||||
XtPointer /*call_data*/)
|
||||
{
|
||||
FindDialog *findData = (FindDialog *)closure;
|
||||
|
||||
findData->getAllFields();
|
||||
findData->findMatching(TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::clearCallback(Widget /*button*/,
|
||||
XtPointer closure,
|
||||
XtPointer /*call_data*/)
|
||||
{
|
||||
FindDialog *findData = (FindDialog *)closure;
|
||||
register unsigned int offset;
|
||||
|
||||
for (offset = 0; offset < findData->_num_text_fields; offset++) {
|
||||
if (findData->_text_fields[offset] != NULL) {
|
||||
XmTextFieldSetString(findData->_text_fields[offset], "");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::closeCallback(Widget /*button*/,
|
||||
XtPointer closure,
|
||||
XtPointer /*call_data*/)
|
||||
{
|
||||
FindDialog *findData = (FindDialog *)closure;
|
||||
|
||||
findData->popdown();
|
||||
return;
|
||||
}
|
||||
134
cde/programs/dtmail/dtmail/FindDialog.h
Normal file
134
cde/programs/dtmail/dtmail/FindDialog.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: FindDialog.h /main/4 1996/04/21 19:42:01 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef FINDDIALOG_H
|
||||
#define FINDDIALOG_H
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include "Dialog.h"
|
||||
|
||||
//
|
||||
// This class is used for the 'Mailer - Find' dialog box.
|
||||
//
|
||||
class FindDialog : public Dialog {
|
||||
|
||||
public:
|
||||
FindDialog(RoamMenuWindow * parent);
|
||||
~FindDialog() { clear(); };
|
||||
|
||||
//
|
||||
// These come from 'Dialog'.
|
||||
//
|
||||
void popped_up() { };
|
||||
void popped_down() { };
|
||||
void popup() { XtPopup(_w, XtGrabNone); };
|
||||
void popdown() { XtPopdown(_w); };
|
||||
void widgetDestroyed() {};
|
||||
|
||||
// The set/clear status methods will set and clear the status line.
|
||||
//
|
||||
void setStatus(const char * str);
|
||||
void clearStatus(void);
|
||||
|
||||
Widget createWorkArea(Widget);
|
||||
|
||||
//
|
||||
// Like initialize() except returns success status.
|
||||
//
|
||||
Boolean startup();
|
||||
|
||||
//
|
||||
// Set the search direction for find.
|
||||
//
|
||||
void setSearchForward(Boolean forward) { // True == Forward, False = Backward.
|
||||
_searchForward = forward;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
struct ActionAreaItem {
|
||||
char * label; // Button label.
|
||||
XtCallbackProc callback;
|
||||
caddr_t data;
|
||||
};
|
||||
|
||||
//
|
||||
// Clear out the data. After this function is complete the
|
||||
// data should look as if the constructor was just called and
|
||||
// before initialize().
|
||||
//
|
||||
void clear();
|
||||
|
||||
Boolean findMatching(Boolean findAll = False);
|
||||
|
||||
Boolean compareMessage(DtMailMessageHandle handle);
|
||||
|
||||
Boolean compareHeader(DtMailEnv & error,
|
||||
DtMailValueSeq & seq,
|
||||
const char * cmpToString);
|
||||
|
||||
static void directionCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void findCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void findSelectAllCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void clearCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void closeCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void helpCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void textFieldCallback(Widget, XtPointer, XtPointer);
|
||||
|
||||
//
|
||||
// Pull all fields out of the dialog and store in _text_values;
|
||||
//
|
||||
void getAllFields();
|
||||
|
||||
unsigned int _num_text_fields; // Array size.
|
||||
|
||||
Widget _status_text;
|
||||
Widget * _text_fields;
|
||||
char ** _text_names;
|
||||
char ** _text_abstract_name;
|
||||
char ** _text_labels;
|
||||
char ** _text_values;
|
||||
|
||||
unsigned int _num_buttons; // Array size.
|
||||
ActionAreaItem * _buttonData;
|
||||
|
||||
Boolean _searchForward;
|
||||
RoamMenuWindow * _roamWindow;
|
||||
};
|
||||
|
||||
#endif
|
||||
204
cde/programs/dtmail/dtmail/Fonts.C
Normal file
204
cde/programs/dtmail/dtmail/Fonts.C
Normal file
@@ -0,0 +1,204 @@
|
||||
/* $TOG: Fonts.C /main/8 1997/09/04 08:06:26 mgreess $ */
|
||||
/*
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994 Novell, Inc.
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
*
|
||||
* This code was borrowed from dtcm (Calendar Manager).
|
||||
* Its purpose is to find a font in a particular family that is
|
||||
* the same size as the user font being used.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/AtomMgr.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "Fonts.h"
|
||||
|
||||
|
||||
/*
|
||||
* Walk a font_list looking for a FontSet with the
|
||||
* XmFONTLIST_DEFAULT_TAG set. If we fail to find a FontSet with this tag,
|
||||
* return the first FontSet found. If we fail to find a FontSet return
|
||||
* the first font found.
|
||||
*
|
||||
* This function returns either a XFontStruct or a XFontSet. The type can
|
||||
* be determined by the value of type_return which will equal either
|
||||
* XmFONT_IS_FONTSET or XmFONT_IS_FONT.
|
||||
*
|
||||
* The XFontStruct or XFontSet that is returned is not a copy and should
|
||||
* not be freed.
|
||||
*/
|
||||
static XtPointer
|
||||
get_font(
|
||||
XmFontList font_list,
|
||||
XmFontType *type_return)
|
||||
{
|
||||
XmFontContext fl_context;
|
||||
XmFontListEntry fl_entry;
|
||||
XtPointer fl_entry_font = NULL, font_to_use = NULL;
|
||||
char *fl_entry_font_tag;
|
||||
Boolean found_font_set = False,
|
||||
found_font_struct = False,
|
||||
do_break = False;
|
||||
|
||||
*type_return = XmFONT_IS_FONT;
|
||||
|
||||
if (!XmFontListInitFontContext(&fl_context, font_list))
|
||||
return (XtPointer)NULL;
|
||||
|
||||
do
|
||||
{
|
||||
fl_entry = XmFontListNextEntry(fl_context);
|
||||
if (fl_entry)
|
||||
{
|
||||
fl_entry_font = XmFontListEntryGetFont(fl_entry, type_return);
|
||||
if (*type_return == XmFONT_IS_FONTSET)
|
||||
{
|
||||
fl_entry_font_tag = XmFontListEntryGetTag(fl_entry);
|
||||
|
||||
/*
|
||||
* Save the first font set found in-
|
||||
* case the default tag is not set.
|
||||
*/
|
||||
if (!found_font_set)
|
||||
{
|
||||
font_to_use = fl_entry_font;
|
||||
found_font_set = True;
|
||||
found_font_struct = True;
|
||||
|
||||
if (!strcmp(XmFONTLIST_DEFAULT_TAG, fl_entry_font_tag))
|
||||
do_break = True;
|
||||
}
|
||||
else if (!strcmp(XmFONTLIST_DEFAULT_TAG, fl_entry_font_tag))
|
||||
{
|
||||
/* Found right font set */
|
||||
font_to_use = fl_entry_font;
|
||||
do_break = True;
|
||||
}
|
||||
|
||||
if (fl_entry_font_tag != NULL)
|
||||
XtFree((char*) fl_entry_font_tag);
|
||||
|
||||
if (do_break)
|
||||
break;
|
||||
}
|
||||
else if (!found_font_struct)
|
||||
{
|
||||
font_to_use = fl_entry_font;
|
||||
found_font_struct = True;
|
||||
}
|
||||
}
|
||||
} while (fl_entry != NULL);
|
||||
|
||||
XmFontListFreeFontContext(fl_context);
|
||||
|
||||
if (!found_font_set && !found_font_struct)
|
||||
return (XtPointer)NULL;
|
||||
|
||||
return (XtPointer)font_to_use;
|
||||
}
|
||||
|
||||
/*
|
||||
* Strip the font out of a give fontlist.
|
||||
*/
|
||||
Boolean
|
||||
fontlist_to_font(
|
||||
XmFontList font_list,
|
||||
FontType *new_font)
|
||||
{
|
||||
XmFontType type_return;
|
||||
XtPointer font_data;
|
||||
|
||||
if (!font_list) return False;
|
||||
|
||||
font_data = get_font(font_list, &type_return);
|
||||
|
||||
if (!font_data)
|
||||
return False;
|
||||
|
||||
new_font->cf_type = type_return;
|
||||
|
||||
if (type_return == XmFONT_IS_FONTSET)
|
||||
new_font->f.cf_fontset = (XFontSet)font_data;
|
||||
else
|
||||
new_font->f.cf_font = (XFontStruct *)font_data;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the pixel size of the user font. Try to match a symbol
|
||||
* font to that size. If one can't be found, return NULL, calling
|
||||
* function will probably default to the user font.
|
||||
*/
|
||||
void
|
||||
load_app_font(
|
||||
Widget w,
|
||||
FontType *userfont,
|
||||
char **fontname)
|
||||
{
|
||||
unsigned long pixel_size;
|
||||
Display *dpy = XtDisplay(w);
|
||||
char font_name[128],
|
||||
*font_name_ptr = font_name,
|
||||
**font_names;
|
||||
int nnames;
|
||||
Atom pixel_atom = XmInternAtom(dpy, "PIXEL_SIZE", FALSE);
|
||||
|
||||
/* First get the pixel size from the User Font */
|
||||
if (userfont->cf_type == XmFONT_IS_FONT) {
|
||||
/* If we can't get the pixel size from the user font we
|
||||
* default to a 12 pixel font.
|
||||
*/
|
||||
if (!XGetFontProperty(userfont->f.cf_font, pixel_atom,
|
||||
&pixel_size))
|
||||
pixel_size = 12;
|
||||
} else {
|
||||
XFontStruct **font_struct_list;
|
||||
char **font_name_list;
|
||||
int list_size;
|
||||
|
||||
if (!(list_size = XFontsOfFontSet(userfont->f.cf_fontset,
|
||||
&font_struct_list,
|
||||
&font_name_list))) {
|
||||
pixel_size = 12;
|
||||
} else {
|
||||
if (!XGetFontProperty(font_struct_list[0],
|
||||
pixel_atom,
|
||||
&pixel_size))
|
||||
pixel_size = 12;
|
||||
}
|
||||
}
|
||||
|
||||
/* See if the font exists */
|
||||
sprintf (font_name,
|
||||
"-dt-application-medium-r-normal--%ld-*-*-*-*-*-dtsymbol-*",
|
||||
pixel_size);
|
||||
font_names = XListFonts(dpy, font_name, 1, &nnames);
|
||||
|
||||
if (!nnames) {
|
||||
/* Try again */
|
||||
sprintf (font_name,
|
||||
"-*-symbol-medium-r-normal--%ld-*-*-*-*-*", pixel_size);
|
||||
font_names = XListFonts(dpy, font_name, 1, &nnames);
|
||||
}
|
||||
if (!nnames) {
|
||||
/* Try again with the default size */
|
||||
pixel_size = 12;
|
||||
sprintf (font_name,
|
||||
"-dt-application-medium-r-normal--%ld-*-*-*-*-*-dtsymbol-*",
|
||||
pixel_size);
|
||||
font_names = XListFonts(dpy, font_name, 1, &nnames);
|
||||
}
|
||||
if (!nnames) {
|
||||
*fontname = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
XFreeFontNames(font_names);
|
||||
*fontname = XtNewString (font_name);
|
||||
}
|
||||
|
||||
31
cde/programs/dtmail/dtmail/Fonts.h
Normal file
31
cde/programs/dtmail/dtmail/Fonts.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* $XConsortium: Fonts.h /main/3 1996/04/21 19:52:59 drk $ */
|
||||
/*
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994 Novell, Inc.
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef FONTS_H
|
||||
#define FONTS_H
|
||||
|
||||
typedef struct _FontType {
|
||||
XmFontType cf_type;
|
||||
union {
|
||||
XFontStruct *cf_font;
|
||||
XFontSet cf_fontset;
|
||||
} f;
|
||||
} FontType;
|
||||
|
||||
extern Boolean
|
||||
fontlist_to_font(
|
||||
XmFontList font_list,
|
||||
FontType *new_font);
|
||||
|
||||
extern void
|
||||
load_app_font(
|
||||
Widget w,
|
||||
FontType *userfont,
|
||||
char **fontname);
|
||||
|
||||
#endif /* FONTS_H */
|
||||
328
cde/programs/dtmail/dtmail/Icon.C
Normal file
328
cde/programs/dtmail/dtmail/Icon.C
Normal file
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Icon.C /main/8 1998/10/27 19:42:30 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_CB_REASON
|
||||
#define PRINTCB(str) printf("%s\n",str)
|
||||
#else
|
||||
#define PRINTCB(str)
|
||||
#endif
|
||||
|
||||
#include <Dt/Dnd.h>
|
||||
#include "Icon.h"
|
||||
#include "RoamApp.h"
|
||||
#include "DtMailEditor.hh"
|
||||
#include "Editor.hh"
|
||||
#include <Dt/Editor.h>
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/StringDefs.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <Xm/ColorObjP.h>
|
||||
|
||||
Icon::Icon (
|
||||
Attachment *classparent,
|
||||
char *name,
|
||||
XmString label, /* label string */
|
||||
unsigned short /* type */,
|
||||
Widget parent,
|
||||
int indx
|
||||
) : UIComponent (name)
|
||||
{
|
||||
#define MAX_NUM_COLORS 8
|
||||
DtMail::BodyPart *bp;
|
||||
DtMailEnv mail_error;
|
||||
char *type = NULL, *icon_name = NULL;
|
||||
char *icon_filename = NULL, *host_prefix = NULL;
|
||||
int n = 0;
|
||||
Arg args[20];
|
||||
int btn1_transfer = 0;
|
||||
int colorUse;
|
||||
short act, inact, prim, second, text;
|
||||
XmPixelSet pixels[XmCO_NUM_COLORS];
|
||||
|
||||
_parent = classparent;
|
||||
_indx = indx;
|
||||
_is_selected = FALSE;
|
||||
_is_armed = FALSE;
|
||||
|
||||
// Get the pixmap image file name for this attachment.
|
||||
bp = _parent->getBodyPart();
|
||||
bp->getContents(mail_error, NULL, NULL, &type, NULL, NULL, NULL);
|
||||
|
||||
// Retrieve the host name.
|
||||
host_prefix = DtDtsDataTypeToAttributeValue(type,
|
||||
DtDTS_DA_DATA_HOST,
|
||||
NULL);
|
||||
|
||||
// Get the name of the icon.
|
||||
icon_name = (char *) DtDtsDataTypeToAttributeValue(type,
|
||||
DtDTS_DA_ICON,
|
||||
NULL);
|
||||
// Retrieve icon file name
|
||||
icon_filename = XmGetIconFileName(XtScreen(parent),
|
||||
NULL,
|
||||
icon_name,
|
||||
host_prefix,
|
||||
DtMEDIUM);
|
||||
|
||||
// Get pixel data.
|
||||
XmeGetColorObjData(XtScreen(parent), &colorUse, pixels, XmCO_NUM_COLORS,
|
||||
&act, &inact, &prim, &second, &text);
|
||||
_cur_fg = pixels[text].fg;
|
||||
_cur_bg = pixels[text].sc;
|
||||
|
||||
n = 0;
|
||||
XtSetArg (args[n], XmNshadowThickness, 0); n++;
|
||||
XtSetArg (args[n], XmNfillOnArm, FALSE); n++;
|
||||
XtSetArg (args[n], XmNhighlightThickness, 2); n++;
|
||||
XtSetArg (args[n], XmNimageName, icon_filename); n++;
|
||||
XtSetArg (args[n], XmNstring, label); n++;
|
||||
XtSetArg( args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
|
||||
XtSetArg( args[n], XmNpixmapPosition, XmPIXMAP_TOP); n++;
|
||||
XtSetArg( args[n], XmNbehavior, XmICON_DRAG); n++;
|
||||
XtSetArg( args[n], XmNfillMode, XmFILL_PARENT); n++;
|
||||
XtSetArg( args[n], XmNbackground, _cur_bg); n++;
|
||||
XtSetArg( args[n], XmNforeground, _cur_fg); n++;
|
||||
|
||||
_w = _DtCreateIcon(parent,"iconGadget", args,n);
|
||||
|
||||
XtAddEventHandler(XtParent(_w), Button1MotionMask, FALSE,
|
||||
(XtEventHandler)&Icon::dragMotionHandler,
|
||||
(XtPointer)this);
|
||||
|
||||
XtVaGetValues((Widget)XmGetXmDisplay(XtDisplay(XtParent(_w))),
|
||||
"enableBtn1Transfer", &btn1_transfer,
|
||||
NULL);
|
||||
|
||||
if (btn1_transfer != True) {
|
||||
XtAddEventHandler(XtParent(_w), Button2MotionMask, FALSE,
|
||||
(XtEventHandler)&Icon::dragMotionHandler,
|
||||
(XtPointer)this);
|
||||
}
|
||||
|
||||
XtAddCallback(
|
||||
_w,
|
||||
XmNcallback,
|
||||
(XtCallbackProc)&Icon::iconCallback,
|
||||
(XtPointer)this
|
||||
);
|
||||
|
||||
if (type) {
|
||||
free(type);
|
||||
type = NULL;
|
||||
}
|
||||
|
||||
if (host_prefix) {
|
||||
DtDtsFreeAttributeValue(host_prefix);
|
||||
host_prefix = NULL;
|
||||
}
|
||||
if (icon_name) {
|
||||
DtDtsFreeAttributeValue(icon_name);
|
||||
icon_name = NULL;
|
||||
}
|
||||
if (icon_filename) {
|
||||
XtFree(icon_filename);
|
||||
icon_filename = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Icon::~Icon()
|
||||
{
|
||||
int btn1_transfer = 0;
|
||||
|
||||
XtRemoveCallback(
|
||||
_w,
|
||||
XmNcallback,
|
||||
(XtCallbackProc)&Icon::iconCallback,
|
||||
(XtPointer)this
|
||||
);
|
||||
XtRemoveEventHandler(XtParent(_w), Button1MotionMask, FALSE,
|
||||
(XtEventHandler)&Icon::dragMotionHandler,
|
||||
(XtPointer)this);
|
||||
|
||||
XtVaGetValues((Widget)XmGetXmDisplay(XtDisplay(XtParent(_w))),
|
||||
"enableBtn1Transfer", &btn1_transfer,
|
||||
NULL);
|
||||
|
||||
if (btn1_transfer != True) {
|
||||
XtRemoveEventHandler(XtParent(_w), Button2MotionMask, FALSE,
|
||||
(XtEventHandler)&Icon::dragMotionHandler,
|
||||
(XtPointer)this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Icon::iconCallback(Widget , XtPointer client_data, XtPointer call_data)
|
||||
{
|
||||
DtIconCallbackStruct *cb = (DtIconCallbackStruct *)call_data;
|
||||
Icon *obj = (Icon *)client_data;
|
||||
XEvent *event;
|
||||
|
||||
if ((event = cb->event) != (XEvent *) NULL) {
|
||||
/*
|
||||
* The following seems rather bogus.... to make assumptions
|
||||
* about the context of a ButtonPress before decoding
|
||||
* the reason for the callback.
|
||||
*/
|
||||
if ((event->type == ButtonPress) &&
|
||||
(! IsModifierKey(XLookupKeysym((XKeyEvent *) event, 0)))) {
|
||||
if (event->xbutton.state & ControlMask)
|
||||
{
|
||||
/* Cntrl Button press processing*/
|
||||
// Need to handle it. Postponed...
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch(cb->reason) {
|
||||
case XmCR_UNHIGHLIGHT:
|
||||
PRINTCB("unhighlight");
|
||||
break;
|
||||
case XmCR_HIGHLIGHT:
|
||||
PRINTCB("highlight");
|
||||
break;
|
||||
case XmCR_ACTIVATE:
|
||||
PRINTCB("activate");
|
||||
break;
|
||||
case XmCR_DISARM:
|
||||
obj->disarm();
|
||||
PRINTCB("disarm");
|
||||
break;
|
||||
case XmCR_ARM:
|
||||
obj->arm();
|
||||
PRINTCB("arm");
|
||||
break;
|
||||
case XmCR_SELECT:
|
||||
PRINTCB("select");
|
||||
obj->select();
|
||||
break;
|
||||
case XmCR_DEFAULT_ACTION:
|
||||
PRINTCB("default_action");
|
||||
obj->defaultAction();
|
||||
break;
|
||||
case XmCR_DRAG:
|
||||
PRINTCB("drag");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Icon::dragMotionHandler(
|
||||
Widget widget,
|
||||
XtPointer clientData,
|
||||
XEvent *event)
|
||||
{
|
||||
Icon *icon = (Icon *) clientData;
|
||||
|
||||
icon->parent()->parent()->owner()->attachDragMotionHandler(widget, event);
|
||||
}
|
||||
|
||||
void
|
||||
Icon::invert()
|
||||
{
|
||||
Arg args[2];
|
||||
int n;
|
||||
Pixel swap;
|
||||
|
||||
n = 0;
|
||||
XtSetArg( args[n], XmNbackground, _cur_fg); n++;
|
||||
XtSetArg( args[n], XmNforeground, _cur_bg); n++;
|
||||
XtSetValues(_w, args, n);
|
||||
|
||||
swap = _cur_fg;
|
||||
_cur_fg = _cur_bg;
|
||||
_cur_bg = swap;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Icon::arm()
|
||||
{
|
||||
// deselect others in all cases
|
||||
_parent->set_selected();
|
||||
|
||||
if(_is_armed == TRUE)
|
||||
return;
|
||||
|
||||
_is_selected = TRUE;
|
||||
|
||||
invert();
|
||||
|
||||
_is_armed = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
Icon::disarm()
|
||||
{
|
||||
if(_is_armed == FALSE || _is_selected == TRUE )
|
||||
return;
|
||||
|
||||
invert();
|
||||
|
||||
_is_armed = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
Icon::unselect()
|
||||
{
|
||||
if(_is_selected == FALSE)
|
||||
return;
|
||||
|
||||
_is_selected = FALSE;
|
||||
|
||||
disarm();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Icon::primitiveSelect()
|
||||
{
|
||||
if(_is_selected == TRUE || _is_armed == TRUE)
|
||||
return;
|
||||
|
||||
_is_selected = TRUE;
|
||||
|
||||
invert();
|
||||
|
||||
_is_armed = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
Icon::select()
|
||||
{
|
||||
if(_is_selected == TRUE)
|
||||
return;
|
||||
|
||||
arm();
|
||||
}
|
||||
|
||||
void
|
||||
Icon::defaultAction()
|
||||
{
|
||||
select();
|
||||
_parent->handleDoubleClick();
|
||||
}
|
||||
70
cde/programs/dtmail/dtmail/Icon.h
Normal file
70
cde/programs/dtmail/dtmail/Icon.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Icon.h /main/6 1998/01/16 11:21:49 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef ICON_H
|
||||
#define ICON_H
|
||||
|
||||
#include "UIComponent.h"
|
||||
#include "Attachment.h"
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
#include <Dt/Dts.h>
|
||||
#include <Dt/IconFile.h>
|
||||
extern "C" {
|
||||
#include <Dt/Icon.h>
|
||||
}
|
||||
|
||||
class Icon : public UIComponent {
|
||||
private:
|
||||
Boolean _is_selected;
|
||||
Boolean _is_armed;
|
||||
Pixel _cur_fg, _cur_bg;
|
||||
void invert(void);
|
||||
void arm(void);
|
||||
void disarm(void);
|
||||
int _indx; /* user data */
|
||||
static void dragMotionHandler(Widget, XtPointer, XEvent*);
|
||||
static void iconCallback(Widget, XtPointer, XtPointer);
|
||||
protected:
|
||||
Attachment *_parent; // associated attachemnt
|
||||
|
||||
public:
|
||||
// Constructor and destructor
|
||||
Icon (Attachment*, char*, XmString label, unsigned short, Widget, int);
|
||||
virtual ~Icon();
|
||||
|
||||
// AV callback methods
|
||||
void select(void);
|
||||
void primitiveSelect(void);
|
||||
void defaultAction(void);
|
||||
void unselect();
|
||||
|
||||
// associated attachment
|
||||
Attachment* parent() { return ( _parent ); }
|
||||
virtual const char *const className() { return ( "Icon" ); }
|
||||
|
||||
// static functions
|
||||
static int maxIconWidth() { return 38; }
|
||||
static int maxIconHeight() { return 38; }
|
||||
};
|
||||
#endif
|
||||
346
cde/programs/dtmail/dtmail/IgnoreListUiItem.C
Normal file
346
cde/programs/dtmail/dtmail/IgnoreListUiItem.C
Normal file
@@ -0,0 +1,346 @@
|
||||
/* $TOG: IgnoreListUiItem.C /main/4 1997/09/03 17:38:42 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: IgnoreListUiItem.C /main/4 1997/09/03 17:38:42 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/List.h>
|
||||
#include <Xm/TextF.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include "options_ui.h"
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
#include <DtMail/IgnoreListUiItem.hh>
|
||||
|
||||
void handleIgnoreSelection(Widget w, XtPointer clientdata, XtPointer calldata);
|
||||
extern Boolean props_changed;
|
||||
|
||||
// IgnoreListUiItem::IgnoreListUiItem
|
||||
// IgnoreListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
IgnoreListUiItem::IgnoreListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
Widget text_entry_widget):ListUiItem(w, source, search_key, NULL)
|
||||
{
|
||||
source = source; search_key = search_key;
|
||||
|
||||
entry_field_widget = text_entry_widget;
|
||||
|
||||
list_items = NULL;
|
||||
deleted_items = NULL;
|
||||
|
||||
XtVaSetValues(w,
|
||||
XmNuserData, this,
|
||||
XmNautomaticSelection, True,
|
||||
XmNselectionPolicy, XmBROWSE_SELECT,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(w,
|
||||
XmNbrowseSelectionCallback,
|
||||
(XtCallbackProc)handleIgnoreSelection,
|
||||
(XtPointer)this);
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
void handleIgnoreSelection(Widget w, XtPointer, XtPointer calldata)
|
||||
{
|
||||
IgnoreListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
// motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getEntryFieldWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// IgnoreListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::writeFromUiToSource()
|
||||
{
|
||||
Widget w = this->getWidget();
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
int i, num_items;
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
num_items = deleted_items->length();
|
||||
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->removeIgnore(error,(*deleted_items)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
num_items = list_items->length();
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->addIgnore(error,(*list_items)[i]->label);
|
||||
}
|
||||
}
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// IgnoreListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
DtVirtArray<char *> *char_list = NULL;
|
||||
int list_len, i;
|
||||
PropStringPair *new_pair;
|
||||
|
||||
Widget w = this->getWidget();
|
||||
|
||||
XmListDeleteAllItems(w);
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
delete list_items;
|
||||
list_items=NULL;
|
||||
}
|
||||
|
||||
// ignore list code here...
|
||||
char_list = mail_rc->getIgnoreList();
|
||||
|
||||
if(char_list != NULL)
|
||||
{
|
||||
list_len = char_list->length();
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
for(i = 0; i < list_len; i++)
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
new_pair->label = strdup((*char_list)[i]);
|
||||
new_pair->value = NULL;
|
||||
|
||||
list_items->append(new_pair);
|
||||
}
|
||||
}
|
||||
|
||||
options_list_init(w, char_list);
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::handleAddButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if( (strlen(test_str) > 1) &&
|
||||
(!XmListItemExists(this->getWidget(),
|
||||
XmStringCreateLocalized(test_str))) )
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
new_pair->label = strdup(test_str);
|
||||
new_pair->value = NULL;
|
||||
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
pos_list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,0);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
1);
|
||||
XmListSelectPos(this->getWidget(),
|
||||
1,
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
1);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::handleChangeButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
XmString replace_string;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
// if nothing selected nothing to change...
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if(strlen(test_str) > 1)
|
||||
{
|
||||
|
||||
new_pair = (*list_items)[pos_list[0] - 1];
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[pos_list[0] -1]->label));
|
||||
|
||||
free(new_pair->label);
|
||||
new_pair->label = strdup(test_str);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
replace_string = XmStringCreateLocalized(new_pair->label);
|
||||
|
||||
XmListReplaceItemsPos(this->getWidget(),
|
||||
&replace_string,
|
||||
1,
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::handleDeleteButtonPress()
|
||||
{
|
||||
Widget list_widget = this->getWidget();
|
||||
int *p_list, p_count;
|
||||
|
||||
// get the selected position
|
||||
if(XmListGetSelectedPos(list_widget,
|
||||
&p_list,
|
||||
&p_count))
|
||||
{
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[p_list[0] -1]->label));
|
||||
|
||||
// delete the item from our list
|
||||
this->list_items->remove(p_list[0] - 1); // remove only first
|
||||
|
||||
// delete the item from the widget
|
||||
XmListDeletePos(list_widget, p_list[0]);
|
||||
|
||||
XtVaSetValues(this->getEntryFieldWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
XmListSelectPos(list_widget,
|
||||
p_list[0],
|
||||
TRUE);
|
||||
props_changed = TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
void IgnoreListUiItem::AddDefaults()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
DtVirtArray<char *> *char_list = NULL;
|
||||
int list_len;
|
||||
|
||||
// ignore list code here...
|
||||
char_list = mail_rc->getIgnoreList();
|
||||
|
||||
list_len = char_list->length();
|
||||
if(list_len == 0)
|
||||
{
|
||||
XmTextFieldSetString(entry_field_widget,"Received");
|
||||
handleAddButtonPress();
|
||||
XmTextFieldSetString(entry_field_widget,"");
|
||||
mail_rc->addIgnore(error,"Received");
|
||||
mail_rc->update(error);
|
||||
}
|
||||
}
|
||||
|
||||
71
cde/programs/dtmail/dtmail/Image.C
Normal file
71
cde/programs/dtmail/dtmail/Image.C
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Image.C /main/4 1996/04/21 19:42:11 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
|
||||
#include "Image.h"
|
||||
#include "stdlib.h"
|
||||
Image::Image( Widget w, char *filename )
|
||||
{
|
||||
GC gc;
|
||||
Pixmap bitmap,pixmap;
|
||||
int xhot,yhot;
|
||||
XGCValues values;
|
||||
Display *display=XtDisplay( w );
|
||||
|
||||
_filename=strdup(filename);
|
||||
|
||||
|
||||
|
||||
XReadBitmapFile( display,
|
||||
RootWindowOfScreen(XtScreen(w)),
|
||||
_filename,
|
||||
&_width,
|
||||
&_height,
|
||||
&bitmap,
|
||||
&xhot,
|
||||
&yhot );
|
||||
|
||||
pixmap = XCreatePixmap( display,
|
||||
RootWindowOfScreen( XtScreen(w) ),
|
||||
_width,
|
||||
_height,
|
||||
DefaultDepthOfScreen( XtScreen(w) ));
|
||||
|
||||
// XtVaGetValues( w,
|
||||
// XtNfontColor, &values.foreground,
|
||||
// XtNbackground, &values.background,
|
||||
// NULL );
|
||||
|
||||
gc = XtGetGC( w, GCForeground | GCBackground, &values );
|
||||
|
||||
XCopyPlane( display, bitmap, pixmap, gc, 0, 0, _width, _height, 0 ,0 ,1 );
|
||||
_image = XGetImage( display, pixmap,
|
||||
0, 0,
|
||||
_width, _height,
|
||||
AllPlanes, ZPixmap );
|
||||
|
||||
}
|
||||
|
||||
Image::~Image(){
|
||||
free ( _filename );
|
||||
}
|
||||
|
||||
#endif /* DEAD_WOOD */
|
||||
39
cde/programs/dtmail/dtmail/Image.h
Normal file
39
cde/programs/dtmail/dtmail/Image.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Image.h /main/4 1996/04/21 19:42:14 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef IMAGE_H
|
||||
#define IMAGE_H
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/StringDefs.h>
|
||||
|
||||
|
||||
class Image {
|
||||
private:
|
||||
XImage *_image;
|
||||
unsigned int _width,_height;
|
||||
char *_filename;
|
||||
public:
|
||||
Image( Widget, char * );
|
||||
~Image();
|
||||
XImage *image() { return _image; }
|
||||
};
|
||||
|
||||
#endif
|
||||
126
cde/programs/dtmail/dtmail/Imakefile
Normal file
126
cde/programs/dtmail/dtmail/Imakefile
Normal file
@@ -0,0 +1,126 @@
|
||||
XCOMM $TOG: Imakefile /main/25 1998/02/17 15:18:16 mgreess $
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
EXTRA_LOAD_FLAGS = ExtraLoadFlags $(UNSHARED_CXXLIB)
|
||||
|
||||
INCLUDES = -I. -I../include -I../include/MotifApp \
|
||||
-I../include/utils -I../include/DtMail \
|
||||
-I../libDtMail/RFC -I$(CDELIBSRC) -I$(DTHELPSRC)
|
||||
|
||||
#ifndef DtMailDefines
|
||||
# define DtMailDefines
|
||||
#endif
|
||||
DEFINES = -DRELEASE_NOTES -DDTMAIL_TOOLTALK -DDTEDITOR DtMailDefines
|
||||
|
||||
DEPLIBS = ../MotifApp/libMotifApp.a ../libDtMail/libDtMail.a DepDtClientLibs
|
||||
LOCAL_LIBRARIES = ../libDtMail/libDtMail.a ../MotifApp/libMotifApp.a DtClientLibs
|
||||
|
||||
/* Sun needs the widechar library */
|
||||
#ifdef SunArchitecture
|
||||
SYS_LIBRARIES = $(DYNLIBSYSLIB) $(ICONVSYSLIB) $(REGEXSYSLIB) -lw -lm
|
||||
#else
|
||||
SYS_LIBRARIES = $(DYNLIBSYSLIB) $(ICONVSYSLIB) $(REGEXSYSLIB) -lm
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SunArchitecture
|
||||
# ifndef SUNPRODIR
|
||||
SUNPRO_DIR = /opt/SUNWspro
|
||||
# else
|
||||
SUNPRO_DIR = SUNPRODIR
|
||||
# endif
|
||||
|
||||
C++LIBPATH = -L$(SUNPRO_DIR)/lib
|
||||
|
||||
# ifdef USE_SPRO_V3
|
||||
SPRO_V3_OPTIONS = -noex -USPRO_V2
|
||||
# ifdef DEBUGTREE
|
||||
SPRO_V3_OPTIONS += -xsb
|
||||
# endif /* DEBUGTREE */
|
||||
# else
|
||||
EXTRA_CCOPTIONS += -DSPRO_V2
|
||||
# endif /* USE_SPRO_V3 */
|
||||
|
||||
EXTRA_C++OPTIONS = -xF +w $(SPRO_V3_OPTIONS)
|
||||
EXTRA_CCOPTIONS = -xF -xstrconst -Xa -v
|
||||
|
||||
# ifdef USE_EDITRES
|
||||
EXTRA_LIBRARIES = $(XMULIB) ExtraLibraries
|
||||
# endif
|
||||
#endif /* SunArchitecture */
|
||||
|
||||
SRCS = AliasListUiItem.C AlternatesListUiItem.C \
|
||||
AntiCheckBoxUiItem.C AttachArea.C \
|
||||
Attachment.C \
|
||||
CheckBoxUiItem.C CheckForMailUiItem.C \
|
||||
ComposeCmds.C CustomListUiItem.C \
|
||||
Dialog.C DialogShell.C \
|
||||
DmxMailbox.C DmxMessage.C \
|
||||
DmxPrintJob.C DmxPrintOptions.C \
|
||||
DmxPrintOutput.C DmxPrintSetup.C \
|
||||
DmxUtils.C DtEditor.C \
|
||||
DtMailEditor.C DtMailGenDialog.C \
|
||||
DtMailWDM.C Editor.C \
|
||||
EncryptedTextFieldUiItem.C FindDialog.C \
|
||||
Fonts.C Icon.C \
|
||||
IgnoreListUiItem.C Image.C \
|
||||
InboxTextFieldUiItem.C IndexedOptionMenu.C \
|
||||
IndexedOptionMenuUiItem.C ListUiItem.C \
|
||||
MailRcSource.C MailRetrievalOptions.C \
|
||||
MailSession.C \
|
||||
MoveMenuListUiItem.C MsgHndArray.C \
|
||||
MsgScrollingList.C NoOpCmd.C \
|
||||
OptCmd.C PasswordDialogManager.C \
|
||||
PropUi.C QueryDialogManager.C \
|
||||
RoamApp.C RoamCmds.C \
|
||||
RoamInterruptibleCmd.C RoamMenuWindow.C \
|
||||
ScaleUiItem.C SendMsgDialog.C \
|
||||
Sort.C SortCmd.C \
|
||||
SpinBoxUiItem.C StringTab.c \
|
||||
TemplateListUiItem.C TextFieldUiItem.C \
|
||||
Undelete.C ViewMsgDialog.C \
|
||||
WMSaveSession.C XmStrCollector.C \
|
||||
XmTextEditor.C XtArgCollector.C \
|
||||
dtb_utils.C options_stubs.C \
|
||||
options_ui.C options_util.C
|
||||
|
||||
OBJS = AliasListUiItem.o AlternatesListUiItem.o \
|
||||
AntiCheckBoxUiItem.o AttachArea.o \
|
||||
Attachment.o \
|
||||
CheckBoxUiItem.o CheckForMailUiItem.o \
|
||||
ComposeCmds.o CustomListUiItem.o \
|
||||
Dialog.o DialogShell.o \
|
||||
DmxMailbox.o DmxMessage.o \
|
||||
DmxPrintJob.o DmxPrintOptions.o \
|
||||
DmxPrintOutput.o DmxPrintSetup.o \
|
||||
DmxUtils.o DtEditor.o \
|
||||
DtMailEditor.o DtMailGenDialog.o \
|
||||
DtMailWDM.o Editor.o \
|
||||
EncryptedTextFieldUiItem.o FindDialog.o \
|
||||
Fonts.o Icon.o \
|
||||
IgnoreListUiItem.o Image.o \
|
||||
InboxTextFieldUiItem.o IndexedOptionMenu.o \
|
||||
IndexedOptionMenuUiItem.o ListUiItem.o \
|
||||
MailRcSource.o MailRetrievalOptions.o \
|
||||
MailSession.o \
|
||||
MoveMenuListUiItem.o MsgHndArray.o \
|
||||
MsgScrollingList.o NoOpCmd.o \
|
||||
OptCmd.o PasswordDialogManager.o \
|
||||
PropUi.o QueryDialogManager.o \
|
||||
RoamApp.o RoamCmds.o \
|
||||
RoamInterruptibleCmd.o RoamMenuWindow.o \
|
||||
ScaleUiItem.o SendMsgDialog.o \
|
||||
Sort.o SortCmd.o \
|
||||
SpinBoxUiItem.o StringTab.o \
|
||||
TemplateListUiItem.o TextFieldUiItem.o \
|
||||
Undelete.o ViewMsgDialog.o \
|
||||
WMSaveSession.o XmStrCollector.o \
|
||||
XmTextEditor.o XtArgCollector.o \
|
||||
dtb_utils.o options_stubs.o \
|
||||
options_ui.o options_util.o
|
||||
|
||||
# Rules
|
||||
NormalCplusplusObjectRule()
|
||||
|
||||
ComplexCplusplusProgramTarget(dtmail)
|
||||
97
cde/programs/dtmail/dtmail/InboxTextFieldUiItem.C
Normal file
97
cde/programs/dtmail/dtmail/InboxTextFieldUiItem.C
Normal file
@@ -0,0 +1,97 @@
|
||||
/* $TOG: InboxTextFieldUiItem.C /main/1 1998/02/17 12:35:07 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/InboxTextFieldUiItem.hh>
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include "MailSession.hh"
|
||||
#include "RoamApp.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
InboxTextFieldUiItem::InboxTextFieldUiItem(
|
||||
Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
PropUiCallback validator,
|
||||
void * validator_data)
|
||||
: PropUiItem(w, source, search_key, validator, validator_data)
|
||||
{
|
||||
options_field_init(w, &(this->dirty_bit));
|
||||
}
|
||||
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void InboxTextFieldUiItem::writeFromUiToSource()
|
||||
{
|
||||
char *mailspool_file = NULL;
|
||||
char *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
MailSession *ses = theRoamApp.session();
|
||||
DtMail::Session *d_session = ses->session();
|
||||
DtMailObjectSpace space;
|
||||
DtMailEnv error;
|
||||
DtMailEnv mail_error;
|
||||
|
||||
d_session->queryImpl(error,
|
||||
d_session->getDefaultImpl(mail_error),
|
||||
DtMailCapabilityMailspoolName,
|
||||
&space,
|
||||
&mailspool_file);
|
||||
value = options_field_get_value(w);
|
||||
|
||||
if (0 == strcmp(value, mailspool_file))
|
||||
prop_source->setValue("MAILSPOOL_FILE");
|
||||
else
|
||||
prop_source->setValue(value);
|
||||
|
||||
if (NULL != mailspool_file) free((void*) mailspool_file);
|
||||
}
|
||||
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void InboxTextFieldUiItem::writeFromSourceToUi()
|
||||
{
|
||||
char *mailspool_file = NULL;
|
||||
char *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
MailSession *ses = theRoamApp.session();
|
||||
DtMail::Session *d_session = ses->session();
|
||||
DtMailObjectSpace space;
|
||||
DtMailEnv error;
|
||||
DtMailEnv mail_error;
|
||||
|
||||
d_session->queryImpl(error,
|
||||
d_session->getDefaultImpl(mail_error),
|
||||
DtMailCapabilityMailspoolName,
|
||||
&space,
|
||||
&mailspool_file);
|
||||
value = (char *)prop_source->getValue();
|
||||
|
||||
if (0 == strcmp(value, "MAILSPOOL_FILE"))
|
||||
options_field_set_value(w, mailspool_file, this->dirty_bit);
|
||||
else
|
||||
options_field_set_value(w, value, this->dirty_bit);
|
||||
|
||||
if (NULL != value) free((void*) value);
|
||||
if (NULL != mailspool_file) free((void*) mailspool_file);
|
||||
}
|
||||
253
cde/programs/dtmail/dtmail/IndexedOptionMenu.C
Normal file
253
cde/programs/dtmail/dtmail/IndexedOptionMenu.C
Normal file
@@ -0,0 +1,253 @@
|
||||
/* $TOG: IndexedOptionMenu.C /main/3 1997/11/21 18:42:21 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
|
||||
#include "Dmx.h"
|
||||
#include "IndexedOptionMenu.h"
|
||||
#include "MailMsg.h"
|
||||
#include "dtmailopts.h"
|
||||
|
||||
IndexedOptionMenu::IndexedOptionMenu (
|
||||
Widget parent,
|
||||
int nmenu_items,
|
||||
char **strings,
|
||||
void **data
|
||||
) : UIComponent( "IndexedOptionMenu" )
|
||||
{
|
||||
int nargs;
|
||||
Arg args[8];
|
||||
Widget menu;
|
||||
XmString xms;
|
||||
|
||||
_nmenu_items = nmenu_items;
|
||||
if (nmenu_items && strings != NULL)
|
||||
{
|
||||
_strings = (char **) XtMalloc(nmenu_items * sizeof(char*));
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_strings[i] = strings[i];
|
||||
}
|
||||
if (nmenu_items && data != NULL)
|
||||
{
|
||||
_data = (void **) XtMalloc(nmenu_items * sizeof(void*));
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_data[i] = data[i];
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the pulldown menu for the option menus,
|
||||
* and populate it with pushbuttons.
|
||||
* Attach the original strings used to generate
|
||||
* the button labels to the buttons as userData.
|
||||
*/
|
||||
menu = XmCreatePulldownMenu(parent, "Menu", NULL, 0);
|
||||
_buttons = (Widget *) XtMalloc( _nmenu_items * sizeof(Widget) );
|
||||
for (int i=0; i<_nmenu_items; i++)
|
||||
{
|
||||
static char button_label[32];
|
||||
|
||||
sprintf(button_label, "Button%d", i);
|
||||
_buttons[i] = XmCreatePushButton(menu, button_label, NULL, 0);
|
||||
xms = XmStringCreateLocalized(_strings[i]);
|
||||
XtVaSetValues(
|
||||
_buttons[i],
|
||||
XmNuserData, i,
|
||||
XmNlabelString, xms,
|
||||
NULL);
|
||||
XmStringFree(xms);
|
||||
XtManageChild(_buttons[i]);
|
||||
}
|
||||
|
||||
nargs=0;
|
||||
XtSetArg(args[nargs], XmNsubMenuId, menu); nargs++;
|
||||
_w = XmCreateOptionMenu(parent, "IndexedOptionMenu", args, nargs);
|
||||
installDestroyHandler();
|
||||
|
||||
//XtRealizeWidget(_w);
|
||||
}
|
||||
|
||||
IndexedOptionMenu::IndexedOptionMenu (
|
||||
Widget option_menu,
|
||||
int nmenu_items,
|
||||
char **strings,
|
||||
void **data,
|
||||
Widget *buttons
|
||||
) : UIComponent( "IndexedOptionMenu" )
|
||||
{
|
||||
_w = option_menu;
|
||||
installDestroyHandler();
|
||||
_nmenu_items = nmenu_items;
|
||||
_strings = NULL;
|
||||
_data = NULL;
|
||||
_buttons = NULL;
|
||||
|
||||
if (nmenu_items && strings != NULL)
|
||||
{
|
||||
_strings = (char **) XtMalloc(nmenu_items * sizeof(char*));
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_strings[i] = strings[i];
|
||||
}
|
||||
if (nmenu_items && data != NULL)
|
||||
{
|
||||
_data = (void **) XtMalloc(nmenu_items * sizeof(void*));
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_data[i] = data[i];
|
||||
}
|
||||
if (nmenu_items && buttons != NULL)
|
||||
{
|
||||
_buttons = (Widget *) XtMalloc( _nmenu_items * sizeof(Widget) );
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_buttons[i] = buttons[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IndexedOptionMenu::~IndexedOptionMenu (void)
|
||||
{
|
||||
if (_w != NULL)
|
||||
XtDestroyWidget(_w);
|
||||
if (_buttons)
|
||||
XtFree((char *) _buttons);
|
||||
if (_strings)
|
||||
XtFree((char *) _strings);
|
||||
if (_data)
|
||||
XtFree((char *) _data);
|
||||
}
|
||||
|
||||
void
|
||||
IndexedOptionMenu::addMenuButtonCallback(
|
||||
char* callback_name,
|
||||
XtCallbackProc callback,
|
||||
XtPointer client_data)
|
||||
{
|
||||
for (int i=0; i<_nmenu_items; i++)
|
||||
XtAddCallback(_buttons[i], callback_name, callback, client_data);
|
||||
}
|
||||
|
||||
void*
|
||||
IndexedOptionMenu::getDataSpec (void)
|
||||
{
|
||||
int index = getIndexSpec();
|
||||
return _data[index];
|
||||
}
|
||||
|
||||
int
|
||||
IndexedOptionMenu::getIndexSpec (void)
|
||||
{
|
||||
int data = 0;
|
||||
|
||||
if (_w)
|
||||
{
|
||||
Widget selected;
|
||||
XtVaGetValues(_w, XmNmenuHistory, &selected, NULL);
|
||||
XtVaGetValues(selected, XmNuserData, &data, NULL);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
char*
|
||||
IndexedOptionMenu::getStringSpec(void)
|
||||
{
|
||||
int index = getIndexSpec();
|
||||
return _strings[index];
|
||||
}
|
||||
|
||||
void
|
||||
IndexedOptionMenu::setSpec (int spec)
|
||||
{
|
||||
XtVaSetValues(_w, XmNmenuHistory, _buttons[spec], NULL );
|
||||
}
|
||||
|
||||
void
|
||||
IndexedOptionMenu::setSpec (const char *string)
|
||||
{
|
||||
int spec = stringToIndex(string);
|
||||
if (spec >= _nmenu_items) return;
|
||||
setSpec(spec);
|
||||
}
|
||||
|
||||
void
|
||||
IndexedOptionMenu::setSpec (void *data)
|
||||
{
|
||||
int spec = dataToIndex(data);
|
||||
if (spec >= _nmenu_items) return;
|
||||
setSpec(spec);
|
||||
}
|
||||
|
||||
int
|
||||
IndexedOptionMenu::dataToIndex (void *data)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index=0; index<_nmenu_items; index++)
|
||||
if (! strncmp((char*) _data[index], (char*) data, strlen((char*) data)))
|
||||
return index;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
int
|
||||
IndexedOptionMenu::stringToIndex (const char *string)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index=0; index<_nmenu_items; index++)
|
||||
if (! strncmp(_strings[index], string, strlen(string)) )
|
||||
return index;
|
||||
|
||||
return index;
|
||||
}
|
||||
85
cde/programs/dtmail/dtmail/IndexedOptionMenu.h
Normal file
85
cde/programs/dtmail/dtmail/IndexedOptionMenu.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* $XConsortium: IndexedOptionMenu.h /main/2 1996/10/02 11:47:36 mgreess $ */
|
||||
|
||||
#ifndef _INDEXED_OPTION_MENU
|
||||
#define _INDEXED_OPTION_MENU
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "UIComponent.h"
|
||||
|
||||
class IndexedOptionMenu : public UIComponent
|
||||
{
|
||||
public:
|
||||
|
||||
IndexedOptionMenu ( Widget, int, char**, void** );
|
||||
IndexedOptionMenu ( Widget, int, char**, void**, Widget* );
|
||||
~IndexedOptionMenu (void);
|
||||
|
||||
void addMenuButtonCallback(char*, XtCallbackProc, XtPointer);
|
||||
int getIndexSpec();
|
||||
char *getStringSpec();
|
||||
void *getDataSpec();
|
||||
void setSpec(int);
|
||||
void setSpec(const char*);
|
||||
void setSpec(void*);
|
||||
|
||||
private:
|
||||
int dataToIndex(void*);
|
||||
int stringToIndex(const char*);
|
||||
|
||||
int _nmenu_items;
|
||||
char **_strings;
|
||||
void **_data;
|
||||
Widget *_buttons;
|
||||
};
|
||||
|
||||
#endif // _INDEXED_OPTION_MENU
|
||||
113
cde/programs/dtmail/dtmail/IndexedOptionMenuUiItem.C
Normal file
113
cde/programs/dtmail/dtmail/IndexedOptionMenuUiItem.C
Normal file
@@ -0,0 +1,113 @@
|
||||
/* $TOG: IndexedOptionMenuUiItem.C /main/4 1997/11/21 17:19:04 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/IndexedOptionMenuUiItem.hh>
|
||||
|
||||
extern Boolean props_changed;
|
||||
|
||||
// IndexedOptionMenuUiItem::IndexedOptionMenuUiItem
|
||||
// IndexedOptionMenuUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
IndexedOptionMenuUiItem::IndexedOptionMenuUiItem(
|
||||
IndexedOptionMenu *iom,
|
||||
int source,
|
||||
char *search_key
|
||||
) : PropUiItem(iom->baseWidget(), source, search_key)
|
||||
{
|
||||
_iom = iom;
|
||||
_iom->addMenuButtonCallback(
|
||||
XmNactivateCallback,
|
||||
IndexedOptionMenuUiItem::valueChangedCB,
|
||||
(XtPointer) this);
|
||||
}
|
||||
|
||||
// IndexedOptionMenuUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IndexedOptionMenuUiItem::writeFromUiToSource()
|
||||
{
|
||||
char *value;
|
||||
Widget w;
|
||||
|
||||
w = this->getWidget();
|
||||
value = (char*) _iom->getDataSpec();
|
||||
prop_source->setValue(value);
|
||||
}
|
||||
|
||||
// IndexedOptionMenuUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IndexedOptionMenuUiItem::writeFromSourceToUi()
|
||||
{
|
||||
const char *value;
|
||||
|
||||
value = (char *)prop_source->getValue();
|
||||
_iom->setSpec((void*) value);
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
}
|
||||
|
||||
// IndexedOptionMenuUiItem::valueChangedCB()
|
||||
// Marks the item as having its value changed.
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IndexedOptionMenuUiItem::valueChangedCB(
|
||||
Widget,
|
||||
XtPointer clientdata,
|
||||
XtPointer
|
||||
)
|
||||
{
|
||||
IndexedOptionMenuUiItem *thisIomui;
|
||||
|
||||
thisIomui = (IndexedOptionMenuUiItem *) clientdata;
|
||||
thisIomui->dirty_bit = TRUE;
|
||||
props_changed = TRUE;
|
||||
}
|
||||
|
||||
76
cde/programs/dtmail/dtmail/ListUiItem.C
Normal file
76
cde/programs/dtmail/dtmail/ListUiItem.C
Normal file
@@ -0,0 +1,76 @@
|
||||
/* $TOG: ListUiItem.C /main/4 1997/04/29 16:23:46 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
|
||||
// ListUiItem::ListUiItem
|
||||
// ListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
ListUiItem::ListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
DtVirtArray<char *> *alias_list
|
||||
):PropUiItem(w, source, search_key)
|
||||
{
|
||||
#ifdef DEAD_WOOD
|
||||
data_source = source;
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
if(alias_list != NULL)
|
||||
options_list_init(w, alias_list);
|
||||
|
||||
}
|
||||
|
||||
// ListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void ListUiItem::writeFromUiToSource()
|
||||
{
|
||||
// char *textfield_value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
// textfield_value = options_field_get_value(w);
|
||||
|
||||
// prop_source->setValue(textfield_value);
|
||||
}
|
||||
|
||||
// ListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void ListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
// char *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
// value = (char *)prop_source->getValue();
|
||||
|
||||
// options_field_set_value(w, value, this->dirty_bit);
|
||||
|
||||
}
|
||||
void ListUiItem::AddDefaults()
|
||||
{
|
||||
// wrapper
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
80
cde/programs/dtmail/dtmail/MailMsg.h
Normal file
80
cde/programs/dtmail/dtmail/MailMsg.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: MailMsg.h /main/5 1998/04/22 14:17:19 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef MAILMSG_H
|
||||
#define MAILMSG_H
|
||||
|
||||
#include <nl_types.h>
|
||||
#include <Dt/MsgCatP.h>
|
||||
|
||||
/*
|
||||
* DtMail comment tag is NL_COMMENT (NL = National Language).
|
||||
* genmsg will extract comment blocks containing NL_COMMENT.
|
||||
*/
|
||||
|
||||
extern nl_catd DT_catd; /* Catgets file descriptor */
|
||||
|
||||
#define DTMAIL_CAT "DtMail"
|
||||
#define NL_SET 1
|
||||
#define BUTTON_SET 1
|
||||
#define TITLE_SET 1
|
||||
#define LABEL_SET 1
|
||||
#define DIALOG_SET 3
|
||||
#define MSG_SET 3
|
||||
#define ERR_SET 2
|
||||
|
||||
#ifdef XGETTEXT
|
||||
#define MAILMSG(msgid, str) dgettext(NL_SET, msgid, str)
|
||||
#else
|
||||
#define MAILMSG(msgid, str) catgets(DT_catd, NL_SET, msgid, str)
|
||||
#endif
|
||||
|
||||
#ifdef hpV4
|
||||
#define GETMSG(DT_catd, NL_SET, msgid, str) _DtCatgetsCached(DT_catd, NL_SET, msgid, str)
|
||||
#else
|
||||
#define GETMSG(DT_catd, NL_SET, msgid, str) catgets(DT_catd, NL_SET, msgid, str)
|
||||
#endif
|
||||
|
||||
|
||||
/* MailBox.C msgid 100 - 199
|
||||
* MBOX_*
|
||||
*/
|
||||
|
||||
/* MsgScrollingList.C msgid 200 - 299
|
||||
* MSGLIST_*
|
||||
*/
|
||||
|
||||
/* RoamCmds.C msgid 300 - 399
|
||||
* ROCMD_*
|
||||
*/
|
||||
|
||||
/* RoamMenuWindow.C msgid 400 - 499
|
||||
* ROMENU_*
|
||||
*/
|
||||
|
||||
/* SendMsgDialog.C msgid 500 - 599
|
||||
* SEND_*
|
||||
*/
|
||||
|
||||
/* Undelete.C msgid 600 - 699
|
||||
* UNDEL_*
|
||||
*/
|
||||
|
||||
#endif // MAILMSG_H
|
||||
155
cde/programs/dtmail/dtmail/MailRcSource.C
Normal file
155
cde/programs/dtmail/dtmail/MailRcSource.C
Normal file
@@ -0,0 +1,155 @@
|
||||
/* $TOG: MailRcSource.C /main/13 1999/03/25 13:41:38 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <EUSCompat.h>
|
||||
#include <DtMail/PropSource.hh>
|
||||
#include <DtMail/DtMailTypes.h>
|
||||
#include <DtMail/DtVirtArray.hh>
|
||||
#include "str_utils.h"
|
||||
|
||||
#include "DmxPrintOptions.h"
|
||||
|
||||
static PropDefaults static_defaults[] ={
|
||||
{ "retrieveinterval", "300" },
|
||||
{ "bell", "1" },
|
||||
{ "flash", "0" },
|
||||
{ "headerlines", "15" },
|
||||
{ "showto", "f" },
|
||||
{ "showmsgnum", "f" },
|
||||
{ "popuplines", "24" },
|
||||
{ "toolcols", "80" },
|
||||
{ "indentprefix", ">" },
|
||||
{ "hideattachments", "f" },
|
||||
{ "folder", "~" },
|
||||
{ "filefolder", "~" },
|
||||
{ "dontunifyselection", "f" },
|
||||
{ "dontunifyfileselection", "f" },
|
||||
{ "confirmattachments", "f" },
|
||||
{ "confirmattachmentthreshold", "64" },
|
||||
{ "cachedfilemenusize", "10" },
|
||||
{ "dontdisplaycachedfiles", "f" },
|
||||
{ "record", "" },
|
||||
{ "dontlogmessages", "f" },
|
||||
{ "keepdeleted", "f" },
|
||||
{ "quietdelete", "f" },
|
||||
{ "expert", "f" },
|
||||
{ "strictmime", "f" },
|
||||
{ "cdetooltalklock", "f" },
|
||||
{ "allnet", "f" },
|
||||
{ "metoo", "f" },
|
||||
{ "usealternates", "f" },
|
||||
{ "deaddir", "~/dead_letter" },
|
||||
{ "saveinterval", "30" },
|
||||
{ DMX_PROPKEY_HEADER_LEFT, DMX_PROPVAL_SUBJECT_HEADER },
|
||||
{ DMX_PROPKEY_HEADER_RIGHT, DMX_PROPVAL_EMPTY },
|
||||
{ DMX_PROPKEY_FOOTER_LEFT, DMX_PROPVAL_USER_NAME },
|
||||
{ DMX_PROPKEY_FOOTER_RIGHT, DMX_PROPVAL_PAGE_NUMBER },
|
||||
{ DMX_PROPKEY_MARGIN_TOP, DMX_PROPVAL_DFLT_MARGIN },
|
||||
{ DMX_PROPKEY_MARGIN_RIGHT, DMX_PROPVAL_DFLT_MARGIN },
|
||||
{ DMX_PROPKEY_MARGIN_BOTTOM, DMX_PROPVAL_DFLT_MARGIN },
|
||||
{ DMX_PROPKEY_MARGIN_LEFT, DMX_PROPVAL_DFLT_MARGIN },
|
||||
{ DMX_PROPKEY_PRINT_HEADERS, DMX_PROPVAL_STANDARD },
|
||||
{ DMX_PROPKEY_MESSAGE_SEPARATOR,DMX_PROPVAL_PAGE_BREAK },
|
||||
{ DMX_PROPKEY_SEPARATOR_STRING, "-" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
DtVirtArray<PropDefaults*> *PropSource::_dynamic_defaults =
|
||||
new DtVirtArray<PropDefaults*> (20);
|
||||
|
||||
PropSource::PropSource(DtMail::MailRc *m_rc, char *key)
|
||||
{
|
||||
_mail_rc = m_rc;
|
||||
_key = key;
|
||||
}
|
||||
|
||||
PropSource::~PropSource() {;}
|
||||
|
||||
void
|
||||
PropSource::setDefaultValue(char *key, char *value)
|
||||
{
|
||||
PropDefaults *df;
|
||||
|
||||
for (int i=0; i<_dynamic_defaults->length(); i++)
|
||||
{
|
||||
df = (PropDefaults*) (*_dynamic_defaults)[i];
|
||||
if (0 == strcmp(key, df->key))
|
||||
{
|
||||
if (NULL != df->value) free((void*) df->value);
|
||||
df->value = strdup(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
df = (PropDefaults*) malloc(sizeof(PropDefaults));
|
||||
df->key = strdup(key);
|
||||
df->value = strdup(value);
|
||||
_dynamic_defaults->append(df);
|
||||
}
|
||||
|
||||
const char *
|
||||
PropSource::getDefaultValue(void)
|
||||
{
|
||||
PropDefaults *df;
|
||||
|
||||
for (int i=0; i<_dynamic_defaults->length(); i++)
|
||||
{
|
||||
df = (PropDefaults*) (*_dynamic_defaults)[i];
|
||||
if (0 == strcmp(_key, df->key)) return strdup(df->value);
|
||||
}
|
||||
|
||||
for (df=static_defaults; df->key; df++)
|
||||
if (strcasecmp(_key, df->key) == 0) return strdup(df->value);
|
||||
|
||||
return strdup(PropSourceDEFAULTVALUE);
|
||||
}
|
||||
|
||||
// MailRcSource::getValue
|
||||
// gets the value from the mailrc hash table and returns it
|
||||
/////////////////////////////////////////////////////////////////
|
||||
const char *MailRcSource::getValue(DtMailBoolean decrypt)
|
||||
{
|
||||
const char *value = NULL;
|
||||
DtMailEnv error;
|
||||
|
||||
_mail_rc->getValue(error, _key , &value, decrypt);
|
||||
|
||||
if (value == NULL || error.isSet())
|
||||
{
|
||||
value = getDefaultValue();
|
||||
return value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// MailRcSource::setValue
|
||||
// Sets the passed value into the mailrc hash tables
|
||||
/////////////////////////////////////////////////////////////////
|
||||
void MailRcSource::setValue(char *value, DtMailBoolean encrypt)
|
||||
{
|
||||
DtMailEnv error;
|
||||
|
||||
const char * d_value = getDefaultValue();
|
||||
|
||||
if (strcmp(d_value, value))
|
||||
_mail_rc->setValue(error, _key , value, encrypt);
|
||||
else
|
||||
_mail_rc->removeValue(error, _key);
|
||||
}
|
||||
1007
cde/programs/dtmail/dtmail/MailRetrievalOptions.C
Normal file
1007
cde/programs/dtmail/dtmail/MailRetrievalOptions.C
Normal file
File diff suppressed because it is too large
Load Diff
139
cde/programs/dtmail/dtmail/MailRetrievalOptions.h
Normal file
139
cde/programs/dtmail/dtmail/MailRetrievalOptions.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/* $TOG: MailRetrievalOptions.h /main/3 1998/02/17 12:35:42 mgreess $ */
|
||||
|
||||
#ifndef _MAIL_RETRIEVAL_OPTIONS_H
|
||||
#define _MAIL_RETRIEVAL_OPTIONS_H
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <DtMail/EncryptedTextFieldUiItem.hh>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/DtMailServer.hh>
|
||||
#include <DtMail/DtVirtArray.hh>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include "UIComponent.h"
|
||||
#include "IndexedOptionMenu.h"
|
||||
|
||||
struct MrPropVal
|
||||
{
|
||||
char *prop_value_string;
|
||||
int set_id;
|
||||
int msg_id;
|
||||
char *dflt_gui_string;
|
||||
};
|
||||
|
||||
class MailRetrievalOptions : public UIComponent
|
||||
{
|
||||
|
||||
private:
|
||||
char *_foldername;
|
||||
DtVirtArray<PropUiItem *>
|
||||
*_propui_array;
|
||||
int _propui_array_iterator;
|
||||
EncryptedTextFieldUiItem
|
||||
*_password_pui;
|
||||
DtVirtArray<Widget> *_retrieval_tbs;
|
||||
|
||||
Widget _parent;
|
||||
Widget _form;
|
||||
|
||||
Widget _inboxpath_label;
|
||||
Widget _inboxpath_tf;
|
||||
Widget _checkfornewmail_label;
|
||||
Widget _checkfornewmail_sb;
|
||||
|
||||
Widget _system_tb;
|
||||
|
||||
DtVirtArray<Widget> *_server_options;
|
||||
Widget _server_frame;
|
||||
Widget _server_tb;
|
||||
Widget _serverframe_form;
|
||||
Widget _serverprotocol_label;
|
||||
IndexedOptionMenu *_serverprotocol_iom;
|
||||
Widget _servername_label;
|
||||
Widget _servername_tf;
|
||||
Widget _username_label;
|
||||
Widget _username_tf;
|
||||
Widget _password_label;
|
||||
Widget _password_tf;
|
||||
Widget _rememberpassword_tb;
|
||||
Widget _removeafterdelivery_tb;
|
||||
Widget _retrieveold_tb;
|
||||
|
||||
DtVirtArray<Widget> *_custom_options;
|
||||
Widget _custom_frame;
|
||||
Widget _custom_tb;
|
||||
Widget _customframe_form;
|
||||
Widget _customcommand_label;
|
||||
Widget _customcommand_tf;
|
||||
|
||||
static void rememberPasswordChangedCB(Widget,XtPointer,XtPointer);
|
||||
static void retrievalTBSValueChangedCB(Widget,XtPointer,XtPointer);
|
||||
|
||||
public:
|
||||
|
||||
MailRetrievalOptions(Widget, const char *foldername = NULL);
|
||||
~MailRetrievalOptions(void);
|
||||
|
||||
PropUiItem *getFirstProp(void);
|
||||
PropUiItem *getNextProp(void);
|
||||
int getNumProps(void);
|
||||
void initOptionInteractions(void);
|
||||
static char *isValidInboxPath(PropUiItem* pui, void* data);
|
||||
static char *getPassword(char *foldername);
|
||||
};
|
||||
|
||||
#endif // _MAIL_RETRIEVAL_OPTIONS_H
|
||||
345
cde/programs/dtmail/dtmail/MailSession.C
Normal file
345
cde/programs/dtmail/dtmail/MailSession.C
Normal file
@@ -0,0 +1,345 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: MailSession.C /main/9 1999/03/26 16:51:51 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include <DtMail/DtMailXtProc.h>
|
||||
#include <DtMail/IO.hh>
|
||||
|
||||
#include "MailSession.hh"
|
||||
#include "MemUtils.hh"
|
||||
#include "RoamMenuWindow.h"
|
||||
|
||||
DtMail::Session * MailSession::_app_session = NULL;
|
||||
int MailSession::_num_deactivated = 0;
|
||||
|
||||
MailSession::MailSession(DtMailEnv & error, XtAppContext context)
|
||||
: _open_mailboxes(128)
|
||||
{
|
||||
error.clear();
|
||||
|
||||
if (_app_session) {
|
||||
error.setError(DTME_ObjectInUse);
|
||||
return;
|
||||
}
|
||||
|
||||
_app_session = new DtMail::Session(error, "dtmail");
|
||||
if (error.isSet())
|
||||
{
|
||||
// Benign error
|
||||
if ((DTMailError_t)error == DTME_NoMsgCat) error.clear();
|
||||
|
||||
// Else need to translate the error into an DTME_* error
|
||||
// defined in DtMailError.hh
|
||||
}
|
||||
|
||||
XtAppAddInput(context,
|
||||
_app_session->eventFileDesc(error),
|
||||
(XtPointer)XtInputReadMask,
|
||||
DtMailXtInputProc,
|
||||
_app_session);
|
||||
|
||||
#if 0
|
||||
//
|
||||
// Used to be both XtInputReadMask and XtInputExceptMask
|
||||
// went to the same procedure. Resulted in problems in
|
||||
// when using R6 polling instead of R5 select. Now
|
||||
// use separate input handlers.
|
||||
//
|
||||
XtAppAddInput(context,
|
||||
_app_session->eventFileDesc(error),
|
||||
(XtPointer)XtInputExceptMask,
|
||||
DtMailXtExceptProc,
|
||||
_app_session);
|
||||
#endif
|
||||
|
||||
DtMailDamageContext = context;
|
||||
}
|
||||
|
||||
MailSession::~MailSession(void)
|
||||
{
|
||||
for (int mb = 0; mb < _open_mailboxes.length(); mb++)
|
||||
{
|
||||
delete _open_mailboxes[mb]->handle;
|
||||
delete _open_mailboxes[mb]->path;
|
||||
}
|
||||
|
||||
delete _app_session;
|
||||
}
|
||||
|
||||
Boolean
|
||||
MailSession::isMboxOpen(const char *path)
|
||||
{
|
||||
int pos = locate(path);
|
||||
if (pos >= 0) return (TRUE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
RoamMenuWindow *
|
||||
MailSession::getRMW(const char *path)
|
||||
{
|
||||
int slot = locate(path);
|
||||
if (slot >= 0)
|
||||
return(_open_mailboxes[slot]->rmw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RoamMenuWindow *
|
||||
MailSession::getRMW(DtMail::MailBox *mbox)
|
||||
{
|
||||
int slot = locate(mbox);
|
||||
return(_open_mailboxes[slot]->rmw);
|
||||
}
|
||||
|
||||
DtMail::MailBox *
|
||||
MailSession::open(
|
||||
DtMailEnv & error,
|
||||
const char * path,
|
||||
DtMailCallback cb_func,
|
||||
void * client_data,
|
||||
DtMailBoolean auto_create,
|
||||
DtMailBoolean request_lock,
|
||||
DtMailBoolean auto_parse)
|
||||
{
|
||||
// First, see if we have this open in this process.
|
||||
int slot = locate(path);
|
||||
|
||||
// We do not allow open an already opened mailbox
|
||||
// because this may cause memory fault when a message is
|
||||
// deleted from one RMW and the other RMW would like to
|
||||
// read the already deleted message.
|
||||
// (1) set error to DTME_AlreadyOpened
|
||||
// (2) Return a NULL
|
||||
if (slot >= 0)
|
||||
{
|
||||
error.setError(DTME_AlreadyOpened);
|
||||
if (client_data == NULL)
|
||||
{
|
||||
_open_mailboxes[slot]->open_ref_count += 1;
|
||||
return _open_mailboxes[slot]->handle;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
// Create a handle for determining what to do next. This will
|
||||
// add us to the file session so we will start getting call
|
||||
// back requests on this file.
|
||||
DtMail::MailBox * mailbox = _app_session->mailBoxConstruct(
|
||||
error, DtMailFileObject,
|
||||
(void *)path,
|
||||
cb_func, client_data);
|
||||
if (error.isSet())
|
||||
{
|
||||
error.setError(DTME_ObjectCreationFailed);
|
||||
delete mailbox;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Does this file exist? If it doesn't and create is
|
||||
// on then make one. If create is off, then raise an
|
||||
// error.
|
||||
mailbox->open(error,
|
||||
auto_create,
|
||||
DTMAIL_DEFAULT_OPEN_MODE,
|
||||
DTMAIL_DEFAULT_CREATE_MODE,
|
||||
request_lock,
|
||||
auto_parse);
|
||||
|
||||
// Need to translate from BE error to a FE error that the
|
||||
// user can understand. Opening a mail container can result
|
||||
// in a variety of errors. Translate those that are considered
|
||||
// to be relevant (for now) - the set can always be extended.
|
||||
// Toss others into an UnknownFormat error.
|
||||
if (error.isSet())
|
||||
{
|
||||
delete mailbox;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
addToList(mailbox, path, (RoamMenuWindow *) client_data);
|
||||
return mailbox;
|
||||
}
|
||||
|
||||
void
|
||||
MailSession::close(DtMailEnv & error, const DtMail::MailBox * mb)
|
||||
{
|
||||
// Find the mail box slot.
|
||||
int slot = locate(mb);
|
||||
if (slot < 0)
|
||||
{
|
||||
error.setError(DTME_ObjectInvalid);
|
||||
return;
|
||||
}
|
||||
|
||||
MailBoxItem * mbi = _open_mailboxes[slot];
|
||||
mbi->open_ref_count -= 1;
|
||||
if (mbi->open_ref_count <= 0)
|
||||
{
|
||||
if (! _open_mailboxes[slot]->is_active) _num_deactivated--;
|
||||
|
||||
delete mbi->handle;
|
||||
delete mbi->path;
|
||||
|
||||
_open_mailboxes.remove(slot);
|
||||
delete mbi;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MailSession::convert(
|
||||
DtMailEnv & error,
|
||||
const char *, // old_path
|
||||
const char *, // new_path
|
||||
DtMailStatusCallback, // cb_func
|
||||
void *) // client_data
|
||||
{
|
||||
error.clear();
|
||||
}
|
||||
|
||||
void
|
||||
MailSession::copy(
|
||||
DtMailEnv & error,
|
||||
DtMail::Message &, // msg
|
||||
const char *) // path
|
||||
{
|
||||
error.clear();
|
||||
}
|
||||
|
||||
int
|
||||
MailSession::locate(const char *path)
|
||||
{
|
||||
int slot;
|
||||
struct stat pathbuf;
|
||||
|
||||
SafeStat(path, &pathbuf);
|
||||
for (slot = 0; slot < _open_mailboxes.length(); slot++)
|
||||
{
|
||||
if (strcmp(_open_mailboxes[slot]->path, path) == 0)
|
||||
return slot;
|
||||
|
||||
if (! _open_mailboxes[slot]->stated)
|
||||
{
|
||||
_open_mailboxes[slot]->stated = TRUE;
|
||||
SafeStat(
|
||||
_open_mailboxes[slot]->path,
|
||||
&_open_mailboxes[slot]->statbuf);
|
||||
}
|
||||
|
||||
if (pathbuf.st_ino == _open_mailboxes[slot]->statbuf.st_ino &&
|
||||
pathbuf.st_dev == _open_mailboxes[slot]->statbuf.st_dev)
|
||||
return slot;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
MailSession::locate(const DtMail::MailBox *mb)
|
||||
{
|
||||
for (int slot = 0; slot < _open_mailboxes.length(); slot++)
|
||||
if (mb == _open_mailboxes[slot]->handle)
|
||||
return slot;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
MailSession::locate(const RoamMenuWindow *rmw)
|
||||
{
|
||||
for (int slot = 0; slot < _open_mailboxes.length(); slot++)
|
||||
if (rmw == _open_mailboxes[slot]->rmw)
|
||||
return slot;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
MailSession::isActiveRMW(RoamMenuWindow *rmw)
|
||||
{
|
||||
int slot = locate((const RoamMenuWindow *) rmw);
|
||||
if (slot < 0) return 0;
|
||||
|
||||
return _open_mailboxes[slot]->is_active;
|
||||
}
|
||||
|
||||
void
|
||||
MailSession::activateRMW(RoamMenuWindow *rmw)
|
||||
{
|
||||
int slot = locate((const RoamMenuWindow *) rmw);
|
||||
if (slot < 0) return;
|
||||
|
||||
if (! _open_mailboxes[slot]->is_active)
|
||||
{
|
||||
DtMail::MailBox *mailbox = rmw->mailbox();
|
||||
mailbox->enableMailRetrieval();
|
||||
|
||||
DtMailEnv mail_error;
|
||||
mail_error.clear();
|
||||
rmw->checkForMail(mail_error);
|
||||
|
||||
_open_mailboxes[slot]->is_active = TRUE;
|
||||
_num_deactivated--;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MailSession::deactivateRMW(RoamMenuWindow *rmw)
|
||||
{
|
||||
int slot = locate((const RoamMenuWindow *) rmw);
|
||||
if (slot < 0) return;
|
||||
|
||||
if (_open_mailboxes[slot]->is_active)
|
||||
{
|
||||
DtMail::MailBox *mailbox = rmw->mailbox();
|
||||
mailbox->disableMailRetrieval();
|
||||
|
||||
_open_mailboxes[slot]->is_active = FALSE;
|
||||
_num_deactivated++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MailSession::addToList(
|
||||
DtMail::MailBox *mb,
|
||||
const char *path,
|
||||
RoamMenuWindow *rmw)
|
||||
{
|
||||
MailBoxItem * mbi = new MailBoxItem;
|
||||
|
||||
mbi->handle = mb;
|
||||
mbi->is_active = TRUE;
|
||||
mbi->stated = FALSE;
|
||||
mbi->open_ref_count = 1;
|
||||
mbi->path = strdup_n(path);
|
||||
mbi->rmw = rmw;
|
||||
|
||||
_open_mailboxes.append(mbi);
|
||||
}
|
||||
|
||||
Tt_status
|
||||
MailSession::lockCB(Tt_message, Tttk_op, const char*, uid_t, int, void*)
|
||||
{
|
||||
// We never give up the lock during a copy!
|
||||
return TT_ERR_INVALID;
|
||||
}
|
||||
84
cde/programs/dtmail/dtmail/MailSession.hh
Normal file
84
cde/programs/dtmail/dtmail/MailSession.hh
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: MailSession.hh /main/8 1999/03/26 16:52:44 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef _MAILSESSION_HH
|
||||
#define _MAILSESSION_HH
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include "RoamMenuWindow.h"
|
||||
|
||||
class MailSession
|
||||
{
|
||||
public:
|
||||
MailSession(DtMailEnv &, XtAppContext);
|
||||
~MailSession(void);
|
||||
|
||||
// raises ME_NotBento, ME_AlreadyLocked, ME_OtherAssumedRole, ME_NoSuchFile
|
||||
DtMail::MailBox *open(DtMailEnv&, const char*, DtMailCallback, void*,
|
||||
DtMailBoolean auto_create = DTM_TRUE,
|
||||
DtMailBoolean request_lock = DTM_TRUE,
|
||||
DtMailBoolean auto_parse = DTM_TRUE);
|
||||
|
||||
void close(DtMailEnv&, const DtMail::MailBox*);
|
||||
|
||||
// raises ME_UnknownFormat
|
||||
void convert(DtMailEnv&, const char*, const char*,
|
||||
DtMailStatusCallback cb_func = NULL,
|
||||
void *client_data = NULL);
|
||||
|
||||
// raises ME_NotBento, ME_RequestDenied
|
||||
void copy(DtMailEnv&, DtMail::Message&, const char*);
|
||||
|
||||
int isActiveRMW(RoamMenuWindow*);
|
||||
void activateRMW(RoamMenuWindow*);
|
||||
void deactivateRMW(RoamMenuWindow*);
|
||||
RoamMenuWindow *getRMW(DtMail::MailBox* mbox);
|
||||
RoamMenuWindow *getRMW(const char* path);
|
||||
Boolean isMboxOpen(const char* path);
|
||||
int numDeactivatedRMW() { return _num_deactivated; }
|
||||
DtMail::Session *session(void) { return _app_session; }
|
||||
|
||||
private:
|
||||
struct MailBoxItem
|
||||
{
|
||||
DtMail::MailBox *handle;
|
||||
int stated;
|
||||
struct stat statbuf;
|
||||
int is_active;
|
||||
int open_ref_count;
|
||||
char *path;
|
||||
RoamMenuWindow *rmw;
|
||||
};
|
||||
DtVirtArray<MailBoxItem *> _open_mailboxes;
|
||||
static DtMail::Session *_app_session;
|
||||
static int _num_deactivated;
|
||||
|
||||
void addToList(DtMail::MailBox*, const char*, RoamMenuWindow*);
|
||||
int locate(const char * path);
|
||||
int locate(const DtMail::MailBox *);
|
||||
int locate(const RoamMenuWindow *);
|
||||
static Tt_status
|
||||
lockCB(Tt_message, Tttk_op, const char*, uid_t, int, void*);
|
||||
};
|
||||
|
||||
#endif
|
||||
0
cde/programs/dtmail/dtmail/Mapfile.SunOS.53.sparc
Normal file
0
cde/programs/dtmail/dtmail/Mapfile.SunOS.53.sparc
Normal file
0
cde/programs/dtmail/dtmail/Mapfile.SunOS.54.i386
Normal file
0
cde/programs/dtmail/dtmail/Mapfile.SunOS.54.i386
Normal file
347
cde/programs/dtmail/dtmail/MoveMenuListUiItem.C
Normal file
347
cde/programs/dtmail/dtmail/MoveMenuListUiItem.C
Normal file
@@ -0,0 +1,347 @@
|
||||
/* $TOG: MoveMenuListUiItem.C /main/5 1997/09/03 17:39:09 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: MoveMenuListUiItem.C /main/5 1997/09/03 17:39:09 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/List.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include "options_ui.h"
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
#include <DtMail/MoveMenuListUiItem.hh>
|
||||
|
||||
extern void handleIgnoreSelection(Widget, XtPointer, XtPointer );
|
||||
extern Boolean props_changed;
|
||||
|
||||
// MoveMenuListUiItem::MoveMenuListUiItem
|
||||
// MoveMenuListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
MoveMenuListUiItem::MoveMenuListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
Widget text_entry_widget):ListUiItem(w, source, search_key, NULL)
|
||||
{
|
||||
source = source; search_key = search_key;
|
||||
|
||||
entry_field_widget = text_entry_widget;
|
||||
|
||||
list_items = NULL;
|
||||
deleted_items = NULL;
|
||||
|
||||
XtVaSetValues(w,
|
||||
XmNuserData, this,
|
||||
XmNautomaticSelection, True,
|
||||
XmNselectionPolicy, XmBROWSE_SELECT,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(w,
|
||||
XmNbrowseSelectionCallback,
|
||||
(XtCallbackProc)handleMMSelection,
|
||||
(XtPointer)this);
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
void handleMMSelection(Widget w, XtPointer, XtPointer calldata)
|
||||
{
|
||||
MoveMenuListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
// motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getEntryFieldWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// MoveMenuListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void MoveMenuListUiItem::writeFromUiToSource()
|
||||
{
|
||||
Widget w = this->getWidget();
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
int i, num_items, total_len = 0;
|
||||
char *mm_str = NULL;
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
if(list_items->length() > 0)
|
||||
{
|
||||
num_items = list_items->length();
|
||||
|
||||
// calc mailrc strlen...
|
||||
total_len = 1; // add space for the terminator...
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
// strlen + space
|
||||
total_len = total_len + strlen((*list_items)[i]->label) + 1;
|
||||
}
|
||||
|
||||
mm_str = (char *)malloc(total_len);
|
||||
mm_str[0] = '\0';
|
||||
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
strcat(mm_str, (*list_items)[i]->label);
|
||||
strcat(mm_str, " ");
|
||||
}
|
||||
|
||||
mail_rc->setValue(error, "filemenu2", mm_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
mail_rc->removeValue(error, "filemenu2");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mail_rc->removeValue(error, "filemenu2");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MoveMenuListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void MoveMenuListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
Widget w = this->getWidget();
|
||||
const char *list_str = NULL;
|
||||
char *token, *buf = NULL;
|
||||
PropStringPair *new_pair;
|
||||
DtVirtArray<char *> *char_list = NULL;
|
||||
|
||||
XmListDeleteAllItems(w);
|
||||
|
||||
// set up move menu list
|
||||
mail_rc->getValue(error, "filemenu2", &list_str);
|
||||
|
||||
if (list_str == NULL) {
|
||||
list_str = strdup(" ");
|
||||
|
||||
// set list_items to NULL, otherwise the cancel and reset will not
|
||||
// work. The list_items will be showed up next time even the cancel
|
||||
// or reset button is pressed
|
||||
list_items = NULL ;
|
||||
|
||||
if ((buf = (char *) malloc(strlen(list_str) + 1)) == NULL)
|
||||
return;
|
||||
strcpy(buf, (char *)list_str);
|
||||
}
|
||||
else {
|
||||
char * expanded_str = d_session->expandPath(error, list_str);
|
||||
if ((buf = (char *) malloc(strlen(expanded_str) + 1)) == NULL) {
|
||||
free(expanded_str);
|
||||
return;
|
||||
}
|
||||
strcpy(buf, expanded_str);
|
||||
free(expanded_str);
|
||||
}
|
||||
|
||||
if((token = (char *) strtok(buf, " ")))
|
||||
{
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
char_list = new DtVirtArray<char *>(10);
|
||||
|
||||
new_pair = new PropStringPair;
|
||||
new_pair->label = strdup(token);
|
||||
new_pair->value = NULL;
|
||||
list_items->append(new_pair);
|
||||
|
||||
char_list->append(strdup(token));
|
||||
|
||||
while(token = (char *)strtok(NULL, " "))
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
new_pair->label = strdup(token);
|
||||
new_pair->value = NULL;
|
||||
list_items->append(new_pair);
|
||||
|
||||
char_list->append(strdup(token));
|
||||
}
|
||||
}
|
||||
|
||||
options_list_init(w, char_list);
|
||||
|
||||
delete char_list;
|
||||
|
||||
if(list_str != NULL)
|
||||
free((void*) list_str);
|
||||
|
||||
if(buf != NULL)
|
||||
free((void *)buf);
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
void MoveMenuListUiItem::handleAddButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if(strlen(test_str) > 0)
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
new_pair->label = strdup(test_str);
|
||||
new_pair->value = NULL;
|
||||
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
pos_list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,0);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
1);
|
||||
XmListSelectPos(this->getWidget(),
|
||||
1,
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
1);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void MoveMenuListUiItem::handleChangeButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
XmString replace_string;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
// if nothing selected nothing to change...
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if(strlen(test_str) > 0)
|
||||
{
|
||||
|
||||
new_pair = (*list_items)[pos_list[0] - 1];
|
||||
|
||||
free(new_pair->label);
|
||||
new_pair->label = strdup(test_str);
|
||||
|
||||
|
||||
// list_items->insert(new_pair,pos_list[0] - 1);
|
||||
replace_string = XmStringCreateLocalized(new_pair->label);
|
||||
|
||||
XmListReplaceItemsPos(this->getWidget(),
|
||||
&replace_string,
|
||||
1,
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void MoveMenuListUiItem::handleDeleteButtonPress()
|
||||
{
|
||||
Widget list_widget = this->getWidget();
|
||||
int *p_list, p_count;
|
||||
|
||||
// get the selected position
|
||||
if(XmListGetSelectedPos(list_widget,
|
||||
&p_list,
|
||||
&p_count))
|
||||
{
|
||||
|
||||
// delete the item from our list
|
||||
this->list_items->remove(p_list[0] - 1); // remove only first
|
||||
|
||||
// delete the item from the widget
|
||||
XmListDeletePos(list_widget, p_list[0]);
|
||||
|
||||
XtVaSetValues(this->getEntryFieldWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
XmListSelectPos(list_widget,
|
||||
p_list[0],
|
||||
TRUE);
|
||||
props_changed = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
224
cde/programs/dtmail/dtmail/MsgHndArray.C
Normal file
224
cde/programs/dtmail/dtmail/MsgHndArray.C
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: MsgHndArray.C /main/6 1998/09/02 15:54:28 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include "MsgHndArray.hh"
|
||||
#include "MemUtils.hh"
|
||||
|
||||
MsgStruct*
|
||||
MsgHndArray::at(int indx)
|
||||
{
|
||||
return(_contents[indx]);
|
||||
}
|
||||
|
||||
void
|
||||
MsgHndArray::clear()
|
||||
{
|
||||
memset(_contents, 0, sizeof(MsgStruct *)*_size);
|
||||
}
|
||||
|
||||
int
|
||||
MsgHndArray::length()
|
||||
{
|
||||
return(_length);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
MsgHndArray::indexof(MsgStruct *a_msg_struct)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
for (tmp = 0; tmp < _length; tmp++)
|
||||
{
|
||||
if ((_contents[tmp]->sessionNumber == a_msg_struct->sessionNumber) &&
|
||||
(_contents[tmp]->message_handle == a_msg_struct->message_handle))
|
||||
{
|
||||
return(tmp);
|
||||
}
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int
|
||||
MsgHndArray::indexof(DtMailMessageHandle a_message_handle)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
for (tmp = 0; tmp < _length; tmp++)
|
||||
{
|
||||
if (_contents[tmp]->message_handle == a_message_handle)
|
||||
{
|
||||
return(tmp);
|
||||
}
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void
|
||||
MsgHndArray::remove_entry(MsgStruct *ms)
|
||||
{
|
||||
for (int i=0; i<_length; i++)
|
||||
{
|
||||
if (ms == _contents[i])
|
||||
{
|
||||
remove_entry(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MsgHndArray::remove_entry(int position)
|
||||
{
|
||||
int i;
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS);
|
||||
|
||||
if ((position < 0) || (position >= _length)) return;
|
||||
|
||||
tmpMS = _contents[position];
|
||||
|
||||
for (i=position; i<(_length-1); i++)
|
||||
_contents[i] = _contents[i+1];
|
||||
|
||||
_contents[_length] = NULL;
|
||||
_length -= 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
MsgHndArray::insert(
|
||||
MsgStruct *a_msg_struct
|
||||
)
|
||||
{
|
||||
int i, j, orig_size, return_val;
|
||||
int sess_num;
|
||||
Boolean found;
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS1);
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS2);
|
||||
|
||||
found = FALSE;
|
||||
sess_num = a_msg_struct->sessionNumber;
|
||||
|
||||
for(i = 0; i < _length; i++) {
|
||||
tmpMS1 = _contents[i];
|
||||
if (tmpMS1->sessionNumber > sess_num) {
|
||||
_contents[i] = a_msg_struct;
|
||||
return_val = i;
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == TRUE) {
|
||||
_length++;
|
||||
|
||||
// If we hit size, then grow by 25% to allow more entries.
|
||||
// Zero out the added portion.
|
||||
|
||||
if (_length == _size) {
|
||||
orig_size = _size;
|
||||
_size += (_size >> 2);
|
||||
_contents = (MsgStruct **)realloc(_contents,
|
||||
_size * sizeof(MsgStruct *));
|
||||
memset(_contents+orig_size, 0, sizeof(MsgStruct *)*_size);
|
||||
}
|
||||
|
||||
for (j = i + 1; j < _length; j++) {
|
||||
tmpMS2 = _contents[j];
|
||||
_contents[j] = tmpMS1;
|
||||
tmpMS1 = tmpMS2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_contents[_length] = a_msg_struct;
|
||||
return_val = _length;
|
||||
_length++;
|
||||
}
|
||||
return(return_val);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MsgHndArray::append(
|
||||
MsgStruct *a_msg_struct
|
||||
)
|
||||
|
||||
{
|
||||
|
||||
_contents[_length] = a_msg_struct;
|
||||
_length++;
|
||||
|
||||
// If we hit size, then grow by 25% to allow more entries.
|
||||
|
||||
if (_length == _size) {
|
||||
_size += (_size >> 2);
|
||||
_contents = (MsgStruct **)realloc(_contents,
|
||||
_size * sizeof(MsgStruct *));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MsgHndArray::mark_for_delete(int indx)
|
||||
{
|
||||
_contents[indx]->is_deleted = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
MsgHndArray::compact(
|
||||
int start_pos
|
||||
)
|
||||
{
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS);
|
||||
int i;
|
||||
|
||||
if ((_length <= 0) || (start_pos < 0) || (start_pos >= _length))
|
||||
return;
|
||||
|
||||
for (i = _length - 1; i >= start_pos; i--) {
|
||||
tmpMS = _contents[i];
|
||||
if (tmpMS->is_deleted) {
|
||||
tmpMS->is_deleted = FALSE;
|
||||
remove_entry(i);
|
||||
compact(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Replace the MsgStruct at 'position' with the passed MsgStruct.
|
||||
// The MsgStruct previously located at 'position' is *not* destroyed.
|
||||
//
|
||||
void
|
||||
MsgHndArray::replace(
|
||||
int position,
|
||||
MsgStruct *a_msg_struct
|
||||
)
|
||||
{
|
||||
if (position < 0 || position >= _length) {
|
||||
return;
|
||||
}
|
||||
|
||||
_contents[position] = a_msg_struct;
|
||||
|
||||
return;
|
||||
}
|
||||
88
cde/programs/dtmail/dtmail/MsgHndArray.hh
Normal file
88
cde/programs/dtmail/dtmail/MsgHndArray.hh
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: MsgHndArray.hh /main/9 1998/09/02 15:54:58 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef _MSGHNDARRAY_HH
|
||||
#define _MSGHNDARRAY_HH
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined(USL) && (OSMAJORVERSION == 2)
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <malloc.h>
|
||||
#if defined(USL) && (OSMAJORVERSION == 2)
|
||||
};
|
||||
#endif
|
||||
#include <DtMail/DtMail.hh>
|
||||
|
||||
class MsgStruct {
|
||||
public:
|
||||
MsgStruct() {};
|
||||
~MsgStruct() {};
|
||||
|
||||
int indexNumber;
|
||||
int sessionNumber;
|
||||
DtMailMessageHandle message_handle;
|
||||
Boolean is_deleted;
|
||||
};
|
||||
|
||||
class MsgHndArray {
|
||||
protected:
|
||||
int _size;
|
||||
MsgStruct **_contents;
|
||||
int _length;
|
||||
|
||||
public:
|
||||
MsgHndArray(int sz = 1024, int zeroed = 1)
|
||||
{
|
||||
_contents = (MsgStruct**) malloc(sizeof(MsgStruct*)*sz);
|
||||
_size = sz;
|
||||
if (zeroed) memset(_contents, 0, sizeof(MsgStruct *)*sz);
|
||||
|
||||
_length = 0;
|
||||
|
||||
}
|
||||
|
||||
~MsgHndArray()
|
||||
{
|
||||
// for (int ent = 0; ent < _length; ent++) {
|
||||
// delete _contents[ent];
|
||||
// }
|
||||
|
||||
free((void*) _contents);
|
||||
}
|
||||
|
||||
int length();
|
||||
MsgStruct* at(int a_number);
|
||||
int insert(MsgStruct* a_msg_struct);
|
||||
void clear();
|
||||
int indexof(MsgStruct* a_msg_struct);
|
||||
int indexof(DtMailMessageHandle a_msg_handle);
|
||||
void remove_entry(int position);
|
||||
void remove_entry(MsgStruct *ms);
|
||||
void append(MsgStruct *a_msg_struct);
|
||||
void mark_for_delete(int position);
|
||||
void compact(int start_pos);
|
||||
void replace(int postition, MsgStruct *a_msg_struct);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
3033
cde/programs/dtmail/dtmail/MsgScrollingList.C
Normal file
3033
cde/programs/dtmail/dtmail/MsgScrollingList.C
Normal file
File diff suppressed because it is too large
Load Diff
232
cde/programs/dtmail/dtmail/MsgScrollingList.hh
Normal file
232
cde/programs/dtmail/dtmail/MsgScrollingList.hh
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: MsgScrollingList.hh /main/12 1998/10/22 19:56:25 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef MSGSCROLLINGLIST_H
|
||||
#define MSGSCROLLINGLIST_H
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
#include "Image.h"
|
||||
#endif /* DEAD_WOOD */
|
||||
#include "MsgHndArray.hh"
|
||||
#include "RoamCmds.h"
|
||||
#include "ScrollingList.h"
|
||||
#include "UIComponent.h"
|
||||
#include "XmStrCollector.h"
|
||||
#include "XtArgCollector.h"
|
||||
|
||||
|
||||
//#include "UndeleteMessageFromListDialog.h"
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Xatom.h>
|
||||
}
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
/* MSGLIST_* msgid 200 -299
|
||||
*/
|
||||
#define MSGLIST_SELMV 200
|
||||
#define MSGLIST_SELCP 201
|
||||
#define MSGLIST_NORC 202
|
||||
#define MSGLIST_NOBOX 203
|
||||
#define MSGLIST_NOOPEN 204
|
||||
#define MSGLIST_MSGMV 205
|
||||
#define MSGLIST_MSGSMV 206
|
||||
#define MSGLIST_MSGCP 207
|
||||
#define MSGLIST_MSGSCP 208
|
||||
#define MSGLIST_NOSEL 209
|
||||
#define MSGLIST_RAISE 210
|
||||
#define MSGLIST_EXIT 211
|
||||
#define MSGLIST_OKBUT 212
|
||||
#define MSGLIST_DLGTTL 213
|
||||
|
||||
class Sort;
|
||||
class MsgScrollingList : public ScrollingList {
|
||||
|
||||
public:
|
||||
|
||||
MsgScrollingList ( RoamMenuWindow *, Widget, char * );
|
||||
~MsgScrollingList ();
|
||||
|
||||
// Accesors
|
||||
int selected_item_position() { return _selected_item_position; }
|
||||
RoamMenuWindow *parent() { return _parent; }
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
void addChooseCommand( ChooseCmd * );
|
||||
void addDeleteCommand( DeleteCmd * );
|
||||
#endif /* DEAD_WOOD */
|
||||
void select_next_item();
|
||||
void select_prev_item();
|
||||
|
||||
DtMailMessageHandle msgno(int index);
|
||||
MsgStruct* get_message_struct(int index);
|
||||
|
||||
DtMailMessageHandle current_msg_handle();
|
||||
int position(DtMailMessageHandle msgno);
|
||||
#ifdef DEAD_WOOD
|
||||
int position(MsgStruct* a_msg_struct);
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
virtual const char *const className() {return ("MsgScrollingList");}
|
||||
virtual void insertMsg(DtMailMessageHandle);
|
||||
virtual void insertDeletedMsg(DtMailMessageHandle);
|
||||
virtual void deleteSelected(Boolean silent = TRUE);
|
||||
|
||||
int copySelected(DtMailEnv &, char *, int delete_after_copy, int silent);
|
||||
void items( XmString [], int );
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
void appendMsg(DtMailMessageHandle msg_hndl, int sess_num);
|
||||
|
||||
void appendMsg(DtMailMessageHandle msgno);
|
||||
|
||||
DtMailMessageHandle lastMsg();
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
void clearMsgs();
|
||||
|
||||
void updateListItems(int current,
|
||||
Boolean renumber_only = TRUE,
|
||||
MsgHndArray *selected = NULL);
|
||||
DtMailBoolean senderIsToHeaderWhenMailFromMe(void);
|
||||
void checkDisplayProp(void);
|
||||
|
||||
XmString formatHeader(DtMailHeaderLine & retrieved,
|
||||
int sess_num,
|
||||
DtMailBoolean has_attachments,
|
||||
DtMailBoolean new_msg);
|
||||
|
||||
void visibleItems(int n_vis)
|
||||
{
|
||||
XtVaSetValues(_w, XmNvisibleItemCount, n_vis, NULL);
|
||||
}
|
||||
|
||||
int visibleItems(void)
|
||||
{
|
||||
int n_vis;
|
||||
XtVaGetValues(_w, XmNvisibleItemCount, &n_vis, NULL);
|
||||
return(n_vis);
|
||||
}
|
||||
|
||||
Widget get_scrolling_list();
|
||||
MsgHndArray *selected();
|
||||
DtMailBoolean show_with_attachments(DtMailMessageHandle);
|
||||
DtMailBoolean show_with_attachments(DtMail::Message * msg);
|
||||
|
||||
void display_message( DtMailEnv &, DtMailMessageHandle );
|
||||
void display_and_select_message(DtMailEnv &, DtMailMessageHandle );
|
||||
|
||||
// Select all of the messages in the list and display the last one.
|
||||
void select_all_and_display_last(DtMailEnv &);
|
||||
|
||||
//
|
||||
// Select all of the messages in the array[] of DtMailMessageHandle.
|
||||
// 'array' is NULL terminated list.
|
||||
//
|
||||
void select_all_and_display_last(DtMailEnv &,
|
||||
DtMailMessageHandle *array,
|
||||
unsigned int elements);
|
||||
|
||||
void display_no_message();
|
||||
void scroll_to_bottom();
|
||||
void scroll_to_position( int );
|
||||
virtual void extended_selection( DtMailEnv &, int );
|
||||
int get_selected_item();
|
||||
int get_displayed_item();
|
||||
int get_num_new_messages() { return num_new_messages; }
|
||||
int get_num_deleted_messages() { return num_deleted_messages; }
|
||||
void expunge(void);
|
||||
int resetIndexNums(void);
|
||||
int resetSessionNums(void);
|
||||
void layoutLabels();
|
||||
void layoutLabels(Widget, Widget, Widget, Widget);
|
||||
int get_num_messages() { return _msgs->length(); }
|
||||
MsgHndArray *get_deleted_messages() { return _deleted_messages; }
|
||||
MsgHndArray *get_messages() { return _msgs; }
|
||||
void sort_messages();
|
||||
|
||||
void viewInSeparateWindow(DtMailEnv &);
|
||||
void shutdown();
|
||||
|
||||
void undelete_messages(MsgHndArray *);
|
||||
void undelete_last_deleted();
|
||||
void display_message_summary();
|
||||
#ifdef DEAD_WOOD
|
||||
void display_message_selected();
|
||||
#endif /* DEAD_WOOD */
|
||||
void display_message(DtMailEnv &, int a_position);
|
||||
|
||||
int load_headers(DtMailEnv &);
|
||||
void load_headers(DtMailEnv &, DtMailMessageHandle last);
|
||||
void do_list_vis_adjustment();
|
||||
|
||||
// Save these to adjust as msg numbers changed ON/OFF.
|
||||
Widget _sender_lbl;
|
||||
Widget _subject_lbl;
|
||||
Widget _date_lbl;
|
||||
Widget _size_lbl;
|
||||
|
||||
protected:
|
||||
virtual void defaultAction( Widget, XtPointer, XmListCallbackStruct * );
|
||||
static void extendedSelectionCallback( Widget, XtPointer, XmListCallbackStruct * );
|
||||
MsgHndArray *_msgs;
|
||||
DtMailHeaderRequest _header_info;
|
||||
|
||||
// Msgs Popup stuff.
|
||||
Widget _msgsPopupMenu;
|
||||
MenuBar *_menuPopupMsgs;
|
||||
|
||||
private:
|
||||
#ifdef DEAD_WOOD
|
||||
Image *_attach_image;
|
||||
Image *_letter_image;
|
||||
#endif /* DEAD_WOOD */
|
||||
RoamMenuWindow *_parent;
|
||||
ChooseCmd *_choose;
|
||||
DeleteCmd *_delete;
|
||||
int _selected_item_position;
|
||||
int _displayed_item_position;
|
||||
int session_message_number;
|
||||
|
||||
int num_new_messages;
|
||||
int num_deleted_messages;
|
||||
MsgHndArray *_deleted_messages;
|
||||
|
||||
DtMailBoolean _numbered;
|
||||
Boolean _selection_on;
|
||||
Sort *_sorter;
|
||||
|
||||
// Collect the arguments to SetValues in load_headers
|
||||
// This prevents multiple redisplays of the XmList widget
|
||||
XtArgCollector *_xtarg_collector;
|
||||
|
||||
// Collect the XmString items in load_headers
|
||||
XmStrCollector *_xmstr_collector;
|
||||
|
||||
// Save the XmString that was allocated so that we can
|
||||
// free it later. It would probably be better to add this
|
||||
// to the XtArgCollector class, but since it's only one
|
||||
// item it's easier to do it this way.
|
||||
XmString _selected_items;
|
||||
};
|
||||
|
||||
#endif
|
||||
116
cde/programs/dtmail/dtmail/NoOpCmd.C
Normal file
116
cde/programs/dtmail/dtmail/NoOpCmd.C
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: NoOpCmd.C /main/5 1998/07/24 16:06:19 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// NoOpCmd.C: Example, dummy command class
|
||||
//////////////////////////////////////////////////////////
|
||||
#include <stdio.h>
|
||||
#include "EUSDebug.hh"
|
||||
#include "NoOpCmd.h"
|
||||
#include "Application.h"
|
||||
|
||||
void okCallback (void *);
|
||||
|
||||
NoOpCmd::NoOpCmd ( char *name,
|
||||
char *label,
|
||||
int active ) : Cmd ( name, label, active )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NoOpCmd::doit()
|
||||
{
|
||||
// Just print a message that allows us to trace the execution
|
||||
|
||||
char *buf = new char[1024];
|
||||
char *tmpName;
|
||||
|
||||
tmpName = (char *) name();
|
||||
|
||||
sprintf(buf, "%s : Sorry, not implemented.", tmpName);
|
||||
|
||||
theInfoDialogManager->post(tmpName, buf, (void *) this,
|
||||
okCallback);
|
||||
|
||||
// this->setQuestion(buf);
|
||||
//
|
||||
// this->execute();
|
||||
|
||||
delete [] buf;
|
||||
|
||||
// cout << name() << ":" << "doit\n" << flush;
|
||||
}
|
||||
|
||||
void NoOpCmd::undoit()
|
||||
{
|
||||
// Just print a message that allows us to trace the execution
|
||||
|
||||
DebugPrintf(1, "%s:\n", name());
|
||||
}
|
||||
|
||||
|
||||
void okCallback( void *)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
LabelCmd::~LabelCmd(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
LabelCmd::doit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
LabelCmd::undoit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const char *const
|
||||
LabelCmd::className(void)
|
||||
{
|
||||
return "LabelCmd";
|
||||
}
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
87
cde/programs/dtmail/dtmail/NoOpCmd.h
Normal file
87
cde/programs/dtmail/dtmail/NoOpCmd.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: NoOpCmd.h /main/3 1995/11/06 16:10:29 rswiston $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// NoOpCmd.h: Example, dummy command class
|
||||
/////////////////////////////////////////////////////////////
|
||||
#ifndef NOOPCMD_H
|
||||
#define NOOPCMD_H
|
||||
|
||||
#include "Cmd.h"
|
||||
#include "AskFirstCmd.h"
|
||||
#include "InfoDialogManager.h"
|
||||
|
||||
class NoOpCmd : public Cmd {
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
// virtual void okCallback(void *);
|
||||
|
||||
public:
|
||||
|
||||
NoOpCmd ( char *, char *, int );
|
||||
virtual const char *const className () { return "NoOpCmd"; }
|
||||
};
|
||||
|
||||
class LabelCmd: public Cmd {
|
||||
protected:
|
||||
|
||||
#ifdef CAN_INLINE_VIRTUALS
|
||||
virtual void doit() {}
|
||||
virtual void undoit() {}
|
||||
#else /* ! CAN_INLINE_VIRTUALS */
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
|
||||
public:
|
||||
LabelCmd ( char *name, char *label, int active) :Cmd(name, label, active){}
|
||||
#ifdef CAN_INLINE_VIRTUALS
|
||||
virtual ~LabelCmd(){}
|
||||
virtual const char *const className () { return "LabelCmd"; }
|
||||
#else /* CAN_INLINE_VIRTUALS */
|
||||
~LabelCmd();
|
||||
virtual const char *const className ();
|
||||
#endif /* CAN_INLINE_VIRTUALS */
|
||||
};
|
||||
|
||||
#endif
|
||||
278
cde/programs/dtmail/dtmail/Node.C
Normal file
278
cde/programs/dtmail/dtmail/Node.C
Normal file
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Node.C /main/4 1996/04/21 19:42:41 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Node.h"
|
||||
|
||||
// In the design, we had abstracted out the DOMF related activities
|
||||
// (insertion in lookup table, creation of the objref corresponding to
|
||||
// servant...) into <>Impl classes.
|
||||
// The <>Servant classes derive from the <>Impl classes.
|
||||
// Note how, in the constructor of the NodeServant class, we call the
|
||||
// constructor of the parent NodeImpl class passing in "this".
|
||||
// The NodeImpl constructor uses "this" to insert into the lookup table...
|
||||
|
||||
|
||||
Node::Node()
|
||||
{
|
||||
|
||||
my_message_handle = NULL;
|
||||
my_message_header = NULL;
|
||||
|
||||
homep = DTM_FALSE;
|
||||
deleted_p = DTM_FALSE;
|
||||
my_previous_node = NULL;
|
||||
my_next_node = NULL;
|
||||
}
|
||||
|
||||
Node::Node(
|
||||
DtMailMessageHandle msg_num,
|
||||
char* hdr
|
||||
)
|
||||
{
|
||||
my_message_handle = msg_num;
|
||||
my_message_header = hdr;
|
||||
|
||||
homep = DTM_FALSE;
|
||||
deleted_p = DTM_FALSE;
|
||||
my_previous_node = NULL;
|
||||
my_next_node = NULL;
|
||||
}
|
||||
|
||||
Node::~Node() {}
|
||||
|
||||
void
|
||||
Node::set_homep(
|
||||
)
|
||||
{
|
||||
homep = DTM_TRUE;
|
||||
}
|
||||
|
||||
boolean
|
||||
Node::is_home(
|
||||
)
|
||||
{
|
||||
return(homep);
|
||||
}
|
||||
|
||||
// Starting with the current node "this", traverse nodes until
|
||||
// home node is reached.
|
||||
|
||||
Node*
|
||||
Node::get_home(
|
||||
)
|
||||
{
|
||||
Node* a_node;
|
||||
unsigned char is_home_p;
|
||||
|
||||
|
||||
a_node = this;
|
||||
|
||||
is_home_p = a_node->is_home();
|
||||
|
||||
if (is_home_p) {
|
||||
return (this);
|
||||
}
|
||||
else {
|
||||
Node* n;
|
||||
|
||||
n = a_node->next();
|
||||
n->get_home();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Node::set_message_handle(
|
||||
DtMailMessageHandle a_hndl
|
||||
)
|
||||
{
|
||||
my_message_handle = a_hndl;
|
||||
}
|
||||
|
||||
|
||||
DtMailMessageHandle
|
||||
Node::get_message_handle()
|
||||
{
|
||||
return(my_message_handle);
|
||||
}
|
||||
|
||||
void
|
||||
Node::set_message_header(
|
||||
char* hdr
|
||||
)
|
||||
{
|
||||
my_message_header = hdr;
|
||||
}
|
||||
|
||||
char*
|
||||
Node::get_message_header()
|
||||
{
|
||||
return(my_message_header);
|
||||
}
|
||||
|
||||
Node*
|
||||
Node::next(
|
||||
)
|
||||
{
|
||||
|
||||
return(my_next_node);
|
||||
|
||||
}
|
||||
|
||||
// Don't attempt duplicating a nil objref!
|
||||
|
||||
Node*
|
||||
Node::prev(
|
||||
)
|
||||
{
|
||||
|
||||
return(my_previous_node);
|
||||
|
||||
}
|
||||
|
||||
// Don't attempt duplicating a nil objref!
|
||||
|
||||
void
|
||||
Node::set_previous_node(
|
||||
Node* a_node
|
||||
)
|
||||
{
|
||||
my_previous_node = a_node;
|
||||
|
||||
}
|
||||
|
||||
// Don't attempt duplicating a nil objref!
|
||||
|
||||
void
|
||||
Node::set_next_node(
|
||||
Node* a_node
|
||||
)
|
||||
{
|
||||
my_next_node = a_node;
|
||||
}
|
||||
|
||||
// append anyNode to self
|
||||
|
||||
void
|
||||
Node::append(
|
||||
Node* anyNode
|
||||
)
|
||||
{
|
||||
|
||||
Node* tmpNext;
|
||||
Node* tmpSelf;
|
||||
Node* inNode;
|
||||
|
||||
if (anyNode == NULL) {
|
||||
printf("Cannot append NIL node!");
|
||||
return;
|
||||
}
|
||||
|
||||
inNode = anyNode;
|
||||
|
||||
tmpSelf = this;
|
||||
|
||||
if (my_next_node)
|
||||
{
|
||||
tmpNext = my_next_node;
|
||||
my_next_node = inNode;
|
||||
inNode->set_previous_node(tmpSelf);
|
||||
inNode->set_next_node(my_next_node);
|
||||
tmpNext->set_previous_node(inNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
my_next_node = inNode;
|
||||
my_previous_node = inNode;
|
||||
inNode->set_previous_node(tmpSelf);
|
||||
inNode->set_next_node(tmpSelf);
|
||||
}
|
||||
}
|
||||
|
||||
// prepend anyNode to self
|
||||
|
||||
void
|
||||
Node::prepend(
|
||||
Node* anyNode
|
||||
)
|
||||
{
|
||||
|
||||
Node* tmpPrev;
|
||||
Node* inNode;
|
||||
Node* tmpSelf;
|
||||
|
||||
if (anyNode == NULL) {
|
||||
printf("Cannot prepend NIL node!");
|
||||
return;
|
||||
}
|
||||
|
||||
inNode = anyNode;
|
||||
tmpSelf = this;
|
||||
|
||||
if (my_previous_node)
|
||||
{
|
||||
tmpPrev = my_previous_node;
|
||||
my_previous_node = inNode;
|
||||
inNode->set_next_node(tmpSelf);
|
||||
inNode->set_previous_node(tmpPrev);
|
||||
tmpPrev->set_next_node(inNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
my_next_node = inNode;
|
||||
my_previous_node = inNode;
|
||||
inNode->set_previous_node(tmpSelf);
|
||||
inNode->set_next_node(tmpSelf);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Good etiquette requires that clients remove() a node
|
||||
// before destroy()-ing it.
|
||||
|
||||
void
|
||||
Node::remove(
|
||||
)
|
||||
{
|
||||
|
||||
my_previous_node->set_next_node(my_next_node);
|
||||
|
||||
my_next_node->set_previous_node(my_previous_node);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Node::set_number(int i)
|
||||
{
|
||||
bogus_number = i;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
Node::get_number()
|
||||
{
|
||||
return(bogus_number);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
130
cde/programs/dtmail/dtmail/Node.h
Normal file
130
cde/programs/dtmail/dtmail/Node.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Node.h /main/4 1996/04/21 19:42:44 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef __NODESERVANT_HH
|
||||
#define __NODESERVANT_HH
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include <DtMail/DtMail.hh>
|
||||
|
||||
// Nodes are of critical importance to the MailTool architecture
|
||||
// since all classes rely heavily on Nodes.
|
||||
// It is possible for the client to maintain a list of Nodes for
|
||||
// each Folder that it is interested in. Each Folder has a list of
|
||||
// Nodes, a Node for each Message the Folder's mailfile contains.
|
||||
// Each Message has a list of Nodes, a Node for each Attachment the
|
||||
// Message contains. And so on...
|
||||
// Nodes are circular lists and the root node is the only one that
|
||||
// has a "home-p" set to TRUE. Each Node has a my_previous_node and
|
||||
// a my_next_node which point to the previous and next nodes in the
|
||||
// circular list. Each Node has data which is of type CORBA::ObjRef.
|
||||
// The data in the Node depends on which level the node exists -
|
||||
// Nodes maintained by Folders contain Messages, Nodes maintained by
|
||||
// Messages contain Attachments, ...
|
||||
// This implementation of Nodes is abstract enough for *any* CORBA::ObjRef
|
||||
// to be placed in Nodes. Hence, it can be easily used or adapted-for-use
|
||||
// in any other environment requiring its functionality.
|
||||
// Semantics:
|
||||
//
|
||||
// set_homep() : Set self to be home-node.
|
||||
// is_homep() : Is self home-node?
|
||||
// get_home() : Traverse through hierarchy until
|
||||
// home-node is reached.
|
||||
// set/get_data() : Set or get Node's data.
|
||||
// next(), prev() : Go to next (or previous) Node.
|
||||
// append(), prepend() : Append or prepend a Node to self.`
|
||||
// remove() : Remove node from list.
|
||||
// destroy() : Destroy node, its contents and release objrefs.
|
||||
|
||||
|
||||
class Node {
|
||||
|
||||
public:
|
||||
Node();
|
||||
Node(
|
||||
DtMailMessageHandle msg_num,
|
||||
char * str
|
||||
);
|
||||
|
||||
~Node();
|
||||
|
||||
void set_homep(
|
||||
);
|
||||
boolean is_home(
|
||||
);
|
||||
Node* get_home(
|
||||
);
|
||||
|
||||
void set_message_handle(
|
||||
DtMailMessageHandle a_hndl
|
||||
);
|
||||
|
||||
|
||||
DtMailMessageHandle get_message_handle(
|
||||
);
|
||||
|
||||
void set_message_header(char* hdr);
|
||||
char* get_message_header();
|
||||
|
||||
void set_number(int i);
|
||||
int get_number();
|
||||
|
||||
Node* next(
|
||||
);
|
||||
|
||||
Node* prev(
|
||||
);
|
||||
|
||||
void set_previous_node(
|
||||
Node* anyNode
|
||||
);
|
||||
void set_next_node(
|
||||
Node* anyNode
|
||||
);
|
||||
|
||||
void append(
|
||||
Node* anyNode
|
||||
);
|
||||
void prepend(
|
||||
Node* anyNode
|
||||
);
|
||||
|
||||
void remove(
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
DtMailMessageHandle my_message_handle;
|
||||
char* my_message_header;
|
||||
int bogus_number;
|
||||
boolean homep;
|
||||
boolean deleted_p;
|
||||
Node* my_previous_node;
|
||||
Node* my_next_node;
|
||||
};
|
||||
|
||||
|
||||
#endif //__NODESERVANT_HH
|
||||
|
||||
|
||||
|
||||
|
||||
290
cde/programs/dtmail/dtmail/Notifier.C
Normal file
290
cde/programs/dtmail/dtmail/Notifier.C
Normal file
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Notifier.C /main/4 1996/04/21 19:42:47 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "Notifier.hh"
|
||||
|
||||
NotifyEvent::NotifyEvent(void)
|
||||
{
|
||||
}
|
||||
|
||||
NotifyEvent::~NotifyEvent(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
NotifyEvent::eventTriggered(void)
|
||||
{
|
||||
assert(!"Pure virtual NotifyEvent::eventTriggered called");
|
||||
}
|
||||
|
||||
Notifier::EventKey::EventKey(void * key)
|
||||
: ObjectKey("Notifier::EventKey")
|
||||
{
|
||||
_key = key;
|
||||
}
|
||||
|
||||
Notifier::EventKey::~EventKey(void)
|
||||
{
|
||||
}
|
||||
|
||||
Notifier::EventKey::operator==(ObjectKey & other)
|
||||
{
|
||||
EventKey * ok = (EventKey *)&other;
|
||||
|
||||
return(_key == ok->_key);
|
||||
}
|
||||
|
||||
Notifier::EventKey::operator!=(ObjectKey & other)
|
||||
{
|
||||
EventKey * ok = (EventKey *)&other;
|
||||
|
||||
return(_key != ok->_key);
|
||||
}
|
||||
|
||||
Notifier::EventKey::operator<(ObjectKey & other)
|
||||
{
|
||||
EventKey * ok = (EventKey *)&other;
|
||||
|
||||
return(_key < ok->_key);
|
||||
}
|
||||
|
||||
Notifier::EventKey::operator>(ObjectKey & other)
|
||||
{
|
||||
EventKey * ok = (EventKey *)&other;
|
||||
|
||||
return(_key > ok->_key);
|
||||
}
|
||||
|
||||
Notifier::EventKey::operator<=(ObjectKey & other)
|
||||
{
|
||||
EventKey * ok = (EventKey *)&other;
|
||||
|
||||
return(_key <= ok->_key);
|
||||
}
|
||||
|
||||
Notifier::EventKey::operator>=(ObjectKey & other)
|
||||
{
|
||||
EventKey * ok = (EventKey *)&other;
|
||||
|
||||
return(_key >= ok->_key);
|
||||
}
|
||||
|
||||
HashVal
|
||||
Notifier::EventKey::hashValue(void)
|
||||
{
|
||||
unsigned long lkey = (unsigned long)_key;
|
||||
|
||||
return(((lkey >> 16) & 0xffff) ^ (lkey & 0xffff));
|
||||
}
|
||||
|
||||
// These constants are used to keep the ends of the pipe straight.
|
||||
//
|
||||
static const int READ = 0;
|
||||
static const int WRITE = 1;
|
||||
|
||||
Notifier::Notifier(XtAppContext context)
|
||||
: _events(5), // Pending events that need to be sent.
|
||||
_timer_events(8) // Events for timing.
|
||||
{
|
||||
// Create a pipe for sending events.
|
||||
//
|
||||
pipe(_event_fds);
|
||||
|
||||
// Register the input file descriptor for callback.
|
||||
//
|
||||
XtAppAddInput(context,
|
||||
_event_fds[READ],
|
||||
(XtPointer)(XtInputReadMask | XtInputExceptMask),
|
||||
eventProc,
|
||||
this);
|
||||
|
||||
_context = context;
|
||||
}
|
||||
|
||||
int
|
||||
Notifier::deleteTimerEvent(ObjectKey &, TimerEvent * event, void *)
|
||||
{
|
||||
XtRemoveTimeOut(event->id);
|
||||
delete event->event;
|
||||
delete event;
|
||||
return(1);
|
||||
}
|
||||
|
||||
Notifier::~Notifier(void)
|
||||
{
|
||||
XtRemoveInput(_id);
|
||||
|
||||
close(_event_fds[READ]);
|
||||
close(_event_fds[WRITE]);
|
||||
|
||||
// We need to run through all of the pending events. They may
|
||||
// be interesting to the recipient and should be delivered before
|
||||
// we shutdown.
|
||||
//
|
||||
while (_events.length()) {
|
||||
NotifyEvent * event = _events[0];
|
||||
event->eventTriggered();
|
||||
delete event;
|
||||
_events.remove(0);
|
||||
}
|
||||
|
||||
// Now we want to throw away all of the events we have laying about
|
||||
// for timers and signals.
|
||||
//
|
||||
_timer_events.forEach(deleteTimerEvent, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
Notifier::notify(NotifyEvent & event, DtMailBoolean fast_path)
|
||||
{
|
||||
// The fast path means use an immediate call. Really pretty
|
||||
// simple. Fire the event and throw away the memory for it.
|
||||
//
|
||||
if (fast_path == DTM_TRUE) {
|
||||
event.eventTriggered();
|
||||
delete &event;
|
||||
}
|
||||
|
||||
// A little more complex. We will add the event to the queue, and
|
||||
// send a byte through the pipe. This will cause us to wake up
|
||||
// later, after going through the queue.
|
||||
//
|
||||
_events.append(&event);
|
||||
|
||||
char bogus_buf = 0;
|
||||
write(_event_fds[WRITE], &bogus_buf, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
Notifier::IntervalId
|
||||
Notifier::addInterval(int interval_ms,
|
||||
DtMailBoolean multi_shot,
|
||||
NotifyEvent & event)
|
||||
{
|
||||
TimerEvent * t_event = new TimerEvent;
|
||||
|
||||
t_event->interval = interval_ms;
|
||||
t_event->multi_shot = multi_shot;
|
||||
t_event->event = &event;
|
||||
|
||||
t_event->id = XtAppAddTimeOut(_context, interval_ms, timerProc, this);
|
||||
|
||||
EventKey * key = new EventKey((void *)t_event->id);
|
||||
_timer_events.set(*key, t_event);
|
||||
|
||||
return(t_event);
|
||||
}
|
||||
|
||||
void
|
||||
Notifier::removeInterval(IntervalId id)
|
||||
{
|
||||
// The Id is really the TimerEvent structure pointer. We dont have
|
||||
// a key for these objects so we will have to enumerate the entire
|
||||
// list of timer events until we find the appropriate key.
|
||||
//
|
||||
TimerEvent * t_event = (TimerEvent *)id;
|
||||
|
||||
TimerSearch t_srch;
|
||||
t_srch.srch_event = t_event;
|
||||
t_srch.key = NULL;
|
||||
|
||||
_timer_events.forEach(searchTimer, &t_srch);
|
||||
|
||||
if (t_srch.key) {
|
||||
_timer_events.remove(*t_srch.key);
|
||||
delete t_event->event;
|
||||
delete t_event;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
Notifier::eventProc(XtPointer client_data, int * fd, XtInputId *)
|
||||
{
|
||||
Notifier * self = (Notifier *)client_data;
|
||||
|
||||
// There was activity on the pipe. Read one byte, and fire one
|
||||
// event. We don't want to fire more than that or we will run
|
||||
// the risk of spending too much time in the callbacks.
|
||||
//
|
||||
char bogus_buf;
|
||||
read(*fd, &bogus_buf, 1);
|
||||
|
||||
if (self->_events.length()) {
|
||||
NotifyEvent * event = self->_events[0];
|
||||
event->eventTriggered();
|
||||
delete event;
|
||||
self->_events.remove(0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
Notifier::timerProc(XtPointer client_data, XtIntervalId *id)
|
||||
{
|
||||
Notifier * self = (Notifier *)client_data;
|
||||
EventKey key((void *)*id);
|
||||
|
||||
TimerEvent * t_event = self->_timer_events.lookup(key);
|
||||
if (!t_event) {
|
||||
// Bogus event.
|
||||
return;
|
||||
}
|
||||
|
||||
t_event->event->eventTriggered();
|
||||
|
||||
// We remove the event from the list. We do this because the
|
||||
// key will change because we will get a new interval id.
|
||||
//
|
||||
self->_timer_events.remove(key);
|
||||
|
||||
// If this is a multi-shot event we have to register it again.
|
||||
//
|
||||
if (t_event->multi_shot == DTM_TRUE) {
|
||||
t_event->id = XtAppAddTimeOut(self->_context,
|
||||
t_event->interval,
|
||||
timerProc,
|
||||
self);
|
||||
EventKey * new_key = new EventKey((void *)t_event->id);
|
||||
self->_timer_events.set(*new_key, t_event);
|
||||
}
|
||||
else {
|
||||
delete t_event->event;
|
||||
delete t_event;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Notifier::searchTimer(ObjectKey & key, TimerEvent * event, void * client_data)
|
||||
{
|
||||
TimerSearch * srch = (TimerSearch *)client_data;
|
||||
|
||||
if (event == srch->srch_event) {
|
||||
srch->key = (EventKey *)&key;
|
||||
return(0);
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
105
cde/programs/dtmail/dtmail/Notifier.hh
Normal file
105
cde/programs/dtmail/dtmail/Notifier.hh
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Notifier.hh /main/4 1996/04/21 19:42:50 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef NOTIFIER_HH
|
||||
#define NOTIFIER_HH
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
#include <DtMail/DtMailTypes.h>
|
||||
#include <DtMail/DtVirtArray.hh>
|
||||
#include <DtMail/HashTable.hh>
|
||||
|
||||
class NotifyEvent {
|
||||
public:
|
||||
NotifyEvent(void);
|
||||
virtual ~NotifyEvent(void);
|
||||
|
||||
virtual void eventTriggered(void); // PURE VIRTUAL
|
||||
};
|
||||
|
||||
class Notifier {
|
||||
public:
|
||||
Notifier(XtAppContext);
|
||||
virtual ~Notifier(void);
|
||||
|
||||
void notify(NotifyEvent & event,
|
||||
DtMailBoolean fast_path = DTM_FALSE);
|
||||
|
||||
typedef void * IntervalId;
|
||||
IntervalId addInterval(int interval_ms,
|
||||
DtMailBoolean multi_shot,
|
||||
NotifyEvent & event);
|
||||
void removeInterval(IntervalId id);
|
||||
|
||||
void signalEvent(int sig, NotifyEvent & event);
|
||||
void removeSignal(int sig);
|
||||
|
||||
private:
|
||||
int _event_fds[2];
|
||||
DtVirtArray<NotifyEvent *> _events;
|
||||
|
||||
struct TimerSearch;
|
||||
friend TimerSearch;
|
||||
|
||||
class EventKey : public ObjectKey {
|
||||
public:
|
||||
EventKey(void * key);
|
||||
~EventKey(void);
|
||||
|
||||
virtual int operator==(ObjectKey &);
|
||||
virtual int operator!=(ObjectKey &);
|
||||
virtual int operator<(ObjectKey &);
|
||||
virtual int operator>(ObjectKey &);
|
||||
virtual int operator<=(ObjectKey &);
|
||||
virtual int operator>=(ObjectKey &);
|
||||
|
||||
virtual HashVal hashValue(void);
|
||||
|
||||
void * keyValue(void) { return _key; }
|
||||
private:
|
||||
void * _key;
|
||||
};
|
||||
|
||||
struct TimerEvent {
|
||||
NotifyEvent *event;
|
||||
DtMailBoolean multi_shot;
|
||||
int interval;
|
||||
XtIntervalId id;
|
||||
};
|
||||
|
||||
HashTable<TimerEvent *> _timer_events;
|
||||
|
||||
XtAppContext _context;
|
||||
XtInputId _id;
|
||||
|
||||
static void eventProc(XtPointer client_data, int * fd, XtInputId *);
|
||||
static void timerProc(XtPointer, XtIntervalId *);
|
||||
|
||||
static int deleteTimerEvent(ObjectKey &, TimerEvent *, void *);
|
||||
|
||||
struct TimerSearch {
|
||||
TimerEvent * srch_event;
|
||||
EventKey * key;
|
||||
};
|
||||
static int searchTimer(ObjectKey &, TimerEvent *, void *);
|
||||
};
|
||||
|
||||
#endif
|
||||
1319
cde/programs/dtmail/dtmail/OptCmd.C
Normal file
1319
cde/programs/dtmail/dtmail/OptCmd.C
Normal file
File diff suppressed because it is too large
Load Diff
132
cde/programs/dtmail/dtmail/PasswordDialogManager.C
Normal file
132
cde/programs/dtmail/dtmail/PasswordDialogManager.C
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: PasswordDialogManager.C /main/4 1996/04/21 19:42:53 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include "PasswordDialogManager.h"
|
||||
#include <Xm/SelectioB.h>
|
||||
#include <Xm/TextF.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
|
||||
PasswordDialogManager *thePasswordDialogManager =
|
||||
new PasswordDialogManager ( "PasswordDialog" );
|
||||
|
||||
|
||||
PasswordDialogManager::PasswordDialogManager ( char *name ) :
|
||||
PromptDialogManager ( name )
|
||||
{
|
||||
// Empty
|
||||
_pwd[0] = 0;
|
||||
}
|
||||
|
||||
Widget PasswordDialogManager::createDialog ( Widget parent )
|
||||
{
|
||||
|
||||
Widget dialog = XmCreatePromptDialog ( parent, _name, NULL, 0);
|
||||
|
||||
XtVaSetValues ( dialog,
|
||||
XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
|
||||
NULL );
|
||||
|
||||
XtUnmanageChild( XmSelectionBoxGetChild( dialog,
|
||||
XmDIALOG_TEXT ) );
|
||||
|
||||
XtUnmanageChild( XmSelectionBoxGetChild( dialog,
|
||||
XmDIALOG_SELECTION_LABEL ) );
|
||||
|
||||
Widget rc = XtCreateManagedWidget ( "PasswordArea",
|
||||
xmRowColumnWidgetClass,
|
||||
dialog,
|
||||
NULL, 0 );
|
||||
|
||||
Widget _user_label = XtCreateManagedWidget
|
||||
( "UserLabel",
|
||||
xmLabelWidgetClass,
|
||||
rc,
|
||||
NULL, 0);
|
||||
|
||||
_user = XtCreateManagedWidget
|
||||
( "User",
|
||||
xmTextFieldWidgetClass,
|
||||
rc,
|
||||
NULL, 0);
|
||||
|
||||
Widget _password_label = XtCreateManagedWidget
|
||||
( "PasswordLabel",
|
||||
xmLabelWidgetClass,
|
||||
rc,
|
||||
NULL, 0);
|
||||
|
||||
_password = XtCreateManagedWidget
|
||||
( "Password",
|
||||
xmTextFieldWidgetClass,
|
||||
rc,
|
||||
NULL, 0);
|
||||
|
||||
XtManageChild( rc );
|
||||
XtAddCallback ( _password,
|
||||
XmNmodifyVerifyCallback,
|
||||
(XtCallbackProc )
|
||||
&PasswordDialogManager::modifyVerifyCallback,
|
||||
( XtPointer ) this );
|
||||
return dialog;
|
||||
}
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
char *
|
||||
PasswordDialogManager::userName(){
|
||||
return ( XmTextFieldGetString( _user ) );
|
||||
}
|
||||
|
||||
char *
|
||||
PasswordDialogManager::password(){
|
||||
// return ( XmTextFieldGetString( _password ) );
|
||||
return _pwd;
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
void
|
||||
PasswordDialogManager::modifyVerifyCallback( Widget w,
|
||||
XtPointer clientData,
|
||||
XmTextVerifyCallbackStruct *cbs ) {
|
||||
PasswordDialogManager *pdm=( PasswordDialogManager * ) clientData;
|
||||
pdm->modifyVerify( w, cbs );
|
||||
}
|
||||
|
||||
void
|
||||
PasswordDialogManager::modifyVerify( Widget ,
|
||||
XmTextVerifyCallbackStruct *cbs )
|
||||
{
|
||||
int len;
|
||||
|
||||
if ( cbs->text->ptr == NULL ) // Backspace
|
||||
return;
|
||||
for ( len=0; len< cbs->text->length; len++ ) {
|
||||
strncat(_pwd, &cbs->text->ptr[len], 1);
|
||||
cbs->text->ptr[len] = '*';
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
void
|
||||
PasswordDialogManager::resetPassword()
|
||||
{
|
||||
_pwd[0] = 0;
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
54
cde/programs/dtmail/dtmail/PasswordDialogManager.h
Normal file
54
cde/programs/dtmail/dtmail/PasswordDialogManager.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: PasswordDialogManager.h /main/4 1996/04/21 19:42:56 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// PasswordDialogManager.h
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PASSWORDDIALOGMANAGER_H
|
||||
#define PASSWORDDIALOGMANAGER_H
|
||||
#include "PromptDialogManager.h"
|
||||
|
||||
class PasswordDialogManager : public PromptDialogManager {
|
||||
private:
|
||||
|
||||
Widget _user;
|
||||
Widget _password;
|
||||
static void modifyVerifyCallback(Widget, XtPointer, XmTextVerifyCallbackStruct *);
|
||||
char _pwd[100]; // Big enough for most reasonable passwords.
|
||||
protected:
|
||||
|
||||
Widget createDialog ( Widget );
|
||||
|
||||
public:
|
||||
|
||||
PasswordDialogManager ( char * );
|
||||
void modifyVerify( Widget,XmTextVerifyCallbackStruct * );
|
||||
#ifdef DEAD_WOOD
|
||||
char *userName();
|
||||
char *password();
|
||||
void resetPassword();
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
};
|
||||
|
||||
extern PasswordDialogManager *thePasswordDialogManager;
|
||||
|
||||
#endif
|
||||
78
cde/programs/dtmail/dtmail/PropUi.C
Normal file
78
cde/programs/dtmail/dtmail/PropUi.C
Normal file
@@ -0,0 +1,78 @@
|
||||
/* $TOG: PropUi.C /main/6 1998/02/17 15:18:54 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include "RoamApp.h"
|
||||
#include <DtMail/DtVirtArray.hh>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/PropSource.hh>
|
||||
#include <string.h>
|
||||
|
||||
// PropUiItem::PropUiItem
|
||||
// PropUiItem ctor
|
||||
////////////////////////////////////////////////////////////////
|
||||
PropUiItem::PropUiItem( Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
PropUiCallback validator,
|
||||
void *validator_data)
|
||||
{
|
||||
// init variables
|
||||
prop_widget = w;
|
||||
dirty_bit = FALSE;
|
||||
source = source;
|
||||
key = strdup(search_key);
|
||||
_uiValueValidator = validator;
|
||||
_uiValueValidatorData = validator_data;
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = NULL;
|
||||
DtMail::MailRc * m_rc = NULL;
|
||||
|
||||
switch (source)
|
||||
{
|
||||
case _FROM_MAILRC:
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
prop_source = (PropSource *) new MailRcSource(m_rc, key );
|
||||
break;
|
||||
|
||||
default:
|
||||
prop_source = NULL;
|
||||
fprintf(stderr, "Error in PropUiItem ctor\n");
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
// PropUiItem::~PropUiItem
|
||||
// PropUiItem dtor
|
||||
////////////////////////////////////////////////////////////////
|
||||
PropUiItem::~PropUiItem()
|
||||
{
|
||||
// release memory alloced by the class
|
||||
free(key);
|
||||
delete prop_source;
|
||||
}
|
||||
|
||||
//
|
||||
// Returns NULL if the PropUiItem has a valid value; NLS error message if not.
|
||||
////////////////////////////////////////////////////////////////
|
||||
char * PropUiItem::uiValueIsValid()
|
||||
{
|
||||
if (NULL == _uiValueValidator) return NULL;
|
||||
return _uiValueValidator(this, _uiValueValidatorData);
|
||||
}
|
||||
51
cde/programs/dtmail/dtmail/QueryDialogManager.C
Normal file
51
cde/programs/dtmail/dtmail/QueryDialogManager.C
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: QueryDialogManager.C /main/4 1996/04/21 19:43:02 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
|
||||
#include "QueryDialogManager.hh"
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/MessageB.h>
|
||||
|
||||
QueryDialogManager *theQueryDialogManager =
|
||||
new QueryDialogManager ( "QueryDialog" );
|
||||
|
||||
|
||||
QueryDialogManager::QueryDialogManager ( char *name )
|
||||
:DialogManager ( name )
|
||||
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
Widget QueryDialogManager::createDialog ( Widget parent )
|
||||
{
|
||||
|
||||
Widget dialog = XmCreateQuestionDialog ( parent, _name, NULL, 0);
|
||||
|
||||
XtVaSetValues ( dialog,
|
||||
XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
|
||||
NULL );
|
||||
|
||||
return dialog;
|
||||
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
46
cde/programs/dtmail/dtmail/QueryDialogManager.hh
Normal file
46
cde/programs/dtmail/dtmail/QueryDialogManager.hh
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: QueryDialogManager.hh /main/4 1996/04/21 19:43:05 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// QueryDialogManager.hh
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
|
||||
#ifndef QUERYDIALOGMANAGER_HH
|
||||
#define QUERYDIALOGMANAGER_HH
|
||||
|
||||
#include "DialogManager.h"
|
||||
|
||||
class QueryDialogManager : public DialogManager {
|
||||
|
||||
protected:
|
||||
Widget createDialog ( Widget );
|
||||
|
||||
public:
|
||||
|
||||
QueryDialogManager ( char * );
|
||||
};
|
||||
|
||||
extern QueryDialogManager *theQueryDialogManager;
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* DEAD_WOOD */
|
||||
1
cde/programs/dtmail/dtmail/ReleaseNotes
Normal file
1
cde/programs/dtmail/dtmail/ReleaseNotes
Normal file
@@ -0,0 +1 @@
|
||||
Remeber to compile versions of imapd for 4.1.1 4.1.2 and 4.1.3
|
||||
128
cde/programs/dtmail/dtmail/Resources
Normal file
128
cde/programs/dtmail/dtmail/Resources
Normal file
@@ -0,0 +1,128 @@
|
||||
!CDE_Mail*DefaultMailBox: {dobbs}/var/spool/mail/karlj
|
||||
!CDE_Mail*DefaultMailBox: {morfryn}/var/mail/karlj
|
||||
CDE_Mail*DefaultMailBox: /home/dlp/mail/deferred
|
||||
CDE_Mail*foreground: White
|
||||
CDE_Mail*Background: #8c26bf
|
||||
.roam.Mail_View.mainWindow.Work_Area.Message_ListSW.Message_List.foreground: White
|
||||
.roam.Mail_View.mainWindow.Work_Area.Message_ListSW.Message_List.background: Black
|
||||
*VertScrollBar*background: #8c26bf
|
||||
*Mail_View.Message_View.Work_Area.TextSW.Text.foreground: Black
|
||||
CDE_Mail*WorkingDialog*dialogTitle: Working...
|
||||
CDE_Mail*interval: 300
|
||||
CDE_Mail*File*pushpin: out
|
||||
CDE_Mail*View*pushpin: out
|
||||
CDE_Mail*Next: True
|
||||
CDE_Mail*Edit*MenuShell*pushpin: out
|
||||
CDE_Mail*Compose*pushpin: out
|
||||
CDE_Mail*View*Messages*pushpin: none
|
||||
CDE_Mail*View*Sort By*pushpin: none
|
||||
CDE_Mail*Compose*Reply*pushpin: none
|
||||
CDE_Mail*Compose*Vacation*pushpin: none
|
||||
CDE_Mail*Next*default: True
|
||||
CDE_Mail*Interval: 300
|
||||
CDE_Mail*PrintScript: lp -dpubs3
|
||||
CDE_Mail*MailFiles: /home/satish/TestMail
|
||||
CDE_Mail*View*busy: False
|
||||
CDE_Mail*From*label: From:
|
||||
CDE_Mail*Text*label: Text:
|
||||
CDE_Mail*Find*pushpin: in
|
||||
CDE_Mail*Start*default: True
|
||||
!CDE_Mail*Change*default: True
|
||||
!CDE_Mail*FullHeader: False
|
||||
*Commands*weight: 0
|
||||
*Messages*refName: Commands
|
||||
CDE_Mail*Message_List*fontList: -misc-fixed-medium-*-*-*-13-*=plain,-misc-fixed-bold-*-*-*-13-*=bold
|
||||
!*Message_List*fontList: -*-courier-bold-*-*-*-14-*=bold,*-courier-medium-*-*-*-14-*=plain
|
||||
*Message_List*scrollBarDisplayPolicy: STATIC
|
||||
*Message_List*visibleItemCount: 15
|
||||
*Message_List*width: 500
|
||||
*Message_List*listSizePolicy: VARIABLE
|
||||
*Message_List*viewHeight: 7
|
||||
*Message_List*doubleClickInterval: 400
|
||||
!CDE_Mail*Message_List*font: -misc-fixed-bold-*-*-*-*-*-*-*-*-*-*-*
|
||||
!CDE_Mail*font: -misc-fixed-bold-*-*-*-*-*-*-*-*-*-*-*
|
||||
*Error_Text*bottomAttachment: ATTACH_FORM
|
||||
*Error_Text*leftAttachment: ATTACH_FORM
|
||||
*Error_Text*rightAttachment: ATTACH_FORM
|
||||
*Error_Text*rows: 1
|
||||
*Error_Text*cursorPositionVisible: False
|
||||
*Error_Text*marginHeight: 1
|
||||
*Message_List*recomputeWidth: FALSE
|
||||
*Message_List*prefMinWidth: 575
|
||||
*Message_List*selectionPolicy: EXTENDED_SELECT
|
||||
*Work_Area*Text*editMode: MULTI_LINE_EDIT
|
||||
*Work_Area*Text*rows: 20
|
||||
*Work_Area*Text*columns: 80
|
||||
*Work_Area*Text*bottomWidget: AttachArea
|
||||
*Work_Area*Text*bottmAttachment: attach_widget
|
||||
|
||||
*Message_Send*scrollHorizontal: False
|
||||
*Message_Send*wordWrap: True
|
||||
*Message_View*height: 300
|
||||
*Message_View*width: 400
|
||||
!*Message_View*Work_Area*Editor*height: 300
|
||||
!*Message_View*Work_Area*Editor*width: 400
|
||||
!*Message_View*leftAttachement: ATTACH_FORM
|
||||
!*Message_View*rightAttachment: ATTACH_FORM
|
||||
!*Message_View*bottomAttachment: ATTACH_FORM
|
||||
!*Message_View*topAttachement: ATTACH_FORM
|
||||
!CDE_Mail*Mail_View*width: 200
|
||||
CDE_Mail*Mail_View*scrollVertical: True
|
||||
CDE_Mail*menubar*marginHeight: 1
|
||||
CDE_Mail*menubar*tearOffModel: TEAR_OFF_ENABLED
|
||||
CDE_Mail*AttachAreaMenuBar*marginHeight: 1
|
||||
CDE_Mail*HeaderArea*To*marginHeight: 1
|
||||
CDE_Mail*HeaderArea*Subject*marginHeight: 1
|
||||
CDE_Mail*HeaderArea*Cc*marginHeight: 1
|
||||
|
||||
|
||||
!CDE_Mail*Message_Send*rc*leftAttachment: attach_form
|
||||
!CDE_Mail*Message_Send*rc*rightAttachment: attach_form
|
||||
!CDE_Mail*Message_Send*rc*packing: pack_tight
|
||||
!CDE_Mail*Message_Send*rc*orientation: horizontal
|
||||
!CDE_Mail*Message_Send*rc*numColumns: 3
|
||||
|
||||
!*Message_View*charsVisible: 80
|
||||
!*Message_View*viewWidth: 570
|
||||
*Attachments*weight: 0
|
||||
*inputFocusFeedback: inputfocuscolor
|
||||
CDE_Mail*View*Separator*separatorType: SHADOW_ETCHED_IN
|
||||
CDE_Mail*PasswordDialog*dialogTitle: Login...
|
||||
*PasswordArea*packing: pack_column
|
||||
*PasswordArea*numColumns: 2
|
||||
*PasswordArea*orientation: horizontal
|
||||
*PasswordArea*isAligned: True
|
||||
*PasswordArea*entryAlignment: alignment_end
|
||||
|
||||
CDE_Mail*UserLabel*labelString: Login:
|
||||
CDE_Mail*PasswordLabel*labelString: Password:
|
||||
*AttachmentsMenuBar.rightAttachment: attach_form
|
||||
*AttachmentsMenuBar.leftAttachment: attach_form
|
||||
*AttachmentsMenuBar.foreground: White
|
||||
|
||||
!*AttachArea.topAttachment: attach_opposite_widget
|
||||
!*AttachArea.topWidget: Text
|
||||
!*AttachArea.rightAttachment: attach_form
|
||||
!*AttachArea.leftAttachment: attach_form
|
||||
!*AttachArea.bottomAttachment: attach_form
|
||||
!*AttachArea.bottomWidget: AttachArea2
|
||||
CDE_Mail*AttachArea*AttachAreaMenuBar*File.foreground: White
|
||||
CDE_Mail*AttachArea*AttachAreaMenuBar*Edit.foreground: White
|
||||
CDE_Mail*AttachArea.background: White
|
||||
CDE_Mail*AttachArea*foreground: Black
|
||||
!CDE_Mail*To.topAttachment: attach_form
|
||||
!CDE_Mail*To.rightAttachment: attach_form
|
||||
!CDE_Mail*To.leftAttachment: attach_form
|
||||
|
||||
*sw.ScrolledWindowClipWindow.background: Black
|
||||
*sw.VertScrollBar.increment: 61
|
||||
*sw.VertScrollBar.pageIncrement: 61
|
||||
|
||||
*rc.orientation: horizontal
|
||||
*rc.width: 600
|
||||
*rc.height: 62
|
||||
*rc.resizeWidth: FALSE
|
||||
*rc.adjustLast: FALSE
|
||||
*rc.spacing: 10
|
||||
*sw.height: 66
|
||||
|
||||
2148
cde/programs/dtmail/dtmail/RoamApp.C
Normal file
2148
cde/programs/dtmail/dtmail/RoamApp.C
Normal file
File diff suppressed because it is too large
Load Diff
176
cde/programs/dtmail/dtmail/RoamApp.h
Normal file
176
cde/programs/dtmail/dtmail/RoamApp.h
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: RoamApp.h /main/20 1999/07/13 08:41:18 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef ROAMAPP_H
|
||||
#define ROAMAPP_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "MailSession.hh"
|
||||
#include <DtMail/DtVirtArray.hh>
|
||||
|
||||
class Cmd;
|
||||
class VacationCmd;
|
||||
class DtMailGenDialog;
|
||||
class RoamMenuWindow;
|
||||
|
||||
class RoamApp : public Application
|
||||
{
|
||||
private:
|
||||
DtVirtArray<Display*> _activePrintDisplays;
|
||||
int _busy_count;
|
||||
DtMailGenDialog *_dialog;
|
||||
Display *_errorPrintDisplay;
|
||||
Boolean _firstSaveYourselfArrived;
|
||||
Cmd *_options;
|
||||
char *_optionsHandle;
|
||||
RoamMenuWindow *_mailview;
|
||||
Boolean _quitSilently;
|
||||
Boolean _quitQuickly;
|
||||
static XtResource _resources[];
|
||||
VacationCmd *_vacation;
|
||||
FILE *session_fp;
|
||||
XtWorkProcId _shutdownWorkprocID;
|
||||
|
||||
void initSession(void);
|
||||
void openSessionFile(char *filename);
|
||||
char *parseSessionArg(int *argc, char **argv);
|
||||
void restoreSession(void);
|
||||
static Boolean shutdownWorkproc(XtPointer);
|
||||
static void smpDieCB(Widget, XtPointer, XtPointer);
|
||||
static void smpInteractCB(Widget, XtPointer, XtPointer);
|
||||
static void smpSaveSessionCB(Widget, XtPointer, XtPointer);
|
||||
virtual int smpSaveSessionGlobal(void);
|
||||
virtual void smpSaveSessionLocal(void);
|
||||
|
||||
|
||||
protected:
|
||||
XtIntervalId _appTimeoutId;
|
||||
char *_default_mailbox;
|
||||
char *_glyph_font; // Font for attchment glyph
|
||||
char *_glyph_name; // Font for attchment glyph
|
||||
char *_mailfiles_folder;
|
||||
MailSession *_mail_session;
|
||||
DtMail::Transport *_mail_transport;
|
||||
char *_print_script;
|
||||
char *_system_font; // Variable width font
|
||||
XmFontList _system_fontlist;
|
||||
int _tt_fd;
|
||||
char *_user_font; // Fixed width font
|
||||
XmFontList _user_fontlist;
|
||||
|
||||
static void applicationTimeout ( XtPointer, XtIntervalId * );
|
||||
static void disableGroupPrivileges(void *);
|
||||
static void enableGroupPrivileges(void *);
|
||||
static long lastInteractiveEventTime(void *);
|
||||
static void setBusyState(DtMailEnv &, DtMailBusyState, void *);
|
||||
static void showBusyState(DtMailEnv &, DtMailBusyState, void *);
|
||||
void timeout(XtIntervalId *);
|
||||
|
||||
public:
|
||||
RoamApp(char*);
|
||||
virtual ~RoamApp();
|
||||
|
||||
void busyAllWindows(const char * msg = NULL);
|
||||
virtual const char *const
|
||||
className()
|
||||
{ return "RoamApp"; }
|
||||
void closeAllWindows(void);
|
||||
char *default_mailbox()
|
||||
{ return _default_mailbox; }
|
||||
DtMail::Transport *default_transport(void)
|
||||
{ return _mail_transport; }
|
||||
MainWindow *defaultStatusWindow();
|
||||
int (*_default_x_error_handler)(Display*, XErrorEvent*);
|
||||
DtMailGenDialog *genDialog();
|
||||
Display *getErrorPrintDisplay(void)
|
||||
{ return _errorPrintDisplay; }
|
||||
void globalAddToCachedContainerList(char*);
|
||||
void globalPropChange(void);
|
||||
char *glyphName(void)
|
||||
{ return _glyph_name; }
|
||||
RoamMenuWindow *inboxWindow();
|
||||
virtual void initialize( int *, char ** );
|
||||
Boolean isActivePrintDisplay(Display *display)
|
||||
{ return (_activePrintDisplays.indexof(display)>=0); }
|
||||
Cmd *mailOptions(void)
|
||||
{ return _options; };
|
||||
char *mail_folder()
|
||||
{ return _mailfiles_folder; }
|
||||
RoamMenuWindow *nextRoamMenuWindow(RoamMenuWindow*);
|
||||
void closeInactiveRoamMenuWindows(void);
|
||||
void reopenRoamMenuWindows(void);
|
||||
virtual void open_catalog();
|
||||
char *optionsDialog(void)
|
||||
{ return _optionsHandle; }
|
||||
char *print_script(){ return _print_script; }
|
||||
Boolean quitSilently(void)
|
||||
{ return _quitSilently; }
|
||||
Boolean quitQuickly(void)
|
||||
{ return _quitQuickly; }
|
||||
void registerActivePrintDisplay(Display *display)
|
||||
{ _activePrintDisplays.append(display); }
|
||||
MailSession *session(void) { return _mail_session; }
|
||||
FILE *sessionFile(void) { return session_fp;}
|
||||
void setErrorPrintDisplay(Display *display)
|
||||
{ _errorPrintDisplay = display; }
|
||||
void setOptionsDialog(char *oHandle)
|
||||
{ _optionsHandle = oHandle; }
|
||||
void setQuitSilently(void) { _quitSilently = TRUE; }
|
||||
void setQuitQuickly(void) { _quitQuickly = TRUE; }
|
||||
void setSession(MailSession *);
|
||||
virtual void shutdown();
|
||||
void checkForShutdown();
|
||||
Boolean startVacation(Widget, Widget);
|
||||
static void statusCallback(DtMailOperationId, DtMailEnv&, void*);
|
||||
void stopVacation();
|
||||
void unbusyAllWindows(void);
|
||||
void unregisterActivePrintDisplay(Display *display)
|
||||
{ _activePrintDisplays.remove(display); }
|
||||
void unsetQuitSilently(void) { _quitSilently = FALSE; }
|
||||
void unsetQuitQuickly(void) { _quitQuickly = FALSE; }
|
||||
VacationCmd* vacation();
|
||||
};
|
||||
|
||||
// This method will parse a colon/space tuples that are used in
|
||||
// the mail properties.
|
||||
//
|
||||
struct PropStringPair {
|
||||
char * label;
|
||||
char * value;
|
||||
|
||||
PropStringPair(void);
|
||||
PropStringPair(const PropStringPair &);
|
||||
~PropStringPair(void);
|
||||
};
|
||||
|
||||
char *formatPropPair(char * key, void * data);
|
||||
void parsePropString(const char * input, DtVirtArray<PropStringPair *> & result);
|
||||
char* getPropStringValue(DtVirtArray<PropStringPair *> &result, const char *value);
|
||||
|
||||
extern RoamApp theRoamApp;
|
||||
|
||||
// This variable indicates whether RoamMenuWindow is mapped or not.
|
||||
// If a RMW is mapped, then Self_destruct will not be called by Compose
|
||||
// if Compose was started by ToolTalk.
|
||||
extern int dtmail_mapped;
|
||||
|
||||
#endif // ROAMAPP_H
|
||||
4129
cde/programs/dtmail/dtmail/RoamCmds.C
Normal file
4129
cde/programs/dtmail/dtmail/RoamCmds.C
Normal file
File diff suppressed because it is too large
Load Diff
1037
cde/programs/dtmail/dtmail/RoamCmds.h
Normal file
1037
cde/programs/dtmail/dtmail/RoamCmds.h
Normal file
File diff suppressed because it is too large
Load Diff
238
cde/programs/dtmail/dtmail/RoamInterruptibleCmd.C
Normal file
238
cde/programs/dtmail/dtmail/RoamInterruptibleCmd.C
Normal file
@@ -0,0 +1,238 @@
|
||||
/* $XConsortium: RoamInterruptibleCmd.C /main/3 1995/11/06 16:12:29 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////
|
||||
// RoamInterruptibleCmd.C: Abstract class that supports lengthy,
|
||||
// user-interruptible activities
|
||||
//////////////////////////////////////////////////////////////
|
||||
#include "RoamInterruptibleCmd.hh"
|
||||
#include "DtMailWDM.hh"
|
||||
#include "Application.h"
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include <assert.h>
|
||||
extern forceUpdate( Widget );
|
||||
|
||||
|
||||
RoamInterruptibleCmd::RoamInterruptibleCmd ( char *name,
|
||||
char *label,
|
||||
int active ) :
|
||||
NoUndoCmd ( name, label, active )
|
||||
{
|
||||
_wpId = NULL; // There is no work procedure yet
|
||||
_callback = NULL; // Callbacks are specified in execute()
|
||||
_clientData = NULL;
|
||||
_done = FALSE;
|
||||
_interrupted = FALSE;
|
||||
}
|
||||
|
||||
RoamInterruptibleCmd::~RoamInterruptibleCmd()
|
||||
{
|
||||
// Clean up by removing all callbacks
|
||||
|
||||
if ( _wpId)
|
||||
XtRemoveWorkProc ( _wpId );
|
||||
}
|
||||
|
||||
void
|
||||
RoamInterruptibleCmd::execute (
|
||||
RoamTaskDoneCallback callback,
|
||||
void *clientData
|
||||
)
|
||||
{
|
||||
_callback = callback;
|
||||
_clientData = clientData;
|
||||
execute();
|
||||
}
|
||||
|
||||
void
|
||||
RoamInterruptibleCmd::execute()
|
||||
{
|
||||
char *name_str;
|
||||
|
||||
name_str = (char *) name();
|
||||
|
||||
_done = FALSE; // Initialize flag
|
||||
|
||||
// Let the derived class post the dialog.
|
||||
// Updates happen when derived classes call update() or
|
||||
// updateMessage().
|
||||
|
||||
post_dialog();
|
||||
|
||||
// Call the Cmd execute function to handle the Undo, and other
|
||||
// general mechanisms supported by Cmd.
|
||||
// execute() calls doit() of derived class.
|
||||
|
||||
Cmd::execute();
|
||||
|
||||
// If the task was completed in a single call,
|
||||
// don't bother to set up a work procedure. Just
|
||||
// give derived classes a chance to cleanup and
|
||||
// call the application's callback function
|
||||
|
||||
// If it was interrupted, the interruptCallback would have been
|
||||
// called already and the dialog would have been unposted...
|
||||
|
||||
// We need to focus on only two cases here: what if the task was
|
||||
// was completed in one call without interruptions (unpost dialog
|
||||
// and call callback indicating task completed), and what if the
|
||||
// task was not completed in one call (install a workProc...)
|
||||
//
|
||||
|
||||
// if it done but not interrupted, it was genuinely done.
|
||||
if (_done && !_interrupted)
|
||||
{
|
||||
unpost_dialog(); // derived classes implement this
|
||||
cleanup();
|
||||
|
||||
if ( _callback ) // the FALSE is to say it was not interrupted.
|
||||
( *_callback )( this, FALSE, _clientData );
|
||||
}
|
||||
|
||||
// If the task is not done and it was not interrupted and there is
|
||||
// a callback to install, install a work procedure to continue the
|
||||
// task as soon as possible. Call the callback via the work proc
|
||||
// after completion.
|
||||
//
|
||||
|
||||
else if ((!_done && !_interrupted && _callback))
|
||||
{
|
||||
|
||||
_wpId = XtAppAddWorkProc ( theApplication->appContext(),
|
||||
&RoamInterruptibleCmd::workProcCallback,
|
||||
(XtPointer) this );
|
||||
}
|
||||
}
|
||||
|
||||
Boolean
|
||||
RoamInterruptibleCmd::workProcCallback (
|
||||
XtPointer clientData
|
||||
)
|
||||
{
|
||||
RoamInterruptibleCmd *obj = (RoamInterruptibleCmd *) clientData;
|
||||
|
||||
// The work procedure just returns the value returned by the
|
||||
// workProc member function.
|
||||
|
||||
return ( obj->workProc() );
|
||||
}
|
||||
|
||||
Boolean
|
||||
RoamInterruptibleCmd::workProc()
|
||||
{
|
||||
// Call derived class's check_if_done() and see if they think the
|
||||
// work is already done.
|
||||
|
||||
check_if_done();
|
||||
|
||||
if (_interrupted) {
|
||||
|
||||
unpost_dialog();
|
||||
cleanup();
|
||||
|
||||
// the TRUE is to say task was interrupted
|
||||
|
||||
if ( _callback )
|
||||
( *_callback )( this, TRUE, _clientData );
|
||||
}
|
||||
|
||||
// If the task has been completed, hide the dialog,
|
||||
// give the derived class a chance to clean up, and notify
|
||||
// the application that instantiated this object.
|
||||
|
||||
else if (_done) {
|
||||
unpost_dialog();
|
||||
cleanup();
|
||||
|
||||
// the FALSE is to say task completed without interruptions
|
||||
|
||||
if ( _callback )
|
||||
( *_callback )( this, FALSE, _clientData );
|
||||
}
|
||||
|
||||
return _done;
|
||||
}
|
||||
|
||||
void
|
||||
RoamInterruptibleCmd::cleanup()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
// The task has been interrupted. The user clicked on interrupt...
|
||||
|
||||
void
|
||||
RoamInterruptibleCmd::interruptCallback (
|
||||
void * clientData
|
||||
)
|
||||
{
|
||||
RoamInterruptibleCmd *obj = ( RoamInterruptibleCmd * ) clientData;
|
||||
|
||||
// Just set the _interrupt flag to TRUE. The workProc()
|
||||
// function will notice the next time it is called
|
||||
|
||||
obj->interrupt();
|
||||
}
|
||||
|
||||
void
|
||||
RoamInterruptibleCmd::interrupt()
|
||||
{
|
||||
_interrupted = TRUE;
|
||||
|
||||
if (_wpId) {
|
||||
// Remove the work procedure
|
||||
|
||||
XtRemoveWorkProc ( _wpId );
|
||||
}
|
||||
|
||||
// Remove the working dialog and give derived
|
||||
// classes a chance to clean up
|
||||
|
||||
unpost_dialog();
|
||||
cleanup();
|
||||
|
||||
// Notify the application that the task was interrupted
|
||||
|
||||
if ( _callback )
|
||||
( *_callback )( this, TRUE, _clientData);
|
||||
}
|
||||
|
||||
void
|
||||
RoamInterruptibleCmd::updateMessage (
|
||||
char * msg
|
||||
)
|
||||
{
|
||||
theDtMailWDM->updateDialog ( msg );
|
||||
forceUpdate(theDtMailWDM->baseWidget());
|
||||
}
|
||||
|
||||
Boolean
|
||||
RoamInterruptibleCmd::interrupted()
|
||||
{
|
||||
return _interrupted;
|
||||
}
|
||||
|
||||
void
|
||||
RoamInterruptibleCmd::update()
|
||||
{
|
||||
forceUpdate(theDtMailWDM->baseWidget());
|
||||
}
|
||||
|
||||
|
||||
|
||||
92
cde/programs/dtmail/dtmail/RoamInterruptibleCmd.hh
Normal file
92
cde/programs/dtmail/dtmail/RoamInterruptibleCmd.hh
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: RoamInterruptibleCmd.hh /main/3 1995/11/06 16:12:42 rswiston $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// RoamInterruptibleCmd.h: Abstract class that supports lengthy,
|
||||
// user-interruptible activities
|
||||
//////////////////////////////////////////////////////////////
|
||||
#ifndef ROAMINTERRUPTIBLECMD_H
|
||||
#define ROAMINTERRUPTIBLECMD_H
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include "NoUndoCmd.h"
|
||||
|
||||
// Influenced by the InterruptibleCmd class from MotifApp.
|
||||
// Different because it does not call the derived class's
|
||||
// doit() repeatedly. Instead, it repeatedly calls check_if_done().
|
||||
|
||||
// Define a type for the callback invoked when the task is finished
|
||||
|
||||
class RoamInterruptibleCmd;
|
||||
|
||||
typedef void (*RoamTaskDoneCallback) (
|
||||
RoamInterruptibleCmd *,
|
||||
Boolean,
|
||||
void * );
|
||||
|
||||
class RoamInterruptibleCmd : public NoUndoCmd {
|
||||
|
||||
private:
|
||||
|
||||
XtWorkProcId _wpId; // The ID of the workproc
|
||||
RoamTaskDoneCallback _callback; // Application-defined callback
|
||||
void *_clientData;
|
||||
|
||||
protected:
|
||||
|
||||
Boolean _done; // TRUE if the task has been completed
|
||||
Boolean _interrupted; // TRUE if the task was interrupted
|
||||
|
||||
virtual void cleanup(); // Called when task ends
|
||||
virtual void updateMessage ( char * );
|
||||
|
||||
virtual void post_dialog() = 0;
|
||||
virtual void unpost_dialog() = 0;
|
||||
virtual void check_if_done() = 0;
|
||||
|
||||
Boolean workProc ();
|
||||
static Boolean workProcCallback ( XtPointer );
|
||||
static void interruptCallback ( void * );
|
||||
void interrupt();
|
||||
|
||||
|
||||
// Derived classes implement doit(), declared by Cmd
|
||||
|
||||
public:
|
||||
|
||||
RoamInterruptibleCmd ( char * , char *, int );
|
||||
virtual ~RoamInterruptibleCmd();
|
||||
|
||||
virtual void execute(); // Overrides base class member function
|
||||
virtual void execute ( RoamTaskDoneCallback, void * );
|
||||
|
||||
// Enable others to check if the command was interrupted...
|
||||
virtual Boolean interrupted();
|
||||
|
||||
// Force update (and flushing of events in queue).
|
||||
virtual void update();
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
5497
cde/programs/dtmail/dtmail/RoamMenuWindow.C
Normal file
5497
cde/programs/dtmail/dtmail/RoamMenuWindow.C
Normal file
File diff suppressed because it is too large
Load Diff
593
cde/programs/dtmail/dtmail/RoamMenuWindow.h
Normal file
593
cde/programs/dtmail/dtmail/RoamMenuWindow.h
Normal file
@@ -0,0 +1,593 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: RoamMenuWindow.h /main/29 1999/02/03 18:01:26 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef ROAMMENUWINDOW_H
|
||||
#define ROAMMENUWINDOW_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Roam window for viewing messages
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
|
||||
#include "MenuWindow.h"
|
||||
#include "MenuBar.h"
|
||||
#include "DtMailGenDialog.hh"
|
||||
#include "NoOpCmd.h"
|
||||
#include "QuitCmd.h"
|
||||
#include "UndoCmd.h"
|
||||
#include "IconifyCmd.h"
|
||||
#include "CmdList.h"
|
||||
#include "RoamCmds.h"
|
||||
#include "Sort.hh"
|
||||
#include "ViewMsgDialog.h"
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include "MsgScrollingList.hh"
|
||||
#include "AttachArea.h"
|
||||
#include "FindDialog.h"
|
||||
#include "Editor.hh"
|
||||
|
||||
//#include "CDEM_CoeEd.hh"
|
||||
|
||||
#include "DtMailEditor.hh"
|
||||
|
||||
#include "Undelete.hh"
|
||||
|
||||
/* ROMENU_* msgid 400 - 499
|
||||
*/
|
||||
#define ROMENU_NOINIT 400
|
||||
#define ROMENU_NEWM 401
|
||||
#define ROMENU_STAT 402
|
||||
#define ROMENU_SUM 403
|
||||
#define ROMENU_SEL 404
|
||||
#define ROMENU_NOOPEN 405
|
||||
#define ROMENU_NOCREAT 406
|
||||
#define ROMENU_NOCRT 407
|
||||
#define ROMENU_CREAT 408
|
||||
#define ROMENU_LOAD 409
|
||||
#define ROMENU_INFO 410
|
||||
#define ROMENU_EMPTYC 411
|
||||
#define ROMENU_NEXT 412
|
||||
#define ROMENU_PREV 413
|
||||
#define ROMENU_PRT 414
|
||||
#define ROMENU_MVCP 415
|
||||
#define ROMENU_SENDER 416
|
||||
#define ROMENU_SUB 417
|
||||
#define ROMENU_DATE 418
|
||||
#define ROMENU_SIZE 419
|
||||
#define ROMENU_OPENBOX 420
|
||||
#define ROMENU_NEW 421
|
||||
#define ROMENU_OPEN 422
|
||||
#define ROMENU_EMPTY 423
|
||||
#define ROMENU_SAVEAS 424
|
||||
#define ROMENU_CLOSE 425
|
||||
#define ROMENU_OPMSG 426
|
||||
#define ROMENU_SAVEMSG 427
|
||||
#define ROMENU_PRINT 428
|
||||
#define ROMENU_DEL 429
|
||||
#define ROMENU_LAST 430
|
||||
#define ROMENU_LIST 431
|
||||
#define ROMENU_UNDEL 432
|
||||
#define ROMENU_MSG 433
|
||||
#define ROMENU_UNDMSG 434
|
||||
#define ROMENU_CPTO 435
|
||||
#define ROMENU_COPY 436
|
||||
#define ROMENU_SELALL 437
|
||||
#define ROMENU_PROP 438
|
||||
#define ROMENU_EDIT 439
|
||||
#define ROMENU_FDMSG 440
|
||||
#define ROMENU_FULL 441
|
||||
#define ROMENU_ABB 442
|
||||
#define ROMENU_BYDATE 443
|
||||
#define ROMENU_BYSEND 444
|
||||
#define ROMENU_BYSUB 445
|
||||
#define ROMENU_BYSIZE 446
|
||||
#define ROMENU_BYSTAT 447
|
||||
#define ROMENU_VIEW 448
|
||||
#define ROMENU_HDR 449
|
||||
#define ROMENU_NEWMSG 450
|
||||
#define ROMENU_NEWINCL 451
|
||||
#define ROMENU_FORWARD 452
|
||||
#define ROMENU_REPLY 453
|
||||
#define ROMENU_RPYALL 454
|
||||
#define ROMENU_RPYINCL 455
|
||||
#define ROMENU_RPYAINCL 456
|
||||
#define ROMENU_COMP 457
|
||||
#define ROMENU_VAC 458
|
||||
#define ROMENU_ONITEM 459
|
||||
#define ROMENU_ONAPP 460
|
||||
#define ROMENU_ONVER 461
|
||||
#define ROMENU_HELP 462
|
||||
#define ROMENU_LOADING 463
|
||||
#define ROMENU_CON 464
|
||||
#define ROMENU_DELMSG 465
|
||||
#define ROMENU_NOEMPTY 466
|
||||
#define ROMENU_EMPTY_CONT 467
|
||||
#define ROMENU_EMPTY_NOFILE 468
|
||||
#define ROMENU_MOVE 469
|
||||
#define ROMENU_RELNOTES 470
|
||||
|
||||
class RoamMenuWindow : public MenuWindow, public AbstractEditorParent
|
||||
{
|
||||
public:
|
||||
RoamMenuWindow(char*);
|
||||
virtual ~RoamMenuWindow();
|
||||
virtual void initialize();
|
||||
virtual void manage();
|
||||
|
||||
void Full(Boolean);
|
||||
Widget GetMainWin() { return _main; }
|
||||
// Popup Menu Event Handler
|
||||
static void MenuButtonHandler(Widget, XtPointer, XEvent*, Boolean*);
|
||||
static void ShowErrMsg(char*, Boolean, void*);
|
||||
|
||||
void attachmentFeedback(Boolean);
|
||||
void checkForMail(DtMailEnv &error)
|
||||
{ _we_called_newmail = TRUE; _mailbox->checkForMail(error); }
|
||||
virtual const char *const
|
||||
className() { return "RoamMenuWindow"; }
|
||||
void create_new_container(char*);
|
||||
Widget getDragIcon(Widget widget);
|
||||
void load_mailbox(DtMailEnv &mail_error);
|
||||
static XtActionProc
|
||||
msgListDragStart(Widget, XEvent*, String*, Cardinal*);
|
||||
// DND: Drop Site
|
||||
static void msgListConvertCallback( Widget, XtPointer, XtPointer);
|
||||
void msgListDropRegister();
|
||||
void msgListDropEnable();
|
||||
void msgListDropDisable();
|
||||
static void msgListDragFinishCallback(Widget, XtPointer, XtPointer);
|
||||
void msgListDragSetup();
|
||||
static Bool msgListLookForButton(Display*, XEvent*, XPointer);
|
||||
static void msgListProcessPress(Widget, XEvent*, String*, Cardinal*);
|
||||
static void msgListTransferCallback(Widget, XtPointer, XtPointer);
|
||||
void open(DtMailEnv &, DtMailBoolean, DtMailBoolean);
|
||||
void open_and_load(DtMailEnv &, DtMailBoolean, DtMailBoolean);
|
||||
virtual void panicQuit();
|
||||
void postErrorDialog(DtMailEnv&);
|
||||
void propsChanged(void);
|
||||
virtual void quit(Boolean delete_win = FALSE);
|
||||
void quit_silently();
|
||||
void reopen_mail_file();
|
||||
void removeVacationTitle(void);
|
||||
void setVacationTitle(void);
|
||||
void setTitle(char *suffix);
|
||||
void startAutoSave();
|
||||
void stopAutoSave();
|
||||
void sync_work_area_size();
|
||||
Boolean vacation();
|
||||
void view_mail_file(char*, DtMailBoolean create = DTM_FALSE);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Accessors
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
DtMailEditor *get_editor() { return(_my_editor); }
|
||||
ViewMsgDialog *msgView()
|
||||
{
|
||||
if ( _numDialogs==0 )
|
||||
return 0;
|
||||
else
|
||||
return _dialogs[_numDialogs-1];
|
||||
}
|
||||
FindDialog *get_find_dialog();
|
||||
DtMail::MailBox *mailbox() { return _mailbox; }
|
||||
MenuBar *menuBar() { return _menuBar; }
|
||||
MsgScrollingList *list() { return _list; }
|
||||
DtMailGenDialog *genDialog() { return _genDialog; }
|
||||
Widget workArea() { return _workArea;}
|
||||
Boolean fullHeader() { return _full_header_resource; }
|
||||
char *mailboxName() { return _mailbox_name; }
|
||||
unsigned int x() { return _x; }
|
||||
unsigned int y() { return _y; }
|
||||
unsigned int width() { return _width; }
|
||||
unsigned int height() { return _height; }
|
||||
char *mailbox_fullpath() { return _mailbox_fullpath; }
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Mutators
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void addToRowOfButtons();
|
||||
void addToRowOfLabels(MsgScrollingList *msglist);
|
||||
void addToRowOfMessageStatus();
|
||||
|
||||
void clearStatus(void);
|
||||
void forwardFilename(char*);
|
||||
char *forwardFilename();
|
||||
void fullHeader(Boolean flag);
|
||||
ViewMsgDialog *ifViewExists(DtMailMessageHandle msg_num);
|
||||
Boolean inbox();
|
||||
SortBy last_sorted_by(void) { return _last_sorted_by; }
|
||||
void last_sorted_by(SortBy type);
|
||||
void message( char * );
|
||||
void message_summary();
|
||||
void message_summary(int msgn, int nmsgs, int nnew, int ndeleted);
|
||||
void message_selected(int msgn, int nmsgs, int nnew, int ndeleted);
|
||||
void mailboxName( char *name)
|
||||
{
|
||||
if (NULL != _mailbox_name) free((void*)_mailbox_name);
|
||||
_mailbox_name=strdup( name );
|
||||
}
|
||||
void mailboxFullpath( char *path)
|
||||
{
|
||||
if (NULL != _mailbox_fullpath) free((void*)_mailbox_fullpath);
|
||||
_mailbox_fullpath=strdup( path );
|
||||
}
|
||||
void registerDialog(ViewMsgDialog*);
|
||||
void setStatus(const char *);
|
||||
void set_find_dialog(FindDialog *dialog) { _findDialog = dialog; }
|
||||
void showMessageFullHeaders(Boolean);
|
||||
void unregisterDialog(ViewMsgDialog*);
|
||||
|
||||
void construct_file_menu();
|
||||
void construct_message_menu();
|
||||
void construct_edit_menu();
|
||||
void construct_view_menu();
|
||||
void construct_compose_menu();
|
||||
void construct_move_menu();
|
||||
void construct_attachment_menu();
|
||||
void construct_attachment_popup(void);
|
||||
void construct_text_popup(void);
|
||||
void construct_message_popup();
|
||||
void construct_help_menu();
|
||||
|
||||
UndelFromListDialog
|
||||
*get_undel_dialog() {return _msg_undelete_from_list->dialog();}
|
||||
DtMail::MailRc
|
||||
*get_mail_rc();
|
||||
void clear_message();
|
||||
int inList(char *filename, DtVirtArray<ContainerMenuCmd *> *);
|
||||
void addToCachedContainerList(char *filename);
|
||||
void syncCachedContainerList();
|
||||
void newMailIndicators(void);
|
||||
void expunge(void);
|
||||
int queryExpunge(void);
|
||||
Boolean requiredConversion() {return _required_conversion;}
|
||||
|
||||
virtual void text_selected();
|
||||
virtual void text_unselected();
|
||||
|
||||
void attachment_selected();
|
||||
void all_attachments_deselected();
|
||||
void all_attachments_selected();
|
||||
void selectAllAttachments();
|
||||
void add_att(char *) { ; }
|
||||
void add_att(char *, DtMailBuffer) { ; }
|
||||
void add_att(DtMailBuffer) { ; }
|
||||
void activate_default_attach_menu();
|
||||
void deactivate_default_attach_menu();
|
||||
void activate_default_message_menu();
|
||||
void deactivate_default_message_menu();
|
||||
void showAttachArea();
|
||||
void hideAttachArea();
|
||||
void addAttachmentActions(char **, int);
|
||||
void removeAttachmentActions();
|
||||
void invokeAttachmentAction(int);
|
||||
void save_selected_attachment(char *);
|
||||
int showConversionStatus(int, int);
|
||||
void conversionFinished();
|
||||
void convert(char *, char *);
|
||||
void resetCacheList(int new_size);
|
||||
|
||||
// syncViewAndStore() does the sync-ing of the view of a mail
|
||||
// container and the storage of that container.
|
||||
// E.g., this callback and therefore the method gets invoked every
|
||||
// time a message gets expunged by the back end based on "timed delete".
|
||||
//
|
||||
// The method needs to then remove the expunged message from the
|
||||
// deleted messages list, thereby syncing the view to be always
|
||||
// current with the storage.
|
||||
// Similarly, the method also gets invoked when the container store
|
||||
// has received new mail. The view then needs to be updated....
|
||||
|
||||
DtMailBoolean syncViewAndStore(DtMailCallbackOp, const char*, va_list);
|
||||
|
||||
// Static public methods now.
|
||||
static DtMailBoolean syncViewAndStoreCallback(
|
||||
DtMailCallbackOp op,
|
||||
const char * path,
|
||||
const char * prompt_hint,
|
||||
void * client_data,
|
||||
...);
|
||||
static int ConvertStatusCB(int current, int total, void *);
|
||||
virtual void postMsgsPopup(XEvent *event);
|
||||
inline Boolean IsLoaded () { return _is_loaded; }
|
||||
|
||||
// XSMP support
|
||||
static RoamMenuWindow
|
||||
*restoreSession(char*);
|
||||
virtual int smpSaveSessionGlobal(void);
|
||||
virtual void smpSaveSessionLocal(void);
|
||||
|
||||
protected:
|
||||
|
||||
Boolean _checkformail_when_mapped;
|
||||
Boolean _delete_on_quit;
|
||||
char *_forward_filename;
|
||||
Boolean _full_header_resource;
|
||||
SortBy _last_sorted_by;
|
||||
char *_mail_files_resource;
|
||||
char *_mailbox_fullpath;
|
||||
char *_mailbox_name;
|
||||
char *_mailbox_name_resource;
|
||||
Boolean _required_conversion;
|
||||
Boolean _we_called_newmail;
|
||||
|
||||
ViewMsgDialog **_dialogs;
|
||||
int _numDialogs;
|
||||
FindDialog *_findDialog;
|
||||
|
||||
//
|
||||
// ContainerList
|
||||
//
|
||||
int _display_cached_list;
|
||||
char *_filemenu2;
|
||||
int _first_cached_item;
|
||||
int _max_cached_list_size;
|
||||
DtVirtArray<ContainerMenuCmd *> *_user_containerlist;
|
||||
DtVirtArray<ContainerMenuCmd *> *_cached_containerlist;
|
||||
|
||||
//
|
||||
// File Menu
|
||||
//
|
||||
CmdList *_file_cmdlist;
|
||||
Cmd *_file_separator;
|
||||
CheckForNewMailCmd *_file_check_new_mail;
|
||||
Cmd *_file_open_inbox;
|
||||
UnifiedSelectMailboxCmd *_file_new_container;
|
||||
UnifiedSelectMailboxCmd *_file_open;
|
||||
Cmd *_file_destroy_deleted_msgs;
|
||||
Cmd *_file_quit;
|
||||
Widget _file_cascade;
|
||||
|
||||
//
|
||||
// Open Cascade Menu
|
||||
//
|
||||
CmdList *_open_container_cmdlist;
|
||||
Cmd *_open_container_separator;
|
||||
Cmd *_open_container_inbox;
|
||||
UnifiedSelectMailboxCmd
|
||||
*_open_container_other;
|
||||
|
||||
DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist;
|
||||
DtVirtArray<ContainerMenuCmd *> *_open_container_containerlist_cached;
|
||||
Widget _opencontainerMenu;
|
||||
|
||||
//
|
||||
// Message Menu
|
||||
//
|
||||
CmdList *_msg_cmdlist;
|
||||
Cmd *_msg_separator;
|
||||
Cmd *_msg_open;
|
||||
Cmd *_msg_save_as;
|
||||
Cmd *_msg_print;
|
||||
Cmd *_msg_find;
|
||||
Cmd *_msg_select_all;
|
||||
Cmd *_msg_delete;
|
||||
Cmd *_msg_undelete_last;
|
||||
UndeleteCmd *_msg_undelete_from_list;
|
||||
|
||||
//
|
||||
// CopyTo Cascade Menu
|
||||
//
|
||||
CmdList *_copyto_cmdlist;
|
||||
Cmd *_copyto_separator;
|
||||
CopyToInboxCmd *_copyto_inbox;
|
||||
Cmd *_copyto_other;
|
||||
|
||||
DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist;
|
||||
DtVirtArray<ContainerMenuCmd *> *_copyto_containerlist_cached;
|
||||
Widget _copytoMenu;
|
||||
Widget _message_cascade;
|
||||
|
||||
//
|
||||
// Edit Menu
|
||||
//
|
||||
CmdList *_edit_cmdlist;
|
||||
Cmd *_edit_copy;
|
||||
Cmd *_edit_select_all;
|
||||
|
||||
//
|
||||
// Attachments Menu
|
||||
//
|
||||
CmdList *_att_cmdlist;
|
||||
Cmd *_att_save;
|
||||
Cmd *_att_select_all;
|
||||
|
||||
//
|
||||
// View Menu
|
||||
//
|
||||
CmdList *_view_cmdlist;
|
||||
Cmd *_view_separator;
|
||||
Cmd *_view_next;
|
||||
Cmd *_view_previous;
|
||||
Cmd *_view_abbrev_headers;
|
||||
Cmd *_view_sortTD;
|
||||
Cmd *_view_sortSender;
|
||||
Cmd *_view_sortSubject;
|
||||
Cmd *_view_sortSize;
|
||||
Cmd *_view_sortStatus;
|
||||
|
||||
//
|
||||
// Compose Menu
|
||||
//
|
||||
CmdList *_comp_cmdlist;
|
||||
Cmd *_comp_separator;
|
||||
Cmd *_comp_new;
|
||||
Cmd *_comp_new_include;
|
||||
Cmd *_comp_forward;
|
||||
Cmd *_comp_replySender;
|
||||
Cmd *_comp_replyAll;
|
||||
Cmd *_comp_replySinclude;
|
||||
Cmd *_comp_replyAinclude;
|
||||
|
||||
//
|
||||
// Move Menu
|
||||
//
|
||||
CmdList *_move_cmdlist;
|
||||
Cmd *_move_separator;
|
||||
MoveToInboxCmd *_move_inbox;
|
||||
Cmd *_move_other;
|
||||
|
||||
DtVirtArray<ContainerMenuCmd *> *_move_containerlist;
|
||||
DtVirtArray<ContainerMenuCmd *> *_move_containerlist_cached;
|
||||
Widget _moveMenu;
|
||||
Widget _move_cascade;
|
||||
|
||||
//
|
||||
// Help Menu
|
||||
//
|
||||
CmdList *_help_cmdlist;
|
||||
Cmd *_help_separator;
|
||||
Cmd *_help_overview;
|
||||
Cmd *_help_tasks;
|
||||
Cmd *_help_reference;
|
||||
Cmd *_help_on_item;
|
||||
Cmd *_help_using_help;
|
||||
Cmd *_help_about_mailer;
|
||||
|
||||
//
|
||||
// Message Popup
|
||||
//
|
||||
CmdList *_msgsPopup_cmdlist;
|
||||
Cmd *_msgsPopup_separator;
|
||||
|
||||
MenuBar *_menuPopupMsgs;
|
||||
Widget _msgsPopupMenu;
|
||||
Widget _msgsPopupMoveMenu;
|
||||
|
||||
//
|
||||
// Text Popup
|
||||
//
|
||||
CmdList *_textPopup_cmdlist;
|
||||
Cmd *_textPopup_separator;
|
||||
|
||||
//
|
||||
// Attachments Popup
|
||||
//
|
||||
CmdList *_attPopup_cmdlist;
|
||||
Cmd *_attPopup_separator;
|
||||
CmdList *_attActions_cmdlist;
|
||||
|
||||
Widget _attachmentMenu;
|
||||
|
||||
//
|
||||
// Message filing interface
|
||||
//
|
||||
ConvertContainerCmd *_convertContainerCmd;
|
||||
OpenContainerCmd *_openContainerCmd;
|
||||
|
||||
//
|
||||
// This is the set of buttons below the scrolling list
|
||||
// They get used in the addToRowOfButtons() method
|
||||
//
|
||||
DeleteCmd *_delete_button;
|
||||
Cmd *_next_button;
|
||||
Cmd *_previous_button;
|
||||
Cmd *_replySender_button;
|
||||
Cmd *_print_button;
|
||||
Cmd *_move_copy_button;
|
||||
|
||||
|
||||
DtMail::MailBox *_mailbox;
|
||||
Boolean _inbox;
|
||||
MsgScrollingList *_list;
|
||||
DtMailGenDialog *_genDialog;
|
||||
|
||||
Widget createWorkArea ( Widget );
|
||||
void createMenuPanes();
|
||||
void createContainerList();
|
||||
void createOpenContainerList(CmdList *);
|
||||
void createCopyList(CmdList *);
|
||||
void configurenotify(
|
||||
unsigned int,
|
||||
unsigned int,
|
||||
unsigned int,
|
||||
unsigned int,
|
||||
unsigned int);
|
||||
void mapnotify();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
static XtResource _resources[];
|
||||
static char *_supported[];
|
||||
|
||||
Pixmap _mbox_image;
|
||||
Pixmap _mbox_mask;
|
||||
|
||||
unsigned int _x;
|
||||
unsigned int _y;
|
||||
unsigned int _width;
|
||||
unsigned int _height;
|
||||
unsigned int _border_width;
|
||||
Dimension _workarea_width;
|
||||
Dimension _workarea_height;
|
||||
|
||||
DtMailEditor *_my_editor;
|
||||
Widget _message;
|
||||
Widget _message_summary;
|
||||
Widget _rowOfLabels;
|
||||
Widget _rowOfButtons;
|
||||
Widget _rowOfMessageStatus;
|
||||
XtWorkProcId _quitWorkprocID;
|
||||
Boolean _clear_message_p;
|
||||
Boolean _create_mailbox_file;
|
||||
Boolean _is_loaded;
|
||||
Boolean _open_create_flag;
|
||||
Boolean _open_lock_flag;
|
||||
|
||||
//
|
||||
// Message header list column labels
|
||||
//
|
||||
Widget _sender_lbl;
|
||||
Widget _subject_lbl;
|
||||
Widget _date_lbl;
|
||||
Widget _size_lbl;
|
||||
|
||||
XmString _sender_xms;
|
||||
XmString _subject_xms;
|
||||
XmString _date_xms;
|
||||
XmString _size_xms;
|
||||
|
||||
XmString _sender_key_xms;
|
||||
XmString _subject_key_xms;
|
||||
XmString _date_key_xms;
|
||||
XmString _size_key_xms;
|
||||
|
||||
static void ownselectionCallback(Widget, XtPointer, XtPointer );
|
||||
static void structurenotify(Widget, XtPointer, XEvent *, Boolean *);
|
||||
static void file_selection_callback(void *, char * );
|
||||
static void create_container_callback(void *, char * );
|
||||
static void move_callback(void *, char *);
|
||||
static void copy_callback(void *, char *);
|
||||
static void save_attachment_callback(void *, char *);
|
||||
static void delete_attachment_callback(void *, char *);
|
||||
static void conversionFinishedCallback(
|
||||
RoamInterruptibleCmd *,
|
||||
Boolean,
|
||||
void *);
|
||||
static void map_menu( Widget, XtPointer, XtPointer );
|
||||
static Boolean quitWorkproc(XtPointer);
|
||||
};
|
||||
|
||||
#endif
|
||||
16
cde/programs/dtmail/dtmail/RunLocalBento
Normal file
16
cde/programs/dtmail/dtmail/RunLocalBento
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/csh -f
|
||||
set echo
|
||||
#
|
||||
# A script that aids in debugging and testing dtmail
|
||||
#
|
||||
if ( `uname -s` != SunOS ) then
|
||||
echo "Only support SunOS"
|
||||
exit 1
|
||||
endif
|
||||
|
||||
|
||||
setenv DT_MAIL /home/dougr/INBOX
|
||||
setenv DEFAULT_BACKEND Bento
|
||||
setenv LD_LIBRARY_PATH ../libDtMail:../../../lib/Bento:../../../binstall/lib:$LD_LIBRARY_PATH
|
||||
ldd -r ./dtmail
|
||||
exec dtmail &
|
||||
14
cde/programs/dtmail/dtmail/RunLocalMime
Normal file
14
cde/programs/dtmail/dtmail/RunLocalMime
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/csh -f
|
||||
#
|
||||
# A script that aids in debugging and testing dtmail
|
||||
#
|
||||
if ( `uname -s` != SunOS ) then
|
||||
echo "Only support SunOS"
|
||||
exit 1
|
||||
endif
|
||||
|
||||
set echo
|
||||
#setenv DEFAULT_BACKEND RFC-MIME
|
||||
setenv LD_LIBRARY_PATH ../libDtMail:../../../binstall/lib:$LD_LIBRARY_PATH
|
||||
ldd -r ./dtmail
|
||||
exec ./dtmail $* &
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user