summaryrefslogtreecommitdiffstats
path: root/kmail/kmcomposewin.h
blob: ec576bda5897926ba88394b981128689c040f58c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
/* -*- mode: C++; c-file-style: "gnu" -*-
 * KMComposeWin Header File
 * Author: Markus Wuebben <markus.wuebben@kde.org>
 */
#ifndef __KMComposeWin
#define __KMComposeWin

#ifndef KDE_USE_FINAL
# ifndef REALLY_WANT_KMCOMPOSEWIN_H
#  error Do not include kmcomposewin.h anymore. Include composer.h instead.
# endif
#endif

#include "composer.h"
#include "messagesender.h"

#include <set>

#include <tqlabel.h>
#include <tqlistview.h>

#include <tqcheckbox.h>
#include <tqpushbutton.h>
#include <tqclipboard.h>
#include <tqpalette.h>
#include <tqfont.h>
#include <tqptrlist.h>
#include <tqvaluevector.h>
#include <tqsplitter.h>

#include <tdeio/job.h>
#include <kglobalsettings.h>
#include <tdeversion.h>
#include <keditcl.h>
#include <ktempdir.h>

#include "mailcomposerIface.h"
#include "accountmanager.h"

#include <libtdepim/addresseelineedit.h>
#include <mimelib/mediatyp.h>

#include <kleo/enum.h>

class TQCloseEvent;
class TQComboBox;
class TQFrame;
class TQGridLayout;
class TQListView;
class TQPopupMenu;
class TQPushButton;
class TQCString;
class TDECompletion;
class KMEdit;
class KMComposeWin;
class KMFolderComboBox;
class KMFolder;
class KMMessage;
class KMMessagePart;
class TDEProcess;
class KDirWatch;
class TDESelectAction;
class TDEFontAction;
class TDEFontSizeAction;
class TDESelectAction;
class KStatusBar;
class TDEAction;
class TDEToggleAction;
class KTempFile;
class TDEToolBar;
class TDEToggleAction;
class TDESelectColorAction;
class KURL;
class TDERecentFilesAction;
class SpellingFilter;
class MessageComposer;
class RecipientsEditor;
class KMLineEdit;
class KMLineEditSpell;
class KMAtmListViewItem;
class SnippetWidget;

namespace KPIM {
  class IdentityCombo;
  class Identity;
}

namespace KMail {
  class AttachmentListView;
  class DictionaryComboBox;
  class EditorWatcher;
}

namespace GpgME {
  class Error;
}

//-----------------------------------------------------------------------------
class KMComposeWin : public KMail::Composer, public MailComposerIface
{
  Q_OBJECT
  
  friend class ::KMEdit;
  friend class ::MessageComposer;

private: // mailserviceimpl, kmkernel, kmcommands, callback, kmmainwidget
  KMComposeWin( KMMessage* msg=0, uint identity=0 );
  ~KMComposeWin();
public:
  static Composer * create( KMMessage * msg = 0, uint identity = 0 );

  MailComposerIface * asMailComposerIFace() { return this; }
  const MailComposerIface * asMailComposerIFace() const { return this; }

public: // mailserviceimpl
  /**
   * From MailComposerIface
   */
  void send(int how);
  void addAttachmentsAndSend(const KURL::List &urls, const TQString &comment, int how);
  void addAttachment(KURL url,TQString comment);
  void addAttachment(const TQString &name,
                    const TQCString &cte,
                    const TQByteArray &data,
                    const TQCString &type,
                    const TQCString &subType,
                    const TQCString &paramAttr,
                    const TQString &paramValue,
                    const TQCString &contDisp);
public: // kmcommand
  void setBody (TQString body);

private:
  /**
   * To catch palette changes
   */
  virtual bool event(TQEvent *e);

  /**
   * update colors
   */
  void readColorConfig();

  /**
   * Write settings to app's config file.
   */
   void writeConfig(void);

  /**
   * If necessary increases the word wrap of the editor so that it will
   * not wrap the body string
   */
   void verifyWordWrapLengthIsAdequate(const TQString&);

public: // kmkernel, kmcommands, callback
  /**
   * Set the message the composer shall work with. This discards
   * previous messages without calling applyChanges() on them before.
   */
   void setMsg(KMMessage* newMsg, bool mayAutoSign=TRUE,
	       bool allowDecryption=FALSE, bool isModified=FALSE);

