\section{KMime\-Magic Class Reference}
\label{classKMimeMagic}\index{KMimeMagic@{KMimeMagic}}
{\bf This class or method is obsolete, it is provided for compatibility only.} Use {\bf KMime\-Type::find\-By\-Content()}{\rm (p.\,\pageref{classKMimeType_e6})} 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.  


{\tt \#include $<$kmimemagic.h$>$}

Collaboration diagram for KMime\-Magic:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=120pt]{classKMimeMagic__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KMime\-Magic} ()
\begin{CompactList}\small\item\em 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. \item\end{CompactList}\item 
{\bf KMime\-Magic} (const  {\bf QString} \&config\-File)
\begin{CompactList}\small\item\em Create a parser and initialize it with the given config file. \item\end{CompactList}\item 
{\bf $\sim$KMime\-Magic} ()
\begin{CompactList}\small\item\em Destroy the parser. \item\end{CompactList}\item 
bool {\bf merge\-Config} (const  {\bf QString} \&config\-File)
\begin{CompactList}\small\item\em Merge an existing parse table with the data from the given file. \item\end{CompactList}\item 
bool {\bf merge\-Buf\-Config} (char $\ast$)
\begin{CompactList}\small\item\em Merge an existing parse table with the data from the given buffer. \item\end{CompactList}\item 
void {\bf set\-Follow\-Links} (bool \_\-enable)
\begin{CompactList}\small\item\em Enable/Disable follow-links. \item\end{CompactList}\item 
{\bf KMime\-Magic\-Result} $\ast$ {\bf find\-File\-Type} (const  {\bf QString} \&\_\-filename)
\begin{CompactList}\small\item\em Try to find a Mime\-Type for the given file. \item\end{CompactList}\item 
{\bf KMime\-Magic\-Result} $\ast$ {\bf find\-Buffer\-Type} (const  {\bf QByte\-Array} \&p)
\begin{CompactList}\small\item\em Same functionality as above, except data is not read from a file. \item\end{CompactList}\item 
{\bf KMime\-Magic\-Result} $\ast$ {\bf find\-Buffer\-File\-Type} (const  {\bf QByte\-Array} \&, const  {\bf QString} \&filename)
\begin{CompactList}\small\item\em Same functionality as {\bf find\-Buffer\-Type}{\rm (p.\,\pageref{classKMimeMagic_a7})}() but with additional capability of distinguishing between C-headers and C-Source. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KMime\-Magic} $\ast$ {\bf self} ()
\begin{CompactList}\small\item\em Returns a pointer to the unique KMime\-Magic instance in this process. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Protected Member Functions}
\begin{CompactItemize}
\item 
void {\bf init\-Static} ()\label{classKMimeMagic_f0}

\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
{\bf KMime\-Magic\-Result} $\ast$ {\bf magic\-Result}
\begin{CompactList}\small\item\em The result type. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Protected Attributes}
\begin{CompactItemize}
\item 
{\bf KMime\-Magic} $\ast$ {\bf s\_\-p\-Self} = 0L\label{classKMimeMagic_t0}

\end{CompactItemize}


\subsection{Detailed Description}
{\bf This class or method is obsolete, it is provided for compatibility only.} Use {\bf KMime\-Type::find\-By\-Content()}{\rm (p.\,\pageref{classKMimeType_e6})} 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. 

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 100 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 2045 of file kmimemagic.cpp.

References KGlobal::dirs(), KStandard\-Dirs::find\-All\-Resources(), 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 2057 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 2086 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 2103 of file kmimemagic.cpp.

References QString::is\-Empty().

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 2121 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 2138 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 2201 of file kmimemagic.cpp.

References magic\-Result, KMime\-Magic\-Result::set\-Accuracy(), KMime\-Magic\-Result::set\-Invalid(), KMime\-Magic\-Result::set\-Mime\-Type(), and QString::strip\-White\-Space().

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 2144 of file kmimemagic.cpp.

References magic\-Result, KMime\-Magic\-Result::set\-Accuracy(), KMime\-Magic\-Result::set\-Invalid(), KMime\-Magic\-Result::set\-Mime\-Type(), and QString::strip\-White\-Space().

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 2190 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 30 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 196 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}
