home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / ftp.vapor.com / microdot-1 / md1_src_02.lzx / sendwin.c < prev    next >
C/C++ Source or Header  |  2014-05-19  |  26KB  |  1,119 lines

  1. #include "microdot.h"
  2.  
  3. #include "ogre.h"
  4. #include "ogre_protos.h"
  5.  
  6. #define GID_LV 56
  7. #define GID_EMPS 55
  8. #define GID_LVNEU 16
  9. #define GID_LVBRETT 17
  10. #define GID_LVUSER 18
  11. #define GID_LVLOESCH 19
  12. #define GID_CBZ00        9
  13. #define GID_CBDIREKT    3
  14. #define GID_CBCLEARBEZ    4
  15. #define GID_CBBIN        8
  16. #define GID_CBEB        1
  17. #define GID_EBWAITDAYS  2
  18.  
  19. #define GID_BETREFF 60
  20. #define GID_COMMENT 61
  21. #define GID_DISKUIN 62
  22. #define GID_DISKUINSEL 63
  23. #define GID_DISKUINME 64
  24.  
  25. #define GID_BINFILE 70
  26. #define GID_BINNAME 71
  27. #define GID_BINDATE 72
  28. #define GID_BINFILESEL 73
  29.  
  30. #define GID_SEND 15
  31. #define GID_EDIT 14
  32. #define GID_EDITCOMMENT 30
  33. #define GID_EDITHEADER 32
  34. #define GID_CANCEL 13
  35.  
  36. #define GID_INFO 31
  37. #define GID_PGP 33
  38. #define GID_SENDHOLD 34
  39.  
  40. static char *mailbetreff,*windowtitle,*mailcomment,**empliste,*mailbezug,*maildiskin;
  41. static long mailflags;
  42.  
  43. static char *moab;
  44. static char *mqbez;
  45. static char **moem;
  46. static char *quoteid;
  47. static char *mfto;
  48.  
  49. static int pgp_sign, pgp_addkey, pgp_nocrypt;
  50.  
  51. long str2dat(char *date)
  52. {
  53.     char x[6],*p,*p2;
  54.     int c;
  55.  
  56.     memset(x,0,6);
  57.     if(!date) return(0);
  58.     date=stpblk(date);
  59.     if(!date[0]) return(0);
  60.  
  61.     /* zuerst zeit */
  62.     p=strchr(date,':');
  63.     if(p) {
  64.         p2=p-1;
  65.         while(isdigit(*p2)) p2--;
  66.         x[4]=atoi(++p);
  67.         x[3]=atoi(++p2);
  68.         p=strchr(p,':');
  69.         if(p) x[5]=atoi(++p);
  70.     }
  71.  
  72.     /* datum */
  73.     p=strchr(date,'.');
  74.     if(p) {
  75.         p2=p-1;
  76.         while(isdigit(*p2)) p2--;
  77.         x[1]=atoi(++p);
  78.         x[2]=atoi(++p2);
  79.         p=strchr(p,'.');
  80.         if(p) {
  81.             c=atoi(++p);
  82.             if(c>1970) c-=1970; else c-=70;
  83.             x[0]=c;
  84.         }
  85.     }
  86.  
  87.     return(utpack(x));
  88. }
  89.  
  90. char *dat2str(long t)
  91. {
  92.     static char ds[32];
  93.     char x[6];
  94.  
  95.     utunpk(t,x);
  96.  
  97.     sprintf(ds,"%02ld.%02ld.%ld %02ld:%02ld:%02ld",
  98.         x[2],x[1],x[0]+1970,x[3],x[4],x[5]);
  99.     return(ds);
  100. }
  101.  
  102. /*void linkmail(char *from,char *to)
  103. {
  104.     BPTR l;
  105.     int rc;
  106.  
  107.     if( !isv37 || ( prefs.flags2 & MDF2_NOLINKS ) )
  108.     {
  109.         copyfile( from, to );
  110.         return;
  111.     }
  112.  
  113.     l = Lock( from, SHARED_LOCK );
  114.     if( !l )
  115.         return;
  116.     DeleteFile( to );
  117.     rc = MakeLink( to, l, 0 );
  118.     UnLock( l );
  119.     if( !rc )
  120.         copyfile( from, to );
  121. }
  122. */
  123.  
  124. struct emp
  125. {
  126.     struct MinNode n;
  127.     char emp[ 256 ];
  128.     char pgpid[ 256 ];
  129. };
  130.  
  131. #define SF_PM 1
  132. #define SF_PGP 2
  133.  
  134. static int reallysendmails(struct ogwin *ogw, struct hlist *addhlist, struct List *emplist, int flags, int binmail, int hold )
  135. {
  136.     char path2[256];
  137.     int c,d;
  138.     char *p,**sppp;
  139.     struct mbrett *sp;
  140.     char tmp[44];
  141.     struct emp *emp;
  142.     struct hlist *hlist;
  143.     struct pindex *pix;
  144.     struct mail new, newpm;
  145.     int oldhold;
  146.  
  147.     if( binmail )
  148.     {
  149.         if( !moab )
  150.             p = ogreStringValue( ogw, GID_BINFILE );
  151.         else p = TMPMSGNAME;
  152.         c = getfilelen(p);
  153.         if( c<1 )
  154.         {
  155.             c = IoErr();
  156.             askreq("Fehler beim Verschicken:\nImportdatei '%s'\nlΣ▀t sich nicht ÷ffnen (%ld)\n%s\n\nPrⁿfen Sie, ob der Dos-Pfad fⁿr die zu verschickende Datei\nrichtig eingetragen ist.","Abbruch",p, c, errorstring(c) );
  157.             return(0);
  158.         }
  159.     }
  160.     else
  161.     {
  162.         c=getfilelen( TMPMSGNAME );
  163.         if(c<1)
  164.         {
  165.             c = IoErr();
  166.             askreq("Fehler beim Verschicken:\nDatei '" TMPMSGNAME "'\nlΣ▀t sich nicht ÷ffnen (%ld)\n%s\n\nBitte stellen Sie sicher, da▀ Sie\neinen Nachrichtentext eingegeben haben.","Abbruch",c, errorstring(c) );
  167.             return(0);
  168.         }
  169.     }
  170.  
  171.     sp = findbrett( "/╗SPOOL", 0 );
  172.     if( !sp )
  173.     {
  174.         askreq( "Interner Versandfehler:\nSpoolbrett nicht gefunden.", "Abbruch" );
  175.         return( NULL );
  176.     }
  177.  
  178.     //str2_7bit( ogreStringValue( ogw, GID_BETREFF ), path2 );
  179.  
  180.     /* Header schreiben */
  181.     makedateheader( tmp, time(0) );
  182.  
  183.     /* Datum auf 0 setzen */
  184.     if( prefs.flags & MDF_TIME00 )
  185.         memset( &tmp[8], '0', 6 );
  186.  
  187.     hlist = hl_initheader();
  188.     if( !hlist )
  189.     {
  190.         askreq( "Interner Versandfehler:\nKein Speicher fⁿr die Headererzeugung.", "Abbruch" );
  191.         return( NULL );
  192.     }
  193.  
  194.     if( pgpavail )
  195.     {
  196.         if( pgp_sign )
  197.             hl_addheader( hlist, "SIGNED", "PGP" );
  198.     }
  199.  
  200.     if( pgp_nocrypt )
  201.         hl_addheader( hlist, "STAT", "NOCIPHER" );
  202.  
  203.     hl_addheader( hlist, "BET", ogreStringValue( ogw, GID_BETREFF ) );
  204.     hl_addheader( hlist, "MID", makemid() );
  205.     hl_addheader( hlist, "EDA", tmp );
  206.  
  207.     p = ogreStringValue( ogw, GID_COMMENT );
  208.     if(p && p[0])
  209.     {
  210.         //str2_7bit( p, path2 );
  211.         hl_addheader( hlist, "ZUSAMMENFASSUNG", p );
  212.     }
  213.  
  214.     p = ogreStringValue( ogw, GID_DISKUIN );
  215.     if(p && p[0])
  216.         hl_addheader( hlist, "DISKUSSION-IN", stpblk(p));
  217.  
  218.     p = ogreStringValue( ogw, GID_BINNAME );
  219.     if(p && p[0])
  220.         hl_addheader( hlist, "FILE", stpblk(p));
  221.  
  222.     /* Empfangsbestaetigung? */
  223.     if( ( flags & SF_PM ) && ( prefs.flags & MDF_EB ) )
  224.         hl_addheader( hlist, "EB", "" );
  225.  
  226.     if( moab && moab[0] )
  227.     {
  228.         hl_addheader( hlist, "OAB", moab );
  229.         sppp=moem;
  230.         while(*sppp) 
  231.             hl_addheader( hlist, "OEM", *sppp++ );
  232.     }
  233.  
  234.     /* Direkt? */
  235.     if( ( flags & SF_PM ) && ogreValue( ogw, GID_CBDIREKT ) )
  236.         hl_addheader( hlist, "PRIO", "10" );
  237.  
  238.     if( flags & SF_PGP )
  239.     {
  240.         if( binmail == 1 )
  241.         {
  242.             hl_addheader( hlist, "CRYPT-CONTENT-TYP", "BIN" );
  243.             hl_addheader( hlist, "TYP", "BIN" );
  244.         }
  245.         hl_addheader( hlist, "CRYPT", "PGP" );
  246.     }
  247.     else
  248.     {
  249.         /* Bin? */
  250.         if( binmail == 1 )
  251.             hl_addheader( hlist, "TYP", "BIN" );
  252.     }
  253.     
  254.     /* Quote-ID */
  255. #if 0
  256.     if(quoteid)
  257.         hl_addheader( hlist, "X-QUOTE", quoteid );
  258. #endif
  259.  
  260.     /* Bezuge */
  261.     if( mailbezug && !ogreValue( ogw, GID_CBCLEARBEZ ) )
  262.     {
  263.         if( mqbez )
  264.             hl_addheader( hlist, "BEZ", mqbez );
  265.         hl_addheader( hlist, "BEZ", mailbezug );
  266.         if( mfto )
  267.             hl_addheader( hlist, "F-TO", mfto );
  268.     }
  269.  
  270.     /* PGP */
  271.     if( pgp_addkey )
  272.         pgp_addpubkey( hlist );
  273.     else if( pgpavail )
  274.         hl_addheader( hlist, "PGP-KEY-AVAIL", prefs.pgp_avail );
  275.  
  276.     /* EMPs */
  277.     emp = (struct emp *) emplist->lh_Head;
  278.     while( emp->n.mln_Succ )
  279.     {
  280.         hl_addheader( hlist, "EMP", emp->emp );
  281.         emp = (struct emp *) emp->n.mln_Succ;
  282.     }
  283.  
  284.     /* ZusΣtzliche */
  285.     if( addhlist )
  286.     {
  287.         struct header *h = hl_findheader( addhlist, NULL );
  288.  
  289.         while( h )
  290.         {
  291.             hl_addheader( hlist, h->head, h->data );
  292.             h = hl_nextheader( h );
  293.         }
  294.     }
  295.  
  296.     /* weiter */
  297.  
  298.     p = TMPMSGNAME;
  299.     if( binmail && !moab )
  300.         p = ogreStringValue( ogw, GID_BINFILE );
  301.  
  302.     memset( &new, 0, sizeof( new ) );
  303.     header2mail( hlist, &new );
  304.  
  305.     if( getfilelen( TMPCOMMENTNAME ) > 0 )
  306.         pix = msg_store( TMPCOMMENTNAME, -1, p, -1,
  307.             &new.pufferID, &new.mailID, hlist );
  308.     else
  309.         pix = msg_store( NULL, 0, p, -1,
  310.             &new.pufferID, &new.mailID, hlist );
  311.  
  312.     if( !pix )
  313.     {
  314.         hl_freeheader( hlist );
  315.         askreq( "Interner Versandfehler.", "Abbruch" );
  316.         return( 0 );
  317.     }
  318.  
  319.     /*new.maillen = pix->datasize + pix->commentsize;*/
  320.     new.maillen = getfilelen( p );
  321.  
  322.     /* Spoolbrett */
  323.     oldhold = new.flags & MMF_ARCHIVE;
  324.     if( hold )
  325.         new.flags |= MMF_ARCHIVE;
  326.     else
  327.         new.flags &= ~MMF_ARCHIVE;
  328.     storemail2ix( &new, sp, NULL );
  329.     new.flags |= oldhold;
  330.  
  331.     if( ! ( prefs.flags2 & MDF2_OWNMAILSNEW ) )
  332.     {
  333.         new.flags &= ~ MMF_UNSEEN;
  334.         new.flags |= MMF_READ;
  335.     }
  336.  
  337. /*    if( prefs.flags2 & MDF2_OWNMAILSREAD )
  338.     {
  339.         new.flags |= MMF_READ;
  340.     }*/
  341.  
  342.     /* Nun in die Bretter */
  343.  
  344.     newpm = new;
  345.  
  346.     sprintf( new.absender, "%s@%s%s", prefs.username, ISRFC ? prefs.pointname : prefs.boxname, prefs.boxdomain );
  347.     strcpy( new.absenderreal, prefs.userrealname );
  348.  
  349.     emp = (struct emp *) emplist->lh_Head;
  350.     d = 0;
  351.     while( emp->n.mln_Succ )
  352.     {
  353.         sp = NULL;
  354.         if( emp->emp[0]=='/' )
  355.         {
  356.             sp = findbrett( emp->emp, 0 );
  357.             retest:
  358.             if(!sp)
  359.             {
  360.                 int r;
  361.                 r = askreq("Warnung:\n%s\nin der EmpfΣngerliste\nist nicht als Brett eingetragen.","Brett eintragen|Ignorieren", emp->emp);
  362.                 if( r )
  363.                 {
  364.                     sp = findbrett( emp->emp, TRUE );
  365.                     sortbrettlist();
  366.                     calcnumentries();
  367.                     makebrettview();
  368.                     goto retest;
  369.                 }
  370.             }
  371.         }
  372.         else if( !d )
  373.         {
  374.             sp = findpmbrett( hlist );
  375.             d = 1;
  376.             storemail2ix( &newpm, sp, NULL );
  377.             if( ! ( prefs.flags2 & MDF2_OWNMAILSNEW ) )
  378.                 sp->b.newmails--;
  379.             if( prefs.flags2 & MDF2_OWNMAILSREAD )
  380.                 sp->b.unreadmails--;
  381.             sp = NULL;
  382.         }
  383.  
  384.         if( sp )
  385.         {
  386.             storemail2ix( &new, sp, NULL );
  387.             if( ! ( prefs.flags2 & MDF2_OWNMAILSNEW ) )
  388.                 sp->b.newmails--;
  389.             if( prefs.flags2 & MDF2_OWNMAILSREAD )
  390.                 sp->b.unreadmails--;
  391.         }
  392.  
  393.         emp = (struct emp *) emp->n.mln_Succ;
  394.     }
  395.  
  396.     hl_freeheader( hlist );
  397.     closeallwriteixfiles();
  398.  
  399.     return(2);
  400. }
  401.  
  402. static int reallysend( struct ogwin *ogw, struct hlist *hlist, int hold )
  403. {
  404.     struct List    brettlist;
  405.     struct List pmlist;
  406.     struct List pgplist;
  407.     void *emppool;
  408.     int bin = ogreValue( ogw, GID_CBBIN );
  409.     int c;
  410.     char tmp[256], *p;
  411.     struct emp *emp;
  412.     int rc;
  413.     struct ogrevn *vn;
  414.  
  415.     ogreCopyStringValue( ogw, GID_BETREFF, tmp );
  416.     if( !tmp[ 0 ]á)
  417.     {
  418.         rc = askreq( "Sie haben keinen Betreff angegeben.", "Trotzdem weiter|Abbruch" );
  419.         if( !rc )
  420.             return( 0 );
  421.     }
  422.  
  423.     NewList( &brettlist );
  424.     NewList( &pmlist );
  425.     NewList( &pgplist );
  426.  
  427.     emppool = LibCreatePool( NULL, 2048, 2048 );
  428.  
  429.     loaduserlist();
  430.  
  431.     for( c = 0; ; c++ )
  432.     {
  433.         vn = ogreLVGetEntry( ogw, GID_LV, c );
  434.         if( !vn )
  435.             break;
  436.         emp = LibAllocPooled( emppool, sizeof( *emp ) );
  437.         strcpy( emp->emp, vn->txt );
  438.         if( emp->emp[0]=='/' )    /* Brett */
  439.         {
  440.             strupr(emp->emp);
  441.             AddTail( &brettlist, (struct Node *) emp );
  442.             continue;
  443.         }
  444.         else /* PM */
  445.         {
  446.             struct user u;
  447.  
  448. /*            strcpy( tmp, emp->emp );
  449.             p = strchr( tmp, ' ' );
  450.             if( p )
  451.                 *p = 0;*/
  452.             if( !pgp_nocrypt && !getuser( emp->emp, &u ) && ( u.flags & UF_PGP ) )
  453.                 AddTail( &pgplist, (struct Node *) emp );
  454.             else
  455.                 AddTail( &pmlist, (struct Node *) emp );
  456.         }
  457.     }
  458.  
  459.     /* Gut, die EmpfΣngerlisten stehen bereit */
  460.  
  461.     freeuserlist( FALSE );
  462.  
  463.     rc = 0;
  464.  
  465.     if( !IsListEmpty( &pmlist ) )
  466.         rc |= reallysendmails( ogw, hlist, &pmlist, SF_PM, bin, hold );
  467.  
  468.     if( !IsListEmpty( &pgplist ) )
  469.         rc |= reallysendmails( ogw, hlist, &pgplist, SF_PM | SF_PGP, bin, hold );
  470.  
  471.     if( !IsListEmpty( &brettlist ) )
  472.         rc |= reallysendmails( ogw, hlist, &brettlist, 0, bin, hold );
  473.  
  474.     LibDeletePool( emppool );
  475.  
  476.     if( !c )
  477.         askreq( "Sie haben keine EmpfΣnger angegeben!", "Abbruch" );
  478.  
  479.     return( rc );
  480. }
  481.  
  482.  
  483. static char *bin_options[] = { "Text", "BinΣr", "Textdatei", NULL };
  484.  
  485. /*static char *signmodes[] = { "Clearsig (lesbar)", "Voll (unlesbar)", "Nein", NULL };*/
  486.  
  487. #define PS_OK 1
  488. #define PS_NOCRYPT 2
  489. #define PS_SIGN 3
  490. #define PS_ADDKEY 4
  491.  
  492. static void setpgp( void )
  493. {
  494.     struct ogwin *ogw;
  495.     struct IntuiMessage *im;
  496.     struct Window *iw;
  497.     int Done = FALSE;
  498.  
  499.     ogw = ogreInitWindow( scr, WFLG_RMBTRAP, 0, "PGP-Status" );
  500.  
  501.     ogreAddGroup( ogw, 0 | OGGP_EXPANDSTRING, OGFRAME_OUTLINE, NULL );
  502.  
  503.     ogreAddCheckbox( ogw, 0, 'k', "Eigenen _Key anfⁿgen:", PS_ADDKEY, pgp_addkey );
  504.     ogreAddCheckbox( ogw, 1, 'n', "Nachricht _nicht verschlⁿsseln:", PS_NOCRYPT, pgp_nocrypt );
  505.     ogreAddCheckbox( ogw, 2, 's', "Nachricht _signieren:", PS_SIGN, pgp_sign );
  506. //    ogreAddCycle( ogw, 2, 's', "Nachricht _signieren:", PS_SIGN, signmodes, 20, pgp_sign );
  507.  
  508.     ogreAddGroup( ogw, 1, OGFRAME_NONE, NULL );
  509.     ogreAddButton( ogw, 0 | OGB_ONENTER, 'o', "_OK", PS_OK );
  510.  
  511.     iw = ogreOpenWindow( ogw );
  512.     if( !iw )
  513.         return;
  514.  
  515.     while( !Done )
  516.     {
  517.         while( ( im = ogreIM( ogw ) ) )
  518.         {
  519.             if( im->Class == IDCMP_GADGETHELP)
  520.                 showguidenum( "editpgp_gads", im->Code );
  521.             else if( im->Class == GADGETUP )
  522.             {
  523.                 switch( im->Code )
  524.                 {
  525.                     case PS_OK:
  526.                         Done = 1;
  527.                         break;
  528.  
  529.                 }
  530.             }
  531.         }
  532.     }
  533.  
  534.     pgp_addkey = ogreValue( ogw, PS_ADDKEY );
  535.     pgp_sign = ogreValue( ogw, PS_SIGN );
  536.     pgp_nocrypt = ogreValue( ogw, PS_NOCRYPT );
  537.  
  538.     ogreExitWindow( ogw );
  539. }
  540.  
  541. int sendwinauto;
  542. int dosendwin( 
  543.     char *title,
  544.     char *betreff,
  545.     char *comment,
  546.     char *bezug,
  547.     char **emp,
  548.     long flags,
  549.     char *oab,
  550.     char **oem,
  551.     char *diskin,
  552.     char *quote,
  553.     char *qbez,
  554.     char *binfile,
  555.     char *fileheader,
  556.     char *ftoheader
  557. )
  558. {
  559.     struct IntuiMessage *im;
  560.     struct ogwin *ogw;
  561.     struct ogrevn *vn;
  562.     struct Window *iw;
  563.     int Done = FALSE;
  564.     int bin = flags;
  565.     int isediting = -1;
  566.     char *p;
  567.     void *rtwinlock;
  568.     long tv;
  569.     struct MsgPort *awmp = NULL;
  570.     struct AppWindow *aw = NULL;
  571.     struct AppMessage *am;
  572.     ULONG aws = 0, sig, isig;
  573.     struct WBArg *wba;
  574.     char buffer[á128 ];
  575.     int c, d;
  576.     struct hlist *hlist = hl_initheader();
  577.  
  578.     windowtitle    = title;
  579.     mailbetreff    = betreff;
  580.     mailcomment    = comment;
  581.     mailbezug   = bezug;
  582.     empliste    = emp;
  583.     quoteid     = quote;
  584.     mailflags    = flags;
  585.     maildiskin    = diskin;
  586.     moab        = oab;
  587.     moem        = oem;
  588.     mqbez        = qbez;
  589.     mfto        = ftoheader;
  590.  
  591.     pgp_addkey = pgp_sign = pgp_nocrypt = 0;
  592.  
  593.     ogw = ogreInitWindow( scr, WFLG_RMBTRAP, 0, title );
  594.  
  595.     ogreAddGroup( ogw, 0 | OGGP_EXPANDSTRING , OGFRAME_OUTLINE, " EmpfΣnger " );
  596.     ogreAddList( ogw, 0, 0xff, NULL, GID_LV, 40, 4, 0, NULL );
  597.     ogreLVInit( ogw, GID_LV );
  598.     if( emp )
  599.     {
  600.         while( *emp )
  601.         {
  602.             ogreLVAddEntry( ogw, GID_LV, *emp++, 2, NULL );
  603.         }
  604.     }
  605.  
  606.     ogreAddString( ogw, 1, '\n', NULL, GID_EMPS, NULL, 40, 256 | OGSF_NONEXTACT );
  607.     ogreAddButton( ogw, 2, 'n', "_Neu", GID_LVNEU );
  608.     ogreAddButton( ogw, 2, 'b', "_Brett", GID_LVBRETT );
  609.     ogreAddButton( ogw, 2, 'u', "_UserIn", GID_LVUSER );
  610.     ogreAddButton( ogw, 2, 'l', "_L÷schen", GID_LVLOESCH );
  611.  
  612.     ogreAddGroup( ogw, 0 | OGGP_EXPANDSTRING, OGFRAME_OUTLINE, " Status " );
  613.     ogreAddCheckbox( ogw, 0, '0', "Zeit _00:00:00", GID_CBZ00, prefs.flags & MDF_TIME00 );
  614.     ogreAddCheckbox( ogw, 1, 'z', "Direkt_zustellung", GID_CBDIREKT, FALSE );
  615.     ogreAddCheckbox( ogw, 2, 0, "Bezⁿge l÷schen", GID_CBCLEARBEZ, FALSE );
  616.     ogreAddCheckbox( ogw, 3, 'p', "Em_pfangsbestΣtigung", GID_CBEB, prefs.flags & MDF_EB );
  617. /*    ogreAddInteger( ogw, 4, 'w', "_Wartezeit Tage:", GID_EBWAITDAYS, 7, 0, MAXINT, 11, 3 );*/
  618.     ogreAddCycle( ogw, 4, 'r', "Ve_rsandart", GID_CBBIN, bin_options, 10, bin );
  619.  
  620.     ogreAddGroup( ogw, 1 | OGGP_EXPANDSTRING, OGFRAME_OUTLINE, " Info " );
  621.     ogreAddString( ogw, 0, 't', "      Be_treff:", GID_BETREFF, betreff, 40, 256 );
  622.     ogreAddString( ogw, 1, 'k', "_Kurzkommentar:", GID_COMMENT, comment, 40, 256 );
  623.     ogreAddString( ogw, 2, 's', "     Di_sku-In:", GID_DISKUIN, diskin, 40, 128 );
  624.     ogreAddButton( ogw, 2 | OGGP_KEEPSIZE, 'S', "?", GID_DISKUINSEL );
  625.     ogreAddButton( ogw, 2 | OGGP_KEEPSIZE, 0, "╖", GID_DISKUINME );
  626.  
  627.     ogreAddGroup( ogw, 2 | OGGP_EXPANDSTRING, OGFRAME_OUTLINE, " Importieren " );
  628.     ogreAddString( ogw, 0, 'd', "_DOS-Datei:", GID_BINFILE, binfile, 40, 256 );
  629.     ogreAddButton( ogw, 0 | OGGP_KEEPSIZE, 'D', "?", GID_BINFILESEL );
  630.     ogreAddString( ogw, 1, 'i', "Date_iname:", GID_BINNAME, fileheader, 16, 256 );
  631.     ogreAddString( ogw, 1, 'm', "Dateidatu_m:", GID_BINDATE, NULL, 10, 32 );
  632.  
  633.     ogreAddGroup( ogw, 3 | OGGP_EXPANDSTRING, OGFRAME_NONE, NULL );
  634.     ogreAddText( ogw, 0, "Info:", GID_INFO, "", 56, TRUE );
  635.     ogreAddButton( ogw, 1 | OGB_ONENTER, 'v', "_Verschicken", GID_SEND );
  636.     ogreAddButton( ogw, 1, 0, "Parken", GID_SENDHOLD );
  637.     ogreAddButton( ogw, 1, 'e', "_Editieren", GID_EDIT );
  638.     ogreAddButton( ogw, 1, 'o', "K_ommentar", GID_EDITCOMMENT );
  639.     ogreAddButton( ogw, 1, 'h', "_Header", GID_EDITHEADER );
  640.  
  641.     if( pgpavail )
  642.         ogreAddButton( ogw, 1, 'g', "P_GP", GID_PGP );
  643.  
  644.     ogreAddButton( ogw, 1, 0x5f, "Hilfe", OGID_HELP );
  645.     ogreAddButton( ogw, 1 | OGB_ONESC, 'a', "_Abbruch", GID_CANCEL );
  646.  
  647.     /* Bezⁿge l÷schen abschalten? */
  648.     if( !bezug )
  649.         ogreEnable( ogw, FALSE, GID_CBCLEARBEZ, 0 );
  650.     ogreEnable( ogw, bin, GID_BINFILE, GID_BINFILESEL, 0 );
  651.     ogreEnable( ogw, bin == 1, GID_BINNAME, GID_BINDATE, 0 );
  652.     ogreEnable( ogw, !bin, GID_EDIT, 0 );
  653.     /*ogreEnable( ogw, prefs.flags & MDF_EB, GID_EBWAITDAYS, 0 );*/
  654.     ogreEnable( ogw, isediting >= 0, GID_EMPS, GID_LVLOESCH, 0 );
  655.     ogreEnable( ogw, !moab, GID_EDIT, GID_CBBIN, GID_BETREFF, 0 );
  656.  
  657.     iw = ogreOpenWindow( ogw );
  658.     if( !iw )
  659.         return( 0 );
  660.  
  661.     isig = 1 << iw->UserPort->mp_SigBit;
  662.  
  663.     if( wbwindow && WorkbenchBase )
  664.     {
  665.         awmp     = CreateMsgPort();
  666.         aws     = 1 << awmp->mp_SigBit;
  667.         aw         = AddAppWindow( 0, NULL, iw, awmp, TAG_DONE );
  668.     }
  669.  
  670.     goto viewinfo;
  671.  
  672.     while( !Done )
  673.     {
  674.         if( sendwinauto )
  675.         {
  676.             rtwinlock = rtLockWindow( iw );
  677.             Done = reallysend( ogw, hlist, FALSE );
  678.             rtUnlockWindow( iw, rtwinlock );
  679.             sendwinauto = FALSE;
  680.         }
  681.  
  682.         sig = mWait( isig | aws );
  683.  
  684.         if( sig & aws )
  685.         {
  686.             while( ( am = ( struct AppMessage * ) GetMsg( awmp ) ) )
  687.             {
  688.                 if( am->am_NumArgs )
  689.                 {
  690.                     char dirname[ 256 ];
  691.  
  692.                     wba = am->am_ArgList;
  693.                     NameFromLock( wba->wa_Lock, dirname, 255 );
  694.                     AddPart( dirname, wba->wa_Name, 255 );
  695.  
  696.                     ogreSetStringValue( ogw, GID_BINFILE, dirname );
  697.  
  698.                     tv = getft( dirname );
  699.                     if( tv>0 )
  700.                     {
  701.                         ogreSetStringValue( ogw, GID_BINDATE, dat2str( tv ) );
  702.                         ogreSetStringValue( ogw, GID_BINNAME, filepart( dirname ) );
  703.  
  704.                         if( !bin )
  705.                             bin = 2;
  706.                     }
  707.                 }
  708.                 ReplyMsg( am );
  709.             }
  710.         }
  711.  
  712.         while( ( im = ogreIM( ogw ) ) )
  713.         {
  714.             if( im->Class == IDCMP_GADGETHELP)
  715.                 showguidenum( "sendwin_gads", im->Code );
  716.             else if( im->Class == GADGETUP )
  717.             {
  718.                 switch( im->Code )
  719.                 {
  720.  
  721.                     case GID_EMPS:
  722.                         if( isediting >= 0 )
  723.                         {
  724.                             if( ! ( * ( stpblk( ogreStringValue( ogw, GID_EMPS ) ) ) ) )
  725.                             {
  726.                                 ogreLVSelect( ogw, GID_LV, -1 );
  727.                                 ogreLVSetEntry( ogw, GID_LV, isediting, ogreStringValue( ogw, GID_EMPS ), 2 );
  728.                                 ogreLVRefresh( ogw, GID_LV );                    
  729.                                 isediting = -1;
  730.                                 ogreSetStringValue( ogw, GID_EMPS, "" );
  731.                             }
  732.                             else
  733.                             {
  734.                                 ogreLVSelect( ogw, GID_LV, -1 );
  735.                                 ogreLVSetEntry( ogw, GID_LV, isediting, ogreStringValue( ogw, GID_EMPS ), 2 );
  736.                                 ogreLVRefresh( ogw, GID_LV );                    
  737.                                 isediting = -1;
  738.                                 ogreSetStringValue( ogw, GID_EMPS, "" );
  739.                             }
  740.                         }
  741.                         break;
  742.  
  743.                     case GID_CBBIN:
  744.                         bin = ogreValue( ogw, GID_CBBIN );
  745.                         break;
  746.  
  747.                     case GID_CBEB:
  748.                         if( ogreValue( ogw, GID_CBEB ) )
  749.                             prefs.flags |= MDF_EB;
  750.                         else
  751.                             prefs.flags &= ~MDF_EB;
  752.                         break;
  753.  
  754.                     case GID_CBZ00:
  755.                         if( ogreValue( ogw, GID_CBZ00 ) )
  756.                             prefs.flags |= MDF_TIME00;
  757.                         else
  758.                             prefs.flags &= ~MDF_TIME00;
  759.                         break;
  760.  
  761.                     case GID_LV:
  762.                         isediting = ogreValue( ogw, GID_LV );
  763.                         vn = ogreLVGetEntry( ogw, GID_LV, isediting );
  764.                         if( vn )
  765.                         {
  766.                             ogreEnable( ogw, TRUE, GID_EMPS, 0 );
  767.                             ogreSetStringValue( ogw, GID_EMPS, vn->txt );
  768.                             if( im->Qualifier )
  769.                                 ogreActivate( ogw, GID_EMPS );
  770.                         }
  771.                         break;
  772.  
  773.                     case GID_LVLOESCH:
  774.                         if( isediting >= 0 )
  775.                         {
  776.                             ogreLVRemEntry( ogw, GID_LV, isediting );
  777.                             ogreLVRefresh( ogw, GID_LV );
  778.                             isediting = -1;
  779.                             ogreSetStringValue( ogw, GID_EMPS, "" );
  780.                         }
  781.                         break;
  782.  
  783.                     case GID_LVBRETT:
  784.                         rtwinlock = rtLockWindow( iw );
  785.                         while( ( p = dobrettreqmulti() ) )
  786.                         {
  787.                             if( !ogreLVFindEntry( ogw, GID_LV, p ) )
  788.                             {
  789.                                 ogreLVAddEntry( ogw, GID_LV, p, 2, 0 );
  790.                                 isediting = -1;
  791.                                 ogreLVSelect( ogw, GID_LV, -1 );
  792.                                 ogreLVRefresh( ogw, GID_LV );
  793.                             }
  794.                         }
  795.                         rtUnlockWindow( iw, rtwinlock );
  796.                         break;
  797.                     
  798.                     case GID_LVUSER:
  799.                         rtwinlock = rtLockWindow( iw );
  800.                         while( ( p = douserreqmulti() ) )
  801.                         {
  802.                             if( !ogreLVFindEntry( ogw, GID_LV, p ) )
  803.                             {
  804.                                 ogreLVAddEntry( ogw, GID_LV, p, 2, 0 );
  805.                                 isediting = -1;
  806.                                 ogreLVSelect( ogw, GID_LV, -1 );
  807.                                 ogreLVRefresh( ogw, GID_LV );
  808.                             }
  809.                         }
  810.                         rtUnlockWindow( iw, rtwinlock );
  811.                         break;
  812.  
  813.                     case GID_LVNEU:
  814.                         isediting = ogreLVAddEntry( ogw, GID_LV, "", 1, 0 );
  815.                         ogreLVRefresh( ogw, GID_LV );
  816.                         ogreSetStringValue( ogw, GID_EMPS, "" );
  817.                         ogreActivate( ogw, GID_EMPS );
  818.                         break;
  819.  
  820.                     case GID_BINFILESEL:
  821.                         newdofrselfile( ogw, GID_BINFILE, "Importdatei auswΣhlen..." );
  822.                         p = ogreStringValue( ogw, GID_BINFILE );
  823.                         tv = getft( p );
  824.                         if( tv>0 )
  825.                         {
  826.                             ogreSetStringValue( ogw, GID_BINDATE, dat2str( tv ) );
  827.                             ogreSetStringValue( ogw, GID_BINNAME, filepart( p ) );
  828.                         }
  829.                         p = ogreStringValue( ogw, GID_BETREFF );
  830.                         if( !*p )
  831.                             ogreSetStringValue( ogw, GID_BETREFF, ogreStringValue( ogw, GID_BINNAME ) );
  832.                         break;
  833.  
  834.                     case GID_DISKUINSEL:
  835.                         rtwinlock = rtLockWindow( iw );
  836.                         p = dobrettreq();
  837.                         rtUnlockWindow( iw, rtwinlock );
  838.                         if( !p )
  839.                             break;
  840.                         ogreSetStringValue( ogw, GID_DISKUIN, p );
  841.                         break;
  842.  
  843.                     case GID_DISKUINME:
  844.                         sprintf( buffer, "%s@%s%s", prefs.username, ISRFC ? prefs.pointname : prefs.boxname, prefs.boxdomain );
  845.                         ogreSetStringValue( ogw, GID_DISKUIN, buffer );
  846.                         break;
  847.  
  848.                     case GID_EDIT:
  849.                         rtwinlock = rtLockWindow( iw );
  850.                         calleditor( TMPMSGNAME );
  851.                         rtUnlockWindow( iw, rtwinlock );
  852.                         ActivateWindow( iw );
  853.                         break;
  854.  
  855.                     case GID_EDITCOMMENT:
  856.                         rtwinlock = rtLockWindow( iw );
  857.                         calleditor( TMPCOMMENTNAME );
  858.                         rtUnlockWindow( iw, rtwinlock );
  859.                         ActivateWindow( iw );
  860.                         break;
  861.  
  862.                     case GID_EDITHEADER:
  863.                         rtwinlock = rtLockWindow( iw );
  864.                         doeditheader( hlist, "ZusΣtzliche Headerzeilen anfⁿgen:" );
  865.                         rtUnlockWindow( iw, rtwinlock );
  866.                         ActivateWindow( iw );
  867.                         break;
  868.  
  869.                     case GID_PGP:
  870.                         ogreLockWindow( ogw );
  871.                         setpgp();
  872.                         ogreUnlockWindow( ogw );
  873.                         break;
  874.  
  875.                     case GID_SEND:
  876.                         rtwinlock = rtLockWindow( iw );
  877.                         Done = reallysend( ogw, hlist, FALSE );
  878.                         rtUnlockWindow( iw, rtwinlock );
  879.                         break;
  880.  
  881.                     case GID_SENDHOLD:
  882.                         rtwinlock = rtLockWindow( iw );
  883.                         Done = reallysend( ogw, hlist, TRUE );
  884.                         rtUnlockWindow( iw, rtwinlock );
  885.                         break;
  886.  
  887.                     case GID_CANCEL:
  888.                         Done = 1;
  889.                         break;
  890.                 }
  891.             }
  892.  
  893. viewinfo:
  894.  
  895.             /* Infotext erzeugen */
  896.             c = getfilelen( TMPCOMMENTNAME );
  897.             d = getfilelen( ( bin ) ? ogreStringValue( ogw, GID_BINFILE ) : TMPMSGNAME );
  898.             buffer[á0 ]á= 0;
  899.             if( d > 0 )
  900.                 sprintf( buffer, "%lD Byte Inhalt", d );
  901.             if( c > 0 )
  902.             {
  903.                 if( buffer[á0 ]á)
  904.                     strcat( buffer, ", " );
  905.                 asprintf( buffer, "%lD Byte Kommentar", c );
  906.             }
  907.  
  908.             ogreSetStringValue( ogw, GID_INFO, buffer );
  909.  
  910.             ogreEnable( ogw, bin, GID_BINFILE, GID_BINFILESEL, 0 );
  911.             ogreEnable( ogw, bin == 1, GID_BINNAME, GID_BINDATE, 0 );
  912.             ogreEnable( ogw, !bin && !moab, GID_EDIT, 0 );
  913.         /*    ogreEnable( ogw, prefs.flags & MDF_EB, GID_EBWAITDAYS, 0 );*/
  914.             ogreEnable( ogw, isediting >= 0, GID_EMPS, GID_LVLOESCH, 0 );
  915.         }
  916.     }
  917.  
  918.     if( aw )
  919.         RemoveAppWindow( aw );
  920.  
  921.     if( awmp )
  922.         DeleteMsgPort( awmp );
  923.  
  924.     ogreExitWindow( ogw );
  925.  
  926.     hl_freeheader( hlist );
  927.  
  928.     DeleteFile( TMPMSGNAME );
  929.     DeleteFile( TMPCOMMENTNAME );
  930.     return( Done == 2 );
  931. }
  932.  
  933. #define HE_OK 1
  934. #define HE_CANCEL 2
  935. #define HE_HLV 3
  936. #define HE_HL 5
  937. #define HE_NEW 6
  938. #define HE_DEL 7
  939. #define HE_DLV 4
  940.  
  941. static char *hdesc[]á= {
  942.     "EMP:             EmpfΣnger",
  943.     "BEZ:             BezugsID",
  944.     "STAT:            Status",
  945.     "ANTWORT-AN:      Adresse",
  946.     "DISKUSSION-IN:   Brett/Adresse",
  947.     "STICHWORT:       Stichw÷rter",
  948.     "ZUSAMMENFASSUNG: Kurzkommentar",
  949.     "EB:              EmpfangsbestΣtigung",
  950.     NULL
  951. };
  952.  
  953. #if 0
  954. static char *hexcl[]á= {
  955.     "ABS",
  956.     "MID",
  957.     "EDA",
  958.     "DDA",
  959.     "FILE",
  960.     "BET",
  961.     "MAILER",
  962.     "LEN",
  963.     "KOM",
  964.     NULL
  965. };
  966. #endif
  967.  
  968. int doeditheader( struct hlist *hlist, char *title )
  969. {
  970.     struct ogwin *ogw;
  971.     struct IntuiMessage *im;
  972.     struct ogrevn *vn;
  973.     struct Window *iw;
  974.     int Done = FALSE;
  975.     char **ptr;
  976.     struct header *hl = ( struct header * ) hlist->l.mlh_Head;
  977.     char buffer[ 8192 + 256 ];
  978.     int isediting = -1;
  979.     char *p;
  980.     int c;
  981.  
  982.     ogw = ogreInitWindow( scr, WFLG_RMBTRAP, 0, title );
  983.  
  984.     ogreAddGroup( ogw, 0 | OGGP_EXPANDSTRING , OGFRAME_NONE, NULL );
  985.     ogreAddList( ogw, 0, 0xff, NULL, HE_HLV, 32, 12, 0, NULL );
  986.     ogreAddList( ogw, 0, 0, NULL, HE_DLV, 32, 12, 0, NULL );
  987.  
  988.     ogreLVInit( ogw, HE_HLV );
  989.     while( hl->n.mln_Succ )
  990.     {
  991.         sprintf( buffer, "%s:%s", hl->head, hl->data );
  992.         ogreLVAddEntry( ogw, HE_HLV, buffer, 2, hl );
  993.         hl = ( struct header * ) hl->n.mln_Succ;
  994.     }
  995.  
  996.     ogreLVInit( ogw, HE_DLV );
  997.     ptr = hdesc;
  998.     while( *ptr )
  999.     {
  1000.         ogreLVAddEntry( ogw, HE_DLV, *ptr++, FALSE, NULL );
  1001.     }
  1002.  
  1003.     ogreAddString( ogw, 1, '\n', NULL, HE_HL, NULL, 40, 8192 | OGSF_NONEXTACT );
  1004.     ogreAddButton( ogw, 2, 'n', "_Neu", HE_NEW );
  1005.     ogreAddButton( ogw, 2, 'l', "_L÷schen", HE_DEL );
  1006.  
  1007.     ogreAddGroup( ogw, 1 , OGFRAME_NONE, NULL );
  1008.     ogreAddButton( ogw, 0 | OGB_ONENTER, 'o', "_OK", HE_OK );
  1009.     ogreAddHelp( ogw, 0 );
  1010.     ogreAddButton( ogw, 0 | OGB_ONESC, 'a', "_Abbruch", HE_CANCEL );
  1011.  
  1012.     ogreEnable( ogw, FALSE, HE_HL, HE_DEL, 0 );
  1013.  
  1014.     iw = ogreOpenWindow( ogw );
  1015.     if( !iw )
  1016.         return( 0 );
  1017.  
  1018.     while( !Done )
  1019.     {
  1020.         ogreEnable( ogw, isediting >= 0, HE_HL, HE_DEL, 0 );
  1021.  
  1022.         if( ( im = ogreWaitIM( ogw ) ) )
  1023.         {
  1024.             if( im->Class == IDCMP_GADGETHELP)
  1025.                 showguidenum( "editheader_gads", im->Code );
  1026.             else if( im->Class == GADGETUP )
  1027.             {
  1028.                 switch( im->Code )
  1029.                 {
  1030.                     case HE_OK:
  1031.                         Done = 1;
  1032.                         break;
  1033.  
  1034.                     case HE_CANCEL:
  1035.                         Done = 2;
  1036.                         break;
  1037.  
  1038.                     case HE_DEL:
  1039.                         if( isediting >= 0 )
  1040.                         {
  1041.                             ogreLVRemEntry( ogw, HE_HLV, isediting );
  1042.                             ogreLVRefresh( ogw, HE_HLV );
  1043.                             isediting = -1;
  1044.                             ogreSetStringValue( ogw, GID_EMPS, "" );
  1045.                         }
  1046.                         break;
  1047.  
  1048.                     case HE_NEW:
  1049.                         isediting = ogreLVAddEntry( ogw, HE_HLV, "", 1, 0 );
  1050.                         ogreLVRefresh( ogw, HE_HLV );
  1051.                         ogreSetStringValue( ogw, HE_HL, "" );
  1052.                         ogreActivate( ogw, HE_HL );
  1053.                         break;
  1054.  
  1055.                     case HE_DLV:
  1056.                         vn = ogreLVGetEntry( ogw, HE_DLV, ogreValue( ogw, HE_DLV ) );
  1057.                         if( vn )
  1058.                         {
  1059.                             strcpy( buffer, vn->txt );
  1060.                             p = strchr( buffer, ':'á);
  1061.                             if( p )
  1062.                                 p[ 1 ]á= 0;
  1063.                             isediting = ogreLVAddEntry( ogw, HE_HLV, buffer, 3, 0 );
  1064.                             ogreLVRefresh( ogw, HE_HLV );
  1065.                             ogreSetStringValue( ogw, HE_HL, buffer );
  1066.                             ogreActivate( ogw, HE_HL );
  1067.                         }
  1068.                         break;
  1069.  
  1070.                     case HE_HLV:
  1071.                         isediting = ogreValue( ogw, HE_HLV );
  1072.                         vn = ogreLVGetEntry( ogw, HE_HLV, isediting );
  1073.                         if( vn )
  1074.                         {
  1075.                             ogreSetStringValue( ogw, HE_HL, vn->txt );
  1076.                             if( im->Qualifier )
  1077.                                 ogreActivate( ogw, HE_HL );
  1078.                         }
  1079.                         break;
  1080.  
  1081.                     case HE_HL:
  1082.                         if( isediting >= 0 )
  1083.                         {
  1084.                             ogreLVSelect( ogw, HE_HLV, -1 );
  1085.                             ogreLVSetEntry( ogw, HE_HLV, isediting, ogreStringValue( ogw, HE_HL ), 2 );
  1086.                             ogreLVRefresh( ogw, HE_HLV );                    
  1087.                             isediting = -1;
  1088.                             ogreSetStringValue( ogw, HE_HL, "" );
  1089.                         }
  1090.                         break;
  1091.                 }
  1092.             }
  1093.         }
  1094.     }
  1095.  
  1096.     if( Done == 1 )
  1097.     {
  1098.         hl_clearhlist( hlist );
  1099.  
  1100.         for( c = 0; ; c++ )
  1101.         {
  1102.             vn = ogreLVGetEntry( ogw, HE_HLV, c );
  1103.             if( !vn )
  1104.                 break;
  1105.             strcpy( buffer, vn->txt );
  1106.             p = strchr( buffer, ':'á);
  1107.             if( !p )
  1108.                 continue;
  1109.             *p++ = 0;
  1110.             p = stpblk( p );
  1111.             hl_addheader( hlist, buffer, p );
  1112.         }
  1113.  
  1114.     }
  1115.  
  1116.     ogreExitWindow( ogw );
  1117.     return( Done == 1 );
  1118. }
  1119.