2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
26 * $TOG: Attachment.h /main/8 1998/05/06 15:54:12 rafi $
28 * RESTRICTED CONFIDENTIAL INFORMATION:
30 * The information in this document is subject to special
31 * restrictions in a confidential disclosure agreement between
32 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
33 * document outside HP, IBM, Sun, USL, SCO, or Univel without
34 * Sun's specific written approval. This document and all copies
35 * and derivative works thereof must be returned or destroyed at
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
47 #include <Dt/Action.h>
48 #include <DtMail/DtMail.hh>
49 #include <DtMail/DtVirtArray.hh>
51 #include "UIComponent.h"
52 #include "AttachArea.h"
56 typedef enum { ROAM_CACHED, ROAM_LOCAL, ROAM_AVAILABLE, ROAM_UNAVAILABLE } ACState;
58 typedef enum { DONTKNOW, EXECUTABLE, NOTEXECUTABLE } ExecState;
63 class ActionCallback {
64 friend class Attachment;
66 ActionCallback(DtMailObjectKey, Attachment *);
70 DtMailObjectKey _myKey;
71 Attachment *_myAttachment;
74 class Attachment : public UIComponent {
78 // This version takes a filename as a parameter
80 Attachment ( AttachArea *, String, DtMail::BodyPart *, int);
82 virtual ~Attachment(); // Destructor
83 virtual void initialize();
89 void invokeAction(int);
91 int operator==(const Attachment&);
95 // Note: functions calling getLabel are responsible for freeing
96 // the XmString it returns
98 XmString getLabel() { return ( XmStringCopy ( _label ) ); }
99 void rename(XmString);
103 unsigned long getContentsSize()
104 { return ( _myContentsSize ); }
106 Dimension getWidth() { return ( _attachmentWidth ); }
107 Dimension getHeight() { return ( _attachmentHeight );}
108 Position getX() { return ( _positionX ); }
109 Position getY() { return ( _positionY );}
110 int getRow() { return ( _row ); }
112 Boolean isManaged() { return ( XtIsManaged(_w) ); }
113 Boolean isDeleted() { return ( _deleted ); }
114 AttachArea* parent() { return ( _parent ); }
115 Widget getIconWidget() { return ( _w); }
116 void manageIconWidget(void);
117 void unmanageIconWidget(void);
119 String getSaveAsFilename()
120 { return ( _saveAsFilename ); }
121 char* getCeName() { return ( _ce_name ); }
122 unsigned short getType() { return ( _type ); }
123 String getSubType() { return ( _subtype ); }
124 DtMail::BodyPart *getBodyPart() { return ( _body_part ); }
125 Boolean isBinary() { return ( _binary ); }
126 Boolean isSelected() { return ( _selected ); }
129 void saveToFile(DtMailEnv & error,char *filename);
130 virtual const char *const className() { return ( "Attachment" ); }
133 void setLabel( XmString str );
139 #else /* ! DEAD_WOOD */
141 void setRow(int row) { _row = row; }
142 #endif /* ! DEAD_WOOD */
146 void setSaveAsFilename(String str)
147 { ( _saveAsFilename = str); }
149 void set_binary(Boolean binary)
150 { ( _binary = binary); }
152 void handleDoubleClick();
155 void setAttachArea(AttachArea *);
157 Boolean check_if_binary(String, unsigned long);
158 #endif /* DEAD_WOOD */
160 // SR -- Added methods below
162 void primitive_select();
164 Boolean is_selected();
172 void registerAction(DtActionInvocationID);
173 void unregisterAction(DtActionInvocationID);
175 static void actionCallback(
176 DtActionInvocationID id,
177 XtPointer client_data,
178 DtActionArg *actionArgPtr,
180 DtActionStatus status
185 Icon* myIcon; // my Icon instance
187 Pixel _background; // The background color
188 Pixel _foreground; // The foreground color
189 AttachArea *_parent; // The Parent class
190 XmString _label; // The name (no absolute path)
191 DtMail::BodyPart *_body_part; // Pointer to back end body part.
193 Dimension _attachmentWidth; // The width of the attachment
194 Dimension _attachmentHeight; // The height of the attachment
195 Position _positionX; // The X Position
196 Position _positionY; // The Y Position
198 Boolean _deleted; // True is it has been deleted
199 Boolean _selected; // True if selected.
200 int _row; // Which row this is displayed in
201 String _saveAsFilename; // Name for Save As
202 int _index; // Index in attachArea
205 unsigned short _type;
210 Boolean _haveContents;
211 char *_myAllocContents;
212 const void *_myContents;
213 unsigned long _myContentsSize;
215 Boolean _canKillSelf;
217 char ** _myActionsList;
218 DtVirtArray<DtActionInvocationID> _myActionIds;
219 DtMailObjectKey _key;
220 void _setMyContents(const void * data, int size);