\section{KMime\-Magic Class Reference}
\label{classKMimeMagic}\index{KMimeMagic@{KMimeMagic}}
{\tt \#include $<$kmimemagic.h$>$}

Collaboration diagram for KMime\-Magic:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=106pt]{classKMimeMagic__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KMime\-Magic} ()
\item 
{\bf KMime\-Magic} (const {\bf QString} \&config\-File)
\item 
{\bf $\sim$KMime\-Magic} ()
\item 
bool {\bf merge\-Config} (const {\bf QString} \&config\-File)
\item 
bool {\bf merge\-Buf\-Config} (char $\ast$)
\item 
void {\bf set\-Follow\-Links} (bool \_\-enable)
\item 
{\bf KMime\-Magic\-Result} $\ast$ {\bf find\-File\-Type} (const {\bf QString} \&\_\-filename)
\item 
{\bf KMime\-Magic\-Result} $\ast$ {\bf find\-Buffer\-Type} (const {\bf QByte\-Array} \&p)
\item 
{\bf KMime\-Magic\-Result} $\ast$ {\bf find\-Buffer\-File\-Type} (const {\bf QByte\-Array} \&, const {\bf QString} \&filename)
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static {\bf KMime\-Magic} $\ast$ {\bf self} ()
\end{CompactItemize}
\subsection*{Static Protected Member Functions}
\begin{CompactItemize}
\item 
static void {\bf init\-Static} ()\label{classKMimeMagic_f0}

\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
{\bf KMime\-Magic\-Result} $\ast$ {\bf magic\-Result}
\end{CompactItemize}
\subsection*{Static Protected Attributes}
\begin{CompactItemize}
\item 
static {\bf KMime\-Magic} $\ast$ {\bf s\_\-p\-Self}\label{classKMimeMagic_t0}

\end{CompactItemize}


\subsection{Detailed Description}
\begin{Desc}
\item[{\bf Deprecated}]Use {\bf KMime\-Type::find\-By\-Content()}{\rm (p.\,\pageref{classKMimeType_e7})} instead May be removed in {\bf KDE} 4.0. Determine auto-magically the type of file, not only by using its extension, but also by reading its contents. \end{Desc}


Unless specified otherwise, KMime\-Magic uses \$KDEDIR/share/mimelnk/magic for this purpose.

To make KMime\-Magic restore the 'atime' of a file after it opened it, add its directory in kmimemagicrc like: [Settings] atime\-Dirs=/tmp,/var/tmp,/home/dfaure/tmp This isn't done by default because it changes the 'ctime'. See {\bf kmimemagic.cpp}{\rm (p.\,\pageref{kmimemagic_8cpp})} for a full discussion on this issue.

The basic usage of KMime\-Magic is : \begin{itemize}
\item Get a pointer to it, using {\bf KMime\-Magic::self()}{\rm (p.\,\pageref{classKMimeMagic_e0})}. \item Use it for any file or buffer you want, using one of the three {\tt find}...Type() methods.\end{itemize}
The result is contained in the class {\bf KMime\-Magic\-Result}{\rm (p.\,\pageref{classKMimeMagicResult})}. 



Definition at line 101 of file kmimemagic.h.

\subsection{Constructor \& Destructor Documentation}
\index{KMimeMagic@{KMime\-Magic}!KMimeMagic@{KMimeMagic}}
\index{KMimeMagic@{KMimeMagic}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KMime\-Magic::KMime\-Magic ()}\label{classKMimeMagic_a0}


Create a parser and initialize it with the KDE-global data: the \char`\"{}magic\char`\"{} config file as well as the snippets from share/config/magic. 

\begin{Desc}
\item[Since:]3.1 \end{Desc}


Definition at line 2113 of file kmimemagic.cpp.

References KGlobal::dirs(), endl(), KStandard\-Dirs::find\-All\-Resources(), k\_\-funcinfo, kd\-Warning(), locate(), and merge\-Config().\index{KMimeMagic@{KMime\-Magic}!KMimeMagic@{KMimeMagic}}
\index{KMimeMagic@{KMimeMagic}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KMime\-Magic::KMime\-Magic (const {\bf QString} \& {\em config\-File})}\label{classKMimeMagic_a1}


Create a parser and initialize it with the given config file. 



Definition at line 2125 of file kmimemagic.cpp.\index{KMimeMagic@{KMime\-Magic}!~KMimeMagic@{$\sim$KMimeMagic}}
\index{~KMimeMagic@{$\sim$KMimeMagic}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KMime\-Magic::$\sim${\bf KMime\-Magic} ()}\label{classKMimeMagic_a2}


Destroy the parser. 



Definition at line 2154 of file kmimemagic.cpp.

References magic\-Result.

\subsection{Member Function Documentation}
\index{KMimeMagic@{KMime\-Magic}!mergeConfig@{mergeConfig}}
\index{mergeConfig@{mergeConfig}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KMime\-Magic::merge\-Config (const {\bf QString} \& {\em config\-File})}\label{classKMimeMagic_a3}


Merge an existing parse table with the data from the given file. 

\begin{Desc}
\item[Returns:]{\tt true} on success. \end{Desc}


Definition at line 2171 of file kmimemagic.cpp.

References endl(), k\_\-funcinfo, and kd\-Debug().