   void disableWordWrap();

  /** Don't check if there are too many recipients for a mail,
   * eg. when sending out invitations.
   */
  void disableRecipientNumberCheck();

  /** Don't check for forgotten attachments for a mail,
   * eg. when sending out invitations.
   */
  void disableForgottenAttachmentsCheck();

  /**
   * Ignore the "sticky" setting of the transport combo box and prefer the X-KMail-Transport
   * header field of the message instead.
   * Do the same for the identity combo box, don't obey the "sticky" setting but use the
   * X-KMail-Identity header field instead.
   *
   * This is useful when sending out invitations, since you don't see the GUI and want the
   * identity and transport to be set to the values stored in the messages.
   */
  void ignoreStickyFields();

   /**
    * Returns @c true while the message composing is in progress.
    */
   bool isComposing() const { return mComposer != 0; }

private: // kmedit
  /**
   * Returns message of the composer. To apply the user changes to the
   * message, call applyChanges() first.
   */
   KMMessage* msg() const { return mMsg; }

public: // kmkernel
  /**
   * Set the filename which is used for autosaving.
   */
  void setAutoSaveFilename( const TQString & filename );

private:
  /**
   * Returns true if the message was modified by the user.
   */
  bool isModified() const;

  /**
   * Set whether the message should be treated as modified or not.
   */
  void setModified( bool modified );

public: // kmkernel, callback
  /**
   * If this flag is set the message of the composer is deleted when
   * the composer is closed and the message was not sent. Default: FALSE
   */
   inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }

  /**
   * If this flag is set, the compose window will delete itself after
   * the window has been closed.
   */
  void setAutoDeleteWindow( bool f );

public: // kmcommand
  /**
   * If this folder is set, the original message is inserted back after
   * cancelling
   */
   void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
public: // kmkernel, kmcommand, mailserviceimpl
  /**
   * Recode to the specified charset
   */
   void setCharset(const TQCString& aCharset, bool forceDefault = FALSE);

public: // kmcommand
  /**
   * Sets the focus to the edit-widget and the cursor below the
   * "On ... you wrote" line when hasMessage is true.
   * Make sure you call this _after_ setMsg().
   */
   void setReplyFocus( bool hasMessage = true );

  /**
   * Sets the focus to the subject line edit. For use when creating a
   * message to a known recipient.
   */
   void setFocusToSubject();

private:
  /**
   * determines whether inline signing/encryption is selected
   */
   bool inlineSigningEncryptionSelected();

   /**
    * Tries to find the given mimetype @p type in the KDE Mimetype registry.
    * If found, returns its localized description, otherwise the @p type
    * in lowercase.
    */
   static TQString prettyMimeType( const TQString& type );
    TQString quotePrefixName() const;

private: // kmedit:
  KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
  void setSubjectTextWasSpellChecked( bool _spell ) {
    mSubjectTextWasSpellChecked = _spell;
  }
  bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }

  void paste( TQClipboard::Mode mode );

public: // callback
  /** Disabled signing and encryption completely for this composer window. */
  void setSigningAndEncryptionDisabled( bool v )
  {
    mSigningAndEncryptionExplicitlyDisabled = v;
  }

private slots:
  void polish();
  /**
   * Actions:
   */
  void slotPrint();
  void slotAttachFile();
  void slotInsertRecentFile(const KURL&);
  void slotAttachedFile(const KURL&);
public slots: // kmkernel, callback
  void slotSendNow();
private slots:
  void slotSendNowVia( int item );
  void slotSendLater();
  void slotSendLaterVia( int item );

  void getTransportMenu();

  /**
   * Returns true when saving was successful.
   */
  void slotSaveDraft();
  void slotSaveTemplate();
  void slotNewComposer();
  void slotNewMailReader();
  void slotClose();
  void slotHelp();

  void slotFind();
  void slotSearchAgain();
  void slotReplace();
  void slotUndo();
  void slotRedo();
  void slotCut();
  void slotCopy();
  void slotPasteClipboard();
  void slotPasteClipboardAsQuotation();
  void slotPasteClipboardAsAttachment();
  void slotAddQuotes();
  void slotRemoveQuotes();
  void slotAttachPNGImageData(const TQByteArray &image);

  void slotMarkAll();

  void slotFolderRemoved(KMFolder*);

  void slotEditDone( KMail::EditorWatcher* watcher );

