AddFaceHeader include

From 40tude Dialog Wiki

AddFaceHeader (Include)

The AddFaceHeader-script allows you to include a Face-header into your articles and/or e-mails. It is a modified version of the CustomizeUserAgent-script by Thomas Barghahn. If you notice any bugs, please feel free to contact the author Maik Prinz (2prinz@gmx.de).


Excerpt from a header modified by this script:

"Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEU0IhTPmHzwzb2paUXU[...]"

Face-Header in Mozilla:

Face-header.png

Face-Header in Dialog, displayed by means of FaceView:

Faceview2.png

See also "The Face Header"-Website for more information about the face header.

Generate a Face code with the offline PNGtoFace-Tool for MS WIN-XP: www.2prinz.de/dialog/face.htm or with the online base64 decoding and encoding texts and files tool: www.motobit.com/util/base64-decoder-encoder.asp

To view the picture encoded in a Face string use the website:
www.opinionatedgeek.com/dotnet/tools/Base64Decode/Default.aspx


Installation & setup of the script

This script is triggered by an X-2Face:-header in your article or e-mail. To add such a header to any of your identities, go to Menu -> Settings -> Servers, Identities, Signatures... -> X-Header and create a new entry "2Face".

X-add.png X-headers.png

You can now choose to either manually add a Face code to selected articles by filling All headers -> X-headers -> X-2Face: in the Composition Window, or to permanently add this header to an identity (Identities -> Default X-Headers, the value of the header must contain at least on character).


Identity.png



Please note that this script is an include-file!. You have to copy the following script inside a new custom script (for example "Include_AddFaceHeader") and safe it. Please don't compile this custom script! After that you have to add the following lines to your OnBeforeSending-Script:

{$I Include_AddFaceHeader.ds}    

and

AddFaceHeader ( Message, IsEmail );

This may look like this:

program OnBeforeSendingMessage;

  {$I Include_AddFaceHeader.ds}   

function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
begin
  result:=true;

  //possibly some other calls to scripts

  AddFaceHeader ( Message, IsEmail );

end;

begin
end.

Just compile this OnBeforeSending-Script now to get your include-file to work. The setup of the script is shown inside the script. Please take a look at this to customize the script to your own fits. Please note that whenever you reconfigure the AddFaceHeader custom script, you have to recompile the OnBeforeSending-Script to apply the changes.


The Include-File

Please be sure that this is the only content in the include-file!

// Version : 1.2.1
// Date    : 02.03.2006
// Dialog  : 2.0.15.1 beta 38
//
// 1.1.0 New Skript 08.06.2005
// 1.1.1 FaceCode from the script off
// 1.1.2 Line length of the "Face-Header" limited
// 1.2.0 Optimize by Thomas Barghahn
// 1.2.1 New optional Face Line-Break

procedure Init_AddFaceHeader ( var AddFaceChange   : String;
                               var AddOnFaceHeader : String;
                               var UseFaceFolding  : Boolean;
                               var ChangeInEmails  : Boolean;
                               var ChangeInNews    : Boolean
);

begin

//  ----------------------------------------------------
//  Configuration settings
//  ----------------------------------------------------

    // set the header you want to change to "Face:" here, e.g. 'X-2Face:'
    AddFaceChange := 'X-2Face:';
    
    // set 'false' to set a single line Face-Header
    UseFaceFolding := true;

    // change header in emails and/or postings
    // set 'true' or 'false'
    ChangeInEmails := true;
    ChangeInNews := true;
    
//  ----------------------------------------------------
//  End of configuration settings
//  ---------------------------------------------------- 

end;

   // --------------------------------------------------------------- //
   // ----  No user maintainable parts below this line -------------- //
   // --------------------------------------------------------------- //
    

procedure AddFaceHeader(Message:TStringlist;IsEmail:boolean);

var i, z, MaxInt      : integer;
    AddFaceChange, f  : String;
    AddOnFaceHeader   : String;
    UseFaceFolding    : Boolean;
    ChangeInEmails    : Boolean;
    ChangeInNews      : Boolean;

begin
   Init_AddFaceHeader ( AddFaceChange, AddOnFaceHeader, UseFaceFolding, ChangeInEmails, ChangeInNews );
   MaxInt := 2147483647;
   if ((IsEmail=true)  and (ChangeInEmails=true)) or
      ((IsEmail=false) and (ChangeInNews=true)) then begin
         f := ' ';
         i := 1;
         z := 79;
         if UseFaceFolding then begin f := #13#10 + ' '; end;
         while (Message.Strings[i]<>'') do begin
            if (pos(AddFaceChange,Message.Strings[i]) = 1) and (length(Message.Strings[i]) > 199) then begin
               AddOnFaceHeader := 'Face: ' + Copy ( Message.Strings[i], length(AddFaceChange)+2, MaxInt);
               While z < length(AddOnFaceHeader)+1 do begin
                  insert (f, AddOnFaceHeader, z);
                  z := z + 79;
               end; //while
               Message.Strings[i] := AddOnFaceHeader;
            end; //if      
            i := i + 1;
         end; {end of while}
   end; //if
end; //procedure


Maik Prinz May 2005