Referenced by KMime\-Magic().\index{KMimeMagic@{KMime\-Magic}!mergeBufConfig@{mergeBufConfig}}
\index{mergeBufConfig@{mergeBufConfig}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KMime\-Magic::merge\-Buf\-Config (char $\ast$)}\label{classKMimeMagic_a4}


Merge an existing parse table with the data from the given buffer. 

\begin{Desc}
\item[Returns:]{\tt true} on success. \end{Desc}


Definition at line 2189 of file kmimemagic.cpp.\index{KMimeMagic@{KMime\-Magic}!setFollowLinks@{setFollowLinks}}
\index{setFollowLinks@{setFollowLinks}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KMime\-Magic::set\-Follow\-Links (bool {\em \_\-enable})}\label{classKMimeMagic_a5}


Enable/Disable follow-links. 

(Default is disabled.) 

Definition at line 2206 of file kmimemagic.cpp.\index{KMimeMagic@{KMime\-Magic}!findFileType@{findFileType}}
\index{findFileType@{findFileType}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KMime\-Magic\-Result} $\ast$ KMime\-Magic::find\-File\-Type (const {\bf QString} \& {\em \_\-filename})}\label{classKMimeMagic_a6}


Try to find a Mime\-Type for the given file. 

If no special Mime\-Type is found, the default Mime\-Type is returned. This function looks at the content of the file.

\begin{Desc}
\item[Returns:]A pointer to the result object. Do {\em not\/} delete the result object. After another call to KMime\-Magic the returned result object changes its value since it is reused by KMime\-Magic. \end{Desc}


Definition at line 2279 of file kmimemagic.cpp.

References KMime\-Magic\-Result::accuracy(), endl(), kd\-Debug(), magic\-Result, KMime\-Magic\-Result::set\-Accuracy(), KMime\-Magic\-Result::set\-Invalid(), and KMime\-Magic\-Result::set\-Mime\-Type().

Referenced by KMime\-Type::find\-By\-File\-Content(), and KMime\-Type::find\-By\-URL().\index{KMimeMagic@{KMime\-Magic}!findBufferType@{findBufferType}}
\index{findBufferType@{findBufferType}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KMime\-Magic\-Result} $\ast$ KMime\-Magic::find\-Buffer\-Type (const {\bf QByte\-Array} \& {\em p})}\label{classKMimeMagic_a7}


Same functionality as above, except data is not read from a file. 

Instead a buffer can be supplied which is examined.

\begin{Desc}
\item[Returns:]A pointer to the result object. Do {\em not\/} delete the result object. After another call to KMime\-Magic the returned result object changes its value since it is reused by KMime\-Magic. \end{Desc}


Definition at line 2212 of file kmimemagic.cpp.

References KMime\-Magic\-Result::accuracy(), magic\-Result, KMime\-Magic\-Result::set\-Accuracy(), KMime\-Magic\-Result::set\-Invalid(), and KMime\-Magic\-Result::set\-Mime\-Type().

Referenced by find\-Buffer\-File\-Type(), and KMime\-Type::find\-By\-Content().\index{KMimeMagic@{KMime\-Magic}!findBufferFileType@{findBufferFileType}}
\index{findBufferFileType@{findBufferFileType}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KMime\-Magic\-Result} $\ast$ KMime\-Magic::find\-Buffer\-File\-Type (const {\bf QByte\-Array} \&, const {\bf QString} \& {\em filename})}\label{classKMimeMagic_a8}


Same functionality as {\bf find\-Buffer\-Type()}{\rm (p.\,\pageref{classKMimeMagic_a7})} but with additional capability of distinguishing between C-headers and C-Source. 

For this purpose this function looks at the extension of the filename. This means that 'filename' can be a filename on some FTP server, too.

\begin{Desc}
\item[Returns:]A pointer to the result object. Do {\em not\/} delete the result object. After another call to KMime\-Magic the returned result object changes its value since it is reused by KMime\-Magic. \end{Desc}


Definition at line 2268 of file kmimemagic.cpp.

References find\-Buffer\-Type().\index{KMimeMagic@{KMime\-Magic}!self@{self}}
\index{self@{self}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KMime\-Magic} $\ast$ KMime\-Magic::self ()\hspace{0.3cm}{\tt  [static]}}\label{classKMimeMagic_e0}


Returns a pointer to the unique KMime\-Magic instance in this process. 



Definition at line 41 of file kmimemagic.cpp.

Referenced by KMime\-Type::find\-By\-Content(), KMime\-Type::find\-By\-File\-Content(), and KMime\-Type::find\-By\-URL().

\subsection{Member Data Documentation}
\index{KMimeMagic@{KMime\-Magic}!magicResult@{magicResult}}
\index{magicResult@{magicResult}!KMimeMagic@{KMime\-Magic}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KMime\-Magic\-Result}$\ast$ {\bf KMime\-Magic::magic\-Result}\hspace{0.3cm}{\tt  [protected]}}\label{classKMimeMagic_p0}


The result type. 



Definition at line 197 of file kmimemagic.h.

Referenced by find\-Buffer\-Type(), find\-File\-Type(), and $\sim$KMime\-Magic().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
kmimemagic.h\item 
kmimemagic.cpp\end{CompactItemize}