public slots: // kmkernel
  /**
     Tell the composer to always send the message, even if the user
     hasn't changed the next. This is useful if a message is
     autogenerated (e.g., via a DCOP call), and the user should
     simply be able to confirm the message and send it.
  */
  void slotSetAlwaysSend( bool bAlwaysSend );
private slots:
  /**
   * toggle fixed width font.
   */
  void slotUpdateFont();

  /**
   * Open addressbook editor dialog.
   */
  void slotAddrBook();
  /**
   * Insert a file to the end of the text in the editor.
   */
  void slotInsertFile();

  void slotSetCharset();
  /**
   * Check spelling of text.
   */
  void slotSpellcheck();
  void slotSpellcheckConfig();
  void slotSubjectTextSpellChecked();

  /**
   * Change crypto plugin to be used for signing/encrypting messages,
   * or switch to built-in OpenPGP code.
   */
  void slotSelectCryptoModule( bool init = false );

  /**
   * XML-GUI stuff
   */
  void slotStatusMessage(const TQString &message);
  void slotEditToolbars();
  void slotUpdateToolbars();
  void slotEditKeys();
  /**
   * Read settings from app's config file.
   */
  void readConfig( bool reload = false );
  /**
   * Change window title to given string.
   */
  void slotUpdWinTitle(const TQString& );

  /**
   * Switch the icon to lock or unlock respectivly.
   * Change states of all encrypt check boxes in the attachments listview
   */
  void slotEncryptToggled(bool);

  /**
   * Change states of all sign check boxes in the attachments listview
   */
  void slotSignToggled(bool);

public slots: // kmkernel, callback
  /**
   * Switch wordWrap on/off
   */
  void slotWordWrapToggled(bool);

private slots:
  /**
   * Append signature file to the end of the text in the editor.
   */
  void slotAppendSignature();

  /**
   * Prepend signature file at the beginning of the text in the editor.
   */
  void slotPrependSignature();

  /**
   * Insert signature file at the cursor position of the text in the editor.
   */
  void slotInsertSignatureAtCursor();

  /**
   * Attach sender's public key.
   */
  void slotInsertMyPublicKey();

  /**
   * Insert arbitary public key from public keyring in the editor.
   */
  void slotInsertPublicKey();

  /**
   * Enable/disable some actions in the Attach menu
   */
  void slotUpdateAttachActions();

  /**
   * Open a popup-menu in the attachments-listbox.
   */
  void slotAttachPopupMenu(TQListViewItem *, const TQPoint &, int);

  /**
   * Returns the number of the current attachment in the listbox,
   * or -1 if there is no current attachment
   */
  int currentAttachmentNum();

  /**
   * Attachment operations.
   */
  void slotAttachOpen();
  void slotAttachView();
  void slotAttachRemove();
  void slotAttachSave();
  void slotAttachProperties();
  void slotAttachOpenWith();
  void slotAttachEdit();
  void slotAttachEditWith();
  void slotAttachmentDragStarted();

  /**
   * Select an email from the addressbook and add it to the line
   * the pressed button belongs to.
   */
  void slotAddrBookTo();
  void slotAddrBookFrom();
  void slotAddrBookReplyTo();

  void slotCleanSpace();

  void slotToggleMarkup();
  void toggleMarkup(bool markup);
  void htmlToolBarVisibilityChanged( bool visible );

//  void slotSpellConfigure();
  void slotSpellcheckDone(int result);
  void slotSpellcheckDoneClearStatus();

public slots: // kmkernel
  void autoSaveMessage();

private slots:
  void updateCursorPosition();

  void slotView();

  /**
   * Update composer field to reflect new identity
   */
  void slotIdentityChanged(uint);

  /**
   * KIO slots for attachment insertion
   */
  void slotAttachFileData(TDEIO::Job *, const TQByteArray &);
  void slotAttachFileResult(TDEIO::Job *);

  void slotListAction(const TQString &);
  void slotFontAction(const TQString &);
  void slotSizeAction(int);
  void slotAlignLeft();
  void slotAlignCenter();
  void slotAlignRight();
  void slotTextBold();
  void slotTextItalic();
  void slotTextUnder();
  void slotFormatReset();
  void slotTextColor();
  void fontChanged( const TQFont & );
  void alignmentChanged( int );

public: // kmkernel, attachmentlistview
  bool addAttach(const KURL url);

public: // kmcommand
  /**
   * Add an attachment to the list.
   */
  void addAttach(const KMMessagePart* msgPart);

private:
  const KPIM::Identity & identity() const;
  uint identityUid() const;
  Kleo::CryptoMessageFormat cryptoMessageFormat() const;
  bool encryptToSelf() const;

signals:
  void applyChangesDone( bool );
  void attachmentAdded( const KURL&, bool success );

private:
  /**
   * Applies the user changes to the message object of the composer
   * and signs/encrypts the message if activated. Returns FALSE in
   * case of an error (e.g. if PGP encryption fails).
   * Disables the controls of the composer window unless @dontDisable
   * is true.
   */
  void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );

  /**
   * Install grid management and header fields. If fields exist that
   * should not be there they are removed. Those that are needed are
   * created if necessary.
   */
  void rethinkFields(bool fromslot=false);

  /**
    Connect signals for moving focus by arrow keys. Returns next edit.
  */
  TQWidget *connectFocusMoving( TQWidget *prev, TQWidget *next );

  /**
   * Show or hide header lines
   */

  void rethinkHeaderLine( int aValue, int aMask, int& aRow,
                          TQLabel* aLbl,
                          TQLineEdit* aEdt, TQPushButton* aBtn = 0,
                          const TQString &toolTip = TQString(),
                          const TQString &whatsThis = TQString() );

  void rethinkHeaderLine( int value, int mask, int& row,
                          TQLabel* lbl, TQComboBox* cbx, TQCheckBox *chk );

  /**
   * Checks how many recipients are and warns if there are too many.
   * @return true, if the user accepted the warning and the message should be sent
   */
  bool checkRecipientNumber() const;


  bool checkTransport() const;

  /**
   * Initialization methods
   */
  void setupActions();
  void setupStatusBar();
  void setupEditor();


  /**
   * Header fields.
   */
  TQString subject() const;
  TQString to() const;
  TQString cc() const;
  TQString bcc() const;
  TQString from() const;
  TQString replyTo() const;

  /**
   * Use the given folder as sent-mail folder if the given folder exists.
   * Else show an error message and use the default sent-mail folder as
   * sent-mail folder.
   */
  void setFcc( const TQString &idString );

  /**
   * Ask for confirmation if the message was changed before close.
   */
  virtual bool queryClose ();
  /**
   * prevent kmail from exiting when last window is deleted (kernel rules)
  */
  virtual bool queryExit ();

  /**
   * Open the attachment with the given index and with ("Open with")
   */
  void openAttach( int index, bool with );

  /**
   * View the attachment with the given index.
   */
  void viewAttach( int index );

  /**
    Edit the attachment with the given index.
  */
  void editAttach( int index, bool openWith );

  /**
   * Remove an attachment from the list.
   */
   void removeAttach(const TQString &url);
   void removeAttach(int idx);

   /**
    * Updates an item in the TQListView to represnet a given message part
    */
   void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
        bool loadDefaults = true );

  /**
   * Open addressbook and append selected addresses to the given
   * edit field.
   */
  void addrBookSelInto();

  void addrBookSelIntoOld();
  void addrBookSelIntoNew();

