%% Copyright (C) 2016 Achim D. Brucker, https://www.brucker.ch
%%
%% License:
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1.3c of the License, or (at your opinion) any later version.
%%   OR
%%   The 2-clause BSD-style license.
%%
%%   SPDX-License-Identifier: LPPL-1.3c+ OR BSD-2-Clause
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{beamerthemelh-presentation}
     [2016/11/01 v0.0  LaTeX presentation class implementing the cooperate design of LogicalHacking.com]

\RequirePackage{ifthen}
\usepackage{xkeyval}
\usepackage{xstring}
\usepackage{etoolbox}
\usepackage{environ}

\usepackage{fontawesome}
\definecolor{linkedin}{RGB}{24,103,158}
\definecolor{twitter}{RGB}{29,161,242}

\newcommand{\titlevisual}[1]{\titlegraphic{\includegraphics[width=\paperwidth,height=\paperheight]{#1}}}

\urlstyle{sf}
%
\newboolean{lh@title@light}
\setboolean{lh@title@light}{false}
\DeclareOptionX{titlelight}{\setboolean{lh@title@light}{true}}
% 
\newboolean{lh@inverse}
\setboolean{lh@inverse}{false}
\DeclareOptionX{inverse}{\setboolean{lh@inverse}{true}}
%
\def\lh@classification@sel@default{5}
\def\lh@classification@sel{5}
\newcommand{\lh@CCBYNCND}{\href{https://creativecommons.org/licenses/by-nc-nd/4.0/}{CC BY-NC-ND 4.0}}
\newcommand{\lh@CCBYND}{\href{https://creativecommons.org/licenses/by-nd/4.0/}{CC BY-ND 4.0}}
\newcommand{\lh@CCBY}{\href{https://creativecommons.org/licenses/by/4.0/}{CC BY 4.0}}
\newcommand{\lh@CCzero}{\href{https://creativecommons.org/publicdomain/zero/1.0/}{CC0 1.0}}
\newcommand{\lh@GFDL}{\href{https://www.gnu.org/licenses/fdl.html}{GFDL 1.3}}

\newcommand{\lh@strictlyconfidential}{Strictly Confidential}
\newcommand{\lh@confidential}{Confidential}
\newcommand{\lh@internal}{Internal}
\newcommand{\lh@customer}{Customer}
\newcommand{\lh@student}{Student\ifthenelse{\equal{\lh@classification@student@short}{}}%
{}{~(\lh@classification@student@short)}}
\newcommand{\lh@public}{Public}


\newboolean{lh@slide@strictlyconfidential}\setboolean{lh@slide@strictlyconfidential}{false}
\newboolean{lh@slide@confidential}\setboolean{lh@slide@confidential}{false}
\newboolean{lh@slide@internal}\setboolean{lh@slide@internal}{false}
\newboolean{lh@slide@customer}\setboolean{lh@slide@customer}{false}
\newboolean{lh@slide@student}\setboolean{lh@slide@student}{false}
\newboolean{lh@slide@public-cc-by-nc-nd}\setboolean{lh@slide@public-cc-by-nc-nd}{false}
\newboolean{lh@slide@public-cc-by-nd}\setboolean{lh@slide@public-cc-by-nd}{false}
\newboolean{lh@slide@public-cc-by}\setboolean{lh@slide@public-cc-by}{false}
\newboolean{lh@slide@public-cc-zero}\setboolean{lh@slide@public-cc-zero}{false}
\newboolean{lh@slide@public-gfdl}\setboolean{lh@slide@public-gfdl}{false}



\newcommand{\classification}{UNDEFINED}
\define@choicekey*{beamerthemelh-presentation.sty}{classification}[\val\nr]%
{strictly-confidential,confidential,internal,customer,student,public-cc-by-nc-nd,%
  public-cc-by-nd,public-cc-by,public-cc-zero,public-gfdl}%
[strictly-confidential]%
{%
  \let\lh@classification@sel@default\nr
}

\define@choicekey*{beamerframe}{classification}[\val\nr]%
{strictly-confidential,confidential,internal,customer,student,public-cc-by-nc-nd,%
  public-cc-by-nd,public-cc-by,public-cc-zero,public-gfdl}%
[strictly-confidential]%
{%
  \let\lh@classification@sel\nr
  \ifcase\nr\relax% strictly confidential
    \setboolean{lh@slide@strictlyconfidential}{true}
  \or% confidential
    \setboolean{lh@slide@confidential}{true}
  \or% internal
    \setboolean{lh@slide@internal}{true}
  \or% customer
    \setboolean{lh@slide@customer}{true}
  \or% student
    \setboolean{lh@slide@student}{true}
  \or% public
    \setboolean{lh@slide@public-cc-by-nc-nd}{true}
  \or
    \setboolean{lh@slide@public-cc-by-nd}{true}
  \or
    \setboolean{lh@slide@public-cc-by}{true}
  \or
    \setboolean{lh@slide@public-cc-zero}{true}
  \or
    \setboolean{lh@slide@public-gfdl}{true}
  \fi%
}

\ProcessOptionsX\relax
%\ProcessOptionsBeamer\relax
%\ProcessOptions

\newcommand{\lh@classification@text}[1]{%
  \ifcase\number#1\relax% strictly confidential
    \alert{\lh@strictlyconfidential}%
  \or% confidential
    \alert{\lh@confidential}%
  \or% internal
    \alert{\lh@internal}%
  \or% customer
    \lh@customer%
  \or% student
    \lh@student%
  \or% public
    \lh@public~(\lh@CCBYNCND)%
  \or
    \lh@public~(\lh@CCBYND)%
  \or
    \lh@public~(\lh@CCBY)%
  \or
    \lh@public~(\lh@CCzero)%
  \or
    \lh@public~(\lh@GFDL)%
  \else
    UNDEFINED~CLASSIFICATION:~#1%
  \fi%
}
\newcommand{\lh@classification@description}[1]{%
  \ifcase\number#1\relax% strictly confidential
    classified ``\emph{\lh@stricltyconfidential}'' and only available
    to a small number of
    precisely specified persons. Disclosure to third parties only after a
    confidentiality agreement has been signed.
   \or% confidential
    classified ``\emph{\lh@confidential}'' and only available to members of the Software
    Assurance \& Security Research Team that are pre-defined by the
    information owner. Disclosure to third parties only after a
    confidentiality agreement has been signed.
  \or% internal
    classified ``\emph{\lh@internal}'' and only available to staff of the Software
    Assurance \& Security Research Team  Disclosure to third parties only after a
    confidentiality agreement has been signed.
  \or% customer
    classified ``\emph{\lh@customer}'' and only available to staff
    of the University of Exeter and to business partners. Disclosure to third parties only after a
    confidentiality agreement has been signed.
  \or% student
    classified ``\emph{\lh@student}'' and only available to 
    \ifthenelse{\equal{\lh@classification@student@long}{}}%
    {staff of the University of Exeter and to a limited group of students
      (e.g., that are registered for a specific module) of the  University of Exeter.}%
     {students of the University of Exeter that are registered to the module \lh@classification@student@long.}
    Disclosure to third parties only after a
    confidentiality agreement has been signed.
  \or% public CC BY NC ND
     licensed under
    a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0
    International Public License (\lh@CCBYNCND).
  \or% public CC BY ND
    licensed under
    a Creative Commons Attribution-NoDerivatives 4.0
    International Public License (\lh@CCBYND).
  \or% public CC BY
    licensed under
    a Creative Commons Attribution 4.0
    International Public License (\lh@CCBY).
  \or% public CC 0
    licensed under
    a \lh@CCzero license: To the extent possible under law, all copyright
    and related or neighboring rights to the slides marked \lh@CCBY are
    waived.
  \or% public GFDL
    licensed under
    the \lh@GFDL:\\
     Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
  \fi%
}

\BeforeBeginEnvironment{frame}{%
  \let\lh@classification@sel\lh@classification@sel@default%
}


\mode<presentation>
\let\lh@classification@sel\lh@classification@sel@default%
\renewcommand{\classification}{\lh@classification@text{\lh@classification@sel}}
\def\lh@classification{\classification}


\RequirePackage{xcolor}
\RequirePackage[]{lh-logo}[2016/08/15]
\RequirePackage{xparse}
\usepackage{lmodern}
\usepackage{raleway}
\usepackage{sfmath}
\usepackage{sansmathaccent}
\usepackage{mathabx}
\usepackage[T1]{fontenc}



\usecolortheme{lh-core}
\ifthenelse{\boolean{lh@inverse}}{%
  \usecolortheme{lh-core-inverse}
}{%
}

\usecolortheme{lh-titlelight}
\usecolortheme{lh-titledark}
%
\newcommand{\settitledark}{%
  \setbeamercolortitledark%
  \setboolean{lh@title@light}{false}%
}
\newcommand{\settitlelight}{%
  \setbeamercolortitlelight%
  \setboolean{lh@title@light}{true}%
}
%
\ifthenelse{\boolean{lh@title@light}}{%
  \setbeamercolortitlelight%
}{%
  \setbeamercolortitledark%
}
\useinnertheme{lh}
\useoutertheme{lh}
\usefonttheme{lh}
\mode
<all>

\AtBeginDocument{
\providecommand{\thanksMsg}{Thank you for your attention!}
\providecommand{\thankYouMsg}{Thank you!}
\providecommand{\thanksQuestionsMsg}{Any questions or remarks?}
\providecommand{\AgendaMsg}{Outline}
}

\newcommand{\CopyrightFrame}{%
  \bgroup%\setbeamertemplate{footline}[default]%
  \begin{frame}\vfill%
    \frametitle{Document Classification and License Information}
    \footnotesize
    \textcopyright~\the\year~\href{https://logicalhacking.com}{LogicalHacking.com}, \insertshortauthor.
    \begin{itemize}\footnotesize
    \item This presentation is classified as \emph{\classification}:\\
       Except where otherwise noted, this presentation is
      \lh@classification@description{\lh@classification@sel}
      \ifthenelse{%
      \boolean{lh@slide@strictlyconfidential}\OR%
      \boolean{lh@slide@confidential}\OR%
      \boolean{lh@slide@internal}\OR%
      \boolean{lh@slide@customer}\OR%
      \boolean{lh@slide@public-cc-by-nc-nd}\OR%
      \boolean{lh@slide@public-cc-by-nd}\OR%
      \boolean{lh@slide@public-cc-by}\OR%
      \boolean{lh@slide@public-cc-zero}\OR%
      \boolean{lh@slide@public-gfdl}}{
    \item Deviating from this, the following classifications apply:
        \begin{itemize}\tiny 
          \ifthenelse{\boolean{lh@slide@strictlyconfidential}}{
          \item Slides marked \emph{\lh@classification@text{0}} are
            \lh@classification@description{0}
          }{}
          \ifthenelse{\boolean{lh@slide@confidential}}{
          \item Slides marked \emph{\lh@classification@text{1}} are
            \lh@classification@description{1}
          }{}
          \ifthenelse{\boolean{lh@slide@internal}}{
          \item Slides marked \emph{\lh@classification@text{2}} are
            \lh@classification@description{2}
          }{}
          \ifthenelse{\boolean{lh@slide@customer}}{
          \item Slides marked \emph{\lh@classification@text{3}} are
            \lh@classification@description{3}
          }{}
          \ifthenelse{\boolean{lh@slide@public-cc-by-nc-nd}}{
          \item Slides marked \emph{\lh@classification@text{4}} are
            \lh@classification@description{4}
          }{}
          \ifthenelse{\boolean{lh@slide@public-cc-by-nd}}{
          \item Slides marked \emph{\lh@classification@text{5}} are
            \lh@classification@description{5}
          }{}
          \ifthenelse{\boolean{lh@slide@public-cc-by}}{
          \item Slides marked \emph{\lh@classification@text{6}} are
            \lh@classification@description{6}
          }{}
          \ifthenelse{\boolean{lh@slide@public-cc-zero}}{
          \item Slides marked \emph{\lh@classification@text{7}} are
            \lh@classification@description{7}
          }{}
          \ifthenelse{\boolean{lh@slide@public-gfdl}}{
          \item Slides marked \emph{\lh@classification@text{8}} are
            \lh@classification@description{8}
          }{}
        \end{itemize}
    }{}
    \end{itemize}
  \end{frame}
  \egroup}

\newcommand{\AgendaFrame}[1][]{%
\bgroup  %\setbeamertemplate{footline}[default]%
\begin{frame}
  \frametitle{\AgendaMsg}
  {\tableofcontents[#1]}
\end{frame}
\egroup}


\def\lh@contactauthor{\insertshortauthor}
\newcommand{\contactauthor}[1]{\gdef\lh@contactauthor{#1}}
\def\lh@contactemail{}
\newcommand{\contactemail}[1]{\gdef\lh@contactemail{#1}}
\def\lh@contacttwitter{}
\newcommand{\contacttwitter}[1]{\gdef\lh@contacttwitter{#1}}
\def\lh@contactlinkedin{}
\newcommand{\contactlinkedin}[1]{\gdef\lh@contactlinkedin{#1}}
\def\lh@contactwww{}
\newcommand{\contactwww}[1]{\gdef\lh@contactwww{#1}}
\def\lh@contactblog{}
\newcommand{\contactblog}[1]{\gdef\lh@contactblog{#1}}
\def\lh@thanks{\huge \thanksMsg\\ \thanksQuestionsMsg}
\newcommand{\thanksinfo}[1]{\gdef\lh@thanks{#1}}

\def\lh@classification@student@short{}
\newcommand{\lectureshortname}[1]{\gdef\lh@classification@student@short{#1}}

\def\lh@classification@student@long{}
\newcommand{\lecturelongname}[1]{\gdef\lh@classification@student@long{#1}}

\newcommand{\ContactFrame}[1]{%
  \@tempdima=\paperwidth%
  \advance\@tempdima by -6mm%
  \@tempdimb=\paperheight%
%  \advance\@tempdimb by -26mm%
  \advance\@tempdimb by -\baselineskip%
  \advance\@tempdimb by -\baselineskip%
  \advance\@tempdimb by -\baselineskip%
  \advance\@tempdimb by -\baselineskip%
  \advance\@tempdimb by -\baselineskip%
  \advance\@tempdimb by -2mm%
  
\begin{frame}[plain]
  \begin{beamercolorbox}[ht=3mm,sep=0cm,wd=\@tempdima]{titlerule}
  \end{beamercolorbox}
  \begin{minipage}[][\@tempdimb][t]{\@tempdima}
  % \begin{beamercolorbox}[sep=0.2cm,wd=\@tempdima]{footer}
  #1%
  % \end{beamercolorbox}
\end{minipage}
\begin{beamercolorbox}[sep=0.2cm,wd=\@tempdima]{footer}
  \raggedright
  \rlap{\noindent\small\textbf{\,\,\,\,Contact:}}%
  {\footnotesize
    \hfill\begin{minipage}[t]{.45\@tempdima}\raggedleft
      \hfill\lh@contactauthor\\
      Department of Computer Science\\
      University of Exeter\\
      Streatham Campus\\
      Exeter, EX4 4QF, UK
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.45\@tempdima}
      \ifthenelse{\equal{\lh@contactemail}{}}{}{\faEnvelopeSquare~\href{mailto:\lh@contactemail}{\lh@contactemail}\\}
      \ifthenelse{\equal{\lh@contacttwitter}{}}{}{\faTwitterSquare~\href{https://twitter.com/in/\lh@contacttwitter/}{@\lh@contacttwitter}\\}
      \ifthenelse{\equal{\lh@contactlinkedin}{}}{}{\faLinkedinSquare~\url{\lh@contactlinkedin}\\}
      \ifthenelse{\equal{\lh@contactwww}{}}{}{\faExternalLinkSquare~\url{\lh@contactwww}\\}
      \ifthenelse{\equal{\lh@contactblog}{}}{}{\faRssSquare~\url{\lh@contactblog}}
    \end{minipage}\hfill}
\end{beamercolorbox}
  \begin{beamercolorbox}[ht=0mm,sep=.2cm,wd=\@tempdima]{}
{\setlength{\unitlength}{1em}\begin{picture}(0,0)
\put(0,1.2){\href{https://logicalhacking.com}{\lhSmallLogoDark[width=8mm]}}
\end{picture}}
\end{beamercolorbox}
\end{frame}
}



\newcommand{\ThanksFrame}{%
  \ContactFrame{\vfil\centering \lh@thanks\vfil}
}

\newcommand{\KeyTakeAwayFrame}[1]{%
  \ContactFrame{%
    \medskip
    \begin{columns}
      \begin{column}{.18\paperwidth}
      \end{column}
      \begin{column}{.695\paperwidth}
        \;\textbf{\large\alert{Key Take-Aways}}\\[-.2\baselineskip]
        {\color{lhDarkGray}%
        \parbox{0pt}{\rule{0.69\paperwidth}{.3pt}}}
    \end{column}
      \begin{column}{.005\paperwidth}
      \end{column}
    \end{columns}
    \smallskip
    \begin{columns}
      \begin{column}{.2\paperwidth}
        \includegraphics[width=.9\columnwidth]{lh-bulb}
      \end{column}
      \begin{column}{.695\paperwidth}
        #1
      \end{column}
      \begin{column}{.005\paperwidth}
      \end{column}
    \end{columns} 
  }
}



\DeclareDocumentCommand{\PartFrame}{ O{red} O{lhWhite} m }{%
  \setbeamercolor{footer}{fg=#1, bg=#2}
  \bgroup
  \part{#3}
  \frame{\partpage}
  \egroup
}

\newsavebox{\@tempsboxa}
\newsavebox{\@tempsboxb}
\newlength{\@tempdimd}
\newenvironment{kickerbox}[1][]
{%
  \@tempdima=\textwidth%
  \advance\@tempdima by -8mm%
  \advance\@tempdima by -4mm%   
  % 
  \sbox{\@tempsboxb}{\parbox{4mm}{#1}}%
  % 
  \begin{lrbox}{\@tempsboxa}%
    \begin{minipage}{\the\@tempdima}%
}{%
\end{minipage}%
\end{lrbox}%
  \settowidth{\@tempdima}{\usebox{\@tempsboxa}}
  \advance\@tempdima by .4cm%
  \settoheight{\@tempdimb}{\usebox{\@tempsboxa}}
  \settodepth{\@tempdimc}{\usebox{\@tempsboxa}}
  \advance\@tempdimb by .4cm%
  \advance\@tempdimb by \the\@tempdimc%
  %
  \@tempdimc=\@tempdimb%
  \settodepth{\@tempdimd}{\usebox{\@tempsboxb}}
  \advance\@tempdimc by -\@tempdimd
  \settodepth{\@tempdimd}{\usebox{\@tempsboxb}}
  \advance\@tempdimc by -\@tempdimd
\advance\@tempdimc by -.6cm

  \smallskip
  \begin{columns}[onlytextwidth]
    \begin{column}[t]{7mm}
    \begin{beamercolorbox}[sep=.1cm,wd=8mm,ht=\the\@tempdimb]{palette secondary}
     \usebox{\@tempsboxb}\vspace{\the\@tempdimc}%
   \end{beamercolorbox}
    \end{column}
     \begin{column}[t]{\the\@tempdima}
       \begin{beamercolorbox}[sep=0.2cm,wd=\the\@tempdima,ht=\the\@tempdimb]{kicker}%
         \usebox{\@tempsboxa}%
       \end{beamercolorbox}%
     \end{column}
   \end{columns}
   \smallskip
}

\newenvironment{quotebox}
{\begin{kickerbox}[{\Huge\textbf{\usebeamercolor[bg]{kicker}{\,``}}}]}
  {\end{kickerbox}}

\newcommand{\partnerLogo}[1][]{}

\NewEnviron{abstractframe}[1][]{%
\begin{frame}<beamer:0>[plain,label={fra:abstract-en},#1]
     \centerline{\emph{\inserttitle: \insertsubtitle}}
    \bigskip\begin{abstract}\footnotesize
    \BODY
  \end{abstract}\end{frame}
}

\institute[University of Exeter]{%
  \textbf{Software Assurance \& Security Research}\\
  Department of Computer
  Science, University of Exeter, Exeter, UK\\
  \hspace{.6cm} \href{https://logicalhacking.com/}{https://logicalhacking.com/} }



\endinput

