KVIrc  4.9.2
DeveloperAPIs
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
KviPackageWriter Class Reference

This class is used to create KVIrc package files. More...

#include <KviPackageWriter.h>

+ Inheritance diagram for KviPackageWriter:

Public Types

enum  AddFileFlags { NoCompression = 1, FollowSymLinks = 2 }
 
enum  PackFlags { NoProgressDialog = 1 }
 

Public Member Functions

bool addDirectory (const QString &szLocalDirectoryName, const QString &szTargetDirectoryPrefix, kvi_u32_t uAddFileFlags=0)
 Adds a directory to the package. More...
 
bool addFile (const QString &szLocalFileName, const QString &szTargetFileName, kvi_u32_t uAddFileFlags=0)
 Adds a file to the package. More...
 
void addInfoField (const QString &szName, const QString &szValue)
 Adds an info field as a name=value pair. More...
 
void addInfoField (const QString &szName, QByteArray *pArray)
 Adds an info field as a name=value pair. More...
 
 KviPackageWriter ()
 Creates the package writer object. More...
 
bool pack (const QString &szFileName, kvi_u32_t uPackFlags=0)
 Attempts to pack everything and store it as the specified file. More...
 
virtual ~KviPackageWriter ()
 Destroys the object. More...
 
- Public Member Functions inherited from KviPackageIOEngine
KviPointerHashTable< QString,
QByteArray > * 
binaryInfoFields ()
 Returns the binary info fields. More...
 
 KviPackageIOEngine ()
 Creates the I/O engine object. More...
 
const QString & lastError ()
 Returns the last error. More...
 
KviPointerHashTable< QString,
QString > * 
stringInfoFields ()
 Returns the string info fields. More...
 
virtual ~KviPackageIOEngine ()
 Destroys the object. More...
 

Private Member Functions

bool addFileInternal (const QFileInfo *fi, const QString &szLocalFileName, const QString &szTargetFileName, kvi_u32_t uAddFileFlags=0)
 Adds a file to the package. More...
 
bool packFile (KviFile *pFile, KviPackageWriterDataField *pDataField)
 Attempts to pack everything and store it as the specified file. More...
 
bool packInternal (const QString &szFileName, kvi_u32_t uPackFlags=0)
 Attempts to pack everything and store it as the specified file. More...
 

Private Attributes

KviPackageWriterPrivatem_p
 

Additional Inherited Members

- Protected Member Functions inherited from KviPackageIOEngine
void hideProgressDialog ()
 Hides the progress dialog. More...
 
bool readError ()
 Sets the last error as read error. More...
 
void setLastError (const QString &szLastError)
 Sets the last error. More...
 
void showProgressDialog (const QString &szCaption, int iTotalSteps)
 Shows the progress dialog. More...
 
bool updateProgress (int iProgress, const QString &szLabel)
 Updates the progress dialog. More...
 
bool writeError ()
 Sets the last error as write error. More...
 

Detailed Description

This class is used to create KVIrc package files.

You simply instantiate it, add some info fields, add some files and then call pack().

Member Enumeration Documentation

Enumerator
NoCompression 

If you don't want to compress the file

FollowSymLinks 

If you want to follow the symlinks

Enumerator
NoProgressDialog 

If you want to avoid the progress dialog

Constructor & Destructor Documentation

KviPackageWriter::KviPackageWriter ( )

Creates the package writer object.

Returns
KviPackageWriter

References m_p, KviPackageWriterPrivate::pDataFields, and KviPointerList< T >::setAutoDelete().

KviPackageWriter::~KviPackageWriter ( )
virtual

Destroys the object.

References m_p, and KviPackageWriterPrivate::pDataFields.

Member Function Documentation

bool KviPackageWriter::addDirectory ( const QString &  szLocalDirectoryName,
const QString &  szTargetDirectoryPrefix,
kvi_u32_t  uAddFileFlags = 0 
)