private:
  /**
   * Turn encryption on/off. If setByUser is true then a message box is shown
   * in case encryption isn't possible.
   */
  void setEncryption( bool encrypt, bool setByUser = false );

  /**
   * Turn signing on/off. If setByUser is true then a message box is shown
   * in case signing isn't possible.
   */
  void setSigning( bool sign, bool setByUser = false );

  /**
     Returns true if the user forgot to attach something.
  */
  bool userForgotAttachment();

  /**
   * Retrieve encrypt flag of an attachment
   * ( == state of it's check box in the attachments list view )
   */
  bool encryptFlagOfAttachment(int idx);

  /**
   * Retrieve sign flag of an attachment
   * ( == state of it's check box in the attachments list view )
   */
  bool signFlagOfAttachment(int idx);


  /**
   * Decrypt an OpenPGP block or strip off the OpenPGP envelope of a text
   * block with a clear text signature. This is only done if the given
   * string contains exactly one OpenPGP block.
   * This function is for example used to restore the unencrypted/unsigned
   * message text for editting.
   */
  static void decryptOrStripOffCleartextSignature( TQCString& );

  /**
   * Save the message into the Drafts or Templates folder.
   */
  bool saveDraftOrTemplate( const TQString &folderName, KMMessage *msg );

  /**
   * Send the message. Returns true if the message was sent successfully.
   */
  enum SaveIn { None, Drafts, Templates };
  void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
               KMComposeWin::SaveIn saveIn = KMComposeWin::None );

  /**
   * Returns the autosave interval in milliseconds (as needed for TQTimer).
   */
  int autoSaveInterval() const;

  /**
   * Initialize autosaving (timer and filename).
   */
  void initAutoSave();

  /**
   * Enables/disables autosaving depending on the value of the autosave
   * interval.
   */
  void updateAutoSave();

  /**
   * Stop autosaving and delete the autosaved message.
   */
  void cleanupAutoSave();

  /**
   * Validates a list of email addresses.
   * @return true if all addresses are valid.
   * @return false if one or several addresses are invalid.
   */
  static bool validateAddresses( TQWidget * parent, const TQString & addresses );

  /**
   * Sets the transport combobox to @p transport. If @p transport is empty
   * then the combobox remains unchanged. If @p transport is neither a known transport
   * nor a custom transport then the combobox is set to the default transport.
   * @param transport the transport the combobox should be set to
   */
  void setTransport( const TQString & transport );

  enum SignaturePlacement { Append, Prepend, AtCursor };

  /**
   * Helper to insert the signature of the current identy at the
   * beginning or end of the editor.
   */
  void insertSignature( SignaturePlacement placement = Append );
private slots:
   /**
    * Compress an attachemnt with the given index
    */
    void compressAttach(int idx);
    void uncompressAttach(int idx);
    void editorFocusChanged(bool gained);
    void recipientEditorSizeHintChanged();
    void setMaximumHeaderSize();

private:
  TQWidget   *mMainWidget;
  TQComboBox *mTransport;
  KMail::DictionaryComboBox *mDictionaryCombo;
  KPIM::IdentityCombo    *mIdentity;
  KMFolderComboBox *mFcc;
  KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
  KMLineEditSpell *mEdtSubject;
  TQLabel    *mLblIdentity, *mLblTransport, *mLblFcc;
  TQLabel    *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
  TQLabel    *mDictionaryLabel;
  TQCheckBox *mBtnIdentity, *mBtnDictionary, *mBtnTransport, *mBtnFcc;
  TQPushButton *mBtnTo, *mBtnCc, *mBtnBcc, /* *mBtnFrom, */ *mBtnReplyTo;
  bool mSpellCheckInProgress;
  bool mDone;
  bool mAtmModified;
  TQListViewItem *mAtmSelectNew;

  KMEdit* mEditor;
  TQGridLayout* mGrid;
  KMMessage *mMsg;
  TQValueVector<KMMessage*> mComposedMessages;
  KMail::AttachmentListView* mAtmListView;
  int mAtmColEncrypt;
  int mAtmColSign;
  int mAtmColCompress;
  int mAtmEncryptColWidth;
  int mAtmSignColWidth;
  int mAtmCompressColWidth;
  TQPtrList<TQListViewItem> mAtmItemList;
  TQPtrList<KMMessagePart> mAtmList;
  TQPopupMenu *mAttachMenu;
  int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId, mEditId, mEditWithId;
  bool mAutoDeleteMsg;
  bool mSigningAndEncryptionExplicitlyDisabled;
  bool mLastSignActionState, mLastEncryptActionState;
  bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
  KMFolder *mFolder;
  long mShowHeaders;
  bool mConfirmSend;
  bool mDisableBreaking; // Move
  int mNumHeaders;
  bool mUseHTMLEditor;
  bool mHtmlMarkup;
  TQFont mBodyFont, mFixedFont;
  TQPtrList<KTempFile> mAtmTempList;
  TQPalette mPalette;
  uint mId;
  TQString mOldSigText;

  TDEAction *mAttachPK, *mAttachMPK,
          *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
          *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
  TDERecentFilesAction *mRecentAction;

  TDEAction *mAppendSignatureAction, *mPrependSignatureAction, *mInsertSignatureAction;

  TDEToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
  TDEToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
  TDEToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
  TDEToggleAction *mSubjectAction;
  TDEToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
  TDEToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
  TDEToggleAction *mDictionaryAction, *mSnippetAction;

  TDESelectAction *listAction;
  TDEFontAction *fontAction;
  TDEFontSizeAction *fontSizeAction;
  TDEToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
  TDEToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
  TDEToggleAction *plainTextAction, *markupAction;
  TDEAction *actionFormatColor, *actionFormatReset;
  TDEAction *mHtmlToolbar;

  TDESelectAction *mEncodingAction;
  TDESelectAction *mCryptoModuleAction;

  TQCString mCharset;
  TQCString mDefCharset;
  TQStringList mCharsets;
  bool mAutoCharset;

  bool mAlwaysSend;

  TQStringList mFolderNames;
  TQValueList<TQGuardedPtr<KMFolder> > mFolderList;
  TQMap<TDEIO::Job*, KURL> mAttachJobs;
  KURL::List mAttachFilesPending;
  int mAttachFilesSend;

private:
  // helper method for slotInsert(My)PublicKey()
  void startPublicKeyExport();
  bool canSignEncryptAttachments() const {
    return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
  }

  bool mSubjectTextWasSpellChecked;

  TQString addQuotesToText( const TQString &inputText );
  TQString removeQuotesFromText( const TQString &inputText );
  // helper method for rethinkFields
  int calcColumnWidth(int which, long allShowing, int width);

private slots:
  void slotCompletionModeChanged( TDEGlobalSettings::Completion );
  void slotConfigChanged();

  void slotComposerDone( bool );

  void slotContinueDoSend( bool );
  void slotContinuePrint( bool );
  void slotContinueAutoSave();

  void slotEncryptChiasmusToggled( bool );

  /**
   * Helper method (you could call is a bottom-half :) for
   * startPublicKeyExport()
   */
  void slotPublicKeyExportResult( const GpgME::Error & err, const TQByteArray & keydata );

  /**
   *  toggle automatic spellchecking
   */
  void slotAutoSpellCheckingToggled(bool);

  /**
   *  Updates signature actions when identity changes.
   */
  void slotUpdateSignatureActions();

  /**
   * Updates the visibility and text of the signature and encryption state indicators.
   */
  void slotUpdateSignatureAndEncrypionStateIndicators();
private:
  TQColor mForeColor,mBackColor;
  TQFont mSaveFont;
  TQSplitter *mHeadersToEditorSplitter;
  TQWidget* mHeadersArea;
  TQSplitter *mSplitter;
  TQSplitter *mSnippetSplitter;
  struct atmLoadData
  {
    KURL url;
    TQByteArray data;
    bool insert;
    TQCString encoding;
  };
  TQMap<TDEIO::Job *, atmLoadData> mMapAtmLoadData;

  // These are for passing on methods over the applyChanges calls
  KMail::MessageSender::SendMethod mSendMethod;
  KMComposeWin::SaveIn mSaveIn;

  TDEToggleAction *mEncryptChiasmusAction;
  bool mEncryptWithChiasmus;

  // This is the temporary object that constructs the message out of the
  // window
  MessageComposer* mComposer;

  // Temp var for slotPrint:
  bool mMessageWasModified;

  // Temp var for slotInsert(My)PublicKey():
  TQString mFingerprint;

  // Temp ptr for saving image from clipboard
  KTempDir *mTempDir;

  bool mClassicalRecipients;

  RecipientsEditor *mRecipientsEditor;
  int mLabelWidth;

  TQTimer *mAutoSaveTimer;
  TQString mAutoSaveFilename;
  int mLastAutoSaveErrno; // holds the errno of the last try to autosave

  TQPopupMenu *mActNowMenu;
  TQPopupMenu *mActLaterMenu;

  TQMap<KMail::EditorWatcher*, KMMessagePart*> mEditorMap;
  TQMap<KMail::EditorWatcher*, KTempFile*> mEditorTempFiles;

  TQLabel *mSignatureStateIndicator;
  TQLabel *mEncryptionStateIndicator;

  SnippetWidget *mSnippetWidget;
  std::set<KTempDir*> mTempDirs;

  /** If the message in this composer has a cursor position set (for
   *   instance because it comes from a template containing %CURSOR)
   *   then we need to preserve that cursor position even when auto-
   *   appending (or prepending) the signature during composer setup.
   *   Set to true *once* (and only in setMsg() at that) to avoid
   *   accidentally moving the cursor.
   */
  bool mPreserveUserCursorPosition;

  bool mPreventFccOverwrite;
  bool mCheckForRecipients;
  bool mCheckForForgottenAttachments;
  bool mIgnoreStickyFields;
};

#endif