Adds a directory to the package.

Parameters
szLocalDirectoryNameThe source directory
szTargetDirectoryPrefixThe destination directory
uAddFileFlagsThe flags of the directory
Returns
bool

References addFileInternal(), d, KviQString::ensureLastCharIs(), KviQString::equalCS(), FollowSymLinks, j, and KVI_PATH_SEPARATOR_CHAR.

Referenced by AddonFunctions::pack(), and ThemeFunctions::packageThemes().

bool KviPackageWriter::addFile ( const QString &  szLocalFileName,
const QString &  szTargetFileName,
kvi_u32_t  uAddFileFlags = 0 
)

Adds a file to the package.

The file must be specified as absolute local path and as target path relative to the KVIrc local directory. This is a shortcut to addFileInternal() ... more ?

Parameters
szLocalFileNameThe source file
szTargetFileNameThe destination file
uAddFileFlagsThe flags of the file
Returns
bool

References addFileInternal().

Referenced by AddonFunctions::pack().

bool KviPackageWriter::addFileInternal ( const QFileInfo *  fi,
const QString &  szLocalFileName,
const QString &  szTargetFileName,
kvi_u32_t  uAddFileFlags = 0 
)
private

Adds a file to the package.

This is the real addFile() function

Parameters
fiTHe information of the file
szLocalFileNameThe source file
szTargetFileNameThe destination file
uAddFileFlagsThe flags of the file
Returns
bool

References KviPointerList< T >::append(), f, FollowSymLinks, KVI_PACKAGE_DATAFIELD_TYPE_FILE, KviPackageWriterDataField::m_bFileAllowCompression, m_p, KviPackageWriterDataField::m_szFileLocalName, KviPackageWriterDataField::m_szFileTargetName, KviPackageWriterDataField::m_uType, NoCompression, and KviPackageWriterPrivate::pDataFields.

Referenced by addDirectory(), and addFile().

void KviPackageWriter::addInfoField ( const QString &  szName,
const QString &  szValue 
)

Adds an info field as a name=value pair.

Parameters
szNameThe name of the info field
szValueThe value of the info field
Returns
void

References KviPointerHashTable< Key, T >::replace(), and KviPackageIOEngine::stringInfoFields().

Referenced by AddonFunctions::pack(), and ThemeFunctions::packageThemes().

void KviPackageWriter::addInfoField ( const QString &  szName,
QByteArray *  pArray 
)

Adds an info field as a name=value pair.

Parameters
szNameThe name of the info field
pArrayThe value of the info field
Returns
void

References KviPackageIOEngine::binaryInfoFields(), and KviPointerHashTable< Key, T >::replace().

bool KviPackageWriter::pack ( const QString &  szFileName,
kvi_u32_t  uPackFlags = 0 
)

Attempts to pack everything and store it as the specified file.

This is a shortcut to packInternal() hiding the progress dialog There is no mandatory extension but you should use KVI_FILEEXTENSION_THEMEPACKAGE for themes and KVI_FILEEXTENSION_ADDONPACKAGE for addons. See kvi_fileextension.h

Parameters
szFileNameThe file name of the package
uPackFlagsThe flags of the package
Returns
bool

References __tr2qs, KviPackageIOEngine::hideProgressDialog(), KviPackageWriterPrivate::iCurrentProgress, m_p, NoProgressDialog, packInternal(), KviPackageIOEngine::showProgressDialog(), and KviPackageIOEngine::updateProgress().

Referenced by AddonFunctions::pack(), and ThemeFunctions::packageThemes().

bool KviPackageWriter::packFile ( KviFile pFile,
KviPackageWriterDataField pDataField 
)
private
bool KviPackageWriter::packInternal ( const QString &  szFileName,
kvi_u32_t  uPackFlags = 0 
)
private

Member Data Documentation

KviPackageWriterPrivate* KviPackageWriter::m_p
private

The documentation for this class was generated from the following files: